Skip to main content

caixa_core/
dep.rs

1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17///  :versao "^0.1"
18///  :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22///  :versao "*"
23///  :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27///  :versao "0.1.0"
28///  :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33    /// Caixa name — must match the target caixa's `:nome`.
34    pub nome: String,
35
36    /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37    pub versao: String,
38
39    /// Where to fetch the caixa from. Defaults to the feira registry.
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub fonte: Option<DepSource>,
42
43    /// If true, a missing `:fonte` is not a build failure.
44    #[serde(default, skip_serializing_if = "is_false")]
45    pub opcional: bool,
46
47    /// Feature flags to enable on the target caixa.
48    #[serde(default, skip_serializing_if = "Vec::is_empty")]
49    pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81    /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82    /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83    /// or any git-ssh URL.
84    Git {
85        repo: String,
86        #[serde(default, skip_serializing_if = "Option::is_none")]
87        tag: Option<String>,
88        #[serde(default, skip_serializing_if = "Option::is_none")]
89        rev: Option<String>,
90        #[serde(default, skip_serializing_if = "Option::is_none")]
91        branch: Option<String>,
92    },
93    /// Local filesystem path — dev only; cannot be published.
94    Path { caminho: String },
95}
96
97impl DepSource {
98    /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99    ///
100    /// This is the resolver-side fallback for `dep.fonte: None`, not an
101    /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102    /// all `None`) and is therefore rejected by [`Self::validate`]. The
103    /// resolver fills the pin in at fetch time from the resolved commit;
104    /// authors never serialize this shape as a `Dep::fonte` value.
105    #[must_use]
106    pub fn default_github(org: &str, nome: &str) -> Self {
107        Self::Git {
108            repo: format!("github:{org}/{nome}"),
109            tag: None,
110            rev: None,
111            branch: None,
112        }
113    }
114
115    /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116    /// every consumer that reads "which single git ref does this source
117    /// resolve to?" keys off — returns the author-declared `:tag` /
118    /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119    /// borrowed from the typed slot's own `Option<String>` storage; `None`
120    /// on [`Self::Path`] (a path source carries no git-ref) and on a
121    /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122    /// `None` (the [`Self::default_github`] shorthand shape the resolver
123    /// materializes when the author omits `:fonte` — rejected by
124    /// [`Self::validate`], but the accessor's return is defined on this
125    /// arm too so pre-validate consumers reach for the same typed dispatch
126    /// as post-validate ones).
127    ///
128    /// **Precedence: rev > tag > branch.** The canonical precedence every
129    /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130    /// per-fetch `git checkout <ref>` reads through the same
131    /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132    /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133    /// through the same cascade at caixa-crd/src/conversion.rs. The
134    /// [`Self::validate`] gate enforces "exactly one pin set" — under
135    /// that invariant every accepted [`Self::Git`] carries exactly one
136    /// non-`None` pin and the precedence is unobservable, but the
137    /// precedence remains defined for pre-validate consumers (the
138    /// resolver's `MissingPin` diagnostic path, the caixa-crd
139    /// round-trip's default `"main"` fallback the author never sees a
140    /// diagnostic on) and defense-in-depth for a hypothetical future
141    /// state where multiple pins survive the gate. The precedence is
142    /// **rev before tag** because `:rev` (a git commit OID) is the
143    /// reproducibility-strongest identifier — an OID resolves to exactly
144    /// one commit regardless of which refname points at it, whereas
145    /// `:tag` and `:branch` are refnames the remote can silently move
146    /// (a tag re-push, a branch head advance); the resolver's freeze
147    /// step at fetch time promotes the resolved commit to `:rev` for
148    /// exactly this reason. **Tag before branch** because `:tag` is
149    /// conventionally immutable (a release tag) whereas `:branch` is
150    /// conventionally mutable (a tracking ref) — a caixa carrying both
151    /// a release tag and a tracking branch reads as "prefer the release
152    /// pin, fall through to the tracking pin only if the release is
153    /// missing". The cascade order also matches the byte-order every
154    /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155    /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156    /// [`Self::validate`]'s `pins` array).
157    ///
158    /// Prior to this lift the "sole set pin" projection sat twice in the
159    /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160    /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161    /// { … })?;`) and at caixa-crd's `dep_into_ref`
162    /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163    /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164    /// of the same precedence cascade with no compile-time link back to
165    /// the typed slot. A future extension of the pin axis to a richer
166    /// author surface (a `:commit` pin peer of `:rev` once the substrate
167    /// grows a signed-commit-verification pin, a `:ref` pin the M4
168    /// substrate operator resolves per-cluster ahead of fetch, a
169    /// promotion of the plain `Option<String>` pins to a typed
170    /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171    /// once the sibling [`crate::render::is_git_oid`] /
172    /// [`crate::render::is_git_ref_name`] gates land as typed
173    /// constructors) would have had to be threaded through both
174    /// open-coded copies in lockstep or the resolver's `git checkout`
175    /// target would silently disagree with the CRD's `git_ref` fill —
176    /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177    /// "v1"))` would ship with the resolver checking out `deadbeef`
178    /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179    /// lacre closure disagreeing with the emitted K8s CR the operator
180    /// reads. Lifting the resolution to a typed method on the substrate
181    /// primitive means both downstream consumers reach for exactly one
182    /// typed dispatch — the resolver's accept-set migrates as a unit on
183    /// any future pin-axis addition.
184    ///
185    /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186    /// `Option<&DepSource>` composite-reference accessor on the outer-
187    /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188    /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189    /// git-fetching consumer runs after the outer `:fonte` slot resolves
190    /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191    /// substrate primitive, thin projections at each consumer" discipline
192    /// the outer accessor family already carries.
193    #[must_use]
194    pub fn sole_pin(&self) -> Option<&str> {
195        match self {
196            Self::Git {
197                tag, rev, branch, ..
198            } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199            Self::Path { .. } => None,
200        }
201    }
202
203    /// Validate the `:fonte` value-shape: every author-surface
204    /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205    /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206    /// value; every `:fonte (:tipo path …)` must carry a non-empty
207    /// `:caminho`.
208    ///
209    /// Called from [`Dep::validate`] with the dep's `:nome` so every
210    /// diagnostic carries the offending entry verbatim — same
211    /// self-locating shape the `:deps :versao` (2420c44),
212    /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213    /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214    /// (3f9d7a0) gates already expose.
215    ///
216    /// Until this gate landed `:fonte` was the only `:deps`-related
217    /// typed surface still untyped past `Caixa::from_lisp`:
218    /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219    ///   passed parse and surfaced as a git-clone failure at
220    ///   lacre-resolve time, far from the source caixa.lisp.
221    /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222    ///   passed parse and surfaced as the resolver's
223    ///   [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224    ///   at fetch time, again far from the source caixa.lisp; lifting
225    ///   to validate-time gives the author the same diagnostic at the
226    ///   edit site.
227    /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228    ///   pins set — passed parse and the resolver silently picked
229    ///   `:rev > :tag > :branch`, ignoring the other pins with no
230    ///   diagnostic; the author had no way to know their `:branch`
231    ///   was dropped. This is the canonical "pin drift" footgun.
232    /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233    ///   passed parse and surfaced as `git checkout ""` at fetch time.
234    /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235    ///   parse and surfaced as
236    ///   [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237    ///   with `path: PathBuf("")` — not actionable.
238    ///
239    /// Each rejected shape maps to a typed
240    /// [`DepError::Fonte*`] variant that names the offending
241    /// dep's `:nome` and the specific axis, so the author can grep
242    /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243    /// one edit.
244    pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245        match self {
246            Self::Git {
247                repo,
248                tag,
249                rev,
250                branch,
251            } => {
252                if repo.is_empty() {
253                    return Err(DepError::fonte_repo_empty(nome));
254                }
255                // The `:repo` value flows verbatim into the caixa-resolver's
256                // `git clone <repo>` subprocess invocation. Until this gate
257                // landed `:repo` was the last untyped `:fonte`-related axis
258                // past the empty arm: a malformed-but-non-empty repo URL
259                // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260                // `":repo "-upload-pack=evil""` leading `-` — the canonical
261                // CLI-argument-injection vector at the `git clone` boundary;
262                // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263                // reads as a relative filesystem path rather than the
264                // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265                // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266                // silently passed validate and the failure surfaced at
267                // lacre-resolve time with a porcelain-quoting-confused error
268                // far from the source caixa.lisp. The lifted predicate makes
269                // the git-porcelain-URL intersection-floor a substrate-level
270                // invariant at validate time, peer with the three pin axes
271                // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272                // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273                // — every `:fonte (:tipo git …)` past validate is now
274                // structurally accept-shaped on every axis the resolver
275                // consumes (the `:repo` URL the `git clone` invokes against,
276                // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277                // accepts, the `:rev` commit OID the lacre's content-
278                // addressing equality probe resolves), closing the
279                // `:fonte` slot's value-shape trajectory end-to-end.
280                if let Err(reason) = crate::render::is_git_repo_url(repo) {
281                    return Err(DepError::fonte_repo_shape(nome, repo, reason));
282                }
283                let pins: [(&'static str, Option<&String>); 3] = [
284                    (":tag", tag.as_ref()),
285                    (":rev", rev.as_ref()),
286                    (":branch", branch.as_ref()),
287                ];
288                let set: Vec<&'static str> =
289                    pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290                match set.len() {
291                    0 => {
292                        return Err(DepError::fonte_pin_missing(nome));
293                    }
294                    1 => {
295                        for (pin, value) in pins {
296                            if value.is_some_and(String::is_empty) {
297                                return Err(DepError::fonte_pin_empty(nome, pin));
298                            }
299                        }
300                    }
301                    _ => {
302                        return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303                    }
304                }
305                // Per-pin value-shape gate. The refname-shaped axes
306                // (`:tag` + `:branch`) route through
307                // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308                // `:rev` axis routes through
309                // [`crate::render::is_git_oid`]. The two predicates
310                // partition the `:fonte` pin axes structurally — refname
311                // vs. hex commit — so a cross-axis mis-slot (the
312                // canonical "I conflated `:rev` and `:branch`" footgun:
313                // `:rev "main"` defeating the reproducibility contract,
314                // `:tag "deadbeef…"` mis-slotting a SHA into the
315                // refname-shaped axis) lands at the offending axis's
316                // predicate, not at lacre-resolve `git fetch` /
317                // `git checkout` time. Their valid sets intersect at
318                // the empty set: every refname is rejected by
319                // `is_git_oid`, every OID is rejected by
320                // `is_git_ref_name`, structurally.
321                //
322                // Until this gate landed `:tag` / `:branch` were the
323                // refname-shaped axes still untyped past the empty-pin
324                // arm: a malformed-but-non-empty refname
325                // (`:tag "v0.1.0 "` trailing space — the canonical
326                // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327                // with git's atomic-rename guard suffix; `:tag "../escape"`
328                // path-traversal via consecutive dots; `:branch "main "`
329                // trailing space; `:branch "feature/foo bar"` embedded
330                // space; `:branch "@"` the literal HEAD alias;
331                // `:branch "refs/heads/main"` the fully-qualified ref
332                // copied from `git show-ref` output that resolves to
333                // a literal ref named `refs/heads/refs/heads/main` on
334                // disk) silently passed validate; the `:rev` axis was
335                // the last `:fonte`-related axis still untyped past the
336                // empty-pin arm: a malformed-but-non-empty hex-OID
337                // (`:rev "main"` conflating with `:branch` — the
338                // reproducibility-contract leak; `:rev "v0.1.0"`
339                // conflating with `:tag` — the same mis-slot on the
340                // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341                // 6-char prefix that's ambiguous across repo history;
342                // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343                // inconsistently against `git rev-parse HEAD`'s
344                // lowercase emission) silently passed validate and the
345                // failure surfaced at lacre-resolve `git fetch` /
346                // `git checkout` time with a quoting-confused error
347                // far from the source caixa.lisp, with no field naming
348                // which `:deps` entry carried the typo. Lifting both
349                // gates to caixa-build time matches the value-shape
350                // trajectory the peer typed axes already follow
351                // (c4213a4 typed WitContract endpoint/subject/slot;
352                // eb3456d :entrada :paths; c7d05ec :entrada :host;
353                // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354                // 63e18a0 :contratos :subject; 2f4316e :contratos
355                // :slot; e70d213 :fonte :tag + :branch) — the typed
356                // slot's valid set matches its downstream consumer's
357                // accepted set (here, the git porcelain's refname /
358                // commit-OID grammars at `git fetch` / `git checkout`
359                // time), structurally. Same diagnostic shape every
360                // per-axis value-shape lift already exposes
361                // (`*Invalid { axis, reason }`); the `value:` field
362                // carries the offending refname / OID verbatim so the
363                // author can grep their caixa.lisp for the
364                // `:tag "<value>"` / `:branch "<value>"` /
365                // `:rev "<value>"` literal and fix it in one edit.
366                for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367                    if let Some(v) = value
368                        && let Err(reason) = crate::render::is_git_ref_name(v)
369                    {
370                        return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371                    }
372                }
373                if let Some(v) = rev.as_ref()
374                    && let Err(reason) = crate::render::is_git_oid(v)
375                {
376                    return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377                }
378                Ok(())
379            }
380            Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381        }
382    }
383
384    /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385    /// `:caminho` axis. Walks the leading-byte cascade closed by the
386    /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387    /// orthogonal embedded-control-byte arm (d624c8d) covering
388    /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389    /// embedded-`\` Windows-path-separator arm closing the
390    /// cross-host-OS-separator divergence vector on the same
391    /// THEORY.md §V.2 render-determinism axis.
392    ///
393    /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394    /// per-arm cascade now spans nine diagnostic shapes — every new
395    /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396    /// a future glob-metachar `*` / `?` arm) lands here rather than
397    /// re-inflating `Self::validate`. The
398    /// function stays a thin per-arm linear walk for one reason: each
399    /// arm's diagnostic carries a distinct typed [`DepError`] variant
400    /// rather than a parser-shaped `reason` string, so collapsing the
401    /// cascade onto a generic [`crate::render`] predicate would regress
402    /// the per-arm self-locating diagnostic that `feira lint` consumers
403    /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404    /// [`crate::render::is_git_repo_url`], etc.) lives on the
405    /// reason-string-shaped axes; the `:caminho` axis keeps its
406    /// per-arm variant shape.
407    #[allow(
408        clippy::too_many_lines,
409        reason = "the per-arm cascade is structurally flat by design — every \
410                  `:caminho` arm carries its own typed [`DepError`] variant + \
411                  per-arm Why comment, so collapsing the cascade onto a generic \
412                  [`crate::render`] predicate would regress the per-arm self-locating \
413                  diagnostic the `feira lint` consumer surface depends on"
414    )]
415    fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416        if caminho.is_empty() {
417            return Err(DepError::fonte_caminho_empty(nome));
418        }
419        // Reproducibility gate on the `:fonte (:tipo path …)`
420        // `:caminho` axis. The lacre pipeline embeds the value
421        // verbatim in its per-dep content-address
422        // (`conteudo: format!("path:{caminho}")`,
423        // caixa-resolver/src/resolve.rs:189) and that string
424        // folds into the BLAKE3 closure the lacre keys every
425        // downstream consumer (the substrate's reproducibility
426        // contract, CAIXA-SDLC §III.2 — the lacre is the
427        // build's content-addressed identity, peer of the Nix
428        // store path) against. Until this gate landed an
429        // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430        // canonical "I dragged the folder out of Finder into
431        // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432        // the macOS path-layout peer; the
433        // `${WORKSPACE}/caixa-teia` shell-expanded literal
434        // pasted from a CI manifest) silently passed validate
435        // and the failure surfaced *as a successful build with
436        // a divergent lacre*: the BLAKE3 closure on Alice's
437        // workstation differed from the closure on Bob's
438        // workstation, two CI runners with different
439        // `${HOME}` layouts emitted two distinct
440        // content-addresses for the byte-identical caixa, and
441        // the substrate's "the lacre is the build's identity"
442        // contract silently broke far from the source
443        // caixa.lisp — the most insidious failure mode the
444        // typed slot can carry (no error surfaces; the
445        // divergence is invisible until two machines compare
446        // lacres). The same THEORY.md §V.2 render-determinism
447        // discipline `is_sandboxed_relative_path` already
448        // applies on the M2 typed path-slots
449        // (`:behavior :on-*`, `:upgrade-from :state-change
450        // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451        // narrowed to the absolute-vs-relative axis only:
452        // `:fonte :caminho`'s canonical author-surface form is
453        // the `..`-traversing sibling-workspace path
454        // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455        // full `is_sandboxed_relative_path` lift would
456        // structurally reject every legitimate path-fonte
457        // dep. The narrower
458        // `std::path::Path::is_absolute` cut admits the
459        // sibling-workspace form while still rejecting the
460        // host-layout-leaking absolute shape — the
461        // reproducibility contract bites at exactly the
462        // absolute boundary, and that's the axis the
463        // substrate-level invariant is meant to hold. Same
464        // diagnostic shape every per-axis value-shape lift on
465        // the surrounding [`DepError::Fonte*`] cluster carries
466        // (the offending `:nome` + offending `:caminho`
467        // quoted verbatim so the author can grep their
468        // caixa.lisp for the `:caminho "<value>"` literal and
469        // fix it in one edit). The empty arm strictly
470        // precedes this arm so the blank-string footgun
471        // surfaces the more self-locating
472        // `FonteCaminhoEmpty` diagnostic (the empty string
473        // is not absolute under `Path::new("").is_absolute()`
474        // so the precedence is a no-op at value level — the
475        // pin matters only at the diagnostic-shape level if
476        // a future codec round-trip ever produces an empty
477        // string that probes as absolute).
478        if std::path::Path::new(caminho).is_absolute() {
479            return Err(DepError::fonte_caminho_absolute(nome, caminho));
480        }
481        // Reproducibility gate's tilde-expansion arm. The b94fd83
482        // `FonteCaminhoAbsolute` closes the leading-`/`
483        // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484        // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485        // doc footgun) silently passed both the empty arm and
486        // the absolute arm because `Path::new("~").is_absolute()`
487        // returns `false` — `~` is a shell-expansion convention,
488        // not a POSIX path component, so `std::path::Path` treats
489        // it as a literal directory-name segment. The lacre
490        // pipeline then embedded the value verbatim
491        // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492        // failure mode forked per consumer:
493        //
494        //   - The caixa-resolver's `Path` arm folds `:caminho`
495        //     through `Path::new(caminho).join(<file>)` without
496        //     `~`-expansion, so the build looked for a literal
497        //     `./~/work/caixa-teia` subdirectory and failed at
498        //     resolve time with a `No such file or directory`
499        //     error far from the source caixa.lisp (the lacre
500        //     itself, though, was already byte-identical across
501        //     machines — every machine emitted the same
502        //     `path:~/work/caixa-teia` content-address).
503        //   - A future caixa-resolver pass that *does* expand `~`
504        //     (the canonical shell-convention idiom every
505        //     resolver eventually reaches for once an author
506        //     reports the literal-`~`-directory bug) would re-
507        //     introduce the host-layout-leak the b94fd83 absolute
508        //     gate closes: Alice's `~` expands to `/home/alice`,
509        //     Bob's to `/home/bob`, two CI runners with different
510        //     `$HOME` layouts resolve to two distinct paths for
511        //     the byte-identical caixa, and the substrate's
512        //     "the lacre is the build's identity" contract
513        //     silently breaks far from the source caixa.lisp.
514        //
515        // Closing the gate at `DepSource::validate` (here at the
516        // canonical caixa-build-time boundary, peer with the
517        // absolute arm above) refuses both failure modes
518        // structurally: the typed accepted set excludes every
519        // `~`-prefixed authoring shape, so the resolver is
520        // free to grow `~`-expansion (or any other convention-
521        // expansion the substrate adopts) without re-opening
522        // the host-layout-leak at the typed boundary. Same
523        // diagnostic shape every per-axis value-shape gate on
524        // the surrounding [`DepError::Fonte*`] cluster carries
525        // (the offending `:nome` + offending `:caminho` quoted
526        // verbatim so the author can grep their caixa.lisp for
527        // the `:caminho "<value>"` literal and fix it in one
528        // edit).
529        //
530        // The cascade preserves narrower-diagnostic-first
531        // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532        // → `FonteCaminhoTildeExpansion`. The empty arm
533        // structurally precedes both (the bytes "" / "~" don't
534        // overlap), and the absolute arm structurally precedes
535        // the tilde arm (an absolute path can't start with `~`
536        // since absolute paths start with `/`; the bytes "/" /
537        // "~" don't overlap either). Both arms are
538        // value-disjoint, so the precedence is a no-op at value
539        // level — the pin matters only at the diagnostic-shape
540        // level if a future codec round-trip ever produces a
541        // value that probes as both absolute and tilde-prefixed.
542        if caminho.starts_with('~') {
543            return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544        }
545        // Reproducibility gate's shell-variable-expansion arm.
546        // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547        // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548        // closes the leading-`~` shell-home-expansion shape; the
549        // leading-`$` is the sibling shell-variable-expansion shape
550        // — same host-layout-leaking semantic, different syntactic
551        // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552        // canonical paste-from-`echo $HOME`-doc footgun) and the
553        // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554        // the canonical paste-from-CI-manifest footgun every
555        // GitHub Actions / GitLab CI / Drone manifest carries)
556        // silently passed every prior arm because
557        // `Path::is_absolute` returns false on `$` (the `$` is a
558        // shell convention, not a POSIX path component, so
559        // `std::path::Path` treats it as a literal directory-name
560        // segment) and the tilde arm's `starts_with('~')` doesn't
561        // fire.
562        //
563        // Same per-consumer failure-fork the tilde arm closes:
564        //
565        //   - The caixa-resolver's `Path` arm folds `:caminho`
566        //     through `Path::new(caminho).join(<file>)` without
567        //     `$`-expansion, so the build looks for a literal
568        //     `./$HOME/work/caixa-teia` subdirectory and fails at
569        //     resolve time with a `No such file or directory`
570        //     error far from the source caixa.lisp.
571        //   - A future caixa-resolver pass that *does* expand
572        //     `$VAR` (the shell-convention idiom every resolver
573        //     eventually reaches for once an author reports the
574        //     literal-`$HOME`-directory bug, especially for CI's
575        //     `${WORKSPACE}` idiom) would re-introduce the host-
576        //     layout-leak the b94fd83 absolute gate closes:
577        //     Alice's `$HOME` expands to `/home/alice`, Bob's to
578        //     `/home/bob`, two CI runners with different
579        //     `${WORKSPACE}` layouts resolve to two distinct
580        //     paths for the byte-identical caixa, and the
581        //     substrate's "the lacre is the build's identity"
582        //     contract silently breaks far from the source
583        //     caixa.lisp.
584        //
585        // Closing the gate at `DepSource::validate` (here at the
586        // canonical caixa-build-time boundary, peer with the
587        // absolute + tilde arms above) refuses both failure modes
588        // structurally. Same diagnostic shape every per-axis
589        // value-shape gate on the surrounding [`DepError::Fonte*`]
590        // cluster carries (the offending `:nome` + offending
591        // `:caminho` quoted verbatim).
592        //
593        // The cascade preserves narrower-diagnostic-first ordering:
594        // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595        // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596        // The empty arm structurally precedes all three subsequent
597        // arms; the absolute arm structurally precedes both the
598        // tilde and the var arms (absolute paths start with `/`,
599        // the bytes `/` / `~` / `$` don't overlap at the leading
600        // position); the tilde arm structurally precedes the var
601        // arm (`~` and `$` don't overlap at the leading position).
602        // Every pair is value-disjoint, so the precedence is a
603        // no-op at value level — the pin matters only at the
604        // diagnostic-shape level if a future codec round-trip ever
605        // produces a probe-as-both value.
606        //
607        // The gate covers every leading-`$` shape: the canonical
608        // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609        // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610        // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611        // GitHub Actions / GitLab CI / Drone paste footgun), the
612        // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613        // (degenerate "I meant `$HOME` and forgot the rest"). All
614        // shapes route through the same `caminho.starts_with('$')`
615        // byte check.
616        if caminho.starts_with('$') {
617            return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618        }
619        // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620        // f4efe9c arms closed the leading-byte host-layout-leak shapes
621        // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622        // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623        // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624        // *except* the ASCII space byte `0x20`). The bare ASCII space at
625        // the leading position is the orthogonal paste-from-aligned-doc
626        // shape that silently passed every prior arm: `Path::is_absolute`
627        // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628        // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629        // the value's last byte is not `/`, so the canonical
630        // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631        // form in a multi-entry `:deps` block sits at the same column —
632        // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633        // it from the rendered alignment into a fresh entry preserves the
634        // leading whitespace verbatim) silently rendered as a path with
635        // a leading-space directory component the resolver folds through
636        // `Path::join` looking for a literal `./ ../caixa-teia`
637        // subdirectory that fails at resolve time with a non-self-
638        // locating `No such file or directory` error.
639        //
640        // The lacre pipeline's reproducibility contract bites
641        // strictly at this byte: `path:" ../caixa-teia"` and
642        // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643        // (`conteudo: format!("path:{caminho}")`,
644        // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645        // semantic-identical caixa, and the substrate's "the lacre is
646        // the build's identity" contract (CAIXA-SDLC §III.2) silently
647        // breaks across two workstations whose authors differ only in
648        // paste-from-aligned-doc whitespace habits — the most insidious
649        // failure mode the typed slot can carry (no error surfaces; the
650        // divergence is invisible until two machines compare lacres).
651        //
652        // The arm fires AFTER the absolute / tilde / var leading-byte
653        // arms (each names the more self-locating shell-convention
654        // diagnostic on values that probe as that arm's leading-byte
655        // sentinel followed by a leading space — e.g.
656        // `:caminho "/  /foo"` surfaces `FonteCaminhoAbsolute` because
657        // the leading byte is `/`, not space) and BEFORE the
658        // embedded-control-byte arm (a leading-space value with an
659        // embedded control byte surfaces the broader leading-space
660        // diagnostic because the cascade walks leading-byte arms first
661        // — peer with how `FonteCaminhoAbsolute` precedes
662        // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663        //
664        // The peer single-token-shaped axes already reject leading
665        // whitespace on the same paste-from-aligned-doc contract:
666        // [`crate::render::is_git_repo_url`] rejects leading whitespace
667        // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668        // leading whitespace on `:fonte :tag`/`:branch`,
669        // [`crate::render::is_chart_description_shape`] rejects leading
670        // whitespace on `:descricao`,
671        // [`crate::render::is_spdx_expression_shape`] rejects leading
672        // whitespace on `:licenca`. Closing the same byte on
673        // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674        // space anywhere in a typed string slot" invariant structurally
675        // consistent across every value-shape-gated typed surface (the
676        // `:caminho` axis was the last typed string surface still
677        // admitting a leading space byte).
678        if caminho.starts_with(' ') {
679            return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680        }
681        // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682        // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683        // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684        // this arm closes the orthogonal leading-`-` axis on the same
685        // subprocess-argument-boundary the peer `is_git_repo_url` arm
686        // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687        // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688        // `:fonte :tag` / `:branch`) already reject.
689        //
690        // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691        // content-address (`conteudo: format!("path:{caminho}")`,
692        // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693        // value through `Path::join` looking for a literal `./{caminho}`
694        // subdirectory. Every downstream subprocess that consumes the
695        // resolved path — a `git -C {caminho} <verb>` invocation, a
696        // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697        // future operator-side `nix build --path {caminho}` spawn, an
698        // `xargs` / `find {caminho}` / `stat {caminho}` /
699        // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700        // as a CLI flag rather than a positional path when the
701        // subprocess invocation does not carry a `--` argument-list
702        // terminator between the flag block and the path argument. The
703        // canonical footguns:
704        //
705        //   - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706        //     `find -rf` reinterpretation; the byte the peer
707        //     `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708        //     example paste-idiom carries as its first token).
709        //   - `:caminho "-C"` — `git -C` config-injection paste
710        //     (`git -C -C` reinterprets the second `-C` as another
711        //     `--change-directory` flag rather than the path
712        //     argument; the canonical `git -C <path>` porcelain
713        //     idiom every multi-repo workspace tool carries).
714        //   - `:caminho "--upload-pack=cat /etc/passwd"` — the
715        //     canonical long-flag CLI-arg-injection vector at every
716        //     git porcelain entry point (`git clone`, `git fetch`,
717        //     `git ls-remote`) that consumes a path or URL
718        //     argument; peer with `is_git_repo_url`'s leading-`-`
719        //     arm (render.rs:2037) on the sibling `:fonte :repo`
720        //     axis, which the arm's diagnostic explicitly cites.
721        //   - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722        //     override paste-idiom (paste-from-`git -c foo=bar`
723        //     shell-history footgun that reinterprets the value as
724        //     a `[foo] bar` config injection on every git porcelain
725        //     entry point).
726        //
727        // POSIX `std::path::Path` treats a leading `-` as a literal
728        // filename byte, so the resolver folds `-rf` through `Path::join`
729        // and looks for a literal `./-rf` subdirectory — the failure
730        // surfaces at resolve time with a non-self-locating `No such
731        // file or directory` error far from the source caixa.lisp, and
732        // the value rides through the lacre content-address into every
733        // downstream shell-spawned subprocess. On any consumer that
734        // shells out without the `--` terminator (the common case at
735        // every porcelain entry-point) the reinterpretation is silent
736        // and the failure mode is arbitrary-argument-injection.
737        //
738        // The arm fires AFTER the absolute / tilde / var / leading-space
739        // leading-byte arms (each names the more self-locating shell-
740        // convention diagnostic on values that probe as that arm's
741        // leading-byte sentinel — the byte sets are pairwise disjoint at
742        // the leading position, so the precedence pin is a no-op at
743        // value level, but the ordering keeps every leading-byte arm's
744        // diagnostic-shape stable) and BEFORE the embedded-control-byte
745        // arm (a leading-`-` value with an embedded control byte
746        // surfaces the narrower leading-`-` diagnostic because the
747        // cascade walks leading-byte arms first — peer with how
748        // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749        // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750        // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751        //
752        // The peer single-token-shaped axes already reject leading `-`
753        // on the same CLI-arg-injection contract:
754        // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755        // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756        // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757        // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758        // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759        // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760        // [`crate::render::is_cargo_feature_name`] rejects it on
761        // `:caracteristicas`, and the feira `init` / `add <nome>`
762        // positional gate (868c191) rejects it on the CLI positional
763        // itself. Closing the same byte on `:fonte :caminho` makes the
764        // substrate-wide "no leading `-` anywhere in a typed single-
765        // token string slot routed through a subprocess argument"
766        // invariant structurally consistent across every value-shape-
767        // gated typed surface (the `:caminho` axis was the last typed
768        // string surface still admitting a leading `-` byte).
769        if caminho.starts_with('-') {
770            return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771        }
772        // Reproducibility gate's embedded-control-byte arm. The
773        // b94fd83 + a5c248e + f4efe9c arms closed the three
774        // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775        // this arm closes the orthogonal embedded-control-byte
776        // axis — any ASCII control byte (`0x00..=0x1F` plus
777        // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778        // shape every peer single-token-typed-slot value-shape
779        // predicate the surrounding [`crate::render`] cluster
780        // gates against (the lifted `is_git_repo_url` arm on
781        // `:fonte :repo`, the `is_git_ref_name` arm on
782        // `:tag`/`:branch`, the `is_chart_description_shape` /
783        // `is_chart_maintainer_name_shape` /
784        // `is_chart_keyword_shape` arms on the
785        // Helm-chart-shaped axes); now consistent on the
786        // `:caminho` axis too.
787        //
788        // Until this gate landed any embedded control byte
789        // silently passed validate, the lacre pipeline embedded
790        // the value verbatim in its per-dep content-address
791        // (`conteudo: format!("path:{caminho}")`,
792        // caixa-resolver/src/resolve.rs:189), and the failure
793        // forked per byte and per consumer:
794        //
795        //   - NUL (`0x00`) the canonical "POSIX paths cannot
796        //     contain a NUL byte" shape: every `std::fs` syscall
797        //     routes the path through `CString::new`, which
798        //     fails with `NulError` on the first NUL byte; the
799        //     build would surface a `NulError` at resolve time
800        //     far from the source caixa.lisp.
801        //   - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802        //     multiline-doc footgun: a `:caminho
803        //     "../caixa-teia\nrm -rf /"` value (paste landed mid-
804        //     `:caminho` block from a multi-line code-fence)
805        //     silently round-trips through `Path::join` but the
806        //     embedded newline class is a sibling of the CRLF-at-
807        //     subprocess-argument injection vector
808        //     `is_git_repo_url` already closes on `:repo`.
809        //   - Tab (`0x09`) the canonical paste-from-aligned-table
810        //     footgun: the tab is invisible in most editors, and
811        //     the lacre embeds the value verbatim so two
812        //     paste-from-distinct-tables yield divergent lacres
813        //     across host editors that strip vs preserve tabs.
814        //   - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815        //     paste-from-binary-blob shape every peer single-
816        //     token-shaped slot rejects under the same
817        //     `b < 0x20 || b == 0x7F` predicate.
818        //
819        // Mirrors the cascade discipline every prior `:caminho`
820        // arm establishes: `FonteCaminhoEmpty` →
821        // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822        // → `FonteCaminhoVarExpansion` →
823        // `FonteCaminhoLeadingWhitespace` →
824        // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825        // The six leading-byte arms structurally precede the
826        // embedded-byte arm because the leading-byte shapes are
827        // the more self-locating diagnostic on values that probe
828        // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829        // narrower `FonteCaminhoAbsolute` rather than the broader
830        // embedded-control-byte arm); the precedence pin matters
831        // at the diagnostic-shape level even though the empty /
832        // absolute / tilde / var arms are value-disjoint from a
833        // bare control byte (which would itself be a leading
834        // byte under the empty / absolute / tilde / var arms'
835        // leading-position semantics, but those arms guard the
836        // specific shell-convention characters `/` / `~` / `$`
837        // — a leading `0x01` byte falls through to this arm).
838        for &b in caminho.as_bytes() {
839            if b < 0x20 || b == 0x7F {
840                return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841            }
842        }
843        // Reproducibility gate's Windows-path-separator arm. The four
844        // leading-byte arms (`/` / `~` / `$`) and the embedded-
845        // control-byte arm close the host-layout-leaking + paste-from-
846        // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847        // the orthogonal cross-host-OS-separator shape — same render-
848        // determinism axis, different semantic mechanism. POSIX
849        // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850        // inside a single path component (so `..\caixa-teia` is one
851        // directory named literally `..\caixa-teia`, sibling of `.`
852        // and `..`); Windows [`std::path::Path`] treats `\` as a
853        // primary path separator equal to `/` (so `..\caixa-teia` is
854        // the parent's sibling directory `caixa-teia`). The lacre
855        // pipeline embeds the value verbatim in its per-dep content-
856        // address (`conteudo: format!("path:{caminho}")`, caixa-
857        // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858        // values resolve to two distinct directories across runner
859        // OSes — the same THEORY.md §V.2 render-determinism contract
860        // the absolute / tilde / var arms protect, here against the
861        // cross-host-OS-separator divergence vector. Even on POSIX-
862        // only resolvers (the canonical pleme-io substrate posture),
863        // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864        // PowerShell `Get-Location` paste-idiom footgun) silently
865        // passes every prior arm because `Path::is_absolute` returns
866        // false on `..` and `\` is neither a leading-byte sentinel
867        // nor a control byte, then the resolver folds the value
868        // through `Path::new(caminho).join(<file>)` looking for a
869        // literal `./..\caixa-teia` subdirectory and fails at
870        // resolve time with a non-self-locating `No such file or
871        // directory` error far from the source caixa.lisp.
872        //
873        // The peer single-token-shaped axes on the same git-CLI /
874        // path-CLI consumer cluster already reject `\` under the same
875        // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876        // line 1441 (`"must not contain \\ … the canonical Windows-
877        // path-leak footgun; use / for hierarchical refs"`) gates
878        // `:fonte :tag` / `:fonte :branch` against the same byte,
879        // and [`crate::render::is_gateway_api_http_path`] line 506
880        // includes `\` in the eleven-byte RFC-3986-reserved rejection
881        // set on `:entrada :paths`. Closing the same byte on `:fonte
882        // :caminho` makes the substrate-wide "no Windows path
883        // separator anywhere in a typed string slot" invariant
884        // structurally consistent across every path-shaped typed
885        // surface (the `:caminho` axis was the last typed string
886        // surface still admitting `\`).
887        //
888        // The arm fires AFTER the control-char arm because the
889        // control-char diagnostic is the more self-locating axis on
890        // values that probe as both (`"..\caixa\0teia"` carries both
891        // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892        // rejected byte, so `FonteCaminhoControlChar` wins). Same
893        // narrower-diagnostic-first cascade discipline every prior
894        // arm establishes. A pure-`\` value
895        // (`"..\caixa-teia"` with no control bytes) falls through
896        // every prior arm and lands here.
897        for &b in caminho.as_bytes() {
898            if b == b'\\' {
899                return Err(DepError::fonte_caminho_backslash(nome, caminho));
900            }
901        }
902        // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903        // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904        // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905        // paste-from-shell-prompt footgun class, different syntactic surface.
906        // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907        // single path component (so `../caixa-teia>output` is one directory
908        // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909        // but every interactive shell (bash / zsh / fish / nushell) lexes
910        // `<` / `>` as input / output redirection operators — a `:caminho
911        // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912        // pipeline that wrote build output and forgot to trim the redirect"
913        // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914        // redirection paste idiom) silently passes every prior arm because
915        // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916        // byte sentinels nor control bytes nor `\`, and the value's last byte
917        // isn't `/`. The resolver folds the value through
918        // `Path::new(caminho).join(<file>)` looking for a literal
919        // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920        // with a non-self-locating `No such file or directory` error far
921        // from the source caixa.lisp.
922        //
923        // The lacre pipeline embeds the value verbatim in its per-dep
924        // content-address (`conteudo: format!("path:{caminho}")`,
925        // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926        // the BLAKE3 closure and rides downstream as part of the build's
927        // identity. The bytes carry a second class of hazard the prior
928        // separator-shaped arms don't: every typed-string slot whose value
929        // ever flows verbatim into a shell-spawned subprocess (the caixa-
930        // resolver's `git clone` invocation, a future `feira tofu` shell-
931        // out, a future operator-side `nix flake check` spawn) is the
932        // canonical CRLF-at-subprocess-argument / shell-metachar injection
933        // surface that every peer single-token-shaped typed slot already
934        // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935        // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936        // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937        // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938        // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939        // shell-metachar-injection banner. The `:caminho` axis was the last
940        // typed string surface still admitting these two bytes; this arm
941        // closes the gap so the substrate-wide "no shell-redirection
942        // metacharacter anywhere in a typed string slot" invariant is now
943        // structurally consistent across every path-shaped typed surface.
944        //
945        // The arm fires AFTER the control-char arm + backslash arm because
946        // both prior arms carry more self-locating diagnostics on values
947        // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948        // cross-OS-separator divergence is the load-bearing axis, so the
949        // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950        // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951        // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952        // because the embedded redirection byte is the more semantic-
953        // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954        // but the load-bearing diagnostic is the embedded `<` shell-
955        // redirection — the trailing `/` is the secondary observation, and
956        // an author who removes the `<` is likely to also tab-strip the
957        // trailing separator).
958        for &b in caminho.as_bytes() {
959            if b == b'<' || b == b'>' {
960                return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961            }
962        }
963        // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964        // arm closes the `<` / `>` input/output redirection sentinels; `|`
965        // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966        // shell-prompt footgun class, different syntactic surface. POSIX
967        // `std::path::Path` treats `|` as a literal path-component byte (so
968        // `../caixa-teia|tee` is one directory named literally
969        // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970        // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971        // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972        // `ls ../caixa-teia | grep` line out of a shell-history block and
973        // forgot to trim the pipeline tail" footgun) or `:caminho
974        // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975        // circuit OR line" idiom) silently passes every prior arm because
976        // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977        // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978        // value's last byte isn't `/`. The resolver folds the value through
979        // `Path::new(caminho).join(<file>)` looking for a literal
980        // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981        // with a non-self-locating `No such file or directory` error far
982        // from the source caixa.lisp.
983        //
984        // The lacre pipeline embeds the value verbatim in its per-dep
985        // content-address (`conteudo: format!("path:{caminho}")`,
986        // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987        // BLAKE3 closure and rides downstream as part of the build's identity
988        // into every shell-spawned subprocess (the caixa-resolver's `git
989        // clone` invocation, a future `feira tofu` shell-out, a future
990        // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991        // subprocess-argument / shell-metachar injection surface every peer
992        // single-token-shaped typed slot already closes. The peer path-shaped
993        // axis [`crate::render::is_gateway_api_http_path`]
994        // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996        // axis was the last typed path-string surface still admitting this
997        // byte; this arm closes the gap so the substrate-wide "no shell-
998        // composition metacharacter anywhere in a typed string slot that
999        // flows verbatim into a shell-spawned subprocess" invariant extends
1000        // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001        // `:caminho` axis.
1002        //
1003        // The arm fires AFTER the shell-redirection arm because the prior
1004        // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005        // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006        // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007        // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008        // cascade discipline every prior `:caminho` arm establishes). The arm
1009        // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010        // the more semantic-locating axis on probe-as-both values
1011        // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012        // embedded `|` shell-pipe — the trailing `/` is the secondary
1013        // observation, and an author who removes the `|` is likely to also
1014        // tab-strip the trailing separator).
1015        for &b in caminho.as_bytes() {
1016            if b == b'|' {
1017                return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018            }
1019        }
1020        // Reproducibility gate's shell-command-separator arm. The 124106f
1021        // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022        // shell-command-separator sentinel — same paste-from-shell-prompt
1023        // footgun class, different syntactic surface. POSIX `std::path::Path`
1024        // treats `;` as a literal path-component byte (so
1025        // `../caixa-teia;rm -rf /` is one directory named literally
1026        // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027        // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028        // sequential-command terminator that fires the next command
1029        // regardless of the prior command's exit status — a `:caminho
1030        // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031        // one-liner that chained a cleanup tail after the directory name"
1032        // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033        // POSIX `case` arm's `;;` terminator into the middle of a path"
1034        // idiom) silently passes every prior arm because `Path::is_absolute`
1035        // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036        // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037        // byte isn't `/`. The resolver folds the value through
1038        // `Path::new(caminho).join(<file>)` looking for a literal
1039        // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040        // time with a non-self-locating `No such file or directory` error far
1041        // from the source caixa.lisp.
1042        //
1043        // The lacre pipeline embeds the value verbatim in its per-dep
1044        // content-address (`conteudo: format!("path:{caminho}")`,
1045        // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046        // BLAKE3 closure and rides downstream as part of the build's identity
1047        // into every shell-spawned subprocess (the caixa-resolver's `git
1048        // clone` invocation, a future `feira tofu` shell-out, a future
1049        // operator-side `nix flake check` spawn) as the canonical
1050        // shell-metachar injection surface every peer single-token-shaped
1051        // typed slot already closes. The peer path-shaped axis
1052        // [`crate::render::is_gateway_api_http_path`]
1053        // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054        // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055        // axis was the last typed path-string surface still admitting this
1056        // byte; this arm closes the gap so the substrate-wide "no shell-
1057        // composition metacharacter anywhere in a typed string slot that
1058        // flows verbatim into a shell-spawned subprocess" invariant extends
1059        // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060        // `:caminho` axis.
1061        //
1062        // The arm fires AFTER the shell-pipe arm because the prior arm's
1063        // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064        // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065        // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066        // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067        // cascade discipline every prior `:caminho` arm establishes). The arm
1068        // fires BEFORE the trailing-`/` arm because the embedded
1069        // command-separator byte is the more semantic-locating axis on
1070        // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071        // load-bearing diagnostic is the embedded `;` shell-command-
1072        // separator — the trailing `/` is the secondary observation, and an
1073        // author who removes the `;` is likely to also tab-strip the trailing
1074        // separator).
1075        for &b in caminho.as_bytes() {
1076            if b == b';' {
1077                return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078            }
1079        }
1080        // Reproducibility gate's shell-background / logical-AND arm. The
1081        // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082        // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083        // — same paste-from-shell-prompt footgun class, different
1084        // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085        // literal path-component byte (so `../caixa-teia & sleep 1` is
1086        // one directory named literally `../caixa-teia & sleep 1`,
1087        // sibling of `.` and `..`), but every interactive shell
1088        // (bash / zsh / fish / nushell) lexes `&` two ways:
1089        //
1090        //   - Single `&` as the background-task terminator that detaches
1091        //     the prior command into the background and returns control
1092        //     to the prompt immediately (the canonical `cmd &` idiom
1093        //     every long-running pipeline uses);
1094        //   - Double `&&` as the logical-AND list operator that fires
1095        //     the next command only if the prior command succeeded (the
1096        //     canonical `make && make install` idiom every build script
1097        //     carries).
1098        //
1099        // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100        // pasted a `cd path & sleep 1` background-launch into the
1101        // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102        // (the symmetric "I copied a `cd path && make` build chain"
1103        // idiom) silently passes every prior arm because
1104        // `Path::is_absolute` returns false on `..`, `&` is neither a
1105        // leading-byte sentinel nor a control byte nor `\` nor
1106        // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107        // The resolver folds the value through
1108        // `Path::new(caminho).join(<file>)` looking for a literal
1109        // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110        // time with a non-self-locating `No such file or directory`
1111        // error far from the source caixa.lisp.
1112        //
1113        // The lacre pipeline embeds the value verbatim in its per-dep
1114        // content-address (`conteudo: format!("path:{caminho}")`,
1115        // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116        // the BLAKE3 closure and rides downstream as part of the build's
1117        // identity into every shell-spawned subprocess (the
1118        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119        // shell-out, a future operator-side `nix flake check` spawn) as
1120        // the canonical shell-metachar injection surface every peer
1121        // single-token-shaped typed slot already closes. The peer
1122        // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123        // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125        // `:caminho` axis was the last typed path-string surface still
1126        // admitting this byte; this arm closes the gap so the
1127        // substrate-wide "no shell-composition metacharacter anywhere
1128        // in a typed string slot that flows verbatim into a
1129        // shell-spawned subprocess" invariant extends from
1130        // shell-command-separator (`;`) to shell-background /
1131        // logical-AND (`&`) on the `:caminho` axis.
1132        //
1133        // The arm fires AFTER the shell-command-separator arm because
1134        // the prior arm's `cmd-a; cmd-b` shape is the more common
1135        // shell-history paste idiom on values that probe as both
1136        // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137        // command-separator-tail paste is the load-bearing root-cause
1138        // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139        // discipline every prior `:caminho` arm establishes). The arm
1140        // fires BEFORE the trailing-`/` arm because the embedded
1141        // background / list-AND byte is the more semantic-locating axis
1142        // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143        // load-bearing diagnostic is the embedded `&` shell-background
1144        // / logical-AND metachar — the trailing `/` is the secondary
1145        // observation, and an author who removes the `&` is likely to
1146        // also tab-strip the trailing separator).
1147        for &b in caminho.as_bytes() {
1148            if b == b'&' {
1149                return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150            }
1151        }
1152        // Reproducibility gate's shell-command-substitution arm. The
1153        // e12e4f3 shell-background / logical-AND arm closes the `&`
1154        // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155        // command-substitution sentinel — every POSIX shell (sh /
1156        // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157        // the canonical legacy wrapper that runs the enclosed command
1158        // and substitutes its standard-output verbatim into the
1159        // surrounding word (a `whoami` wrapped in backticks expands
1160        // to the current user's name; a `cat /etc/passwd` wrapped in
1161        // backticks expands to the file's contents — the canonical
1162        // CWE-78 shell-command-injection vector every shell-side
1163        // hardening guide enumerates first). POSIX
1164        // `std::path::Path` treats backtick as a literal path-
1165        // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166        // is one directory named literally that, sibling of `.` and
1167        // `..`).
1168        //
1169        // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170        // canonical "I pasted a shell one-liner carrying a backticked
1171        // `whoami` command-substitution expansion into the `:caminho`
1172        // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173        // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174        // path` working-directory expansion") silently passes every
1175        // prior arm because `Path::is_absolute` returns false on
1176        // `..`, the backtick byte is neither a leading-byte sentinel
1177        // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178        // modern `$()` form at leading position only; backtick is
1179        // the orthogonal legacy form) nor a control byte nor `\` nor
1180        // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181        // byte isn't `/`. The resolver folds the value through
1182        // `Path::new(caminho).join(<file>)` looking for a literal
1183        // subdirectory whose name embeds the backticked token and
1184        // fails at resolve time with a non-self-locating `No such
1185        // file or directory` error far from the source caixa.lisp.
1186        //
1187        // The lacre pipeline embeds the value verbatim in its per-
1188        // dep content-address (`conteudo: format!("path:{caminho}")`,
1189        // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190        // lands in the BLAKE3 closure and rides downstream as part
1191        // of the build's identity into every shell-spawned
1192        // subprocess (the caixa-resolver's `git clone` invocation, a
1193        // future `feira tofu` shell-out, a future operator-side
1194        // `nix flake check` spawn) as the canonical shell-metachar
1195        // injection surface every peer single-token-shaped typed
1196        // slot already closes. The peer path-shaped axis
1197        // [`crate::render::is_gateway_api_http_path`]
1198        // (caixa-core/src/render.rs:506) rejects backtick as part of
1199        // its eleven-byte RFC-3986-reserved set on `:entrada
1200        // :paths`. The `:caminho` axis was the last typed path-
1201        // string surface still admitting this byte; this arm closes
1202        // the gap so the substrate-wide "no shell-composition
1203        // metacharacter anywhere in a typed string slot that flows
1204        // verbatim into a shell-spawned subprocess" invariant
1205        // extends from shell-background / logical-AND (`&`) to
1206        // shell-command-substitution (backtick) on the `:caminho`
1207        // axis.
1208        //
1209        // The arm fires AFTER the shell-background arm because the
1210        // prior arm's `cmd & sleep` shape is the more common shell-
1211        // history paste idiom on values that probe as both (a
1212        // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213        // both `&` and a backtick — the background-launch tail is
1214        // the load-bearing root-cause edit, so
1215        // `FonteCaminhoShellBackground` wins; same cascade
1216        // discipline every prior `:caminho` arm establishes). The
1217        // arm fires BEFORE the trailing-`/` arm because the
1218        // embedded command-substitution byte is the more semantic-
1219        // locating axis on probe-as-both values (a
1220        // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221        // load-bearing diagnostic is the embedded backtick shell-
1222        // command-substitution metachar — the trailing `/` is the
1223        // secondary observation, and an author who removes the
1224        // backtick is likely to also tab-strip the trailing
1225        // separator).
1226        for &b in caminho.as_bytes() {
1227            if b == b'`' {
1228                return Err(DepError::fonte_caminho_shell_command_substitution(
1229                    nome, caminho,
1230                ));
1231            }
1232        }
1233        // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234        // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235        // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236        // paste-from-shell-prompt footgun class, different syntactic surface.
1237        // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238        // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239        // sequence of characters in a path component (including the empty
1240        // sequence), `?` matches exactly one character. POSIX
1241        // `std::path::Path` treats both bytes as literal path-component bytes
1242        // (so `../caixa-teia/*.lisp` is one directory named literally
1243        // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244        //
1245        // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246        // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247        // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248        // `rm foo?` single-char-wildcard removal idiom") silently passes
1249        // every prior arm because `Path::is_absolute` returns false on `..`,
1250        // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251        // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252        // value's last byte isn't `/`. The resolver folds the value through
1253        // `Path::new(caminho).join(<file>)` looking for a literal
1254        // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255        // non-self-locating `No such file or directory` error far from the
1256        // source caixa.lisp.
1257        //
1258        // The lacre pipeline embeds the value verbatim in its per-dep
1259        // content-address (`conteudo: format!("path:{caminho}")`,
1260        // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261        // the BLAKE3 closure and rides downstream as part of the build's
1262        // identity into every shell-spawned subprocess (the caixa-resolver's
1263        // `git clone` invocation, a future `feira tofu` shell-out, a future
1264        // operator-side `nix flake check` spawn) as the canonical
1265        // shell-metachar / pathname-expansion surface every peer
1266        // single-token-shaped typed slot already closes. The peer path-shaped
1267        // axis [`crate::render::is_gateway_api_http_path`]
1268        // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269        // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270        // `:caminho` axis was the last typed path-string surface still
1271        // admitting these two bytes; this arm closes the gap so the
1272        // substrate-wide "no shell-composition / glob-expansion
1273        // metacharacter anywhere in a typed string slot that flows verbatim
1274        // into a shell-spawned subprocess" invariant extends from
1275        // shell-command-substitution (backtick) to glob-expansion
1276        // (`*` / `?`) on the `:caminho` axis.
1277        //
1278        // The arm fires AFTER the backtick arm because the prior arm's
1279        // CWE-78 shell-command-injection vector is the load-bearing
1280        // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281        // carries both backtick and `*` — the command-substitution paste
1282        // is the load-bearing root-cause edit, so
1283        // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284        // discipline every prior `:caminho` arm establishes). The arm
1285        // fires BEFORE the trailing-`/` arm because the embedded glob
1286        // byte is the more semantic-locating axis on probe-as-both values
1287        // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288        // embedded `*` glob metachar — the trailing `/` is the secondary
1289        // observation, and an author who removes the `*` is likely to
1290        // also tab-strip the trailing separator).
1291        for &b in caminho.as_bytes() {
1292            if b == b'*' || b == b'?' {
1293                return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294            }
1295        }
1296        // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297        // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298        // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299        // grouping sentinels — same paste-from-shell-prompt footgun class,
1300        // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301        // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302        // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303        // shell with a fresh environment scope (the canonical sandboxing
1304        // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305        // to scope a `cd` to one subshell without disturbing the parent's
1306        // working directory), and `$(<cmd>)` is the modern Bourne
1307        // command-substitution shape the upstream f4efe9c
1308        // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309        // the closing `)` byte completes that substitution shape and must
1310        // be refused on the same axis (peer with the
1311        // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312        // same byte-pair on the sibling `:fonte :repo` axis under the
1313        // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314        // POSIX `std::path::Path` treats both bytes as literal path-
1315        // component bytes (so `../caixa-teia/(date)` is one directory
1316        // named literally `../caixa-teia/(date)`, sibling of `.` and
1317        // `..`).
1318        //
1319        // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320        // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321        // liner whose modern command-substitution expansion lands the
1322        // current date as a subdirectory name" footgun) or `:caminho
1323        // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324        // `(cd foo && pwd)` subshell-grouping working-directory probe
1325        // idiom") silently passes every prior arm because
1326        // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327        // neither leading-byte sentinels nor control bytes nor `\` nor
1328        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329        // and the value's last byte isn't `/`. The resolver folds the
1330        // value through `Path::new(caminho).join(<file>)` looking for a
1331        // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332        // at resolve time with a non-self-locating `No such file or
1333        // directory` error far from the source caixa.lisp.
1334        //
1335        // The lacre pipeline embeds the value verbatim in its per-dep
1336        // content-address (`conteudo: format!("path:{caminho}")`,
1337        // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338        // in the BLAKE3 closure and rides downstream as part of the
1339        // build's identity into every shell-spawned subprocess (the
1340        // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341        // shell-out, a future operator-side `nix flake check` spawn) as
1342        // the canonical shell-metachar / subshell-grouping surface every
1343        // peer single-token-shaped typed slot already closes. The peer
1344        // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345        // rejects the same byte pair on `:fonte :repo` under the same
1346        // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347        // `:caminho` axis was the last typed path-string surface still
1348        // admitting these two bytes;
1349        // this arm closes the gap so the substrate-wide "no shell-
1350        // composition metacharacter anywhere in a typed string slot that
1351        // flows verbatim into a shell-spawned subprocess" invariant
1352        // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353        // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354        // leading-`$` arm, the typed `:caminho` accepted set now
1355        // structurally excludes the entire modern Bourne
1356        // command-substitution surface — leading `$` closes the
1357        // leading byte of every `$(<cmd>)` shape, this arm closes the
1358        // trailing `)` boundary.
1359        //
1360        // The arm fires AFTER the shell-glob arm because the prior arm's
1361        // `*` / `?` pathname-expansion shape is the more common shell-
1362        // history paste idiom on values that probe as both
1363        // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364        // glob-paste-tail is the load-bearing root-cause edit, so
1365        // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366        // prior `:caminho` arm establishes). The arm fires BEFORE the
1367        // trailing-`/` arm because the embedded subshell-grouping byte
1368        // is the more semantic-locating axis on probe-as-both values
1369        // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370        // is the embedded `(` shell-subshell-grouping metachar — the
1371        // trailing `/` is the secondary observation, and an author who
1372        // removes the `(` is likely to also tab-strip the trailing
1373        // separator).
1374        for &b in caminho.as_bytes() {
1375            if b == b'(' || b == b')' {
1376                return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377                    nome, caminho, b,
1378                ));
1379            }
1380        }
1381        // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382        // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383        // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384        // URI-Template-placeholder byte pair — same paste-from-shell-
1385        // prompt + paste-from-templated-doc footgun class, different
1386        // syntactic surface. Every POSIX-derived shell that implements
1387        // brace expansion (bash / zsh / ksh / fish; the canonical
1388        // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389        // `cp file{,.bak}` idiom every shell-history block carries)
1390        // expands `{a,b,c}` to the cross-product of its comma-separated
1391        // members and `{1..10}` to the integer range; RFC 6570 reserves
1392        // the matched pair for URI Template placeholders (the canonical
1393        // `https://{host}/{org}/{repo}` substitution shape every
1394        // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395        // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396        // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397        // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398        // shape) emit. POSIX `std::path::Path` treats both bytes as
1399        // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400        // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401        // sibling of `.` and `..`).
1402        //
1403        // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404        // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405        // expansion one-liner that fans across two siblings" footgun)
1406        // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407        // a `{{org}}` Mustache / Helm template placeholder out of a
1408        // README quick-start and forgot to substitute") silently passes
1409        // every prior arm because `Path::is_absolute` returns false on
1410        // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411        // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412        // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413        // byte isn't `/`. The resolver folds the value through
1414        // `Path::new(caminho).join(<file>)` looking for a literal
1415        // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416        // at resolve time with a non-self-locating `No such file or
1417        // directory` error far from the source caixa.lisp.
1418        //
1419        // The lacre pipeline embeds the value verbatim in its per-dep
1420        // content-address (`conteudo: format!("path:{caminho}")`,
1421        // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422        // lands in the BLAKE3 closure and rides downstream as part of
1423        // the build's identity into every shell-spawned subprocess
1424        // (the caixa-resolver's `git clone` invocation, a future
1425        // `feira tofu` shell-out, a future operator-side `nix flake
1426        // check` spawn) as the canonical shell-metachar / brace-
1427        // expansion surface every peer single-token-shaped typed
1428        // slot already closes. The peer git-source axis
1429        // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430        // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431        // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432        // shell-brace-expansion banner. The `:caminho` axis was the last
1433        // typed path-string surface still admitting these two bytes;
1434        // this arm closes the gap so the substrate-wide "no shell-
1435        // composition metacharacter anywhere in a typed string slot
1436        // that flows verbatim into a shell-spawned subprocess"
1437        // invariant extends from shell-subshell-grouping (`(` / `)`)
1438        // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439        // and the typed `:caminho` accepted set now also structurally
1440        // excludes the URI Template / templating-engine placeholder
1441        // surface that would silently round-trip through any
1442        // downstream IaC templating-engine layer.
1443        //
1444        // The arm fires AFTER the shell-subshell-grouping arm because
1445        // the prior arm's `(` / `)` shape is the more semantic-locating
1446        // axis on values that probe as both (`"../{cd foo}(date)"`
1447        // carries both `{` and `(` — the parenthesis-pair is the
1448        // load-bearing modern-Bourne-command-substitution surface the
1449        // prior arm closes; same cascade discipline every prior
1450        // `:caminho` arm establishes). The arm fires BEFORE the
1451        // trailing-`/` arm because the embedded brace-expansion byte
1452        // is the more semantic-locating axis on probe-as-both values
1453        // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454        // load-bearing diagnostic is the embedded `{` brace-expansion
1455        // metachar — the trailing `/` is the secondary observation,
1456        // and an author who removes the `{` is likely to also tab-
1457        // strip the trailing separator).
1458        for &b in caminho.as_bytes() {
1459            if b == b'{' || b == b'}' {
1460                return Err(DepError::fonte_caminho_shell_brace_expansion(
1461                    nome, caminho, b,
1462                ));
1463            }
1464        }
1465        // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466        // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467        // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468        // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469        // footgun class, different syntactic surface. Every POSIX shell
1470        // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471        // bracket pair as the glob character-class operator: `[abc]`
1472        // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473        // ASCII letter; `[^x]` negates (the canonical
1474        // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475        // lowercase-sibling glob every shell-history block carries —
1476        // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477        // closing the unbounded pathname-expansion sentinels). The
1478        // bracket pair additionally carries the POSIX `test` /
1479        // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480        // the canonical idiom every shell-script conditional uses) and
1481        // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482        // bracket pair is the TOML inline-array delimiter
1483        // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484        // manifest cross-idiom-leak vector), the YAML flow-sequence
1485        // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486        // values.yaml cross-idiom leak), the JSON array delimiter,
1487        // and the POSIX-ERE / PCRE bracket-expression / character-
1488        // class anchor (the canonical paste-from-regex-doc shape).
1489        // POSIX `std::path::Path` treats both bytes as literal path-
1490        // component bytes (so `../[caixa-teia]` is one directory
1491        // named literally `../[caixa-teia]`, sibling of `.` and
1492        // `..`).
1493        //
1494        // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495        // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496        // one-liner that matches every lowercase-sibling-suffix
1497        // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498        // build"` (the symmetric "I pasted a TOML inline-array /
1499        // YAML flow-sequence shape out of an aligned manifest"
1500        // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501        // `*.[ch]` C-source character-class paste-from-shell-history
1502        // shape) silently passes every prior arm because
1503        // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504        // neither leading-byte sentinels nor control bytes nor `\`
1505        // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506        // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507        // last byte isn't `/`. The resolver folds the value through
1508        // `Path::new(caminho).join(<file>)` looking for a literal
1509        // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510        // time with a non-self-locating `No such file or directory`
1511        // error far from the source caixa.lisp.
1512        //
1513        // The lacre pipeline embeds the value verbatim in its per-dep
1514        // content-address (`conteudo: format!("path:{caminho}")`,
1515        // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516        // lands in the BLAKE3 closure and rides downstream as part of
1517        // the build's identity into every shell-spawned subprocess
1518        // (the caixa-resolver's `git clone` invocation, a future
1519        // `feira tofu` shell-out, a future operator-side `nix flake
1520        // check` spawn) as the canonical shell-metachar / glob-
1521        // character-class / TOML-array surface every peer single-
1522        // token-shaped typed slot already closes. The `:caminho` axis
1523        // was the last typed path-string surface still admitting
1524        // these two bytes; this arm closes the gap so the substrate-
1525        // wide "no shell-composition metacharacter anywhere in a
1526        // typed string slot that flows verbatim into a shell-spawned
1527        // subprocess" invariant extends from shell-brace-expansion
1528        // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529        // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530        // the typed `:caminho` accepted set now structurally excludes
1531        // the entire POSIX pathname-expansion / glob surface —
1532        // unbounded glob (`*` / `?`) AND bounded character-class
1533        // (`[abc]` / `[a-z]`).
1534        //
1535        // The arm fires AFTER the shell-brace-expansion arm because
1536        // the prior arm's `{` / `}` shape is the more semantic-
1537        // locating axis on values that probe as both
1538        // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539        // expansion fan is the load-bearing root-cause edit, so
1540        // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541        // discipline every prior `:caminho` arm establishes). The arm
1542        // fires BEFORE the trailing-`/` arm because the embedded
1543        // bracket-expansion byte is the more semantic-locating axis
1544        // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545        // load-bearing diagnostic is the embedded `[` glob-character-
1546        // class metachar — the trailing `/` is the secondary
1547        // observation, and an author who removes the `[` is likely
1548        // to also tab-strip the trailing separator).
1549        for &b in caminho.as_bytes() {
1550            if b == b'[' || b == b']' {
1551                return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552                    nome, caminho, b,
1553                ));
1554            }
1555        }
1556        // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557        // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558        // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559        // delimiter pair — same paste-from-shell-prompt footgun class,
1560        // different syntactic surface. Every POSIX shell (sh / bash /
1561        // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562        // string-literal quoting operator: `'…'` is the strong
1563        // (no-expansion) single-quoted string and `"…"` is the weak
1564        // (variable-/command-substitution-preserving) double-quoted
1565        // string — the canonical `cd '../caixa-teia'` shell-history
1566        // idiom every path-with-embedded-whitespace paste block carries,
1567        // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568        // shape. Beyond shell, the two bytes carry the JSON string-literal
1569        // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570        // config cross-idiom-leak vector), the YAML double-quoted +
1571        // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572        // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573        // manifest cross-idiom leak), the TOML basic + literal string
1574        // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575        // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576        // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577        // — the canonical "I copied the entire `:caminho "..."` slot
1578        // rather than just the string body" author-surface footgun),
1579        // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580        // excludes both bytes from the `unreserved / pct-encoded /
1581        // sub-delims / ":" / "@"` `pchar` production. POSIX
1582        // `std::path::Path` treats both bytes as literal path-component
1583        // bytes (so `../"caixa-teia"` is one directory named literally
1584        // `../"caixa-teia"`, sibling of `.` and `..`).
1585        //
1586        // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587        // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588        // quoting preserved the sibling-workspace path verbatim across
1589        // the whitespace paste boundary" footgun), `:caminho
1590        // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591        // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592        // string / paste-from-tatara-lisp string-literal cross-idiom-
1593        // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594        // quote "I pasted a JSON key-value pair fragment into the
1595        // middle of the path" idiom) silently passes every prior arm
1596        // because `Path::is_absolute` returns false on `..` / `'` /
1597        // `"`, `'` / `"` are neither leading-byte sentinels nor
1598        // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599        // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600        // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601        // folds the value through `Path::new(caminho).join(<file>)`
1602        // looking for a literal `./'../caixa-teia'` subdirectory and
1603        // fails at resolve time with a non-self-locating `No such file
1604        // or directory` error far from the source caixa.lisp.
1605        //
1606        // The lacre pipeline embeds the value verbatim in its per-dep
1607        // content-address (`conteudo: format!("path:{caminho}")`,
1608        // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609        // lands in the BLAKE3 closure and rides downstream as part of
1610        // the build's identity into every shell-spawned subprocess
1611        // (the caixa-resolver's `git clone` invocation, a future
1612        // `feira tofu` shell-out, a future operator-side `nix flake
1613        // check` spawn) as the canonical shell-metachar / string-
1614        // literal-delimiter surface every peer single-token-shaped
1615        // typed slot already closes. The peer `:fonte :repo` axis
1616        // closes both bytes under the same shell-quote-grouping /
1617        // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618        // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619        // `:caminho` axis was the last typed path-string surface
1620        // still admitting these two bytes; this arm closes the gap
1621        // so the substrate-wide "no shell-composition metacharacter
1622        // anywhere in a typed string slot that flows verbatim into a
1623        // shell-spawned subprocess" invariant extends from shell-
1624        // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625        // / `"`) on the `:caminho` axis. Together with the peer
1626        // JSON / YAML / TOML string-literal delimiters closing at
1627        // this arm and the 598b770 `{` / `}` brace-expansion arm
1628        // closing the templating-engine-placeholder boundary, the
1629        // typed `:caminho` accepted set now structurally excludes
1630        // the entire cross-config-DSL string-literal / templating
1631        // paste-from-aligned-manifest cross-idiom-leak surface that
1632        // would silently round-trip through any downstream JSON /
1633        // YAML / TOML / HCL / tatara-lisp parsing layer.
1634        //
1635        // The arm fires AFTER the shell-bracket-expansion arm because
1636        // the prior arm's `[` / `]` shape is the more semantic-
1637        // locating axis on values that probe as both (`"../[a-z]'x'"`
1638        // carries both `[` and `'` — the glob-character-class
1639        // expansion is the load-bearing root-cause edit, so
1640        // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641        // discipline every prior `:caminho` arm establishes). The arm
1642        // fires BEFORE the trailing-`/` arm because the embedded
1643        // quote-grouping byte is the more semantic-locating axis on
1644        // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645        // the load-bearing diagnostic is the embedded `'` shell-
1646        // string-literal metachar — the trailing `/` is the secondary
1647        // observation, and an author who removes the `'` is likely to
1648        // also tab-strip the trailing separator).
1649        for &b in caminho.as_bytes() {
1650            if b == b'\'' || b == b'"' {
1651                return Err(DepError::fonte_caminho_shell_quote_grouping(
1652                    nome, caminho, b,
1653                ));
1654            }
1655        }
1656        // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657        // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658        // the orthogonal "byte at which four distinct downstream parsers all
1659        // truncate the value at the first occurrence" surface, and no prior arm
1660        // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661        // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662        // of a word (or after unquoted whitespace) as the comment-lead: from
1663        // that byte to the end of the physical line is a comment discarded
1664        // before command parsing (`cd ../caixa-teia  # legacy sibling` — the
1665        // canonical paste-from-shell-history-with-trailing-annotation shape
1666        // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667        // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668        // at any position preceded by whitespace or at line-start (`path:
1669        // ../caixa-teia  # pin` — the canonical paste-from-values.yaml /
1670        // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671        // treats `;` as the comment-lead but a growing number of consumer
1672        // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673        // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674        // the comment-lead too — the pair extends the cross-config-DSL
1675        // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676        // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677        // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678        // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679        // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680        // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681        // `#` selects a flake output — the same axis the peer
1682        // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683        // surface at a68f818 with the same downstream-drops-the-tail
1684        // rationale).
1685        //
1686        // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687        // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688        // paste-from-shell-history-with-trailing-annotation footgun),
1689        // `:caminho "../caixa-teia  # pin"` (the symmetric YAML flow-scalar
1690        // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691        // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692        // silently passes every prior arm because `Path::is_absolute` returns
1693        // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694        // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695        // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696        // and the value's last byte isn't `/`. The resolver folds the value
1697        // through `Path::new(caminho).join(<file>)` looking for a literal
1698        // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699        // resolve time with a non-self-locating `No such file or directory`
1700        // error far from the source caixa.lisp — while every downstream
1701        // shell / YAML / URL parser silently truncates the value at the `#`
1702        // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703        // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704        // an emitted YAML `path:` scalar disagree with the resolver on which
1705        // directory the value names. Two workstations whose downstream
1706        // shell / YAML / URL parsing layers differ in unquoted-`#`
1707        // recognition emit divergent build artifacts for the byte-identical
1708        // caixa.lisp value.
1709        //
1710        // The lacre pipeline embeds the value verbatim in its per-dep
1711        // content-address (`conteudo: format!("path:{caminho}")`,
1712        // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713        // closure and rides downstream as part of the build's identity into
1714        // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715        // invocation, a future `feira tofu` shell-out, a future operator-side
1716        // `nix flake check` spawn) as the canonical shell-metachar /
1717        // comment-lead / URL-fragment-delimiter surface every peer
1718        // single-token-shaped typed slot already closes. The peer `:fonte
1719        // :repo` axis closes the byte under the URL-fragment-identifier
1720        // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721        // the last typed path-string surface still admitting the byte. This
1722        // arm closes the gap so the substrate-wide "no shell-composition
1723        // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724        // typed string slot that flows verbatim into a shell-spawned
1725        // subprocess or downstream YAML / URL parser" invariant extends from
1726        // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727        // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728        // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729        // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730        // templating-engine-placeholder boundary, the typed `:caminho`
1731        // accepted set now structurally excludes the entire
1732        // paste-with-trailing-annotation / paste-from-URL-permalink /
1733        // paste-from-YAML-comment cross-idiom-leak surface that would
1734        // silently round-trip through any downstream shell / YAML / URL /
1735        // dotenv / gitconfig / HCL parsing layer to a different value than
1736        // the resolver's `Path::join` sees.
1737        //
1738        // The arm fires AFTER the shell-quote-grouping arm because the prior
1739        // arm's `'` / `"` shape is the more semantic-locating axis on values
1740        // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741        // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742        // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743        // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744        // trailing-`/` arm because the embedded comment-lead / fragment-
1745        // delimiter byte is the more semantic-locating axis on probe-as-both
1746        // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747        // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748        // observation, and an author who removes the `#pin` fragment is
1749        // likely to also tab-strip the trailing separator).
1750        for &b in caminho.as_bytes() {
1751            if b == b'#' {
1752                return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753            }
1754        }
1755        // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756        // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757        // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758        // byte — the mandatory encoding mechanism for every byte outside the
1759        // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760        // itself must be percent-encoded as `%25` to appear literally inside
1761        // a URL value. The byte carries three distinct render-determinism
1762        // hazards on the `:caminho` axis, no prior arm has covered it, and
1763        // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764        // already closes the same byte under the same URL-percent-encoding
1765        // banner — the `:caminho` axis was the last typed path-string surface
1766        // still admitting the byte.
1767        //
1768        // First, the paste-from-browser-address-bar percent-encoded-space
1769        // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770        // README hyperlink / a browser address bar / a percent-encoded
1771        // permalink expecting `%20` to decode to a literal space at the
1772        // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773        // literal path-component byte, so `Path::join` looks for a literal
1774        // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775        // non-self-locating `No such file or directory` error far from the
1776        // source caixa.lisp — while the author's mental model was
1777        // `../caixa teia`, the decoded shape. Two authors whose only
1778        // difference is percent-encoding presence resolve to two distinct
1779        // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780        // for what they intended as the byte-identical sibling-workspace
1781        // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782        // content-address (`conteudo: format!("path:{caminho}")`,
1783        // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784        // downstream into the BLAKE3 closure and locks the substrate's
1785        // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786        // to the wrong encoding — the same THEORY.md §V.2 render-
1787        // determinism vector every prior `:caminho` arm protects.
1788        //
1789        // Second, the printf-format-specifier lead footgun: `%` is the C /
1790        // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791        // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792        // shell-diagnostic one-liner carries) and the printf builtin is
1793        // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794        // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795        // value flowing into any future `feira` verb that shells out with a
1796        // printf-formatted path template silently gets reinterpreted as a
1797        // format-directive rather than a literal byte — the canonical
1798        // CWE-134 format-string-injection vector.
1799        //
1800        // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801        // ksh reserve `%N` at word-start as the job-control specifier —
1802        // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803        // "the most recent job whose command started with `foo`". A future
1804        // `feira` verb that invokes `kill %1` on a caminho-scoped
1805        // subprocess would silently redirect the signal to a wrong target.
1806        //
1807        // Beyond the three shell-side hazards, `%` is a first-class parser
1808        // byte in three cross-config-DSL layers the substrate's paste-idiom
1809        // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810        // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811        // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812        // YAML directive block silently trips the YAML directive parser on
1813        // any downstream emitted YAML manifest); Prometheus / Grafana
1814        // template syntax uses `%(var)s` as the substitution lead; and Nix
1815        // interpolation uses `${var}` (not `%`) but Envsubst /
1816        // Kubernetes / OpenShift template layers use `%VAR%` as the
1817        // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818        // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819        //
1820        // The three malformed-`%HH` classes documented on the peer
1821        // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822        //
1823        //   - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824        //     where `%` isn't followed by two hex digits) — every WHATWG-
1825        //     conformant URL parser rejects the value at parse time per
1826        //     RFC 3986 §2.1, but the byte rides into the lacre before
1827        //     the resolver subprocess crosses the URL-parser boundary.
1828        //   - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829        //     intending the `%2F` as the URL encoding of `/`) locks a
1830        //     `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831        //     the byte-identical `path:../caixa/teia` form.
1832        //   - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833        //     already itself an encoded `%`, so the intent was likely a
1834        //     literal `%20` that survived one round-trip through a
1835        //     URL-encoder that shouldn't have run) locks a triply-
1836        //     divergent closure across the encoded / once-decoded /
1837        //     twice-decoded chain.
1838        //
1839        // POSIX `std::path::Path` treats the byte as a literal path-
1840        // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841        // paste-from-browser-address-bar percent-encoded-space footgun),
1842        // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843        // directive-block cross-idiom leak), or `:caminho
1844        // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845        // shell-diagnostic-one-liner shape) silently passes every prior arm
1846        // because `Path::is_absolute` returns false on `..`, `%` is neither
1847        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850        // value's last byte isn't `/`. The resolver folds the value through
1851        // `Path::new(caminho).join(<file>)` looking for a literal
1852        // subdirectory named `../caixa%20teia` and fails at resolve time
1853        // with a non-self-locating `No such file or directory` error far
1854        // from the source caixa.lisp — while every downstream URL parser /
1855        // shell printf builtin / YAML directive parser silently
1856        // reinterprets the byte to a different value than the resolver's
1857        // `Path::join` sees. Two workstations whose downstream URL / shell
1858        // / YAML layers differ in `%HH` recognition emit divergent build
1859        // artifacts for the byte-identical caixa.lisp value.
1860        //
1861        // The lacre pipeline embeds the value verbatim in its per-dep
1862        // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863        // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864        // closure and rides into every shell-spawned subprocess (the
1865        // resolver's `git clone`, a future `feira tofu` shell-out, a
1866        // future operator-side `nix flake check` spawn) as the canonical
1867        // URL-percent-encoding-escape / printf-format-specifier / bash-
1868        // job-control-specifier surface every peer single-token-shaped
1869        // typed slot already closes. This arm closes the gap so the
1870        // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871        // specifier / job-control-specifier / YAML-directive-lead byte
1872        // anywhere in a typed string slot that flows verbatim into a
1873        // shell-spawned subprocess or downstream URL / printf / YAML
1874        // parser" invariant extends from shell-comment / URL-fragment
1875        // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876        // `:caminho` axis.
1877        //
1878        // The arm fires AFTER the shell-comment arm because the prior
1879        // arm's `#` shape is the more semantic-locating axis on values
1880        // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881        // and `#` — the URL-fragment-identifier is the load-bearing
1882        // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883        // same cascade discipline every prior `:caminho` arm establishes).
1884        // The arm fires BEFORE the trailing-`/` arm because the embedded
1885        // percent-encoding-escape byte is the more semantic-locating axis
1886        // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887        // the load-bearing diagnostic is the embedded `%` percent-
1888        // encoding-escape — the trailing `/` is the secondary observation,
1889        // and an author who decodes the `%20` to a literal space is
1890        // likely to also tab-strip the trailing separator).
1891        for &b in caminho.as_bytes() {
1892            if b == b'%' {
1893                return Err(DepError::fonte_caminho_url_percent_encoding(
1894                    nome, caminho, b,
1895                ));
1896            }
1897        }
1898        // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899        // command-substitution / arithmetic-expansion arm. The f4efe9c
1900        // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901        // through `FonteCaminhoVarExpansion` under the leading-byte-
1902        // sentinel host-layout-leak banner (peer with the b94fd83
1903        // absolute / a5c248e tilde leading-byte arms), but the arm
1904        // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905        // (embedded `$HOME` in a nested path segment — the canonical
1906        // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907        // an author copies a partially-substituted shell one-liner and
1908        // the leading segment is a literal `../foo` while the mid
1909        // segment carries the un-substituted `$HOME` template), a
1910        // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911        // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912        // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913        // (the paste-from-shell-prompt command-substitution idiom), or
1914        // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915        // idiom) silently passes every prior arm because
1916        // `Path::is_absolute` returns false on `..`, `$` is neither a
1917        // leading-byte sentinel (the f4efe9c arm fires only at position
1918        // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919        // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920        // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921        // value's last byte isn't `/`. Note that `$(...)` command-
1922        // substitution and `$((...))` arithmetic-expansion each carry
1923        // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924        // arm catches structurally at the earlier `(` position — but
1925        // an author who reaches for the sh-brace-substitution
1926        // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927        // which no prior arm covers. This arm closes the last
1928        // positional gap on the `$` byte on the `:caminho` axis so
1929        // every position — leading (`FonteCaminhoVarExpansion`) and
1930        // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931        // structurally rejected.
1932        //
1933        // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934        // ash / fish / nushell) lexes `$` as the variable-expansion /
1935        // command-substitution / arithmetic-expansion operator per
1936        // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937        // Expansion) expands a named variable, `${<name>}` (Parameter
1938        // Expansion braced form) does the same with an explicit token
1939        // boundary, `$(<cmd>)` (Command Substitution modern form,
1940        // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941        // already closes) runs a subshell and substitutes its stdout,
1942        // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943        // arithmetic expression. Every form is a host-layout /
1944        // environment-state / shell-subprocess-side-effect leak when
1945        // the byte lands in a value the resolver passes to a shell-
1946        // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947        // the Nix `${var}` string-interpolation lead (the paste-from-
1948        // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949        // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950        // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951        // variable lead (the paste-from-`Makefile` shape), the
1952        // JavaScript / TypeScript template-literal `${expr}` interp
1953        // lead (the paste-from-JS-template-string idiom in a
1954        // multi-lang-monorepo where a `path` attribute gets copied out
1955        // of a `package.json` script or a Vite config), the envsubst /
1956        // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957        // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958        // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959        // from-`.php`-config footgun), the Perl scalar-variable lead
1960        // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961        // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962        // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963        // cross-idiom paste-footgun surface is broader than any single
1964        // shell layer — `$` is a first-class parser byte in nearly
1965        // every config / templating / build-system DSL the substrate's
1966        // paste-idiom surface routinely crosses. The peer `:fonte
1967        // :repo` axis closes the byte under the shell-variable-
1968        // expansion / URL-sub-delim banner (b9d187c `$` on
1969        // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970        // axes close `$` as part of `is_git_ref_name`'s printable-
1971        // ASCII-restricted grammar (`git check-ref-format` rejects the
1972        // byte outright), and the peer `:entrada :paths` axis closes
1973        // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974        // reserved set. The `:caminho` axis was the last typed path-
1975        // string surface still admitting `$` at positions other than 0.
1976        //
1977        // POSIX `std::path::Path` treats `$` as a literal path-
1978        // component byte, so `:caminho "../foo$HOME/bar"` silently
1979        // routes through `Path::new(caminho).join(<file>)` looking for
1980        // a literal `./{caminho}` subdirectory that fails at resolve
1981        // time with a non-self-locating `No such file or directory`
1982        // error far from the source caixa.lisp. But every downstream
1983        // shell / envsubst / Nix / Make / K8s-template parser silently
1984        // reinterprets the byte to a different value than the
1985        // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986        // to a `cd '{caminho}'` command line, a `nix flake check`
1987        // invocation on an emitted YAML `path:` scalar folded through
1988        // envsubst, or a `helm template` invocation with a
1989        // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990        // template all disagree with the resolver on which directory
1991        // the value names. Two workstations whose downstream shell /
1992        // envsubst / Nix / Make / K8s-template parsing layers differ
1993        // in `$VAR` recognition (or, worse, expand the byte against
1994        // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995        // `$HOME=/home/bob`) emit divergent build artifacts for the
1996        // byte-identical caixa.lisp value. Even in the case where the
1997        // resolver strictly does NOT expand `$VAR` (the current
1998        // implementation) the divergence still bites at the lacre-
1999        // identity axis: the lacre pipeline embeds the value verbatim
2000        // in its per-dep content-address (`conteudo:
2001        // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002        // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003        // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004        // one author would have produced by substituting the literal
2005        // value at author time, defeating the THEORY.md §V.2 render-
2006        // determinism contract on the same axis every prior `:caminho`
2007        // arm protects.
2008        //
2009        // Beyond the render-determinism / host-layout-leak vectors,
2010        // `$` at any position in a value flowing verbatim into a
2011        // shell-spawned subprocess is the canonical CWE-78 shell-
2012        // command-injection surface every peer single-token-shaped
2013        // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014        // that rides into a future `feira tofu` shell-out as `cd
2015        // '../foo$(whoami)/bar'` gets substituted by the shell at
2016        // subprocess-argument-expansion time even inside single quotes
2017        // in fewer positions than one might expect (the substitution
2018        // fires only outside single-quoting per POSIX §2.2.2, but
2019        // eval-style wrappers and `sh -c` layers that route the value
2020        // through re-parsing round-trip the substitution — the same
2021        // vector the c370458 backtick arm closes at the sibling
2022        // command-substitution-legacy-form surface). Every future
2023        // `feira` verb that shells out with a `caminho`-formatted
2024        // subprocess argument silently inherits this substitution
2025        // vector unless the typed slot's accepted set structurally
2026        // excludes the byte.
2027        //
2028        // Frontier inspiration: OTP's `gen_server` return-value grammar
2029        // rejects mid-tuple shell-metachar bytes by construction —
2030        // `{noreply, State}` never carries a raw `$` because the
2031        // Erlang term type system has no notion of "string that gets
2032        // shelled out"; caixa's typed slots inherit the same
2033        // structural discipline (types-are-theorems, the compounding
2034        // mandate's leverage-point-1) by refusing values that would
2035        // silently reinterpret at any downstream layer. Peer with
2036        // Unison's content-addressed code (no ambient environment —
2037        // every reference is a hash, no `$VAR` substitution possible)
2038        // and Pony's capabilities (a path capability that carries a
2039        // `$` would be ill-typed at the reference layer).
2040        //
2041        // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042        // e3558fa `%` arm) because a value carrying both `%` and `$`
2043        // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044        // encoded space next to a `$HOME` template") surfaces the
2045        // narrower URL-encoding diagnostic first — the paste-from-
2046        // browser-address-bar shape is the load-bearing self-locating
2047        // edit on every probe-as-both value; same cascade discipline
2048        // every prior `:caminho` arm establishes (a323db8 %  before
2049        // this arm, this arm before trailing-`/`). The arm fires
2050        // BEFORE the trailing-`/` arm because the embedded shell-
2051        // variable-expansion byte is the more semantic-locating axis
2052        // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053        // but the load-bearing diagnostic is the embedded `$` — the
2054        // trailing `/` is the secondary observation, and an author
2055        // who substitutes the `$HOME` template with a literal value is
2056        // likely to also tab-strip the trailing separator).
2057        for &b in caminho.as_bytes() {
2058            if b == b'$' {
2059                return Err(DepError::fonte_caminho_shell_variable_expansion(
2060                    nome, caminho, b,
2061                ));
2062            }
2063        }
2064        // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065        // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066        // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067        // orthogonal POSIX shell-history-expansion sentinel every interactive
2068        // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069        // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070        // re-runs the most recent history entry beginning with `command`,
2071        // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072        // last word of the prior command, `!:N` substitutes the Nth word,
2073        // `^old^new` rewrites the prior command's `old` to `new` (the
2074        // canonical set of `set -o histexpand` operators bash's default
2075        // interactive session enables). Beyond the shell-history layer,
2076        // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077        // admits the byte inside a path segment, but every WHATWG-conformant
2078        // special-scheme URL parser percent-encodes it inside a query
2079        // component via the 'special-query percent-encode set' the peer
2080        // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081        // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082        // (logical-negation prefix — the paste-from-source-code idiom where
2083        // an author copies `!path.exists()` out of a Rust snippet and the
2084        // trailing punctuation crosses the string-literal boundary); the
2085        // canonical English-typography emphasis / exclamation mark (the
2086        // paste-from-prose enthusiasm-form idiom where an author writes
2087        // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088        // to a kebab-case slug); and the Nix flake-ref import-attribute
2089        // `import ./foo.nix { … }` sibling operator surface.
2090        //
2091        // POSIX `std::path::Path` treats `!` as a literal path-component
2092        // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093        // from-shell-history footgun where the author copies a `cd
2094        // ../caixa-teia && !sudo make install` one-liner from a quick-
2095        // start README and the trailing `!sudo` rides in verbatim as a
2096        // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097        // `!!` repeat-prior-command paste idiom), a `:caminho
2098        // "../caixa-teia!"` (the English-typography enthusiasm-form
2099        // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100        // last-word-substitution shape) silently pass every prior arm
2101        // because `Path::is_absolute` returns false on `..`, `!` is neither
2102        // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103        // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104        // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105        // and the value's last byte isn't `/`. The resolver folds the value
2106        // through `Path::new(caminho).join(<file>)` looking for a literal
2107        // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108        // with a non-self-locating `No such file or directory` error far
2109        // from the source caixa.lisp — while every downstream interactive
2110        // shell with `set -o histexpand` reinterprets the byte as the
2111        // history-expansion prefix, and the failure mode forks per
2112        // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113        // line executed under `bash -i` (the operator-notebook interactive
2114        // shell) substitutes the `!sudo` reference to the most recent
2115        // history entry starting with `sudo`, silently invoking whatever
2116        // privileged command that entry named.
2117        //
2118        // The lacre pipeline embeds the value verbatim in its per-dep
2119        // content-address (`conteudo: format!("path:{caminho}")`,
2120        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121        // BLAKE3 closure and rides into every shell-spawned subprocess
2122        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123        // a future operator-side `nix flake check` spawn) as the
2124        // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125        // every peer single-token-shaped typed slot already closes. The
2126        // peer `:fonte :repo` axis closes the byte under the same shell-
2127        // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128        // `is_git_repo_url`); the `:caminho` axis was the last typed
2129        // path-string surface still admitting the byte. This arm closes
2130        // the gap so the substrate-wide "no shell-composition
2131        // metacharacter / history-expansion sentinel anywhere in a typed
2132        // string slot that flows verbatim into a shell-spawned subprocess"
2133        // invariant extends from shell-variable-expansion (`$`) to shell-
2134        // history-expansion (`!`) on the `:caminho` axis. Together with
2135        // the peer c370458 backtick command-substitution-legacy-form arm
2136        // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137        // sibling `:repo` axis, the typed `:caminho` accepted set now
2138        // structurally excludes every byte the POSIX shell §2.6 Word
2139        // Expansions section, §2.3 Token Recognition step 6, and every
2140        // history-expansion / brace-expansion / pathname-expansion /
2141        // parameter-expansion / command-substitution / arithmetic-
2142        // expansion operator lexes as a first-class parser byte.
2143        //
2144        // Frontier inspiration: Unison's content-addressed code (no
2145        // ambient environment — every reference is a hash, no `!<num>`
2146        // history-index substitution possible; the caixa substrate's
2147        // lacre discipline arrives at the same guarantee by refusing
2148        // bytes at manifest-parse time that would reinterpret against
2149        // ambient shell history state); Pony's capabilities (a path
2150        // capability that carries a `!` would be ill-typed at the
2151        // reference layer).
2152        //
2153        // The arm fires AFTER the shell-variable-expansion arm because a
2154        // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155        // canonical "I pasted a `$HOME`-templated path adjacent to a
2156        // trailing `!sudo` history-expansion") surfaces the narrower
2157        // shell-variable-expansion diagnostic first — the paste-from-CI-
2158        // manifest-with-`$VAR`-template shape is the load-bearing self-
2159        // locating edit on every probe-as-both value; same cascade
2160        // discipline every prior `:caminho` arm establishes. The arm
2161        // fires BEFORE the trailing-`/` arm because the embedded shell-
2162        // history-expansion byte is the more semantic-locating axis on
2163        // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164        // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165        // is the secondary observation, and an author who removes the
2166        // `!sudo` history reference is likely to also tab-strip the
2167        // trailing separator).
2168        for &b in caminho.as_bytes() {
2169            if b == b'!' {
2170                return Err(DepError::fonte_caminho_shell_history_expansion(
2171                    nome, caminho, b,
2172                ));
2173            }
2174        }
2175        // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176        // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177        // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178        // (`0x5E`) is the paired-operator half of the same bash-reference
2179        // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180        // form (POSIX bash rewrites the prior command's `old` string to
2181        // `new` and re-executes it, the canonical typo-correction one-
2182        // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183        // trailing substitution fragment verbatim into a `:caminho` value
2184        // when the author trims only the leading `git clone` prefix). The
2185        // peer `:fonte :repo` axis closes the byte under the same
2186        // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187        // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188        // path-string surface still admitting the byte after 6a04767
2189        // landed the `!` arm.
2190        //
2191        // Beyond bash history-substitution, `^` carries five distinct
2192        // downstream-reinterpretation surfaces the typed slot's accepted
2193        // set must structurally exclude:
2194        //
2195        // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196        //    layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197        //    required to percent-encode-or-refuse at the wire boundary.
2198        //    The WHATWG URL spec's 'fragment percent-encode set' maps
2199        //    `^` → `%5E` at the query / fragment component transition;
2200        //    libcurl silently percent-encodes the byte on the wire, so a
2201        //    `:caminho "../foo^bar"` value the resolver's `Path::join`
2202        //    sees as a literal `./../foo^bar` subdirectory diverges from
2203        //    the byte-transformed `%5E` shape any downstream `feira tofu`
2204        //    curl-invocation or artifact-registry-fetch would emit — the
2205        //    canonical wire-boundary divergence vector the peer
2206        //    `{`, `}`, `|`, `\` `:caminho` arms already close (
2207        //    `FonteCaminhoShellBraceExpansion` at 598b770,
2208        //    `FonteCaminhoShellPipe` at the pipe arm,
2209        //    `FonteCaminhoBackslash` at the backslash arm).
2210        // 2. **Regex character-class negation prefix `[^abc]`** — the
2211        //    canonical paste-from-doc-regex-pipeline footgun where an
2212        //    author copies a `grep '[^abc]'` idiom from a docs quick-
2213        //    listing and the character-class negation byte rides in
2214        //    verbatim.
2215        // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216        //    JavaScript / Nix / Go — the paste-from-source-code idiom
2217        //    where an author copies an `x ^ y`-shaped expression out of
2218        //    a source snippet and the operator crosses the string-
2219        //    literal boundary.
2220        // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221        //    escapes the next character in a `cmd.exe` batch context (a
2222        //    peer of the backslash arm's Windows-separator-leak vector).
2223        //    A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224        //    file footgun reinterprets at every `cmd.exe`-spawned
2225        //    subprocess (the resolver's future Windows-runner shell-out,
2226        //    the operator's WinRM path, a future PowerShell-embedded
2227        //    invocation).
2228        // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229        //    paste-from-typeset-doc footgun where a mathematical
2230        //    superscript notation (`x^2` / `M^T`) leaks from prose.
2231        //
2232        // POSIX `std::path::Path` treats `^` as a literal path-component
2233        // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234        // substitution), `:caminho "../foo^"` (trailing history-
2235        // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236        // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237        // arm at 986963b fires first on this shape), or `:caminho
2238        // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239        // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240        // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241        // / `"` / `#` / `%` / `$` / `!`) and route through
2242        // `Path::new(caminho).join(<file>)` looking for a literal
2243        // `./{caminho}` subdirectory that fails at resolve time with a
2244        // non-self-locating `No such file or directory` error far from
2245        // the source caixa.lisp — while every downstream shell / curl /
2246        // regex / `cmd.exe` layer reinterprets the byte to its own
2247        // semantic.
2248        //
2249        // The lacre pipeline embeds the value verbatim in its per-dep
2250        // content-address (`conteudo: format!("path:{caminho}")`,
2251        // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252        // BLAKE3 closure and rides into every shell-spawned subprocess
2253        // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254        // a future operator-side `nix flake check` spawn) as the
2255        // canonical shell-history-substitution / RFC-3986-unwise /
2256        // regex-negation surface every peer single-token-shaped typed
2257        // slot already closes. This arm together with the immediate-
2258        // predecessor `!` arm (6a04767) closes the full `set -o
2259        // histexpand` operator surface on the `:caminho` axis — the
2260        // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261        // quick-substitution form via `^` — so the substrate-wide "no
2262        // shell-history operator anywhere in a typed string slot that
2263        // flows verbatim into a shell-spawned subprocess" invariant
2264        // extends from the `!` prefix half to the `^` quick-substitution
2265        // half. Every peer bash-history operator now fails at manifest-
2266        // parse time with a self-locating diagnostic naming the offending
2267        // caixa.lisp rather than at resolve-time as a `Path::join`-
2268        // derived `No such file or directory` (harmless but non-self-
2269        // locating) or worse riding into a downstream `bash -i` context
2270        // that reinterprets the byte-pair against ambient history state.
2271        //
2272        // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273        // "Quick substitution. Repeat the previous command, replacing
2274        // string1 with string2." + RFC 3986 §2 'unwise' set
2275        // ("characters that gateways and other transport agents are
2276        // known to sometimes modify") + Pony's capabilities (a path
2277        // capability that carries a `^` would be ill-typed at the
2278        // reference layer, matching the same structural discipline the
2279        // sibling `!` history-expansion arm inherits from Unison's
2280        // content-addressed no-ambient-history discipline).
2281        //
2282        // The arm fires AFTER the shell-history-expansion `!` arm because
2283        // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284        // the canonical "I pasted a `!sudo` history-reference next to a
2285        // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286        // form `!` diagnostic first — the `!` form is the load-bearing
2287        // self-locating edit on every probe-as-both value (an author who
2288        // removes the `!sudo` reference is likely to also strip the
2289        // paired `^` substitution fragment); same cascade discipline
2290        // every prior `:caminho` arm establishes. The arm fires BEFORE
2291        // the trailing-`/` arm because the embedded shell-history-
2292        // substitution byte is the more semantic-locating axis on
2293        // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294        // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295        // is the secondary observation, and an author who removes the
2296        // `^bar` substitution fragment is likely to also tab-strip the
2297        // trailing separator).
2298        for &b in caminho.as_bytes() {
2299            if b == b'^' {
2300                return Err(DepError::fonte_caminho_shell_history_substitution(
2301                    nome, caminho, b,
2302                ));
2303            }
2304        }
2305        // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306        // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307        // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308        // backslash arm closes the cross-host-OS-separator vector. The
2309        // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310        // footgun — `Path::join("../caixa-teia")` and
2311        // `Path::join("../caixa-teia/")` resolve to the same directory
2312        // (POSIX path-component-walk treats trailing `/` as a no-op for
2313        // directory targets, which `:caminho` always names — the sibling-
2314        // workspace dep root is structurally a directory). The lacre
2315        // pipeline embeds the value verbatim in its per-dep content-address
2316        // (`conteudo: format!("path:{caminho}")`,
2317        // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318        // semantic-meaning yields two distinct BLAKE3 closures depending on
2319        // whether the author shell-tab-completed the path (every interactive
2320        // shell appends `/` on tab-completing a directory, idiomatic in
2321        // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322        // shells emits without trailing `/`, but `realpath -e -m` on a
2323        // directory with trailing `/` preserves it), or copied a Cargo
2324        // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325        // (Cargo accepts both shapes and folds them the same way). Two
2326        // workstations whose authors differ only in tab-completion habits
2327        // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328        // and the substrate's "the lacre is the build's identity" contract
2329        // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330        //
2331        // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332        // arm protects, here against the trailing-separator divergence
2333        // vector: every typed slot's accepted set excludes byte-divergent
2334        // values that round-trip to the same downstream semantic. The peer
2335        // path-shaped axes already reject trailing separators on the same
2336        // contract: [`crate::render::is_gateway_api_http_path`] gates
2337        // `:entrada :paths` against any non-canonical normalization, and
2338        // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339        // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340        // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341        // whose canonical form would re-introduce determinism divergence.
2342        //
2343        // The arm fires last in the cascade because every prior arm carries
2344        // a more self-locating diagnostic on values that probe as both
2345        // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346        // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347        // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348        // the load-bearing diagnostic is the absolute host-layout-leak —
2349        // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350        // but the load-bearing diagnostic is the Windows-separator cross-
2351        // OS divergence — the backslash arm wins). The arm covers every
2352        // shape where the last byte is `/` regardless of length, including
2353        // the degenerate single-`/` (which the absolute arm catches first)
2354        // and the consecutive-`//` (where every prior arm passes on the
2355        // bytes other than the trailing `/`).
2356        if caminho.as_bytes().last() == Some(&b'/') {
2357            return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358        }
2359        Ok(())
2360    }
2361}
2362
2363impl Dep {
2364    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365    /// accessor every consumer of the dep-graph identity axis keys off —
2366    /// returns the author-declared `:nome` byte-string verbatim as a
2367    /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368    ///
2369    /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370    /// label that names the target caixa (validated by [`Self::validate`]
2371    /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372    /// same accept-set the peer caixa-identifier axes carry — top-level
2373    /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374    /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375    /// downstream consumer that fans on the dep's name-identity keys off
2376    /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377    /// [`crate::render::insert_first_seen`] dedup key + the paired
2378    /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379    /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380    /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381    /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382    /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383    /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384    /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385    /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386    /// every `caixa-resolver` `ResolveError::MissingPath` /
2387    /// `ResolveError::MissingPin` carrier that names the offending dep
2388    /// (`resolve.rs:177,206`), each resolved
2389    /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390    /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391    /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392    ///
2393    /// Prior to this lift the `.nome` byte-string was read inline at every
2394    /// production site — the [`crate::Caixa::validate_deps`] paired
2395    /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396    /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397    /// parent-equality checks, and every caixa-resolver / caixa-feira
2398    /// site enumerated above — open-coded field-accesses that expressed
2399    /// no compile-time link back to the typed slot. A future extension of
2400    /// the `:deps :nome` axis to a richer author surface (a per-scope
2401    /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402    /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403    /// namespace-qualified rewrite the future M4 lacre-federation layer
2404    /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405    /// to a richer scoped-identifier newtype once cross-registry federation
2406    /// lands) would have had to be threaded through every open-coded copy
2407    /// in lockstep or two consumers would silently disagree on which caixa
2408    /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409    /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410    /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411    /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412    /// requeue-suppression seen-set, one build-time diagnostic
2413    /// disagreeing with the run-time closure the substrate's lacre
2414    /// pipeline actually materializes. Lifting the resolution rule to a
2415    /// typed method on the substrate primitive means every downstream
2416    /// consumer of the caixa's per-`:deps` identity surface reaches for
2417    /// exactly one typed dispatch — the resolver's accept-set migrates as
2418    /// a unit on any future axis addition.
2419    ///
2420    /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421    /// `&str`-return required-scalar projection pattern the sibling
2422    /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423    /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424    /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425    /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426    /// accessors — same "one typed dispatch on the substrate primitive,
2427    /// thin projections at each consumer" discipline extended onto the
2428    /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429    /// remaining unlifted caixa-name-referencing accessor family in the
2430    /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431    /// term the field's docstring already reaches for ("Caixa name — must
2432    /// match the target caixa's `:nome`") and the peer caixa-identity
2433    /// accessor family the substrate already carries.
2434    #[must_use]
2435    pub const fn nome(&self) -> &str {
2436        self.nome.as_str()
2437    }
2438
2439    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440    /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441    /// the dep-graph version-pin axis keys off — returns the author-
2442    /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443    /// borrowed from the typed slot's own [`String`] storage.
2444    ///
2445    /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446    /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447    /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448    /// entry-point consumes — same accept-set the peer requirement-
2449    /// carrying axes carry (per-`:membros`
2450    /// [`crate::Membro::versao_requirement`], per-`:children`
2451    /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452    /// through the shared
2453    /// [`crate::render::require_valid_versao_requirement`] cascade in
2454    /// [`Self::validate`]. Every downstream consumer that fans on the
2455    /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456    /// `require_valid_versao_requirement` gate + the paired
2457    /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458    /// requirement-shape rejection, the `feira lock` stub-resolver's
2459    /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460    /// `conteudo` hash-input interpolation and the paired
2461    /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462    /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463    ///
2464    /// Prior to this lift the `.versao` byte-string was read inline at
2465    /// every production site — the [`Self::validate`] paired
2466    /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467    /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468    /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469    /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470    /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471    /// same shapes — open-coded field-accesses that expressed no
2472    /// compile-time link back to the typed slot. A future extension of
2473    /// the `:deps :versao` axis to a richer author surface (a per-scope
2474    /// version-lock overlay the resolver folds through the
2475    /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476    /// docstring already acknowledges, a per-cluster canary-version
2477    /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478    /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479    /// once cross-registry federation lands) would have had to be
2480    /// threaded through every open-coded copy in lockstep or two
2481    /// consumers would silently disagree on which release constraint a
2482    /// given dep resolves to — the [`Self::validate`] requirement-gate
2483    /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484    /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485    /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486    /// content-addressed hash the substrate's fetch pipeline actually
2487    /// materializes, one build-time diagnostic disagreeing with the
2488    /// run-time closure. Lifting the resolution rule to a typed method
2489    /// on the substrate primitive means every downstream consumer of
2490    /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491    /// one typed dispatch — the resolver's accept-set migrates as a
2492    /// unit on any future axis addition.
2493    ///
2494    /// Second accessor on the outer `Dep` type — folds on the outer-
2495    /// `Dep` `&str`-return required-scalar projection pattern the
2496    /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497    /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498    /// (a40b0e3) / per-`:children`
2499    /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500    /// family) member/child version-pin accessors — the three
2501    /// requirement-carrying axes (`Dep::versao_requirement` on the
2502    /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503    /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504    /// Supervisor side) now share one accessor discipline for the
2505    /// shared substrate concept "another caixa referenced by a
2506    /// Cargo-shaped semver requirement". The pair
2507    /// `(nome(), versao_requirement())` jointly projects the
2508    /// `(nome, versao)` field pair every dep-graph consumer that fans
2509    /// on per-dep identity + version pin keys off. Named
2510    /// `versao_requirement()` rather than `versao()` because the field's
2511    /// storage-side `.versao` label is already the author-surface term
2512    /// (`:versao`); the accessor's name carries the semantic role — the
2513    /// semver *requirement* string the shared
2514    /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515    /// raw field access and a typed dispatch read differently at every
2516    /// consumer site. Matches the peer
2517    /// [`crate::Membro::versao_requirement`] /
2518    /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519    /// discipline verbatim.
2520    #[must_use]
2521    pub const fn versao_requirement(&self) -> &str {
2522        self.versao.as_str()
2523    }
2524
2525    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526    /// Zig-store-model per-dep source-tuple optional-composite-reference
2527    /// accessor every consumer of the dep-graph fetch-source axis keys
2528    /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529    /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530    /// own `Option<DepSource>` storage, with `None` naming the "author
2531    /// omitted `:fonte`" shorthand every resolver-side default-fill
2532    /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533    /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534    /// the [`Dep::fonte`] field docstring already documents) treats as
2535    /// the "resolve through the configured default host / org
2536    /// (`github:<default-org>/<nome>`)" partition.
2537    ///
2538    /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539    /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540    /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541    /// rev, branch }` for the git-clone arm every published caixa
2542    /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543    /// local-filesystem arm every unpublishable in-tree checkout
2544    /// resolves through. Every downstream consumer that fans on the
2545    /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546    /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547    /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548    /// diagnostics through the [`DepError::Fonte*`] carrier family
2549    /// naming the offending `Dep::nome`), the caixa-crd conversion
2550    /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551    /// `{repo, git_ref}` pair the K8s-CR side consumes
2552    /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553    /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554    /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555    /// concrete `DepSource` at run time.
2556    ///
2557    /// Prior to this lift the `.fonte` typed slot was read inline at
2558    /// every production site — the [`Self::validate`]
2559    /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560    /// gate delegates through, the caixa-crd `dep_into_ref`
2561    /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562    /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563    /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564    /// coded field-accesses that expressed no compile-time link back to
2565    /// the typed slot. A future extension of the `:deps :fonte` axis
2566    /// to a richer author surface (a per-scope source-override table
2567    /// the resolver folds through the `~/.config/caixa/config.yaml`
2568    /// entry the [`Dep`] docstring already acknowledges, a per-org
2569    /// mirror-fallback list the future M4 lacre-federation resolver
2570    /// consults ahead of the `default_github` fallback, a promotion of
2571    /// the plain `Option<DepSource>` to a richer
2572    /// `{primary, mirrors, integrity}` triple once cross-registry
2573    /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574    /// M4 lacre gate binds against ahead of the git-fetch) would have
2575    /// had to be threaded through every open-coded copy in lockstep or
2576    /// two consumers would silently disagree on which fetch source a
2577    /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578    /// gate reading the author-declared source while the caixa-crd
2579    /// projector read a per-scope-override-resolved source would
2580    /// silently split the build-time refusal from the CR the
2581    /// substrate's admission pipeline actually materializes, one
2582    /// build-time diagnostic disagreeing with the run-time closure.
2583    /// Lifting the resolution rule to a typed method on the substrate
2584    /// primitive means every downstream consumer of the caixa's per-
2585    /// `:deps` fetch-source surface reaches for exactly one typed
2586    /// dispatch — the resolver's accept-set migrates as a unit on any
2587    /// future axis addition.
2588    ///
2589    /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590    /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591    /// reference projection pattern the sibling per-`Dep` `:opcional`
2592    /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593    /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594    /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595    /// `Option<&Composite>` composite-reference sub-family the
2596    /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597    /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598    /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599    /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600    /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601    /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602    /// accessor already carries — extends that "one typed dispatch on
2603    /// the substrate primitive, thin projections at each consumer"
2604    /// discipline onto the third outer typed-slot altitude that carries
2605    /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606    /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607    /// copy or clone) because every downstream consumer of the fonte
2608    /// composite treats it as a read-only per-arm dispatch source — the
2609    /// reference-view is the narrowest borrow that supports every
2610    /// present + roadmapped consumer (per-arm match projection at the
2611    /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612    /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613    /// `default_github` fill applies" partition every resolver
2614    /// consults, `.cloned()`-on-demand for the two resolver-side
2615    /// default-fill call sites that require an owned `DepSource` for
2616    /// `Option::unwrap_or_else`) without cloning the composite through
2617    /// every consumer's fast path. The `Option` half of the return-type
2618    /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619    /// side default applies" partition (not a default composite the
2620    /// downstream must reject on emptiness) — the accessor projects the
2621    /// raw `Option<DepSource>` slot's presence bit through the
2622    /// reference-return unchanged. Named `fonte()` to match the storage
2623    /// field's name verbatim and the tatara-lisp author-surface term
2624    /// (`:fonte`) the field's own docstring already carries.
2625    ///
2626    /// Declared `pub const fn` — the body projects through
2627    /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628    /// well within the workspace MSRV, so every downstream `const`-
2629    /// context consumer of the per-`Dep` `:fonte` composite-reference
2630    /// accessor reaches through the same typed dispatch on the
2631    /// substrate primitive at const-eval time as at runtime. The
2632    /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633    /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634    /// that forwards through each lifted accessor) locks the posture
2635    /// load-bearing at caixa-core build time — any future accidental
2636    /// downgrade to non-`const` fails the wrapper with E0015
2637    /// (`cannot call non-const method`), strictly stronger than a
2638    /// runtime `assert!` and side-stepping the destructor-in-const
2639    /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640    /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641    /// `WitContract` pre-projection accessor family's `const`-eval-
2642    /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643    /// accessor family's parallel pass (231a968) — same "one canonical
2644    /// dispatch per axis, `const`-eval posture pinned at the substrate
2645    /// primitive, thin projections at each consumer" discipline
2646    /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647    ///
2648    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649    #[must_use]
2650    pub const fn fonte(&self) -> Option<&DepSource> {
2651        self.fonte.as_ref()
2652    }
2653
2654    /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655    /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656    /// every consumer of the dep-graph feature-flag axis keys off —
2657    /// returns the author-declared `:caracteristicas` feature-name list
2658    /// verbatim as a `&[String]` slice-view over the same backing buffer
2659    /// the raw `self.caracteristicas.as_slice()` field access borrows
2660    /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661    /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662    /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663    /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664    /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665    /// — possibly empty — and the returned `&[String]` degenerates to
2666    /// an empty slice on that arm without any silent `None` collapse).
2667    ///
2668    /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669    /// carries the set-shaped feature-toggle list the substrate walks
2670    /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671    /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672    /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673    /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674    /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675    /// walk, empty-first / value-shape-second / duplicate-third
2676    /// precedence via the peer per-axis two-arm cascade discipline every
2677    /// substrate-blessed Vec-keyed-by-name slot already follows).
2678    /// Every downstream consumer that fans on the dep's feature-toggle
2679    /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680    /// per-entry linear walk that gates each feature-name byte-string
2681    /// through the empty / value-shape / duplicate arms (raising the
2682    /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683    /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684    /// offending `Dep::nome`), and every future
2685    /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686    /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687    /// future caixa-resolver per-dep feature-projection walk that folds
2688    /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689    /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690    /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691    /// features slice the K8s-CR admission gate consumes, the future
2692    /// per-cluster feature-overlay the M4 lacre-federation resolver
2693    /// composes ahead of the substrate-wide feature-name accept-set).
2694    ///
2695    /// Prior to this lift the `.caracteristicas` byte-string list was
2696    /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697    /// &self.caracteristicas` walk — the only in-crate consumer of the
2698    /// raw field beyond the per-`Dep` constructor pair
2699    /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700    /// round-trip / per-test fixture-mutation paths — an open-coded
2701    /// field-access that expressed no compile-time link back to the
2702    /// typed slot. A future extension of the `:caracteristicas` axis to
2703    /// a richer author surface (a per-scope feature-overlay the resolver
2704    /// folds through the `~/.config/caixa/config.yaml` entry the
2705    /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706    /// activation overlay the future M4 lacre-federation layer applies
2707    /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708    /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709    /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710    /// docstring anticipates lands) would have had to be threaded
2711    /// through every open-coded copy in lockstep or two consumers
2712    /// would silently disagree on which feature closure a given dep
2713    /// activates — the [`Self::validate_caracteristicas`] gate walking
2714    /// the author-declared list while a downstream caixa-resolver
2715    /// consumer walked a per-scope-override-resolved list would
2716    /// silently split the build-time refusal from the lacre closure
2717    /// the substrate's fetch pipeline actually materializes, one
2718    /// build-time diagnostic disagreeing with the run-time closure.
2719    /// Lifting the resolution rule to a typed method on the substrate
2720    /// primitive means every downstream consumer of the caixa's per-
2721    /// `:deps` feature-toggle surface reaches for exactly one typed
2722    /// dispatch — the resolver's accept-set migrates as a unit on any
2723    /// future axis addition.
2724    ///
2725    /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726    /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727    /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728    /// future outer scalar lift folds on and closes the outer-`Dep`
2729    /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731    /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732    /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733    /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734    /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735    /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736    /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737    /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738    /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739    /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740    /// altitude — extends the "one typed dispatch on the substrate
2741    /// primitive, thin projections at each consumer" discipline onto the
2742    /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743    /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744    /// because every downstream consumer of the feature-toggle list
2745    /// treats it as a read-only sequence — the slice-view is the
2746    /// narrowest borrow that supports every present + roadmapped
2747    /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748    /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749    /// the typed view reaches for (the storage-side `Vec` remains
2750    /// reachable through the `pub caracteristicas` field for the
2751    /// mutation-carrying serde round-trip and per-test fixture-mutation
2752    /// paths). Named `caracteristicas()` to match the storage field's
2753    /// name verbatim and the tatara-lisp author-surface term
2754    /// (`:caracteristicas`) the field's own docstring already carries.
2755    ///
2756    /// Declared `pub const fn` — the body projects through
2757    /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758    /// well within the workspace MSRV, so every downstream `const`-
2759    /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760    /// accessor reaches through the same typed dispatch on the
2761    /// substrate primitive at const-eval time as at runtime. Pinned
2762    /// load-bearing by the paired
2763    /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764    /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765    /// the full pin-shape rationale.
2766    ///
2767    /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768    #[must_use]
2769    pub const fn caracteristicas(&self) -> &[String] {
2770        self.caracteristicas.as_slice()
2771    }
2772
2773    /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774    /// missing-source-tolerance flag scalar accessor every consumer of
2775    /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776    /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777    /// typed slot's own `bool` storage (no borrow of `&self` past the
2778    /// call; the `Copy`-return arm matches the peer
2779    /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780    /// projected sibling discipline the outer flat-spread family
2781    /// already carries). Default-`false` (`#[serde(default,
2782    /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783    /// `Dep` past parse definitionally carries a `bool` — `false` when
2784    /// the author omits `:opcional` — and the returned value degenerates
2785    /// to `false` on that arm without any silent `None` collapse).
2786    ///
2787    /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788    /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789    /// missing-source arm as a soft-fail rather than a build refusal"
2790    /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791    /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792    /// dropped from the resolved dep-graph rather than tripping the
2793    /// build-refusal edge that a mandatory `:opcional false` entry
2794    /// would). Every downstream consumer that fans on the dep's
2795    /// missing-source-tolerance keys off this accessor: the future
2796    /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797    /// dispatch on the opcional bit ahead of the lacre closure
2798    /// materialization), the future caixa-crd per-`spec.deps`
2799    /// `optional` boolean the K8s-CR admission gate consumes on the
2800    /// per-dep partition, and the future feira / caixa-resolver /
2801    /// caixa-crd feature-projection walk that folds the opcional bit
2802    /// into the resolved feature-closure the future M4 lacre-federation
2803    /// layer emits.
2804    ///
2805    /// Prior to this lift the `.opcional` `bool` slot was read inline
2806    /// at the sole in-crate consumer site — the tests-module
2807    /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808    /// pinning the [`Self::simple`] constructor's default-`false` fill
2809    /// (the only in-crate read of the raw field beyond the per-`Dep`
2810    /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811    /// serde round-trip / per-test fixture-mutation paths) — an open-
2812    /// coded field-access that expressed no compile-time link back to
2813    /// the typed slot. A future extension of the `:opcional` axis to a
2814    /// richer author surface (a per-scope opcional-override the resolver
2815    /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816    /// docstring already acknowledges, a per-cluster opcional-override
2817    /// the future M4 lacre-federation layer applies per-CR, a promotion
2818    /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819    /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820    /// roadmap lands) would have had to be threaded through every open-
2821    /// coded copy in lockstep or two consumers would silently disagree
2822    /// on which missing-source arm a given dep resolves to — the
2823    /// [`Self::simple`] constructor's default-`false` fill reading
2824    /// verbatim while a downstream caixa-resolver consumer read a per-
2825    /// scope-override-resolved bit would silently split the build-time
2826    /// arm from the lacre closure the substrate's fetch pipeline
2827    /// actually materializes, one build-time diagnostic disagreeing
2828    /// with the run-time closure. Lifting the resolution rule to a
2829    /// typed method on the substrate primitive means every downstream
2830    /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831    /// reaches for exactly one typed dispatch — the resolver's accept-
2832    /// set migrates as a unit on any future axis addition.
2833    ///
2834    /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835    /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836    /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837    /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838    /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839    /// `:caracteristicas`) now routes through exactly one typed
2840    /// dispatch on the substrate primitive. First outer-`Dep`
2841    /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842    /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843    /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844    /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845    /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846    /// already carries — extends the "one typed dispatch on the
2847    /// substrate primitive, thin projections at each consumer"
2848    /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849    /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850    /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851    /// every downstream consumer treats it as a plain discriminant
2852    /// value — the by-value return is the narrowest return-shape that
2853    /// supports every present + roadmapped consumer (`.then(…)` early
2854    /// return on the resolver-side drop-vs-error partition, direct
2855    /// bool composition with a per-scope-override projector, plain
2856    /// `if dep.opcional() { … }` early return at every future admission
2857    /// gate) without leaking the storage field's `bool`-in-`&self`
2858    /// lifetime the by-value return elides. Marked `pub const fn` so
2859    /// the accessor is `const`-callable — same discipline the peer
2860    /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861    /// accessor carries. Named `opcional()` to match the storage
2862    /// field's name verbatim and the tatara-lisp author-surface term
2863    /// (`:opcional`) the field's own docstring already carries.
2864    #[must_use]
2865    pub const fn opcional(&self) -> bool {
2866        self.opcional
2867    }
2868
2869    /// Build a minimal registry-sourced dep.
2870    #[must_use]
2871    pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872        Self {
2873            nome: nome.into(),
2874            versao: versao.into(),
2875            fonte: None,
2876            opcional: false,
2877            caracteristicas: Vec::new(),
2878        }
2879    }
2880
2881    /// Build a Git-sourced dep (tag-based).
2882    #[must_use]
2883    pub fn git(
2884        nome: impl Into<String>,
2885        versao: impl Into<String>,
2886        repo: impl Into<String>,
2887        tag: impl Into<String>,
2888    ) -> Self {
2889        Self {
2890            nome: nome.into(),
2891            versao: versao.into(),
2892            fonte: Some(DepSource::Git {
2893                repo: repo.into(),
2894                tag: Some(tag.into()),
2895                rev: None,
2896                branch: None,
2897            }),
2898            opcional: false,
2899            caracteristicas: Vec::new(),
2900        }
2901    }
2902
2903    /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904    /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905    /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906    /// semver requirement.
2907    ///
2908    /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909    /// is the same Cargo-shaped requirement string `:membros :versao`
2910    /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911    /// and `:children :versao` (validated at
2912    /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913    /// the lacre pipeline resolves all three axes through the same
2914    /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915    /// `:deps :versao` was the last `:versao` axis untyped past
2916    /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917    /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918    /// leaking-into-:versao `"v0.1"` typo, the accidental
2919    /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920    /// surfaced at lacre-resolve time, far from the source
2921    /// caixa.lisp, with no field naming which `:deps` entry carried
2922    /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923    /// the offending entry's `:nome` + the offending `:versao`
2924    /// verbatim + the parser's own wording in `reason`, so the
2925    /// author's grep target is unambiguous.
2926    ///
2927    /// The author surface for `:deps :nome` is the same DNS-1123 label
2928    /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929    /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930    /// `:membros :caixa` (validated at
2931    /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932    /// `:children :caixa` (validated at
2933    /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934    /// :nome` value flows verbatim through the lacre pipeline as the
2935    /// target caixa's `:nome` (which the gate at the *target* side now
2936    /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937    /// `lareira-<nome>` Helm chart name segment, the per-dep
2938    /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939    /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940    /// this gate landed `:deps :nome` was the fourth and last
2941    /// DNS-1123-shaped caixa-identifier axis still untyped past
2942    /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943    /// Teia"` uppercase — the canonical "I copied the README header"
2944    /// typo; `"caixa_teia"` underscore — the Go module / Python
2945    /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946    /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947    /// silently passed parse and surfaced at lacre-resolve time when
2948    /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949    /// — far from the source `:deps` entry, with a diagnostic naming
2950    /// the *target's* `:nome` rather than the dep entry that referenced
2951    /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952    /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953    /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954    /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955    /// so every downstream consumer (caixa-resolver's lacre fetch,
2956    /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957    /// fan-out emitter) reaches for the name knowing the value is
2958    /// apiserver-valid without re-validating.
2959    ///
2960    /// Empty checks fire first (narrower diagnostic), parse last —
2961    /// same ordering discipline as
2962    /// [`crate::AplicacaoSpec::validate_membros`] and
2963    /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964    /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965    /// structurally necessary even with the parse arm in place. The
2966    /// `:nome` shape gate runs after the `:nome` empty gate and before
2967    /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968    /// sees the name-side diagnostic first (the name is the
2969    /// self-locating axis — without it, the parse diagnostic can't
2970    /// quote `:nome "<bad>"`).
2971    pub fn validate(&self) -> Result<(), DepError> {
2972        if self.nome.is_empty() {
2973            return Err(DepError::NomeEmpty);
2974        }
2975        if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976            return Err(DepError::nome_invalid(&self.nome, reason));
2977        }
2978        // Delegate the empty-first + `parse_requirement` cascade to the
2979        // shared [`crate::render::require_valid_versao_requirement`]
2980        // helper — same two-arm shape the peer
2981        // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982        // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983        // :versao` route through, so drift between the three axes'
2984        // accepted requirement sets is structurally impossible and the
2985        // parse-side no-op the empty-first arm closes (semver's empty
2986        // parse yields an implicit `*`) lives in exactly one predicate.
2987        crate::render::require_valid_versao_requirement(
2988            self.versao_requirement(),
2989            || DepError::versao_empty(&self.nome),
2990            |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991        )?;
2992        if let Some(fonte) = self.fonte() {
2993            fonte.validate(&self.nome)?;
2994        }
2995        self.validate_caracteristicas()?;
2996        Ok(())
2997    }
2998
2999    /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000    /// are operationally meaningless. The `:caracteristicas` slot is
3001    /// a set of feature toggles to enable on the target caixa — same
3002    /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003    /// two structural footguns close here:
3004    ///
3005    ///   - empty-string entry (`(:caracteristicas (""))`): the future
3006    ///     caixa-resolver lacre pipeline would consume the empty
3007    ///     identifier as a no-op feature enable, silently dropping the
3008    ///     author's intent far from the source `caixa.lisp`;
3009    ///   - duplicate entry within one dep (`(:caracteristicas ("http"
3010    ///     "http"))`): the feature-toggle slot is set-shaped (enabling
3011    ///     a feature twice has no additional semantic — there is no
3012    ///     `feature × 2`), so two entries naming the same feature are
3013    ///     a silent miscount, the same set-not-multiset distinction
3014    ///     every peer Vec-keyed-by-name axis already closes
3015    ///     ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016    ///     `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017    ///     on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018    ///     on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019    ///     on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020    ///     on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021    ///     on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022    ///     / [`crate::UpgradeError::DuplicateStateChange`] /
3023    ///     [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024    ///     entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025    ///     on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026    ///     immediate-predecessor 359fba5 closed).
3027    ///
3028    /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029    /// every peer set-not-multiset gate uses; the empty arm fires
3030    /// before the duplicate arm so an entry with both an empty feature
3031    /// *and* a duplicate of some later feature surfaces the empty-
3032    /// shape diagnostic first (the empty-feature axis is the
3033    /// more-actionable defect since the missing-name renders the
3034    /// duplicate-key arm ambiguous: two `""` entries would both report
3035    /// `caracteristica: ""` with no way to distinguish the offending
3036    /// site). Empty-first cascade discipline mirrors every peer per-
3037    /// entry shape + duplicate gate
3038    /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039    /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040    /// before `MembroDuplicate`).
3041    ///
3042    /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043    /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044    /// fires between the empty arm and the duplicate arm — the
3045    /// canonical per-entry-shape-before-cross-entry-uniqueness
3046    /// precedence every peer two-arm + value-shape gate establishes
3047    /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048    /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049    /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050    /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051    /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052    /// Until the value-shape arm landed `:caracteristicas` accepted
3053    /// every non-empty distinct string — a structurally invalid
3054    /// feature name (`"http feature"` whitespace, `"+http"` the
3055    /// canonical paste-from-`+optional-feature` doc activation-form
3056    /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057    /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058    /// only applies inside list-grammar contexts, `"http,json"`
3059    /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060    /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061    /// inconsistently across NFC/NFD normalization, the 65-byte
3062    /// paste-from-binary slug) silently passed validate and the
3063    /// failure surfaced at `cargo metadata` time as the
3064    /// `restricted_names::validate_feature_name` parser's rejection,
3065    /// far from the source `caixa.lisp`, with no field naming which
3066    /// `:deps` entry's `:caracteristicas` carried the typo. The
3067    /// lifted predicate makes the Cargo-feature-name-grammar
3068    /// intersection-floor a substrate-level invariant at validate
3069    /// time — same trajectory as the eight peer
3070    /// [`crate::render`] value-shape predicates each typed surface
3071    /// downstream of a structured grammar already follows
3072    /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073    /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074    /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075    /// [`is_nats_subject`](crate::render::is_nats_subject),
3076    /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077    /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078    /// [`is_git_oid`](crate::render::is_git_oid),
3079    /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080    fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081        let mut seen = std::collections::HashSet::new();
3082        for c in self.caracteristicas() {
3083            if c.is_empty() {
3084                return Err(DepError::caracteristica_empty(&self.nome));
3085            }
3086            if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087                return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088            }
3089            crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090                DepError::caracteristica_duplicate(&self.nome, c)
3091            })?;
3092        }
3093        Ok(())
3094    }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140    deps: &[Dep],
3141    deps_dev: &[Dep],
3142    parent_nome: &str,
3143) -> Result<(), DepError> {
3144    for dep in deps {
3145        if dep.nome() == parent_nome {
3146            return Err(DepError::dep_is_self(
3147                parent_nome,
3148                crate::render::DEP_AUTHOR_KEY_DEPS,
3149            ));
3150        }
3151    }
3152    for dep in deps_dev {
3153        if dep.nome() == parent_nome {
3154            return Err(DepError::dep_is_self(
3155                parent_nome,
3156                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157            ));
3158        }
3159    }
3160    Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202    /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203    /// lacre closure resolves at every build. Wire-format
3204    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205    Prod,
3206    /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207    /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208    /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209    Dev,
3210}
3211
3212impl DepList {
3213    /// Exhaustive iteration surface for every consumer that reads the
3214    /// full closed-set (the future M4 admission webhook's per-list
3215    /// summary rejection body, any future round-trip pin harness). A
3216    /// future variant addition extends this slice as a single edit and
3217    /// every consumer picks up the new entry by construction — the
3218    /// compiler-checked exhaustiveness on the sibling method `match`
3219    /// arms is the build-time guarantee that no arm forgets to grow.
3220    pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222    /// Canonical author-surface tag every substrate consumer that
3223    /// names the offending dep-list in a diagnostic reaches for —
3224    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226    /// the same `&'static str` payload the sibling
3227    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228    /// already carry. Routing every dep-list diagnostic through the
3229    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230    /// literal-carry axis on the two-list dep-graph surface — a
3231    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232    /// wire-format promotion (a distinct diagnostic form for the
3233    /// `Dev` arm) reaches every consumer through one edit on the
3234    /// canonical constant, not a coordinated rewrite across the
3235    /// substrate's dep-graph consumers.
3236    #[must_use]
3237    pub const fn as_str(self) -> &'static str {
3238        match self {
3239            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241        }
3242    }
3243
3244    /// Substrate-canonical reverse projection on the two-list dep-graph
3245    /// axis — parses the author-surface wire tag back to the typed
3246    /// variant, or `None` when `s` is outside the closed-set arm-string
3247    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251    /// the round-trip migrate through one caixa-core edit on any future
3252    /// list-axis addition.
3253    ///
3254    /// Prior to this lift the substrate carried only the forward
3255    /// `Self → &str` projection on the two-list dep-graph axis (the
3256    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257    /// through it, the two [`DepError::DuplicateNome`] /
3258    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259    /// as a `&'static str` `list:` field). Every future consumer that
3260    /// wanted to promote the wire tag back to the typed enum (a future
3261    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262    /// wire form into the typed enum before dispatching to
3263    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265    /// wire re-parse of the per-list diagnostic body, a future
3266    /// [`DepError`] widening that promotes the two `list: &'static str`
3267    /// fields to a typed `list: DepList` carry so downstream consumers
3268    /// dispatch on the enum rather than string-comparing the wire
3269    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271    /// compile-time link back to the typed [`DepList`] enum. A future
3272    /// variant addition (a `:build-dep` or `:test-dep` third list once
3273    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276    /// would silently split the wire byte-string the emitter walks from
3277    /// the parser's arm-set — the round-trip would carry the new list
3278    /// through the forward projection but land on the fallback silently
3279    /// at every non-updated reverse parser, far from the arm-addition
3280    /// commit that caused the drift. Lifting the resolver to a typed
3281    /// method on the substrate primitive closes the drift footgun by
3282    /// construction: the parser's accept-set is the same set the
3283    /// [`Self::as_str`] emitter walks (routed through the same lifted
3284    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286    /// of the round-trip migrate through one caixa-core edit on any
3287    /// future list-axis addition.
3288    ///
3289    /// Same closed-set-reverse-projection discipline the sibling
3290    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295    /// carry on the peer wire-side `str → Self` axes — extended onto
3296    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297    /// closed-set typed enum on the caixa surface to converge on the
3298    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299    /// `from_str`) to match the peer shapes verbatim and side-step the
3300    /// derived [`std::str::FromStr`] impls the sibling
3301    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304    /// caller picks the diagnostic form appropriate for its use site —
3305    /// a future `feira dep --list …` arg-parse that surfaces
3306    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308    /// path folds `None` onto its per-CR structured refusal body.
3309    #[must_use]
3310    pub fn from_wire(s: &str) -> Option<Self> {
3311        match s {
3312            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314            _ => None,
3315        }
3316    }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335        f.write_str(self.as_str())
3336    }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391    fn as_ref(&self) -> &str {
3392        self.as_str()
3393    }
3394}
3395
3396/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3397/// [`DepList`] closed-set typed enum — routes through the paired
3398/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3399/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3400/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3401/// through, rather than an open-coded per-arm
3402/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3403/// has no compile-time link back to the substrate primitive.
3404///
3405/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3406/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3407/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3408/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3409/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3410/// which silently omitted [`DepList`] despite this enum being listed
3411/// as a sibling closed-set fieldless typed enum in every peer's
3412/// docstring). Every sibling closed-set fieldless typed enum on the
3413/// caixa surface now carries both trait-idiomatic axes
3414/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3415/// against the substrate-primitive canonical projection accessors
3416/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3417/// closed-set is the fifteenth and true-final peer.
3418///
3419/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3420/// `Option<Self>` return-shape's deliberate deferral of error typing:
3421/// the caller picks the diagnostic form appropriate for its use site
3422/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3423/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3424/// the M4 admission-webhook rejection body wraps `Err(())` with the
3425/// accepted-set enumeration).
3426///
3427/// Pinned load-bearing by
3428/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3429/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3430/// accept-set) and
3431/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3432/// (rejection witness against silent accept-set widening).
3433impl TryFrom<&str> for DepList {
3434    type Error = ();
3435
3436    fn try_from(s: &str) -> Result<Self, Self::Error> {
3437        Self::from_wire(s).ok_or(())
3438    }
3439}
3440
3441/// Trait-idiomatic *forward* projection on the two-list dep-graph
3442/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3443/// routes byte-for-byte through the paired substrate-primitive
3444/// [`DepList::as_str`] `pub const fn` accessor so
3445/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3446/// reaches the same two-arm lifted
3447/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3448/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3449/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3450/// surfaces already return.
3451///
3452/// Closes the substrate-wide trait-idiomatic forward-projection
3453/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3454/// via 523157d and traced through the 13 sibling closed-set typed
3455/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3456/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3457/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3458/// every peer's docstring naming it as a sibling. Paired with the
3459/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3460/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3461/// idiomatic axis pair, mirroring the pre-existing method-named
3462/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3463/// substrate-primitive axis pair.
3464///
3465/// The paired [`DepList::as_str`] returns `&'static str` by
3466/// construction — each arm resolves to a
3467/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3468/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3469/// static lifetime — so the trait's return-type promise is upheld
3470/// structurally.
3471///
3472/// Pinned load-bearing by
3473/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3474/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3475/// emit-set, plus a `const`-context materialization witness for the
3476/// `&'static str` lifetime promise) and
3477/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3478/// (partition pin + two-way round-trip through the paired
3479/// [`TryFrom<&str>`] axis).
3480impl From<DepList> for &'static str {
3481    fn from(list: DepList) -> &'static str {
3482        list.as_str()
3483    }
3484}
3485
3486/// Trait-idiomatic *forward* projection on the two-list dep-graph
3487/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3488/// `&'static str` axis — the borrowed-input companion to the paired
3489/// owned-input [`From<DepList> for &'static str`] impl immediately
3490/// above. Routes byte-for-byte through the same substrate-primitive
3491/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3492/// binds a `&DepList` through the standard-library `.into()` /
3493/// [`From<&Self> for &'static str`] axis (a
3494/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3495/// per-arm accept-set materializer that iterates the substrate-
3496/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3497/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3498/// forces every call site through an explicit `.copied()` /
3499/// dereference / [`Copy`]-bound restatement rather than the direct
3500/// trait-idiomatic projection; a future generic
3501/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3502/// that walks the `iter().map(Into::into)` shape verbatim; the future
3503/// M4 admission-webhook rejection body that composes the accepted-set
3504/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3505/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3506/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3507/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3508/// owned-input [`From<DepList> for &'static str`], the sibling
3509/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3510/// surfaces already return.
3511///
3512/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3513/// forward-projection family on the last-touched closed-set fieldless
3514/// typed enum — first-mover on the borrowed-input axis, mirroring the
3515/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3516/// input axis (523157d). Rust's `From` trait does not auto-derive the
3517/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3518/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3519/// in `core`), so every closed-set typed enum that carries the
3520/// owned-input axis but not the borrowed-input axis forces every
3521/// borrowed-input call site through a `.copied()` /
3522/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3523/// bounds have no compile-time link to the substrate primitive. The
3524/// remaining fourteen substrate-wide closed-set fieldless typed enum
3525/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3526/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3527/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3528/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3529/// of this campaign.
3530///
3531/// Pinned load-bearing by
3532/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3533/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3534/// emit-set via a borrowed input, plus a `const`-context materialization
3535/// witness) and
3536/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3537/// (cross-axis partition pin against the paired owned-input
3538/// [`From<DepList> for &'static str`] impl).
3539impl From<&DepList> for &'static str {
3540    fn from(list: &DepList) -> &'static str {
3541        list.as_str()
3542    }
3543}
3544
3545/// Trait-idiomatic *forward* projection on the two-list dep-graph
3546/// [`DepList`] closed-set typed enum from an *owned* input onto the
3547/// owned-[`String`] axis — routes byte-for-byte through the
3548/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3549/// every consumer that binds a [`DepList`] through the standard-library
3550/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3551/// axis reaches the same two-arm lifted
3552/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3553/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3554/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3555/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3556/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3557///
3558/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3559/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3560/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3561/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3562/// second-of-two-in-M2 per-child restart-decision axis, then onto
3563/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3564/// closed-set fieldless typed enum on the caixa surface, then onto
3565/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3566/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3567/// Rust's standard library does not carry a blanket
3568/// `impl<T: AsRef<str>> From<T> for String` (nor an
3569/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3570/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3571/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3572/// quadruple but not the owned-[`String`] axis forces every owned-string
3573/// call site through a `.to_string()` / `.as_str().to_owned()` /
3574/// `String::from(list.as_str())` detour whose type bounds have no
3575/// compile-time link to the substrate primitive.
3576///
3577/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3578/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3579/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3580/// share one vocabulary by construction — `PascalCase` on the three
3581/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3582/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3583/// emit and [`DepList::from_wire`] parse resolve through the same
3584/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3585/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3586/// (there is no wire/diagnostic axis split on this enum — both halves
3587/// of the round-trip route through the same two `pub const &str` values),
3588/// so the owned-[`String`] forward projection this impl exposes composes
3589/// directly with the paired trait-idiomatic reverse
3590/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3591/// borrow — no intermediate wire-vocab hop like the peer
3592/// [`crate::CaixaKind`] axis pair requires.
3593///
3594/// The remaining ten closed-set typed enums on the caixa substrate
3595/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3596/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3597/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3598/// this campaign — each carries the same paired [`AsRef<str>`] /
3599/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3600/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3601/// axis extends onto.
3602///
3603/// Pinned load-bearing by
3604/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3605/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3606/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3607/// witness) and
3608/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3609/// (cross-axis partition against the sibling owned-`&'static str` axis
3610/// and the [`ToString::to_string`] surface, a
3611/// `.iter().copied().map(String::from)` pipe witness over
3612/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3613/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3614/// borrow — composes directly without the wire-vocab intermediate hop
3615/// the peer [`crate::CaixaKind`] axis pair requires).
3616impl From<DepList> for String {
3617    fn from(list: DepList) -> String {
3618        list.as_str().to_owned()
3619    }
3620}
3621
3622/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3623/// projection on the two-list dep-graph [`DepList`] closed-set typed
3624/// enum — the fourth (and closing) corner of the
3625/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3626/// projection family on this enum, mirror of the peer M2 OTP-shape
3627/// [`From<&RestartStrategy> for String`] (579385f) and
3628/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3629/// closed the corner on the sibling supervisor-level restart-strategy
3630/// and per-child restart-decision enums. Routes byte-for-byte through
3631/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3632/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3633/// [`&DepList`] and needs an owned [`String`] — a future
3634/// `serde_json::Value::String(String::from(&list))` structured-payload
3635/// composer over a borrowed field, a future `Iterator::map` over
3636/// `&[DepList]` that projects to owned keys through
3637/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3638/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3639/// alone forces every call site through an explicit `.copied()` /
3640/// spurious [`Copy`] deref restatement rather than the direct trait-
3641/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3642/// that keys off a borrowed-iteration axis where dereferencing the list
3643/// would force an unnecessary `Copy` at every step, the future
3644/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3645/// per-list author-surface-tag diagnostic emit whose iteration axis is
3646/// borrowed by construction — reaches the same two-arm lifted
3647/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3648/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3649/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3650/// three other trait-idiomatic forward-projection impls
3651/// ([`From<DepList> for &'static str`],
3652/// [`From<&DepList> for &'static str`],
3653/// [`From<DepList> for String`]) already return.
3654///
3655/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3656/// owned-`String` output* forward-projection family opened on
3657/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3658/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3659/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3660/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3661/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3662/// standard library does not carry a blanket
3663/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3664/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3665/// typed enum that carries the paired `AsRef<str>` / `Display` /
3666/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3667/// `From<Self> for String` quintuple but not the borrowed-input owned-
3668/// [`String`] axis forces every borrowed-input owned-string call site
3669/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3670/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3671/// whose type bounds have no compile-time link to the substrate
3672/// primitive.
3673///
3674/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3675/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3676/// axis pairs (whose forward emit and reverse parse share one
3677/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3678/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3679/// [`DepList::from_wire`] parse resolve through the same lifted
3680/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3681/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3682/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3683/// tags — there is no wire/diagnostic axis split on this enum), so the
3684/// borrowed-input owned-[`String`] projection this impl exposes
3685/// composes directly with the paired trait-idiomatic reverse
3686/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3687/// borrow — no intermediate wire-vocab hop like the peer
3688/// [`crate::CaixaKind`] axis pair requires.
3689///
3690/// The remaining ten closed-set typed enums on the caixa substrate
3691/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3692/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3693/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3694/// are the future targets of this 2×2-completion campaign — each
3695/// carries the same paired quintuple that this borrowed-input owned-
3696/// [`String`] axis extends onto.
3697///
3698/// Pinned load-bearing by
3699/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3700/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3701/// emit-set through the borrowed-input surface) and
3702/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3703/// (cross-axis partition pin against the paired owned-input owned-
3704/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3705/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3706/// impl, and the sibling [`ToString::to_string`] surface routed through
3707/// [`std::fmt::Display`], plus a direct round-trip witness through
3708/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3709/// borrow that closes the two-way `&Self → String → Self` round-trip
3710/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3711/// reverse axis pair).
3712impl From<&DepList> for String {
3713    fn from(list: &DepList) -> String {
3714        list.as_str().to_owned()
3715    }
3716}
3717
3718/// Trait-idiomatic *forward* projection on the two-list dep-graph
3719/// [`DepList`] closed-set typed enum from an *owned* input onto the
3720/// borrowed-heap-string [`std::borrow::Cow<'static, str>`] axis —
3721/// routes byte-for-byte through the substrate-primitive
3722/// [`DepList::as_str`] `pub const fn` accessor (via
3723/// [`std::borrow::Cow::Borrowed`]) so every consumer that binds a
3724/// [`DepList`] through the standard-library `.into()` /
3725/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
3726/// [`Into<std::borrow::Cow<'static, str>>`]) axis reaches the same
3727/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3728/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] canonical `pub const
3729/// &str` values the paired [`From<DepList> for &'static str`],
3730/// [`From<&DepList> for &'static str`], [`From<DepList> for String`],
3731/// and [`From<&DepList> for String`] 2×2 trait-idiomatic forward-
3732/// projection corners, the sibling [`std::fmt::Display`],
3733/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return,
3734/// rather than an open-coded per-call-site
3735/// `std::borrow::Cow::Borrowed(list.as_str())` /
3736/// `std::borrow::Cow::Owned(list.to_string())` composition whose
3737/// type bounds have no compile-time link back to the substrate
3738/// primitive.
3739///
3740/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3741/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3742/// [`DepList::as_str`] accessor's return carries the `&'static str`
3743/// lifetime by construction (each `match` arm resolves to one of
3744/// the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3745/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3746/// values with static lifetime), so the zero-alloc borrowed arm is
3747/// the type-correct projection with no runtime allocation. The
3748/// paired [`std::borrow::Cow::Owned`] arm stays reachable at the
3749/// call site through the existing [`From<DepList> for String`] axis
3750/// composed with [`std::borrow::Cow::from`] on the resulting owned
3751/// [`String`] — a caller who chose to mutate the projection lands
3752/// on the owned arm by their own composition, not by the substrate-
3753/// primitive projection silently allocating on their behalf.
3754///
3755/// Rust's standard library carries no blanket `impl<T: AsRef<str>>
3756/// From<T> for Cow<'static, str>` (nor an `impl<T: fmt::Display>
3757/// From<T> for Cow<'static, str>`), so the paired sibling
3758/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3759/// [`AsRef<str>`], and [`std::fmt::Display`] surfaces do not
3760/// implicitly extend to a [`std::borrow::Cow<'static, str>`]-bound
3761/// call site — every such site is forced through a
3762/// `Cow::Borrowed(list.as_str())` / `Cow::Owned(list.to_string())`
3763/// open-code whose type bounds have no compile-time link back to
3764/// the substrate primitive until this lift.
3765///
3766/// First-mover on the outside-M3 substrate-wide tier of the
3767/// substrate-wide trait-idiomatic [`std::borrow::Cow<'static, str>`]
3768/// forward-projection campaign, opening the tier on the first
3769/// caixa-core-internal closed-set fieldless typed enum peer outside
3770/// the M2 OTP-shape and M3 mesh-shape tiers. The
3771/// [`crate::CaixaKind`] top-level first-mover
3772/// (99c1735 owned-input, d45c409 borrowed-input) opened the axis on
3773/// the structurally most fundamental closed-set fieldless typed
3774/// enum; the paired M2 OTP-shape
3775/// [`crate::supervisor::RestartStrategy`] (7dd28b3, 9b3e4b3) and
3776/// [`crate::supervisor::RestartPolicy`] (0612398, ee577fd) closed
3777/// the M2 OTP-shape tier; the paired M3-mesh-shape
3778/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3779/// (8634dec, 25690ef), [`crate::aplicacao::PlacementStrategy`]
3780/// `:placement :estrategia` distribution-strategy (eee504d,
3781/// afdf0f4), and [`crate::aplicacao::RateLimitUnit`] `:politicas
3782/// :rate-limit` canonical-suffix (1d59925, `From<&RateLimitUnit>`
3783/// Cow closer) closed the M3-mesh-shape tier. The remaining
3784/// outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3785/// [`crate::render::PathShapeViolation`]) and the outside-
3786/// `caixa-core` peers (`InvariantKind`, `ArchVerdict`, `Severity`,
3787/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the remaining
3788/// future targets of this campaign; the paired borrowed-input
3789/// [`From<&DepList> for std::borrow::Cow<'static, str>`]
3790/// `{Self, &Self}`-closer on this outside-M3-tier-opening peer is
3791/// the next commit's target.
3792///
3793/// Same three-path convergence discipline as the paired sibling
3794/// [`From<DepList> for &'static str`] / [`From<DepList> for String`]
3795/// / [`std::fmt::Display`] / [`AsRef<str>`] surfaces (this
3796/// [`std::borrow::Cow<'static, str>`] axis, the paired sibling
3797/// surfaces, and [`DepList::as_str`] all route through the same two
3798/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3799/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3800/// values by construction), so a future variant addition, rename,
3801/// or per-arm wire-tag drift reaches every forward-projection path
3802/// through exactly one caixa-core edit at the [`DepList::as_str`]
3803/// `match` head.
3804///
3805/// Pinned load-bearing by
3806/// [`tests::dep_list_from_into_static_cow_str_routes_through_as_str_accessor`]
3807/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3808/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`])
3809/// and
3810/// [`tests::dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3811/// (cross-axis partition pin against the paired
3812/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3813/// and [`ToString`]-through-[`std::fmt::Display`] axes, plus a
3814/// `.iter().copied().map(Cow::from)` pipe witness over
3815/// [`DepList::ALL`] that materializes the two-arm accept-set through
3816/// the [`std::borrow::Cow<'static, str>`] axis alone and pins the
3817/// zero-alloc discipline on every element).
3818impl From<DepList> for std::borrow::Cow<'static, str> {
3819    fn from(list: DepList) -> std::borrow::Cow<'static, str> {
3820        std::borrow::Cow::Borrowed(list.as_str())
3821    }
3822}
3823
3824/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, str>`]
3825/// output* forward projection on the two-list dep-graph [`DepList`]
3826/// closed-set typed enum — the borrowed-input companion to the paired
3827/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] impl
3828/// immediately above (6858bac). Routes byte-for-byte through the same
3829/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor (via
3830/// [`std::borrow::Cow::Borrowed`]) so every consumer that holds a
3831/// `&DepList` and needs a [`std::borrow::Cow<'static, str>`] — a
3832/// `DepList::ALL.iter().map(std::borrow::Cow::from).collect::<Vec<_>>()`
3833/// per-arm accept-set materializer whose iterator over
3834/// `&'static [DepList]` yields `&DepList` (not `DepList`, so the paired
3835/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] axis
3836/// alone forces every call site through an explicit `.copied()` /
3837/// dereference / [`Copy`]-bound restatement rather than the direct
3838/// trait-idiomatic projection), a future generic
3839/// `<T: for<'a> Into<std::borrow::Cow<'static, str>>>`-bound emitter on
3840/// a per-`:deps` / `:deps-dev` diagnostic column that walks the
3841/// `iter().map(Into::into)` shape verbatim, the future M4
3842/// `caixa.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection body
3843/// that composes the accepted-`:deps` / `:deps-dev` list-key enumeration
3844/// from an iterated `DepList::ALL.iter().map(|l| l.into())` pipe rather
3845/// than a per-arm `match l { … }` cascade — reaches the same two-arm
3846/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3847/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3848/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], the four
3849/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3850/// forward-projection corners, and the paired owned-input
3851/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl already
3852/// return.
3853///
3854/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3855/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3856/// [`DepList::as_str`] accessor's return carries the `&'static str`
3857/// lifetime by construction (each `match` arm resolves to one of the
3858/// two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3859/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3860/// byte-strings with static lifetime), so the zero-alloc borrowed arm
3861/// is the type-correct projection with no runtime allocation on the
3862/// borrowed-input surface just as on the paired owned-input surface.
3863///
3864/// Closes the `{Self, &Self}` input-shape corner on the outside-M3
3865/// caixa-core two-list dep-graph [`std::borrow::Cow<'static, str>`]
3866/// axis opened one commit prior (6858bac) on the paired owned-input
3867/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl — first
3868/// outside-M3 caixa-core peer on the axis, one commit after the paired
3869/// M3-mesh-shape [`crate::aplicacao::RateLimitUnit`] `:politicas
3870/// :rate-limit` canonical-suffix (1d59925), the paired M3-mesh-shape
3871/// [`crate::aplicacao::PlacementStrategy`] `:placement :estrategia`
3872/// distribution-strategy (eee504d + afdf0f4), the paired M3-mesh-shape
3873/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3874/// (8634dec + 25690ef), the paired M2 OTP-shape
3875/// [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3) and
3876/// [`crate::supervisor::RestartPolicy`] (0612398 + ee577fd), and the
3877/// paired top-level [`crate::CaixaKind`] (99c1735 + d45c409) peers
3878/// closed the M3-mesh-shape, M2-OTP-shape, and top-level tiers.
3879/// Rust's standard library does not carry a blanket
3880/// `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor an
3881/// `impl<T: fmt::Display> From<&T> for Cow<'static, str>`), so every
3882/// closed-set fieldless typed enum peer on the substrate that carries
3883/// the paired owned-input [`Cow<'static, str>`] axis but not the
3884/// borrowed-input axis forces every borrowed-input
3885/// [`Cow<'static, str>`]-parameterized call site through a spurious
3886/// [`Copy`] deref (`std::borrow::Cow::from(*list)`) or a
3887/// `std::borrow::Cow::Borrowed(list.as_str())` open-code whose type
3888/// bounds have no compile-time link to the substrate primitive.
3889///
3890/// The remaining outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3891/// [`crate::render::PathShapeViolation`]) and the outside-`caixa-core`
3892/// peers (`InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
3893/// `Semantic`, `FerriteRuntime`) are the remaining future targets of
3894/// the campaign; closing this borrowed-input corner on [`DepList`]
3895/// leaves [`crate::CaixaDialeto`] as the next outside-M3 caixa-core
3896/// closed-set fieldless typed enum peer target on the
3897/// [`std::borrow::Cow<'static, str>`] axis.
3898///
3899/// Same three-path convergence discipline as the paired sibling
3900/// [`From<&DepList> for &'static str`], [`From<&DepList> for String`],
3901/// [`std::fmt::Display`], and [`AsRef<str>`] surfaces (this borrowed-
3902/// input [`std::borrow::Cow<'static, str>`] axis, the paired owned-
3903/// input [`From<DepList> for std::borrow::Cow<'static, str>`] axis, the
3904/// paired sibling `{Self, &Self} × {&'static str, String}` 2×2 corners,
3905/// and [`DepList::as_str`] all route through the same two lifted
3906/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3907/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` values
3908/// by construction), so a future variant addition, rename, or per-arm
3909/// wire-tag drift reaches every forward-projection path through
3910/// exactly one caixa-core edit at the [`DepList::as_str`] `match` head.
3911///
3912/// Pinned load-bearing by
3913/// [`tests::dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
3914/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3915/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`]
3916/// through the borrowed-input surface) and
3917/// [`tests::dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3918/// (cross-axis partition pin against the paired owned-input
3919/// [`From<DepList> for std::borrow::Cow<'static, str>`], the paired
3920/// borrowed-input owned-`&'static str` [`From<&DepList> for &'static
3921/// str`], and the paired borrowed-input owned-`String` [`From<&DepList>
3922/// for String`] impls, plus a `.iter().map(std::borrow::Cow::from)`
3923/// pipe witness over [`DepList::ALL`] — whose iterator yields
3924/// `&DepList` by construction, so the borrowed-input
3925/// [`std::borrow::Cow<'static, str>`] axis is what routes the pipe
3926/// through the substrate-primitive [`DepList::as_str`] accessor with
3927/// the zero-alloc [`std::borrow::Cow::Borrowed`] arm by construction
3928/// and without a spurious [`Copy`] deref).
3929impl From<&DepList> for std::borrow::Cow<'static, str> {
3930    fn from(list: &DepList) -> std::borrow::Cow<'static, str> {
3931        std::borrow::Cow::Borrowed(list.as_str())
3932    }
3933}
3934
3935/// Errors raised by [`Dep::validate`].
3936///
3937/// Mirrors the per-axis error families the other `:versao`-carrying
3938/// typed surfaces expose
3939/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3940/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3941/// [`crate::SupervisorError::EmptyChildVersion`] /
3942/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3943/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3944#[derive(Debug, Error, PartialEq, Eq)]
3945pub enum DepError {
3946    #[error(
3947        ":deps entry has empty :nome (every dep must name a target caixa; \
3948         omit the entry instead of carrying an empty name)"
3949    )]
3950    NomeEmpty,
3951    #[error(
3952        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3953         (the value flows verbatim as the target caixa's `:nome`, the rendered \
3954         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3955         value, and the resolver's checkout-directory leaf — each apiserver-side \
3956         schema rejects non-DNS-1123 names at admission time; use a lowercase \
3957         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3958         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3959    )]
3960    NomeInvalid { nome: String, reason: String },
3961    #[error(
3962        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3963         constraint that resolves through the lacre pipeline)"
3964    )]
3965    VersaoEmpty { nome: String },
3966    #[error(
3967        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3968         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3969         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3970         and `:children :versao` carry; the lacre pipeline resolves all three \
3971         through the same parser)"
3972    )]
3973    VersaoInvalid {
3974        nome: String,
3975        versao: String,
3976        reason: String,
3977    },
3978    #[error(
3979        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3980         (every git source must name a repo — use a `github:org/repo` \
3981         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3982         entire :fonte block to fall back to the default-host resolver \
3983         convention)"
3984    )]
3985    FonteRepoEmpty { nome: String },
3986    #[error(
3987        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3988         invalid value-shape: {reason} (the value flows verbatim into the \
3989         caixa-resolver's `git clone <repo>` subprocess invocation; every \
3990         documented form carries a `:` separator and no whitespace / \
3991         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3992         an `https://host/path` / `ssh://[user@]host/path` / \
3993         `git://host/path` / `file:///path` URL, or the `git@host:path` \
3994         scp-style SSH form)"
3995    )]
3996    FonteRepoShape {
3997        nome: String,
3998        repo: String,
3999        reason: String,
4000    },
4001    #[error(
4002        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4003         (set exactly one of :tag, :rev, or :branch so the resolver \
4004         can pick a reproducible commit; omit the entire :fonte block \
4005         to fall back to the default-host resolver convention, which \
4006         resolves the latest tag matching :versao)"
4007    )]
4008    FontePinMissing { nome: String },
4009    #[error(
4010        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4011         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4012         set so the resolver's checkout target is unambiguous (the \
4013         resolver's silent precedence is :rev > :tag > :branch — if \
4014         you intended one specifically, drop the others)"
4015    )]
4016    FontePinAmbiguous { nome: String, pins: String },
4017    #[error(
4018        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4019         (a set pin must name a non-empty git ref; drop the {pin} key \
4020         entirely to fall through to another pin axis)"
4021    )]
4022    FontePinEmpty { nome: String, pin: String },
4023    #[error(
4024        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4025         value-shape: {reason} (the git porcelain enforces the same shape at \
4026         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4027         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4028         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4029         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4030         prepends at clone time, and avoid abbreviated SHAs which are \
4031         ambiguous across repository history)"
4032    )]
4033    FontePinShape {
4034        nome: String,
4035        pin: String,
4036        value: String,
4037        reason: String,
4038    },
4039    #[error(
4040        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4041         (every path source must name a non-empty filesystem path; \
4042         omit the entire :fonte block to fall back to the default-host \
4043         resolver convention)"
4044    )]
4045    FonteCaminhoEmpty { nome: String },
4046    #[error(
4047        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4048         absolute (the lacre pipeline embeds the value verbatim in its \
4049         per-dep content-address `path:{caminho}` at \
4050         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4051         BLAKE3 closure differ across machines — defeating the \
4052         reproducibility contract that's load-bearing for CSE; express \
4053         the path relative to the caixa.lisp location, e.g. \
4054         \"../caixa-teia\" for a sibling workspace dep)"
4055    )]
4056    FonteCaminhoAbsolute { nome: String, caminho: String },
4057    #[error(
4058        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4059         with `~` (the leading-tilde is a shell-expansion convention, not a \
4060         POSIX path component — `Path::is_absolute` returns false on it, so \
4061         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4062         pipeline embeds the value verbatim in its per-dep content-address \
4063         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4064         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4065         so the build looks for a literal `./{caminho}` subdirectory and \
4066         fails at resolve time far from the source caixa.lisp; even worse, a \
4067         future caixa-resolver pass that *does* expand `~` would silently \
4068         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4069         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4070         runners with different `$HOME` layouts resolve to two distinct paths \
4071         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4072         determinism contract; express the path relative to the caixa.lisp \
4073         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4074         spell out the full relative path explicitly if a workstation-rooted \
4075         dep is genuinely intended)"
4076    )]
4077    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4078    #[error(
4079        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4080         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4081         not a POSIX path component — `Path::is_absolute` returns false on it \
4082         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4083         embeds the value verbatim in its per-dep content-address \
4084         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4085         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4086         so the build looks for a literal `./{caminho}` subdirectory and \
4087         fails at resolve time far from the source caixa.lisp; even worse, a \
4088         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4089         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4090         invites) would silently re-open the host-layout-leak the b94fd83 \
4091         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4092         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4093         layouts resolve to two distinct paths for the byte-identical caixa, \
4094         defeating the THEORY.md §V.2 render-determinism contract; express \
4095         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4096         for a sibling workspace dep, or spell out the full relative path \
4097         explicitly if a workstation-rooted dep is genuinely intended)"
4098    )]
4099    FonteCaminhoVarExpansion { nome: String, caminho: String },
4100    #[error(
4101        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4102         with a space (the leading ASCII space `0x20` is the orthogonal \
4103         paste-from-aligned-doc footgun that silently passes \
4104         `Path::is_absolute` and every prior leading-byte arm — \
4105         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4106         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4107         resolve time with a non-self-locating `No such file or directory` \
4108         error far from the source caixa.lisp; the lacre pipeline embeds \
4109         the value verbatim in its per-dep content-address `path:{caminho}` \
4110         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4111         semantic-identical caixa values (` ../caixa-teia` vs \
4112         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4113         workstations whose authors differ only in paste-from-aligned- \
4114         caixa.lisp-doc whitespace habits — the most insidious failure \
4115         mode the typed slot can carry (no error surfaces; the divergence \
4116         is invisible until two machines compare lacres), defeating the \
4117         THEORY.md §V.2 render-determinism contract. The canonical \
4118         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4119         a multi-entry `:deps` block sits at the same column — an author \
4120         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4121         the rendered alignment into a fresh entry preserves the leading \
4122         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4123         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4124         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4125         `is_chart_description_shape`, `:licenca` via \
4126         `is_spdx_expression_shape`. Drop the leading space; express the \
4127         path as a bare relative single-token like \"../caixa-teia\")"
4128    )]
4129    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4130    #[error(
4131        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4132         with `-` (the canonical CLI-argument-injection footgun on the \
4133         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4134         its per-dep content-address `path:{caminho}` at \
4135         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4136         through `Path::join` looking for a literal `./{caminho}` \
4137         subdirectory. Every downstream subprocess that consumes the resolved \
4138         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4139         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4140         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4141         value as a CLI flag rather than a positional path when the invocation \
4142         does not carry a `--` argument-list terminator between the flag block \
4143         and the path (the common case at every porcelain entry point). The \
4144         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4145         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4146         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4147         CLI-arg-injection vector at every git porcelain entry point that \
4148         consumes a path or URL argument, peer with is_git_repo_url's \
4149         leading-`-` arm on the sibling `:fonte :repo` axis), \
4150         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4151         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4152         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4153         for a literal `./-rf` subdirectory that fails at resolve time with a \
4154         non-self-locating `No such file or directory` error far from the \
4155         source caixa.lisp — but on any downstream shell-out without `--` the \
4156         reinterpretation is silent and the failure mode is arbitrary-\
4157         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4158         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4159         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4160         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4161         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4162         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4163         `:children :caixa`, `:deps :nome`, cluster names); \
4164         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4165         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4166         leading `-` on the CLI positional itself. Express the path as a bare \
4167         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4168         directory name carries no leading-hyphen semantic, and `./` / `../` \
4169         prefixes structurally partition the leading-byte set to safe values.)"
4170    )]
4171    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4172    #[error(
4173        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4174         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4175         every `std::fs` syscall routes the path through `CString::new` which \
4176         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4177         value verbatim in its per-dep content-address `path:{caminho}` at \
4178         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4179         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4180         determinism contract — the canonical paste-from-multiline-doc \
4181         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4182         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4183         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4184         already gates against. Express the path as a relative single-line ASCII \
4185         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4186    )]
4187    FonteCaminhoControlChar {
4188        nome: String,
4189        caminho: String,
4190        byte: u8,
4191    },
4192    #[error(
4193        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4194         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4195         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4196         not the parent's sibling — and the caixa-resolver folds the value through \
4197         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4198         resolve time with a non-self-locating `No such file or directory` error far \
4199         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4200         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4201         resolve to two distinct directories across runner OSes — the lacre pipeline \
4202         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4203         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4204         determinism contract via the cross-host-OS-separator divergence vector. The \
4205         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4206         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4207         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4208         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4209         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4210         \"../caixa-teia\" for a sibling workspace dep)"
4211    )]
4212    FonteCaminhoBackslash { nome: String, caminho: String },
4213    #[error(
4214        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4215         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4216         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4217         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4218         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4219         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4220         as literal path-component bytes, so the resolver folds the value through \
4221         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4222         subdirectory and fails at resolve time with a non-self-locating `No such \
4223         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4224         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4225         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4226         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4227         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4228         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4229         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4230         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4231         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4232         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4233         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4234         redirection semantic.",
4235        ch = *byte as char
4236    )]
4237    FonteCaminhoShellRedirection {
4238        nome: String,
4239        caminho: String,
4240        byte: u8,
4241    },
4242    #[error(
4243        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4244         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4245         `|` as the pipe operator that wires one command's stdout to the next command's \
4246         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4247         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4248         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4249         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4250         treats `|` as a literal path-component byte, so the resolver folds the value \
4251         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4252         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4253         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4254         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4255         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4256         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4257         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4258         subprocess-argument / shell-metachar injection surface every peer single-token-\
4259         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4260         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4261         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4262         workspace directory name carries no shell-pipe semantic."
4263    )]
4264    FonteCaminhoShellPipe { nome: String, caminho: String },
4265    #[error(
4266        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4267         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4268         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4269         command regardless of the prior command's exit status, so `:caminho \
4270         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4271         footgun where an author copies a `cd path; do-thing` chain without trimming \
4272         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4273         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4274         literal path-component byte, so the resolver folds the value through \
4275         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4276         subdirectory and fails at resolve time with a non-self-locating `No such file \
4277         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4278         the value verbatim in its per-dep content-address `path:{caminho}` at \
4279         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4280         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4281         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4282         canonical shell-metachar injection surface every peer single-token-shaped \
4283         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4284         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4285         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4286         workspace directory name carries no shell-command-separator semantic."
4287    )]
4288    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4289    #[error(
4290        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4291         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4292         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4293         terminator detaching the prior command and returning control immediately to \
4294         the prompt, double `&&` as the logical-AND list operator firing the next \
4295         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4296         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4297         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4298         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4299         05c358e closed the sequential-command-separator vector, this arm closes the \
4300         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4301         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4302         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4303         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4304         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4305         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4306         surface every peer single-token-shaped typed slot already closes. The peer \
4307         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4308         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4309         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4310         shell-background / logical-AND semantic."
4311    )]
4312    FonteCaminhoShellBackground { nome: String, caminho: String },
4313    #[error(
4314        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4315         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4316         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4317         wrapper that runs the enclosed command and substitutes its standard-output \
4318         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4319         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4320         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4321         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4322         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4323         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4324         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4325         background / logical-AND vector, this arm closes the orthogonal command-\
4326         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4327         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4328         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4329         value verbatim in its per-dep content-address `path:{caminho}` at \
4330         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4331         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4332         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4333         shell-metachar injection surface every peer single-token-shaped typed slot \
4334         already closes. The peer `:entrada :paths` axis rejects the byte via \
4335         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4336         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4337         directory name carries no shell-command-substitution semantic."
4338    )]
4339    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4340    #[error(
4341        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4342         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4343         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4344         expansion wildcards: `*` matches any sequence of characters in a path component \
4345         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4346         canonical paste-from-shell-listing footgun where an author copies a \
4347         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4348         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4349         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4350         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4351         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4352         locating `No such file or directory` error far from the source caixa.lisp. The \
4353         lacre pipeline embeds the value verbatim in its per-dep content-address \
4354         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4355         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4356         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4357         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4358         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4359         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4360         reserved set. Express the path as a bare relative single-token like \
4361         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4362         / pathname-expansion semantic.",
4363        ch = *byte as char
4364    )]
4365    FonteCaminhoShellGlob {
4366        nome: String,
4367        caminho: String,
4368        byte: u8,
4369    },
4370    #[error(
4371        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4372         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4373         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4374         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4375         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4376         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4377         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4378         arm closes the leading byte of — together the two arms now structurally exclude the \
4379         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4380         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4381         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4382         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4383         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4384         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4385         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4386         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4387         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4388         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4389         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4390         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4391         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4392         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4393         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4394         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4395         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4396         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4397         subshell-grouping semantic.",
4398        ch = *byte as char
4399    )]
4400    FonteCaminhoShellSubshellGrouping {
4401        nome: String,
4402        caminho: String,
4403        byte: u8,
4404    },
4405    #[error(
4406        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4407         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4408         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4409         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4410         comma-separated members and `{{1..10}}` expands to the integer range — the \
4411         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4412         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4413         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4414         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4415         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4416         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4417         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4418         `std::path::Path` treats the byte as a literal path-component byte, so a \
4419         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4420         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4421         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4422         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4423         silently passes every prior arm and the resolver folds the value through \
4424         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4425         resolve time with a non-self-locating `No such file or directory` error far from \
4426         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4427         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4428         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4429         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4430         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4431         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4432         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4433         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4434         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4435         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4436         directory name carries no shell-brace-expansion / URI-Template-placeholder \
4437         semantic; if two siblings actually need pinning, author two separate `:deps` \
4438         entries rather than one brace-expanded `:caminho` value.",
4439        ch = *byte as char
4440    )]
4441    FonteCaminhoShellBraceExpansion {
4442        nome: String,
4443        caminho: String,
4444        byte: u8,
4445    },
4446    #[error(
4447        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4448         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4449         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4450         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4451         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4452         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4453         glob every shell-history block carries; the bracket pair additionally carries the \
4454         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4455         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4456         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4457         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4458         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4459         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4460         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4461         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4462         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4463         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4464         leak) silently passes every prior arm and the resolver folds the value through \
4465         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4466         resolve time with a non-self-locating `No such file or directory` error far from \
4467         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4468         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4469         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4470         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4471         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4472         surface every peer single-token-shaped typed slot already closes. Express the path \
4473         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4474         directory name carries no shell-bracket-expansion / glob-character-class / array-\
4475         literal semantic; if a family of sibling caixas actually needs pinning, author \
4476         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4477        ch = *byte as char
4478    )]
4479    FonteCaminhoShellBracketExpansion {
4480        nome: String,
4481        caminho: String,
4482        byte: u8,
4483    },
4484    #[error(
4485        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4486         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4487         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4488         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4489         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4490         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4491         every path-with-embedded-whitespace paste block carries and the symmetric \
4492         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4493         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4494         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4495         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4496         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4497         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4498         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4499         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4500         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4501         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4502         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4503         production. POSIX `std::path::Path` treats the byte as a literal path-component \
4504         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4505         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4506         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4507         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4508         shape) silently passes every prior arm and the resolver folds the value through \
4509         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4510         resolve time with a non-self-locating `No such file or directory` error far from \
4511         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4512         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4513         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4514         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4515         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4516         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4517         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4518         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4519         `is_git_repo_url`). Express the path as a bare relative single-token like \
4520         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4521         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4522         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4523         quoting on the outer syntactic layer, so an inner quote pair would nest and \
4524         desugar to a broken layer).",
4525        ch = *byte as char
4526    )]
4527    FonteCaminhoShellQuoteGrouping {
4528        nome: String,
4529        caminho: String,
4530        byte: u8,
4531    },
4532    #[error(
4533        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4534         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4535         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4536         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4537         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4538         discarding the byte and everything after it to the end of the physical line \
4539         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4540         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4541         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4542         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4543         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4544         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4545         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4546         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4547         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4548         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4549         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4550         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4551         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4552         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4553         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4554         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4555         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4556         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4557         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4558         fails at resolve time with a non-self-locating `No such file or directory` \
4559         error far from the source caixa.lisp — while every downstream shell / YAML / \
4560         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4561         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4562         scalar disagree with the resolver on which directory the value names. The \
4563         lacre pipeline embeds the value verbatim in its per-dep content-address \
4564         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4565         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4566         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4567         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4568         fragment-delimiter surface every peer single-token-shaped typed slot already \
4569         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4570         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4571         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4572         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4573         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4574         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4575         and drop any `#fragment` tail entirely (fragment identifiers select \
4576         renderings, not directories, and `:caminho` names a directory).",
4577        ch = *byte as char
4578    )]
4579    FonteCaminhoShellComment {
4580        nome: String,
4581        caminho: String,
4582        byte: u8,
4583    },
4584    #[error(
4585        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4586         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4587         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4588         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4589         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4590         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4591         literally inside a URL value. The canonical paste-from-browser-address-bar \
4592         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4593         encoded README hyperlink / browser address bar / percent-encoded permalink \
4594         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4595         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4596         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4597         `std::path::Path` treats the byte as a literal path-component byte, so \
4598         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4599         resolve time with a non-self-locating `No such file or directory` error far \
4600         from the source caixa.lisp — while every downstream URL parser / shell printf \
4601         builtin / YAML directive parser silently reinterprets the byte to a different \
4602         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4603         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4604         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4605         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4606         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4607         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4608         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4609         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4610         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4611         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4612         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4613         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4614         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4615         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4616         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4617         printf-format-specifier / job-control-specifier surface every peer single-\
4618         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4619         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4620         `is_git_repo_url`). Express the path as a bare relative single-token like \
4621         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4622         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4623         any `%20` percent-encoded-space with a literal space then reject the whole \
4624         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4625         directory name never carries an embedded space in practice); drop any \
4626         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4627         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4628        ch = *byte as char
4629    )]
4630    FonteCaminhoUrlPercentEncoding {
4631        nome: String,
4632        caminho: String,
4633        byte: u8,
4634    },
4635    #[error(
4636        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4637         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4638         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4639         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4640         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4641         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4642         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4643         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4644         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4645         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4646         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4647         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4648         the byte is a first-class parser byte in nearly every config / templating / \
4649         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4650         `std::path::Path` treats the byte as a literal path-component byte, so the \
4651         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4652         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4653         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4654         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4655         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4656         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4657         subdirectory that fails at resolve time with a non-self-locating `No such file \
4658         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4659         the value verbatim in its per-dep content-address `path:{caminho}` at \
4660         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4661         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4662         time lock to two distinct BLAKE3 closures across two workstations whose \
4663         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4664         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4665         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4666         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4667         is the canonical CWE-78 shell-command-injection surface every peer single-\
4668         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4669         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4670         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4671         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4672         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4673         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4674         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4675         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4676         so every position — leading and embedded — is structurally rejected. Substitute \
4677         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4678         time, or express the path as a bare relative single-token like \
4679         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4680         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4681        ch = *byte as char
4682    )]
4683    FonteCaminhoShellVariableExpansion {
4684        nome: String,
4685        caminho: String,
4686        byte: u8,
4687    },
4688    #[error(
4689        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4690         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4691         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4692         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4693         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4694         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4695         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4696         and the substitution fires at every history-expansion-enabled shell context — \
4697         `set -o histexpand` is bash's default for interactive sessions and the layer \
4698         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4699         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4700         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4701         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4702         encodes it inside a query component via the 'special-query percent-encode set' \
4703         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4704         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4705         prefix — the paste-from-source-code idiom where an author copies \
4706         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4707         the string-literal boundary); the canonical English-typography emphasis / \
4708         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4709         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4710         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4711         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4712         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4713         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4714         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4715         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4716         repeat-prior-command paste idiom), the English-typography `:caminho \
4717         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4718         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4719         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4720         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4721         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4722         subdirectory that fails at resolve time with a non-self-locating `No such file \
4723         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4724         the value verbatim in its per-dep content-address `path:{caminho}` at \
4725         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4726         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4727         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4728         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4729         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4730         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4731         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4732         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4733         name carries no shell-history-expansion / bang-operator semantic; drop any \
4734         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4735         idiom; and drop any trailing English-typography exclamation mark that pasted \
4736         from prose.",
4737        ch = *byte as char
4738    )]
4739    FonteCaminhoShellHistoryExpansion {
4740        nome: String,
4741        caminho: String,
4742        byte: u8,
4743    },
4744    #[error(
4745        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4746         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4747         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4748         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4749         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4750         substitution' history operator that rewrites the prior command's `old` string to \
4751         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4752         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4753         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4754         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4755         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4756         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4757         literal value diverges from every downstream `feira tofu` curl-invocation / \
4758         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4759         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4760         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4761         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4762         `std::path::Path` treats `^` as a literal path-component byte, so \
4763         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4764         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4765         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4766         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4767         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4768         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4769         that fails at resolve time with a non-self-locating `No such file or directory` \
4770         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4771         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4772         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4773         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4774         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4775         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4776         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4777         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4778         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4779         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4780         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4781         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4782         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4783         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4784         drop any trailing `^` history-substitution-open fragment.",
4785        ch = *byte as char
4786    )]
4787    FonteCaminhoShellHistorySubstitution {
4788        nome: String,
4789        caminho: String,
4790        byte: u8,
4791    },
4792    #[error(
4793        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4794         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4795         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4796         value verbatim in its per-dep content-address `path:{caminho}` at \
4797         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4798         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4799         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4800         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4801         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4802         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4803         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4804         already, so the trailing separator carries no information. Use \
4805         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4806    )]
4807    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4808    #[error(
4809        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4810         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4811         apply the same set-not-multiset discipline; one package per table), and \
4812         two entries naming the same caixa carry two version constraints / source \
4813         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4814         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4815         silently overwrites the first at the resolver-side `concrete_versao` step, \
4816         and the dropped entry's pin / features never reach the closure — far from \
4817         the source caixa.lisp, with no field naming which `:deps` entry was the \
4818         silent loser. If two version constraints are genuinely needed (the rare \
4819         multi-version closure case the lacre pipeline doesn't yet support), the \
4820         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4821         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4822    )]
4823    DuplicateNome { nome: String, list: &'static str },
4824    #[error(
4825        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4826         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4827         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4828         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4829         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4830         with the canonical kebab-case feature name the target caixa declares."
4831    )]
4832    CaracteristicaEmpty { nome: String },
4833    #[error(
4834        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4835         feature name: {reason} (the value flows verbatim into Cargo's \
4836         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4837         parser enforces the same shape at `cargo metadata` time; use a single-token \
4838         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4839         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4840         an ASCII alphanumeric or `_`)"
4841    )]
4842    CaracteristicaInvalid {
4843        nome: String,
4844        caracteristica: String,
4845        reason: String,
4846    },
4847    #[error(
4848        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4849         every feature-flag list keys its entries by name (Cargo's \
4850         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4851         per feature per dep), and two entries naming the same feature are a redundant \
4852         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4853         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4854         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4855         feature once regardless of declaration count, so the duplicate's pin / position never \
4856         reaches the closure with no field naming the silent loser. One entry per feature per \
4857         dep; if two distinct features are intended, name each verbatim."
4858    )]
4859    CaracteristicaDuplicate {
4860        nome: String,
4861        caracteristica: String,
4862    },
4863    #[error(
4864        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4865         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4866         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4867         rejects mid-traversal far from the source caixa.lisp or recurses on until \
4868         it exhausts its stack). Every :nome is globally-unique substrate identity, \
4869         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4870         *is* the parent itself, not a coincidentally-named peer. Drop the \
4871         self-referential dep entry — to reference code from this caixa, use \
4872         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4873         referencing the caixa's own code surface) instead."
4874    )]
4875    DepIsSelf { nome: String, list: &'static str },
4876}
4877
4878// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4879// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4880// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4881// variant — the paired `{ nome: String, caminho: String }` two-slot family
4882// on [`DepError`], sibling of the peer
4883// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4884// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4885// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4886// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4887// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4888// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4889// `{ de, para, wit, expected }`), and
4890// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4891// variants on `{ de, para, <field>: String, reason: String }`) on the
4892// `AplicacaoError` envelopes, the peer
4893// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4894// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4895// (0419438, 4 variants on `{ caixa, kind, slots }`),
4896// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4897// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4898// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4899// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4900// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4901// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4902// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4903// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4904//
4905// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4906// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4907// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4908// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4909// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4910// CommandSubstitution}` on the four single-byte shell operators; and the
4911// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4912// opened the identical `DepError::FonteCaminho<Variant> { nome:
4913// nome.to_string(), caminho: caminho.to_string() }` four-line
4914// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4915// — the exact "same block re-inlined at every consumer" shape the PRIME
4916// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4917// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4918// families each closed on their sibling envelopes. The eleven variants
4919// share one `{ nome: String, caminho: String }` shape, so the fold routes
4920// each wire-up site through one dispatch per typed variant.
4921//
4922// The macro below generates one `#[must_use]` inherent constructor per
4923// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4924// wire-up site collapses onto one dispatch:
4925// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4926// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4927// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4928// once — inside the macro — rather than at every wire-up site.
4929//
4930// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4931// shapes at the per-byte-classification arms — the
4932// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4933// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4934// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4935// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4936// cluster — carry an additional `byte: u8` naming the offending byte and
4937// so would break the uniform-two-field routing this macro promises. They
4938// instead fold onto the sibling three-field envelope through
4939// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4940// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4941// two-slot family is the `byte: u8` classification the arms carry. The
4942// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4943// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4944// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4945// envelope.
4946//
4947// Every future consumer that wants to construct one of these eleven
4948// variants outside the current in-crate [`DepSource::validate_caminho`]
4949// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4950// at lacre-resolve time re-checking the same value-shape axes the resolver
4951// consumes, a future `feira validate --deps` per-caixa admission verb
4952// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4953// rejecting a `:caminho` value against a cluster-local snapshot) now
4954// reaches each variant through one call rather than re-inlining the
4955// four-line struct-literal in lockstep with the eleven in-crate wire-up
4956// sites.
4957macro_rules! fonte_caminho_ctors {
4958    ($($ctor:ident => $variant:ident),* $(,)?) => {
4959        impl DepError {
4960            $(
4961                #[doc = concat!(
4962                    "Construct a [`DepError::",
4963                    stringify!($variant),
4964                    "`] naming the offending `:deps :nome` + `:fonte ",
4965                    "(:tipo path …) :caminho` pair. Folds the uniform ",
4966                    "`Self::",
4967                    stringify!($variant),
4968                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4969                    "two-slot struct-literal onto one substrate primitive so ",
4970                    "every [`DepSource::validate_caminho`] wire-up on this ",
4971                    "variant reads through one dispatch rather than the ",
4972                    "pre-lift four-line open-coded block."
4973                )]
4974                #[must_use]
4975                pub fn $ctor(nome: &str, caminho: &str) -> Self {
4976                    Self::$variant {
4977                        nome: nome.to_string(),
4978                        caminho: caminho.to_string(),
4979                    }
4980                }
4981            )*
4982        }
4983    };
4984}
4985
4986fonte_caminho_ctors! {
4987    fonte_caminho_absolute => FonteCaminhoAbsolute,
4988    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4989    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4990    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4991    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4992    fonte_caminho_backslash => FonteCaminhoBackslash,
4993    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4994    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4995    fonte_caminho_shell_background => FonteCaminhoShellBackground,
4996    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4997    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4998}
4999
5000// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5001// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5002// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5003// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5004// three-slot family on [`DepError`], strict sibling of the peer
5005// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5006// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5007// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5008// axis broke its uniform-two-field routing — the exact "future compounding
5009// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5010// here. Third fold family on this `DepError` envelope, sibling of the peer
5011// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5012// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5013// same enum.
5014//
5015// Each of the twelve wire-up sites on this shape (the control-byte arm
5016// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5017// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5018// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5019// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5020// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5021// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5022// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5023// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5024// `FonteCaminhoShellHistoryExpansion` on `!`, and
5025// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5026// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5027// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5028// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5029// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5030// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5031// closed on the sibling two-field envelope of this same enum. The twelve
5032// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5033// the fold routes each wire-up site through one dispatch per typed variant.
5034//
5035// The macro below generates one `#[must_use]` inherent constructor per
5036// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5037// so every wire-up site collapses onto one dispatch:
5038// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5039// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5040// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5041// `byte`) is spelled once — inside the macro — rather than at every wire-up
5042// site.
5043//
5044// Every future consumer that wants to construct one of these twelve
5045// variants outside the current in-crate [`DepSource::validate_caminho`]
5046// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5047// at lacre-resolve time re-checking the same value-shape axes the resolver
5048// consumes, a future `feira validate --deps` per-caixa admission verb
5049// re-checking the `:fonte :caminho` axis against the shell-metachar
5050// classification bytes this cluster catches, a per-lacre overlay resolver
5051// rejecting a `:caminho` value against a cluster-local snapshot) now
5052// reaches each variant through one call rather than re-inlining the
5053// five-line struct-literal in lockstep with the twelve in-crate wire-up
5054// sites.
5055macro_rules! fonte_caminho_byte_ctors {
5056    ($($ctor:ident => $variant:ident),* $(,)?) => {
5057        impl DepError {
5058            $(
5059                #[doc = concat!(
5060                    "Construct a [`DepError::",
5061                    stringify!($variant),
5062                    "`] naming the offending `:deps :nome` + `:fonte ",
5063                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5064                    "classification. Folds the uniform `Self::",
5065                    stringify!($variant),
5066                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5067                    "byte }` three-slot struct-literal onto one substrate ",
5068                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5069                    "on this variant reads through one dispatch rather than ",
5070                    "the pre-lift five-line open-coded block."
5071                )]
5072                #[must_use]
5073                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5074                    Self::$variant {
5075                        nome: nome.to_string(),
5076                        caminho: caminho.to_string(),
5077                        byte,
5078                    }
5079                }
5080            )*
5081        }
5082    };
5083}
5084
5085fonte_caminho_byte_ctors! {
5086    fonte_caminho_control_char => FonteCaminhoControlChar,
5087    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5088    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5089    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5090    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5091    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5092    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5093    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5094    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5095    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5096    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5097    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5098}
5099
5100// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5101// single-slot struct-variant wire-up sites scattered across
5102// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5103// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5104// substrate primitive per typed variant — the paired `{ nome: String }`
5105// single-slot family on [`DepError`], sibling of the peer
5106// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5107// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5108// the same enum, and of the peer
5109// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5110// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5111// axis. Second fold family on this `DepError` envelope, and the first on
5112// the single-`{ nome }` shape.
5113//
5114// The five wire-up sites this fold closes each opened the identical
5115// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5116// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5117// local — the exact "same block re-inlined at every consumer" shape the
5118// PRIME DIRECTIVE names as a bug. The five variants share one
5119// `{ nome: String }` shape, so the fold routes each wire-up site through
5120// one dispatch per typed variant.
5121//
5122// The macro below generates one `#[must_use]` inherent constructor per
5123// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5124// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5125// pre-lift struct-literal on the same `&str` fixture. The uniform
5126// one-field construction (`nome.to_string()`) is spelled once — inside
5127// the macro — rather than at every wire-up site. Callers that hold a
5128// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5129// and lets the macro-owned `.to_string()` produce the fresh owning copy
5130// the enum variant needs; the semantics collapse onto the same
5131// `.clone()`-equivalent one this fold replaces at every site.
5132//
5133// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5134// on the same envelope stays on its pre-lift open-coded wire-up shape —
5135// it carries no `nome` field (the offending `:nome` value *is* the empty
5136// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5137// signature this macro promises does not apply. Every future consumer
5138// that wants to construct one of these five variants outside the current
5139// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5140// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5141// re-validator at lacre-resolve time, a future `feira validate --deps`
5142// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5143// these empty-value shapes against a cluster-local snapshot) now reaches
5144// each variant through one call rather than re-inlining the three-line
5145// struct-literal in lockstep with the five in-crate wire-up sites.
5146macro_rules! dep_nome_only_ctors {
5147    ($($ctor:ident => $variant:ident),* $(,)?) => {
5148        impl DepError {
5149            $(
5150                #[doc = concat!(
5151                    "Construct a [`DepError::",
5152                    stringify!($variant),
5153                    "`] naming the offending `:deps :nome`. Folds the ",
5154                    "uniform `Self::",
5155                    stringify!($variant),
5156                    " { nome: nome.to_string() }` one-field ",
5157                    "struct-literal onto one substrate primitive so every ",
5158                    "in-crate wire-up on this variant reads through one ",
5159                    "dispatch rather than the pre-lift three-line ",
5160                    "open-coded block."
5161                )]
5162                #[must_use]
5163                pub fn $ctor(nome: &str) -> Self {
5164                    Self::$variant { nome: nome.to_string() }
5165                }
5166            )*
5167        }
5168    };
5169}
5170
5171dep_nome_only_ctors! {
5172    versao_empty => VersaoEmpty,
5173    fonte_repo_empty => FonteRepoEmpty,
5174    fonte_pin_missing => FontePinMissing,
5175    fonte_caminho_empty => FonteCaminhoEmpty,
5176    caracteristica_empty => CaracteristicaEmpty,
5177}
5178
5179// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5180// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5181// [`crate::manifest::Caixa::validate_deps`] +
5182// [`validate_no_self_dep`] onto one substrate-primitive family per
5183// typed variant — the `DepError`-side siblings of the peer
5184// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5185// on the `SupervisorError { caixa: String }` one-slot envelope and of
5186// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5187// `DepError { nome: String }` one-slot envelope. The two variants
5188// carry the same `{ nome: String, list: &'static str }` two-slot
5189// shape: the `nome` field names the offending dep the diagnostic
5190// points the author back at, and the `list` field carries the
5191// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5192// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5193// [`validate_deps`] arms, and via the paired
5194// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5195// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5196// canonicals on the [`validate_no_self_dep`] arm) so the author can
5197// grep their caixa.lisp for the offending list block in one edit.
5198//
5199// Each of the four wire-up sites opened the same struct-literal
5200// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5201// two-line block — the exact "same block re-inlined at every
5202// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5203// altitude the peer `DepError` / `SupervisorError` /
5204// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5205// already closed on their sibling envelopes. The two `#[must_use]`
5206// inherent constructors below fold each wire-up onto one dispatch:
5207// `DepError::duplicate_nome(<nome>, <list>)` and
5208// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5209// pre-lift struct-literal on the same scalar fixtures. The `list:
5210// &'static str` parameter (not `impl Into<String>`) preserves the
5211// exact wire tag every consumer already passes verbatim — no
5212// downstream diagnostic reshaping at the lift, matching the peer
5213// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5214// contract each wire-up site already keys off.
5215macro_rules! dep_nome_list_ctors {
5216    ($($ctor:ident => $variant:ident),* $(,)?) => {
5217        impl DepError {
5218            $(
5219                #[doc = concat!(
5220                    "Construct a [`DepError::",
5221                    stringify!($variant),
5222                    "`] naming the offending `:deps :nome` and the ",
5223                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5224                    "the diagnostic points the author back at. Folds ",
5225                    "the uniform `Self::",
5226                    stringify!($variant),
5227                    " { nome: nome.to_string(), list }` two-field ",
5228                    "struct-literal onto one substrate primitive so ",
5229                    "every in-crate wire-up on this variant reads ",
5230                    "through one dispatch rather than the pre-lift ",
5231                    "open-coded struct-literal block."
5232                )]
5233                #[must_use]
5234                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5235                    Self::$variant { nome: nome.to_string(), list }
5236                }
5237            )*
5238        }
5239    };
5240}
5241
5242dep_nome_list_ctors! {
5243    duplicate_nome => DuplicateNome,
5244    dep_is_self => DepIsSelf,
5245}
5246
5247// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5248// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5249// <value>.to_string(), reason }` struct-variant wire-up sites at
5250// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5251// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5252// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5253// primitive family per typed variant — the `DepError`-side siblings of the
5254// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5255// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5256// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5257// the two-slot `{ nome, caminho }` envelope, and
5258// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5259// caminho, byte }` envelope. The three variants share the same
5260// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5261// the `nome` field names the offending dep the diagnostic points the
5262// author back at, the middle `<axis>: String` field carries the offending
5263// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5264// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5265// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5266// field carries the parser-shaped rejection sentence the paired
5267// [`crate::render::require_valid_versao_requirement`] /
5268// [`crate::render::is_git_repo_url`] /
5269// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5270// axis-field name differs across variants (`versao` / `repo` /
5271// `caracteristica`) so the ctor family below takes the axis field name as
5272// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5273// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5274// -> Self` inherent constructor per typed variant that spells the uniform
5275// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5276// `reason` forwarded owned) exactly once. Peer of the sibling
5277// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5278// family on the `AplicacaoError` envelope's mirror-symmetric
5279// `{ <field>: String, reason: String }` two-slot shape — same
5280// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5281// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5282// envelope keys off (every `DepError` variant carries the offending
5283// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5284// offending block in one edit).
5285//
5286// The three wire-up sites this fold closes are:
5287// - [`DepSource::validate`]'s `:repo` value-shape arm
5288//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5289//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5290//   rejects the offending URL);
5291// - [`Dep::validate`]'s `:versao` requirement-shape arm
5292//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5293//   self.versao_requirement().to_string(), reason }` inside the
5294//   [`crate::render::require_valid_versao_requirement`] callback pair);
5295// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5296//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5297//   caracteristica: c.clone(), reason })` after
5298//   [`crate::render::is_cargo_feature_name`] rejects the offending
5299//   feature-name).
5300//
5301// Each opened the identical five-line struct-literal against the same
5302// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5303// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5304// same altitude the peer four already-lifted `DepError` ctor families
5305// closed on their sibling shape-envelopes. The three variant / axis-field
5306// discriminators are the only things that vary between them; the rest of
5307// the struct-literal is a byte-for-byte re-inline.
5308//
5309// Every future consumer wanting to raise one of these three diagnostics
5310// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5311// time re-checking each declared dep against the same requirement +
5312// git-URL + feature-name value-shape cascade, a future `feira validate
5313// --deps` per-caixa admission verb re-running the shape gates on demand,
5314// a per-lacre overlay resolver rejecting an author-supplied dep against a
5315// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5316// the five-line struct-literal in lockstep with the three in-crate
5317// wire-up sites.
5318macro_rules! dep_nome_axis_reason_ctors {
5319    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5320        impl DepError {
5321            $(
5322                #[doc = concat!(
5323                    "Construct a [`DepError::",
5324                    stringify!($variant),
5325                    "`] naming the offending `:deps :nome`, the offending ",
5326                    "`:", stringify!($axis), "` axis value, and the ",
5327                    "parser-shaped rejection `reason`. Folds the uniform ",
5328                    "`Self::",
5329                    stringify!($variant),
5330                    " { nome: nome.to_string(), ",
5331                    stringify!($axis),
5332                    ": ",
5333                    stringify!($axis),
5334                    ".to_string(), reason }` three-field struct-literal ",
5335                    "onto one substrate primitive so every in-crate ",
5336                    "wire-up on this variant reads through one dispatch ",
5337                    "rather than the pre-lift five-line open-coded block. ",
5338                    "The `nome: &str` and `",
5339                    stringify!($axis),
5340                    ": &str` parameters accept `&str` literals and ",
5341                    "`&String` (via Deref coercion) so every existing ",
5342                    "wire-up threads through the ctor without a ",
5343                    "pre-conversion; the `reason: String` parameter takes ",
5344                    "an owned `String` (not `impl Into<String>`) matching ",
5345                    "the paired `crate::render::*` predicate's ",
5346                    "`Result<(), String>` return shape every wire-up ",
5347                    "already holds owned at the call site."
5348                )]
5349                #[must_use]
5350                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5351                    Self::$variant {
5352                        nome: nome.to_string(),
5353                        $axis: $axis.to_string(),
5354                        reason,
5355                    }
5356                }
5357            )*
5358        }
5359    };
5360}
5361
5362dep_nome_axis_reason_ctors! {
5363    versao_invalid => VersaoInvalid { versao },
5364    fonte_repo_shape => FonteRepoShape { repo },
5365    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5366}
5367
5368// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5369// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5370// <value>.to_string() }` struct-variant wire-up sites at
5371// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5372// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5373// per-entry set-not-multiset dedup closure onto one substrate-primitive
5374// family per typed variant — the missing two-slot rung on the
5375// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5376// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5377// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5378// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5379// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5380// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5381// symmetric sibling of the peer
5382// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5383// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5384// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5385// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5386// owned altitude the `DepError` envelope keys off (every `DepError`
5387// variant carries the offending `:deps :nome` verbatim so the author
5388// can grep their caixa.lisp for the offending block in one edit). The
5389// three variants share the same `{ nome: String, <axis>: String }`
5390// two-slot shape: the `nome` field names the offending dep the
5391// diagnostic points the author back at, and the middle `<axis>:
5392// String` field carries the offending per-envelope axis value verbatim
5393// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5394// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5395// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5396// The middle axis-field name differs across variants (`pin` / `pins` /
5397// `caracteristica`) so the ctor family below takes the axis field name
5398// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5399// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5400// Self` inherent constructor per typed variant that spells the
5401// uniform two-field construction (`nome.to_string()` /
5402// `<axis>.to_string()`) exactly once.
5403//
5404// The three wire-up sites this fold closes are:
5405// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5406//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5407//   pin.to_string() });` inside the `set.len() == 1` branch after the
5408//   `is_some_and(String::is_empty)` iterator);
5409// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5410//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5411//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5412// - [`Dep::validate_caracteristicas`]'s per-entry
5413//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5414//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5415//   [`crate::render::insert_first_seen`]).
5416//
5417// Each opened the identical four-line struct-literal against the same
5418// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5419// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5420// same altitude the peer four already-lifted `DepError` ctor families
5421// closed on their sibling shape-envelopes. The three variant / axis-
5422// field discriminators are the only things that vary between them;
5423// the rest of the struct-literal is a byte-for-byte re-inline.
5424//
5425// Every future consumer wanting to raise one of these three
5426// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5427// at lacre-resolve time re-checking each declared dep against the
5428// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5429// set-not-multiset cascade, a future `feira validate --deps` per-
5430// caixa admission verb re-running the shape gates on demand, a
5431// per-lacre overlay resolver rejecting an author-supplied dep against
5432// a cluster-local snapshot the M4 CR materializer projects) now
5433// reaches one dispatch rather than re-inlining the four-line struct-
5434// literal in lockstep with the three in-crate wire-up sites.
5435macro_rules! dep_nome_axis_ctors {
5436    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5437        impl DepError {
5438            $(
5439                #[doc = concat!(
5440                    "Construct a [`DepError::",
5441                    stringify!($variant),
5442                    "`] naming the offending `:deps :nome` and the ",
5443                    "offending `:", stringify!($axis), "` axis value. ",
5444                    "Folds the uniform `Self::",
5445                    stringify!($variant),
5446                    " { nome: nome.to_string(), ",
5447                    stringify!($axis),
5448                    ": ",
5449                    stringify!($axis),
5450                    ".to_string() }` two-field struct-literal onto one ",
5451                    "substrate primitive so every in-crate wire-up on ",
5452                    "this variant reads through one dispatch rather than ",
5453                    "the pre-lift four-line open-coded block. Both `nome: ",
5454                    "&str` and `",
5455                    stringify!($axis),
5456                    ": &str` parameters accept `&str` literals and ",
5457                    "`&String` (via Deref coercion) so every existing ",
5458                    "wire-up threads through the ctor without a pre-",
5459                    "conversion."
5460                )]
5461                #[must_use]
5462                pub fn $ctor(nome: &str, $axis: &str) -> Self {
5463                    Self::$variant {
5464                        nome: nome.to_string(),
5465                        $axis: $axis.to_string(),
5466                    }
5467                }
5468            )*
5469        }
5470    };
5471}
5472
5473dep_nome_axis_ctors! {
5474    fonte_pin_empty => FontePinEmpty { pin },
5475    fonte_pin_ambiguous => FontePinAmbiguous { pins },
5476    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5477}
5478
5479// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5480// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5481// struct-variant wire-up sites at [`DepSource::validate`]'s
5482// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5483// the `DepError` envelope — the last open-coded ctor site remaining on
5484// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5485// carries, and the single-variant sibling of the peer four already-
5486// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5487// on the two-slot `{ nome, caminho }` envelope,
5488// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5489// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5490// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5491// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5492// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5493// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5494// `{ …, value: String, reason: String }` payload shape, one axis
5495// removed at the `nome`-only-owner altitude the `DepError` envelope
5496// keys off (no `edge_pair()` de/para pair).
5497//
5498// The two wire-up sites this fold closes are the paired refname-pin
5499// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5500// pin: pin.to_string(), value: v.clone(), reason }` inside the
5501// `[(":tag", tag), (":branch", branch)]` iterator against
5502// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5503// (`|| DepError::FontePinShape { nome: nome.to_string(),
5504// pin: ":rev".to_string(), value: v.clone(), reason }` against
5505// [`crate::render::is_git_oid`]) — each opened the identical
5506// `DepError::FontePinShape { … }` six-line struct-literal against the
5507// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5508// tuple, the exact "same block re-inlined at every consumer" shape
5509// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5510// the only thing that varies between them (`":tag"`/`":branch"` on
5511// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5512// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5513// route through the same ctor because their `pin` field carries the
5514// author-surface tag verbatim (matching the `FontePinEmpty` /
5515// `FontePinAmbiguous` sibling variants' `pin: String` axis
5516// convention), so the offending author can grep their caixa.lisp for
5517// the offending `:tag "<value>"` / `:branch "<value>"` /
5518// `:rev "<value>"` literal in one edit.
5519//
5520// The single ctor below folds each wire-up onto one dispatch:
5521// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5522// the pre-lift struct-literal on the same `(&str, &str, &str,
5523// String)` fixture. The uniform four-field construction
5524// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5525// `reason` forwarded owned) is spelled once here rather than at every
5526// wire-up site. The `reason: String` field takes an owned `String`
5527// (not `impl Into<String>`) matching the two call sites' pre-existing
5528// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5529// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5530// predicates return `Result<(), String>`, so the caller always holds
5531// an owned `String` at the wire-up site and threading it through the
5532// ctor without a `.into()` shim keeps the routing shape byte-equal to
5533// the pre-lift block. The `value: &str` parameter accepts both `&str`
5534// literals (unused today) and `&String` (from the caller-held
5535// `v: &String` on each arm, via Deref coercion), so every existing
5536// wire-up threads through the ctor without a pre-conversion.
5537//
5538// Every future consumer that wants to construct this variant outside
5539// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5540// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5541// re-checking the same value-shape axes the resolver consumes, a
5542// future `feira validate --deps` per-caixa admission verb re-checking
5543// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5544// resolver rejecting a git-pin value against a cluster-local
5545// snapshot) now reaches this variant through one call rather than
5546// re-inlining the six-line struct-literal in lockstep with the two
5547// in-crate wire-up sites.
5548impl DepError {
5549    /// Construct a [`DepError::FontePinShape`] naming the offending
5550    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5551    /// axis tag, the offending value, and the parser-shaped `reason`.
5552    /// Folds the uniform
5553    /// `Self::FontePinShape { nome: nome.to_string(),
5554    /// pin: pin.to_string(), value: value.to_string(), reason }`
5555    /// four-field struct-literal onto one substrate primitive so
5556    /// every [`DepSource::validate`] wire-up on this variant reads
5557    /// through one dispatch rather than the pre-lift six-line
5558    /// open-coded block. The `nome` string threads verbatim from
5559    /// [`Dep::nome`] at the call site; the `pin` string carries the
5560    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5561    /// `value` string carries the offending refname / hex-OID
5562    /// verbatim; and `reason` forwards the owned `String` returned
5563    /// by [`crate::render::is_git_ref_name`] /
5564    /// [`crate::render::is_git_oid`] without a `.into()` shim.
5565    #[must_use]
5566    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5567        Self::FontePinShape {
5568            nome: nome.to_string(),
5569            pin: pin.to_string(),
5570            value: value.to_string(),
5571            reason,
5572        }
5573    }
5574
5575    /// Construct a [`DepError::NomeInvalid`] naming the offending
5576    /// `:deps :nome` byte-string and the parser-shaped rejection
5577    /// `reason` returned by [`crate::render::is_dns_1123_label`].
5578    ///
5579    /// Folds the uniform
5580    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5581    /// struct-literal onto one substrate primitive so every wire-up on
5582    /// this variant reads through one dispatch rather than the pre-lift
5583    /// four-line open-coded `DepError::NomeInvalid { nome:
5584    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5585    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5586    /// ctor-family ladder (`{ nome }` one-slot →
5587    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5588    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5589    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5590    /// `{ nome, <axis>: String, reason: String }` three-slot →
5591    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5592    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5593    /// — the sole variant on the envelope carrying the
5594    /// `{ nome: String, reason: String }` two-slot shape without a
5595    /// middle axis, matching the peer
5596    /// [`crate::manifest::ManifestError::NomeInvalid`] +
5597    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5598    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5599    /// four-axis DNS-1123 caixa-identifier diagnostic family the
5600    /// existing `nome_invalid_diagnostic_carries_offending_name` test
5601    /// pins on this envelope.
5602    ///
5603    /// The `nome: &str` parameter accepts `&str` literals and `&String`
5604    /// (via Deref coercion) so the sole in-crate wire-up threads through
5605    /// the ctor without a pre-conversion; the `reason: String`
5606    /// parameter takes an owned `String` (not `impl Into<String>`)
5607    /// matching the [`crate::render::is_dns_1123_label`] predicate's
5608    /// `Result<(), String>` return shape the sole wire-up site already
5609    /// holds owned at the call site, keeping the routing byte-equal to
5610    /// the pre-lift block. Same owned-`String`-forward `reason` payload
5611    /// discipline as the sibling three-slot family
5612    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5613    /// and the four-slot [`DepError::fonte_pin_shape`] on
5614    /// `{ nome, pin, value, reason }`.
5615    ///
5616    /// Every future consumer that raises the same diagnostic outside
5617    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5618    /// re-validator at lacre-resolve time re-checking each declared
5619    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5620    /// side schema uses (the `:nome` value flows verbatim as the target
5621    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5622    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5623    /// checkout-directory leaf), a future `feira validate --deps`
5624    /// per-caixa admission verb re-running the shape gate on demand, a
5625    /// per-lacre overlay resolver rejecting an author-supplied dep's
5626    /// `:nome` against a cluster-local snapshot the M4 CR materializer
5627    /// projects, a future authoring-surface widening the field into a
5628    /// `(String, Vec<Suggestion>)` pair carrying a
5629    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5630    /// variant through one call rather than re-inlining the four-line
5631    /// struct-literal in lockstep with the one in-crate wire-up site.
5632    #[must_use]
5633    pub fn nome_invalid(nome: &str, reason: String) -> Self {
5634        Self::NomeInvalid {
5635            nome: nome.to_string(),
5636            reason,
5637        }
5638    }
5639}
5640
5641#[allow(clippy::trivially_copy_pass_by_ref)]
5642fn is_false(b: &bool) -> bool {
5643    !*b
5644}
5645
5646#[cfg(test)]
5647mod tests {
5648    use super::*;
5649
5650    #[test]
5651    fn registry_dep_is_minimal() {
5652        let d = Dep::simple("caixa-teia", "^0.1");
5653        assert_eq!(d.nome, "caixa-teia");
5654        assert_eq!(d.versao, "^0.1");
5655        assert!(d.fonte.is_none());
5656        assert!(!d.opcional());
5657        assert!(d.caracteristicas().is_empty());
5658    }
5659
5660    #[test]
5661    fn dep_string_scalar_accessor_pair_is_const_fn() {
5662        // Fail-before-pass-after pin on [`Dep::nome`] +
5663        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5664        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5665        // entry's [`String`] storage through the `pub const fn`
5666        // [`String::as_str`] (const-stable since Rust 1.87, well
5667        // within the workspace MSRV) — any future accidental
5668        // downgrade to non-`const` fails the corresponding
5669        // `<name>_via_const_fn` wrapper at caixa-core build time with
5670        // E0015 (`cannot call non-const method`), strictly stronger
5671        // than a runtime `assert!`. Sibling of the peer
5672        // per-M2/M3/universal-axis `String → &str` scalar-accessor
5673        // family pins on the sibling `const`-eval-surface passes
5674        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5675        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5676        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5677        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5678        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5679        // [`crate::aplicacao::Entrada::destination`] at the M3
5680        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5681        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5682        // M2 supervisor-tree axis,
5683        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5684        // M2 upgrade axis, and the per-`:contratos`
5685        // [`crate::aplicacao::WitContract::source`] /
5686        // [`crate::aplicacao::WitContract::destination`] /
5687        // [`crate::aplicacao::WitContract::world_ref`] trio the
5688        // sibling pin at 279823b already anchors).
5689        const fn nome_via_const_fn(d: &Dep) -> &str {
5690            d.nome()
5691        }
5692        const fn versao_via_const_fn(d: &Dep) -> &str {
5693            d.versao_requirement()
5694        }
5695        for (nome, versao) in [
5696            ("caixa-teia", "^0.1"),
5697            ("caixa-mesh", "~0.2.3"),
5698            ("caixa-helm", "*"),
5699        ] {
5700            let d = Dep::simple(nome, versao);
5701            assert_eq!(nome_via_const_fn(&d), d.nome());
5702            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5703            assert_eq!(d.nome(), nome);
5704            assert_eq!(d.versao_requirement(), versao);
5705        }
5706    }
5707
5708    #[test]
5709    fn dep_outer_accessor_family_is_const_fn() {
5710        // Fail-before-pass-after pin on [`Dep::fonte`] +
5711        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5712        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5713        // entry's composite / list storage through a `pub const fn`
5714        // stdlib method (`Option::<DepSource>::as_ref` /
5715        // `Vec::<String>::as_slice`, both const-stable since Rust
5716        // 1.83, well within the workspace MSRV). Any future
5717        // accidental downgrade to non-`const` fails the corresponding
5718        // `<name>_via_const_fn` wrapper at caixa-core build time with
5719        // E0015 (`cannot call non-const method`), strictly stronger
5720        // than a runtime `assert!` and side-stepping the destructor-
5721        // in-const restriction the `Dep` fixture's `String` /
5722        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5723        // direct-`const _: () = assert!(...)` residence.
5724        //
5725        // Peer of the sibling per-`Dep` scalar-accessor pair pin
5726        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5727        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5728        // the `const`-eval-surface discipline onto the composite-
5729        // reference and slice-return arms of the outer-`Dep` accessor
5730        // family, closing the four-slot outer surface (`:nome` +
5731        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5732        // posture. The `:opcional` `bool` arm already carries the
5733        // posture through [`Dep::opcional`]'s prior `pub const fn`
5734        // declaration, so this pin lands the last two unlifted
5735        // outer-`Dep` accessors and closes the family.
5736        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5737            d.fonte()
5738        }
5739        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5740            d.caracteristicas()
5741        }
5742        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5743        let empty = Dep::simple("caixa-teia", "^0.1");
5744        assert!(fonte_via_const_fn(&empty).is_none());
5745        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5746        assert!(caracteristicas_via_const_fn(&empty).is_empty());
5747        assert_eq!(
5748            caracteristicas_via_const_fn(&empty),
5749            empty.caracteristicas()
5750        );
5751        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5752        // still empty.
5753        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5754        assert!(fonte_via_const_fn(&git).is_some());
5755        assert_eq!(fonte_via_const_fn(&git), git.fonte());
5756        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5757        // Populated `:caracteristicas` — exercise the non-empty
5758        // slice-view arm to pin the accessor's borrow shape against
5759        // both a `Vec::new()` empty backing buffer and a populated one.
5760        let mut with_features = Dep::simple("caixa-teia", "^0.1");
5761        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5762        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5763        assert_eq!(
5764            caracteristicas_via_const_fn(&with_features),
5765            with_features.caracteristicas()
5766        );
5767    }
5768
5769    #[test]
5770    fn git_dep_carries_tag() {
5771        let d = Dep::git("t", "*", "github:o/r", "v1");
5772        match d.fonte {
5773            Some(DepSource::Git {
5774                ref repo, ref tag, ..
5775            }) => {
5776                assert_eq!(repo, "github:o/r");
5777                assert_eq!(tag.as_deref(), Some("v1"));
5778            }
5779            _ => panic!("expected Git source"),
5780        }
5781    }
5782
5783    #[test]
5784    fn validate_accepts_simple_dep() {
5785        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5786    }
5787
5788    #[test]
5789    fn validate_rejects_empty_nome() {
5790        // The fail-before-pass-after pin for `:nome ""`: the empty-name
5791        // arm fires first so the per-entry parse-side diagnostic doesn't
5792        // emit a useless `nome: ""` reference.
5793        let mut d = Dep::simple("placeholder", "^0.1");
5794        d.nome = String::new();
5795        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5796    }
5797
5798    #[test]
5799    fn validate_rejects_empty_versao() {
5800        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5801        // semver crate accepts the empty string as a wildcard match),
5802        // so the empty-`:versao` arm is structurally necessary even
5803        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5804        // `EmptyChildVersion` ordering on the other two `:versao` axes.
5805        let mut d = Dep::simple("caixa-teia", "ignored");
5806        d.versao = String::new();
5807        let err = d.validate().unwrap_err();
5808        assert!(
5809            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5810            "got {err:?}"
5811        );
5812    }
5813
5814    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5815
5816    #[test]
5817    fn validate_rejects_nome_with_uppercase() {
5818        // The fail-before-pass-after pin: a non-empty but uppercase
5819        // `:nome` silently passed `validate()` on every pre-gate
5820        // codebase because the prior shape only refused the empty
5821        // string. The DNS-1123 violation surfaced far downstream at
5822        // lacre-resolve time when the *target* caixa's `:nome` failed
5823        // its own gate — far from the `:deps` entry, with a diagnostic
5824        // naming the target rather than the dep entry that referenced
5825        // it. Same fail-before-pass-after fixture pinned for
5826        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5827        // and Caixa `:nome` (6c992f8).
5828        let d = Dep::simple("Caixa-Teia", "^0.1");
5829        let err = d.validate().unwrap_err();
5830        assert!(
5831            matches!(
5832                err,
5833                DepError::NomeInvalid { ref nome, ref reason }
5834                    if nome == "Caixa-Teia" && reason.contains("uppercase")
5835            ),
5836            "got {err:?}"
5837        );
5838    }
5839
5840    #[test]
5841    fn validate_rejects_nome_with_underscore() {
5842        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5843        // "I'm thinking of Go module names / Python identifiers" leak.
5844        // Same fixture pinned for the peer caixa-identifier axes.
5845        let d = Dep::simple("caixa_teia", "^0.1");
5846        let err = d.validate().unwrap_err();
5847        assert!(
5848            matches!(
5849                err,
5850                DepError::NomeInvalid { ref nome, ref reason }
5851                    if nome == "caixa_teia" && reason.contains('_')
5852            ),
5853            "got {err:?}"
5854        );
5855    }
5856
5857    #[test]
5858    fn validate_rejects_nome_with_dot() {
5859        // A `:deps :nome` is a single DNS-1123 *label*, not a
5860        // subdomain — dots are rejected. The `"caixa.teia"` shape is
5861        // the canonical "I confused the dep name with the FQDN /
5862        // namespace" footgun, distinct from the legitimate
5863        // `:fonte :repo "github:org/caixa-teia"` axis.
5864        let d = Dep::simple("caixa.teia", "^0.1");
5865        let err = d.validate().unwrap_err();
5866        assert!(
5867            matches!(
5868                err,
5869                DepError::NomeInvalid { ref nome, ref reason }
5870                    if nome == "caixa.teia" && reason.contains('.')
5871            ),
5872            "got {err:?}"
5873        );
5874    }
5875
5876    #[test]
5877    fn validate_rejects_nome_with_leading_hyphen() {
5878        // RFC 1123 requires alphanumeric at both label boundaries.
5879        // Pinned in parity with the peer DNS-1123 fixtures.
5880        let d = Dep::simple("-caixa-teia", "^0.1");
5881        let err = d.validate().unwrap_err();
5882        assert!(
5883            matches!(
5884                err,
5885                DepError::NomeInvalid { ref nome, ref reason }
5886                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
5887            ),
5888            "got {err:?}"
5889        );
5890    }
5891
5892    #[test]
5893    fn validate_rejects_nome_with_trailing_hyphen() {
5894        let d = Dep::simple("caixa-teia-", "^0.1");
5895        let err = d.validate().unwrap_err();
5896        assert!(
5897            matches!(
5898                err,
5899                DepError::NomeInvalid { ref nome, ref reason }
5900                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
5901            ),
5902            "got {err:?}"
5903        );
5904    }
5905
5906    #[test]
5907    fn validate_rejects_nome_with_slash() {
5908        // The canonical "I copied the GitHub repo path into `:nome`
5909        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5910        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5911        // the local-name slot. Same fixture pinned for `:membros
5912        // :caixa` (3f9d7a0).
5913        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5914        let err = d.validate().unwrap_err();
5915        assert!(
5916            matches!(
5917                err,
5918                DepError::NomeInvalid { ref nome, ref reason }
5919                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
5920            ),
5921            "got {err:?}"
5922        );
5923    }
5924
5925    #[test]
5926    fn validate_rejects_nome_too_long() {
5927        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5928        // Built from a valid character set so the length-bound
5929        // diagnostic surfaces before any per-character check (the
5930        // order pin parallel to the per-character predicates inside
5931        // [`crate::render::is_dns_1123_label`]).
5932        let long = "a".repeat(64);
5933        let d = Dep::simple(&long, "^0.1");
5934        let err = d.validate().unwrap_err();
5935        assert!(
5936            matches!(
5937                err,
5938                DepError::NomeInvalid { ref nome, ref reason }
5939                    if nome.len() == 64 && reason.contains("max length of 63")
5940            ),
5941            "got {err:?}"
5942        );
5943    }
5944
5945    #[test]
5946    fn validate_accepts_canonical_nome_labels() {
5947        // Positive-control sweep — every form the K8s apiserver
5948        // accepts as a DNS-1123 label must round-trip through
5949        // validate. Covers a hyphen-bearing label, a numeric-suffix
5950        // label, a leading-digit label, a single-character label, and
5951        // a 63-byte (exactly the cap) label — the same fixture set
5952        // the peer `:membros :caixa` / `:children :caixa` positive
5953        // controls pin.
5954        for nome in [
5955            "caixa-teia",
5956            "caixa-resolver2",
5957            "2nd-tier-cache",
5958            "x",
5959            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5960        ] {
5961            Dep::simple(nome, "^0.1")
5962                .validate()
5963                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5964        }
5965    }
5966
5967    #[test]
5968    fn nome_empty_takes_precedence_over_nome_invalid() {
5969        // Ordering pin: `NomeEmpty` is the more self-locating
5970        // diagnostic on `""` and must lead — `is_dns_1123_label` is
5971        // only reached after the empty-check fires at the call site.
5972        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5973        // (3f9d7a0) on the peer caixa-identifier axis.
5974        let mut d = Dep::simple("placeholder", "^0.1");
5975        d.nome = String::new();
5976        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5977    }
5978
5979    #[test]
5980    fn nome_invalid_fires_before_versao_empty() {
5981        // Ordering pin: a malformed `:nome` fires before any `:versao`
5982        // axis check on the *same* entry — the per-entry shape gates
5983        // run top-to-bottom (nome empty → nome shape → versao empty →
5984        // versao parse → fonte shape), so a one-entry caixa.lisp with
5985        // both wrong sees the name-side diagnostic first (the name is
5986        // the self-locating axis — without a valid name, the parse
5987        // diagnostic can't quote `:nome "<bad>"`). Same ordering
5988        // discipline as `membro_caixa_invalid_fires_before_versao_check`
5989        // (3f9d7a0).
5990        let mut d = Dep::simple("Caixa-Teia", "^0.1");
5991        d.versao = String::new();
5992        let err = d.validate().unwrap_err();
5993        assert!(
5994            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5995            "got {err:?}"
5996        );
5997    }
5998
5999    #[test]
6000    fn nome_invalid_fires_before_versao_invalid() {
6001        // Ordering pin: a malformed `:nome` fires before the `:versao`
6002        // parse-side check on the *same* entry. Pin separately from
6003        // the empty-versao ordering so a future re-ordering surfaces
6004        // here, parallel to the b0c8389 / c4213a4 trajectory.
6005        let d = Dep::simple("Caixa-Teia", "^^0.1");
6006        let err = d.validate().unwrap_err();
6007        assert!(
6008            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6009            "got {err:?}"
6010        );
6011    }
6012
6013    #[test]
6014    fn nome_invalid_fires_before_fonte_invalid() {
6015        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6016        // shape check on the *same* entry. The `:fonte` diagnostic
6017        // names the offending dep's `:nome` verbatim (via
6018        // `DepSource::validate(&self.nome)`), so a non-self-locating
6019        // name would taint the downstream diagnostic too — the gate
6020        // ordering keeps both diagnostics individually self-locating.
6021        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6022        d.fonte = Some(DepSource::Git {
6023            repo: String::new(),
6024            tag: None,
6025            rev: None,
6026            branch: None,
6027        });
6028        let err = d.validate().unwrap_err();
6029        assert!(
6030            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6031            "got {err:?}"
6032        );
6033    }
6034
6035    #[test]
6036    fn nome_invalid_diagnostic_carries_offending_name() {
6037        // The diagnostic-shape pin: the error names the offending
6038        // `:nome` value verbatim so the author can grep their
6039        // caixa.lisp without re-running the build, and carries a
6040        // non-empty `reason` from `is_dns_1123_label` so the
6041        // predicate's own wording flows through to the diagnostic.
6042        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6043        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6044        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6045        // share a structurally-equivalent diagnostic family.
6046        let d = Dep::simple("Caixa_Teia", "^0.1");
6047        let err = d.validate().unwrap_err();
6048        let DepError::NomeInvalid { nome, reason } = err else {
6049            panic!("expected NomeInvalid, got other variant");
6050        };
6051        assert_eq!(nome, "Caixa_Teia");
6052        assert!(
6053            !reason.is_empty(),
6054            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6055        );
6056    }
6057
6058    #[test]
6059    fn validate_rejects_invalid_versao_requirement() {
6060        // The fail-before-pass-after pin: a non-empty but malformed
6061        // requirement (`"^bad-version"`) silently passed every pre-gate
6062        // codebase because `:deps :versao` wasn't validated. The parse
6063        // failure surfaced far downstream at lacre-resolve time with a
6064        // `semver::Error` that didn't name which `:deps` entry carried
6065        // the typo. The new gate moves the check to caixa-build time
6066        // at the source caixa.lisp.
6067        let d = Dep::simple("caixa-teia", "^bad-version");
6068        let err = d.validate().unwrap_err();
6069        assert!(
6070            matches!(
6071                err,
6072                DepError::VersaoInvalid { ref nome, ref versao, .. }
6073                    if nome == "caixa-teia" && versao == "^bad-version"
6074            ),
6075            "got {err:?}"
6076        );
6077    }
6078
6079    #[test]
6080    fn validate_rejects_versao_with_double_caret_typo() {
6081        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6082        // Cargo-shaped requirement on first glance but fails the parser
6083        // because semver doesn't accept stacked operators. Pin this
6084        // adjacent-shape footgun explicitly so a future relaxation that
6085        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6086        // parity with the `:membros` / `:children` fixtures.
6087        let d = Dep::simple("caixa-teia", "^^0.1");
6088        let err = d.validate().unwrap_err();
6089        assert!(
6090            matches!(
6091                err,
6092                DepError::VersaoInvalid { ref nome, ref versao, .. }
6093                    if nome == "caixa-teia" && versao == "^^0.1"
6094            ),
6095            "got {err:?}"
6096        );
6097    }
6098
6099    #[test]
6100    fn validate_rejects_versao_with_v_prefixed_tag() {
6101        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6102        // semver requirement slot" typo — an author copies the
6103        // publish-side git-tag string verbatim into `:versao`, but
6104        // Cargo's semver parser rejects the leading `v`. Same fixture
6105        // pinned for `:membros :versao` (9888b13) and `:children
6106        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6107        // are *accepted* by the semver crate as an `*` wildcard on the
6108        // patch axis — they're a Cargo-side valid shape, not a typo.)
6109        let d = Dep::simple("caixa-teia", "v0.1");
6110        let err = d.validate().unwrap_err();
6111        assert!(
6112            matches!(
6113                err,
6114                DepError::VersaoInvalid { ref nome, ref versao, .. }
6115                    if nome == "caixa-teia" && versao == "v0.1"
6116            ),
6117            "got {err:?}"
6118        );
6119    }
6120
6121    #[test]
6122    fn validate_accepts_canonical_versao_forms() {
6123        // The five Cargo-shaped requirement forms `:membros :versao`
6124        // and `:children :versao` already accept via
6125        // `crate::parse_requirement` must pass the deps gate without
6126        // re-validating at the resolver layer. Pin every leg so a
6127        // future tightening of the canonical set surfaces here as a
6128        // test failure.
6129        for form in [
6130            "^0.1",      // caret — minor-range pin (the most common shape)
6131            "~0.1.2",    // tilde — patch-range pin
6132            "0.1.0",     // exact — single-version pin
6133            "*",         // wildcard — explicitly any-version
6134            ">=0.1, <2", // multi-range — comma-separated comparators
6135        ] {
6136            Dep::simple("caixa-teia", form)
6137                .validate()
6138                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6139        }
6140    }
6141
6142    #[test]
6143    fn versao_empty_takes_precedence_over_invalid() {
6144        // Order pin: the existing `VersaoEmpty` diagnostic (which
6145        // doesn't try to parse) fires before the new `VersaoInvalid`
6146        // parse-side diagnostic, so an empty `:versao` keeps its
6147        // narrower error message — `parse_requirement("")` would
6148        // otherwise return `Ok(STAR)` and silently pass, but the empty
6149        // arm catches it first.
6150        let mut d = Dep::simple("caixa-teia", "ignored");
6151        d.versao = String::new();
6152        let err = d.validate().unwrap_err();
6153        assert!(
6154            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6155            "got {err:?}"
6156        );
6157    }
6158
6159    #[test]
6160    fn nome_empty_takes_precedence_over_versao_invalid() {
6161        // Order pin: even when `:versao` is malformed and would raise
6162        // its own diagnostic, `:nome ""` fires first because the
6163        // per-entry parse diagnostic needs a non-empty name to be
6164        // self-locating. Mirrors the
6165        // `membros_validation_runs_before_contratos_membership_check`
6166        // ordering on the typed-graph layer.
6167        let mut d = Dep::simple("placeholder", "^bad");
6168        d.nome = String::new();
6169        let err = d.validate().unwrap_err();
6170        assert_eq!(err, DepError::NomeEmpty);
6171    }
6172
6173    #[test]
6174    fn versao_invalid_diagnostic_carries_offending_versao() {
6175        // The diagnostic-shape pin: the error names the offending
6176        // `:versao` value verbatim so the author can grep their
6177        // caixa.lisp without re-running the build, and carries a
6178        // non-empty `reason` from `semver::VersionReq::parse` so the
6179        // parser's own wording flows through to the diagnostic.
6180        let d = Dep::simple("caixa-teia", "not-a-req");
6181        let err = d.validate().unwrap_err();
6182        let DepError::VersaoInvalid {
6183            nome,
6184            versao,
6185            reason,
6186        } = err
6187        else {
6188            panic!("expected VersaoInvalid, got other variant");
6189        };
6190        assert_eq!(nome, "caixa-teia");
6191        assert_eq!(versao, "not-a-req");
6192        assert!(
6193            !reason.is_empty(),
6194            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6195        );
6196    }
6197
6198    // -- :fonte value-shape gate ------------------------------------------
6199
6200    fn dep_with_fonte(fonte: DepSource) -> Dep {
6201        let mut d = Dep::simple("caixa-teia", "^0.1");
6202        d.fonte = Some(fonte);
6203        d
6204    }
6205
6206    #[test]
6207    fn validate_accepts_git_fonte_with_tag() {
6208        // The positive-control pin on the canonical git source — exactly
6209        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6210        // shape every existing caixa-resolver integration test uses.
6211        let d = dep_with_fonte(DepSource::Git {
6212            repo: "github:pleme-io/caixa-teia".into(),
6213            tag: Some("v0.1.0".into()),
6214            rev: None,
6215            branch: None,
6216        });
6217        d.validate().unwrap();
6218    }
6219
6220    #[test]
6221    fn validate_accepts_git_fonte_with_rev() {
6222        // Each of the three pin axes is independently a valid single-pin
6223        // shape; pin the :rev arm so a future relaxation that only
6224        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6225        // OID — the canonical `git rev-parse HEAD` emission shape the
6226        // `crate::render::is_git_oid` value-shape gate now requires;
6227        // abbreviated OIDs are ambiguous across repo history and
6228        // rejected at this gate (pinned separately by
6229        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6230        let d = dep_with_fonte(DepSource::Git {
6231            repo: "github:pleme-io/caixa-teia".into(),
6232            tag: None,
6233            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6234            branch: None,
6235        });
6236        d.validate().unwrap();
6237    }
6238
6239    #[test]
6240    fn validate_accepts_git_fonte_with_branch() {
6241        // The :branch arm is the third valid single-pin shape — pinned
6242        // separately so the gate-accepts-all-three-pin-axes contract is
6243        // a build-error to relax.
6244        let d = dep_with_fonte(DepSource::Git {
6245            repo: "github:pleme-io/caixa-teia".into(),
6246            tag: None,
6247            rev: None,
6248            branch: Some("main".into()),
6249        });
6250        d.validate().unwrap();
6251    }
6252
6253    #[test]
6254    fn validate_accepts_path_fonte() {
6255        // The positive-control pin on the path source — non-empty
6256        // :caminho, no pin axes (paths have no commit identity). Pinned
6257        // so a future "paths must also pin a rev" tightening surfaces
6258        // here as a structural decision, not a silent break.
6259        let d = dep_with_fonte(DepSource::Path {
6260            caminho: "../caixa-teia".into(),
6261        });
6262        d.validate().unwrap();
6263    }
6264
6265    #[test]
6266    fn validate_rejects_git_fonte_with_empty_repo() {
6267        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6268        // "v1")`: the empty-repo shape silently passed every pre-gate
6269        // codebase because `:fonte` wasn't validated. The git-clone
6270        // failure surfaced far downstream at lacre-resolve time with no
6271        // field naming which `:deps` entry carried the typo. The new
6272        // gate moves the check to caixa-build time at the source
6273        // caixa.lisp.
6274        let d = dep_with_fonte(DepSource::Git {
6275            repo: String::new(),
6276            tag: Some("v0.1.0".into()),
6277            rev: None,
6278            branch: None,
6279        });
6280        let err = d.validate().unwrap_err();
6281        assert!(
6282            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6283            "got {err:?}"
6284        );
6285    }
6286
6287    // -- :repo value-shape gate -------------------------------------------
6288    //
6289    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6290    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6291    // codebase admitted any non-empty string; the new
6292    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6293    // URL intersection-floor at validate time, peer with the three pin
6294    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6295    // `is_git_oid`). Every test in this section is a fail-before /
6296    // pass-after pin on a specific authoring footgun.
6297
6298    #[test]
6299    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6300        // The canonical paste-from-doc footgun on `:repo` — an author
6301        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6302        // a doc paragraph. Until this gate landed the empty-repo arm
6303        // passed (the string isn't empty), the resolver issued
6304        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6305        // surfaced at clone time with a quoting-confused error far from
6306        // the source caixa.lisp. Same paste-from-doc footgun the
6307        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6308        // axis — now closed on the `:repo` URL axis too.
6309        let d = dep_with_fonte(DepSource::Git {
6310            repo: "github:pleme-io/caixa-teia ".into(),
6311            tag: Some("v0.1.0".into()),
6312            rev: None,
6313            branch: None,
6314        });
6315        let err = d.validate().unwrap_err();
6316        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6317            panic!("expected FonteRepoShape, got other variant");
6318        };
6319        assert_eq!(nome, "caixa-teia");
6320        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6321        assert!(
6322            reason.contains("whitespace"),
6323            "reason must surface the whitespace arm, got {reason:?}"
6324        );
6325    }
6326
6327    #[test]
6328    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6329        // The canonical CLI-argument-injection footgun at the `git clone`
6330        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6331        // argv parser read the value as a CLI flag, escaping the
6332        // subprocess argument boundary. The `--` separator workaround
6333        // does not fix the typed slot's accepted set; the gate rejects
6334        // the shape upstream at validate time so the resolver never
6335        // invokes a `git clone -…` subprocess.
6336        let d = dep_with_fonte(DepSource::Git {
6337            repo: "-upload-pack=evil".into(),
6338            tag: Some("v0.1.0".into()),
6339            rev: None,
6340            branch: None,
6341        });
6342        let err = d.validate().unwrap_err();
6343        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6344            panic!("expected FonteRepoShape, got other variant");
6345        };
6346        assert_eq!(repo, "-upload-pack=evil");
6347        assert!(
6348            reason.contains("must not start with `-`"),
6349            "reason must surface the leading-`-` arm, got {reason:?}"
6350        );
6351    }
6352
6353    #[test]
6354    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6355        // The canonical paste-from-multiline-doc footgun — a `:repo`
6356        // string with an embedded `\n` silently breaks git's URL parser
6357        // and is a class of CRLF-injection at the subprocess-argument
6358        // boundary. Caught by the control-char arm (0x0A < 0x20).
6359        let d = dep_with_fonte(DepSource::Git {
6360            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6361            tag: Some("v0.1.0".into()),
6362            rev: None,
6363            branch: None,
6364        });
6365        let err = d.validate().unwrap_err();
6366        let DepError::FonteRepoShape { reason, .. } = err else {
6367            panic!("expected FonteRepoShape, got other variant");
6368        };
6369        assert!(
6370            reason.contains("control character"),
6371            "reason must surface the control-char arm, got {reason:?}"
6372        );
6373    }
6374
6375    #[test]
6376    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6377        // Tab is the sibling whitespace footgun (the canonical
6378        // copy-from-aligned-table paste); pinned separately from the
6379        // space arm so a future relaxation that only catches one
6380        // surfaces here.
6381        let d = dep_with_fonte(DepSource::Git {
6382            repo: "github:pleme-io/caixa-teia\t".into(),
6383            tag: Some("v0.1.0".into()),
6384            rev: None,
6385            branch: None,
6386        });
6387        let err = d.validate().unwrap_err();
6388        assert!(
6389            matches!(
6390                err,
6391                DepError::FonteRepoShape { ref reason, .. }
6392                    if reason.contains("whitespace")
6393            ),
6394            "got {err:?}"
6395        );
6396    }
6397
6398    #[test]
6399    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6400        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6401        // non-ASCII silently breaks at git's URL parser and round-trips
6402        // inconsistently across NFC/NFD normalization on APFS /
6403        // case-folding filesystems. Same intersection-floor
6404        // [`is_git_ref_name`] enforces on the refname axes.
6405        let d = dep_with_fonte(DepSource::Git {
6406            repo: "https://github.com/pleme-io/café".into(),
6407            tag: Some("v0.1.0".into()),
6408            rev: None,
6409            branch: None,
6410        });
6411        let err = d.validate().unwrap_err();
6412        assert!(
6413            matches!(
6414                err,
6415                DepError::FonteRepoShape { ref reason, .. }
6416                    if reason.contains("non-ASCII")
6417            ),
6418            "got {err:?}"
6419        );
6420    }
6421
6422    #[test]
6423    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6424        // The fail-before-pass-after pin for the canonical paste-from-
6425        // browser-address-bar footgun on `:repo`: an author copies a
6426        // GitHub permalink to a README anchor / line-permalink and
6427        // forgets to trim the `#fragment` tail. Until this arm landed
6428        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6429        // silently passed every prior arm (no whitespace, no control
6430        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6431        // or `:`), libcurl's URL parser stripped the `#readme` tail
6432        // before opening the HTTPS transport, and the lacre embedded
6433        // the value verbatim in its per-dep BLAKE3 closure — two
6434        // authors whose values differ only in their fragment anchor
6435        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6436        // `git clone` but lock to two distinct lacres, defeating the
6437        // THEORY.md §V.2 render-determinism contract. Same value-shape
6438        // axis-floor every peer typed surface enforces; peer `:fonte
6439        // :tag` / `:fonte :branch` already reject the byte-class through
6440        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6441        // URL grammar admitted) and `:entrada :paths` rejects `#` as
6442        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6443        let d = dep_with_fonte(DepSource::Git {
6444            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6445            tag: Some("v0.1.0".into()),
6446            rev: None,
6447            branch: None,
6448        });
6449        let err = d.validate().unwrap_err();
6450        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6451            panic!("expected FonteRepoShape, got other variant");
6452        };
6453        assert_eq!(nome, "caixa-teia");
6454        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6455        assert!(
6456            reason.contains("must not contain `#`"),
6457            "reason must surface the fragment-`#` arm, got {reason:?}"
6458        );
6459        assert!(
6460            reason.contains("fragment"),
6461            "reason must name the URL fragment grammar, got {reason:?}"
6462        );
6463    }
6464
6465    #[test]
6466    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6467        // The symmetric paste-from-Nix-flake-ref footgun — an author
6468        // confuses the Nix flake-reference idiom (`github:foo/
6469        // bar#packageName`, where `#packageName` selects a flake
6470        // output) with the bare git `:repo` shape. The pleme-io
6471        // substrate authors compose flakes downstream of caixa
6472        // (caixa-flake renders a flake.nix), so the cross-idiom leak
6473        // is the canonical near-miss: the author writes the
6474        // flake-ref shape into a git `:repo` slot. Pinned separately
6475        // from the HTTPS-anchor arm so a future relaxation that
6476        // narrows to one URL scheme surfaces here.
6477        let d = dep_with_fonte(DepSource::Git {
6478            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6479            tag: Some("v0.1.0".into()),
6480            rev: None,
6481            branch: None,
6482        });
6483        let err = d.validate().unwrap_err();
6484        let DepError::FonteRepoShape { reason, .. } = err else {
6485            panic!("expected FonteRepoShape, got other variant");
6486        };
6487        assert!(
6488            reason.contains("must not contain `#`"),
6489            "reason must surface the fragment-`#` arm, got {reason:?}"
6490        );
6491        assert!(
6492            reason.contains("Nix flake"),
6493            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6494        );
6495    }
6496
6497    #[test]
6498    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6499        // The fail-before-pass-after pin for the canonical paste-from-
6500        // browser-address-bar footgun on `:repo` (peer with the
6501        // a68f818 fragment-`#` arm on the same axis). An author
6502        // copies a GitHub tab deep-link out of the address bar and
6503        // forgets to trim the `?tab=…` query tail. Until this arm
6504        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6505        // silently passed every prior arm (no whitespace, no control
6506        // chars, no non-ASCII, no `#` fragment, contains a `:`,
6507        // doesn't start with `-` or `:`); GitHub silently ignored
6508        // the `?query` tail and served the same repo regardless;
6509        // the lacre embedded the value verbatim in its per-dep
6510        // BLAKE3 closure — two authors whose values differ only in
6511        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6512        // `?utm_source=twitter`) resolve to the byte-identical
6513        // upstream `git clone` but lock to two distinct lacres,
6514        // defeating the THEORY.md §V.2 render-determinism contract
6515        // on the same axis the `#` fragment arm closes. Same value-
6516        // shape axis-floor every peer typed surface enforces; peer
6517        // `:fonte :tag` / `:fonte :branch` already reject the byte-
6518        // class through `is_git_ref_name`'s alphabet (refspec glob
6519        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6520        // :paths` rejects `?` as the query separator in
6521        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6522        let d = dep_with_fonte(DepSource::Git {
6523            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6524            tag: Some("v0.1.0".into()),
6525            rev: None,
6526            branch: None,
6527        });
6528        let err = d.validate().unwrap_err();
6529        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6530            panic!("expected FonteRepoShape, got other variant");
6531        };
6532        assert_eq!(nome, "caixa-teia");
6533        assert_eq!(
6534            repo,
6535            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6536        );
6537        assert!(
6538            reason.contains("must not contain `?`"),
6539            "reason must surface the query-`?` arm, got {reason:?}"
6540        );
6541        assert!(
6542            reason.contains("query"),
6543            "reason must name the URL query grammar, got {reason:?}"
6544        );
6545    }
6546
6547    #[test]
6548    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6549        // The symmetric paste-from-social-share footgun — an author
6550        // copies a repo URL out of a Slack unfurl / Twitter share /
6551        // newsletter link / Discord embed and forgets to trim the
6552        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6553        // campaign-tracker tail. Every major social-share / unfurl /
6554        // newsletter platform appends these UTM parameters; the
6555        // canonical near-miss on the `:repo` axis. Pinned separately
6556        // from the GitHub-tab-deep-link arm so a future relaxation
6557        // that narrows to one query-parameter class surfaces here.
6558        let d = dep_with_fonte(DepSource::Git {
6559            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6560                .into(),
6561            tag: Some("v0.1.0".into()),
6562            rev: None,
6563            branch: None,
6564        });
6565        let err = d.validate().unwrap_err();
6566        let DepError::FonteRepoShape { reason, .. } = err else {
6567            panic!("expected FonteRepoShape, got other variant");
6568        };
6569        assert!(
6570            reason.contains("must not contain `?`"),
6571            "reason must surface the query-`?` arm, got {reason:?}"
6572        );
6573        assert!(
6574            reason.contains("campaign-tracker"),
6575            "reason must name the campaign-tracker paste footgun, got {reason:?}"
6576        );
6577    }
6578
6579    #[test]
6580    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6581        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6582        // both per-byte arms inside the same `for &b in s.as_bytes()`
6583        // loop, so the byte that appears first in the value's byte
6584        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6585        // (fragment before query — unusual URL-grammar but value-
6586        // disjoint at byte level) carries both `#` and `?`; the `#`
6587        // byte appears first, so the fragment-`#` arm fires, surfacing
6588        // the more self-locating diagnostic on the byte the author
6589        // pasted earliest in the URL. Mirrors the peer cascade
6590        // discipline `fonte_repo_control_char_fires_before_fragment`
6591        // pins on the prior `:repo` byte-class arm.
6592        let d = dep_with_fonte(DepSource::Git {
6593            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6594            tag: Some("v0.1.0".into()),
6595            rev: None,
6596            branch: None,
6597        });
6598        let err = d.validate().unwrap_err();
6599        let DepError::FonteRepoShape { reason, .. } = err else {
6600            panic!("expected FonteRepoShape, got other variant");
6601        };
6602        assert!(
6603            reason.contains("must not contain `#`"),
6604            "reason must surface the fragment-`#` arm (fires before query-`?` when \
6605             `#` byte appears first in value), got {reason:?}"
6606        );
6607    }
6608
6609    #[test]
6610    fn fonte_repo_control_char_fires_before_fragment() {
6611        // Cascade pin: the control-char arm structurally precedes the
6612        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6613        // positive on both arms (contains LF and `#`), but the narrower
6614        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6615        // (`control character`) wins so the author sees the more
6616        // self-locating arm first. Mirrors the peer cascade discipline
6617        // every prior `:repo` byte-class arm establishes.
6618        let d = dep_with_fonte(DepSource::Git {
6619            repo: "github:pleme-io/caixa-teia\n#readme".into(),
6620            tag: Some("v0.1.0".into()),
6621            rev: None,
6622            branch: None,
6623        });
6624        let err = d.validate().unwrap_err();
6625        let DepError::FonteRepoShape { reason, .. } = err else {
6626            panic!("expected FonteRepoShape, got other variant");
6627        };
6628        assert!(
6629            reason.contains("control character"),
6630            "reason must surface the control-char arm, got {reason:?}"
6631        );
6632    }
6633
6634    #[test]
6635    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6636        // The fail-before-pass-after pin for the canonical Windows-
6637        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6638        // backslash arm on the sibling `:caminho` path-fonte axis).
6639        // An author pastes a Windows Explorer address-bar / PowerShell
6640        // `Get-Location` output into a `file://` URL slot, producing
6641        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6642        // value silently passed every prior arm (no whitespace, no
6643        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6644        // with `-` or `:`); libcurl's URL parser silently translates
6645        // `\` → `/` on some platforms and refuses it on others, so
6646        // the byte rides verbatim into the lacre's per-dep content-
6647        // address but is silently rewritten / rejected at the wire —
6648        // two authors whose `:repo` values differ only in backslash-
6649        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6650        // resolve to the byte-identical local clone but lock to two
6651        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6652        // render-determinism contract on the same axis the `#`
6653        // fragment and `?` query arms close. Same value-shape axis-
6654        // floor every peer typed surface enforces; the `:caminho`
6655        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6656        let d = dep_with_fonte(DepSource::Git {
6657            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6658            tag: Some("v0.1.0".into()),
6659            rev: None,
6660            branch: None,
6661        });
6662        let err = d.validate().unwrap_err();
6663        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6664            panic!("expected FonteRepoShape, got other variant");
6665        };
6666        assert_eq!(nome, "caixa-teia");
6667        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6668        assert!(
6669            reason.contains("must not contain `\\`"),
6670            "reason must surface the backslash-`\\` arm, got {reason:?}"
6671        );
6672        assert!(
6673            reason.contains("Windows"),
6674            "reason must name the Windows-path-confusion footgun, got {reason:?}"
6675        );
6676    }
6677
6678    #[test]
6679    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6680        // The symmetric Win32-shell-mangled-slashes footgun — an author
6681        // copies `https://github.com/foo/bar` into a Win32 shell that
6682        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6683        // separator-coercion bug), pastes the result into a `:repo`
6684        // slot, and produces `https:\\github.com\foo\bar`. Pinned
6685        // separately from the `file://` Explorer-paste arm so a future
6686        // relaxation that narrows to one URL scheme surfaces here.
6687        let d = dep_with_fonte(DepSource::Git {
6688            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6689            tag: Some("v0.1.0".into()),
6690            rev: None,
6691            branch: None,
6692        });
6693        let err = d.validate().unwrap_err();
6694        let DepError::FonteRepoShape { reason, .. } = err else {
6695            panic!("expected FonteRepoShape, got other variant");
6696        };
6697        assert!(
6698            reason.contains("must not contain `\\`"),
6699            "reason must surface the backslash-`\\` arm, got {reason:?}"
6700        );
6701        assert!(
6702            reason.contains("path separator") || reason.contains("path-segment separator"),
6703            "reason must name the URL path-segment separator grammar, got {reason:?}"
6704        );
6705    }
6706
6707    #[test]
6708    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6709        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6710        // are both per-byte arms inside the same `for &b in s.as_bytes()`
6711        // loop, so the byte that appears first in the value's byte order
6712        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6713        // both `#` and `\`; the `#` byte appears first, so the fragment-
6714        // `#` arm fires, surfacing the more self-locating diagnostic on
6715        // the byte the author pasted earliest in the URL. Mirrors the
6716        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6717        // pins on the prior `:repo` byte-class arm.
6718        let d = dep_with_fonte(DepSource::Git {
6719            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6720            tag: Some("v0.1.0".into()),
6721            rev: None,
6722            branch: None,
6723        });
6724        let err = d.validate().unwrap_err();
6725        let DepError::FonteRepoShape { reason, .. } = err else {
6726            panic!("expected FonteRepoShape, got other variant");
6727        };
6728        assert!(
6729            reason.contains("must not contain `#`"),
6730            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6731             `#` byte appears first in value), got {reason:?}"
6732        );
6733    }
6734
6735    #[test]
6736    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6737        // The fail-before-pass-after pin for the canonical URI Template
6738        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6739        // README quick-start snippet / OpenAPI `servers:` URL / Helm
6740        // chart `home:` template that carries unresolved
6741        // `{org}` / `{repo}` placeholders and pastes the raw template
6742        // into the `:repo` slot, expecting the substrate to resolve the
6743        // placeholder downstream. Until this arm landed the value
6744        // silently passed every prior arm (no whitespace, no control
6745        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6746        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6747        // / `%7D` on the wire, so the byte rides verbatim into the
6748        // lacre's per-dep content-address but round-trips inconsistently
6749        // between the lacre's per-dep content-address and the
6750        // resolver's `git clone <repo>` invocation, defeating the
6751        // THEORY.md §V.2 render-determinism contract on the same axis
6752        // the `#` fragment, `?` query, and `\` backslash arms close;
6753        // every git porcelain entry-point additionally fetches a
6754        // nonexistent literal-`{placeholder}`-named path far from the
6755        // source caixa.lisp.
6756        let d = dep_with_fonte(DepSource::Git {
6757            repo: "https://github.com/{org}/caixa-teia".into(),
6758            tag: Some("v0.1.0".into()),
6759            rev: None,
6760            branch: None,
6761        });
6762        let err = d.validate().unwrap_err();
6763        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6764            panic!("expected FonteRepoShape, got other variant");
6765        };
6766        assert_eq!(nome, "caixa-teia");
6767        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6768        assert!(
6769            reason.contains("must not contain `{`"),
6770            "reason must surface the open-brace `{{` arm, got {reason:?}"
6771        );
6772        assert!(
6773            reason.contains("URI Template") || reason.contains("RFC 6570"),
6774            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6775        );
6776    }
6777
6778    #[test]
6779    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6780        // The symmetric Mustache / Handlebars doubled-brace
6781        // substitution-form footgun every CI / IaC templating engine
6782        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6783        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6784        // chart README quick-start snippet emits. Pinned separately
6785        // from the single-`{` `{org}` arm so a future relaxation that
6786        // narrows to one substitution-form surfaces here.
6787        let d = dep_with_fonte(DepSource::Git {
6788            repo: "https://github.com/{{org}}/caixa-teia".into(),
6789            tag: Some("v0.1.0".into()),
6790            rev: None,
6791            branch: None,
6792        });
6793        let err = d.validate().unwrap_err();
6794        let DepError::FonteRepoShape { reason, .. } = err else {
6795            panic!("expected FonteRepoShape, got other variant");
6796        };
6797        assert!(
6798            reason.contains("must not contain `{`"),
6799            "reason must surface the open-brace `{{` arm, got {reason:?}"
6800        );
6801    }
6802
6803    #[test]
6804    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6805        // Asymmetric `}`-only shape — covers the closing-brace-by-
6806        // itself footgun (an author truncated `{org}/{repo}` mid-edit
6807        // and left a trailing `}` from the prior template fragment,
6808        // or pasted a value that included a closing brace from a
6809        // surrounding shell context). Pinned to ensure the predicate
6810        // refuses each brace independently rather than only when both
6811        // appear — a future regression that ANDs the two byte tests
6812        // surfaces here.
6813        let d = dep_with_fonte(DepSource::Git {
6814            repo: "https://github.com/pleme-io/caixa-teia}".into(),
6815            tag: Some("v0.1.0".into()),
6816            rev: None,
6817            branch: None,
6818        });
6819        let err = d.validate().unwrap_err();
6820        let DepError::FonteRepoShape { reason, .. } = err else {
6821            panic!("expected FonteRepoShape, got other variant");
6822        };
6823        assert!(
6824            reason.contains("must not contain `}`"),
6825            "reason must surface the close-brace `}}` arm, got {reason:?}"
6826        );
6827    }
6828
6829    #[test]
6830    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6831        // Cascade pin: the fragment-`#` arm and the template-`{` /
6832        // `}` arm are both per-byte arms inside the same
6833        // `for &b in s.as_bytes()` loop, so the byte that appears
6834        // first in the value's byte order wins. A `:repo
6835        // "https://github.com/p/x#readme{org}"` carries both `#` and
6836        // `{`; the `#` byte appears first, so the fragment-`#` arm
6837        // fires, surfacing the more self-locating diagnostic on the
6838        // byte the author pasted earliest in the URL. Mirrors the
6839        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6840        // pins on the prior `:repo` byte-class arm.
6841        let d = dep_with_fonte(DepSource::Git {
6842            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6843            tag: Some("v0.1.0".into()),
6844            rev: None,
6845            branch: None,
6846        });
6847        let err = d.validate().unwrap_err();
6848        let DepError::FonteRepoShape { reason, .. } = err else {
6849            panic!("expected FonteRepoShape, got other variant");
6850        };
6851        assert!(
6852            reason.contains("must not contain `#`"),
6853            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6854             `#` byte appears first in value), got {reason:?}"
6855        );
6856    }
6857
6858    #[test]
6859    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6860        // The fail-before-pass-after pin for the canonical
6861        // shell-output-redirection footgun on `:repo`: an author
6862        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6863        // / `… >output.txt`) into the `:repo` slot without trimming
6864        // the redirect. Until this arm landed the value silently
6865        // passed every prior arm (no whitespace, no control chars,
6866        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6867        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6868        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6869        // percent-encode set maps `>` → `%3E` on the wire, so the
6870        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6871        // but is silently rewritten or rejected at libcurl's URL-
6872        // parser layer — two authors whose values differ only in
6873        // their redirect tail (`>build.log` vs nothing) resolve to
6874        // the byte-identical upstream `git clone` but lock to two
6875        // distinct lacres, defeating the THEORY.md §V.2 render-
6876        // determinism contract. Peer with the `:caminho` axis's
6877        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6878        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6879        // byte RFC-3986-reserved set on `:entrada :paths`.
6880        let d = dep_with_fonte(DepSource::Git {
6881            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6882            tag: Some("v0.1.0".into()),
6883            rev: None,
6884            branch: None,
6885        });
6886        let err = d.validate().unwrap_err();
6887        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6888            panic!("expected FonteRepoShape, got other variant");
6889        };
6890        assert_eq!(nome, "caixa-teia");
6891        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6892        assert!(
6893            reason.contains("must not contain `>`"),
6894            "reason must surface the output-redirection `>` arm, got {reason:?}"
6895        );
6896        assert!(
6897            reason.contains("redirection") || reason.contains("'delims'"),
6898            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6899        );
6900    }
6901
6902    #[test]
6903    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6904        // The symmetric shell-input-redirection footgun — an author
6905        // pastes a shell-pipeline head (`git clone <input.url` /
6906        // `cat <README.md`) into the `:repo` slot. Pinned separately
6907        // from the `>`-output arm so a future relaxation that only
6908        // catches one of the two redirect bytes surfaces here. Peer
6909        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6910        // arm which closes both `<` and `>` under the same banner.
6911        let d = dep_with_fonte(DepSource::Git {
6912            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6913            tag: Some("v0.1.0".into()),
6914            rev: None,
6915            branch: None,
6916        });
6917        let err = d.validate().unwrap_err();
6918        let DepError::FonteRepoShape { reason, .. } = err else {
6919            panic!("expected FonteRepoShape, got other variant");
6920        };
6921        assert!(
6922            reason.contains("must not contain `<`"),
6923            "reason must surface the input-redirection `<` arm, got {reason:?}"
6924        );
6925        assert!(
6926            reason.contains("RFC 3986") || reason.contains("'unwise'"),
6927            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6928        );
6929    }
6930
6931    #[test]
6932    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6933        // The fail-before-pass-after pin for the canonical
6934        // paste-from-shell-prompt-with-backticked-substitution footgun
6935        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6936        // `:caminho` path-fonte axis). An author pastes a URL whose
6937        // segment carries a backticked command-substitution wrapper
6938        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6939        // from a doc / README quick-start snippet that expected the
6940        // substrate to substitute the value downstream. Until this arm
6941        // landed the value silently passed every prior arm (no
6942        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6943        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6944        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6945        // 'unwise' set and the WHATWG URL spec's fragment percent-
6946        // encode set maps `` ` `` → `%60` on the wire, so the byte
6947        // rides verbatim into the lacre's per-dep BLAKE3 closure but
6948        // is silently rewritten or rejected at libcurl's URL-parser
6949        // layer — two authors whose values differ only in their
6950        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6951        // byte-identical upstream `git clone` but lock to two distinct
6952        // lacres, defeating the THEORY.md §V.2 render-determinism
6953        // contract. Peer with the `:caminho` axis's
6954        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6955        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6956        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6957        let d = dep_with_fonte(DepSource::Git {
6958            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6959            tag: Some("v0.1.0".into()),
6960            rev: None,
6961            branch: None,
6962        });
6963        let err = d.validate().unwrap_err();
6964        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6965            panic!("expected FonteRepoShape, got other variant");
6966        };
6967        assert_eq!(nome, "caixa-teia");
6968        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6969        assert!(
6970            reason.contains("must not contain `` ` ``"),
6971            "reason must surface the backtick command-substitution arm, got {reason:?}"
6972        );
6973        assert!(
6974            reason.contains("command-substitution") || reason.contains("'unwise'"),
6975            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6976             got {reason:?}"
6977        );
6978    }
6979
6980    #[test]
6981    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6982        // Cascade pin: the fragment-`#` arm and the backtick command-
6983        // substitution arm are both per-byte arms inside the same
6984        // `for &b in s.as_bytes()` loop, so the byte that appears first
6985        // in the value's byte order wins. A `:repo
6986        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6987        // and backtick; the `#` byte appears first, so the fragment-
6988        // `#` arm fires, surfacing the more self-locating diagnostic
6989        // on the byte the author pasted earliest in the URL. Mirrors
6990        // the peer cascade discipline
6991        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6992        // pins on the prior `:repo` byte-class arm.
6993        let d = dep_with_fonte(DepSource::Git {
6994            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6995            tag: Some("v0.1.0".into()),
6996            rev: None,
6997            branch: None,
6998        });
6999        let err = d.validate().unwrap_err();
7000        let DepError::FonteRepoShape { reason, .. } = err else {
7001            panic!("expected FonteRepoShape, got other variant");
7002        };
7003        assert!(
7004            reason.contains("must not contain `#`"),
7005            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7006             appears first in value), got {reason:?}"
7007        );
7008    }
7009
7010    #[test]
7011    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7012        // Cascade pin: the shell-redirection `<` / `>` arm and the
7013        // backtick command-substitution arm are both per-byte arms
7014        // inside the same `for &b in s.as_bytes()` loop, so the byte
7015        // that appears first in the value's byte order wins. A `:repo
7016        // "https://github.com/p/x>build.log/`whoami`"` carries both
7017        // `>` and backtick; the `>` byte appears first, so the
7018        // shell-redirection arm fires, surfacing the more self-
7019        // locating diagnostic on the byte the author pasted earliest
7020        // in the URL. Pins the natural-order cascade so a future
7021        // reorder of the per-byte arms surfaces here.
7022        let d = dep_with_fonte(DepSource::Git {
7023            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7024            tag: Some("v0.1.0".into()),
7025            rev: None,
7026            branch: None,
7027        });
7028        let err = d.validate().unwrap_err();
7029        let DepError::FonteRepoShape { reason, .. } = err else {
7030            panic!("expected FonteRepoShape, got other variant");
7031        };
7032        assert!(
7033            reason.contains("must not contain `>`"),
7034            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7035             `>` byte appears first in value), got {reason:?}"
7036        );
7037    }
7038
7039    #[test]
7040    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7041        // Cascade pin: the fragment-`#` arm and the shell-redirection
7042        // `<` / `>` arm are both per-byte arms inside the same
7043        // `for &b in s.as_bytes()` loop, so the byte that appears
7044        // first in the value's byte order wins. A `:repo
7045        // "https://github.com/p/x#readme>build.log"` carries both
7046        // `#` and `>`; the `#` byte appears first, so the fragment-
7047        // `#` arm fires, surfacing the more self-locating diagnostic
7048        // on the byte the author pasted earliest in the URL. Mirrors
7049        // the peer cascade discipline
7050        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7051        // pins on the prior `:repo` byte-class arm.
7052        let d = dep_with_fonte(DepSource::Git {
7053            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7054            tag: Some("v0.1.0".into()),
7055            rev: None,
7056            branch: None,
7057        });
7058        let err = d.validate().unwrap_err();
7059        let DepError::FonteRepoShape { reason, .. } = err else {
7060            panic!("expected FonteRepoShape, got other variant");
7061        };
7062        assert!(
7063            reason.contains("must not contain `#`"),
7064            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7065             `#` byte appears first in value), got {reason:?}"
7066        );
7067    }
7068
7069    #[test]
7070    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7071        // The fail-before-pass-after pin for the canonical
7072        // paste-from-shell-prompt-with-piped-pipeline footgun on
7073        // `:repo` (peer with the 124106f pipe arm on the sibling
7074        // `:caminho` path-fonte axis). An author pastes a shell
7075        // pipeline (`git clone <url> | tee build.log`,
7076        // `git ls-remote <url> | head`) into the `:repo` slot,
7077        // forgetting to trim the `| <consumer>` tail. Until this arm
7078        // landed the value silently passed every prior arm (no
7079        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7080        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7081        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7082        // 'unwise' set and the WHATWG URL spec's fragment percent-
7083        // encode set maps `|` → `%7C` on the wire, so the byte rides
7084        // verbatim into the lacre's per-dep BLAKE3 closure but is
7085        // silently rewritten or rejected at libcurl's URL-parser
7086        // layer — two authors whose values differ only in their pipe
7087        // tail (`|tee build.log` vs nothing) resolve to the byte-
7088        // identical upstream `git clone` but lock to two distinct
7089        // lacres, defeating the THEORY.md §V.2 render-determinism
7090        // contract. Peer with the `:caminho` axis's
7091        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7092        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7093        // RFC-3986-reserved set on `:entrada :paths`.
7094        let d = dep_with_fonte(DepSource::Git {
7095            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7096            tag: Some("v0.1.0".into()),
7097            rev: None,
7098            branch: None,
7099        });
7100        let err = d.validate().unwrap_err();
7101        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7102            panic!("expected FonteRepoShape, got other variant");
7103        };
7104        assert_eq!(nome, "caixa-teia");
7105        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7106        assert!(
7107            reason.contains("must not contain `|`"),
7108            "reason must surface the shell-pipe arm, got {reason:?}"
7109        );
7110        assert!(
7111            reason.contains("pipe") || reason.contains("'unwise'"),
7112            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7113        );
7114    }
7115
7116    #[test]
7117    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7118        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7119        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7120        // so the byte that appears first in the value's byte order
7121        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7122        // both `#` and `|`; the `#` byte appears first, so the
7123        // fragment-`#` arm fires, surfacing the more self-locating
7124        // diagnostic on the byte the author pasted earliest in the
7125        // URL. Mirrors the peer cascade discipline
7126        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7127        // pins on the prior `:repo` byte-class arm.
7128        let d = dep_with_fonte(DepSource::Git {
7129            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7130            tag: Some("v0.1.0".into()),
7131            rev: None,
7132            branch: None,
7133        });
7134        let err = d.validate().unwrap_err();
7135        let DepError::FonteRepoShape { reason, .. } = err else {
7136            panic!("expected FonteRepoShape, got other variant");
7137        };
7138        assert!(
7139            reason.contains("must not contain `#`"),
7140            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7141             appears first in value), got {reason:?}"
7142        );
7143    }
7144
7145    #[test]
7146    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7147        // Cascade pin: the backtick arm and the pipe arm are both per-
7148        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7149        // the byte that appears first in the value's byte order wins.
7150        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7151        // `` ` `` and `|`; the backtick byte appears first, so the
7152        // backtick arm fires, surfacing the more self-locating
7153        // diagnostic on the byte the author pasted earliest in the
7154        // URL. Pins the natural-order cascade so a future reorder of
7155        // the per-byte arms surfaces here.
7156        let d = dep_with_fonte(DepSource::Git {
7157            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7158            tag: Some("v0.1.0".into()),
7159            rev: None,
7160            branch: None,
7161        });
7162        let err = d.validate().unwrap_err();
7163        let DepError::FonteRepoShape { reason, .. } = err else {
7164            panic!("expected FonteRepoShape, got other variant");
7165        };
7166        assert!(
7167            reason.contains("must not contain `` ` ``"),
7168            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7169             appears first in value), got {reason:?}"
7170        );
7171    }
7172
7173    #[test]
7174    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7175        // The fail-before-pass-after pin for the canonical
7176        // paste-from-shell-prompt-with-sequential-command-tail footgun
7177        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7178        // `:caminho` path-fonte axis). An author pastes a shell
7179        // one-liner that chained a cleanup tail after the URL
7180        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7181        // echo done`) into the `:repo` slot, forgetting to trim the
7182        // `; <cmd>` tail. Until this arm landed the value silently
7183        // passed every prior `is_git_repo_url` arm (no whitespace, no
7184        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7185        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7186        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7187        // reserved set and the WHATWG URL spec's fragment percent-
7188        // encode set maps `;` → `%3B` on the wire, so the byte rides
7189        // verbatim into the lacre's per-dep BLAKE3 closure but is
7190        // silently rewritten at libcurl's URL-parser layer — two
7191        // authors whose values differ only in their sequential-command
7192        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7193        // identical upstream `git clone` but lock to two distinct
7194        // lacres, defeating the THEORY.md §V.2 render-determinism
7195        // contract. Peer with the `:caminho` axis's
7196        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7197        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7198        // byte RFC-3986-reserved set on `:entrada :paths`.
7199        let d = dep_with_fonte(DepSource::Git {
7200            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7201            tag: Some("v0.1.0".into()),
7202            rev: None,
7203            branch: None,
7204        });
7205        let err = d.validate().unwrap_err();
7206        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7207            panic!("expected FonteRepoShape, got other variant");
7208        };
7209        assert_eq!(nome, "caixa-teia");
7210        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7211        assert!(
7212            reason.contains("must not contain `;`"),
7213            "reason must surface the shell-command-separator arm, got {reason:?}"
7214        );
7215        assert!(
7216            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7217            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7218             rationale, got {reason:?}"
7219        );
7220    }
7221
7222    #[test]
7223    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7224        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7225        // both per-byte arms inside the same `for &b in s.as_bytes()`
7226        // loop, so the byte that appears first in the value's byte
7227        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7228        // carries both `#` and `;`; the `#` byte appears first, so the
7229        // fragment-`#` arm fires, surfacing the more self-locating
7230        // diagnostic on the byte the author pasted earliest in the URL.
7231        // Mirrors the peer cascade discipline
7232        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7233        // pins on the prior `:repo` byte-class arm.
7234        let d = dep_with_fonte(DepSource::Git {
7235            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7236            tag: Some("v0.1.0".into()),
7237            rev: None,
7238            branch: None,
7239        });
7240        let err = d.validate().unwrap_err();
7241        let DepError::FonteRepoShape { reason, .. } = err else {
7242            panic!("expected FonteRepoShape, got other variant");
7243        };
7244        assert!(
7245            reason.contains("must not contain `#`"),
7246            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7247             byte appears first in value), got {reason:?}"
7248        );
7249    }
7250
7251    #[test]
7252    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7253        // Cascade pin: the pipe arm and the semicolon arm are both
7254        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7255        // so the byte that appears first in the value's byte order
7256        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7257        // both `|` and `;`; the `|` byte appears first, so the
7258        // pipe arm fires, surfacing the more self-locating diagnostic
7259        // on the byte the author pasted earliest in the URL. Pins the
7260        // natural-order cascade so a future reorder of the per-byte
7261        // arms surfaces here.
7262        let d = dep_with_fonte(DepSource::Git {
7263            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7264            tag: Some("v0.1.0".into()),
7265            rev: None,
7266            branch: None,
7267        });
7268        let err = d.validate().unwrap_err();
7269        let DepError::FonteRepoShape { reason, .. } = err else {
7270            panic!("expected FonteRepoShape, got other variant");
7271        };
7272        assert!(
7273            reason.contains("must not contain `|`"),
7274            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7275             appears first in value), got {reason:?}"
7276        );
7277    }
7278
7279    #[test]
7280    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7281        // The fail-before-pass-after pin for the canonical
7282        // paste-from-shell-prompt-with-background-launch-tail footgun
7283        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7284        // `:caminho` path-fonte axis). An author pastes a shell one-
7285        // liner that detached the clone into the background
7286        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7287        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7288        // `&& <cmd>` tail. Until this arm landed the value silently
7289        // passed every prior `is_git_repo_url` arm (no whitespace,
7290        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7291        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7292        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7293        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7294        // fragment percent-encode set maps `&` → `%26` on the wire,
7295        // so the byte rides verbatim into the lacre's per-dep
7296        // BLAKE3 closure but is silently rewritten at libcurl's
7297        // URL-parser layer — two authors whose values differ only
7298        // in their background-launch tail (`& sleep 1` vs nothing)
7299        // resolve to the byte-identical upstream `git clone` but
7300        // lock to two distinct lacres, defeating the THEORY.md
7301        // §V.2 render-determinism contract. Peer with the
7302        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7303        // (e12e4f3) on the sibling path-fonte axis, and
7304        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7305        // reserved set on `:entrada :paths`.
7306        let d = dep_with_fonte(DepSource::Git {
7307            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7308            tag: Some("v0.1.0".into()),
7309            rev: None,
7310            branch: None,
7311        });
7312        let err = d.validate().unwrap_err();
7313        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7314            panic!("expected FonteRepoShape, got other variant");
7315        };
7316        assert_eq!(nome, "caixa-teia");
7317        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7318        assert!(
7319            reason.contains("must not contain `&`"),
7320            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7321        );
7322        assert!(
7323            reason.contains("background-task") || reason.contains("'sub-delims'"),
7324            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7325             got {reason:?}"
7326        );
7327    }
7328
7329    #[test]
7330    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7331        // The fail-before-pass-after pin for the symmetric `&&`
7332        // logical-AND build-chain paste footgun: an author pastes
7333        // a `git clone <url> && cd <repo>` build-chain one-liner
7334        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7335        // is the same `&` byte twice in a row; the per-byte arm
7336        // fires on the first `&` it sees. Pinned separately from
7337        // the single-`&` background-launch shape so a future
7338        // diagnostic-surface change that special-cased the
7339        // doubled-byte form surfaces here.
7340        let d = dep_with_fonte(DepSource::Git {
7341            repo: "github:pleme-io/caixa-teia&&echo".into(),
7342            tag: Some("v0.1.0".into()),
7343            rev: None,
7344            branch: None,
7345        });
7346        let err = d.validate().unwrap_err();
7347        let DepError::FonteRepoShape { reason, .. } = err else {
7348            panic!("expected FonteRepoShape, got other variant");
7349        };
7350        assert!(
7351            reason.contains("must not contain `&`"),
7352            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7353             shape too, got {reason:?}"
7354        );
7355    }
7356
7357    #[test]
7358    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7359        // Cascade pin: the fragment-`#` arm and the background-`&`
7360        // arm are both per-byte arms inside the same `for &b in
7361        // s.as_bytes()` loop, so the byte that appears first in the
7362        // value's byte order wins. A `:repo
7363        // "https://github.com/p/x#readme & sleep"` carries both `#`
7364        // and `&`; the `#` byte appears first, so the fragment-`#`
7365        // arm fires, surfacing the more self-locating diagnostic on
7366        // the byte the author pasted earliest in the URL. Mirrors
7367        // the peer cascade discipline
7368        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7369        // on the prior `:repo` byte-class arm.
7370        let d = dep_with_fonte(DepSource::Git {
7371            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7372            tag: Some("v0.1.0".into()),
7373            rev: None,
7374            branch: None,
7375        });
7376        let err = d.validate().unwrap_err();
7377        let DepError::FonteRepoShape { reason, .. } = err else {
7378            panic!("expected FonteRepoShape, got other variant");
7379        };
7380        assert!(
7381            reason.contains("must not contain `#`"),
7382            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7383             byte appears first in value), got {reason:?}"
7384        );
7385    }
7386
7387    #[test]
7388    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7389        // Cascade pin: the semicolon arm and the background-`&` arm
7390        // are both per-byte arms inside the same `for &b in
7391        // s.as_bytes()` loop, so the byte that appears first in the
7392        // value's byte order wins. A `:repo
7393        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7394        // `&`; the `;` byte appears first, so the semicolon arm
7395        // fires, surfacing the more self-locating diagnostic on the
7396        // byte the author pasted earliest in the URL. Pins the
7397        // natural-order cascade so a future reorder of the per-byte
7398        // arms surfaces here.
7399        let d = dep_with_fonte(DepSource::Git {
7400            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".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 semicolon arm (fires before background-`&` when `;` \
7412             byte appears first in value), got {reason:?}"
7413        );
7414    }
7415
7416    #[test]
7417    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7418        // The fail-before-pass-after pin for the canonical
7419        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7420        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7421        // `:caminho` path-fonte axis). An author pastes a shell one-
7422        // liner that referenced an environment variable
7423        // (`git clone https://github.com/$ORG/x`, `git clone
7424        // github:$USER/repo`) into the `:repo` slot, forgetting to
7425        // substitute the literal value at author time. Until this arm
7426        // landed the value silently passed every prior
7427        // `is_git_repo_url` arm (no whitespace, no control chars, no
7428        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7429        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7430        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7431        // reserved set and the WHATWG URL spec's fragment percent-
7432        // encode set maps `$` → `%24` on the wire, so the byte rides
7433        // verbatim into the lacre's per-dep BLAKE3 closure but is
7434        // silently rewritten at libcurl's URL-parser layer — two
7435        // authors whose values differ only in their `$VAR` /
7436        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7437        // identical upstream `git clone` but lock to two distinct
7438        // lacres, defeating the THEORY.md §V.2 render-determinism
7439        // contract. Beyond determinism, the value is a structural
7440        // host-layout leak: two authors with the same `:repo` slot
7441        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7442        // different upstreams. Peer with the `:caminho` axis's
7443        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7444        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7445        // byte RFC-3986-reserved set on `:entrada :paths`.
7446        let d = dep_with_fonte(DepSource::Git {
7447            repo: "https://github.com/$ORG/caixa-teia".into(),
7448            tag: Some("v0.1.0".into()),
7449            rev: None,
7450            branch: None,
7451        });
7452        let err = d.validate().unwrap_err();
7453        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7454            panic!("expected FonteRepoShape, got other variant");
7455        };
7456        assert_eq!(nome, "caixa-teia");
7457        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7458        assert!(
7459            reason.contains("must not contain `$`"),
7460            "reason must surface the shell-variable-expansion arm, got {reason:?}"
7461        );
7462        assert!(
7463            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7464            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7465             rationale, got {reason:?}"
7466        );
7467    }
7468
7469    #[test]
7470    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7471        // The fail-before-pass-after pin for the symmetric POSIX-
7472        // shell braced `${VAR}` expansion paste footgun: an author
7473        // pastes a CI-manifest line `git clone
7474        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7475        // Actions / GitLab CI / Drone shape) and forgets to
7476        // substitute the literal value. The `${...}` shape is the
7477        // same `$` byte at the leading position of the expansion;
7478        // the per-byte arm fires on the `$`. Pinned separately from
7479        // the bare-`$VAR` shape so a future diagnostic-surface
7480        // change that special-cased the braced form surfaces here.
7481        let d = dep_with_fonte(DepSource::Git {
7482            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7483            tag: Some("v0.1.0".into()),
7484            rev: None,
7485            branch: None,
7486        });
7487        let err = d.validate().unwrap_err();
7488        let DepError::FonteRepoShape { reason, .. } = err else {
7489            panic!("expected FonteRepoShape, got other variant");
7490        };
7491        assert!(
7492            reason.contains("must not contain `$`"),
7493            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7494             shape too, got {reason:?}"
7495        );
7496    }
7497
7498    #[test]
7499    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7500        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7501        // arm are both per-byte arms inside the same `for &b in
7502        // s.as_bytes()` loop, so the byte that appears first in the
7503        // value's byte order wins. A `:repo
7504        // "https://github.com/p/x#readme$HOME"` carries both `#` and
7505        // `$`; the `#` byte appears first, so the fragment-`#` arm
7506        // fires, surfacing the more self-locating diagnostic on the
7507        // byte the author pasted earliest in the URL. Mirrors the
7508        // peer cascade discipline
7509        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7510        // on the prior `:repo` byte-class arm.
7511        let d = dep_with_fonte(DepSource::Git {
7512            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7513            tag: Some("v0.1.0".into()),
7514            rev: None,
7515            branch: None,
7516        });
7517        let err = d.validate().unwrap_err();
7518        let DepError::FonteRepoShape { reason, .. } = err else {
7519            panic!("expected FonteRepoShape, got other variant");
7520        };
7521        assert!(
7522            reason.contains("must not contain `#`"),
7523            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7524             `#` byte appears first in value), got {reason:?}"
7525        );
7526    }
7527
7528    #[test]
7529    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7530        // Cascade pin: the background-`&` arm and the
7531        // var-expansion-`$` arm are both per-byte arms inside the
7532        // same `for &b in s.as_bytes()` loop, so the byte that
7533        // appears first in the value's byte order wins. A `:repo
7534        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7535        // `$`; the `&` byte appears first, so the background arm
7536        // fires, surfacing the more self-locating diagnostic on the
7537        // byte the author pasted earliest in the URL. Pins the
7538        // natural-order cascade so a future reorder of the per-byte
7539        // arms surfaces here — `$` is the most recent byte-class arm,
7540        // so the cascade-pin sweep extends to cover every immediately
7541        // prior byte arm (`#`, `&`) firing first when ordered ahead
7542        // of `$` in the value.
7543        let d = dep_with_fonte(DepSource::Git {
7544            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7545            tag: Some("v0.1.0".into()),
7546            rev: None,
7547            branch: None,
7548        });
7549        let err = d.validate().unwrap_err();
7550        let DepError::FonteRepoShape { reason, .. } = err else {
7551            panic!("expected FonteRepoShape, got other variant");
7552        };
7553        assert!(
7554            reason.contains("must not contain `&`"),
7555            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7556             `&` byte appears first in value), got {reason:?}"
7557        );
7558    }
7559
7560    #[test]
7561    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7562        // The fail-before-pass-after pin for the canonical
7563        // paste-from-shell-prompt glob footgun on `:repo` (peer with
7564        // the cf9034b `*` / `?` arm on the sibling `:caminho`
7565        // path-fonte axis). An author pastes a shell one-liner that
7566        // referenced a glob expansion (`ls
7567        // github.com/pleme-io/caixa-*`, `git clone
7568        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7569        // to substitute the literal repo name. Until this arm landed
7570        // the `*` byte silently passed every prior `is_git_repo_url`
7571        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7572        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7573        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7574        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7575        // the WHATWG URL spec's special-query percent-encode set maps
7576        // `*` → `%2A` on the wire, so the byte rides verbatim into
7577        // the lacre's per-dep BLAKE3 closure but is silently
7578        // rewritten at libcurl's URL-parser layer — two authors
7579        // whose values differ only in their asterisk presence
7580        // resolve to the byte-identical upstream `git clone` but
7581        // lock to two distinct lacres, defeating the THEORY.md §V.2
7582        // render-determinism contract. Peer with the `:caminho`
7583        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7584        // sibling path-fonte axis, and the `is_git_ref_name`
7585        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7586        // axes.
7587        let d = dep_with_fonte(DepSource::Git {
7588            repo: "https://github.com/pleme-io/caixa-*".into(),
7589            tag: Some("v0.1.0".into()),
7590            rev: None,
7591            branch: None,
7592        });
7593        let err = d.validate().unwrap_err();
7594        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7595            panic!("expected FonteRepoShape, got other variant");
7596        };
7597        assert_eq!(nome, "caixa-teia");
7598        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7599        assert!(
7600            reason.contains("must not contain `*`"),
7601            "reason must surface the shell-glob arm, got {reason:?}"
7602        );
7603        assert!(
7604            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7605            "reason must name the shell-glob / pathname-expansion / \
7606             RFC-3986-sub-delims rationale, got {reason:?}"
7607        );
7608    }
7609
7610    #[test]
7611    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7612        // The fail-before-pass-after pin for the symmetric bash
7613        // `globstar` recursive-glob paste footgun: an author pastes
7614        // a `ls github.com/pleme-io/**/x` (the canonical
7615        // `globstar`-shopt-enabled recursive-listing tail) into the
7616        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7617        // the per-byte arm fires on the first `*`. Pinned
7618        // separately from the single-`*` shape so a future
7619        // diagnostic-surface change that special-cased the
7620        // double-`*` form surfaces here.
7621        let d = dep_with_fonte(DepSource::Git {
7622            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7623            tag: Some("v0.1.0".into()),
7624            rev: None,
7625            branch: None,
7626        });
7627        let err = d.validate().unwrap_err();
7628        let DepError::FonteRepoShape { reason, .. } = err else {
7629            panic!("expected FonteRepoShape, got other variant");
7630        };
7631        assert!(
7632            reason.contains("must not contain `*`"),
7633            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7634             got {reason:?}"
7635        );
7636    }
7637
7638    #[test]
7639    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7640        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7641        // both per-byte arms inside the same `for &b in s.as_bytes()`
7642        // loop, so the byte that appears first in the value's byte
7643        // order wins. A `:repo
7644        // "https://github.com/p/x#readme*tail"` carries both `#` and
7645        // `*`; the `#` byte appears first, so the fragment-`#` arm
7646        // fires, surfacing the more self-locating diagnostic on the
7647        // byte the author pasted earliest in the URL. Mirrors the
7648        // peer cascade discipline
7649        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7650        // on the prior `:repo` byte-class arm.
7651        let d = dep_with_fonte(DepSource::Git {
7652            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7653            tag: Some("v0.1.0".into()),
7654            rev: None,
7655            branch: None,
7656        });
7657        let err = d.validate().unwrap_err();
7658        let DepError::FonteRepoShape { reason, .. } = err else {
7659            panic!("expected FonteRepoShape, got other variant");
7660        };
7661        assert!(
7662            reason.contains("must not contain `#`"),
7663            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7664             appears first in value), got {reason:?}"
7665        );
7666    }
7667
7668    #[test]
7669    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7670        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7671        // arm are both per-byte arms inside the same `for &b in
7672        // s.as_bytes()` loop, so the byte that appears first in the
7673        // value's byte order wins. A `:repo
7674        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7675        // the `$` byte appears first, so the var-expansion arm
7676        // fires, surfacing the more self-locating diagnostic on the
7677        // byte the author pasted earliest in the URL. Pins the
7678        // natural-order cascade so a future reorder of the per-byte
7679        // arms surfaces here — `*` is the most recent byte-class
7680        // arm, so the cascade-pin sweep extends to cover the
7681        // immediately prior `$` byte arm firing first when ordered
7682        // ahead of `*` in the value.
7683        let d = dep_with_fonte(DepSource::Git {
7684            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7685            tag: Some("v0.1.0".into()),
7686            rev: None,
7687            branch: None,
7688        });
7689        let err = d.validate().unwrap_err();
7690        let DepError::FonteRepoShape { reason, .. } = err else {
7691            panic!("expected FonteRepoShape, got other variant");
7692        };
7693        assert!(
7694            reason.contains("must not contain `$`"),
7695            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7696             byte appears first in value), got {reason:?}"
7697        );
7698    }
7699
7700    #[test]
7701    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7702        // The fail-before-pass-after pin for the canonical paste-from-
7703        // shell-prompt subshell-grouping footgun on `:repo`. An author
7704        // pastes a doc / README snippet carrying a regex-alternation
7705        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7706        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7707        // `:repo` slot, forgetting to substitute one literal org name.
7708        // Until this arm landed the `(` byte silently passed every
7709        // prior `is_git_repo_url` arm (no whitespace, no control
7710        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7711        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7712        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7713        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7714        // URL spec's special-query percent-encode set maps `(` →
7715        // `%28` and `)` → `%29` on the wire, so the byte rides
7716        // verbatim into the lacre's per-dep BLAKE3 closure but is
7717        // silently rewritten at libcurl's URL-parser layer —
7718        // defeating the THEORY.md §V.2 render-determinism contract on
7719        // the same axis the prior twelve byte-class arms close.
7720        let d = dep_with_fonte(DepSource::Git {
7721            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7722            tag: Some("v0.1.0".into()),
7723            rev: None,
7724            branch: None,
7725        });
7726        let err = d.validate().unwrap_err();
7727        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7728            panic!("expected FonteRepoShape, got other variant");
7729        };
7730        assert_eq!(nome, "caixa-teia");
7731        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7732        assert!(
7733            reason.contains("must not contain `(`"),
7734            "reason must surface the subshell-open-paren arm, got {reason:?}"
7735        );
7736        assert!(
7737            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7738            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7739             got {reason:?}"
7740        );
7741    }
7742
7743    #[test]
7744    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7745        // The symmetric arm pin on the closing `)` byte: an author
7746        // pastes a `$(date)` command-substitution wrapper or a
7747        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7748        // Pinned separately from the opening `(` shape so a future
7749        // diagnostic-surface change that only checked one boundary
7750        // surfaces here. The `(` byte appears earlier in the
7751        // canonical regex / subshell wrapper so the per-byte loop
7752        // fires on `(` first; this test exercises a `:repo` value
7753        // carrying only the closing `)` byte (no opening paren) so
7754        // the `)` arm fires directly — pinning the byte-class arm
7755        // independent of order.
7756        let d = dep_with_fonte(DepSource::Git {
7757            repo: "github:pleme-io/caixa-teia)tail".into(),
7758            tag: Some("v0.1.0".into()),
7759            rev: None,
7760            branch: None,
7761        });
7762        let err = d.validate().unwrap_err();
7763        let DepError::FonteRepoShape { reason, .. } = err else {
7764            panic!("expected FonteRepoShape, got other variant");
7765        };
7766        assert!(
7767            reason.contains("must not contain `)`"),
7768            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7769             got {reason:?}"
7770        );
7771    }
7772
7773    #[test]
7774    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7775        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7776        // are both per-byte arms inside the same `for &b in
7777        // s.as_bytes()` loop, so the byte that appears first in the
7778        // value's byte order wins. A `:repo
7779        // "https://github.com/p/x#readme(tail)"` carries both `#` and
7780        // `(`; the `#` byte appears first, so the fragment-`#` arm
7781        // fires, surfacing the more self-locating diagnostic on the
7782        // byte the author pasted earliest in the URL. Mirrors the
7783        // peer cascade discipline
7784        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7785        // on the prior `:repo` byte-class arm.
7786        let d = dep_with_fonte(DepSource::Git {
7787            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7788            tag: Some("v0.1.0".into()),
7789            rev: None,
7790            branch: None,
7791        });
7792        let err = d.validate().unwrap_err();
7793        let DepError::FonteRepoShape { reason, .. } = err else {
7794            panic!("expected FonteRepoShape, got other variant");
7795        };
7796        assert!(
7797            reason.contains("must not contain `#`"),
7798            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7799             byte appears first in value), got {reason:?}"
7800        );
7801    }
7802
7803    #[test]
7804    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7805        // Cascade pin: the glob-`*` arm (the immediate-predecessor
7806        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7807        // per-byte arms inside the same `for &b in s.as_bytes()`
7808        // loop, so the byte that appears first in the value's byte
7809        // order wins. A `:repo
7810        // "https://github.com/p/x-*-(date)"` carries both `*` and
7811        // `(`; the `*` byte appears first, so the glob arm fires,
7812        // surfacing the more self-locating diagnostic on the byte
7813        // the author pasted earliest in the URL. Pins the natural-
7814        // order cascade so a future reorder of the per-byte arms
7815        // surfaces here — `(` is the most recent byte-class arm,
7816        // so the cascade-pin sweep extends to cover the immediately
7817        // prior `*` byte arm firing first when ordered ahead of `(`
7818        // in the value.
7819        let d = dep_with_fonte(DepSource::Git {
7820            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7821            tag: Some("v0.1.0".into()),
7822            rev: None,
7823            branch: None,
7824        });
7825        let err = d.validate().unwrap_err();
7826        let DepError::FonteRepoShape { reason, .. } = err else {
7827            panic!("expected FonteRepoShape, got other variant");
7828        };
7829        assert!(
7830            reason.contains("must not contain `*`"),
7831            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7832             appears first in value), got {reason:?}"
7833        );
7834    }
7835
7836    #[test]
7837    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7838        // The fail-before-pass-after pin for the canonical paste-from-
7839        // doc-shell-quoting footgun on `:repo`. An author copies a
7840        // README quick-start snippet (`$ git clone "https://github.com/
7841        // foo/bar"`) and keeps the surrounding double-quote bytes when
7842        // pasting into the `:repo` slot — the doc wraps the URL in
7843        // double quotes so the shell doesn't re-lex metachars inside,
7844        // but the typed slot is itself a byte-level string parser, not
7845        // a shell context, so the quote bytes ride into the value
7846        // verbatim. Until this arm landed the `"` byte silently passed
7847        // every prior `is_git_repo_url` arm (no whitespace, no control
7848        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7849        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7850        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7851        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7852        // `` ` ``) every URL parser is required to refuse or percent-
7853        // encode, and the WHATWG URL spec's 'C0 control percent-encode
7854        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7855        // into the lacre's per-dep BLAKE3 closure but is silently
7856        // rewritten at libcurl's URL-parser layer, defeating the
7857        // THEORY.md §V.2 render-determinism contract.
7858        let d = dep_with_fonte(DepSource::Git {
7859            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7860            tag: Some("v0.1.0".into()),
7861            rev: None,
7862            branch: None,
7863        });
7864        let err = d.validate().unwrap_err();
7865        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7866            panic!("expected FonteRepoShape, got other variant");
7867        };
7868        assert_eq!(nome, "caixa-teia");
7869        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7870        assert!(
7871            reason.contains("must not contain `\"`"),
7872            "reason must surface the shell-double-quote arm, got {reason:?}"
7873        );
7874        assert!(
7875            reason.contains("double-quote") || reason.contains("'delims'"),
7876            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7877             got {reason:?}"
7878        );
7879    }
7880
7881    #[test]
7882    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7883        // The symmetric stray-quote tail pin: an author pastes only a
7884        // closing `"` from a shell-history line like `git clone
7885        // "https://github.com/foo/bar" && cd …` (the trim went too
7886        // far in one direction but not the other) into the `:repo`
7887        // slot. Pinned separately from the wrapped-quote shape so a
7888        // future diagnostic-surface change that only checked one
7889        // boundary (only leading, only trailing, only paired) surfaces
7890        // here — the per-byte arm fires anywhere `"` appears.
7891        let d = dep_with_fonte(DepSource::Git {
7892            repo: "github:pleme-io/caixa-teia\"".into(),
7893            tag: Some("v0.1.0".into()),
7894            rev: None,
7895            branch: None,
7896        });
7897        let err = d.validate().unwrap_err();
7898        let DepError::FonteRepoShape { reason, .. } = err else {
7899            panic!("expected FonteRepoShape, got other variant");
7900        };
7901        assert!(
7902            reason.contains("must not contain `\"`"),
7903            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7904             got {reason:?}"
7905        );
7906    }
7907
7908    #[test]
7909    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7910        // Cascade pin: the fragment-`#` arm and the double-quote arm
7911        // are both per-byte arms inside the same `for &b in
7912        // s.as_bytes()` loop, so the byte that appears first in the
7913        // value's byte order wins. A `:repo
7914        // "https://github.com/p/x#readme\"tail"` carries both `#` and
7915        // `"`; the `#` byte appears first, so the fragment-`#` arm
7916        // fires, surfacing the more self-locating diagnostic on the
7917        // byte the author pasted earliest in the URL.
7918        let d = dep_with_fonte(DepSource::Git {
7919            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7920            tag: Some("v0.1.0".into()),
7921            rev: None,
7922            branch: None,
7923        });
7924        let err = d.validate().unwrap_err();
7925        let DepError::FonteRepoShape { reason, .. } = err else {
7926            panic!("expected FonteRepoShape, got other variant");
7927        };
7928        assert!(
7929            reason.contains("must not contain `#`"),
7930            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7931             byte appears first in value), got {reason:?}"
7932        );
7933    }
7934
7935    #[test]
7936    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7937        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7938        // byte-class arm, 3b99147) and the double-quote arm are both
7939        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7940        // so the byte that appears first in the value's byte order
7941        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7942        // and `"`; the `(` byte appears first, so the subshell arm
7943        // fires, surfacing the more self-locating diagnostic on the
7944        // byte the author pasted earliest in the URL. Pins the natural-
7945        // order cascade so a future reorder of the per-byte arms
7946        // surfaces here — `"` is the most recent byte-class arm, so
7947        // the cascade-pin sweep extends to cover the immediately prior
7948        // `(` byte arm firing first when ordered ahead of `"` in the
7949        // value.
7950        let d = dep_with_fonte(DepSource::Git {
7951            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7952            tag: Some("v0.1.0".into()),
7953            rev: None,
7954            branch: None,
7955        });
7956        let err = d.validate().unwrap_err();
7957        let DepError::FonteRepoShape { reason, .. } = err else {
7958            panic!("expected FonteRepoShape, got other variant");
7959        };
7960        assert!(
7961            reason.contains("must not contain `(`"),
7962            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7963             byte appears first in value), got {reason:?}"
7964        );
7965    }
7966
7967    #[test]
7968    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7969        // The fail-before-pass-after pin for the canonical paste-from-
7970        // doc-strong-quoting footgun on `:repo`. An author copies a
7971        // security-conscious README quick-start snippet (`$ git clone
7972        // 'https://github.com/foo/bar'`) and keeps the surrounding
7973        // single-quote bytes when pasting into the `:repo` slot — the
7974        // doc strong-quotes the URL so the shell suppresses every form
7975        // of expansion on the bytes inside (no `$`, no backtick, no
7976        // glob, no word-splitting), but the typed slot is itself a
7977        // byte-level string parser, not a shell context, so the quote
7978        // bytes ride into the value verbatim. Until this arm landed the
7979        // `'` byte silently passed every prior `is_git_repo_url` arm
7980        // (no whitespace, no control chars, no non-ASCII, no `#`, no
7981        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7982        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7983        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7984        // set, peer with the `\"` 'delims' double-quote arm and the
7985        // partner ASCII shell-string-delimiter byte every byte-level
7986        // string parser sharing a value-shape with a shell argument
7987        // must refuse on a URL-shaped slot.
7988        let d = dep_with_fonte(DepSource::Git {
7989            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7990            tag: Some("v0.1.0".into()),
7991            rev: None,
7992            branch: None,
7993        });
7994        let err = d.validate().unwrap_err();
7995        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7996            panic!("expected FonteRepoShape, got other variant");
7997        };
7998        assert_eq!(nome, "caixa-teia");
7999        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8000        assert!(
8001            reason.contains("must not contain `'`"),
8002            "reason must surface the shell-single-quote arm, got {reason:?}"
8003        );
8004        assert!(
8005            reason.contains("single-quote") || reason.contains("strong-quote"),
8006            "reason must name the shell-single-quote / strong-quote rationale, \
8007             got {reason:?}"
8008        );
8009    }
8010
8011    #[test]
8012    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8013        // The symmetric English-typography pin: an author writes
8014        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8015        // from-prose idiom every README / commit-message / chat-thread
8016        // reference to a repo carries) expecting the substrate to
8017        // coerce it to a kebab-case slug — but the byte rides into the
8018        // lacre verbatim. Pinned separately from the wrapped-quote
8019        // shape so a future diagnostic-surface change that only checked
8020        // the boundary positions (only leading, only trailing, only
8021        // paired) surfaces here — the per-byte arm fires anywhere `'`
8022        // appears in the value.
8023        let d = dep_with_fonte(DepSource::Git {
8024            repo: "github:pleme-io/repo's-fork".into(),
8025            tag: Some("v0.1.0".into()),
8026            rev: None,
8027            branch: None,
8028        });
8029        let err = d.validate().unwrap_err();
8030        let DepError::FonteRepoShape { reason, .. } = err else {
8031            panic!("expected FonteRepoShape, got other variant");
8032        };
8033        assert!(
8034            reason.contains("must not contain `'`"),
8035            "reason must surface the shell-single-quote arm on the mid-string \
8036             apostrophe shape, got {reason:?}"
8037        );
8038    }
8039
8040    #[test]
8041    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8042        // Cascade pin: the fragment-`#` arm and the single-quote arm
8043        // are both per-byte arms inside the same `for &b in
8044        // s.as_bytes()` loop, so the byte that appears first in the
8045        // value's byte order wins. A `:repo
8046        // "https://github.com/p/x#readme'tail"` carries both `#` and
8047        // `'`; the `#` byte appears first, so the fragment-`#` arm
8048        // fires, surfacing the more self-locating diagnostic on the
8049        // byte the author pasted earliest in the URL.
8050        let d = dep_with_fonte(DepSource::Git {
8051            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8052            tag: Some("v0.1.0".into()),
8053            rev: None,
8054            branch: None,
8055        });
8056        let err = d.validate().unwrap_err();
8057        let DepError::FonteRepoShape { reason, .. } = err else {
8058            panic!("expected FonteRepoShape, got other variant");
8059        };
8060        assert!(
8061            reason.contains("must not contain `#`"),
8062            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8063             byte appears first in value), got {reason:?}"
8064        );
8065    }
8066
8067    #[test]
8068    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8069        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8070        // byte-class arm, 4267d8b) and the single-quote arm are both
8071        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8072        // so the byte that appears first in the value's byte order
8073        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8074        // `'`; the `"` byte appears first, so the double-quote arm
8075        // fires, surfacing the more self-locating diagnostic on the
8076        // byte the author pasted earliest in the URL. Pins the natural-
8077        // order cascade so a future reorder of the per-byte arms
8078        // surfaces here — `'` is the most recent byte-class arm, so
8079        // the cascade-pin sweep extends to cover the immediately prior
8080        // `"` byte arm firing first when ordered ahead of `'` in the
8081        // value.
8082        let d = dep_with_fonte(DepSource::Git {
8083            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8084            tag: Some("v0.1.0".into()),
8085            rev: None,
8086            branch: None,
8087        });
8088        let err = d.validate().unwrap_err();
8089        let DepError::FonteRepoShape { reason, .. } = err else {
8090            panic!("expected FonteRepoShape, got other variant");
8091        };
8092        assert!(
8093            reason.contains("must not contain `\"`"),
8094            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8095             byte appears first in value), got {reason:?}"
8096        );
8097    }
8098
8099    #[test]
8100    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8101        // The fail-before-pass-after pin for the canonical paste-from-
8102        // shell-history footgun on `:repo`. An author copies a `git
8103        // clone <url>!sudo make install` one-liner from a README's
8104        // quick-start snippet, intending the trailing `!sudo` as a
8105        // shell-history-expansion reference but the typed slot is itself
8106        // a byte-level string parser, not a shell context, so the byte
8107        // rides into the value verbatim. Until this arm landed the `!`
8108        // byte silently passed every prior `is_git_repo_url` arm (no
8109        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8110        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8111        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8112        // start with `-` or `:`); bash with the default `histexpand`
8113        // mode rewrites `!command` to the most recent history entry
8114        // beginning with `command`, the canonical RCE-class injection
8115        // vector when the byte rides into a shell argument.
8116        let d = dep_with_fonte(DepSource::Git {
8117            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8118            tag: Some("v0.1.0".into()),
8119            rev: None,
8120            branch: None,
8121        });
8122        let err = d.validate().unwrap_err();
8123        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8124            panic!("expected FonteRepoShape, got other variant");
8125        };
8126        assert_eq!(nome, "caixa-teia");
8127        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8128        assert!(
8129            reason.contains("must not contain `!`"),
8130            "reason must surface the shell-history-expansion arm, got {reason:?}"
8131        );
8132        assert!(
8133            reason.contains("history-expansion") || reason.contains("bang"),
8134            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8135        );
8136    }
8137
8138    #[test]
8139    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8140        // The symmetric `!!` repeat-prior-command pin: an author paste-
8141        // trims a `git clone <url>` retry idiom from shell history that
8142        // expands to the previous command via `!!`. Pinned separately
8143        // from the wrapped `!command` shape so a future diagnostic-
8144        // surface change that only checked the leading or paired-bang
8145        // position surfaces here — the per-byte arm fires anywhere `!`
8146        // appears in the value.
8147        let d = dep_with_fonte(DepSource::Git {
8148            repo: "github:pleme-io/caixa-teia!!".into(),
8149            tag: Some("v0.1.0".into()),
8150            rev: None,
8151            branch: None,
8152        });
8153        let err = d.validate().unwrap_err();
8154        let DepError::FonteRepoShape { reason, .. } = err else {
8155            panic!("expected FonteRepoShape, got other variant");
8156        };
8157        assert!(
8158            reason.contains("must not contain `!`"),
8159            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8160             got {reason:?}"
8161        );
8162    }
8163
8164    #[test]
8165    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8166        // Cascade pin: the fragment-`#` arm and the bang arm are both
8167        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8168        // so the byte that appears first in the value's byte order
8169        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8170        // both `#` and `!`; the `#` byte appears first, so the
8171        // fragment-`#` arm fires, surfacing the more self-locating
8172        // diagnostic on the byte the author pasted earliest in the URL.
8173        let d = dep_with_fonte(DepSource::Git {
8174            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8175            tag: Some("v0.1.0".into()),
8176            rev: None,
8177            branch: None,
8178        });
8179        let err = d.validate().unwrap_err();
8180        let DepError::FonteRepoShape { reason, .. } = err else {
8181            panic!("expected FonteRepoShape, got other variant");
8182        };
8183        assert!(
8184            reason.contains("must not contain `#`"),
8185            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8186             appears first in value), got {reason:?}"
8187        );
8188    }
8189
8190    #[test]
8191    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8192        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8193        // byte-class arm, e7a109f) and the bang arm are both per-byte
8194        // arms inside the same `for &b in s.as_bytes()` loop, so the
8195        // byte that appears first in the value's byte order wins. A
8196        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8197        // `'` byte appears first, so the single-quote arm fires,
8198        // surfacing the more self-locating diagnostic on the byte the
8199        // author pasted earliest in the URL. Pins the natural-order
8200        // cascade so a future reorder of the per-byte arms surfaces
8201        // here — `!` is the most recent byte-class arm, so the
8202        // cascade-pin sweep extends to cover the immediately prior `'`
8203        // byte arm firing first when ordered ahead of `!` in the value.
8204        let d = dep_with_fonte(DepSource::Git {
8205            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8206            tag: Some("v0.1.0".into()),
8207            rev: None,
8208            branch: None,
8209        });
8210        let err = d.validate().unwrap_err();
8211        let DepError::FonteRepoShape { reason, .. } = err else {
8212            panic!("expected FonteRepoShape, got other variant");
8213        };
8214        assert!(
8215            reason.contains("must not contain `'`"),
8216            "reason must surface the single-quote arm (fires before bang when `'` byte \
8217             appears first in value), got {reason:?}"
8218        );
8219    }
8220
8221    #[test]
8222    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8223        // The fail-before-pass-after pin for the canonical
8224        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8225        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8226        // one-liner from a multi-repo bootstrap doc, intending the
8227        // comma to separate multiple repo entries but the typed
8228        // `:repo` slot names *one* repo (the list-separator belongs
8229        // to the `:deps` list grammar, not to the value). Until this
8230        // arm landed the `,` byte silently passed every prior
8231        // `is_git_repo_url` arm (no whitespace, no control chars, no
8232        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8233        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8234        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8235        // `:`); the byte rode into the lacre's per-dep content-
8236        // address and the resolver's `git clone <repo>` subprocess
8237        // invocation, where no host's repo registry resolved the
8238        // comma-bearing slug.
8239        let d = dep_with_fonte(DepSource::Git {
8240            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8241            tag: Some("v0.1.0".into()),
8242            rev: None,
8243            branch: None,
8244        });
8245        let err = d.validate().unwrap_err();
8246        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8247            panic!("expected FonteRepoShape, got other variant");
8248        };
8249        assert_eq!(nome, "caixa-teia");
8250        assert_eq!(
8251            repo,
8252            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8253        );
8254        assert!(
8255            reason.contains("must not contain `,`"),
8256            "reason must surface the list-separator-comma arm, got {reason:?}"
8257        );
8258        assert!(
8259            reason.contains("list-separator") || reason.contains("sub-delims"),
8260            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8261             got {reason:?}"
8262        );
8263    }
8264
8265    #[test]
8266    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8267        // The symmetric trailing-`,` paste-from-prose pin: an author
8268        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8269        // comma every README-prose list-of-projects sentence carries,
8270        // mistakenly retained when the slug is pasted mid-sentence)
8271        // expecting the substrate to coerce it to a kebab-case slug.
8272        // Pinned separately from the wrapped mid-token shape so a
8273        // future diagnostic-surface change that only checked the
8274        // leading or paired-comma position surfaces here — the
8275        // per-byte arm fires anywhere `,` appears in the value.
8276        let d = dep_with_fonte(DepSource::Git {
8277            repo: "github:pleme-io/caixa-feira,".into(),
8278            tag: Some("v0.1.0".into()),
8279            rev: None,
8280            branch: None,
8281        });
8282        let err = d.validate().unwrap_err();
8283        let DepError::FonteRepoShape { reason, .. } = err else {
8284            panic!("expected FonteRepoShape, got other variant");
8285        };
8286        assert!(
8287            reason.contains("must not contain `,`"),
8288            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8289             got {reason:?}"
8290        );
8291    }
8292
8293    #[test]
8294    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8295        // Cascade pin: the fragment-`#` arm and the comma arm are
8296        // both per-byte arms inside the same `for &b in s.as_bytes()`
8297        // loop, so the byte that appears first in the value's byte
8298        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8299        // carries both `#` and `,`; the `#` byte appears first, so
8300        // the fragment-`#` arm fires, surfacing the more self-
8301        // locating diagnostic on the byte the author pasted earliest
8302        // in the URL.
8303        let d = dep_with_fonte(DepSource::Git {
8304            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8305            tag: Some("v0.1.0".into()),
8306            rev: None,
8307            branch: None,
8308        });
8309        let err = d.validate().unwrap_err();
8310        let DepError::FonteRepoShape { reason, .. } = err else {
8311            panic!("expected FonteRepoShape, got other variant");
8312        };
8313        assert!(
8314            reason.contains("must not contain `#`"),
8315            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8316             appears first in value), got {reason:?}"
8317        );
8318    }
8319
8320    #[test]
8321    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8322        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8323        // byte-class arm, 7d53c68) and the comma arm are both
8324        // per-byte arms inside the same `for &b in s.as_bytes()`
8325        // loop, so the byte that appears first in the value's byte
8326        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8327        // `!` and `,`; the `!` byte appears first, so the bang arm
8328        // fires, surfacing the more self-locating diagnostic on the
8329        // byte the author pasted earliest in the URL. Pins the
8330        // natural-order cascade so a future reorder of the per-byte
8331        // arms surfaces here — `,` is the most recent byte-class
8332        // arm, so the cascade-pin sweep extends to cover the
8333        // immediately prior `!` byte arm firing first when ordered
8334        // ahead of `,` in the value.
8335        let d = dep_with_fonte(DepSource::Git {
8336            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8337            tag: Some("v0.1.0".into()),
8338            rev: None,
8339            branch: None,
8340        });
8341        let err = d.validate().unwrap_err();
8342        let DepError::FonteRepoShape { reason, .. } = err else {
8343            panic!("expected FonteRepoShape, got other variant");
8344        };
8345        assert!(
8346            reason.contains("must not contain `!`"),
8347            "reason must surface the bang arm (fires before comma when `!` byte \
8348             appears first in value), got {reason:?}"
8349        );
8350    }
8351
8352    #[test]
8353    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8354        // The fail-before-pass-after pin for the canonical
8355        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8356        // on `:repo`. An author copies
8357        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8358        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8359        // git clone <url>`, etc. — the canonical
8360        // git-troubleshooting README idiom for a one-shot env-var
8361        // scoped to the `git clone` invocation) from a shell-prompt
8362        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8363        // grammar env-var assignment but the typed `:repo` slot is
8364        // a value parser, not a shell context, so the bytes ride
8365        // into the value verbatim. Until this arm landed the `=`
8366        // byte silently passed every prior `is_git_repo_url` arm
8367        // (no whitespace, no control chars, no non-ASCII, no `#`,
8368        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8369        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8370        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8371        // the byte rode into the lacre's per-dep content-address
8372        // and the resolver's `git clone <repo>` subprocess
8373        // invocation, where the upstream host's git porcelain
8374        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8375        // path that no host's repo registry resolves.
8376        let d = dep_with_fonte(DepSource::Git {
8377            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8378            tag: Some("v0.1.0".into()),
8379            rev: None,
8380            branch: None,
8381        });
8382        let err = d.validate().unwrap_err();
8383        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8384            panic!("expected FonteRepoShape, got other variant");
8385        };
8386        assert_eq!(nome, "caixa-teia");
8387        assert_eq!(
8388            repo,
8389            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8390        );
8391        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8392        // appears before the ` ` byte at position 21, so the `=`
8393        // arm fires (not the whitespace arm) — both arms guard
8394        // the slot, but the per-byte for-loop scans left-to-right
8395        // and the first matching byte wins.
8396        assert!(
8397            reason.contains("must not contain `=`"),
8398            "reason must surface the equals-`=` arm on the env-var-assignment \
8399             paste shape, got {reason:?}"
8400        );
8401        assert!(
8402            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8403            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8404        );
8405    }
8406
8407    #[test]
8408    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8409        // The symmetric paste-from-gitconfig pin: an author copies
8410        // `url=https://github.com/p/x` from `git config --get-all
8411        // remote.origin.url` output, a `.gitconfig` `[remote
8412        // "origin"] url = https://…` ini-stanza paste, or a
8413        // `git config remote.origin.url <value>` doc snippet,
8414        // intending the `url=` prefix as the ini-key but the typed
8415        // `:repo` slot is a URL value parser, not a gitconfig
8416        // grammar. With no leading whitespace and no earlier-arm
8417        // bytes in the value, the `=` arm itself fires (rather
8418        // than cascading to the whitespace arm as in the env-var
8419        // paste shape). Pinned separately so a future diagnostic-
8420        // surface change that only checked the whitespace-leading
8421        // shape surfaces here — the per-byte arm fires anywhere
8422        // `=` appears in the value.
8423        let d = dep_with_fonte(DepSource::Git {
8424            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8425            tag: Some("v0.1.0".into()),
8426            rev: None,
8427            branch: None,
8428        });
8429        let err = d.validate().unwrap_err();
8430        let DepError::FonteRepoShape { reason, .. } = err else {
8431            panic!("expected FonteRepoShape, got other variant");
8432        };
8433        assert!(
8434            reason.contains("must not contain `=`"),
8435            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8436             paste shape, got {reason:?}"
8437        );
8438        assert!(
8439            reason.contains("key-value-separator") || reason.contains("sub-delims"),
8440            "reason must name the key-value-separator / RFC-3986-sub-delims \
8441             rationale, got {reason:?}"
8442        );
8443    }
8444
8445    #[test]
8446    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8447        // Cascade pin: the fragment-`#` arm and the `=` arm are
8448        // both per-byte arms inside the same `for &b in s.as_bytes()`
8449        // loop, so the byte that appears first in the value's byte
8450        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8451        // carries both `#` and `=`; the `#` byte appears first, so
8452        // the fragment-`#` arm fires, surfacing the more self-
8453        // locating diagnostic on the byte the author pasted earliest
8454        // in the URL.
8455        let d = dep_with_fonte(DepSource::Git {
8456            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8457            tag: Some("v0.1.0".into()),
8458            rev: None,
8459            branch: None,
8460        });
8461        let err = d.validate().unwrap_err();
8462        let DepError::FonteRepoShape { reason, .. } = err else {
8463            panic!("expected FonteRepoShape, got other variant");
8464        };
8465        assert!(
8466            reason.contains("must not contain `#`"),
8467            "reason must surface the fragment-`#` arm (fires before equals when \
8468             `#` byte appears first in value), got {reason:?}"
8469        );
8470    }
8471
8472    #[test]
8473    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8474        // Cascade pin: the comma-`,` arm (the immediate-predecessor
8475        // byte-class arm, 775b80e) and the `=` arm are both per-byte
8476        // arms inside the same `for &b in s.as_bytes()` loop, so
8477        // the byte that appears first in the value's byte order
8478        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8479        // and `=`; the `,` byte appears first, so the comma arm
8480        // fires, surfacing the more self-locating diagnostic on
8481        // the byte the author pasted earliest in the URL. Pins the
8482        // natural-order cascade so a future reorder of the per-byte
8483        // arms surfaces here — `=` is the most recent byte-class
8484        // arm, so the cascade-pin sweep extends to cover the
8485        // immediately prior `,` byte arm firing first when ordered
8486        // ahead of `=` in the value.
8487        let d = dep_with_fonte(DepSource::Git {
8488            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8489            tag: Some("v0.1.0".into()),
8490            rev: None,
8491            branch: None,
8492        });
8493        let err = d.validate().unwrap_err();
8494        let DepError::FonteRepoShape { reason, .. } = err else {
8495            panic!("expected FonteRepoShape, got other variant");
8496        };
8497        assert!(
8498            reason.contains("must not contain `,`"),
8499            "reason must surface the comma arm (fires before equals when `,` byte \
8500             appears first in value), got {reason:?}"
8501        );
8502    }
8503
8504    #[test]
8505    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8506        // The fail-before-pass-after pin for the canonical paste-from-
8507        // browser-address-bar percent-encoded-space footgun on `:repo`.
8508        // An author copies `https://github.com/p/x%20test` from a
8509        // browser address bar (or a percent-encoded README hyperlink,
8510        // or a `curl --data-urlencode` shell-pipeline output)
8511        // intending `%20` as the URL encoding of a literal space; the
8512        // typed `:repo` slot already rejects the literal space byte
8513        // (the whitespace arm at the top of `is_git_repo_url`), so an
8514        // author trying to express "I really meant a space" reaches
8515        // for percent-encoding. Until this arm landed the `%` byte
8516        // silently passed every prior `is_git_repo_url` arm and rode
8517        // verbatim into the lacre's per-dep content-address — but
8518        // libcurl re-percent-encodes `%` to `%25` on the wire (since
8519        // `%` is reserved as the escape-sequence lead-in), so the
8520        // wire request becomes `https://github.com/p/x%2520test`, a
8521        // path the lacre's content-address never names. The classic
8522        // render-determinism violation on the encoding-mechanism axis
8523        // itself.
8524        let d = dep_with_fonte(DepSource::Git {
8525            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8526            tag: Some("v0.1.0".into()),
8527            rev: None,
8528            branch: None,
8529        });
8530        let err = d.validate().unwrap_err();
8531        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8532            panic!("expected FonteRepoShape, got other variant");
8533        };
8534        assert_eq!(nome, "caixa-teia");
8535        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8536        assert!(
8537            reason.contains("must not contain `%`"),
8538            "reason must surface the percent-`%` arm on the percent-encoded-space \
8539             paste shape, got {reason:?}"
8540        );
8541        assert!(
8542            reason.contains("percent-encoding") || reason.contains("%25"),
8543            "reason must name the percent-encoding / `%25` re-encoding rationale, \
8544             got {reason:?}"
8545        );
8546    }
8547
8548    #[test]
8549    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8550        // The symmetric over-encoded-path-separator pin: an author
8551        // writes `:repo "https://github.com/p%2Fx"` intending the
8552        // `%2F` as the URL encoding of `/` (the canonical
8553        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8554        // footgun every API client library and OAuth redirect-URI
8555        // documentation surfaces — the `/` is the URL-path-separator
8556        // and some templates percent-encode it to escape interpretation
8557        // as a path separator). The GitHub Smart-HTTP transport
8558        // resolves the URL's path-segment grammar before the
8559        // percent-decoding pass, so the value identifies a different
8560        // resource on the wire than the literal-`/` form the lacre's
8561        // content-address must agree with — two authors whose `:repo`
8562        // values differ only in their `/` vs `%2F` presence lock to
8563        // two distinct BLAKE3 closures for the byte-identical upstream
8564        // `git clone`. Pinned separately so a future diagnostic
8565        // surface that only catches the `%20` shape surfaces here too.
8566        let d = dep_with_fonte(DepSource::Git {
8567            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8568            tag: Some("v0.1.0".into()),
8569            rev: None,
8570            branch: None,
8571        });
8572        let err = d.validate().unwrap_err();
8573        let DepError::FonteRepoShape { reason, .. } = err else {
8574            panic!("expected FonteRepoShape, got other variant");
8575        };
8576        assert!(
8577            reason.contains("must not contain `%`"),
8578            "reason must surface the percent-`%` arm on the over-encoded-path \
8579             shape, got {reason:?}"
8580        );
8581        assert!(
8582            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8583            "reason must name the render-determinism / BLAKE3-closure rationale, \
8584             got {reason:?}"
8585        );
8586    }
8587
8588    #[test]
8589    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8590        // Cascade pin: the fragment-`#` arm and the `%` arm are both
8591        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8592        // so the byte that appears first in the value's byte order
8593        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8594        // both `#` and `%`; the `#` byte appears first, so the
8595        // fragment-`#` arm fires, surfacing the more self-locating
8596        // diagnostic on the byte the author pasted earliest in the URL.
8597        let d = dep_with_fonte(DepSource::Git {
8598            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8599            tag: Some("v0.1.0".into()),
8600            rev: None,
8601            branch: None,
8602        });
8603        let err = d.validate().unwrap_err();
8604        let DepError::FonteRepoShape { reason, .. } = err else {
8605            panic!("expected FonteRepoShape, got other variant");
8606        };
8607        assert!(
8608            reason.contains("must not contain `#`"),
8609            "reason must surface the fragment-`#` arm (fires before percent when \
8610             `#` byte appears first in value), got {reason:?}"
8611        );
8612    }
8613
8614    #[test]
8615    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8616        // Cascade pin: the equals-`=` arm (the immediate-predecessor
8617        // byte-class arm, acf99af) and the `%` arm are both per-byte
8618        // arms inside the same `for &b in s.as_bytes()` loop, so the
8619        // byte that appears first in the value's byte order wins.
8620        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8621        // the `=` byte appears first, so the equals arm fires,
8622        // surfacing the more self-locating diagnostic on the byte the
8623        // author pasted earliest in the URL. Pins the natural-order
8624        // cascade so a future reorder of the per-byte arms surfaces
8625        // here — `%` is the most recent byte-class arm, so the
8626        // cascade-pin sweep extends to cover the immediately prior
8627        // `=` byte arm firing first when ordered ahead of `%` in the
8628        // value.
8629        let d = dep_with_fonte(DepSource::Git {
8630            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8631            tag: Some("v0.1.0".into()),
8632            rev: None,
8633            branch: None,
8634        });
8635        let err = d.validate().unwrap_err();
8636        let DepError::FonteRepoShape { reason, .. } = err else {
8637            panic!("expected FonteRepoShape, got other variant");
8638        };
8639        assert!(
8640            reason.contains("must not contain `=`"),
8641            "reason must surface the equals arm (fires before percent when `=` byte \
8642             appears first in value), got {reason:?}"
8643        );
8644    }
8645
8646    #[test]
8647    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8648        // The fail-before-pass-after pin for the canonical paste-from-
8649        // shell-history footgun on `:repo`. An author copies a
8650        // `git clone <url>` line from their terminal followed by a
8651        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8652        // history shorthand (the `^old^new^` form re-runs the prior
8653        // history entry with the first `old` substituted by `new`,
8654        // bash's default behavior on interactive sessions with
8655        // `set -o histexpand`), forgetting to trim the trailing
8656        // `^...^...` shell-history fragment from the URL value. The
8657        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8658        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8659        // classes), the WHATWG URL spec's 'fragment percent-encode
8660        // set' maps `^` → `%5E` on the wire, so the byte rides
8661        // verbatim into the lacre's per-dep content-address but
8662        // libcurl re-encodes it to `%5E` at `git clone` time — the
8663        // classic render-determinism violation on the same axis the
8664        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8665        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8666        // `#` arms close.
8667        let d = dep_with_fonte(DepSource::Git {
8668            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8669            tag: Some("v0.1.0".into()),
8670            rev: None,
8671            branch: None,
8672        });
8673        let err = d.validate().unwrap_err();
8674        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8675            panic!("expected FonteRepoShape, got other variant");
8676        };
8677        assert_eq!(nome, "caixa-teia");
8678        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8679        assert!(
8680            reason.contains("must not contain `^`"),
8681            "reason must surface the caret-`^` arm on the paste-from-shell-history \
8682             shape, got {reason:?}"
8683        );
8684        assert!(
8685            reason.contains("history-substitution") || reason.contains("%5E"),
8686            "reason must name the shell-history-substitution / `%5E` wire-encoding \
8687             rationale, got {reason:?}"
8688        );
8689    }
8690
8691    #[test]
8692    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8693        // The symmetric paste-from-doc-grep-pipeline footgun: an
8694        // author writes `:repo "github:p/^archived"` after copying a
8695        // `grep '^archived'` regex-anchor / negation idiom from a
8696        // doc / README quick-listing snippet, expecting the substrate
8697        // to coerce it to a literal repo name. The byte rides
8698        // verbatim into the lacre's per-dep content-address and
8699        // diverges from the byte-identical literal `archived` form
8700        // every other author authored — the canonical render-
8701        // determinism violation pin on the second footgun shape the
8702        // caret-`^` arm closes.
8703        let d = dep_with_fonte(DepSource::Git {
8704            repo: "github:pleme-io/^archived".into(),
8705            tag: Some("v0.1.0".into()),
8706            rev: None,
8707            branch: None,
8708        });
8709        let err = d.validate().unwrap_err();
8710        let DepError::FonteRepoShape { reason, .. } = err else {
8711            panic!("expected FonteRepoShape, got other variant");
8712        };
8713        assert!(
8714            reason.contains("must not contain `^`"),
8715            "reason must surface the caret-`^` arm on the regex-anchor shape, \
8716             got {reason:?}"
8717        );
8718        assert!(
8719            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8720            "reason must name the render-determinism / BLAKE3-closure rationale, \
8721             got {reason:?}"
8722        );
8723    }
8724
8725    #[test]
8726    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8727        // Cascade pin: the `%` arm (the immediate-predecessor byte-
8728        // class arm, a323db8) and the `^` arm are both per-byte arms
8729        // inside the same `for &b in s.as_bytes()` loop, so the byte
8730        // that appears first in the value's byte order wins. A
8731        // `:repo "https://github.com/p/x%20mid^tail"` carries both
8732        // `%` and `^`; the `%` byte appears first, so the percent
8733        // arm fires, surfacing the more self-locating diagnostic on
8734        // the byte the author pasted earliest in the URL. Pins the
8735        // natural-order cascade so a future reorder of the per-byte
8736        // arms surfaces here — `^` is the most recent byte-class arm,
8737        // so the cascade-pin sweep extends to cover the immediately
8738        // prior `%` byte arm firing first when ordered ahead of `^`
8739        // in the value.
8740        let d = dep_with_fonte(DepSource::Git {
8741            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8742            tag: Some("v0.1.0".into()),
8743            rev: None,
8744            branch: None,
8745        });
8746        let err = d.validate().unwrap_err();
8747        let DepError::FonteRepoShape { reason, .. } = err else {
8748            panic!("expected FonteRepoShape, got other variant");
8749        };
8750        assert!(
8751            reason.contains("must not contain `%`"),
8752            "reason must surface the percent arm (fires before caret when `%` byte \
8753             appears first in value), got {reason:?}"
8754        );
8755    }
8756
8757    #[test]
8758    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8759        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8760        // (no `github:` prefix, no scheme). Every documented form
8761        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8762        // `file://`, or `git@host:path`); a bare `org/repo` is
8763        // ambiguous (`git clone` reads as a relative filesystem path
8764        // rather than the GitHub-shorthand expansion the author
8765        // probably intended) and the gate rejects the shape upstream.
8766        let d = dep_with_fonte(DepSource::Git {
8767            repo: "pleme-io/caixa-teia".into(),
8768            tag: Some("v0.1.0".into()),
8769            rev: None,
8770            branch: None,
8771        });
8772        let err = d.validate().unwrap_err();
8773        let DepError::FonteRepoShape { reason, .. } = err else {
8774            panic!("expected FonteRepoShape, got other variant");
8775        };
8776        assert!(
8777            reason.contains("must contain a `:`"),
8778            "reason must surface the missing-`:` arm, got {reason:?}"
8779        );
8780        assert!(
8781            reason.contains("github:"),
8782            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8783        );
8784    }
8785
8786    #[test]
8787    fn validate_rejects_git_fonte_with_repo_leading_colon() {
8788        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8789        // scheme that no git porcelain entry-point accepts. Pinned
8790        // separately from the missing-`:` arm because a value with a
8791        // leading `:` does technically contain a `:` separator; the
8792        // shape gate rejects on a dedicated arm so the diagnostic
8793        // names the specific footgun.
8794        let d = dep_with_fonte(DepSource::Git {
8795            repo: ":pleme-io/caixa-teia".into(),
8796            tag: Some("v0.1.0".into()),
8797            rev: None,
8798            branch: None,
8799        });
8800        let err = d.validate().unwrap_err();
8801        let DepError::FonteRepoShape { reason, .. } = err else {
8802            panic!("expected FonteRepoShape, got other variant");
8803        };
8804        assert!(
8805            reason.contains("must not start with `:`"),
8806            "reason must surface the leading-`:` arm, got {reason:?}"
8807        );
8808    }
8809
8810    #[test]
8811    fn validate_rejects_git_fonte_with_repo_too_long() {
8812        // The cap arm — a `:repo` value longer than
8813        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8814        // structurally untenable on every realistic landing site (the
8815        // resolver's `git clone` invocation, the future M4 CR
8816        // materializer's per-dep `repo:` axis); a value of that length
8817        // is almost certainly a paste-from-binary slug.
8818        let too_long = format!(
8819            "github:pleme-io/{}",
8820            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8821        );
8822        let d = dep_with_fonte(DepSource::Git {
8823            repo: too_long.clone(),
8824            tag: Some("v0.1.0".into()),
8825            rev: None,
8826            branch: None,
8827        });
8828        let err = d.validate().unwrap_err();
8829        let DepError::FonteRepoShape { reason, .. } = err else {
8830            panic!("expected FonteRepoShape, got other variant");
8831        };
8832        assert!(
8833            reason.contains("2048"),
8834            "reason must name the cap, got {reason:?}"
8835        );
8836    }
8837
8838    #[test]
8839    fn validate_accepts_canonical_git_fonte_repo_shapes() {
8840        // The positive-control sweep: every documented author shape on
8841        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8842        // must pass the value-shape gate. Pinned so a future tightening
8843        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8844        // here as a structural decision. Each form is exercised with the
8845        // same canonical `:tag` pin so only the `:repo` axis varies.
8846        for repo in [
8847            // The pleme-io registry-shorthand convention — `github:org/repo`.
8848            "github:pleme-io/caixa-teia",
8849            // Other host-aliased shorthands (the resolver's pluggable
8850            // host-prefix table).
8851            "gitlab:pleme-io/caixa-teia",
8852            "codeberg:pleme-io/caixa-teia",
8853            "sourcehut:~pleme-io/caixa-teia",
8854            // Full HTTPS URL with and without `.git` suffix.
8855            "https://github.com/pleme-io/caixa-teia",
8856            "https://github.com/pleme-io/caixa-teia.git",
8857            // HTTP (rare; dev / mirror).
8858            "http://example.com/pleme-io/caixa-teia.git",
8859            // SSH URL.
8860            "ssh://git@github.com/pleme-io/caixa-teia.git",
8861            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8862            // Scp-style SSH — the canonical `git@host:path` short form.
8863            "git@github.com:pleme-io/caixa-teia.git",
8864            "git@git.example.com:team/private.git",
8865            // Anonymous git protocol.
8866            "git://git.example.com/pleme-io/caixa-teia.git",
8867            // Local file URL (dev path).
8868            "file:///tmp/caixa-teia",
8869        ] {
8870            let d = dep_with_fonte(DepSource::Git {
8871                repo: repo.into(),
8872                tag: Some("v0.1.0".into()),
8873                rev: None,
8874                branch: None,
8875            });
8876            d.validate()
8877                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8878        }
8879    }
8880
8881    #[test]
8882    fn fonte_repo_empty_takes_precedence_over_shape() {
8883        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8884        // diagnostic; doesn't try to parse the URL shape) fires before
8885        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8886        // keeps its narrower error message. Mirrors
8887        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8888        // on the ordering layer.
8889        let d = dep_with_fonte(DepSource::Git {
8890            repo: String::new(),
8891            tag: Some("v0.1.0".into()),
8892            rev: None,
8893            branch: None,
8894        });
8895        let err = d.validate().unwrap_err();
8896        assert!(
8897            matches!(err, DepError::FonteRepoEmpty { .. }),
8898            "got {err:?}"
8899        );
8900    }
8901
8902    #[test]
8903    fn fonte_repo_shape_fires_before_pin_missing() {
8904        // Order pin: a malformed `:repo` value on a dep with no pin set
8905        // surfaces the `:repo` shape diagnostic (the more self-locating
8906        // axis — the `:repo` is the load-bearing identity of the source;
8907        // a missing pin is downstream from "do we even know the repo")
8908        // rather than collapsing onto the pin-missing diagnostic. The
8909        // shape gate runs inline before the pin enumeration in
8910        // `DepSource::validate`.
8911        let d = dep_with_fonte(DepSource::Git {
8912            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8913            tag: None,
8914            rev: None,
8915            branch: None,
8916        });
8917        let err = d.validate().unwrap_err();
8918        assert!(
8919            matches!(err, DepError::FonteRepoShape { .. }),
8920            "got {err:?}"
8921        );
8922    }
8923
8924    #[test]
8925    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8926        // The diagnostic-shape pin: the error names the offending
8927        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8928        // so the author can grep their caixa.lisp without re-running
8929        // the build. Mirrors the diagnostic-shape sweep on every prior
8930        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8931        let d = dep_with_fonte(DepSource::Git {
8932            repo: "pleme-io/caixa-teia".into(),
8933            tag: Some("v0.1.0".into()),
8934            rev: None,
8935            branch: None,
8936        });
8937        let err = d.validate().unwrap_err();
8938        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8939            panic!("expected FonteRepoShape, got other variant");
8940        };
8941        assert_eq!(nome, "caixa-teia");
8942        assert_eq!(repo, "pleme-io/caixa-teia");
8943        assert!(
8944            !reason.is_empty(),
8945            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8946        );
8947    }
8948
8949    #[test]
8950    fn validate_rejects_git_fonte_with_no_pin() {
8951        // The fail-before-pass-after pin for the canonical
8952        // `(:tipo git :repo "github:pleme-io/x")` shape with no
8953        // :tag/:rev/:branch — until this gate landed the resolver's
8954        // ResolveError::MissingPin surfaced at fetch time, far from the
8955        // source caixa.lisp. The new gate moves the check to validate
8956        // time and names the offending dep.
8957        let d = dep_with_fonte(DepSource::Git {
8958            repo: "github:pleme-io/caixa-teia".into(),
8959            tag: None,
8960            rev: None,
8961            branch: None,
8962        });
8963        let err = d.validate().unwrap_err();
8964        assert!(
8965            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8966            "got {err:?}"
8967        );
8968    }
8969
8970    #[test]
8971    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8972        // The canonical "pin drift" footgun: an author writes
8973        // `:tag "v1"` and later adds `:branch "main"` without removing
8974        // the :tag, and the resolver silently picks :tag (precedence
8975        // :rev > :tag > :branch). The :branch was dropped with no
8976        // diagnostic. The gate now rejects multi-pin shapes so the
8977        // author makes the precedence explicit at the source.
8978        let d = dep_with_fonte(DepSource::Git {
8979            repo: "github:pleme-io/caixa-teia".into(),
8980            tag: Some("v0.1.0".into()),
8981            rev: None,
8982            branch: Some("main".into()),
8983        });
8984        let err = d.validate().unwrap_err();
8985        let DepError::FontePinAmbiguous { nome, pins } = err else {
8986            panic!("expected FontePinAmbiguous");
8987        };
8988        assert_eq!(nome, "caixa-teia");
8989        assert!(pins.contains(":tag"));
8990        assert!(pins.contains(":branch"));
8991        assert!(!pins.contains(":rev"));
8992    }
8993
8994    #[test]
8995    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8996        // Sibling arm of the pin-drift footgun: :tag + :rev set
8997        // simultaneously. Pinned separately so a future relaxation
8998        // that only catches the (:tag, :branch) pair surfaces here.
8999        let d = dep_with_fonte(DepSource::Git {
9000            repo: "github:pleme-io/caixa-teia".into(),
9001            tag: Some("v0.1.0".into()),
9002            rev: Some("c0ffee".into()),
9003            branch: None,
9004        });
9005        let err = d.validate().unwrap_err();
9006        let DepError::FontePinAmbiguous { nome, pins } = err else {
9007            panic!("expected FontePinAmbiguous");
9008        };
9009        assert_eq!(nome, "caixa-teia");
9010        assert!(pins.contains(":tag"));
9011        assert!(pins.contains(":rev"));
9012    }
9013
9014    #[test]
9015    fn validate_rejects_git_fonte_with_all_three_pins() {
9016        // The maximal ambiguity case — every pin axis set. Pinned so a
9017        // future relaxation that only catches pairs surfaces here. The
9018        // diagnostic must enumerate every offending axis so the author
9019        // sees the full set, not just the first match.
9020        let d = dep_with_fonte(DepSource::Git {
9021            repo: "github:pleme-io/caixa-teia".into(),
9022            tag: Some("v0.1.0".into()),
9023            rev: Some("c0ffee".into()),
9024            branch: Some("main".into()),
9025        });
9026        let err = d.validate().unwrap_err();
9027        let DepError::FontePinAmbiguous { nome, pins } = err else {
9028            panic!("expected FontePinAmbiguous");
9029        };
9030        assert_eq!(nome, "caixa-teia");
9031        assert!(pins.contains(":tag"));
9032        assert!(pins.contains(":rev"));
9033        assert!(pins.contains(":branch"));
9034    }
9035
9036    #[test]
9037    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9038        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9039        // inner string is empty. Distinct from FontePinMissing (where
9040        // every axis is None) — pinned separately so a future
9041        // tightening collapsing them surfaces here as a structural
9042        // decision.
9043        let d = dep_with_fonte(DepSource::Git {
9044            repo: "github:pleme-io/caixa-teia".into(),
9045            tag: Some(String::new()),
9046            rev: None,
9047            branch: None,
9048        });
9049        let err = d.validate().unwrap_err();
9050        let DepError::FontePinEmpty { nome, pin } = err else {
9051            panic!("expected FontePinEmpty");
9052        };
9053        assert_eq!(nome, "caixa-teia");
9054        assert_eq!(pin, ":tag");
9055    }
9056
9057    #[test]
9058    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9059        // Sibling arm — the empty-pin diagnostic names which axis
9060        // carries the empty value, so the author's grep target is
9061        // unambiguous.
9062        let d = dep_with_fonte(DepSource::Git {
9063            repo: "github:pleme-io/caixa-teia".into(),
9064            tag: None,
9065            rev: Some(String::new()),
9066            branch: None,
9067        });
9068        let err = d.validate().unwrap_err();
9069        let DepError::FontePinEmpty { nome, pin } = err else {
9070            panic!("expected FontePinEmpty");
9071        };
9072        assert_eq!(nome, "caixa-teia");
9073        assert_eq!(pin, ":rev");
9074    }
9075
9076    #[test]
9077    fn validate_rejects_path_fonte_with_empty_caminho() {
9078        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9079        // until this gate landed the resolver's
9080        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9081        // fetch time — not actionable. The new gate moves the check to
9082        // validate time and names the offending dep.
9083        let d = dep_with_fonte(DepSource::Path {
9084            caminho: String::new(),
9085        });
9086        let err = d.validate().unwrap_err();
9087        assert!(
9088            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9089            "got {err:?}"
9090        );
9091    }
9092
9093    #[test]
9094    fn validate_rejects_path_fonte_with_absolute_caminho() {
9095        // The fail-before-pass-after pin for the absolute-`:caminho`
9096        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9097        // Until this gate landed an absolute `:caminho` silently
9098        // passed validate; the lacre pipeline embedded the
9099        // host-specific filesystem path verbatim in its
9100        // content-address (`conteudo: format!("path:{caminho}")`,
9101        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9102        // differed per machine — the build succeeded but two CI
9103        // runners with different `${HOME}` layouts emitted two
9104        // distinct lacres for the byte-identical caixa, silently
9105        // breaking the THEORY.md §V.2 render-determinism contract
9106        // far from the source caixa.lisp. The new gate moves the
9107        // check to validate time and names the offending dep +
9108        // caminho verbatim.
9109        let d = dep_with_fonte(DepSource::Path {
9110            caminho: "/home/me/work/caixa-teia".into(),
9111        });
9112        let err = d.validate().unwrap_err();
9113        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9114            panic!("expected FonteCaminhoAbsolute, got other variant");
9115        };
9116        assert_eq!(nome, "caixa-teia");
9117        assert_eq!(caminho, "/home/me/work/caixa-teia");
9118    }
9119
9120    #[test]
9121    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9122        // The canonical sibling-workspace dep form
9123        // (`:caminho "../caixa-teia"`) remains accepted. The
9124        // absolute-path gate above is specifically narrower than the
9125        // shared [`crate::render::is_sandboxed_relative_path`]
9126        // predicate (which additionally forbids `..` traversal): a
9127        // local-path dep's canonical author surface is the in-tree
9128        // sibling-workspace path, so a full sandboxed-relative-path
9129        // lift would structurally reject every legitimate path-fonte
9130        // dep. Pinned so a future tightening to the full predicate
9131        // surfaces here as a structural decision, not a silent break.
9132        let d = dep_with_fonte(DepSource::Path {
9133            caminho: "../caixa-teia".into(),
9134        });
9135        d.validate().unwrap();
9136    }
9137
9138    #[test]
9139    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9140        // A multi-segment relative `:caminho`
9141        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9142        // absolute-path gate brackets the host-layout-leaking shape
9143        // at the leading-`/` boundary only; every relative shape past
9144        // the empty arm continues to pass. Pinned alongside the
9145        // `..`-traversal positive control so a future tightening
9146        // surfaces the full set of legitimate relative forms here
9147        // rather than at a downstream consumer.
9148        let d = dep_with_fonte(DepSource::Path {
9149            caminho: "vendor/forks/caixa-teia".into(),
9150        });
9151        d.validate().unwrap();
9152    }
9153
9154    #[test]
9155    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9156        // The fail-before-pass-after pin for the tilde-expansion
9157        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9158        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9159        // through (`Path::is_absolute` returns false on a leading `~`
9160        // — the tilde is a shell-expansion convention, not a POSIX
9161        // path component), so the lacre embedded the value verbatim
9162        // and the resolver folded it through `Path::join` without
9163        // expansion, looking for a literal `./~/work/caixa-teia`
9164        // subdirectory and failing at resolve time with a
9165        // `No such file or directory` error far from the source
9166        // caixa.lisp. The new gate moves the check to validate time
9167        // and names the offending dep + caminho verbatim.
9168        let d = dep_with_fonte(DepSource::Path {
9169            caminho: "~/work/caixa-teia".into(),
9170        });
9171        let err = d.validate().unwrap_err();
9172        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9173            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9174        };
9175        assert_eq!(nome, "caixa-teia");
9176        assert_eq!(caminho, "~/work/caixa-teia");
9177    }
9178
9179    #[test]
9180    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9181        // The bare `~` form (canonical "I meant `$HOME` and forgot
9182        // the rest"): both the leading-tilde arm catches it and the
9183        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9184        // sweeps through the same arm. Pinned both to ensure the
9185        // gate doesn't narrow to `~/` only.
9186        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9187            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9188            let err = d.validate().unwrap_err();
9189            assert!(
9190                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9191                "{s:?} → {err:?}",
9192            );
9193        }
9194    }
9195
9196    #[test]
9197    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9198        // The leading-`~` is the canonical shell-expansion footgun —
9199        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9200        // backup-file-suffix idiom) is a legitimate POSIX path byte
9201        // with no shell-expansion semantic at the leading position.
9202        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9203        // sweep that would break every legitimate-shape backup-file
9204        // path.
9205        let d = dep_with_fonte(DepSource::Path {
9206            caminho: "../foo~bar/caixa-teia".into(),
9207        });
9208        d.validate().unwrap();
9209    }
9210
9211    #[test]
9212    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9213        // Cascade pin: the empty arm structurally precedes the
9214        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9215        // pin establishes the precedence at the diagnostic-shape
9216        // level should a future codec round-trip ever produce a
9217        // probe-as-both value. Mirrors the peer
9218        // `fonte_repo_empty_fires_before_pin_missing` cascade
9219        // discipline.
9220        let d = dep_with_fonte(DepSource::Path {
9221            caminho: String::new(),
9222        });
9223        let err = d.validate().unwrap_err();
9224        assert!(
9225            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9226            "got {err:?}",
9227        );
9228    }
9229
9230    #[test]
9231    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9232        // Diagnostic-shape pin (peer with
9233        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9234        // payload assertion): the error's Display surfaces both the
9235        // offending `:nome` and the offending `:caminho` verbatim
9236        // so a `feira lint` run can render the diagnostic without
9237        // re-parsing.
9238        let d = dep_with_fonte(DepSource::Path {
9239            caminho: "~alice/dev/caixa-teia".into(),
9240        });
9241        let rendered = d.validate().unwrap_err().to_string();
9242        assert!(
9243            rendered.contains("caixa-teia"),
9244            "diagnostic must name the offending dep: {rendered}",
9245        );
9246        assert!(
9247            rendered.contains("~alice/dev/caixa-teia"),
9248            "diagnostic must quote the offending caminho: {rendered}",
9249        );
9250        assert!(
9251            rendered.contains('~'),
9252            "diagnostic must reference the tilde footgun: {rendered}",
9253        );
9254    }
9255
9256    #[test]
9257    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9258        // The fail-before-pass-after pin for the shell-variable-
9259        // expansion `:caminho` shape: `(:tipo path :caminho
9260        // "$HOME/work/caixa-teia")`. Until this gate landed the
9261        // b94fd83 absolute arm + the a5c248e tilde arm both let
9262        // `$HOME/foo` through (`Path::is_absolute` returns false on
9263        // a leading `$` — the `$` is a shell convention, not a POSIX
9264        // path component; `starts_with('~')` returns false too), so
9265        // the lacre embedded the value verbatim and the resolver
9266        // folded it through `Path::join` without `$`-expansion,
9267        // looking for a literal `./$HOME/work/caixa-teia`
9268        // subdirectory and failing at resolve time with a
9269        // `No such file or directory` error far from the source
9270        // caixa.lisp. The new gate moves the check to validate time
9271        // and names the offending dep + caminho verbatim.
9272        let d = dep_with_fonte(DepSource::Path {
9273            caminho: "$HOME/work/caixa-teia".into(),
9274        });
9275        let err = d.validate().unwrap_err();
9276        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9277            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9278        };
9279        assert_eq!(nome, "caixa-teia");
9280        assert_eq!(caminho, "$HOME/work/caixa-teia");
9281    }
9282
9283    #[test]
9284    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9285        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9286        // form (canonical "paste-from-CI-manifest" footgun every
9287        // GitHub Actions / GitLab CI / Drone manifest carries on
9288        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9289        // canonical "I'm referencing a per-user config dir"),
9290        // and the bare `$` (canonical "I meant `$HOME` and forgot
9291        // the rest"). All shapes route through the same gate's
9292        // byte check. Pinned so the gate doesn't narrow to a
9293        // single shape (e.g. `$HOME/` only).
9294        for s in [
9295            "${HOME}/work/caixa-teia",
9296            "${WORKSPACE}/caixa-teia",
9297            "$XDG_CONFIG_HOME/caixa",
9298            "$",
9299        ] {
9300            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9301            let err = d.validate().unwrap_err();
9302            assert!(
9303                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9304                "{s:?} → {err:?}",
9305            );
9306        }
9307    }
9308
9309    #[test]
9310    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9311        // The `$` byte is the canonical shell-variable-expansion /
9312        // command-substitution / arithmetic-expansion sentinel and
9313        // is rejected at *every* position on the `:caminho` axis: the
9314        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9315        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9316        // (6620f39). Pinned so a future arm doesn't narrow the gate
9317        // back to the leading position and re-open the paste-from-
9318        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9319        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9320        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9321        // the lacre content-address (`path:{caminho}`,
9322        // caixa-resolver/src/resolve.rs:189).
9323        let d = dep_with_fonte(DepSource::Path {
9324            caminho: "../foo$bar/caixa-teia".into(),
9325        });
9326        let err = d.validate().unwrap_err();
9327        assert!(
9328            matches!(
9329                err,
9330                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9331            ),
9332            "got {err:?}",
9333        );
9334    }
9335
9336    #[test]
9337    fn fonte_caminho_tilde_fires_before_var_expansion() {
9338        // Cascade pin: the tilde arm structurally precedes the var
9339        // arm (the bytes `~` and `$` don't overlap at the leading
9340        // position), but the pin establishes the precedence at the
9341        // diagnostic-shape level should a future codec round-trip
9342        // ever produce a probe-as-both value. Mirrors the peer
9343        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9344        // discipline on the immediate-predecessor arm.
9345        let d = dep_with_fonte(DepSource::Path {
9346            caminho: "~/work/caixa-teia".into(),
9347        });
9348        let err = d.validate().unwrap_err();
9349        assert!(
9350            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9351            "got {err:?}",
9352        );
9353    }
9354
9355    #[test]
9356    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9357        // Diagnostic-shape pin (peer with
9358        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9359        // payload assertion on the immediate-predecessor arm): the
9360        // error's Display surfaces both the offending `:nome` and
9361        // the offending `:caminho` verbatim plus the `$` footgun
9362        // character itself so a `feira lint` run can render the
9363        // diagnostic without re-parsing.
9364        let d = dep_with_fonte(DepSource::Path {
9365            caminho: "${WORKSPACE}/caixa-teia".into(),
9366        });
9367        let rendered = d.validate().unwrap_err().to_string();
9368        assert!(
9369            rendered.contains("caixa-teia"),
9370            "diagnostic must name the offending dep: {rendered}",
9371        );
9372        assert!(
9373            rendered.contains("${WORKSPACE}/caixa-teia"),
9374            "diagnostic must quote the offending caminho: {rendered}",
9375        );
9376        assert!(
9377            rendered.contains('$'),
9378            "diagnostic must reference the dollar footgun: {rendered}",
9379        );
9380    }
9381
9382    #[test]
9383    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9384        // The fail-before-pass-after pin for the load-bearing NUL byte:
9385        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9386        // routes the path through `CString::new` which fails with
9387        // `NulError`); until this gate landed a `:caminho
9388        // "../caixa\0teia"` silently passed validate, the lacre
9389        // pipeline embedded the value verbatim, and the failure
9390        // surfaced at the resolver's `Path::join` → `CString::new`
9391        // boundary with a non-self-locating `NulError` far from the
9392        // source caixa.lisp. The new gate moves the check to validate
9393        // time and names the offending dep + caminho + offending byte
9394        // verbatim.
9395        let d = dep_with_fonte(DepSource::Path {
9396            caminho: "../caixa\0teia".into(),
9397        });
9398        let err = d.validate().unwrap_err();
9399        let DepError::FonteCaminhoControlChar {
9400            nome,
9401            caminho,
9402            byte,
9403        } = err
9404        else {
9405            panic!("expected FonteCaminhoControlChar, got {err:?}");
9406        };
9407        assert_eq!(nome, "caixa-teia");
9408        assert_eq!(caminho, "../caixa\0teia");
9409        assert_eq!(byte, 0x00);
9410    }
9411
9412    #[test]
9413    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9414        // The canonical paste-from-multiline-doc footgun on `:caminho`
9415        // — author copies `"../caixa-teia\n"` (trailing newline) out
9416        // of a multi-line code-fence or, worse, a `:caminho
9417        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9418        // injection sibling on the path axis the `is_git_repo_url`
9419        // control-char arm already closes on `:repo`). Pinned
9420        // separately from the NUL arm so a future relaxation that
9421        // catches one but not the other surfaces here.
9422        let d = dep_with_fonte(DepSource::Path {
9423            caminho: "../caixa-teia\n".into(),
9424        });
9425        let err = d.validate().unwrap_err();
9426        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9427            panic!("expected FonteCaminhoControlChar, got {err:?}");
9428        };
9429        assert_eq!(byte, 0x0A);
9430    }
9431
9432    #[test]
9433    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9434        // The CRLF sibling of the LF arm — Windows-line-ending
9435        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9436        // leaves a stray `\r` mid-string after the LF strip. Pinned
9437        // separately from the LF arm so a future relaxation that
9438        // only catches LF surfaces here.
9439        let d = dep_with_fonte(DepSource::Path {
9440            caminho: "../caixa-teia\r".into(),
9441        });
9442        let err = d.validate().unwrap_err();
9443        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9444            panic!("expected FonteCaminhoControlChar, got {err:?}");
9445        };
9446        assert_eq!(byte, 0x0D);
9447    }
9448
9449    #[test]
9450    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9451        // The canonical paste-from-aligned-table footgun — a `\t`
9452        // mid-`:caminho` is invisible in most editors but rides
9453        // through the lacre's content-address verbatim, so two
9454        // paste-from-distinct-tables (one editor strips tabs, one
9455        // preserves them) yield divergent lacres for the byte-
9456        // identical-looking caixa. Pinned separately from the
9457        // whitespace-shaped LF/CR arms so a future relaxation that
9458        // narrows to line-terminator-only surfaces here.
9459        let d = dep_with_fonte(DepSource::Path {
9460            caminho: "../caixa\tteia".into(),
9461        });
9462        let err = d.validate().unwrap_err();
9463        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9464            panic!("expected FonteCaminhoControlChar, got {err:?}");
9465        };
9466        assert_eq!(byte, 0x09);
9467    }
9468
9469    #[test]
9470    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9471        // The DEL byte (`0x7F`) closes the upper-end paste-from-
9472        // binary-blob footgun — the gate's contract is `b < 0x20 ||
9473        // b == 0x7F`, matching the `is_git_repo_url` /
9474        // `is_git_ref_name` predicates' control-char arms. Pinned
9475        // separately from the lower-range arms so a future narrowing
9476        // to `< 0x20` only surfaces here.
9477        let d = dep_with_fonte(DepSource::Path {
9478            caminho: "../caixa\x7fteia".into(),
9479        });
9480        let err = d.validate().unwrap_err();
9481        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9482            panic!("expected FonteCaminhoControlChar, got {err:?}");
9483        };
9484        assert_eq!(byte, 0x7F);
9485    }
9486
9487    #[test]
9488    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9489        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9490        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9491        // are opaque byte sequences and UTF-8 multi-byte sequences
9492        // are a legitimate filename shape (the `café-teia/foo` idiom).
9493        // Pinned so the gate doesn't widen to a full ASCII-only sweep
9494        // that would break every legitimate-shape UTF-8 path.
9495        let d = dep_with_fonte(DepSource::Path {
9496            caminho: "../café-teia/foo".into(),
9497        });
9498        d.validate().unwrap();
9499    }
9500
9501    #[test]
9502    fn fonte_caminho_var_fires_before_control_char() {
9503        // Cascade pin: the var-expansion arm structurally precedes the
9504        // control-char arm. A value like `"$\n"` probes positive on
9505        // both arms (`starts_with('$')` and contains LF), but the
9506        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9507        // wins so the author sees the more self-locating shell-
9508        // expansion arm first. Mirrors the
9509        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9510        // discipline on the immediate-predecessor arm.
9511        let d = dep_with_fonte(DepSource::Path {
9512            caminho: "$HOME\n".into(),
9513        });
9514        let err = d.validate().unwrap_err();
9515        assert!(
9516            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9517            "got {err:?}",
9518        );
9519    }
9520
9521    #[test]
9522    fn validate_rejects_path_fonte_with_leading_space_caminho() {
9523        // The fail-before-pass-after pin for the leading ASCII space
9524        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9525        // Until this gate landed the b94fd83 absolute arm + the a5c248e
9526        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9527        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9528        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9529        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9530        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9531        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9532        // are caught, but the most common whitespace `0x20` space is
9533        // not). The lacre embedded the value verbatim and the resolver
9534        // folded it through `Path::join` looking for a literal `./ ../
9535        // caixa-teia` subdirectory and failing at resolve time with a
9536        // non-self-locating `No such file or directory` error far from
9537        // the source caixa.lisp. The new gate moves the check to
9538        // validate time and names the offending dep + caminho verbatim.
9539        let d = dep_with_fonte(DepSource::Path {
9540            caminho: " ../caixa-teia".into(),
9541        });
9542        let err = d.validate().unwrap_err();
9543        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9544            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9545        };
9546        assert_eq!(nome, "caixa-teia");
9547        assert_eq!(caminho, " ../caixa-teia");
9548    }
9549
9550    #[test]
9551    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9552        // The aligned-doc paste footgun sweep: more than one leading
9553        // space (`"   ../caixa-teia"` — the canonical "I selected the
9554        // aligned column from a four-`:fonte`-entry `:deps` block"
9555        // paste) routes through the same gate's `starts_with(' ')`
9556        // byte check. Pinned so the gate doesn't narrow to a
9557        // single-space prefix.
9558        let d = dep_with_fonte(DepSource::Path {
9559            caminho: "   ../caixa-teia".into(),
9560        });
9561        let err = d.validate().unwrap_err();
9562        assert!(
9563            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9564            "got {err:?}",
9565        );
9566    }
9567
9568    #[test]
9569    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9570        // The leading-space is the canonical paste-from-aligned-doc
9571        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9572        // canonical "I have a directory with a space in its name"
9573        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9574        // legitimate path with no whitespace-leak semantic at the
9575        // non-leading position. Pinned so the gate doesn't widen to a
9576        // full no-space-anywhere sweep that would break every
9577        // legitimate-shape space-in-filename path.
9578        let d = dep_with_fonte(DepSource::Path {
9579            caminho: "../my dir/caixa-teia".into(),
9580        });
9581        d.validate().unwrap();
9582    }
9583
9584    #[test]
9585    fn fonte_caminho_var_fires_before_leading_whitespace() {
9586        // Cascade pin: the var-expansion arm structurally precedes the
9587        // leading-whitespace arm. A value like `"$ "` would probe positive
9588        // on var (`starts_with('$')`) but the leading-byte arms walk
9589        // left-to-right so the var arm fires on the leading `$` before
9590        // the leading-whitespace arm probes. Mirrors the
9591        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9592        // discipline on the immediate-predecessor arms.
9593        let d = dep_with_fonte(DepSource::Path {
9594            caminho: "$VAR".into(),
9595        });
9596        let err = d.validate().unwrap_err();
9597        assert!(
9598            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9599            "got {err:?}",
9600        );
9601    }
9602
9603    #[test]
9604    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9605        // Cascade pin: the leading-whitespace arm structurally precedes
9606        // the control-char arm. A value like `" ../foo\n"` probes
9607        // positive on both (starts with space AND contains LF), but
9608        // the narrower leading-byte diagnostic
9609        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9610        // more self-locating paste-from-aligned-doc arm first. Mirrors
9611        // the `fonte_caminho_var_fires_before_control_char` cascade
9612        // discipline on the immediate-predecessor arm.
9613        let d = dep_with_fonte(DepSource::Path {
9614            caminho: " ../foo\n".into(),
9615        });
9616        let err = d.validate().unwrap_err();
9617        assert!(
9618            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9619            "got {err:?}",
9620        );
9621    }
9622
9623    #[test]
9624    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9625        // Diagnostic-shape pin (peer with
9626        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9627        // payload assertion on the immediate-predecessor arm): the
9628        // error's Display surfaces both the offending `:nome` and the
9629        // offending `:caminho` verbatim, so a `feira lint` run can
9630        // render the diagnostic without re-parsing and the author can
9631        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9632        // one edit.
9633        let d = dep_with_fonte(DepSource::Path {
9634            caminho: " ../caixa-teia".into(),
9635        });
9636        let rendered = d.validate().unwrap_err().to_string();
9637        assert!(
9638            rendered.contains("caixa-teia"),
9639            "diagnostic must name the offending dep: {rendered}",
9640        );
9641        assert!(
9642            rendered.contains(" ../caixa-teia"),
9643            "diagnostic must quote the offending caminho: {rendered}",
9644        );
9645        assert!(
9646            rendered.contains("space"),
9647            "diagnostic must name the space footgun: {rendered}",
9648        );
9649    }
9650
9651    #[test]
9652    fn fonte_caminho_absolute_fires_before_control_char() {
9653        // Cascade pin on the sibling leading-byte arm: a leading `/`
9654        // value with embedded control byte (`"/etc/passwd\n"`) routes
9655        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9656        // — the host-layout-leak diagnostic is the load-bearing axis,
9657        // the control byte is the secondary observation. Same precedence
9658        // logic on every prior leading-byte arm.
9659        let d = dep_with_fonte(DepSource::Path {
9660            caminho: "/etc/passwd\n".into(),
9661        });
9662        let err = d.validate().unwrap_err();
9663        assert!(
9664            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9665            "got {err:?}",
9666        );
9667    }
9668
9669    #[test]
9670    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9671        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9672        // injection `:caminho` shape sweep. Until this gate landed
9673        // every prior leading-byte arm passed a leading-`-` value
9674        // through: `Path::is_absolute` returns false on `-` (the
9675        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9676        // `starts_with('$')` / `starts_with(' ')` all return false,
9677        // and `0x2D` sits outside the control-byte set. The lacre
9678        // embedded the value verbatim and the resolver folded it
9679        // through `Path::join` looking for a literal `./-rf` /
9680        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9681        // `Path::join` time is non-self-locating but harmless, while
9682        // the failure at every downstream `git -C {caminho}` /
9683        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9684        // is arbitrary-CLI-arg-injection because none of those
9685        // porcelains carry a `--` argument-list terminator between
9686        // the flag block and the path argument. The new arm moves the
9687        // rejection to `Caixa::from_lisp` boundary time and names
9688        // the offending dep + caminho verbatim.
9689        //
9690        // Sweep spans the canonical CLI-arg-injection shapes matching
9691        // the peer sweep on the sibling `is_git_ref_name` /
9692        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9693        // `find -rf` reinterpretation vector), `-C` (the `git -C`
9694        // change-directory-config-injection paste), long-flag
9695        // `--upload-pack=cat /etc/passwd` (the canonical
9696        // arbitrary-command-execution vector on every git porcelain
9697        // entry point), git-config-injection `--config=core.merge=ours`,
9698        // and the degenerate single-byte `-` value.
9699        for caminho in [
9700            "-rf",
9701            "-C",
9702            "--upload-pack=cat /etc/passwd",
9703            "--config=core.merge=ours",
9704            "-",
9705        ] {
9706            let d = dep_with_fonte(DepSource::Path {
9707                caminho: caminho.into(),
9708            });
9709            let err = d.validate().unwrap_err();
9710            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9711                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9712            };
9713            assert_eq!(nome, "caixa-teia");
9714            assert_eq!(got, caminho);
9715        }
9716    }
9717
9718    #[test]
9719    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9720        // The leading-`-` is the canonical CLI-arg-injection footgun
9721        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9722        // canonical kebab-separator-between-alphanumeric-segments
9723        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9724        // — a mid-path segment starting with `-`, still a legitimate
9725        // POSIX filename byte at that non-leading position because the
9726        // subprocess reads the whole `{caminho}` value as one positional
9727        // argument, so only the very first byte of the composite path
9728        // string is at the CLI-arg-injection boundary) is a legitimate
9729        // path with no CLI-flag-reinterpretation semantic at the non-
9730        // leading position of the top-level value. Pinned so the gate
9731        // doesn't widen to a full no-`-`-anywhere sweep that would
9732        // break every legitimate-shape kebab-in-filename path (i.e.
9733        // essentially every sibling-workspace caixa dep).
9734        for caminho in [
9735            "../caixa-teia",
9736            "../caixa-teia/-hidden",
9737            "./my-lib",
9738            "../foo-bar/baz",
9739        ] {
9740            let d = dep_with_fonte(DepSource::Path {
9741                caminho: caminho.into(),
9742            });
9743            d.validate()
9744                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9745        }
9746    }
9747
9748    #[test]
9749    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9750        // Cascade pin: the leading-whitespace arm structurally precedes
9751        // the leading-hyphen arm. A value like `" -rf"` probes positive
9752        // on both (leading space AND, one byte in, a `-` — though the
9753        // leading-hyphen arm probes only the very first byte so it
9754        // wouldn't fire on this value; the pin instead documents the
9755        // arm order on the more common "leading space then a hyphen"
9756        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9757        // The narrower leading-space diagnostic (the paste-from-aligned-
9758        // doc footgun) wins so the author sees the more self-locating
9759        // whitespace arm first. Mirrors the
9760        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9761        // discipline on the immediate-predecessor arm.
9762        let d = dep_with_fonte(DepSource::Path {
9763            caminho: " -rf".into(),
9764        });
9765        let err = d.validate().unwrap_err();
9766        assert!(
9767            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9768            "got {err:?}",
9769        );
9770    }
9771
9772    #[test]
9773    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9774        // Cascade pin: the leading-hyphen arm structurally precedes
9775        // the control-char arm. A value like `"-rf\n"` probes positive
9776        // on both (starts with `-` AND contains LF), but the narrower
9777        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9778        // the author sees the more self-locating CLI-arg-injection arm
9779        // first. Mirrors the
9780        // `fonte_caminho_leading_whitespace_fires_before_control_char`
9781        // cascade discipline on the immediate-predecessor arm.
9782        let d = dep_with_fonte(DepSource::Path {
9783            caminho: "-rf\n".into(),
9784        });
9785        let err = d.validate().unwrap_err();
9786        assert!(
9787            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9788            "got {err:?}",
9789        );
9790    }
9791
9792    #[test]
9793    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9794        // Diagnostic-shape pin (peer with
9795        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9796        // payload assertion on the immediate-predecessor arm): the
9797        // error's Display surfaces both the offending `:nome` and the
9798        // offending `:caminho` verbatim plus the CLI-argument-injection
9799        // vocabulary, so a `feira lint` run can render the diagnostic
9800        // without re-parsing and the author can grep their caixa.lisp
9801        // for `:caminho "<value>"` and fix it in one edit.
9802        let d = dep_with_fonte(DepSource::Path {
9803            caminho: "--upload-pack=cat /etc/passwd".into(),
9804        });
9805        let rendered = d.validate().unwrap_err().to_string();
9806        assert!(
9807            rendered.contains("caixa-teia"),
9808            "diagnostic must name the offending dep: {rendered}",
9809        );
9810        assert!(
9811            rendered.contains("--upload-pack=cat /etc/passwd"),
9812            "diagnostic must quote the offending caminho: {rendered}",
9813        );
9814        assert!(
9815            rendered.contains("CLI-argument-injection"),
9816            "diagnostic must name the CLI-argument-injection vector: {rendered}",
9817        );
9818        assert!(
9819            rendered.contains("`-`"),
9820            "diagnostic must name the offending byte: {rendered}",
9821        );
9822    }
9823
9824    #[test]
9825    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9826        // Diagnostic-shape pin (peer with
9827        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9828        // payload assertion on the immediate-predecessor arm): the
9829        // error's Display surfaces the offending `:nome`, the
9830        // offending `:caminho` verbatim, and the offending byte in
9831        // hex form (`0x09` for tab) so a `feira lint` run can render
9832        // the diagnostic without re-parsing.
9833        let d = dep_with_fonte(DepSource::Path {
9834            caminho: "../caixa\tteia".into(),
9835        });
9836        let rendered = d.validate().unwrap_err().to_string();
9837        assert!(
9838            rendered.contains("caixa-teia"),
9839            "diagnostic must name the offending dep: {rendered}",
9840        );
9841        assert!(
9842            rendered.contains("../caixa\tteia"),
9843            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9844        );
9845        assert!(
9846            rendered.contains("0x09"),
9847            "diagnostic must name the offending byte in hex: {rendered:?}",
9848        );
9849    }
9850
9851    #[test]
9852    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9853        // The fail-before-pass-after pin for the canonical Windows-
9854        // path-separator paste footgun: an author who pastes a path
9855        // from Windows-Explorer's `Copy as path`, PowerShell's
9856        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9857        // produces `..\caixa-teia`-shape values that silently passed
9858        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9859        // false; `\` is neither a leading-byte sentinel nor a
9860        // control byte). On POSIX resolvers the value rides through
9861        // `Path::join` as a literal directory name and fails at
9862        // resolve time with `No such file or directory`; on Windows
9863        // resolvers the value resolves to the parent's sibling — two
9864        // distinct directories for the byte-identical caixa.lisp.
9865        // The new arm moves the rejection to validate time and names
9866        // the offending dep + caminho verbatim.
9867        let d = dep_with_fonte(DepSource::Path {
9868            caminho: "..\\caixa-teia".into(),
9869        });
9870        let err = d.validate().unwrap_err();
9871        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9872            panic!("expected FonteCaminhoBackslash, got {err:?}");
9873        };
9874        assert_eq!(nome, "caixa-teia");
9875        assert_eq!(caminho, "..\\caixa-teia");
9876    }
9877
9878    #[test]
9879    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9880        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9881        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9882        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9883        // false (POSIX absolute paths start with `/`, drive letters
9884        // are not a POSIX concept), so the b94fd83 absolute arm
9885        // doesn't fire; the value contains `\` bytes that this arm
9886        // now catches with the more self-locating Windows-path-
9887        // separator diagnostic. Pinned separately from the bare
9888        // `..\caixa-teia` shape so a future arm that targets only
9889        // leading-`..\` doesn't regress the drive-letter coverage.
9890        let d = dep_with_fonte(DepSource::Path {
9891            caminho: "C:\\work\\caixa-teia".into(),
9892        });
9893        let err = d.validate().unwrap_err();
9894        assert!(
9895            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9896            "got {err:?}",
9897        );
9898    }
9899
9900    #[test]
9901    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9902        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9903        // PowerShell tab-completion-on-a-directory append). Pinned
9904        // separately from the embedded-`\` shape so the gate's
9905        // contract is "any `\` anywhere", not "any `\` not at end".
9906        let d = dep_with_fonte(DepSource::Path {
9907            caminho: "..\\caixa-teia\\".into(),
9908        });
9909        let err = d.validate().unwrap_err();
9910        assert!(
9911            matches!(err, DepError::FonteCaminhoBackslash { .. }),
9912            "got {err:?}",
9913        );
9914    }
9915
9916    #[test]
9917    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9918        // The positive-control pin: the gate targets `\` only,
9919        // never `/`. The canonical relative POSIX path
9920        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9921        // so legitimate nested-directory deps aren't broken. Pinned
9922        // so the gate doesn't accidentally widen to a "no path
9923        // separators at all" sweep.
9924        let d = dep_with_fonte(DepSource::Path {
9925            caminho: "../caixa-teia/foo/bar".into(),
9926        });
9927        d.validate().unwrap();
9928    }
9929
9930    #[test]
9931    fn fonte_caminho_control_char_fires_before_backslash() {
9932        // Cascade pin: the control-char arm structurally precedes the
9933        // backslash arm. A value like `"..\caixa\0teia"` probes
9934        // positive on both (`\` byte + NUL byte), but the control-
9935        // char diagnostic wins so the author sees the more self-
9936        // locating POSIX-syscall-rejected-byte diagnostic first
9937        // (NUL outright breaks `CString::new` at every `std::fs`
9938        // syscall boundary; the `\` divergence is the cross-OS-
9939        // separator axis). Mirrors the
9940        // `fonte_caminho_var_fires_before_control_char` cascade
9941        // discipline on the immediate-predecessor arm.
9942        let d = dep_with_fonte(DepSource::Path {
9943            caminho: "..\\caixa\0teia".into(),
9944        });
9945        let err = d.validate().unwrap_err();
9946        assert!(
9947            matches!(err, DepError::FonteCaminhoControlChar { .. }),
9948            "got {err:?}",
9949        );
9950    }
9951
9952    #[test]
9953    fn fonte_caminho_absolute_fires_before_backslash() {
9954        // Cascade pin on the load-bearing leading-byte arm: a leading
9955        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9956        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9957        // — the host-layout-leak diagnostic is the load-bearing
9958        // axis, the `\` byte is the secondary observation. Same
9959        // precedence logic as every prior leading-byte arm.
9960        let d = dep_with_fonte(DepSource::Path {
9961            caminho: "/etc/passwd\\foo".into(),
9962        });
9963        let err = d.validate().unwrap_err();
9964        assert!(
9965            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9966            "got {err:?}",
9967        );
9968    }
9969
9970    #[test]
9971    fn fonte_caminho_var_fires_before_backslash() {
9972        // Cascade pin on the var-expansion arm: a leading-`$` value
9973        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9974        // PowerShell-env-var paste-from-CI-manifest footgun) routes
9975        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9976        // The shell-expansion diagnostic is the more self-locating
9977        // axis since both the leading `$` and the embedded `\`
9978        // are Windows-shell artifacts but the `$` is the root-cause
9979        // surface (an author who removes the `$` is likely to leave
9980        // the `\` too).
9981        let d = dep_with_fonte(DepSource::Path {
9982            caminho: "$WORKSPACE\\caixa-teia".into(),
9983        });
9984        let err = d.validate().unwrap_err();
9985        assert!(
9986            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9987            "got {err:?}",
9988        );
9989    }
9990
9991    #[test]
9992    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9993        // Diagnostic-shape pin (peer with the prior
9994        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9995        // on every preceding arm): the error's Display surfaces the
9996        // offending `:nome` and the offending `:caminho` verbatim
9997        // so a `feira lint` run can render the diagnostic without
9998        // re-parsing.
9999        let d = dep_with_fonte(DepSource::Path {
10000            caminho: "..\\caixa-teia".into(),
10001        });
10002        let rendered = d.validate().unwrap_err().to_string();
10003        assert!(
10004            rendered.contains("caixa-teia"),
10005            "diagnostic must name the offending dep: {rendered}",
10006        );
10007        assert!(
10008            rendered.contains("..\\caixa-teia"),
10009            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10010        );
10011        assert!(
10012            rendered.contains('\\'),
10013            "diagnostic must reference the backslash footgun: {rendered:?}",
10014        );
10015    }
10016
10017    #[test]
10018    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10019        // The fail-before-pass-after pin for the canonical trailing-`/`
10020        // paste footgun: an author who shell-tab-completes a sibling
10021        // directory (every interactive shell — bash/zsh/fish/nushell —
10022        // appends `/` on tab-completing a directory) produces
10023        // `"../caixa-teia/"`-shape values that silently passed every
10024        // prior arm (the leading byte is `.`, no control bytes, no
10025        // backslash). `Path::join` resolves both shapes to the same
10026        // directory at the resolver, but the lacre embeds the value
10027        // verbatim and the BLAKE3 closures diverge across two
10028        // workstations whose authors differ only in tab-completion
10029        // habits.
10030        let d = dep_with_fonte(DepSource::Path {
10031            caminho: "../caixa-teia/".into(),
10032        });
10033        let err = d.validate().unwrap_err();
10034        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10035            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10036        };
10037        assert_eq!(nome, "caixa-teia");
10038        assert_eq!(caminho, "../caixa-teia/");
10039    }
10040
10041    #[test]
10042    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10043        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10044        // directory and tab-completed it" footgun). Pinned separately
10045        // from the canonical `"../caixa-teia/"` shape so the gate's
10046        // contract is "any trailing `/`", not "trailing `/` after a leaf
10047        // name".
10048        let d = dep_with_fonte(DepSource::Path {
10049            caminho: "./".into(),
10050        });
10051        let err = d.validate().unwrap_err();
10052        assert!(
10053            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10054            "got {err:?}",
10055        );
10056    }
10057
10058    #[test]
10059    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10060        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10061        // that double-templated `${VAR}/` over an already-`/`-suffixed
10062        // path" footgun). The gate fires on the last byte being `/`
10063        // regardless of how many `/` precede it; the arm contract is
10064        // "the value ends with `/`", structurally.
10065        let d = dep_with_fonte(DepSource::Path {
10066            caminho: "../caixa-teia//".into(),
10067        });
10068        let err = d.validate().unwrap_err();
10069        assert!(
10070            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10071            "got {err:?}",
10072        );
10073    }
10074
10075    #[test]
10076    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10077        // The `"../"` shape (the canonical "I want the parent" tab-
10078        // completion footgun on a bare `..` path). Pinned separately so
10079        // the gate doesn't accidentally narrow to "trailing `/` only on
10080        // multi-segment paths".
10081        let d = dep_with_fonte(DepSource::Path {
10082            caminho: "../".into(),
10083        });
10084        let err = d.validate().unwrap_err();
10085        assert!(
10086            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10087            "got {err:?}",
10088        );
10089    }
10090
10091    #[test]
10092    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10093        // The positive-control pin: the gate targets the trailing byte
10094        // only, never internal `/` separators. The canonical nested
10095        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10096        // to validate cleanly so legitimate deeply-nested deps aren't
10097        // broken. Pinned so the gate doesn't accidentally widen to a
10098        // "no `/` separators anywhere" sweep that would defeat the
10099        // entire path-fonte author surface.
10100        let d = dep_with_fonte(DepSource::Path {
10101            caminho: "../caixa-teia/foo/bar".into(),
10102        });
10103        d.validate().unwrap();
10104    }
10105
10106    #[test]
10107    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10108        // The positive-control pin on the degenerate single-`.` shape
10109        // (the canonical "the caixa.lisp's own directory" idiom). The
10110        // gate fires on the trailing byte being `/`, not on the path
10111        // being short, so `"."` (one byte, not `/`) must continue to
10112        // validate cleanly.
10113        let d = dep_with_fonte(DepSource::Path {
10114            caminho: ".".into(),
10115        });
10116        d.validate().unwrap();
10117    }
10118
10119    #[test]
10120    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10121        // Cascade pin: the control-char arm structurally precedes the
10122        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10123        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10124        // (control bytes are the paste-from-multiline-doc footgun the
10125        // d624c8d arm already closes). Mirrors the
10126        // `fonte_caminho_control_char_fires_before_backslash` cascade
10127        // discipline on the immediate-predecessor arm.
10128        let d = dep_with_fonte(DepSource::Path {
10129            caminho: "../foo\n/".into(),
10130        });
10131        let err = d.validate().unwrap_err();
10132        assert!(
10133            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10134            "got {err:?}",
10135        );
10136    }
10137
10138    #[test]
10139    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10140        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10141        // ends in `/` but the embedded `\` is the load-bearing
10142        // diagnostic (the cross-host-OS-separator divergence vector
10143        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10144        // narrower-diagnostic-first cascade.
10145        let d = dep_with_fonte(DepSource::Path {
10146            caminho: "..\\caixa-teia/".into(),
10147        });
10148        let err = d.validate().unwrap_err();
10149        assert!(
10150            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10151            "got {err:?}",
10152        );
10153    }
10154
10155    #[test]
10156    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10157        // Cascade pin on the load-bearing leading-byte arm: a leading
10158        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10159        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10160        // — the host-layout-leak diagnostic is the load-bearing axis,
10161        // the trailing `/` is the secondary observation. Same
10162        // precedence logic as every prior leading-byte arm.
10163        let d = dep_with_fonte(DepSource::Path {
10164            caminho: "/etc/passwd/".into(),
10165        });
10166        let err = d.validate().unwrap_err();
10167        assert!(
10168            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10169            "got {err:?}",
10170        );
10171    }
10172
10173    #[test]
10174    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10175        // Diagnostic-shape pin (peer with the prior
10176        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10177        // every preceding arm): the error's Display surfaces the
10178        // offending `:nome` and the offending `:caminho` verbatim so a
10179        // `feira lint` run can render the diagnostic without re-parsing.
10180        let d = dep_with_fonte(DepSource::Path {
10181            caminho: "../caixa-teia/".into(),
10182        });
10183        let rendered = d.validate().unwrap_err().to_string();
10184        assert!(
10185            rendered.contains("caixa-teia"),
10186            "diagnostic must name the offending dep: {rendered}",
10187        );
10188        assert!(
10189            rendered.contains("../caixa-teia/"),
10190            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10191        );
10192        assert!(
10193            rendered.contains("trailing"),
10194            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10195        );
10196    }
10197
10198    // -- :caminho shell-redirection metacharacter arm -----------------------
10199
10200    #[test]
10201    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10202        // The fail-before-pass-after pin for the canonical output-redirection
10203        // paste footgun: an author copies a shell pipeline tail
10204        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10205        // line including the `> build.log` redirect" idiom) and silently
10206        // passed every prior arm (`Path::is_absolute` false on `..`, no
10207        // control bytes, no backslash, doesn't end in `/`). The lacre
10208        // embedded the value verbatim, the resolver folded it through
10209        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10210        // subdirectory, and the failure surfaced at resolve time with a
10211        // non-self-locating `No such file or directory` error. The new arm
10212        // moves the rejection to validate time and names the offending dep
10213        // + caminho + byte verbatim.
10214        let d = dep_with_fonte(DepSource::Path {
10215            caminho: "../caixa-teia>build.log".into(),
10216        });
10217        let err = d.validate().unwrap_err();
10218        let DepError::FonteCaminhoShellRedirection {
10219            nome,
10220            caminho,
10221            byte,
10222        } = err
10223        else {
10224            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10225        };
10226        assert_eq!(nome, "caixa-teia");
10227        assert_eq!(caminho, "../caixa-teia>build.log");
10228        assert_eq!(byte, b'>');
10229    }
10230
10231    #[test]
10232    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10233        // The symmetric input-redirection paste shape
10234        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10235        // `command < input.lisp` line from a tatara-lisp REPL log"
10236        // idiom). Pinned separately from the `>` shape so the gate's
10237        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10238        let d = dep_with_fonte(DepSource::Path {
10239            caminho: "../caixa-teia<input.lisp".into(),
10240        });
10241        let err = d.validate().unwrap_err();
10242        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10243            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10244        };
10245        assert_eq!(byte, b'<');
10246    }
10247
10248    #[test]
10249    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10250        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10251        // "I forgot the source side of the redirect" idiom). Pinned
10252        // separately from the embedded-byte shapes so the gate covers
10253        // every position, not only mid-path.
10254        let d = dep_with_fonte(DepSource::Path {
10255            caminho: ">../caixa-teia".into(),
10256        });
10257        let err = d.validate().unwrap_err();
10258        assert!(
10259            matches!(
10260                err,
10261                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10262            ),
10263            "got {err:?}",
10264        );
10265    }
10266
10267    #[test]
10268    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10269        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10270        // the canonical "I copied a `>>` append redirect" idiom). The arm
10271        // fires on the first `>` encountered; pinned so a future arm that
10272        // tries to distinguish `>` from `>>` doesn't break the broader
10273        // contract.
10274        let d = dep_with_fonte(DepSource::Path {
10275            caminho: "../caixa-teia>>build.log".into(),
10276        });
10277        let err = d.validate().unwrap_err();
10278        assert!(
10279            matches!(
10280                err,
10281                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10282            ),
10283            "got {err:?}",
10284        );
10285    }
10286
10287    #[test]
10288    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10289        // The positive-control pin: the gate targets only `<` / `>`,
10290        // never adjacent printable ASCII or POSIX-valid bytes. The
10291        // canonical relative POSIX path (`"../caixa-teia"`) and a
10292        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10293        // continue to validate cleanly so the gate doesn't widen to a
10294        // "no printable punctuation anywhere" sweep that would defeat
10295        // the entire path-fonte author surface.
10296        let d = dep_with_fonte(DepSource::Path {
10297            caminho: "../caixa-teia/foo/bar".into(),
10298        });
10299        d.validate().unwrap();
10300    }
10301
10302    #[test]
10303    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10304        // Cascade pin on the immediate-predecessor arm: a value carrying
10305        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10306        // canonical "I pasted a Windows-shell command with output
10307        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10308        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10309        // divergence is the load-bearing axis (an author who removes
10310        // the `\` is the root-cause edit; the `>` falls away in the
10311        // same edit since it's downstream of the Windows-shell
10312        // convention).
10313        let d = dep_with_fonte(DepSource::Path {
10314            caminho: "..\\caixa-teia>build.log".into(),
10315        });
10316        let err = d.validate().unwrap_err();
10317        assert!(
10318            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10319            "got {err:?}",
10320        );
10321    }
10322
10323    #[test]
10324    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10325        // Cascade pin on the embedded-control-byte arm: a value carrying
10326        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10327        // canonical paste-from-multiline-doc footgun where a newline
10328        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10329        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10330        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10331        // load-bearing axis on every value that probes positive for
10332        // both — mirrors the cascade discipline on every prior arm.
10333        let d = dep_with_fonte(DepSource::Path {
10334            caminho: "../foo\n>bar".into(),
10335        });
10336        let err = d.validate().unwrap_err();
10337        assert!(
10338            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10339            "got {err:?}",
10340        );
10341    }
10342
10343    #[test]
10344    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10345        // Cascade pin on the load-bearing leading-byte arm: a leading
10346        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10347        // routes through `FonteCaminhoAbsolute` not
10348        // `FonteCaminhoShellRedirection` — the host-layout-leak
10349        // diagnostic is the load-bearing axis, the `>` byte is the
10350        // secondary observation. Same precedence logic as every prior
10351        // leading-byte arm.
10352        let d = dep_with_fonte(DepSource::Path {
10353            caminho: "/etc/passwd>out".into(),
10354        });
10355        let err = d.validate().unwrap_err();
10356        assert!(
10357            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10358            "got {err:?}",
10359        );
10360    }
10361
10362    #[test]
10363    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10364        // Cascade pin on the immediate-successor arm: a value carrying
10365        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10366        // canonical "I tab-completed a path that already had a
10367        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10368        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10369        // the more semantic-locating axis (an author who removes the
10370        // `<` / `>` typically also drops the trailing separator since
10371        // both are paste-from-shell artifacts).
10372        let d = dep_with_fonte(DepSource::Path {
10373            caminho: "../foo></".into(),
10374        });
10375        let err = d.validate().unwrap_err();
10376        assert!(
10377            matches!(
10378                err,
10379                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10380            ),
10381            "got {err:?}",
10382        );
10383    }
10384
10385    #[test]
10386    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10387        // Diagnostic-shape pin (peer with
10388        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10389        // payload assertion on the closest peer arm that also carries a
10390        // `byte` field): the error's Display surfaces the offending
10391        // `:nome`, the offending `:caminho` verbatim, and the offending
10392        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10393        // run can render the diagnostic without re-parsing.
10394        let d = dep_with_fonte(DepSource::Path {
10395            caminho: "../caixa-teia>build.log".into(),
10396        });
10397        let rendered = d.validate().unwrap_err().to_string();
10398        assert!(
10399            rendered.contains("caixa-teia"),
10400            "diagnostic must name the offending dep: {rendered}",
10401        );
10402        assert!(
10403            rendered.contains("../caixa-teia>build.log"),
10404            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10405        );
10406        assert!(
10407            rendered.contains("0x3e"),
10408            "diagnostic must name the offending byte in hex: {rendered:?}",
10409        );
10410        assert!(
10411            rendered.contains("redirection"),
10412            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10413        );
10414    }
10415
10416    // -- :caminho shell-pipe metacharacter arm ----------------------------
10417
10418    #[test]
10419    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10420        // The fail-before-pass-after pin for the canonical shell-pipe
10421        // paste footgun: an author copies a shell-history line
10422        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10423        // the whole `ls dir | grep` line out of zsh history") and
10424        // silently passed every prior arm (`Path::is_absolute` false
10425        // on `..`, no control bytes, no backslash, no `<` / `>`,
10426        // doesn't end in `/`). The lacre embedded the value verbatim,
10427        // the resolver folded it through `Path::join` looking for a
10428        // literal `./../caixa-teia | grep foo` subdirectory, and the
10429        // failure surfaced at resolve time with a non-self-locating
10430        // `No such file or directory` error. The new arm moves the
10431        // rejection to validate time and names the offending dep +
10432        // caminho verbatim.
10433        let d = dep_with_fonte(DepSource::Path {
10434            caminho: "../caixa-teia | grep foo".into(),
10435        });
10436        let err = d.validate().unwrap_err();
10437        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10438            panic!("expected FonteCaminhoShellPipe, got {err:?}");
10439        };
10440        assert_eq!(nome, "caixa-teia");
10441        assert_eq!(caminho, "../caixa-teia | grep foo");
10442    }
10443
10444    #[test]
10445    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10446        // Leading-position `|` shape (`"|../caixa-teia"` — the
10447        // degenerate "I forgot the source side of the pipe" idiom).
10448        // Pinned separately from the embedded-byte shape so the gate
10449        // covers every position, not only mid-path.
10450        let d = dep_with_fonte(DepSource::Path {
10451            caminho: "|../caixa-teia".into(),
10452        });
10453        let err = d.validate().unwrap_err();
10454        assert!(
10455            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10456            "got {err:?}",
10457        );
10458    }
10459
10460    #[test]
10461    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10462        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10463        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10464        // idiom). The arm fires on the first `|` encountered; pinned
10465        // so a future arm that tries to distinguish `|` from `||`
10466        // doesn't break the broader contract.
10467        let d = dep_with_fonte(DepSource::Path {
10468            caminho: "../caixa-teia||fallback".into(),
10469        });
10470        let err = d.validate().unwrap_err();
10471        assert!(
10472            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10473            "got {err:?}",
10474        );
10475    }
10476
10477    #[test]
10478    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10479        // The positive-control pin: the gate targets only `|`, never
10480        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10481        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10482        // pathed variant with adjacent printable punctuation
10483        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10484        // cleanly so the gate doesn't widen to a "no printable
10485        // punctuation anywhere" sweep that would defeat the entire
10486        // path-fonte author surface.
10487        let d = dep_with_fonte(DepSource::Path {
10488            caminho: "../caixa-teia/sub-dir.v2".into(),
10489        });
10490        d.validate().unwrap();
10491    }
10492
10493    #[test]
10494    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10495        // Cascade pin on the immediate-predecessor arm: a value carrying
10496        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10497        // canonical "I pasted a `cmd < input | tee` pipeline tail"
10498        // footgun) routes through `FonteCaminhoShellRedirection` not
10499        // `FonteCaminhoShellPipe`. The input/output redirection
10500        // metachar carries the more self-locating `byte: u8` payload
10501        // (it names which of `<` or `>` triggered), so the prior arm
10502        // wins on every probe-as-both value — same cascade discipline
10503        // every prior `:caminho` arm establishes.
10504        let d = dep_with_fonte(DepSource::Path {
10505            caminho: "../caixa-teia<input|tee".into(),
10506        });
10507        let err = d.validate().unwrap_err();
10508        assert!(
10509            matches!(
10510                err,
10511                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10512            ),
10513            "got {err:?}",
10514        );
10515    }
10516
10517    #[test]
10518    fn fonte_caminho_backslash_fires_before_shell_pipe() {
10519        // Cascade pin on the upstream backslash arm: a value carrying
10520        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10521        // "I pasted a Windows-shell command with pipe to tee"
10522        // footgun) routes through `FonteCaminhoBackslash` not
10523        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10524        // divergence is the load-bearing axis on every probe-as-both
10525        // value (an author who removes the `\` is the root-cause edit;
10526        // the `|` falls away in the same edit since it's downstream of
10527        // the Windows-shell convention).
10528        let d = dep_with_fonte(DepSource::Path {
10529            caminho: "..\\caixa-teia|tee".into(),
10530        });
10531        let err = d.validate().unwrap_err();
10532        assert!(
10533            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10534            "got {err:?}",
10535        );
10536    }
10537
10538    #[test]
10539    fn fonte_caminho_control_char_fires_before_shell_pipe() {
10540        // Cascade pin on the embedded-control-byte arm: a value
10541        // carrying both a control byte and `|` (`"../foo\n|bar"` —
10542        // the canonical paste-from-multiline-doc footgun where a
10543        // newline landed mid-caminho) routes through
10544        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10545        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10546        // diagnostic is the load-bearing axis on every value that
10547        // probes positive for both — mirrors the cascade discipline
10548        // on every prior arm.
10549        let d = dep_with_fonte(DepSource::Path {
10550            caminho: "../foo\n|bar".into(),
10551        });
10552        let err = d.validate().unwrap_err();
10553        assert!(
10554            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10555            "got {err:?}",
10556        );
10557    }
10558
10559    #[test]
10560    fn fonte_caminho_absolute_fires_before_shell_pipe() {
10561        // Cascade pin on the load-bearing leading-byte arm: a leading
10562        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10563        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10564        // — the host-layout-leak diagnostic is the load-bearing axis,
10565        // the `|` byte is the secondary observation. Same precedence
10566        // logic as every prior leading-byte arm.
10567        let d = dep_with_fonte(DepSource::Path {
10568            caminho: "/etc/passwd|tee".into(),
10569        });
10570        let err = d.validate().unwrap_err();
10571        assert!(
10572            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10573            "got {err:?}",
10574        );
10575    }
10576
10577    #[test]
10578    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10579        // Cascade pin on the immediate-successor arm: a value carrying
10580        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10581        // "I tab-completed a path that already had a pipeline tail"
10582        // footgun) routes through `FonteCaminhoShellPipe` not
10583        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10584        // the more semantic-locating axis (an author who removes the
10585        // `|` typically also drops the trailing separator since both
10586        // are paste-from-shell artifacts).
10587        let d = dep_with_fonte(DepSource::Path {
10588            caminho: "../foo|tee/".into(),
10589        });
10590        let err = d.validate().unwrap_err();
10591        assert!(
10592            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10593            "got {err:?}",
10594        );
10595    }
10596
10597    #[test]
10598    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10599        // Diagnostic-shape pin (peer with
10600        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10601        // on the closest single-byte peer arm): the error's Display
10602        // surfaces the offending `:nome` and the offending `:caminho`
10603        // verbatim, and names the shell-pipe footgun explicitly so a
10604        // `feira lint` run can render the diagnostic without
10605        // re-parsing.
10606        let d = dep_with_fonte(DepSource::Path {
10607            caminho: "../caixa-teia | grep foo".into(),
10608        });
10609        let rendered = d.validate().unwrap_err().to_string();
10610        assert!(
10611            rendered.contains("caixa-teia"),
10612            "diagnostic must name the offending dep: {rendered}",
10613        );
10614        assert!(
10615            rendered.contains("../caixa-teia | grep foo"),
10616            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10617        );
10618        assert!(
10619            rendered.contains('|'),
10620            "diagnostic must reference the pipe footgun: {rendered:?}",
10621        );
10622        assert!(
10623            rendered.contains("pipe"),
10624            "diagnostic must name the shell-pipe footgun: {rendered:?}",
10625        );
10626    }
10627
10628    // -- :caminho shell-command-separator metacharacter arm ---------------
10629
10630    #[test]
10631    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10632        // The fail-before-pass-after pin for the canonical shell-command-
10633        // separator paste footgun: an author copies a shell one-liner
10634        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10635        // whole `cd path; do-thing` chain out of a shell-history block")
10636        // and silently passed every prior arm (`Path::is_absolute` false
10637        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10638        // doesn't end in `/`). The lacre embedded the value verbatim, the
10639        // resolver folded it through `Path::join` looking for a literal
10640        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10641        // surfaced at resolve time with a non-self-locating `No such file
10642        // or directory` error. The new arm moves the rejection to validate
10643        // time and names the offending dep + caminho verbatim.
10644        let d = dep_with_fonte(DepSource::Path {
10645            caminho: "../caixa-teia; rm -rf build".into(),
10646        });
10647        let err = d.validate().unwrap_err();
10648        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10649            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10650        };
10651        assert_eq!(nome, "caixa-teia");
10652        assert_eq!(caminho, "../caixa-teia; rm -rf build");
10653    }
10654
10655    #[test]
10656    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10657        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10658        // "I forgot the prior command side of the separator" idiom).
10659        // Pinned separately from the embedded-byte shape so the gate
10660        // covers every position, not only mid-path.
10661        let d = dep_with_fonte(DepSource::Path {
10662            caminho: ";../caixa-teia".into(),
10663        });
10664        let err = d.validate().unwrap_err();
10665        assert!(
10666            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10667            "got {err:?}",
10668        );
10669    }
10670
10671    #[test]
10672    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10673        // The POSIX `case` arm `;;` terminator shape
10674        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10675        // arm tail" idiom). The arm fires on the first `;` encountered;
10676        // pinned so a future arm that tries to distinguish `;` from `;;`
10677        // doesn't break the broader contract.
10678        let d = dep_with_fonte(DepSource::Path {
10679            caminho: "../caixa-teia;;next".into(),
10680        });
10681        let err = d.validate().unwrap_err();
10682        assert!(
10683            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10684            "got {err:?}",
10685        );
10686    }
10687
10688    #[test]
10689    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10690        // The positive-control pin: the gate targets only `;`, never
10691        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10692        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10693        // pathed variant with adjacent printable punctuation
10694        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10695        // cleanly so the gate doesn't widen to a "no printable
10696        // punctuation anywhere" sweep that would defeat the entire
10697        // path-fonte author surface.
10698        let d = dep_with_fonte(DepSource::Path {
10699            caminho: "../caixa-teia/sub-dir.v2".into(),
10700        });
10701        d.validate().unwrap();
10702    }
10703
10704    #[test]
10705    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10706        // Cascade pin on the immediate-predecessor arm: a value carrying
10707        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10708        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10709        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10710        // pipeline-tail paste is the load-bearing root-cause edit on
10711        // every probe-as-both value (an author who removes the `|`
10712        // typically also drops the trailing `; cleanup` since both are
10713        // the same paste-from-shell-history artifact) — same cascade
10714        // discipline every prior `:caminho` arm establishes.
10715        let d = dep_with_fonte(DepSource::Path {
10716            caminho: "../caixa-teia | tee; rm".into(),
10717        });
10718        let err = d.validate().unwrap_err();
10719        assert!(
10720            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10721            "got {err:?}",
10722        );
10723    }
10724
10725    #[test]
10726    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10727        // Cascade pin on the upstream shell-redirection arm: a value
10728        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10729        // the canonical "I pasted a `cmd > log; cleanup` chain"
10730        // footgun) routes through `FonteCaminhoShellRedirection` not
10731        // `FonteCaminhoShellSemicolon`. The input/output redirection
10732        // metachar carries the more self-locating `byte: u8` payload
10733        // (it names which of `<` or `>` triggered), so the prior arm
10734        // wins on every probe-as-both value.
10735        let d = dep_with_fonte(DepSource::Path {
10736            caminho: "../caixa-teia>log; rm".into(),
10737        });
10738        let err = d.validate().unwrap_err();
10739        assert!(
10740            matches!(
10741                err,
10742                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10743            ),
10744            "got {err:?}",
10745        );
10746    }
10747
10748    #[test]
10749    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10750        // Cascade pin on the upstream backslash arm: a value carrying
10751        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10752        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10753        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10754        // The cross-host-OS-separator divergence is the load-bearing axis
10755        // on every probe-as-both value (an author who removes the `\` is
10756        // the root-cause edit; the `;` falls away in the same edit since
10757        // it's downstream of the Windows-shell convention).
10758        let d = dep_with_fonte(DepSource::Path {
10759            caminho: "..\\caixa-teia;rm".into(),
10760        });
10761        let err = d.validate().unwrap_err();
10762        assert!(
10763            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10764            "got {err:?}",
10765        );
10766    }
10767
10768    #[test]
10769    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10770        // Cascade pin on the embedded-control-byte arm: a value carrying
10771        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10772        // paste-from-multiline-doc footgun where a newline landed mid-
10773        // caminho) routes through `FonteCaminhoControlChar` not
10774        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10775        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10776        // on every value that probes positive for both — mirrors the
10777        // cascade discipline on every prior arm.
10778        let d = dep_with_fonte(DepSource::Path {
10779            caminho: "../foo\n;bar".into(),
10780        });
10781        let err = d.validate().unwrap_err();
10782        assert!(
10783            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10784            "got {err:?}",
10785        );
10786    }
10787
10788    #[test]
10789    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10790        // Cascade pin on the load-bearing leading-byte arm: a leading
10791        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10792        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10793        // — the host-layout-leak diagnostic is the load-bearing axis,
10794        // the `;` byte is the secondary observation. Same precedence
10795        // logic as every prior leading-byte arm.
10796        let d = dep_with_fonte(DepSource::Path {
10797            caminho: "/etc/passwd;rm".into(),
10798        });
10799        let err = d.validate().unwrap_err();
10800        assert!(
10801            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10802            "got {err:?}",
10803        );
10804    }
10805
10806    #[test]
10807    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10808        // Cascade pin on the immediate-successor arm: a value carrying
10809        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10810        // "I tab-completed a path that already had a `; cleanup` tail"
10811        // footgun) routes through `FonteCaminhoShellSemicolon` not
10812        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10813        // the more semantic-locating axis (an author who removes the
10814        // `;` typically also drops the trailing separator since both
10815        // are paste-from-shell artifacts).
10816        let d = dep_with_fonte(DepSource::Path {
10817            caminho: "../foo;rm/".into(),
10818        });
10819        let err = d.validate().unwrap_err();
10820        assert!(
10821            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10822            "got {err:?}",
10823        );
10824    }
10825
10826    #[test]
10827    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10828        // Diagnostic-shape pin (peer with
10829        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10830        // on the closest single-byte peer arm): the error's Display
10831        // surfaces the offending `:nome` and the offending `:caminho`
10832        // verbatim, and names the shell-command-separator footgun
10833        // explicitly so a `feira lint` run can render the diagnostic
10834        // without re-parsing.
10835        let d = dep_with_fonte(DepSource::Path {
10836            caminho: "../caixa-teia; rm -rf build".into(),
10837        });
10838        let rendered = d.validate().unwrap_err().to_string();
10839        assert!(
10840            rendered.contains("caixa-teia"),
10841            "diagnostic must name the offending dep: {rendered}",
10842        );
10843        assert!(
10844            rendered.contains("../caixa-teia; rm -rf build"),
10845            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10846        );
10847        assert!(
10848            rendered.contains(';'),
10849            "diagnostic must reference the semicolon footgun: {rendered:?}",
10850        );
10851        assert!(
10852            rendered.contains("command-separator"),
10853            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10854        );
10855    }
10856
10857    #[test]
10858    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10859        // The fail-before-pass-after pin for the canonical shell-
10860        // background-task paste footgun: an author copies a shell one-
10861        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10862        // the whole `cd path & sleep 1` background-launch out of a
10863        // shell-history block") and silently passed every prior arm
10864        // (`Path::is_absolute` false on `..`, no control bytes, no
10865        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10866        // The lacre embedded the value verbatim, the resolver folded it
10867        // through `Path::join` looking for a literal `./../caixa-teia &
10868        // sleep 1` subdirectory, and the failure surfaced at resolve
10869        // time with a non-self-locating `No such file or directory`
10870        // error. The new arm moves the rejection to validate time and
10871        // names the offending dep + caminho verbatim.
10872        let d = dep_with_fonte(DepSource::Path {
10873            caminho: "../caixa-teia & sleep 1".into(),
10874        });
10875        let err = d.validate().unwrap_err();
10876        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10877            panic!("expected FonteCaminhoShellBackground, got {err:?}");
10878        };
10879        assert_eq!(nome, "caixa-teia");
10880        assert_eq!(caminho, "../caixa-teia & sleep 1");
10881    }
10882
10883    #[test]
10884    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10885        // Leading-position `&` shape (`"&../caixa-teia"` — the
10886        // degenerate "I forgot the prior command side of the
10887        // background terminator" idiom). Pinned separately from the
10888        // embedded-byte shape so the gate covers every position, not
10889        // only mid-path.
10890        let d = dep_with_fonte(DepSource::Path {
10891            caminho: "&../caixa-teia".into(),
10892        });
10893        let err = d.validate().unwrap_err();
10894        assert!(
10895            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10896            "got {err:?}",
10897        );
10898    }
10899
10900    #[test]
10901    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10902        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10903        // canonical "I copied a `cd path && make` build chain" idiom
10904        // every Makefile / shell-script wraps). The arm fires on the
10905        // first `&` encountered; pinned so a future arm that tries to
10906        // distinguish `&` from `&&` doesn't break the broader contract.
10907        let d = dep_with_fonte(DepSource::Path {
10908            caminho: "../caixa-teia && make".into(),
10909        });
10910        let err = d.validate().unwrap_err();
10911        assert!(
10912            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10913            "got {err:?}",
10914        );
10915    }
10916
10917    #[test]
10918    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10919        // The positive-control pin: the gate targets only `&`, never
10920        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10921        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10922        // pathed variant with adjacent printable punctuation
10923        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10924        // cleanly so the gate doesn't widen to a "no printable
10925        // punctuation anywhere" sweep that would defeat the entire
10926        // path-fonte author surface.
10927        let d = dep_with_fonte(DepSource::Path {
10928            caminho: "../caixa-teia/sub-dir.v2".into(),
10929        });
10930        d.validate().unwrap();
10931    }
10932
10933    #[test]
10934    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10935        // Cascade pin on the immediate-predecessor arm: a value carrying
10936        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10937        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10938        // routes through `FonteCaminhoShellSemicolon` not
10939        // `FonteCaminhoShellBackground`. The sequential-command-
10940        // separator paste is the more common shell-history paste idiom
10941        // on every probe-as-both value (an author who removes the `;`
10942        // typically also drops the trailing `& sleep` since both are
10943        // paste-from-shell-history artifacts) — same cascade discipline
10944        // every prior `:caminho` arm establishes.
10945        let d = dep_with_fonte(DepSource::Path {
10946            caminho: "../caixa-teia; rm & sleep".into(),
10947        });
10948        let err = d.validate().unwrap_err();
10949        assert!(
10950            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10951            "got {err:?}",
10952        );
10953    }
10954
10955    #[test]
10956    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10957        // Cascade pin on the upstream shell-pipe arm: a value carrying
10958        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10959        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10960        // chain" footgun) routes through `FonteCaminhoShellPipe` not
10961        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10962        // load-bearing root-cause edit on every probe-as-both value.
10963        let d = dep_with_fonte(DepSource::Path {
10964            caminho: "../caixa-teia | tee & sleep".into(),
10965        });
10966        let err = d.validate().unwrap_err();
10967        assert!(
10968            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10969            "got {err:?}",
10970        );
10971    }
10972
10973    #[test]
10974    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10975        // Cascade pin on the upstream shell-redirection arm: a value
10976        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10977        // the canonical "I pasted a `cmd > log & sleep` background-
10978        // redirect chain" footgun) routes through
10979        // `FonteCaminhoShellRedirection` not
10980        // `FonteCaminhoShellBackground`. The input/output redirection
10981        // metachar carries the more self-locating `byte: u8` payload
10982        // (it names which of `<` or `>` triggered), so the prior arm
10983        // wins on every probe-as-both value.
10984        let d = dep_with_fonte(DepSource::Path {
10985            caminho: "../caixa-teia>log & sleep".into(),
10986        });
10987        let err = d.validate().unwrap_err();
10988        assert!(
10989            matches!(
10990                err,
10991                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10992            ),
10993            "got {err:?}",
10994        );
10995    }
10996
10997    #[test]
10998    fn fonte_caminho_backslash_fires_before_shell_background() {
10999        // Cascade pin on the upstream backslash arm: a value carrying
11000        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11001        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11002        // launch chain") routes through `FonteCaminhoBackslash` not
11003        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11004        // divergence is the load-bearing axis on every probe-as-both
11005        // value (an author who removes the `\` is the root-cause edit;
11006        // the `&` falls away in the same edit since it's downstream of
11007        // the Windows-shell convention).
11008        let d = dep_with_fonte(DepSource::Path {
11009            caminho: "..\\caixa-teia & sleep".into(),
11010        });
11011        let err = d.validate().unwrap_err();
11012        assert!(
11013            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11014            "got {err:?}",
11015        );
11016    }
11017
11018    #[test]
11019    fn fonte_caminho_control_char_fires_before_shell_background() {
11020        // Cascade pin on the embedded-control-byte arm: a value
11021        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11022        // the canonical paste-from-multiline-doc footgun where a
11023        // newline landed mid-caminho) routes through
11024        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11025        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11026        // diagnostic is the load-bearing axis on every value that
11027        // probes positive for both — mirrors the cascade discipline on
11028        // every prior arm.
11029        let d = dep_with_fonte(DepSource::Path {
11030            caminho: "../foo\n&sleep".into(),
11031        });
11032        let err = d.validate().unwrap_err();
11033        assert!(
11034            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11035            "got {err:?}",
11036        );
11037    }
11038
11039    #[test]
11040    fn fonte_caminho_absolute_fires_before_shell_background() {
11041        // Cascade pin on the load-bearing leading-byte arm: a leading
11042        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11043        // through `FonteCaminhoAbsolute` not
11044        // `FonteCaminhoShellBackground` — the host-layout-leak
11045        // diagnostic is the load-bearing axis, the `&` byte is the
11046        // secondary observation. Same precedence logic as every prior
11047        // leading-byte arm.
11048        let d = dep_with_fonte(DepSource::Path {
11049            caminho: "/etc/passwd & sleep".into(),
11050        });
11051        let err = d.validate().unwrap_err();
11052        assert!(
11053            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11054            "got {err:?}",
11055        );
11056    }
11057
11058    #[test]
11059    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11060        // Cascade pin on the immediate-successor arm: a value carrying
11061        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11062        // canonical "I tab-completed a path that already had a `&
11063        // sleep` background-launch tail" footgun) routes through
11064        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11065        // The embedded shell-metachar is the more semantic-locating
11066        // axis (an author who removes the `&` typically also drops
11067        // the trailing separator since both are paste-from-shell
11068        // artifacts).
11069        let d = dep_with_fonte(DepSource::Path {
11070            caminho: "../foo&sleep/".into(),
11071        });
11072        let err = d.validate().unwrap_err();
11073        assert!(
11074            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11075            "got {err:?}",
11076        );
11077    }
11078
11079    #[test]
11080    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11081        // Diagnostic-shape pin (peer with
11082        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11083        // on the closest single-byte peer arm): the error's Display
11084        // surfaces the offending `:nome` and the offending `:caminho`
11085        // verbatim, and names the shell-background / logical-AND
11086        // footgun explicitly so a `feira lint` run can render the
11087        // diagnostic without re-parsing.
11088        let d = dep_with_fonte(DepSource::Path {
11089            caminho: "../caixa-teia & sleep 1".into(),
11090        });
11091        let rendered = d.validate().unwrap_err().to_string();
11092        assert!(
11093            rendered.contains("caixa-teia"),
11094            "diagnostic must name the offending dep: {rendered}",
11095        );
11096        assert!(
11097            rendered.contains("../caixa-teia & sleep 1"),
11098            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11099        );
11100        assert!(
11101            rendered.contains('&'),
11102            "diagnostic must reference the ampersand footgun: {rendered:?}",
11103        );
11104        assert!(
11105            rendered.contains("background") || rendered.contains("list-AND"),
11106            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11107        );
11108    }
11109
11110    #[test]
11111    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11112        // The fail-before-pass-after pin for the canonical shell-
11113        // command-substitution paste footgun: an author copies a
11114        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11115        // — the canonical "I pasted a path that included a `pwd`
11116        // / `whoami` / `date` legacy command-substitution expansion
11117        // out of a shell-history block") and silently passed every
11118        // prior arm (`Path::is_absolute` false on `..`, no control
11119        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11120        // end in `/`). The lacre embedded the value verbatim, the
11121        // resolver folded it through `Path::join` looking for a
11122        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11123        // failure surfaced at resolve time with a non-self-locating
11124        // `No such file or directory` error. The new arm moves the
11125        // rejection to validate time and names the offending dep +
11126        // caminho verbatim.
11127        let d = dep_with_fonte(DepSource::Path {
11128            caminho: "../caixa-teia/`whoami`".into(),
11129        });
11130        let err = d.validate().unwrap_err();
11131        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11132            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11133        };
11134        assert_eq!(nome, "caixa-teia");
11135        assert_eq!(caminho, "../caixa-teia/`whoami`");
11136    }
11137
11138    #[test]
11139    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11140        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11141        // the canonical `<backtick>pwd<backtick>/path` working-
11142        // directory expansion shape every shell-side path-composition
11143        // idiom carries). Pinned separately from the embedded-byte
11144        // shape so the gate covers every position, not only mid-path.
11145        let d = dep_with_fonte(DepSource::Path {
11146            caminho: "`pwd`/caixa-teia".into(),
11147        });
11148        let err = d.validate().unwrap_err();
11149        assert!(
11150            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11151            "got {err:?}",
11152        );
11153    }
11154
11155    #[test]
11156    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11157        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11158        // degenerate "I selected an unbalanced backtick out of a
11159        // shell-history block" idiom that probes for the cascade's
11160        // last-byte handling). The trailing-`/` arm fires only on
11161        // last-byte `/`; an unbalanced trailing backtick must route
11162        // through this arm regardless of position.
11163        let d = dep_with_fonte(DepSource::Path {
11164            caminho: "../caixa-teia`".into(),
11165        });
11166        let err = d.validate().unwrap_err();
11167        assert!(
11168            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11169            "got {err:?}",
11170        );
11171    }
11172
11173    #[test]
11174    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11175        // The canonical balanced-pair shape (``"../<backtick>cat
11176        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11177        // command-injection paste idiom every shell-side hardening
11178        // guide enumerates first). The arm fires on the first
11179        // backtick encountered; pinned so a future arm that tries to
11180        // distinguish the opening from the closing byte doesn't break
11181        // the broader contract.
11182        let d = dep_with_fonte(DepSource::Path {
11183            caminho: "../`cat /etc/passwd`".into(),
11184        });
11185        let err = d.validate().unwrap_err();
11186        assert!(
11187            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11188            "got {err:?}",
11189        );
11190    }
11191
11192    #[test]
11193    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11194        // The positive-control pin: the gate targets only the
11195        // backtick byte, never adjacent printable ASCII or POSIX-
11196        // valid bytes. The canonical relative POSIX path
11197        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11198        // adjacent printable punctuation
11199        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11200        // cleanly so the gate doesn't widen to a "no printable
11201        // punctuation anywhere" sweep that would defeat the entire
11202        // path-fonte author surface.
11203        let d = dep_with_fonte(DepSource::Path {
11204            caminho: "../caixa-teia/sub-dir.v2".into(),
11205        });
11206        d.validate().unwrap();
11207    }
11208
11209    #[test]
11210    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11211        // Cascade pin on the immediate-predecessor arm: a value
11212        // carrying both `&` and a backtick (``"../caixa-teia &
11213        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11214        // `cmd & <backtick>sleep N<backtick>` background-launch +
11215        // command-substitution chain" footgun) routes through
11216        // `FonteCaminhoShellBackground` not
11217        // `FonteCaminhoShellCommandSubstitution`. The background-
11218        // launch tail is the more common shell-history paste idiom
11219        // on every probe-as-both value — same cascade discipline
11220        // every prior `:caminho` arm establishes.
11221        let d = dep_with_fonte(DepSource::Path {
11222            caminho: "../caixa-teia & `sleep 1`".into(),
11223        });
11224        let err = d.validate().unwrap_err();
11225        assert!(
11226            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11227            "got {err:?}",
11228        );
11229    }
11230
11231    #[test]
11232    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11233        // Cascade pin on the upstream shell-semicolon arm: a value
11234        // carrying both `;` and a backtick (``"../caixa-teia;
11235        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11236        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11237        // footgun) routes through `FonteCaminhoShellSemicolon` not
11238        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11239        // command-separator paste is the load-bearing root-cause
11240        // edit on every probe-as-both value.
11241        let d = dep_with_fonte(DepSource::Path {
11242            caminho: "../caixa-teia; `whoami`".into(),
11243        });
11244        let err = d.validate().unwrap_err();
11245        assert!(
11246            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11247            "got {err:?}",
11248        );
11249    }
11250
11251    #[test]
11252    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11253        // Cascade pin on the upstream shell-pipe arm: a value
11254        // carrying both `|` and a backtick (``"../caixa-teia |
11255        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11256        // command-substitution paste idiom) routes through
11257        // `FonteCaminhoShellPipe` not
11258        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11259        // paste is the load-bearing root-cause edit on every
11260        // probe-as-both value.
11261        let d = dep_with_fonte(DepSource::Path {
11262            caminho: "../caixa-teia | `tee log`".into(),
11263        });
11264        let err = d.validate().unwrap_err();
11265        assert!(
11266            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11267            "got {err:?}",
11268        );
11269    }
11270
11271    #[test]
11272    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11273        // Cascade pin on the upstream shell-redirection arm: a value
11274        // carrying both `>` and a backtick (``"../caixa-teia>log
11275        // <backtick>date<backtick>"`` — the canonical "I pasted a
11276        // `cmd > log <backtick>date<backtick>` redirect-plus-
11277        // substitution chain" footgun) routes through
11278        // `FonteCaminhoShellRedirection` not
11279        // `FonteCaminhoShellCommandSubstitution`. The input/output
11280        // redirection metachar carries the more self-locating `byte`
11281        // payload (it names which of `<` or `>` triggered), so the
11282        // prior arm wins on every probe-as-both value.
11283        let d = dep_with_fonte(DepSource::Path {
11284            caminho: "../caixa-teia>log `date`".into(),
11285        });
11286        let err = d.validate().unwrap_err();
11287        assert!(
11288            matches!(
11289                err,
11290                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11291            ),
11292            "got {err:?}",
11293        );
11294    }
11295
11296    #[test]
11297    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11298        // Cascade pin on the upstream backslash arm: a value
11299        // carrying both `\` and a backtick (``"..\caixa-teia
11300        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11301        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11302        // chain") routes through `FonteCaminhoBackslash` not
11303        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11304        // separator divergence is the load-bearing axis on every
11305        // probe-as-both value (an author who removes the `\` is the
11306        // root-cause edit; the backtick falls away in the same edit
11307        // since it's downstream of the Windows-shell convention).
11308        let d = dep_with_fonte(DepSource::Path {
11309            caminho: "..\\caixa-teia `whoami`".into(),
11310        });
11311        let err = d.validate().unwrap_err();
11312        assert!(
11313            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11314            "got {err:?}",
11315        );
11316    }
11317
11318    #[test]
11319    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11320        // Cascade pin on the embedded-control-byte arm: a value
11321        // carrying both a control byte and a backtick (`"../foo\n
11322        // `whoami`"` — the canonical paste-from-multiline-doc
11323        // footgun where a newline landed mid-caminho between two
11324        // paste fragments) routes through `FonteCaminhoControlChar`
11325        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11326        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11327        // is the load-bearing axis on every value that probes
11328        // positive for both — mirrors the cascade discipline on
11329        // every prior arm.
11330        let d = dep_with_fonte(DepSource::Path {
11331            caminho: "../foo\n`whoami`".into(),
11332        });
11333        let err = d.validate().unwrap_err();
11334        assert!(
11335            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11336            "got {err:?}",
11337        );
11338    }
11339
11340    #[test]
11341    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11342        // Cascade pin on the load-bearing leading-byte arm: a
11343        // leading `/` value with embedded backtick (``"/etc/passwd
11344        // <backtick>whoami<backtick>"``) routes through
11345        // `FonteCaminhoAbsolute` not
11346        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11347        // leak diagnostic is the load-bearing axis, the backtick
11348        // byte is the secondary observation. Same precedence logic
11349        // as every prior leading-byte arm.
11350        let d = dep_with_fonte(DepSource::Path {
11351            caminho: "/etc/passwd `whoami`".into(),
11352        });
11353        let err = d.validate().unwrap_err();
11354        assert!(
11355            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11356            "got {err:?}",
11357        );
11358    }
11359
11360    #[test]
11361    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11362        // Cascade pin on the immediate-successor arm: a value
11363        // carrying both a backtick and a trailing `/`
11364        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11365        // path that already had a backticked `whoami` substitution
11366        // tail" footgun) routes through
11367        // `FonteCaminhoShellCommandSubstitution` not
11368        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11369        // is the more semantic-locating axis (an author who removes
11370        // the backtick typically also drops the trailing separator
11371        // since both are paste-from-shell artifacts).
11372        let d = dep_with_fonte(DepSource::Path {
11373            caminho: "../`whoami`/".into(),
11374        });
11375        let err = d.validate().unwrap_err();
11376        assert!(
11377            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11378            "got {err:?}",
11379        );
11380    }
11381
11382    #[test]
11383    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11384        // Diagnostic-shape pin (peer with
11385        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11386        // on the closest single-byte peer arm): the error's Display
11387        // surfaces the offending `:nome` and the offending `:caminho`
11388        // verbatim, and names the shell-command-substitution footgun
11389        // explicitly so a `feira lint` run can render the diagnostic
11390        // without re-parsing.
11391        let d = dep_with_fonte(DepSource::Path {
11392            caminho: "../caixa-teia/`whoami`".into(),
11393        });
11394        let rendered = d.validate().unwrap_err().to_string();
11395        assert!(
11396            rendered.contains("caixa-teia"),
11397            "diagnostic must name the offending dep: {rendered}",
11398        );
11399        assert!(
11400            rendered.contains("../caixa-teia/`whoami`"),
11401            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11402        );
11403        assert!(
11404            rendered.contains('`'),
11405            "diagnostic must reference the backtick footgun: {rendered:?}",
11406        );
11407        assert!(
11408            rendered.contains("command-substitution"),
11409            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11410        );
11411    }
11412
11413    #[test]
11414    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11415        // The fail-before-pass-after pin for the canonical pathname-
11416        // expansion paste footgun: an author copies an `ls
11417        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11418        // slot and silently passes every prior arm
11419        // (`Path::is_absolute` false on `..`, no control bytes, no
11420        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11421        // doesn't end in `/`). The lacre embedded the value
11422        // verbatim, the resolver folded it through `Path::join`
11423        // looking for a literal `./../caixa-teia/*` subdirectory,
11424        // and the failure surfaced at resolve time with a non-self-
11425        // locating `No such file or directory` error. The new arm
11426        // moves the rejection to validate time and names the
11427        // offending dep + caminho + byte verbatim.
11428        let d = dep_with_fonte(DepSource::Path {
11429            caminho: "../caixa-teia/*".into(),
11430        });
11431        let err = d.validate().unwrap_err();
11432        let DepError::FonteCaminhoShellGlob {
11433            nome,
11434            caminho,
11435            byte,
11436        } = err
11437        else {
11438            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11439        };
11440        assert_eq!(nome, "caixa-teia");
11441        assert_eq!(caminho, "../caixa-teia/*");
11442        assert_eq!(byte, b'*');
11443    }
11444
11445    #[test]
11446    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11447        // The symmetric single-char-wildcard paste shape
11448        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11449        // out of shell history" idiom). Pinned separately from the
11450        // `*` shape so the gate's contract is "any `*` or `?`
11451        // anywhere", not single-byte coverage.
11452        let d = dep_with_fonte(DepSource::Path {
11453            caminho: "../foo?".into(),
11454        });
11455        let err = d.validate().unwrap_err();
11456        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11457            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11458        };
11459        assert_eq!(byte, b'?');
11460    }
11461
11462    #[test]
11463    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11464        // Leading-position `*` shape (`"*/caixa-teia"` — the
11465        // degenerate "I selected only the wildcard prefix out of a
11466        // shell-glob expression" idiom). Pinned separately from the
11467        // embedded-byte shapes so the gate covers every position,
11468        // not only mid-path.
11469        let d = dep_with_fonte(DepSource::Path {
11470            caminho: "*/caixa-teia".into(),
11471        });
11472        let err = d.validate().unwrap_err();
11473        assert!(
11474            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11475            "got {err:?}",
11476        );
11477    }
11478
11479    #[test]
11480    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11481        // The bash/zsh `globstar` recursive-glob shape
11482        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11483        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11484        // The arm fires on the first `*` encountered; pinned so a
11485        // future arm that tries to distinguish single `*` from
11486        // double `**` doesn't break the broader contract.
11487        let d = dep_with_fonte(DepSource::Path {
11488            caminho: "../caixa-teia/**/foo".into(),
11489        });
11490        let err = d.validate().unwrap_err();
11491        assert!(
11492            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11493            "got {err:?}",
11494        );
11495    }
11496
11497    #[test]
11498    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11499        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11500        // — the "I selected `*.lisp` to mean every Lisp source file
11501        // in the dep root" footgun the prior arms structurally
11502        // cannot catch since `.` is a POSIX-valid path-component
11503        // byte). Pinned so the gate's contract covers the most
11504        // idiomatic glob-paste shape every author meets first.
11505        let d = dep_with_fonte(DepSource::Path {
11506            caminho: "../caixa-teia/*.lisp".into(),
11507        });
11508        let err = d.validate().unwrap_err();
11509        assert!(
11510            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11511            "got {err:?}",
11512        );
11513    }
11514
11515    #[test]
11516    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11517        // The positive-control pin: the gate targets only `*` /
11518        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11519        // The canonical relative POSIX path (`"../caixa-teia"`) and
11520        // a nested deeply-pathed variant with adjacent printable
11521        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11522        // to validate cleanly so the gate doesn't widen to a "no
11523        // printable punctuation anywhere" sweep that would defeat
11524        // the entire path-fonte author surface.
11525        let d = dep_with_fonte(DepSource::Path {
11526            caminho: "../caixa-teia/sub-dir.v2".into(),
11527        });
11528        d.validate().unwrap();
11529    }
11530
11531    #[test]
11532    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11533        // Cascade pin on the immediate-predecessor arm: a value
11534        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11535        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11536        // command-substitution + glob chain") routes through
11537        // `FonteCaminhoShellCommandSubstitution` not
11538        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11539        // injection vector is the load-bearing root-cause edit on
11540        // every probe-as-both value — same cascade discipline every
11541        // prior `:caminho` arm establishes.
11542        let d = dep_with_fonte(DepSource::Path {
11543            caminho: "../`whoami`/*".into(),
11544        });
11545        let err = d.validate().unwrap_err();
11546        assert!(
11547            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11548            "got {err:?}",
11549        );
11550    }
11551
11552    #[test]
11553    fn fonte_caminho_shell_background_fires_before_shell_glob() {
11554        // Cascade pin on the upstream shell-background arm: a value
11555        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11556        // canonical "I pasted a `cmd & ls /*` background + glob
11557        // chain" footgun) routes through `FonteCaminhoShellBackground`
11558        // not `FonteCaminhoShellGlob`. The background-launch tail is
11559        // the load-bearing root-cause edit on every probe-as-both
11560        // value.
11561        let d = dep_with_fonte(DepSource::Path {
11562            caminho: "../caixa-teia & ls /*".into(),
11563        });
11564        let err = d.validate().unwrap_err();
11565        assert!(
11566            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11567            "got {err:?}",
11568        );
11569    }
11570
11571    #[test]
11572    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11573        // Cascade pin on the upstream shell-semicolon arm: a value
11574        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11575        // canonical sequential-cleanup + glob paste idiom) routes
11576        // through `FonteCaminhoShellSemicolon` not
11577        // `FonteCaminhoShellGlob`. The sequential-command-separator
11578        // paste is the load-bearing root-cause edit on every
11579        // probe-as-both value.
11580        let d = dep_with_fonte(DepSource::Path {
11581            caminho: "../caixa-teia; rm *".into(),
11582        });
11583        let err = d.validate().unwrap_err();
11584        assert!(
11585            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11586            "got {err:?}",
11587        );
11588    }
11589
11590    #[test]
11591    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11592        // Cascade pin on the upstream shell-pipe arm: a value
11593        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11594        // canonical pipeline-to-glob paste idiom) routes through
11595        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11596        // pipeline-tail paste is the load-bearing root-cause edit
11597        // on every probe-as-both value.
11598        let d = dep_with_fonte(DepSource::Path {
11599            caminho: "../caixa-teia | ls *".into(),
11600        });
11601        let err = d.validate().unwrap_err();
11602        assert!(
11603            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11604            "got {err:?}",
11605        );
11606    }
11607
11608    #[test]
11609    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11610        // Cascade pin on the upstream shell-redirection arm: a value
11611        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11612        // canonical "I pasted a `cmd > log *` redirect-plus-glob
11613        // chain" footgun) routes through
11614        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11615        // The input/output redirection metachar carries the more
11616        // self-locating `byte` payload (it names which of `<` or `>`
11617        // triggered), so the prior arm wins on every probe-as-both
11618        // value.
11619        let d = dep_with_fonte(DepSource::Path {
11620            caminho: "../caixa-teia>log *".into(),
11621        });
11622        let err = d.validate().unwrap_err();
11623        assert!(
11624            matches!(
11625                err,
11626                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11627            ),
11628            "got {err:?}",
11629        );
11630    }
11631
11632    #[test]
11633    fn fonte_caminho_backslash_fires_before_shell_glob() {
11634        // Cascade pin on the upstream backslash arm: a value
11635        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11636        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11637        // expression" footgun) routes through
11638        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11639        // cross-host-OS-separator divergence is the load-bearing
11640        // axis on every probe-as-both value (an author who removes
11641        // the `\` is the root-cause edit; the `*` falls away in the
11642        // same edit since it's downstream of the Windows-shell
11643        // convention).
11644        let d = dep_with_fonte(DepSource::Path {
11645            caminho: "..\\caixa-teia\\*".into(),
11646        });
11647        let err = d.validate().unwrap_err();
11648        assert!(
11649            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11650            "got {err:?}",
11651        );
11652    }
11653
11654    #[test]
11655    fn fonte_caminho_control_char_fires_before_shell_glob() {
11656        // Cascade pin on the embedded-control-byte arm: a value
11657        // carrying both a control byte and `*` (`"../foo\n*"` — the
11658        // canonical paste-from-multiline-doc footgun where a
11659        // newline landed mid-caminho between two paste fragments)
11660        // routes through `FonteCaminhoControlChar` not
11661        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11662        // NUL-`CString::new`-fail diagnostic is the load-bearing
11663        // axis on every value that probes positive for both —
11664        // mirrors the cascade discipline on every prior arm.
11665        let d = dep_with_fonte(DepSource::Path {
11666            caminho: "../foo\n*".into(),
11667        });
11668        let err = d.validate().unwrap_err();
11669        assert!(
11670            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11671            "got {err:?}",
11672        );
11673    }
11674
11675    #[test]
11676    fn fonte_caminho_absolute_fires_before_shell_glob() {
11677        // Cascade pin on the load-bearing leading-byte arm: a
11678        // leading `/` value with embedded `*` (`"/etc/*"`) routes
11679        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11680        // — the host-layout-leak diagnostic is the load-bearing
11681        // axis, the glob byte is the secondary observation. Same
11682        // precedence logic as every prior leading-byte arm.
11683        let d = dep_with_fonte(DepSource::Path {
11684            caminho: "/etc/*".into(),
11685        });
11686        let err = d.validate().unwrap_err();
11687        assert!(
11688            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11689            "got {err:?}",
11690        );
11691    }
11692
11693    #[test]
11694    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11695        // Cascade pin on the immediate-successor arm: a value
11696        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11697        // canonical "I tab-completed a path that already had a
11698        // glob-expansion tail" footgun) routes through
11699        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11700        // The embedded shell-metachar is the more semantic-locating
11701        // axis (an author who removes the `*` typically also drops
11702        // the trailing separator since both are paste-from-shell
11703        // artifacts).
11704        let d = dep_with_fonte(DepSource::Path {
11705            caminho: "../foo*/".into(),
11706        });
11707        let err = d.validate().unwrap_err();
11708        assert!(
11709            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11710            "got {err:?}",
11711        );
11712    }
11713
11714    #[test]
11715    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11716        // Diagnostic-shape pin (peer with
11717        // `fonte_caminho_shell_redirection_diagnostic_*` on the
11718        // closest two-byte peer arm): the error's Display surfaces
11719        // the offending `:nome`, the offending `:caminho` verbatim,
11720        // the offending byte's hex / character form, and names the
11721        // shell-glob / pathname-expansion footgun explicitly so a
11722        // `feira lint` run can render the diagnostic without
11723        // re-parsing.
11724        let d = dep_with_fonte(DepSource::Path {
11725            caminho: "../caixa-teia/*.lisp".into(),
11726        });
11727        let rendered = d.validate().unwrap_err().to_string();
11728        assert!(
11729            rendered.contains("caixa-teia"),
11730            "diagnostic must name the offending dep: {rendered}",
11731        );
11732        assert!(
11733            rendered.contains("../caixa-teia/*.lisp"),
11734            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11735        );
11736        assert!(
11737            rendered.contains("0x2a"),
11738            "diagnostic must surface the offending byte hex: {rendered:?}",
11739        );
11740        assert!(
11741            rendered.contains("glob"),
11742            "diagnostic must name the shell-glob footgun: {rendered:?}",
11743        );
11744        assert!(
11745            rendered.contains("pathname-expansion"),
11746            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11747        );
11748    }
11749
11750    #[test]
11751    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11752        // The fail-before-pass-after pin for the canonical modern-Bourne
11753        // command-substitution paste footgun: an author copies a
11754        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11755        // `$(<cmd>)` expansion would land the current date as a
11756        // subdirectory name and silently passed every prior arm
11757        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11758        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11759        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11760        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11761        // sits mid-path). The lacre embedded the value verbatim, the
11762        // resolver folded it through `Path::join` looking for a literal
11763        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11764        // surfaced at resolve time with a non-self-locating `No such
11765        // file or directory` error. The new arm moves the rejection to
11766        // validate time and names the offending dep + caminho + byte
11767        // verbatim. The arm fires on the first `(` encountered (the
11768        // opening byte of `$(date)`).
11769        let d = dep_with_fonte(DepSource::Path {
11770            caminho: "../caixa-teia/$(date)/build".into(),
11771        });
11772        let err = d.validate().unwrap_err();
11773        let DepError::FonteCaminhoShellSubshellGrouping {
11774            nome,
11775            caminho,
11776            byte,
11777        } = err
11778        else {
11779            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11780        };
11781        assert_eq!(nome, "caixa-teia");
11782        assert_eq!(caminho, "../caixa-teia/$(date)/build");
11783        assert_eq!(byte, b'(');
11784    }
11785
11786    #[test]
11787    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11788        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11789        // the degenerate "I selected an unbalanced closing paren out of
11790        // a shell-history block" idiom that probes for the cascade's
11791        // last-byte handling on a value carrying only the closing byte).
11792        // Pinned separately from the open-paren shape so the gate's
11793        // contract is "any `(` or `)` anywhere", not single-byte
11794        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11795        // caminho_carrying_question_glob` shape on the immediate-
11796        // predecessor `FonteCaminhoShellGlob` arm.
11797        let d = dep_with_fonte(DepSource::Path {
11798            caminho: "../caixa-teia)".into(),
11799        });
11800        let err = d.validate().unwrap_err();
11801        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11802            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11803        };
11804        assert_eq!(byte, b')');
11805    }
11806
11807    #[test]
11808    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11809        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11810        // canonical "I selected a `(cd foo)` subshell-grouping prefix
11811        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11812        // Pinned separately from the embedded-byte shape so the gate
11813        // covers every position, not only mid-path.
11814        let d = dep_with_fonte(DepSource::Path {
11815            caminho: "(cd foo)/caixa-teia".into(),
11816        });
11817        let err = d.validate().unwrap_err();
11818        assert!(
11819            matches!(
11820                err,
11821                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11822            ),
11823            "got {err:?}",
11824        );
11825    }
11826
11827    #[test]
11828    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11829        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11830        // — the canonical "I copied a `(pwd)` working-directory-probe
11831        // subshell-grouping idiom every shell-history block carries"
11832        // footgun). The value carries no other cascade-preceding
11833        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11834        // `*` / `?`) so the arm fires on the first `(` encountered;
11835        // pinned so a future arm that tries to distinguish the
11836        // opening from the closing byte doesn't break the broader
11837        // contract. Mirrors the peer
11838        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11839        // backtick_pair` shape on the upstream `FonteCaminhoShell\
11840        // CommandSubstitution` arm.
11841        let d = dep_with_fonte(DepSource::Path {
11842            caminho: "../(pwd)/caixa-teia".into(),
11843        });
11844        let err = d.validate().unwrap_err();
11845        assert!(
11846            matches!(
11847                err,
11848                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11849            ),
11850            "got {err:?}",
11851        );
11852    }
11853
11854    #[test]
11855    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11856        // The positive-control pin: the gate targets only `(` / `)`,
11857        // never adjacent printable ASCII or POSIX-valid bytes. The
11858        // canonical relative POSIX path (`"../caixa-teia"`) and a
11859        // nested deeply-pathed variant with adjacent printable
11860        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11861        // validate cleanly so the gate doesn't widen to a "no printable
11862        // punctuation anywhere" sweep that would defeat the entire
11863        // path-fonte author surface.
11864        let d = dep_with_fonte(DepSource::Path {
11865            caminho: "../caixa-teia/sub-dir.v2".into(),
11866        });
11867        d.validate().unwrap();
11868    }
11869
11870    #[test]
11871    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11872        // Cascade pin on the immediate-predecessor arm: a value
11873        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11874        // canonical "I pasted a glob expansion followed by a
11875        // subshell-grouping tail" footgun) routes through
11876        // `FonteCaminhoShellGlob` not
11877        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11878        // shape is the more common shell-history paste idiom on every
11879        // probe-as-both value — same cascade discipline every prior
11880        // `:caminho` arm establishes.
11881        let d = dep_with_fonte(DepSource::Path {
11882            caminho: "../caixa-teia/*(date)".into(),
11883        });
11884        let err = d.validate().unwrap_err();
11885        assert!(
11886            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11887            "got {err:?}",
11888        );
11889    }
11890
11891    #[test]
11892    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11893        // Cascade pin on the upstream shell-command-substitution arm: a
11894        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11895        // — the canonical "I pasted a legacy-backtick + modern-paren
11896        // command-substitution chain" footgun) routes through
11897        // `FonteCaminhoShellCommandSubstitution` not
11898        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11899        // command-injection vector is the load-bearing root-cause edit
11900        // on every probe-as-both value.
11901        let d = dep_with_fonte(DepSource::Path {
11902            caminho: "../`whoami`/$(date)".into(),
11903        });
11904        let err = d.validate().unwrap_err();
11905        assert!(
11906            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11907            "got {err:?}",
11908        );
11909    }
11910
11911    #[test]
11912    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11913        // Cascade pin on the upstream shell-background arm: a value
11914        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11915        // the canonical "I pasted a `cmd & (cd foo)` background-launch
11916        // + subshell-grouping chain" footgun) routes through
11917        // `FonteCaminhoShellBackground` not
11918        // `FonteCaminhoShellSubshellGrouping`. The background-launch
11919        // tail is the load-bearing root-cause edit on every probe-as-
11920        // both value.
11921        let d = dep_with_fonte(DepSource::Path {
11922            caminho: "../caixa-teia & (cd foo)".into(),
11923        });
11924        let err = d.validate().unwrap_err();
11925        assert!(
11926            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11927            "got {err:?}",
11928        );
11929    }
11930
11931    #[test]
11932    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11933        // Cascade pin on the upstream shell-semicolon arm: a value
11934        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11935        // the canonical sequential-cleanup + subshell-grouping paste
11936        // idiom) routes through `FonteCaminhoShellSemicolon` not
11937        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11938        // separator paste is the load-bearing root-cause edit on
11939        // every probe-as-both value.
11940        let d = dep_with_fonte(DepSource::Path {
11941            caminho: "../caixa-teia; (cd foo)".into(),
11942        });
11943        let err = d.validate().unwrap_err();
11944        assert!(
11945            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11946            "got {err:?}",
11947        );
11948    }
11949
11950    #[test]
11951    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11952        // Cascade pin on the upstream shell-pipe arm: a value carrying
11953        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11954        // canonical pipeline-to-subshell-grouping paste idiom) routes
11955        // through `FonteCaminhoShellPipe` not
11956        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11957        // is the load-bearing root-cause edit on every probe-as-both
11958        // value.
11959        let d = dep_with_fonte(DepSource::Path {
11960            caminho: "../caixa-teia | (tee log)".into(),
11961        });
11962        let err = d.validate().unwrap_err();
11963        assert!(
11964            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11965            "got {err:?}",
11966        );
11967    }
11968
11969    #[test]
11970    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11971        // Cascade pin on the upstream shell-redirection arm: a value
11972        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11973        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11974        // plus-subshell-grouping chain" footgun) routes through
11975        // `FonteCaminhoShellRedirection` not
11976        // `FonteCaminhoShellSubshellGrouping`. The input/output
11977        // redirection metachar carries the more self-locating `byte`
11978        // payload (it names which of `<` or `>` triggered), so the
11979        // prior arm wins on every probe-as-both value.
11980        let d = dep_with_fonte(DepSource::Path {
11981            caminho: "../caixa-teia>log (cd foo)".into(),
11982        });
11983        let err = d.validate().unwrap_err();
11984        assert!(
11985            matches!(
11986                err,
11987                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11988            ),
11989            "got {err:?}",
11990        );
11991    }
11992
11993    #[test]
11994    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11995        // Cascade pin on the upstream backslash arm: a value carrying
11996        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11997        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11998        // through `FonteCaminhoBackslash` not
11999        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12000        // separator divergence is the load-bearing axis on every
12001        // probe-as-both value (an author who removes the `\` is the
12002        // root-cause edit; the `(` falls away in the same edit since
12003        // it's downstream of the Windows-shell convention).
12004        let d = dep_with_fonte(DepSource::Path {
12005            caminho: "..\\caixa-teia\\(cd foo)".into(),
12006        });
12007        let err = d.validate().unwrap_err();
12008        assert!(
12009            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12010            "got {err:?}",
12011        );
12012    }
12013
12014    #[test]
12015    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12016        // Cascade pin on the embedded-control-byte arm: a value
12017        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12018        // the canonical paste-from-multiline-doc footgun where a
12019        // newline landed mid-caminho between two paste fragments)
12020        // routes through `FonteCaminhoControlChar` not
12021        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12022        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12023        // load-bearing axis on every value that probes positive for
12024        // both — mirrors the cascade discipline on every prior arm.
12025        let d = dep_with_fonte(DepSource::Path {
12026            caminho: "../foo\n(cd bar)".into(),
12027        });
12028        let err = d.validate().unwrap_err();
12029        assert!(
12030            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12031            "got {err:?}",
12032        );
12033    }
12034
12035    #[test]
12036    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12037        // Cascade pin on the load-bearing leading-byte arm: a leading
12038        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12039        // through `FonteCaminhoAbsolute` not
12040        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12041        // diagnostic is the load-bearing axis, the subshell-grouping
12042        // byte is the secondary observation. Same precedence logic as
12043        // every prior leading-byte arm.
12044        let d = dep_with_fonte(DepSource::Path {
12045            caminho: "/etc/(cd foo)".into(),
12046        });
12047        let err = d.validate().unwrap_err();
12048        assert!(
12049            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12050            "got {err:?}",
12051        );
12052    }
12053
12054    #[test]
12055    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12056        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12057        // value carrying both a leading `$` and a `(` (`"$(date)/\
12058        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12059        // command-substitution at the head of a sibling-workspace
12060        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12061        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12062        // shell-variable-expansion is the more self-locating diagnostic
12063        // on values that probe as both — same load-bearing-leading-
12064        // byte cascade discipline every prior `:caminho` arm
12065        // establishes. Closing both halves of `$(<cmd>)` structurally
12066        // (leading `$` here, trailing `)` on the new arm) excludes the
12067        // entire modern Bourne command-substitution surface from the
12068        // typed `:caminho` accepted set; the cascade preserves the
12069        // narrower leading-byte diagnostic on values that probe both
12070        // halves at the canonical leading position.
12071        let d = dep_with_fonte(DepSource::Path {
12072            caminho: "$(date)/caixa-teia".into(),
12073        });
12074        let err = d.validate().unwrap_err();
12075        assert!(
12076            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12077            "got {err:?}",
12078        );
12079    }
12080
12081    #[test]
12082    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12083        // Cascade pin on the immediate-successor arm: a value carrying
12084        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12085        // "I tab-completed a path that already had a subshell-grouping
12086        // expansion tail" footgun) routes through
12087        // `FonteCaminhoShellSubshellGrouping` not
12088        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12089        // the more semantic-locating axis (an author who removes the
12090        // `(` typically also drops the trailing separator since both
12091        // are paste-from-shell artifacts).
12092        let d = dep_with_fonte(DepSource::Path {
12093            caminho: "../(cd foo)/".into(),
12094        });
12095        let err = d.validate().unwrap_err();
12096        assert!(
12097            matches!(
12098                err,
12099                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12100            ),
12101            "got {err:?}",
12102        );
12103    }
12104
12105    #[test]
12106    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12107        // Diagnostic-shape pin (peer with
12108        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12109        // on the closest two-byte peer arm): the error's Display
12110        // surfaces the offending `:nome`, the offending `:caminho`
12111        // verbatim, the offending byte's hex / character form, and
12112        // names the shell-subshell-grouping footgun explicitly so a
12113        // `feira lint` run can render the diagnostic without re-
12114        // parsing.
12115        let d = dep_with_fonte(DepSource::Path {
12116            caminho: "../caixa-teia/$(date)/build".into(),
12117        });
12118        let rendered = d.validate().unwrap_err().to_string();
12119        assert!(
12120            rendered.contains("caixa-teia"),
12121            "diagnostic must name the offending dep: {rendered}",
12122        );
12123        assert!(
12124            rendered.contains("../caixa-teia/$(date)/build"),
12125            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12126        );
12127        assert!(
12128            rendered.contains("0x28"),
12129            "diagnostic must surface the offending byte hex: {rendered:?}",
12130        );
12131        assert!(
12132            rendered.contains("subshell-grouping"),
12133            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12134        );
12135        assert!(
12136            rendered.contains("command-substitution"),
12137            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12138             {rendered:?}",
12139        );
12140    }
12141
12142    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12143    //
12144    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12145    // `)`) byte-pair arm: the same per-byte cascade with the same
12146    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12147    // `}` brace-expansion / URI-Template placeholder axis. The peer
12148    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12149    // byte pair on the sibling `:fonte :repo` axis under the same
12150    // banner.
12151
12152    #[test]
12153    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12154        // The fail-before-pass-after pin for the canonical paste-from-
12155        // shell-history brace-expansion footgun: an author copies a
12156        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12157        // liner whose `{a,b}` brace expansion fans across two siblings
12158        // and silently passed every prior arm (`Path::is_absolute`
12159        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12160        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12161        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12162        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12163        // value starts with `..` not `$`). The lacre embedded the
12164        // value verbatim, the resolver folded it through `Path::join`
12165        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12166        // subdirectory, and the failure surfaced at resolve time with
12167        // a non-self-locating `No such file or directory` error. The
12168        // new arm moves the rejection to validate time and names the
12169        // offending dep + caminho + byte verbatim. The arm fires on
12170        // the first `{` encountered.
12171        let d = dep_with_fonte(DepSource::Path {
12172            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12173        });
12174        let err = d.validate().unwrap_err();
12175        let DepError::FonteCaminhoShellBraceExpansion {
12176            nome,
12177            caminho,
12178            byte,
12179        } = err
12180        else {
12181            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12182        };
12183        assert_eq!(nome, "caixa-teia");
12184        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12185        assert_eq!(byte, b'{');
12186    }
12187
12188    #[test]
12189    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12190        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12191        // the degenerate "I selected an unbalanced closing brace out
12192        // of a shell-history block" idiom that probes for the
12193        // cascade's last-byte handling on a value carrying only the
12194        // closing byte). Pinned separately from the open-brace shape
12195        // so the gate's contract is "any `{` or `}` anywhere", not
12196        // single-byte coverage. Mirrors the peer
12197        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12198        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12199        // arm.
12200        let d = dep_with_fonte(DepSource::Path {
12201            caminho: "../caixa-teia}".into(),
12202        });
12203        let err = d.validate().unwrap_err();
12204        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12205            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12206        };
12207        assert_eq!(byte, b'}');
12208    }
12209
12210    #[test]
12211    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12212        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12213        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12214        // out of a shell-history one-liner" idiom). Pinned separately
12215        // from the embedded-byte shape so the gate covers every
12216        // position, not only mid-path.
12217        let d = dep_with_fonte(DepSource::Path {
12218            caminho: "{caixa-teia,caixa-helm}/build".into(),
12219        });
12220        let err = d.validate().unwrap_err();
12221        assert!(
12222            matches!(
12223                err,
12224                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12225            ),
12226            "got {err:?}",
12227        );
12228    }
12229
12230    #[test]
12231    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12232        // The canonical URI-Template / Mustache / Helm doubled-brace
12233        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12234        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12235        // quick-start / OpenAPI spec / Helm chart `home:` template
12236        // and forgot to substitute the placeholder" footgun). The arm
12237        // fires on the first `{` encountered; pinned so the gate's
12238        // coverage extends from the bare-brace shell-history shape to
12239        // the doubled-brace URI-Template / templating-engine shape.
12240        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12241        // sibling `:fonte :repo` axis.
12242        let d = dep_with_fonte(DepSource::Path {
12243            caminho: "../{{org}}/caixa-teia".into(),
12244        });
12245        let err = d.validate().unwrap_err();
12246        assert!(
12247            matches!(
12248                err,
12249                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12250            ),
12251            "got {err:?}",
12252        );
12253    }
12254
12255    #[test]
12256    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12257        // The canonical bash brace-range-expansion shape (`"../caixa-
12258        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12259        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12260        // sequence-range form to the `{a,b,c}` comma-separated form).
12261        // The arm fires on the first `{` encountered; pinned so the
12262        // gate's coverage extends from the comma-separated form to
12263        // the integer-range form.
12264        let d = dep_with_fonte(DepSource::Path {
12265            caminho: "../caixa-v{1..10}".into(),
12266        });
12267        let err = d.validate().unwrap_err();
12268        assert!(
12269            matches!(
12270                err,
12271                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12272            ),
12273            "got {err:?}",
12274        );
12275    }
12276
12277    #[test]
12278    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12279        // The positive-control pin: the gate targets only `{` / `}`,
12280        // never adjacent printable ASCII or POSIX-valid bytes. The
12281        // canonical relative POSIX path (`"../caixa-teia"`) and a
12282        // nested deeply-pathed variant with adjacent printable
12283        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12284        // validate cleanly so the gate doesn't widen to a "no
12285        // printable punctuation anywhere" sweep that would defeat
12286        // the entire path-fonte author surface. Peer with
12287        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12288        // on the immediate-predecessor arm.
12289        let d = dep_with_fonte(DepSource::Path {
12290            caminho: "../caixa-teia/sub-dir.v2".into(),
12291        });
12292        d.validate().unwrap();
12293    }
12294
12295    #[test]
12296    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12297        // Cascade pin on the immediate-predecessor arm: a value
12298        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12299        // canonical "I pasted a subshell-grouping followed by a
12300        // brace-expansion tail" footgun) routes through
12301        // `FonteCaminhoShellSubshellGrouping` not
12302        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12303        // shape is the more semantic-locating axis on every probe-
12304        // as-both value because it closes both halves of the modern
12305        // Bourne `$(<cmd>)` command-substitution surface — same
12306        // cascade discipline every prior `:caminho` arm establishes.
12307        let d = dep_with_fonte(DepSource::Path {
12308            caminho: "../(cd foo)/{a,b}".into(),
12309        });
12310        let err = d.validate().unwrap_err();
12311        assert!(
12312            matches!(
12313                err,
12314                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12315            ),
12316            "got {err:?}",
12317        );
12318    }
12319
12320    #[test]
12321    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12322        // Cascade pin on the upstream shell-glob arm: a value carrying
12323        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12324        // "I pasted a glob expansion followed by a brace-expansion
12325        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12326        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12327        // shape is the load-bearing root-cause edit on every
12328        // probe-as-both value.
12329        let d = dep_with_fonte(DepSource::Path {
12330            caminho: "../caixa-teia/*{a,b}".into(),
12331        });
12332        let err = d.validate().unwrap_err();
12333        assert!(
12334            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12335            "got {err:?}",
12336        );
12337    }
12338
12339    #[test]
12340    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12341        // Cascade pin on the upstream shell-command-substitution arm:
12342        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12343        // — the canonical "I pasted a legacy-backtick command-
12344        // substitution followed by a brace-expansion fan-out" footgun)
12345        // routes through `FonteCaminhoShellCommandSubstitution` not
12346        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12347        // command-injection vector is the load-bearing root-cause
12348        // edit on every probe-as-both value.
12349        let d = dep_with_fonte(DepSource::Path {
12350            caminho: "../`whoami`/{a,b}".into(),
12351        });
12352        let err = d.validate().unwrap_err();
12353        assert!(
12354            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12355            "got {err:?}",
12356        );
12357    }
12358
12359    #[test]
12360    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12361        // Cascade pin on the upstream shell-background arm: a value
12362        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12363        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12364        // + brace-expansion chain" footgun) routes through
12365        // `FonteCaminhoShellBackground` not
12366        // `FonteCaminhoShellBraceExpansion`. The background-launch
12367        // tail is the load-bearing root-cause edit on every
12368        // probe-as-both value.
12369        let d = dep_with_fonte(DepSource::Path {
12370            caminho: "../caixa-teia & {a,b}".into(),
12371        });
12372        let err = d.validate().unwrap_err();
12373        assert!(
12374            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12375            "got {err:?}",
12376        );
12377    }
12378
12379    #[test]
12380    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12381        // Cascade pin on the upstream shell-semicolon arm: a value
12382        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12383        // canonical sequential-cleanup + brace-expansion paste
12384        // idiom) routes through `FonteCaminhoShellSemicolon` not
12385        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12386        // separator paste is the load-bearing root-cause edit on
12387        // every probe-as-both value.
12388        let d = dep_with_fonte(DepSource::Path {
12389            caminho: "../caixa-teia; {a,b}".into(),
12390        });
12391        let err = d.validate().unwrap_err();
12392        assert!(
12393            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12394            "got {err:?}",
12395        );
12396    }
12397
12398    #[test]
12399    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12400        // Cascade pin on the upstream shell-pipe arm: a value
12401        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12402        // — the canonical pipeline-to-brace-expansion paste idiom)
12403        // routes through `FonteCaminhoShellPipe` not
12404        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12405        // is the load-bearing root-cause edit on every probe-as-
12406        // both value.
12407        let d = dep_with_fonte(DepSource::Path {
12408            caminho: "../caixa-teia | {tee,cat}".into(),
12409        });
12410        let err = d.validate().unwrap_err();
12411        assert!(
12412            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12413            "got {err:?}",
12414        );
12415    }
12416
12417    #[test]
12418    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12419        // Cascade pin on the upstream shell-redirection arm: a value
12420        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12421        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12422        // plus-brace-expansion chain" footgun) routes through
12423        // `FonteCaminhoShellRedirection` not
12424        // `FonteCaminhoShellBraceExpansion`. The input/output
12425        // redirection metachar carries the more self-locating
12426        // `byte` payload, so the prior arm wins on every probe-
12427        // as-both value.
12428        let d = dep_with_fonte(DepSource::Path {
12429            caminho: "../caixa-teia>log {a,b}".into(),
12430        });
12431        let err = d.validate().unwrap_err();
12432        assert!(
12433            matches!(
12434                err,
12435                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12436            ),
12437            "got {err:?}",
12438        );
12439    }
12440
12441    #[test]
12442    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12443        // Cascade pin on the upstream backslash arm: a value
12444        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12445        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12446        // chain") routes through `FonteCaminhoBackslash` not
12447        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12448        // separator divergence is the load-bearing axis on every
12449        // probe-as-both value.
12450        let d = dep_with_fonte(DepSource::Path {
12451            caminho: "..\\caixa-teia\\{a,b}".into(),
12452        });
12453        let err = d.validate().unwrap_err();
12454        assert!(
12455            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12456            "got {err:?}",
12457        );
12458    }
12459
12460    #[test]
12461    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12462        // Cascade pin on the embedded-control-byte arm: a value
12463        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12464        // the canonical paste-from-multiline-doc footgun where a
12465        // newline landed mid-caminho between two paste fragments)
12466        // routes through `FonteCaminhoControlChar` not
12467        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12468        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12469        // load-bearing axis on every value that probes positive for
12470        // both — mirrors the cascade discipline on every prior arm.
12471        let d = dep_with_fonte(DepSource::Path {
12472            caminho: "../foo\n{a,b}".into(),
12473        });
12474        let err = d.validate().unwrap_err();
12475        assert!(
12476            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12477            "got {err:?}",
12478        );
12479    }
12480
12481    #[test]
12482    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12483        // Cascade pin on the load-bearing leading-byte arm: a
12484        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12485        // routes through `FonteCaminhoAbsolute` not
12486        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12487        // diagnostic is the load-bearing axis, the brace-expansion
12488        // byte is the secondary observation. Same precedence logic
12489        // as every prior leading-byte arm.
12490        let d = dep_with_fonte(DepSource::Path {
12491            caminho: "/etc/{a,b}".into(),
12492        });
12493        let err = d.validate().unwrap_err();
12494        assert!(
12495            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12496            "got {err:?}",
12497        );
12498    }
12499
12500    #[test]
12501    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12502        // Cascade pin on the upstream leading-`$` var-expansion
12503        // arm: a value carrying both a leading `$` and a `{`
12504        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12505        // `${ORG}` shell-variable + curly-brace expansion at the
12506        // head of a sibling-workspace path" footgun) routes through
12507        // `FonteCaminhoVarExpansion` not
12508        // `FonteCaminhoShellBraceExpansion`. The leading-byte
12509        // shell-variable-expansion is the more self-locating
12510        // diagnostic on values that probe as both — same
12511        // load-bearing-leading-byte cascade discipline every prior
12512        // `:caminho` arm establishes.
12513        let d = dep_with_fonte(DepSource::Path {
12514            caminho: "${ORG}/caixa-teia".into(),
12515        });
12516        let err = d.validate().unwrap_err();
12517        assert!(
12518            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12519            "got {err:?}",
12520        );
12521    }
12522
12523    #[test]
12524    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12525        // Cascade pin on the immediate-successor arm: a value
12526        // carrying both `{` and a trailing `/`
12527        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12528        // tab-completed a path that already had a brace-expansion
12529        // expansion tail" footgun) routes through
12530        // `FonteCaminhoShellBraceExpansion` not
12531        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12532        // is the more semantic-locating axis (an author who removes
12533        // the `{` typically also drops the trailing separator since
12534        // both are paste-from-shell artifacts).
12535        let d = dep_with_fonte(DepSource::Path {
12536            caminho: "../{caixa-teia,caixa-helm}/".into(),
12537        });
12538        let err = d.validate().unwrap_err();
12539        assert!(
12540            matches!(
12541                err,
12542                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12543            ),
12544            "got {err:?}",
12545        );
12546    }
12547
12548    #[test]
12549    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12550        // Diagnostic-shape pin (peer with
12551        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12552        // on the closest two-byte peer arm): the error's Display
12553        // surfaces the offending `:nome`, the offending `:caminho`
12554        // verbatim, the offending byte's hex / character form, and
12555        // names the shell-brace-expansion / URI-Template footgun
12556        // explicitly so a `feira lint` run can render the diagnostic
12557        // without re-parsing.
12558        let d = dep_with_fonte(DepSource::Path {
12559            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12560        });
12561        let rendered = d.validate().unwrap_err().to_string();
12562        assert!(
12563            rendered.contains("caixa-teia"),
12564            "diagnostic must name the offending dep: {rendered}",
12565        );
12566        assert!(
12567            rendered.contains("../{caixa-teia,caixa-helm}/build"),
12568            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12569        );
12570        assert!(
12571            rendered.contains("0x7b"),
12572            "diagnostic must surface the offending byte hex: {rendered:?}",
12573        );
12574        assert!(
12575            rendered.contains("brace-expansion"),
12576            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12577        );
12578        assert!(
12579            rendered.contains("URI Template"),
12580            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12581             {rendered:?}",
12582        );
12583    }
12584
12585    #[test]
12586    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12587        // The canonical paste-from-shell-history bracket-glob /
12588        // character-class footgun: an author copies a
12589        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12590        // `[a-z]` POSIX glob character-class matches every lowercase-
12591        // ASCII-suffix sibling caixa directory and silently passed
12592        // every prior arm (`Path::is_absolute` false on `..`, no
12593        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12594        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12595        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12596        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12597        // value starts with `..` not `$`). The lacre embedded the
12598        // value verbatim, the resolver folded it through
12599        // `Path::join` looking for a literal `./../caixa-[a-z]/
12600        // build` subdirectory, and the failure surfaced at resolve
12601        // time with a non-self-locating `No such file or directory`
12602        // error. The new arm moves the rejection to validate time
12603        // and names the offending dep + caminho + byte verbatim.
12604        // The arm fires on the first `[` encountered.
12605        let d = dep_with_fonte(DepSource::Path {
12606            caminho: "../caixa-[a-z]/build".into(),
12607        });
12608        let err = d.validate().unwrap_err();
12609        let DepError::FonteCaminhoShellBracketExpansion {
12610            nome,
12611            caminho,
12612            byte,
12613        } = err
12614        else {
12615            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12616        };
12617        assert_eq!(nome, "caixa-teia");
12618        assert_eq!(caminho, "../caixa-[a-z]/build");
12619        assert_eq!(byte, b'[');
12620    }
12621
12622    #[test]
12623    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12624        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12625        // — the degenerate "I selected an unbalanced closing bracket
12626        // out of a glob character-class block" idiom that probes for
12627        // the cascade's last-byte handling on a value carrying only
12628        // the closing byte). Pinned separately from the open-bracket
12629        // shape so the gate's contract is "any `[` or `]` anywhere",
12630        // not single-byte coverage. Mirrors the peer
12631        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12632        // shape on the immediate-predecessor
12633        // `FonteCaminhoShellBraceExpansion` arm.
12634        let d = dep_with_fonte(DepSource::Path {
12635            caminho: "../caixa-teia]".into(),
12636        });
12637        let err = d.validate().unwrap_err();
12638        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12639            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12640        };
12641        assert_eq!(byte, b']');
12642    }
12643
12644    #[test]
12645    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12646        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12647        // canonical "I selected a `[caixa-teia]` TOML-table-header /
12648        // glob-character-class prefix out of an aligned config /
12649        // shell-history one-liner" idiom). Pinned separately from
12650        // the embedded-byte shape so the gate covers every position,
12651        // not only mid-path.
12652        let d = dep_with_fonte(DepSource::Path {
12653            caminho: "[caixa-teia]/build".into(),
12654        });
12655        let err = d.validate().unwrap_err();
12656        assert!(
12657            matches!(
12658                err,
12659                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12660            ),
12661            "got {err:?}",
12662        );
12663    }
12664
12665    #[test]
12666    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12667        // The canonical TOML inline-array / YAML flow-sequence
12668        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12669        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12670        // inline-array out of a sibling-Cargo manifest" cross-idiom
12671        // leak; the symmetric YAML flow-sequence form `paths: [/a,
12672        // /b]` paste-from-values.yaml shape carries the same
12673        // bracket pair). The arm fires on the first `[` encountered;
12674        // pinned so the gate's coverage extends from the bare-
12675        // bracket glob-character-class shape to the TOML / YAML /
12676        // JSON array-literal shape.
12677        let d = dep_with_fonte(DepSource::Path {
12678            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12679        });
12680        let err = d.validate().unwrap_err();
12681        assert!(
12682            matches!(
12683                err,
12684                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12685            ),
12686            "got {err:?}",
12687        );
12688    }
12689
12690    #[test]
12691    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12692        // The canonical POSIX `test` / `[` builtin command paste
12693        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12694        // script conditional every paste-from-shell-script idiom
12695        // carries; bash's `[[ <expr> ]]` extended-test grammar
12696        // would surface the same byte pair). The arm fires on the
12697        // first `[` encountered; pinned so the gate's coverage
12698        // extends from the embedded-glob-character-class shape to
12699        // the leading-`test`-builtin / extended-test form.
12700        let d = dep_with_fonte(DepSource::Path {
12701            caminho: "../[ -d caixa-teia ]".into(),
12702        });
12703        let err = d.validate().unwrap_err();
12704        assert!(
12705            matches!(
12706                err,
12707                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12708            ),
12709            "got {err:?}",
12710        );
12711    }
12712
12713    #[test]
12714    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12715        // The positive-control pin: the gate targets only `[` /
12716        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12717        // The canonical relative POSIX path (`"../caixa-teia"`) and
12718        // a nested deeply-pathed variant with adjacent printable
12719        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12720        // to validate cleanly so the gate doesn't widen to a "no
12721        // printable punctuation anywhere" sweep that would defeat
12722        // the entire path-fonte author surface. Peer with
12723        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12724        // on the immediate-predecessor arm.
12725        let d = dep_with_fonte(DepSource::Path {
12726            caminho: "../caixa-teia/sub-dir.v2".into(),
12727        });
12728        d.validate().unwrap();
12729    }
12730
12731    #[test]
12732    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12733        // Cascade pin on the immediate-predecessor arm: a value
12734        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12735        // canonical "I pasted a brace-expansion fan followed by a
12736        // glob-character-class tail" footgun) routes through
12737        // `FonteCaminhoShellBraceExpansion` not
12738        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12739        // fan is the load-bearing root-cause edit on every
12740        // probe-as-both value because the bracket-class tail
12741        // typically rides on a prior brace-expansion expansion;
12742        // same cascade discipline every prior `:caminho` arm
12743        // establishes.
12744        let d = dep_with_fonte(DepSource::Path {
12745            caminho: "../{a,b}[ch]".into(),
12746        });
12747        let err = d.validate().unwrap_err();
12748        assert!(
12749            matches!(
12750                err,
12751                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12752            ),
12753            "got {err:?}",
12754        );
12755    }
12756
12757    #[test]
12758    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12759        // Cascade pin on the upstream shell-subshell-grouping arm:
12760        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12761        // the canonical "I pasted a subshell-grouping followed by
12762        // a glob-character-class tail" footgun) routes through
12763        // `FonteCaminhoShellSubshellGrouping` not
12764        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12765        // `$(<cmd>)` command-substitution boundary is the load-
12766        // bearing axis on every probe-as-both value.
12767        let d = dep_with_fonte(DepSource::Path {
12768            caminho: "../(cd foo)/[ch]".into(),
12769        });
12770        let err = d.validate().unwrap_err();
12771        assert!(
12772            matches!(
12773                err,
12774                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12775            ),
12776            "got {err:?}",
12777        );
12778    }
12779
12780    #[test]
12781    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12782        // Cascade pin on the upstream shell-glob arm: a value
12783        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12784        // canonical "I pasted a `*.[ch]` C-source-file glob whose
12785        // unbounded `*` precedes the bracket character-class"
12786        // footgun) routes through `FonteCaminhoShellGlob` not
12787        // `FonteCaminhoShellBracketExpansion`. The unbounded
12788        // pathname-expansion sentinel is the load-bearing root-
12789        // cause edit on every probe-as-both value — the unbounded
12790        // `*` carries the more aggressive expansion vector than
12791        // the bounded `[ch]` class, so the prior arm wins.
12792        let d = dep_with_fonte(DepSource::Path {
12793            caminho: "../caixa-teia/*[ch]".into(),
12794        });
12795        let err = d.validate().unwrap_err();
12796        assert!(
12797            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12798            "got {err:?}",
12799        );
12800    }
12801
12802    #[test]
12803    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12804        // Cascade pin on the upstream shell-command-substitution
12805        // arm: a value carrying both a backtick and `[`
12806        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12807        // legacy-backtick command-substitution followed by a
12808        // glob-character-class tail" footgun) routes through
12809        // `FonteCaminhoShellCommandSubstitution` not
12810        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12811        // command-injection vector is the load-bearing root-cause
12812        // edit on every probe-as-both value.
12813        let d = dep_with_fonte(DepSource::Path {
12814            caminho: "../`whoami`/[ch]".into(),
12815        });
12816        let err = d.validate().unwrap_err();
12817        assert!(
12818            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12819            "got {err:?}",
12820        );
12821    }
12822
12823    #[test]
12824    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12825        // Cascade pin on the upstream shell-background arm: a
12826        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12827        // — the canonical "I pasted a `cmd & [glob]` background-
12828        // launch + bracket-class chain" footgun) routes through
12829        // `FonteCaminhoShellBackground` not
12830        // `FonteCaminhoShellBracketExpansion`. The background-
12831        // launch tail is the load-bearing root-cause edit on
12832        // every probe-as-both value.
12833        let d = dep_with_fonte(DepSource::Path {
12834            caminho: "../caixa-teia & [ch]".into(),
12835        });
12836        let err = d.validate().unwrap_err();
12837        assert!(
12838            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12839            "got {err:?}",
12840        );
12841    }
12842
12843    #[test]
12844    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12845        // Cascade pin on the upstream shell-semicolon arm: a value
12846        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12847        // canonical sequential-cleanup + bracket-class paste
12848        // idiom) routes through `FonteCaminhoShellSemicolon` not
12849        // `FonteCaminhoShellBracketExpansion`. The sequential-
12850        // command-separator paste is the load-bearing root-cause
12851        // edit on every probe-as-both value.
12852        let d = dep_with_fonte(DepSource::Path {
12853            caminho: "../caixa-teia; [ch]".into(),
12854        });
12855        let err = d.validate().unwrap_err();
12856        assert!(
12857            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12858            "got {err:?}",
12859        );
12860    }
12861
12862    #[test]
12863    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12864        // Cascade pin on the upstream shell-pipe arm: a value
12865        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12866        // the canonical pipeline-to-bracket-class paste idiom)
12867        // routes through `FonteCaminhoShellPipe` not
12868        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12869        // paste is the load-bearing root-cause edit on every
12870        // probe-as-both value.
12871        let d = dep_with_fonte(DepSource::Path {
12872            caminho: "../caixa-teia | [tee]".into(),
12873        });
12874        let err = d.validate().unwrap_err();
12875        assert!(
12876            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12877            "got {err:?}",
12878        );
12879    }
12880
12881    #[test]
12882    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12883        // Cascade pin on the upstream shell-redirection arm: a
12884        // value carrying both `>` and `[` (`"../caixa-teia>log
12885        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12886        // redirect-plus-bracket chain" footgun) routes through
12887        // `FonteCaminhoShellRedirection` not
12888        // `FonteCaminhoShellBracketExpansion`. The input/output
12889        // redirection metachar carries the more self-locating
12890        // `byte` payload, so the prior arm wins on every
12891        // probe-as-both value.
12892        let d = dep_with_fonte(DepSource::Path {
12893            caminho: "../caixa-teia>log [ch]".into(),
12894        });
12895        let err = d.validate().unwrap_err();
12896        assert!(
12897            matches!(
12898                err,
12899                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12900            ),
12901            "got {err:?}",
12902        );
12903    }
12904
12905    #[test]
12906    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12907        // Cascade pin on the upstream backslash arm: a value
12908        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12909        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12910        // chain") routes through `FonteCaminhoBackslash` not
12911        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12912        // separator divergence is the load-bearing axis on every
12913        // probe-as-both value.
12914        let d = dep_with_fonte(DepSource::Path {
12915            caminho: "..\\caixa-teia\\[ch]".into(),
12916        });
12917        let err = d.validate().unwrap_err();
12918        assert!(
12919            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12920            "got {err:?}",
12921        );
12922    }
12923
12924    #[test]
12925    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12926        // Cascade pin on the embedded-control-byte arm: a value
12927        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12928        // the canonical paste-from-multiline-doc footgun where a
12929        // newline landed mid-caminho between two paste fragments)
12930        // routes through `FonteCaminhoControlChar` not
12931        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12932        // rejected-byte / NUL-`CString::new`-fail diagnostic is
12933        // the load-bearing axis on every value that probes
12934        // positive for both — mirrors the cascade discipline on
12935        // every prior arm.
12936        let d = dep_with_fonte(DepSource::Path {
12937            caminho: "../foo\n[ch]".into(),
12938        });
12939        let err = d.validate().unwrap_err();
12940        assert!(
12941            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12942            "got {err:?}",
12943        );
12944    }
12945
12946    #[test]
12947    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12948        // Cascade pin on the load-bearing leading-byte arm: a
12949        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12950        // routes through `FonteCaminhoAbsolute` not
12951        // `FonteCaminhoShellBracketExpansion` — the host-layout-
12952        // leak diagnostic is the load-bearing axis, the bracket-
12953        // expansion byte is the secondary observation. Same
12954        // precedence logic as every prior leading-byte arm.
12955        let d = dep_with_fonte(DepSource::Path {
12956            caminho: "/etc/[ch]".into(),
12957        });
12958        let err = d.validate().unwrap_err();
12959        assert!(
12960            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12961            "got {err:?}",
12962        );
12963    }
12964
12965    #[test]
12966    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12967        // Cascade pin on the upstream leading-`$` var-expansion
12968        // arm: a value carrying both a leading `$` and a `[`
12969        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12970        // variable + bracket-class at the head of a sibling-
12971        // workspace path" footgun) routes through
12972        // `FonteCaminhoVarExpansion` not
12973        // `FonteCaminhoShellBracketExpansion`. The leading-byte
12974        // shell-variable-expansion is the more self-locating
12975        // diagnostic on values that probe as both — same
12976        // load-bearing-leading-byte cascade discipline every
12977        // prior `:caminho` arm establishes.
12978        let d = dep_with_fonte(DepSource::Path {
12979            caminho: "$DIR/[ch]".into(),
12980        });
12981        let err = d.validate().unwrap_err();
12982        assert!(
12983            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12984            "got {err:?}",
12985        );
12986    }
12987
12988    #[test]
12989    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12990        // Cascade pin on the immediate-successor arm: a value
12991        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12992        // the canonical "I tab-completed a path that already had
12993        // a bracket-glob-character-class expansion tail" footgun)
12994        // routes through `FonteCaminhoShellBracketExpansion` not
12995        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12996        // is the more semantic-locating axis (an author who
12997        // removes the `[` typically also drops the trailing
12998        // separator since both are paste-from-shell artifacts).
12999        let d = dep_with_fonte(DepSource::Path {
13000            caminho: "../[a-z]/".into(),
13001        });
13002        let err = d.validate().unwrap_err();
13003        assert!(
13004            matches!(
13005                err,
13006                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13007            ),
13008            "got {err:?}",
13009        );
13010    }
13011
13012    #[test]
13013    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13014        // Diagnostic-shape pin (peer with
13015        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13016        // on the closest two-byte peer arm): the error's Display
13017        // surfaces the offending `:nome`, the offending `:caminho`
13018        // verbatim, the offending byte's hex / character form, and
13019        // names the shell-bracket-expansion / glob-character-class
13020        // footgun explicitly so a `feira lint` run can render the
13021        // diagnostic without re-parsing.
13022        let d = dep_with_fonte(DepSource::Path {
13023            caminho: "../caixa-[a-z]/build".into(),
13024        });
13025        let rendered = d.validate().unwrap_err().to_string();
13026        assert!(
13027            rendered.contains("caixa-teia"),
13028            "diagnostic must name the offending dep: {rendered}",
13029        );
13030        assert!(
13031            rendered.contains("../caixa-[a-z]/build"),
13032            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13033        );
13034        assert!(
13035            rendered.contains("0x5b"),
13036            "diagnostic must surface the offending byte hex: {rendered:?}",
13037        );
13038        assert!(
13039            rendered.contains("bracket-expansion"),
13040            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13041        );
13042        assert!(
13043            rendered.contains("glob-character-class"),
13044            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13045             {rendered:?}",
13046        );
13047    }
13048
13049    #[test]
13050    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13051        // The canonical paste-from-shell-history strong-quoted
13052        // sibling-workspace-path footgun: an author copies a
13053        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13054        // quoting preserved the path across a whitespace paste
13055        // boundary and silently passed every prior arm
13056        // (`Path::is_absolute` false on `'..`, no control bytes, no
13057        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13058        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13059        // doesn't end in `/`; the leading-`$` f4efe9c
13060        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13061        // value starts with `'` not `$`). The lacre embedded the
13062        // value verbatim, the resolver folded it through
13063        // `Path::join` looking for a literal `./'../caixa-teia'`
13064        // subdirectory, and the failure surfaced at resolve time
13065        // with a non-self-locating `No such file or directory`
13066        // error. The new arm moves the rejection to validate time
13067        // and names the offending dep + caminho + byte verbatim.
13068        // The arm fires on the first `'` encountered.
13069        let d = dep_with_fonte(DepSource::Path {
13070            caminho: "'../caixa-teia'".into(),
13071        });
13072        let err = d.validate().unwrap_err();
13073        let DepError::FonteCaminhoShellQuoteGrouping {
13074            nome,
13075            caminho,
13076            byte,
13077        } = err
13078        else {
13079            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13080        };
13081        assert_eq!(nome, "caixa-teia");
13082        assert_eq!(caminho, "'../caixa-teia'");
13083        assert_eq!(byte, b'\'');
13084    }
13085
13086    #[test]
13087    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13088        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13089        // — the canonical paste-from-JSON-config / paste-from-YAML-
13090        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13091        // tatara-lisp-string-literal cross-idiom leak). Pinned
13092        // separately from the single-quote shape so the gate's
13093        // contract is "any `'` or `\"` anywhere", not single-byte
13094        // coverage. Mirrors the peer
13095        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13096        // shape on the immediate-predecessor
13097        // `FonteCaminhoShellBracketExpansion` arm.
13098        let d = dep_with_fonte(DepSource::Path {
13099            caminho: "\"../caixa-teia\"".into(),
13100        });
13101        let err = d.validate().unwrap_err();
13102        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13103            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13104        };
13105        assert_eq!(byte, b'"');
13106    }
13107
13108    #[test]
13109    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13110        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13111        // canonical "I pasted a JSON key-value pair fragment into
13112        // the middle of the path" idiom). Pinned separately from
13113        // the leading-byte shape so the gate covers every position,
13114        // not only leading.
13115        let d = dep_with_fonte(DepSource::Path {
13116            caminho: "../\"caixa-teia\"".into(),
13117        });
13118        let err = d.validate().unwrap_err();
13119        assert!(
13120            matches!(
13121                err,
13122                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13123            ),
13124            "got {err:?}",
13125        );
13126    }
13127
13128    #[test]
13129    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13130        // The canonical YAML double-quoted flow-scalar cross-idiom
13131        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13132        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13133        // values.yaml / K8s manifest and dropped it verbatim into
13134        // the `:caminho` slot including the `path: ` key prefix"
13135        // paste-idiom). The arm fires on the first `"` encountered;
13136        // pinned so the gate's coverage extends from the bare-quote
13137        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13138        // shape.
13139        let d = dep_with_fonte(DepSource::Path {
13140            caminho: "path: \"../caixa-teia\"".into(),
13141        });
13142        let err = d.validate().unwrap_err();
13143        assert!(
13144            matches!(
13145                err,
13146                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13147            ),
13148            "got {err:?}",
13149        );
13150    }
13151
13152    #[test]
13153    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13154        // The positive-control pin: the gate targets only `'` /
13155        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13156        // The canonical relative POSIX path (`"../caixa-teia"`) and
13157        // a nested deeply-pathed variant with adjacent printable
13158        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13159        // to validate cleanly so the gate doesn't widen to a "no
13160        // printable punctuation anywhere" sweep that would defeat
13161        // the entire path-fonte author surface. Peer with
13162        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13163        // on the immediate-predecessor arm.
13164        let d = dep_with_fonte(DepSource::Path {
13165            caminho: "../caixa-teia/sub-dir.v2".into(),
13166        });
13167        d.validate().unwrap();
13168    }
13169
13170    #[test]
13171    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13172        // Cascade pin on the immediate-predecessor arm: a value
13173        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13174        // "I pasted a glob-character-class followed by a strong-
13175        // quoted literal tail" footgun) routes through
13176        // `FonteCaminhoShellBracketExpansion` not
13177        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13178        // expansion is the load-bearing root-cause edit on every
13179        // probe-as-both value; same cascade discipline every prior
13180        // `:caminho` arm establishes.
13181        let d = dep_with_fonte(DepSource::Path {
13182            caminho: "../[a-z]'x'".into(),
13183        });
13184        let err = d.validate().unwrap_err();
13185        assert!(
13186            matches!(
13187                err,
13188                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13189            ),
13190            "got {err:?}",
13191        );
13192    }
13193
13194    #[test]
13195    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13196        // Cascade pin on the upstream shell-brace-expansion arm: a
13197        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13198        // canonical "I pasted a brace-expansion fan followed by a
13199        // strong-quoted literal tail" footgun) routes through
13200        // `FonteCaminhoShellBraceExpansion` not
13201        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13202        // is the load-bearing root-cause edit on every probe-as-
13203        // both value.
13204        let d = dep_with_fonte(DepSource::Path {
13205            caminho: "../{a,b}'x'".into(),
13206        });
13207        let err = d.validate().unwrap_err();
13208        assert!(
13209            matches!(
13210                err,
13211                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13212            ),
13213            "got {err:?}",
13214        );
13215    }
13216
13217    #[test]
13218    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13219        // Cascade pin on the upstream shell-subshell-grouping arm:
13220        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13221        // the canonical "I pasted a subshell-grouping followed by
13222        // a strong-quoted literal tail" footgun) routes through
13223        // `FonteCaminhoShellSubshellGrouping` not
13224        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13225        // `$(<cmd>)` command-substitution boundary is the load-
13226        // bearing axis on every probe-as-both value.
13227        let d = dep_with_fonte(DepSource::Path {
13228            caminho: "../(cd foo)/'x'".into(),
13229        });
13230        let err = d.validate().unwrap_err();
13231        assert!(
13232            matches!(
13233                err,
13234                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13235            ),
13236            "got {err:?}",
13237        );
13238    }
13239
13240    #[test]
13241    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13242        // Cascade pin on the upstream shell-glob arm: a value
13243        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13244        // canonical "I pasted a `*` unbounded pathname-expansion
13245        // followed by a strong-quoted literal tail" footgun) routes
13246        // through `FonteCaminhoShellGlob` not
13247        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13248        // expansion sentinel is the load-bearing root-cause edit
13249        // on every probe-as-both value.
13250        let d = dep_with_fonte(DepSource::Path {
13251            caminho: "../caixa-teia/*'x'".into(),
13252        });
13253        let err = d.validate().unwrap_err();
13254        assert!(
13255            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13256            "got {err:?}",
13257        );
13258    }
13259
13260    #[test]
13261    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13262        // Cascade pin on the upstream shell-command-substitution
13263        // arm: a value carrying both a backtick and `'`
13264        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13265        // legacy-backtick command-substitution followed by a
13266        // strong-quoted literal tail" footgun) routes through
13267        // `FonteCaminhoShellCommandSubstitution` not
13268        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13269        // command-injection vector is the load-bearing root-cause
13270        // edit on every probe-as-both value.
13271        let d = dep_with_fonte(DepSource::Path {
13272            caminho: "../`whoami`/'x'".into(),
13273        });
13274        let err = d.validate().unwrap_err();
13275        assert!(
13276            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13277            "got {err:?}",
13278        );
13279    }
13280
13281    #[test]
13282    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13283        // Cascade pin on the upstream shell-background arm: a value
13284        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13285        // canonical "I pasted a `cmd & 'literal'` background-launch
13286        // + quote chain" footgun) routes through
13287        // `FonteCaminhoShellBackground` not
13288        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13289        // tail is the load-bearing root-cause edit on every
13290        // probe-as-both value.
13291        let d = dep_with_fonte(DepSource::Path {
13292            caminho: "../caixa-teia & 'x'".into(),
13293        });
13294        let err = d.validate().unwrap_err();
13295        assert!(
13296            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13297            "got {err:?}",
13298        );
13299    }
13300
13301    #[test]
13302    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13303        // Cascade pin on the upstream shell-semicolon arm: a value
13304        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13305        // canonical sequential-cleanup + quote paste idiom) routes
13306        // through `FonteCaminhoShellSemicolon` not
13307        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13308        // separator paste is the load-bearing root-cause edit on
13309        // every probe-as-both value.
13310        let d = dep_with_fonte(DepSource::Path {
13311            caminho: "../caixa-teia; 'x'".into(),
13312        });
13313        let err = d.validate().unwrap_err();
13314        assert!(
13315            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13316            "got {err:?}",
13317        );
13318    }
13319
13320    #[test]
13321    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13322        // Cascade pin on the upstream shell-pipe arm: a value
13323        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13324        // canonical pipeline-to-quoted-literal paste idiom) routes
13325        // through `FonteCaminhoShellPipe` not
13326        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13327        // is the load-bearing root-cause edit on every probe-as-
13328        // both value.
13329        let d = dep_with_fonte(DepSource::Path {
13330            caminho: "../caixa-teia | 'x'".into(),
13331        });
13332        let err = d.validate().unwrap_err();
13333        assert!(
13334            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13335            "got {err:?}",
13336        );
13337    }
13338
13339    #[test]
13340    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13341        // Cascade pin on the upstream shell-redirection arm: a
13342        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13343        // — the canonical "I pasted a `cmd > log 'literal'`
13344        // redirect-plus-quote chain" footgun) routes through
13345        // `FonteCaminhoShellRedirection` not
13346        // `FonteCaminhoShellQuoteGrouping`. The input/output
13347        // redirection metachar carries the more self-locating
13348        // `byte` payload, so the prior arm wins on every probe-as-
13349        // both value.
13350        let d = dep_with_fonte(DepSource::Path {
13351            caminho: "../caixa-teia>log 'x'".into(),
13352        });
13353        let err = d.validate().unwrap_err();
13354        assert!(
13355            matches!(
13356                err,
13357                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13358            ),
13359            "got {err:?}",
13360        );
13361    }
13362
13363    #[test]
13364    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13365        // Cascade pin on the upstream backslash arm: a value
13366        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13367        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13368        // chain" footgun) routes through `FonteCaminhoBackslash`
13369        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13370        // separator divergence is the load-bearing axis on every
13371        // probe-as-both value.
13372        let d = dep_with_fonte(DepSource::Path {
13373            caminho: "..\\caixa-teia\\'x'".into(),
13374        });
13375        let err = d.validate().unwrap_err();
13376        assert!(
13377            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13378            "got {err:?}",
13379        );
13380    }
13381
13382    #[test]
13383    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13384        // Cascade pin on the embedded-control-byte arm: a value
13385        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13386        // the canonical paste-from-multiline-doc footgun where a
13387        // newline landed mid-caminho between two paste fragments)
13388        // routes through `FonteCaminhoControlChar` not
13389        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13390        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13391        // the load-bearing axis on every value that probes
13392        // positive for both — mirrors the cascade discipline on
13393        // every prior arm.
13394        let d = dep_with_fonte(DepSource::Path {
13395            caminho: "../foo\n'x'".into(),
13396        });
13397        let err = d.validate().unwrap_err();
13398        assert!(
13399            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13400            "got {err:?}",
13401        );
13402    }
13403
13404    #[test]
13405    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13406        // Cascade pin on the load-bearing leading-byte arm: a
13407        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13408        // through `FonteCaminhoAbsolute` not
13409        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13410        // diagnostic is the load-bearing axis, the quote byte is
13411        // the secondary observation. Same precedence logic as every
13412        // prior leading-byte arm.
13413        let d = dep_with_fonte(DepSource::Path {
13414            caminho: "/etc/'x'".into(),
13415        });
13416        let err = d.validate().unwrap_err();
13417        assert!(
13418            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13419            "got {err:?}",
13420        );
13421    }
13422
13423    #[test]
13424    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13425        // Cascade pin on the upstream leading-`$` var-expansion
13426        // arm: a value carrying both a leading `$` and a `'`
13427        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13428        // variable + quoted literal at the head of a sibling-
13429        // workspace path" footgun) routes through
13430        // `FonteCaminhoVarExpansion` not
13431        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13432        // shell-variable-expansion is the more self-locating
13433        // diagnostic on values that probe as both — same
13434        // load-bearing-leading-byte cascade discipline every
13435        // prior `:caminho` arm establishes.
13436        let d = dep_with_fonte(DepSource::Path {
13437            caminho: "$DIR/'x'".into(),
13438        });
13439        let err = d.validate().unwrap_err();
13440        assert!(
13441            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13442            "got {err:?}",
13443        );
13444    }
13445
13446    #[test]
13447    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13448        // Cascade pin on the immediate-successor arm: a value
13449        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13450        // — the canonical "I tab-completed a path whose strong-
13451        // quoted body already carried the quoting from a shell-
13452        // history paste" footgun) routes through
13453        // `FonteCaminhoShellQuoteGrouping` not
13454        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13455        // is the more semantic-locating axis (an author who removes
13456        // the `'` typically also drops the trailing separator since
13457        // both are paste-from-shell artifacts).
13458        let d = dep_with_fonte(DepSource::Path {
13459            caminho: "../'caixa-teia'/".into(),
13460        });
13461        let err = d.validate().unwrap_err();
13462        assert!(
13463            matches!(
13464                err,
13465                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13466            ),
13467            "got {err:?}",
13468        );
13469    }
13470
13471    #[test]
13472    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13473        // Diagnostic-shape pin (peer with
13474        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13475        // on the closest two-byte peer arm): the error's Display
13476        // surfaces the offending `:nome`, the offending `:caminho`
13477        // verbatim, the offending byte's hex / character form, and
13478        // names the shell-quote-grouping / cross-config-DSL-string-
13479        // literal-delimiter footgun explicitly so a `feira lint`
13480        // run can render the diagnostic without re-parsing.
13481        let d = dep_with_fonte(DepSource::Path {
13482            caminho: "'../caixa-teia'".into(),
13483        });
13484        let rendered = d.validate().unwrap_err().to_string();
13485        assert!(
13486            rendered.contains("caixa-teia"),
13487            "diagnostic must name the offending dep: {rendered}",
13488        );
13489        assert!(
13490            rendered.contains("'../caixa-teia'"),
13491            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13492        );
13493        assert!(
13494            rendered.contains("0x27"),
13495            "diagnostic must surface the offending byte hex: {rendered:?}",
13496        );
13497        assert!(
13498            rendered.contains("quote-grouping"),
13499            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13500        );
13501        assert!(
13502            rendered.contains("string-literal"),
13503            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13504             vocabulary: {rendered:?}",
13505        );
13506    }
13507
13508    #[test]
13509    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13510        // The canonical paste-from-shell-history-with-trailing-
13511        // annotation footgun: an author pastes a `cd ../caixa-teia
13512        // # legacy sibling` shell-history one-liner whose unquoted `#`
13513        // comment-lead separates the path from an inline annotation.
13514        // The POSIX shell trims the annotation to `../caixa-teia`
13515        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13516        // `Path::is_absolute` returns false on `..`, `#` is neither
13517        // a leading-byte sentinel nor a control byte nor `\` nor
13518        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13519        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13520        // `"`, and the value's last byte isn't `/` — so the value
13521        // silently passed every prior arm. The resolver folded the
13522        // value through `Path::join` looking for a literal
13523        // `./../caixa-teia # legacy sibling` subdirectory and the
13524        // failure surfaced at resolve time with a non-self-locating
13525        // `No such file or directory` error. The new arm moves the
13526        // rejection to validate time and names the offending dep +
13527        // caminho + byte verbatim.
13528        let d = dep_with_fonte(DepSource::Path {
13529            caminho: "../caixa-teia # legacy sibling".into(),
13530        });
13531        let err = d.validate().unwrap_err();
13532        let DepError::FonteCaminhoShellComment {
13533            nome,
13534            caminho,
13535            byte,
13536        } = err
13537        else {
13538            panic!("expected FonteCaminhoShellComment, got {err:?}");
13539        };
13540        assert_eq!(nome, "caixa-teia");
13541        assert_eq!(caminho, "../caixa-teia # legacy sibling");
13542        assert_eq!(byte, b'#');
13543    }
13544
13545    #[test]
13546    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13547        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13548        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
13549        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
13550        // scalar-plus-comment entry out of an aligned values.yaml and
13551        // dropped it verbatim into the `:caminho` slot" paste-idiom).
13552        // Pinned separately from the shell-history shape so the
13553        // gate's coverage extends from the single-space `#` shape to
13554        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
13555        // requires the `#` to be preceded by whitespace to lex as a
13556        // comment (bare `foo#bar` is a single scalar); the double-
13557        // space paste from an aligned manifest is the canonical
13558        // shape.
13559        let d = dep_with_fonte(DepSource::Path {
13560            caminho: "../caixa-teia  # pin".into(),
13561        });
13562        let err = d.validate().unwrap_err();
13563        assert!(
13564            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13565            "got {err:?}",
13566        );
13567    }
13568
13569    #[test]
13570    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13571        // The URL-fragment-identifier paste shape
13572        // (`"../caixa-teia#readme"` — the canonical
13573        // paste-from-browser-address-bar permalink shape where the
13574        // browser preserved the `#anchor` tail on the copy). Pinned
13575        // separately from the whitespace-separated shell / YAML
13576        // comment shapes so the gate covers the unpadded RFC 3986
13577        // §3.5 fragment-delimiter position too, not only positions
13578        // preceded by unquoted whitespace. Peer with the immediate-
13579        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13580        // (a68f818) which closes the same byte under the same URL-
13581        // fragment-identifier banner.
13582        let d = dep_with_fonte(DepSource::Path {
13583            caminho: "../caixa-teia#readme".into(),
13584        });
13585        let err = d.validate().unwrap_err();
13586        assert!(
13587            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13588            "got {err:?}",
13589        );
13590    }
13591
13592    #[test]
13593    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13594        // Leading-position `#` shape (`"#../caixa-teia"` — the
13595        // "I copied a shell-comment-out entry from a commented-out
13596        // dep row" footgun). Pinned separately from the embedded
13597        // shapes so the gate covers every position, not only
13598        // whitespace-preceded / mid-value.
13599        let d = dep_with_fonte(DepSource::Path {
13600            caminho: "#../caixa-teia".into(),
13601        });
13602        let err = d.validate().unwrap_err();
13603        assert!(
13604            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13605            "got {err:?}",
13606        );
13607    }
13608
13609    #[test]
13610    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13611        // The positive-control pin: the gate targets only `#`,
13612        // never adjacent printable ASCII or POSIX-valid bytes. The
13613        // canonical relative POSIX path (`"../caixa-teia"`) and a
13614        // nested deeply-pathed variant with adjacent printable
13615        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13616        // to validate cleanly so the gate doesn't widen to a "no
13617        // printable punctuation anywhere" sweep that would defeat
13618        // the entire path-fonte author surface. Peer with
13619        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13620        // on the immediate-predecessor arm.
13621        let d = dep_with_fonte(DepSource::Path {
13622            caminho: "../caixa-teia/sub-dir.v2".into(),
13623        });
13624        d.validate().unwrap();
13625    }
13626
13627    #[test]
13628    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13629        // Cascade pin on the immediate-predecessor arm: a value
13630        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13631        // "I pasted a strong-quoted literal followed by a URL-
13632        // fragment permalink tail" footgun) routes through
13633        // `FonteCaminhoShellQuoteGrouping` not
13634        // `FonteCaminhoShellComment`. The shell-string-literal-
13635        // delimiter is the load-bearing root-cause edit on every
13636        // probe-as-both value; same cascade discipline every prior
13637        // `:caminho` arm establishes.
13638        let d = dep_with_fonte(DepSource::Path {
13639            caminho: "../'x'#pin".into(),
13640        });
13641        let err = d.validate().unwrap_err();
13642        assert!(
13643            matches!(
13644                err,
13645                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13646            ),
13647            "got {err:?}",
13648        );
13649    }
13650
13651    #[test]
13652    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13653        // Cascade pin on the upstream shell-bracket-expansion arm:
13654        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13655        // canonical "I pasted a glob-character-class followed by a
13656        // URL-fragment tail" footgun) routes through
13657        // `FonteCaminhoShellBracketExpansion` not
13658        // `FonteCaminhoShellComment`. The glob-character-class
13659        // expansion is the load-bearing root-cause edit on every
13660        // probe-as-both value.
13661        let d = dep_with_fonte(DepSource::Path {
13662            caminho: "../[a-z]#pin".into(),
13663        });
13664        let err = d.validate().unwrap_err();
13665        assert!(
13666            matches!(
13667                err,
13668                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13669            ),
13670            "got {err:?}",
13671        );
13672    }
13673
13674    #[test]
13675    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13676        // Cascade pin on the upstream shell-brace-expansion arm: a
13677        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13678        // canonical "I pasted a brace-expansion fan followed by a
13679        // URL-fragment tail" footgun) routes through
13680        // `FonteCaminhoShellBraceExpansion` not
13681        // `FonteCaminhoShellComment`. The brace-expansion fan is the
13682        // load-bearing root-cause edit on every probe-as-both value.
13683        let d = dep_with_fonte(DepSource::Path {
13684            caminho: "../{a,b}#pin".into(),
13685        });
13686        let err = d.validate().unwrap_err();
13687        assert!(
13688            matches!(
13689                err,
13690                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13691            ),
13692            "got {err:?}",
13693        );
13694    }
13695
13696    #[test]
13697    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13698        // Cascade pin on the upstream shell-subshell-grouping arm:
13699        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13700        // the canonical "I pasted a subshell-grouping followed by a
13701        // URL-fragment tail" footgun) routes through
13702        // `FonteCaminhoShellSubshellGrouping` not
13703        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13704        // command-substitution boundary is the load-bearing axis on
13705        // every probe-as-both value.
13706        let d = dep_with_fonte(DepSource::Path {
13707            caminho: "../(cd foo)#pin".into(),
13708        });
13709        let err = d.validate().unwrap_err();
13710        assert!(
13711            matches!(
13712                err,
13713                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13714            ),
13715            "got {err:?}",
13716        );
13717    }
13718
13719    #[test]
13720    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13721        // Cascade pin on the upstream shell-glob arm: a value
13722        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13723        // canonical "I pasted a `*` unbounded pathname-expansion
13724        // followed by a URL-fragment tail" footgun) routes through
13725        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13726        // The unbounded pathname-expansion sentinel is the load-
13727        // bearing root-cause edit on every probe-as-both value.
13728        let d = dep_with_fonte(DepSource::Path {
13729            caminho: "../caixa-teia/*#pin".into(),
13730        });
13731        let err = d.validate().unwrap_err();
13732        assert!(
13733            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13734            "got {err:?}",
13735        );
13736    }
13737
13738    #[test]
13739    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13740        // Cascade pin on the upstream shell-command-substitution
13741        // arm: a value carrying both a backtick and `#`
13742        // (``"../`whoami`#pin"`` — the canonical "I pasted a
13743        // legacy-backtick command-substitution followed by a URL-
13744        // fragment tail" footgun) routes through
13745        // `FonteCaminhoShellCommandSubstitution` not
13746        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13747        // injection vector is the load-bearing root-cause edit on
13748        // every probe-as-both value.
13749        let d = dep_with_fonte(DepSource::Path {
13750            caminho: "../`whoami`#pin".into(),
13751        });
13752        let err = d.validate().unwrap_err();
13753        assert!(
13754            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13755            "got {err:?}",
13756        );
13757    }
13758
13759    #[test]
13760    fn fonte_caminho_shell_background_fires_before_shell_comment() {
13761        // Cascade pin on the upstream shell-background arm: a value
13762        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13763        // the canonical "I pasted a `cmd &` background-launch
13764        // followed by a URL-fragment tail" footgun) routes through
13765        // `FonteCaminhoShellBackground` not
13766        // `FonteCaminhoShellComment`. The background-launch tail is
13767        // the load-bearing root-cause edit on every probe-as-both
13768        // value.
13769        let d = dep_with_fonte(DepSource::Path {
13770            caminho: "../caixa-teia&pin#tail".into(),
13771        });
13772        let err = d.validate().unwrap_err();
13773        assert!(
13774            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13775            "got {err:?}",
13776        );
13777    }
13778
13779    #[test]
13780    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13781        // Cascade pin on the upstream shell-semicolon arm: a value
13782        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13783        // the canonical sequential-cleanup + URL-fragment paste
13784        // idiom) routes through `FonteCaminhoShellSemicolon` not
13785        // `FonteCaminhoShellComment`. The sequential-command-
13786        // separator paste is the load-bearing root-cause edit on
13787        // every probe-as-both value.
13788        let d = dep_with_fonte(DepSource::Path {
13789            caminho: "../caixa-teia;pin#tail".into(),
13790        });
13791        let err = d.validate().unwrap_err();
13792        assert!(
13793            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13794            "got {err:?}",
13795        );
13796    }
13797
13798    #[test]
13799    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13800        // Cascade pin on the upstream shell-pipe arm: a value
13801        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13802        // the canonical pipeline-to-URL-fragment paste idiom) routes
13803        // through `FonteCaminhoShellPipe` not
13804        // `FonteCaminhoShellComment`. The pipeline-tail paste is
13805        // the load-bearing root-cause edit on every probe-as-both
13806        // value.
13807        let d = dep_with_fonte(DepSource::Path {
13808            caminho: "../caixa-teia|pin#tail".into(),
13809        });
13810        let err = d.validate().unwrap_err();
13811        assert!(
13812            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13813            "got {err:?}",
13814        );
13815    }
13816
13817    #[test]
13818    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13819        // Cascade pin on the upstream shell-redirection arm: a
13820        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13821        // — the canonical "I pasted a `cmd > log` redirect followed
13822        // by a URL-fragment tail" footgun) routes through
13823        // `FonteCaminhoShellRedirection` not
13824        // `FonteCaminhoShellComment`. The input/output redirection
13825        // metachar carries the more self-locating `byte` payload,
13826        // so the prior arm wins on every probe-as-both value.
13827        let d = dep_with_fonte(DepSource::Path {
13828            caminho: "../caixa-teia>log#pin".into(),
13829        });
13830        let err = d.validate().unwrap_err();
13831        assert!(
13832            matches!(
13833                err,
13834                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13835            ),
13836            "got {err:?}",
13837        );
13838    }
13839
13840    #[test]
13841    fn fonte_caminho_backslash_fires_before_shell_comment() {
13842        // Cascade pin on the upstream backslash arm: a value
13843        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13844        // canonical "I pasted a Windows-shell path followed by a
13845        // URL-fragment tail" footgun) routes through
13846        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13847        // The cross-host-OS-separator divergence is the load-
13848        // bearing axis on every probe-as-both value.
13849        let d = dep_with_fonte(DepSource::Path {
13850            caminho: "..\\caixa-teia#pin".into(),
13851        });
13852        let err = d.validate().unwrap_err();
13853        assert!(
13854            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13855            "got {err:?}",
13856        );
13857    }
13858
13859    #[test]
13860    fn fonte_caminho_control_char_fires_before_shell_comment() {
13861        // Cascade pin on the embedded-control-byte arm: a value
13862        // carrying both a control byte and `#` (`"../foo\n#pin"` —
13863        // the canonical paste-from-multiline-doc footgun where a
13864        // newline landed mid-caminho between the path and an
13865        // annotation) routes through `FonteCaminhoControlChar` not
13866        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13867        // byte diagnostic is the load-bearing axis on every value
13868        // that probes positive for both — mirrors the cascade
13869        // discipline on every prior arm.
13870        let d = dep_with_fonte(DepSource::Path {
13871            caminho: "../foo\n#pin".into(),
13872        });
13873        let err = d.validate().unwrap_err();
13874        assert!(
13875            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13876            "got {err:?}",
13877        );
13878    }
13879
13880    #[test]
13881    fn fonte_caminho_absolute_fires_before_shell_comment() {
13882        // Cascade pin on the load-bearing leading-byte arm: a
13883        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13884        // routes through `FonteCaminhoAbsolute` not
13885        // `FonteCaminhoShellComment` — the host-layout-leak
13886        // diagnostic is the load-bearing axis, the fragment byte is
13887        // the secondary observation. Same precedence logic as every
13888        // prior leading-byte arm.
13889        let d = dep_with_fonte(DepSource::Path {
13890            caminho: "/etc/foo#pin".into(),
13891        });
13892        let err = d.validate().unwrap_err();
13893        assert!(
13894            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13895            "got {err:?}",
13896        );
13897    }
13898
13899    #[test]
13900    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13901        // Cascade pin on the upstream leading-`$` var-expansion
13902        // arm: a value carrying both a leading `$` and a `#`
13903        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13904        // shell-variable at the head of a sibling-workspace path
13905        // followed by a URL-fragment tail" footgun) routes through
13906        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13907        // The leading-byte shell-variable-expansion is the more
13908        // self-locating diagnostic on values that probe as both.
13909        let d = dep_with_fonte(DepSource::Path {
13910            caminho: "$DIR/foo#pin".into(),
13911        });
13912        let err = d.validate().unwrap_err();
13913        assert!(
13914            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13915            "got {err:?}",
13916        );
13917    }
13918
13919    #[test]
13920    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13921        // Cascade pin on the immediate-successor arm: a value
13922        // carrying both `#` and a trailing `/`
13923        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13924        // a URL-fragment-carrying path" footgun) routes through
13925        // `FonteCaminhoShellComment` not
13926        // `FonteCaminhoTrailingSlash`. The embedded fragment /
13927        // comment-lead byte is the more semantic-locating axis (an
13928        // author who removes the `#pin` fragment typically also
13929        // drops the trailing separator since both are paste-from-
13930        // URL / paste-from-shell-tab-completion artifacts).
13931        let d = dep_with_fonte(DepSource::Path {
13932            caminho: "../caixa-teia#pin/".into(),
13933        });
13934        let err = d.validate().unwrap_err();
13935        assert!(
13936            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13937            "got {err:?}",
13938        );
13939    }
13940
13941    #[test]
13942    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13943        // Diagnostic-shape pin (peer with
13944        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13945        // on the immediate-predecessor arm): the error's Display
13946        // surfaces the offending `:nome`, the offending `:caminho`
13947        // verbatim, the offending byte's hex / character form, and
13948        // names the shell-comment / URL-fragment-identifier /
13949        // YAML-comment cross-config-DSL footgun explicitly so a
13950        // `feira lint` run can render the diagnostic without
13951        // re-parsing.
13952        let d = dep_with_fonte(DepSource::Path {
13953            caminho: "../caixa-teia#readme".into(),
13954        });
13955        let rendered = d.validate().unwrap_err().to_string();
13956        assert!(
13957            rendered.contains("caixa-teia"),
13958            "diagnostic must name the offending dep: {rendered}",
13959        );
13960        assert!(
13961            rendered.contains("../caixa-teia#readme"),
13962            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13963        );
13964        assert!(
13965            rendered.contains("0x23"),
13966            "diagnostic must surface the offending byte hex: {rendered:?}",
13967        );
13968        assert!(
13969            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13970            "diagnostic must name the shell-comment footgun: {rendered:?}",
13971        );
13972        assert!(
13973            rendered.contains("fragment") || rendered.contains("URL-fragment"),
13974            "diagnostic must reference the URL-fragment-identifier vocabulary: \
13975             {rendered:?}",
13976        );
13977    }
13978
13979    #[test]
13980    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13981        // The canonical paste-from-browser-address-bar percent-
13982        // encoded-space footgun: an author copies `../caixa%20teia`
13983        // out of a URL-encoded README hyperlink / browser address
13984        // bar / percent-encoded permalink expecting `%20` to decode
13985        // to a literal space at the filesystem layer. POSIX
13986        // `std::path::Path` treats `%` as a literal path-component
13987        // byte, so `Path::join` looks for a literal
13988        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13989        // returns false on `..`, `%` is neither a leading-byte
13990        // sentinel nor a control byte nor `\` nor `<` / `>` nor
13991        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13992        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13993        // and the value's last byte isn't `/` — so the value
13994        // silently passed every prior arm. The new arm moves the
13995        // rejection to validate time and names the offending dep +
13996        // caminho + byte verbatim.
13997        let d = dep_with_fonte(DepSource::Path {
13998            caminho: "../caixa%20teia".into(),
13999        });
14000        let err = d.validate().unwrap_err();
14001        let DepError::FonteCaminhoUrlPercentEncoding {
14002            nome,
14003            caminho,
14004            byte,
14005        } = err
14006        else {
14007            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14008        };
14009        assert_eq!(nome, "caixa-teia");
14010        assert_eq!(caminho, "../caixa%20teia");
14011        assert_eq!(byte, b'%');
14012    }
14013
14014    #[test]
14015    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14016        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14017        // intending the `%2F` as the URL encoding of `/`) locks a
14018        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14019        // the byte-identical `path:../caixa/teia` form. Pinned
14020        // separately from the space-encoded shape so the gate's
14021        // coverage extends past the single canonical `%20` example
14022        // to any two-hex-digit percent-encoded sequence.
14023        let d = dep_with_fonte(DepSource::Path {
14024            caminho: "../caixa%2Fteia".into(),
14025        });
14026        let err = d.validate().unwrap_err();
14027        assert!(
14028            matches!(
14029                err,
14030                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14031            ),
14032            "got {err:?}",
14033        );
14034    }
14035
14036    #[test]
14037    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14038        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14039        // where `%` isn't followed by two hex digits) — every
14040        // WHATWG-conformant URL parser rejects the value at parse
14041        // time per RFC 3986 §2.1, but the byte would silently ride
14042        // into the lacre before the resolver subprocess crosses the
14043        // URL-parser boundary. Pinned separately from the well-
14044        // formed `%HH` shapes so the gate covers every percent-
14045        // occurrence, not only strictly-conformant escapes.
14046        let d = dep_with_fonte(DepSource::Path {
14047            caminho: "../caixa-teia%foo".into(),
14048        });
14049        let err = d.validate().unwrap_err();
14050        assert!(
14051            matches!(
14052                err,
14053                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14054            ),
14055            "got {err:?}",
14056        );
14057    }
14058
14059    #[test]
14060    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14061        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14062        // — the canonical paste-from-top-of-doc YAML directive
14063        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14064        // separately from embedded shapes so the gate covers the
14065        // leading-position `%` too, not only mid-value occurrences.
14066        let d = dep_with_fonte(DepSource::Path {
14067            caminho: "%YAML/../caixa-teia".into(),
14068        });
14069        let err = d.validate().unwrap_err();
14070        assert!(
14071            matches!(
14072                err,
14073                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14074            ),
14075            "got {err:?}",
14076        );
14077    }
14078
14079    #[test]
14080    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14081        // The printf-format-specifier paste shape
14082        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14083        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14084        // 134 format-string-injection vector). Pinned separately
14085        // from the URL-encoding shapes so the gate's rationale
14086        // extends past the RFC 3986 axis to the C / POSIX printf
14087        // format-directive-lead axis.
14088        let d = dep_with_fonte(DepSource::Path {
14089            caminho: "../caixa-%s-teia".into(),
14090        });
14091        let err = d.validate().unwrap_err();
14092        assert!(
14093            matches!(
14094                err,
14095                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14096            ),
14097            "got {err:?}",
14098        );
14099    }
14100
14101    #[test]
14102    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14103        // The positive-control pin: the gate targets only `%`,
14104        // never adjacent printable ASCII or POSIX-valid bytes. The
14105        // canonical relative POSIX path (`"../caixa-teia"`) and a
14106        // nested deeply-pathed variant with adjacent printable
14107        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14108        // to validate cleanly so the gate doesn't widen to a "no
14109        // printable punctuation anywhere" sweep that would defeat
14110        // the entire path-fonte author surface. Peer with
14111        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14112        // on the immediate-predecessor arm.
14113        let d = dep_with_fonte(DepSource::Path {
14114            caminho: "../caixa-teia/sub-dir.v2".into(),
14115        });
14116        d.validate().unwrap();
14117    }
14118
14119    #[test]
14120    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14121        // Cascade pin on the immediate-predecessor arm: a value
14122        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14123        // canonical "I pasted a URL-fragment permalink followed by a
14124        // percent-encoded space tail" footgun) routes through
14125        // `FonteCaminhoShellComment` not
14126        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14127        // identifier is the load-bearing downstream-truncation edit
14128        // on every probe-as-both value; same cascade discipline
14129        // every prior `:caminho` arm establishes.
14130        let d = dep_with_fonte(DepSource::Path {
14131            caminho: "../caixa-teia#pin%20".into(),
14132        });
14133        let err = d.validate().unwrap_err();
14134        assert!(
14135            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14136            "got {err:?}",
14137        );
14138    }
14139
14140    #[test]
14141    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14142        // Cascade pin on the upstream shell-quote-grouping arm: a
14143        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14144        // canonical "I pasted a strong-quoted literal followed by
14145        // a percent-encoded space" footgun) routes through
14146        // `FonteCaminhoShellQuoteGrouping` not
14147        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14148        // literal-delimiter is the load-bearing root-cause edit on
14149        // every probe-as-both value.
14150        let d = dep_with_fonte(DepSource::Path {
14151            caminho: "../'x'%20teia".into(),
14152        });
14153        let err = d.validate().unwrap_err();
14154        assert!(
14155            matches!(
14156                err,
14157                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14158            ),
14159            "got {err:?}",
14160        );
14161    }
14162
14163    #[test]
14164    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14165        // Cascade pin on the upstream backslash arm: a value
14166        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14167        // canonical "I pasted a Windows-shell path followed by a
14168        // percent-encoded space" footgun) routes through
14169        // `FonteCaminhoBackslash` not
14170        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14171        // separator divergence is the load-bearing root-cause edit
14172        // on every probe-as-both value.
14173        let d = dep_with_fonte(DepSource::Path {
14174            caminho: "..\\caixa%20teia".into(),
14175        });
14176        let err = d.validate().unwrap_err();
14177        assert!(
14178            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14179            "got {err:?}",
14180        );
14181    }
14182
14183    #[test]
14184    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14185        // Cascade pin on the upstream control-char arm: a value
14186        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14187        // the canonical "I pasted a paste-from-binary-blob path
14188        // followed by a percent-encoded space" footgun) routes
14189        // through `FonteCaminhoControlChar` not
14190        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14191        // rejected byte is the load-bearing root-cause edit on
14192        // every probe-as-both value.
14193        let d = dep_with_fonte(DepSource::Path {
14194            caminho: "../caixa\0%20teia".into(),
14195        });
14196        let err = d.validate().unwrap_err();
14197        assert!(
14198            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14199            "got {err:?}",
14200        );
14201    }
14202
14203    #[test]
14204    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14205        // Cascade pin on the upstream absolute-path arm: a value
14206        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14207        // — the canonical "I pasted an absolute path with a
14208        // percent-encoded space tail" footgun) routes through
14209        // `FonteCaminhoAbsolute` not
14210        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14211        // the load-bearing root-cause edit on every probe-as-both
14212        // value.
14213        let d = dep_with_fonte(DepSource::Path {
14214            caminho: "/etc/passwd%20".into(),
14215        });
14216        let err = d.validate().unwrap_err();
14217        assert!(
14218            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14219            "got {err:?}",
14220        );
14221    }
14222
14223    #[test]
14224    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14225        // Cascade pin on the upstream var-expansion arm: a value
14226        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14227        // — the canonical "I pasted a `$HOME`-rooted path with a
14228        // percent-encoded space" footgun) routes through
14229        // `FonteCaminhoVarExpansion` not
14230        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14231        // expansion is the load-bearing root-cause edit on every
14232        // probe-as-both value.
14233        let d = dep_with_fonte(DepSource::Path {
14234            caminho: "$HOME/caixa%20teia".into(),
14235        });
14236        let err = d.validate().unwrap_err();
14237        assert!(
14238            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14239            "got {err:?}",
14240        );
14241    }
14242
14243    #[test]
14244    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14245        // Cascade pin on the immediate-successor arm: a value
14246        // carrying both `%` and a trailing `/`
14247        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14248        // percent-encoded-space-carrying path" footgun) routes
14249        // through `FonteCaminhoUrlPercentEncoding` not
14250        // `FonteCaminhoTrailingSlash`. The embedded percent-
14251        // encoding-escape byte is the more semantic-locating axis
14252        // (an author who decodes the `%20` to a literal space is
14253        // likely to also tab-strip the trailing separator since
14254        // both are paste-from-URL / paste-from-shell-tab-completion
14255        // artifacts).
14256        let d = dep_with_fonte(DepSource::Path {
14257            caminho: "../caixa%20teia/".into(),
14258        });
14259        let err = d.validate().unwrap_err();
14260        assert!(
14261            matches!(
14262                err,
14263                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14264            ),
14265            "got {err:?}",
14266        );
14267    }
14268
14269    #[test]
14270    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14271        // Diagnostic-shape pin (peer with
14272        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14273        // on the immediate-predecessor arm): the error's Display
14274        // surfaces the offending `:nome`, the offending `:caminho`
14275        // verbatim, the offending byte's hex / character form, and
14276        // names the URL-percent-encoding-escape / printf-format-
14277        // specifier footgun explicitly so a `feira lint` run can
14278        // render the diagnostic without re-parsing.
14279        let d = dep_with_fonte(DepSource::Path {
14280            caminho: "../caixa%20teia".into(),
14281        });
14282        let rendered = d.validate().unwrap_err().to_string();
14283        assert!(
14284            rendered.contains("caixa-teia"),
14285            "diagnostic must name the offending dep: {rendered}",
14286        );
14287        assert!(
14288            rendered.contains("../caixa%20teia"),
14289            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14290        );
14291        assert!(
14292            rendered.contains("0x25"),
14293            "diagnostic must surface the offending byte hex: {rendered:?}",
14294        );
14295        assert!(
14296            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14297            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14298        );
14299        assert!(
14300            rendered.contains("printf") || rendered.contains("format-specifier"),
14301            "diagnostic must reference the printf-format-specifier vocabulary: \
14302             {rendered:?}",
14303        );
14304    }
14305
14306    #[test]
14307    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14308        // The canonical embedded-`$` shell-variable-expansion paste
14309        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14310        // substituted shell one-liner where the leading segment is a
14311        // literal `../foo` while the mid segment carries the un-
14312        // substituted `$HOME` template). The leading-`$` position is
14313        // already gated by the f4efe9c leading-byte arm which routes
14314        // through `FonteCaminhoVarExpansion`; this arm closes the
14315        // last positional gap on `$` — every position on the axis is
14316        // structurally rejected.
14317        let d = dep_with_fonte(DepSource::Path {
14318            caminho: "../foo$HOME/bar".into(),
14319        });
14320        let err = d.validate().unwrap_err();
14321        let DepError::FonteCaminhoShellVariableExpansion {
14322            nome,
14323            caminho,
14324            byte,
14325        } = err
14326        else {
14327            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14328        };
14329        assert_eq!(nome, "caixa-teia");
14330        assert_eq!(caminho, "../foo$HOME/bar");
14331        assert_eq!(byte, b'$');
14332    }
14333
14334    #[test]
14335    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14336        // The symmetric braced-CI-manifest paste shape
14337        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14338        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14339        // footgun). Pinned separately from the bare-`$VAR` shape so
14340        // the gate covers both POSIX shell §2.6 Parameter Expansion
14341        // syntactic forms, not only the unbraced variant. The
14342        // embedded `{` byte in `${...}` is also caught by the 598b770
14343        // shell-brace-expansion arm but that arm fires earlier in
14344        // the cascade — the `$` arm's coverage extends to `${...}`
14345        // structurally, so the diagnostic asserted here is the
14346        // brace-expansion one (which is a valid outcome; the point
14347        // of the pin is that the value never survives validation).
14348        let d = dep_with_fonte(DepSource::Path {
14349            caminho: "../foo${WORKSPACE}/bar".into(),
14350        });
14351        let err = d.validate().unwrap_err();
14352        assert!(
14353            matches!(
14354                err,
14355                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14356                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14357            ),
14358            "got {err:?}",
14359        );
14360    }
14361
14362    #[test]
14363    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14364        // The paste-from-shell-prompt command-substitution idiom
14365        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14366        // `$VAR` shape so the gate's rationale extends to POSIX shell
14367        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14368        // legacy `` `<cmd>` `` form is already closed by the c370458
14369        // backtick arm). The embedded `(` byte in `$(...)` is also
14370        // caught structurally by the 0633c91 shell-subshell-grouping
14371        // arm which fires earlier in the cascade — the diagnostic
14372        // asserted here is either outcome, since both structurally
14373        // reject the value; the point of the pin is that the value
14374        // never survives validation.
14375        let d = dep_with_fonte(DepSource::Path {
14376            caminho: "../foo$(whoami)/bar".into(),
14377        });
14378        let err = d.validate().unwrap_err();
14379        assert!(
14380            matches!(
14381                err,
14382                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14383                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14384            ),
14385            "got {err:?}",
14386        );
14387    }
14388
14389    #[test]
14390    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14391        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14392        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14393        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14394        // idiom copied into a caminho template). None of the prior
14395        // shell-metachar arms cover this shape (`1` is a bare digit;
14396        // no `(` / `{` / letter follows the `$`), so the arm is the
14397        // sole gate on the shape.
14398        let d = dep_with_fonte(DepSource::Path {
14399            caminho: "../foo$1/bar".into(),
14400        });
14401        let err = d.validate().unwrap_err();
14402        assert!(
14403            matches!(
14404                err,
14405                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14406            ),
14407            "got {err:?}",
14408        );
14409    }
14410
14411    #[test]
14412    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14413        // The positive-control pin (peer with
14414        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14415        // on the immediate-predecessor arm): the gate targets only
14416        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14417        // A relative POSIX path carrying dashes / dots / slashes /
14418        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14419        // validate cleanly so the gate doesn't widen to a "no
14420        // printable punctuation anywhere" sweep that would defeat
14421        // the entire path-fonte author surface.
14422        let d = dep_with_fonte(DepSource::Path {
14423            caminho: "../caixa-teia/sub-dir.v2".into(),
14424        });
14425        d.validate().unwrap();
14426    }
14427
14428    #[test]
14429    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14430        // Cascade pin on the leading-`$` sibling arm at line 540: a
14431        // value starting with `$` and carrying an embedded `$` too
14432        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14433        // fully-templated CI path with two un-substituted variables")
14434        // routes through `FonteCaminhoVarExpansion` not
14435        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14436        // host-layout-leak is the load-bearing self-locating axis
14437        // (the leading position dominates the semantic-locating
14438        // rationale on every probe-as-both value); the embedded
14439        // arm's positional-agnostic sweep catches only values whose
14440        // leading byte doesn't route through the earlier leading-
14441        // byte arms.
14442        let d = dep_with_fonte(DepSource::Path {
14443            caminho: "$HOME/foo$WORKSPACE/bar".into(),
14444        });
14445        let err = d.validate().unwrap_err();
14446        assert!(
14447            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14448            "got {err:?}",
14449        );
14450    }
14451
14452    #[test]
14453    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14454        // Cascade pin on the immediate-predecessor arm: a value
14455        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14456        // — the canonical "I pasted a percent-encoded space adjacent
14457        // to a `$HOME` template") routes through
14458        // `FonteCaminhoUrlPercentEncoding` not
14459        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14460        // encoding-escape byte is the more semantic-locating axis
14461        // (the paste-from-browser-address-bar shape is the load-
14462        // bearing self-locating edit); same cascade discipline every
14463        // prior `:caminho` arm establishes.
14464        let d = dep_with_fonte(DepSource::Path {
14465            caminho: "../foo%20$HOME/bar".into(),
14466        });
14467        let err = d.validate().unwrap_err();
14468        assert!(
14469            matches!(
14470                err,
14471                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14472            ),
14473            "got {err:?}",
14474        );
14475    }
14476
14477    #[test]
14478    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14479        // Cascade pin on the immediate-successor arm: a value
14480        // carrying both embedded `$` and a trailing `/`
14481        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14482        // `$HOME`-template-carrying path") routes through
14483        // `FonteCaminhoShellVariableExpansion` not
14484        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14485        // expansion byte is the more semantic-locating axis on
14486        // probe-as-both values (an author who substitutes the
14487        // `$HOME` template with a literal value is likely to also
14488        // tab-strip the trailing separator).
14489        let d = dep_with_fonte(DepSource::Path {
14490            caminho: "../foo$HOME/bar/".into(),
14491        });
14492        let err = d.validate().unwrap_err();
14493        assert!(
14494            matches!(
14495                err,
14496                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14497            ),
14498            "got {err:?}",
14499        );
14500    }
14501
14502    #[test]
14503    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14504        // Diagnostic-shape pin (peer with
14505        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14506        // on the immediate-predecessor arm): the error's Display
14507        // surfaces the offending `:nome`, the offending `:caminho`
14508        // verbatim, the offending byte's hex / character form, and
14509        // names the shell-variable-expansion / command-substitution
14510        // footgun explicitly so a `feira lint` run can render the
14511        // diagnostic without re-parsing.
14512        let d = dep_with_fonte(DepSource::Path {
14513            caminho: "../foo$HOME/bar".into(),
14514        });
14515        let rendered = d.validate().unwrap_err().to_string();
14516        assert!(
14517            rendered.contains("caixa-teia"),
14518            "diagnostic must name the offending dep: {rendered}",
14519        );
14520        assert!(
14521            rendered.contains("../foo$HOME/bar"),
14522            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14523        );
14524        assert!(
14525            rendered.contains("0x24"),
14526            "diagnostic must surface the offending byte hex: {rendered:?}",
14527        );
14528        assert!(
14529            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14530            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14531        );
14532        assert!(
14533            rendered.contains("command-substitution") || rendered.contains("command substitution"),
14534            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14535        );
14536    }
14537
14538    #[test]
14539    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14540        // The fail-before-pass-after pin for the canonical paste-from-
14541        // shell-history footgun on `:caminho`. An author copies a `cd
14542        // ../caixa-teia && !sudo make install` one-liner from a quick-
14543        // start README, intending the trailing `!sudo` as a shell-
14544        // history-expansion reference but the typed slot is itself a
14545        // byte-level string parser, not a shell context, so the byte
14546        // rides into the value verbatim. Until this arm landed the `!`
14547        // byte silently passed every prior `:caminho` cascade arm
14548        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14549        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14550        // `#` / `%` / `$`); bash with the default `histexpand` mode
14551        // rewrites `!command` to the most recent history entry
14552        // beginning with `command`, the canonical RCE-class injection
14553        // vector when the byte rides into a shell argument executed
14554        // under `bash -i` (the operator-notebook interactive shell).
14555        let d = dep_with_fonte(DepSource::Path {
14556            caminho: "../caixa-teia!sudo".into(),
14557        });
14558        let err = d.validate().unwrap_err();
14559        let DepError::FonteCaminhoShellHistoryExpansion {
14560            nome,
14561            caminho,
14562            byte,
14563        } = err
14564        else {
14565            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14566        };
14567        assert_eq!(nome, "caixa-teia");
14568        assert_eq!(caminho, "../caixa-teia!sudo");
14569        assert_eq!(byte, b'!');
14570    }
14571
14572    #[test]
14573    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14574        // The symmetric `!!` repeat-prior-command paste idiom (peer with
14575        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14576        // on `is_git_repo_url`). Pinned separately from the wrapped
14577        // `!command` shape so a future diagnostic-surface change that
14578        // only checked the leading or paired-bang position surfaces
14579        // here — the per-byte arm fires anywhere `!` appears in the
14580        // value, including at consecutive positions in the middle.
14581        let d = dep_with_fonte(DepSource::Path {
14582            caminho: "../foo!!/bar".into(),
14583        });
14584        let err = d.validate().unwrap_err();
14585        assert!(
14586            matches!(
14587                err,
14588                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14589            ),
14590            "got {err:?}",
14591        );
14592    }
14593
14594    #[test]
14595    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14596        // The English-typography enthusiasm-form paste-from-prose
14597        // idiom: an author writes `:caminho "../caixa-teia!"`
14598        // expecting the substrate to coerce it to a kebab-case slug.
14599        // Pinned separately from the `!<word>` shell-history shape so
14600        // the gate's rationale extends to the paste-from-prose surface
14601        // (the same rationale the peer `is_git_repo_url` bang arm at
14602        // 7d53c68 covers). None of the prior shell-metachar arms cover
14603        // this shape (no `!<word>` reference and no `!!` repeat), so
14604        // the arm is the sole gate on the shape.
14605        let d = dep_with_fonte(DepSource::Path {
14606            caminho: "../caixa-teia!".into(),
14607        });
14608        let err = d.validate().unwrap_err();
14609        assert!(
14610            matches!(
14611                err,
14612                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14613            ),
14614            "got {err:?}",
14615        );
14616    }
14617
14618    #[test]
14619    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14620        // The positive-control pin (peer with
14621        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14622        // on the immediate-predecessor arm): the gate targets only
14623        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14624        // A relative POSIX path carrying dashes / dots / slashes /
14625        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14626        // validate cleanly so the gate doesn't widen to a "no
14627        // printable punctuation anywhere" sweep that would defeat
14628        // the entire path-fonte author surface.
14629        let d = dep_with_fonte(DepSource::Path {
14630            caminho: "../caixa-teia/sub-dir.v2".into(),
14631        });
14632        d.validate().unwrap();
14633    }
14634
14635    #[test]
14636    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14637        // Cascade pin on the immediate-predecessor arm: a value
14638        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14639        // — the canonical "I pasted a `$HOME`-templated path adjacent
14640        // to a trailing `!sudo` history-expansion") routes through
14641        // `FonteCaminhoShellVariableExpansion` not
14642        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14643        // expansion byte is the more semantic-locating axis on
14644        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14645        // template shape is the load-bearing self-locating edit);
14646        // same cascade discipline every prior `:caminho` arm
14647        // establishes.
14648        let d = dep_with_fonte(DepSource::Path {
14649            caminho: "../foo$HOME/bar!sudo".into(),
14650        });
14651        let err = d.validate().unwrap_err();
14652        assert!(
14653            matches!(
14654                err,
14655                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14656            ),
14657            "got {err:?}",
14658        );
14659    }
14660
14661    #[test]
14662    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14663        // Cascade pin on the immediate-successor arm: a value carrying
14664        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14665        // — the canonical "I tab-completed a `!sudo`-carrying path")
14666        // routes through `FonteCaminhoShellHistoryExpansion` not
14667        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14668        // expansion byte is the more semantic-locating axis on probe-
14669        // as-both values (an author who removes the `!sudo` history
14670        // reference is likely to also tab-strip the trailing separator).
14671        let d = dep_with_fonte(DepSource::Path {
14672            caminho: "../caixa-teia!sudo/".into(),
14673        });
14674        let err = d.validate().unwrap_err();
14675        assert!(
14676            matches!(
14677                err,
14678                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14679            ),
14680            "got {err:?}",
14681        );
14682    }
14683
14684    #[test]
14685    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14686        // Diagnostic-shape pin (peer with
14687        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14688        // on the immediate-predecessor arm): the error's Display
14689        // surfaces the offending `:nome`, the offending `:caminho`
14690        // verbatim, the offending byte's hex / character form, and
14691        // names the shell-history-expansion / bang-operator footgun
14692        // explicitly so a `feira lint` run can render the diagnostic
14693        // without re-parsing.
14694        let d = dep_with_fonte(DepSource::Path {
14695            caminho: "../caixa-teia!sudo".into(),
14696        });
14697        let rendered = d.validate().unwrap_err().to_string();
14698        assert!(
14699            rendered.contains("caixa-teia"),
14700            "diagnostic must name the offending dep: {rendered}",
14701        );
14702        assert!(
14703            rendered.contains("../caixa-teia!sudo"),
14704            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14705        );
14706        assert!(
14707            rendered.contains("0x21"),
14708            "diagnostic must surface the offending byte hex: {rendered:?}",
14709        );
14710        assert!(
14711            rendered.contains("history-expansion") || rendered.contains("history expansion"),
14712            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14713        );
14714        assert!(
14715            rendered.contains("bang"),
14716            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14717        );
14718    }
14719
14720    #[test]
14721    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14722        // The fail-before-pass-after pin for the canonical paste-from-
14723        // shell-history-quick-substitution footgun on `:caminho`. An
14724        // author copies a `git clone <bad-url>` line from their terminal,
14725        // corrects it via bash's `^bad^good` quick-substitution history
14726        // operator (bash reference §9.3, `set -o histexpand` mode's
14727        // default for interactive sessions), and pastes the trailing
14728        // `^bad^good` substitution fragment into a `:caminho` value
14729        // without trimming the leading `git clone` prefix — the byte
14730        // rides into the manifest verbatim. Until this arm landed the
14731        // `^` byte silently passed every prior `:caminho` cascade arm
14732        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14733        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14734        // `%` / `$` / `!`); bash with the default `histexpand` mode
14735        // rewrites the prior command's `bad` string to `good` and re-
14736        // executes it, the paired-operator half of the `set -o
14737        // histexpand` feature the peer `!` arm already closes the prefix
14738        // half of. The peer `is_git_repo_url` axis rejects the byte at
14739        // 49e142f under the same shell-history-substitution / RFC-3986-
14740        // unwise banner.
14741        let d = dep_with_fonte(DepSource::Path {
14742            caminho: "../foo^bad^good".into(),
14743        });
14744        let err = d.validate().unwrap_err();
14745        let DepError::FonteCaminhoShellHistorySubstitution {
14746            nome,
14747            caminho,
14748            byte,
14749        } = err
14750        else {
14751            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14752        };
14753        assert_eq!(nome, "caixa-teia");
14754        assert_eq!(caminho, "../foo^bad^good");
14755        assert_eq!(byte, b'^');
14756    }
14757
14758    #[test]
14759    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14760        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14761        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14762        // on `is_git_repo_url`). An author copies a `grep '^archived'`
14763        // regex-anchor / negation idiom from a doc snippet and the byte
14764        // rides in verbatim. Pinned separately from the `^old^new^`
14765        // quick-substitution shape so a future diagnostic-surface change
14766        // that only checked the paired-caret history-substitution
14767        // position surfaces here — the per-byte arm fires anywhere `^`
14768        // appears in the value, including at a solitary leading-of-
14769        // segment position.
14770        let d = dep_with_fonte(DepSource::Path {
14771            caminho: "../foo/^archived".into(),
14772        });
14773        let err = d.validate().unwrap_err();
14774        assert!(
14775            matches!(
14776                err,
14777                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14778            ),
14779            "got {err:?}",
14780        );
14781    }
14782
14783    #[test]
14784    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14785        // The trailing-`^` history-substitution-open shape — an author
14786        // starts typing a `^bad^good` quick-substitution but pastes only
14787        // the leading `^` sentinel before context-switching (a bash-
14788        // reference §9.3 valid histexpand prefix on its own — even a
14789        // solitary `^` on the prior command's whole re-execution shape).
14790        // Pinned separately from the `^old^new^` full-form and the leading-
14791        // of-segment `^archived` regex-anchor shape so the gate's
14792        // rationale extends to the paste-from-shell-history-with-only-
14793        // the-first-byte-selected surface. None of the prior shell-
14794        // metachar arms cover this shape.
14795        let d = dep_with_fonte(DepSource::Path {
14796            caminho: "../caixa-teia^".into(),
14797        });
14798        let err = d.validate().unwrap_err();
14799        assert!(
14800            matches!(
14801                err,
14802                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14803            ),
14804            "got {err:?}",
14805        );
14806    }
14807
14808    #[test]
14809    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14810        // The positive-control pin (peer with
14811        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14812        // on the immediate-predecessor arm): the gate targets only
14813        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14814        // A relative POSIX path carrying dashes / dots / slashes /
14815        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14816        // continue to validate cleanly so the gate doesn't widen to
14817        // a "no printable punctuation anywhere" sweep that would
14818        // defeat the entire path-fonte author surface.
14819        let d = dep_with_fonte(DepSource::Path {
14820            caminho: "../caixa-teia/sub_v2.rc".into(),
14821        });
14822        d.validate().unwrap();
14823    }
14824
14825    #[test]
14826    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14827        // Cascade pin on the immediate-predecessor arm: a value carrying
14828        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14829        // canonical "I pasted a `!sudo` history-reference next to a
14830        // `^bad^good` quick-substitution") routes through
14831        // `FonteCaminhoShellHistoryExpansion` not
14832        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14833        // the more semantic-locating axis on probe-as-both values (an
14834        // author who removes the `!sudo` reference is likely to also
14835        // strip the paired `^` substitution fragment); same cascade
14836        // discipline every prior `:caminho` arm establishes.
14837        let d = dep_with_fonte(DepSource::Path {
14838            caminho: "../foo!sudo^bad^good".into(),
14839        });
14840        let err = d.validate().unwrap_err();
14841        assert!(
14842            matches!(
14843                err,
14844                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14845            ),
14846            "got {err:?}",
14847        );
14848    }
14849
14850    #[test]
14851    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14852        // Cascade pin on the immediate-successor arm: a value carrying
14853        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14854        // the canonical "I tab-completed a `^bad^good`-carrying path")
14855        // routes through `FonteCaminhoShellHistorySubstitution` not
14856        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14857        // substitution byte is the more semantic-locating axis on probe-
14858        // as-both values (an author who removes the `^bad^good`
14859        // substitution fragment is likely to also tab-strip the trailing
14860        // separator).
14861        let d = dep_with_fonte(DepSource::Path {
14862            caminho: "../foo^bad^good/".into(),
14863        });
14864        let err = d.validate().unwrap_err();
14865        assert!(
14866            matches!(
14867                err,
14868                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14869            ),
14870            "got {err:?}",
14871        );
14872    }
14873
14874    #[test]
14875    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14876    {
14877        // Diagnostic-shape pin (peer with
14878        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14879        // on the immediate-predecessor arm): the error's Display
14880        // surfaces the offending `:nome`, the offending `:caminho`
14881        // verbatim, the offending byte's hex form, and names the
14882        // shell-history-substitution / RFC-3986-'unwise' / regex-
14883        // negation footgun explicitly so a `feira lint` run can render
14884        // the diagnostic without re-parsing.
14885        let d = dep_with_fonte(DepSource::Path {
14886            caminho: "../foo^bad^good".into(),
14887        });
14888        let rendered = d.validate().unwrap_err().to_string();
14889        assert!(
14890            rendered.contains("caixa-teia"),
14891            "diagnostic must name the offending dep: {rendered}",
14892        );
14893        assert!(
14894            rendered.contains("../foo^bad^good"),
14895            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14896        );
14897        assert!(
14898            rendered.contains("0x5e") || rendered.contains("0x5E"),
14899            "diagnostic must surface the offending byte hex: {rendered:?}",
14900        );
14901        assert!(
14902            rendered.contains("history-substitution") || rendered.contains("history substitution"),
14903            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14904        );
14905        assert!(
14906            rendered.contains("unwise"),
14907            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14908        );
14909    }
14910
14911    #[test]
14912    fn fonte_repo_empty_fires_before_pin_missing() {
14913        // Order pin: empty `:repo` is the more self-locating diagnostic
14914        // (every git source needs a repo; the pin discussion is
14915        // secondary), so it fires before the pin-missing arm even when
14916        // both are violated. Mirrors the
14917        // `nome_empty_takes_precedence_over_versao_invalid` ordering
14918        // discipline on the per-entry layer.
14919        let d = dep_with_fonte(DepSource::Git {
14920            repo: String::new(),
14921            tag: None,
14922            rev: None,
14923            branch: None,
14924        });
14925        let err = d.validate().unwrap_err();
14926        assert!(
14927            matches!(err, DepError::FonteRepoEmpty { .. }),
14928            "got {err:?}"
14929        );
14930    }
14931
14932    #[test]
14933    fn fonte_pin_missing_fires_before_pin_empty() {
14934        // Order pin: a fully-None pin set is structurally distinct from
14935        // a Some(empty) pin — the first surfaces as FontePinMissing
14936        // (no axis chosen), the second as FontePinEmpty (axis chosen
14937        // but value blank). Pin the disjoint relationship so a future
14938        // unification collapses to one variant only as a structural
14939        // decision.
14940        let d = dep_with_fonte(DepSource::Git {
14941            repo: "github:pleme-io/caixa-teia".into(),
14942            tag: None,
14943            rev: None,
14944            branch: None,
14945        });
14946        assert!(matches!(
14947            d.validate().unwrap_err(),
14948            DepError::FontePinMissing { .. }
14949        ));
14950    }
14951
14952    #[test]
14953    fn nome_empty_takes_precedence_over_fonte_invalid() {
14954        // Order pin: a per-entry diagnostic without a non-empty :nome
14955        // can't be self-locating, so :nome "" fires first even when
14956        // :fonte is also malformed. Mirrors
14957        // `nome_empty_takes_precedence_over_versao_invalid` on the
14958        // adjacent axis.
14959        let mut d = dep_with_fonte(DepSource::Git {
14960            repo: String::new(),
14961            tag: None,
14962            rev: None,
14963            branch: None,
14964        });
14965        d.nome = String::new();
14966        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14967    }
14968
14969    #[test]
14970    fn versao_invalid_takes_precedence_over_fonte_invalid() {
14971        // Order pin: the :versao parse-side diagnostic is narrower than
14972        // the :fonte shape diagnostic — a malformed :versao always names
14973        // the parser's reason, which is more actionable than the
14974        // :fonte gate's "the pins are wrong" wording. Pin the ordering
14975        // so a re-ordering surfaces here.
14976        let mut d = dep_with_fonte(DepSource::Git {
14977            repo: String::new(),
14978            tag: None,
14979            rev: None,
14980            branch: None,
14981        });
14982        d.versao = "v0.1".into();
14983        let err = d.validate().unwrap_err();
14984        assert!(
14985            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14986            "got {err:?}"
14987        );
14988    }
14989
14990    #[test]
14991    fn fonte_invalid_diagnostic_carries_offending_nome() {
14992        // The diagnostic-shape pin: every :fonte error variant names
14993        // the offending dep's :nome verbatim, so the author can grep
14994        // caixa.lisp for the `:nome "<n>"` block and fix it in one
14995        // edit. Cover all seven variants so a future variant addition
14996        // forces a parallel diagnostic-shape decision.
14997        for (case, fonte) in [
14998            (
14999                "repo-empty",
15000                DepSource::Git {
15001                    repo: String::new(),
15002                    tag: Some("v1".into()),
15003                    rev: None,
15004                    branch: None,
15005                },
15006            ),
15007            (
15008                "repo-shape",
15009                DepSource::Git {
15010                    repo: "github:p/x ".into(),
15011                    tag: Some("v1".into()),
15012                    rev: None,
15013                    branch: None,
15014                },
15015            ),
15016            (
15017                "pin-missing",
15018                DepSource::Git {
15019                    repo: "github:p/x".into(),
15020                    tag: None,
15021                    rev: None,
15022                    branch: None,
15023                },
15024            ),
15025            (
15026                "pin-ambiguous",
15027                DepSource::Git {
15028                    repo: "github:p/x".into(),
15029                    tag: Some("v1".into()),
15030                    rev: None,
15031                    branch: Some("main".into()),
15032                },
15033            ),
15034            (
15035                "pin-empty",
15036                DepSource::Git {
15037                    repo: "github:p/x".into(),
15038                    tag: Some(String::new()),
15039                    rev: None,
15040                    branch: None,
15041                },
15042            ),
15043            (
15044                "caminho-empty",
15045                DepSource::Path {
15046                    caminho: String::new(),
15047                },
15048            ),
15049            (
15050                "caminho-absolute",
15051                DepSource::Path {
15052                    caminho: "/home/me/work/caixa-teia".into(),
15053                },
15054            ),
15055        ] {
15056            let d = dep_with_fonte(fonte);
15057            let msg = d
15058                .validate()
15059                .expect_err(&format!("{case}: expected fonte error"))
15060                .to_string();
15061            assert!(
15062                msg.contains("\"caixa-teia\""),
15063                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15064            );
15065        }
15066    }
15067
15068    // -- :tag / :branch value-shape gate ----------------------------------
15069
15070    #[test]
15071    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15072        // The canonical paste-from-doc footgun on `:tag` — author
15073        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15074        // paragraph. Until this gate landed the empty-pin arm passed
15075        // (the string isn't empty), the resolver issued
15076        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15077        // surfaced at clone time with a quoting-confused git error
15078        // far from the source caixa.lisp. The new gate moves the
15079        // check to caixa-build time and names the offending dep +
15080        // pin + value verbatim.
15081        let d = dep_with_fonte(DepSource::Git {
15082            repo: "github:pleme-io/caixa-teia".into(),
15083            tag: Some("v0.1.0 ".into()),
15084            rev: None,
15085            branch: None,
15086        });
15087        let err = d.validate().unwrap_err();
15088        let DepError::FontePinShape {
15089            nome,
15090            pin,
15091            value,
15092            reason,
15093        } = err
15094        else {
15095            panic!("expected FontePinShape, got other variant");
15096        };
15097        assert_eq!(nome, "caixa-teia");
15098        assert_eq!(pin, ":tag");
15099        assert_eq!(value, "v0.1.0 ");
15100        assert!(
15101            reason.contains("whitespace"),
15102            "reason must surface the whitespace arm, got {reason:?}"
15103        );
15104    }
15105
15106    #[test]
15107    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15108        // The `.lock` suffix is git's atomic-rename guard for
15109        // in-flight ref updates — a refname ending in `.lock` is
15110        // unwritable on disk. Pinned separately from the whitespace
15111        // arm so a future relaxation that admits one but not the
15112        // other surfaces here.
15113        let d = dep_with_fonte(DepSource::Git {
15114            repo: "github:pleme-io/caixa-teia".into(),
15115            tag: Some("v0.1.0.lock".into()),
15116            rev: None,
15117            branch: None,
15118        });
15119        let err = d.validate().unwrap_err();
15120        let DepError::FontePinShape {
15121            pin, value, reason, ..
15122        } = err
15123        else {
15124            panic!("expected FontePinShape, got other variant");
15125        };
15126        assert_eq!(pin, ":tag");
15127        assert_eq!(value, "v0.1.0.lock");
15128        assert!(
15129            reason.contains(".lock"),
15130            "reason must surface the .lock arm, got {reason:?}"
15131        );
15132    }
15133
15134    #[test]
15135    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15136        // The canonical "branch name with spaces" footgun (`feature
15137        // foo`, `release branch`) — git's refname parser rejects raw
15138        // whitespace, and the failure surfaces at `git checkout
15139        // 'feature foo'` time with a quoting-confused error far from
15140        // the source caixa.lisp. Pinned on the `:branch` axis so the
15141        // gate-applies-to-both-:tag-and-:branch contract is a build-
15142        // error to relax.
15143        let d = dep_with_fonte(DepSource::Git {
15144            repo: "github:pleme-io/caixa-teia".into(),
15145            tag: None,
15146            rev: None,
15147            branch: Some("feature/foo bar".into()),
15148        });
15149        let err = d.validate().unwrap_err();
15150        let DepError::FontePinShape {
15151            pin, value, reason, ..
15152        } = err
15153        else {
15154            panic!("expected FontePinShape, got other variant");
15155        };
15156        assert_eq!(pin, ":branch");
15157        assert_eq!(value, "feature/foo bar");
15158        assert!(
15159            reason.contains("whitespace"),
15160            "reason must surface the whitespace arm, got {reason:?}"
15161        );
15162    }
15163
15164    #[test]
15165    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15166        // The `refs/heads/main` shape — the canonical "I copied the
15167        // fully-qualified ref out of `git show-ref` instead of the
15168        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15169        // at clone time, so this resolves to a literal ref named
15170        // `refs/heads/refs/heads/main` on disk; the silent double-
15171        // prefix is the load-bearing reason to gate at validate.
15172        // The diagnostic must enumerate the leaf the author probably
15173        // meant (`"main"`) so the fix is one edit.
15174        let d = dep_with_fonte(DepSource::Git {
15175            repo: "github:pleme-io/caixa-teia".into(),
15176            tag: None,
15177            rev: None,
15178            branch: Some("refs/heads/main".into()),
15179        });
15180        let err = d.validate().unwrap_err();
15181        let DepError::FontePinShape {
15182            pin, value, reason, ..
15183        } = err
15184        else {
15185            panic!("expected FontePinShape, got other variant");
15186        };
15187        assert_eq!(pin, ":branch");
15188        assert_eq!(value, "refs/heads/main");
15189        assert!(
15190            reason.contains("fully-qualified"),
15191            "reason must surface the qualified-prefix arm, got {reason:?}"
15192        );
15193        assert!(
15194            reason.contains("\"main\""),
15195            "reason must quote the leaf the author probably meant, got {reason:?}"
15196        );
15197    }
15198
15199    #[test]
15200    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15201        // Sibling arm of the qualified-prefix gate on the `:tag`
15202        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15203        // footgun). Pinned separately so a future relaxation that
15204        // only catches the `:branch` arm surfaces here.
15205        let d = dep_with_fonte(DepSource::Git {
15206            repo: "github:pleme-io/caixa-teia".into(),
15207            tag: Some("refs/tags/v0.1.0".into()),
15208            rev: None,
15209            branch: None,
15210        });
15211        let err = d.validate().unwrap_err();
15212        let DepError::FontePinShape {
15213            pin, value, reason, ..
15214        } = err
15215        else {
15216            panic!("expected FontePinShape, got other variant");
15217        };
15218        assert_eq!(pin, ":tag");
15219        assert_eq!(value, "refs/tags/v0.1.0");
15220        assert!(
15221            reason.contains("fully-qualified"),
15222            "reason must surface the qualified-prefix arm, got {reason:?}"
15223        );
15224        assert!(
15225            reason.contains("\"v0.1.0\""),
15226            "reason must quote the leaf the author probably meant, got {reason:?}"
15227        );
15228    }
15229
15230    #[test]
15231    fn validate_rejects_git_fonte_with_branch_named_at() {
15232        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15233        // unsourceable. Pinned so a future relaxation that admits
15234        // any single-character refname surfaces here.
15235        let d = dep_with_fonte(DepSource::Git {
15236            repo: "github:pleme-io/caixa-teia".into(),
15237            tag: None,
15238            rev: None,
15239            branch: Some("@".into()),
15240        });
15241        let err = d.validate().unwrap_err();
15242        let DepError::FontePinShape { pin, value, .. } = err else {
15243            panic!("expected FontePinShape, got other variant");
15244        };
15245        assert_eq!(pin, ":branch");
15246        assert_eq!(value, "@");
15247    }
15248
15249    #[test]
15250    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15251        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15252        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15253        // passes parse and surfaces as a refname-parse error or, on
15254        // older git, a literal `../escape` checkout that escapes the
15255        // refs/ directory tree. Pinned separately from the
15256        // qualified-prefix arm so a future relaxation that catches
15257        // one but not the other surfaces here.
15258        let d = dep_with_fonte(DepSource::Git {
15259            repo: "github:pleme-io/caixa-teia".into(),
15260            tag: Some("../escape".into()),
15261            rev: None,
15262            branch: None,
15263        });
15264        let err = d.validate().unwrap_err();
15265        let DepError::FontePinShape { pin, value, .. } = err else {
15266            panic!("expected FontePinShape, got other variant");
15267        };
15268        assert_eq!(pin, ":tag");
15269        assert_eq!(value, "../escape");
15270    }
15271
15272    #[test]
15273    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15274        // The positive-control pin: hierarchical refnames with one or
15275        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15276        // canonical idiom) round-trip through the gate. Pinned
15277        // separately from the leaf-`"main"` positive control so a
15278        // future tightening that rejects all multi-component refnames
15279        // surfaces here.
15280        let d = dep_with_fonte(DepSource::Git {
15281            repo: "github:pleme-io/caixa-teia".into(),
15282            tag: None,
15283            rev: None,
15284            branch: Some("feature/checkout-rewrite".into()),
15285        });
15286        d.validate().unwrap();
15287    }
15288
15289    #[test]
15290    fn validate_accepts_git_fonte_with_prerelease_tag() {
15291        // The positive-control pin: semver pre-release shape
15292        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15293        // (only consecutive `..` and trailing `.` are rejected), the
15294        // mid-component hyphen is allowed. Pinned separately from
15295        // the bare-`"v0.1.0"` positive control so a future tightening
15296        // that rejects pre-release tags surfaces here.
15297        let d = dep_with_fonte(DepSource::Git {
15298            repo: "github:pleme-io/caixa-teia".into(),
15299            tag: Some("v0.1.0-alpha.1".into()),
15300            rev: None,
15301            branch: None,
15302        });
15303        d.validate().unwrap();
15304    }
15305
15306    #[test]
15307    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15308        // The `:rev` axis is routed through `crate::render::is_git_oid`
15309        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15310        // value with refname-shape punctuation (here, a `:` mid-string
15311        // — would be a refname violation under `is_git_ref_name` too)
15312        // is rejected at the OID-shape gate. The two predicates
15313        // partition the `:fonte` pin axes structurally: an `:rev` value
15314        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15315        // *still* rejected here because every refname character outside
15316        // `[0-9a-f]` fails the OID gate. Same shape as
15317        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15318        // on the refname-shaped axes — the diagnostic names the
15319        // offending dep + pin + value verbatim. The flip-from-accept
15320        // case the prior `:tag`/`:branch` gate left as a "future axis"
15321        // (e70d213) — now landed.
15322        let d = dep_with_fonte(DepSource::Git {
15323            repo: "github:pleme-io/caixa-teia".into(),
15324            tag: None,
15325            rev: Some("c0ffee:notarefname".into()),
15326            branch: None,
15327        });
15328        let err = d.validate().unwrap_err();
15329        let DepError::FontePinShape {
15330            nome,
15331            pin,
15332            value,
15333            reason,
15334        } = err
15335        else {
15336            panic!("expected FontePinShape, got other variant");
15337        };
15338        assert_eq!(nome, "caixa-teia");
15339        assert_eq!(pin, ":rev");
15340        assert_eq!(value, "c0ffee:notarefname");
15341        assert!(
15342            !reason.is_empty(),
15343            "FontePinShape `reason` must carry the predicate's wording verbatim"
15344        );
15345    }
15346
15347    #[test]
15348    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15349        // The positive-control pin on the SHA-1 OID width: exactly 40
15350        // lowercase hex characters — the canonical `git rev-parse HEAD`
15351        // emission on a SHA-1-hashed repository (the default on every
15352        // pre-2.42 git and the canonical pleme-io substrate hash).
15353        // Pinned separately from the SHA-256 positive control so a
15354        // future tightening that only admits one width surfaces here.
15355        let d = dep_with_fonte(DepSource::Git {
15356            repo: "github:pleme-io/caixa-teia".into(),
15357            tag: None,
15358            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15359            branch: None,
15360        });
15361        d.validate().unwrap();
15362    }
15363
15364    #[test]
15365    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15366        // The positive-control pin on the SHA-256 OID width: exactly
15367        // 64 lowercase hex characters — `git`'s
15368        // `extensions.objectFormat = sha256` emission (GA since Git
15369        // 2.42 / Oct 2023). The substrate admits either canonical
15370        // width so an `:rev` authored against a SHA-256-hashed
15371        // upstream round-trips through the gate without per-repo
15372        // configuration. Pinned separately from the SHA-1 positive
15373        // control so a future tightening that drops one width surfaces
15374        // here as a structural decision.
15375        let d = dep_with_fonte(DepSource::Git {
15376            repo: "github:pleme-io/caixa-teia".into(),
15377            tag: None,
15378            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15379            branch: None,
15380        });
15381        d.validate().unwrap();
15382    }
15383
15384    #[test]
15385    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15386        // The canonical `git log --short` / `git rev-parse --short HEAD`
15387        // paste-from-release-notes footgun: a 7-char prefix (git's
15388        // default `core.abbrev`) silently passes string emptiness
15389        // checks and resolves to one commit today, but becomes ambiguous
15390        // tomorrow as the repo grows. Until this gate landed the empty-
15391        // pin arm passed (the string isn't empty) and the resolver
15392        // accepted the prefix through git's separate prefix-lookup pass
15393        // — defeating the reproducibility contract `:rev` carries vs.
15394        // `:tag` / `:branch`. The new gate moves the check to caixa-
15395        // build time and names the offending dep + pin + value verbatim.
15396        let d = dep_with_fonte(DepSource::Git {
15397            repo: "github:pleme-io/caixa-teia".into(),
15398            tag: None,
15399            rev: Some("c0ffee0".into()),
15400            branch: None,
15401        });
15402        let err = d.validate().unwrap_err();
15403        let DepError::FontePinShape {
15404            pin, value, reason, ..
15405        } = err
15406        else {
15407            panic!("expected FontePinShape, got other variant");
15408        };
15409        assert_eq!(pin, ":rev");
15410        assert_eq!(value, "c0ffee0");
15411        assert!(
15412            reason.contains("abbreviated") || reason.contains("ambiguous"),
15413            "reason must surface the abbreviation arm, got {reason:?}"
15414        );
15415    }
15416
15417    #[test]
15418    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15419        // The canonical "I pasted the SHA in uppercase" footgun: `git
15420        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15421        // bearing `:rev` round-trips inconsistently across the
15422        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15423        // equality-check pipeline and fails the lacre's content-
15424        // addressing probe with a confusing case-only diff. Pinned
15425        // separately from the non-hex arm so a future relaxation that
15426        // admits one but not the other surfaces here.
15427        let d = dep_with_fonte(DepSource::Git {
15428            repo: "github:pleme-io/caixa-teia".into(),
15429            tag: None,
15430            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15431            branch: None,
15432        });
15433        let err = d.validate().unwrap_err();
15434        let DepError::FontePinShape {
15435            pin, value, reason, ..
15436        } = err
15437        else {
15438            panic!("expected FontePinShape, got other variant");
15439        };
15440        assert_eq!(pin, ":rev");
15441        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15442        assert!(
15443            reason.contains("uppercase"),
15444            "reason must surface the uppercase arm, got {reason:?}"
15445        );
15446    }
15447
15448    #[test]
15449    fn validate_rejects_git_fonte_with_rev_refname_value() {
15450        // The cross-axis mis-slot footgun: `:rev "main"` — the author
15451        // conflated `:rev` (hex commit ID, immutable) and `:branch`
15452        // (mutable ref pointing at whatever HEAD is today). Until this
15453        // gate landed the resolver silently dispatched on the value
15454        // shape ("`main` doesn't look like a SHA, fall back to
15455        // refname"), defeating the `:rev` reproducibility contract.
15456        // The new gate rejects every non-hex value on the `:rev` axis,
15457        // so the `:rev`/`:branch` boundary is structurally enforced —
15458        // a refname in the `:rev` slot is a build error, not a
15459        // resolver-time silent reinterpretation.
15460        let d = dep_with_fonte(DepSource::Git {
15461            repo: "github:pleme-io/caixa-teia".into(),
15462            tag: None,
15463            rev: Some("main".into()),
15464            branch: None,
15465        });
15466        let err = d.validate().unwrap_err();
15467        let DepError::FontePinShape {
15468            pin, value, reason, ..
15469        } = err
15470        else {
15471            panic!("expected FontePinShape, got other variant");
15472        };
15473        assert_eq!(pin, ":rev");
15474        assert_eq!(value, "main");
15475        // 4 chars `main` fails the length arm before the character arm,
15476        // so the diagnostic surfaces the abbreviation wording (same
15477        // path the `c0ffee0` 7-char fixture lands on); the structural
15478        // assertion is just that the `:rev "main"` value is rejected.
15479        assert!(
15480            !reason.is_empty(),
15481            "FontePinShape reason must be non-empty for refname-shaped :rev"
15482        );
15483    }
15484
15485    #[test]
15486    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15487        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15488        // conflated `:rev` and `:tag`. Pinned separately from the
15489        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15490        // that catches one but not the other surfaces here. The
15491        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15492        // assertion is just that the cross-axis mis-slot is a build
15493        // error, regardless of which sub-arm surfaces the diagnostic
15494        // (`is_git_oid` rejects at the first violation; longer
15495        // tag-shape values would hit the non-hex arm instead).
15496        let d = dep_with_fonte(DepSource::Git {
15497            repo: "github:pleme-io/caixa-teia".into(),
15498            tag: None,
15499            rev: Some("v0.1.0".into()),
15500            branch: None,
15501        });
15502        let err = d.validate().unwrap_err();
15503        let DepError::FontePinShape {
15504            pin, value, reason, ..
15505        } = err
15506        else {
15507            panic!("expected FontePinShape, got other variant");
15508        };
15509        assert_eq!(pin, ":rev");
15510        assert_eq!(value, "v0.1.0");
15511        assert!(
15512            !reason.is_empty(),
15513            "FontePinShape reason must be non-empty for tag-shaped :rev"
15514        );
15515    }
15516
15517    #[test]
15518    fn validate_rejects_git_fonte_with_rev_too_long() {
15519        // Boundary case on the upper end: 41 hex chars — one past the
15520        // SHA-1 width, well below the SHA-256 width. Pin so a future
15521        // relaxation that admits "long enough to be a SHA" without
15522        // matching either canonical width surfaces here. The diagnostic
15523        // names the offending length verbatim so the author's grep
15524        // target is unambiguous (either trim one char or paste the
15525        // full SHA-256).
15526        let too_long: String = "0".repeat(41);
15527        let d = dep_with_fonte(DepSource::Git {
15528            repo: "github:pleme-io/caixa-teia".into(),
15529            tag: None,
15530            rev: Some(too_long.clone()),
15531            branch: None,
15532        });
15533        let err = d.validate().unwrap_err();
15534        let DepError::FontePinShape {
15535            pin, value, reason, ..
15536        } = err
15537        else {
15538            panic!("expected FontePinShape, got other variant");
15539        };
15540        assert_eq!(pin, ":rev");
15541        assert_eq!(value, too_long);
15542        assert!(
15543            reason.contains("41"),
15544            "reason must surface the offending length verbatim, got {reason:?}"
15545        );
15546    }
15547
15548    #[test]
15549    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15550        // The canonical paste-from-doc footgun on `:rev` — author
15551        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15552        // commit-message paragraph. Until this gate landed the empty-
15553        // pin arm passed (the string isn't empty), the resolver issued
15554        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15555        // clone time with a quoting-confused git error far from the
15556        // source caixa.lisp. The new gate moves the check to caixa-
15557        // build time. Length is 41 (40 hex + space) so the length arm
15558        // fires first — pinned separately from the pure-length arm to
15559        // ensure the diagnostic surfaces *some* parser wording, not
15560        // silently pass through.
15561        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15562        let d = dep_with_fonte(DepSource::Git {
15563            repo: "github:pleme-io/caixa-teia".into(),
15564            tag: None,
15565            rev: Some(with_space.clone()),
15566            branch: None,
15567        });
15568        let err = d.validate().unwrap_err();
15569        let DepError::FontePinShape {
15570            pin, value, reason, ..
15571        } = err
15572        else {
15573            panic!("expected FontePinShape, got other variant");
15574        };
15575        assert_eq!(pin, ":rev");
15576        assert_eq!(value, with_space);
15577        assert!(
15578            !reason.is_empty(),
15579            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15580        );
15581    }
15582
15583    #[test]
15584    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15585        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15586        // variant on this axis names the offending dep's `:nome` + the
15587        // `:rev` axis + the offending value verbatim, so the author's
15588        // grep target is the literal `:rev "<value>"` block in
15589        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15590        // carries_offending_nome_pin_value` test on the refname-shaped
15591        // (`:tag` / `:branch`) axes.
15592        let d = dep_with_fonte(DepSource::Git {
15593            repo: "github:p/x".into(),
15594            tag: None,
15595            rev: Some("not-a-sha".into()),
15596            branch: None,
15597        });
15598        let msg = d
15599            .validate()
15600            .expect_err(":rev: expected FontePinShape")
15601            .to_string();
15602        assert!(
15603            msg.contains("\"caixa-teia\""),
15604            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15605        );
15606        assert!(
15607            msg.contains(":rev"),
15608            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15609        );
15610        assert!(
15611            msg.contains("not-a-sha"),
15612            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15613        );
15614    }
15615
15616    #[test]
15617    fn fonte_pin_empty_fires_before_pin_shape() {
15618        // Order pin: a `Some("")` `:tag` is the more self-locating
15619        // diagnostic (the author chose an axis but left it blank;
15620        // grep is unambiguous), so it fires before the shape gate
15621        // even when both arms would match. Pinned so a future
15622        // reordering surfaces here. Mirrors the
15623        // `fonte_repo_empty_fires_before_pin_missing` ordering
15624        // discipline on the peer per-axis arms.
15625        let d = dep_with_fonte(DepSource::Git {
15626            repo: "github:pleme-io/caixa-teia".into(),
15627            tag: Some(String::new()),
15628            rev: None,
15629            branch: None,
15630        });
15631        assert!(matches!(
15632            d.validate().unwrap_err(),
15633            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15634        ));
15635    }
15636
15637    #[test]
15638    fn fonte_pin_shape_fires_after_repo_empty() {
15639        // Order pin: `:repo ""` is the more self-locating axis
15640        // (every git source needs a repo; the per-pin shape gate is
15641        // secondary), so the repo-empty arm fires before the
15642        // per-pin shape arm even when both are violated. Pinned so
15643        // a future reordering surfaces here. Mirrors
15644        // `fonte_repo_empty_fires_before_pin_missing` on the
15645        // adjacent axis pair.
15646        let d = dep_with_fonte(DepSource::Git {
15647            repo: String::new(),
15648            tag: Some("v0.1.0 ".into()),
15649            rev: None,
15650            branch: None,
15651        });
15652        assert!(matches!(
15653            d.validate().unwrap_err(),
15654            DepError::FonteRepoEmpty { .. }
15655        ));
15656    }
15657
15658    #[test]
15659    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15660        // Diagnostic-shape pin across both refname-shaped axes
15661        // (`:tag` + `:branch`): every `FontePinShape` variant names
15662        // the offending dep's `:nome` + the offending pin axis + the
15663        // offending value verbatim, so the author's grep target is
15664        // unambiguous (the literal `:tag "<value>"` / `:branch
15665        // "<value>"` lands in caixa.lisp with quotes). Cover both
15666        // pin axes so a future variant addition forces a parallel
15667        // diagnostic-shape decision.
15668        for (pin_label, fonte) in [
15669            (
15670                ":tag",
15671                DepSource::Git {
15672                    repo: "github:p/x".into(),
15673                    tag: Some("v0.1.0~1".into()),
15674                    rev: None,
15675                    branch: None,
15676                },
15677            ),
15678            (
15679                ":branch",
15680                DepSource::Git {
15681                    repo: "github:p/x".into(),
15682                    tag: None,
15683                    rev: None,
15684                    branch: Some("feature/foo*".into()),
15685                },
15686            ),
15687        ] {
15688            let d = dep_with_fonte(fonte);
15689            let msg = d
15690                .validate()
15691                .expect_err(&format!("{pin_label}: expected FontePinShape"))
15692                .to_string();
15693            assert!(
15694                msg.contains("\"caixa-teia\""),
15695                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15696            );
15697            assert!(
15698                msg.contains(pin_label),
15699                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15700            );
15701        }
15702    }
15703
15704    #[test]
15705    fn git_source_json_round_trip() {
15706        let src = DepSource::Git {
15707            repo: "github:pleme-io/caixa-teia".into(),
15708            tag: Some("v0.1.0".into()),
15709            rev: None,
15710            branch: None,
15711        };
15712        let s = serde_json::to_string(&src).unwrap();
15713        assert!(s.contains(&format!(
15714            r#""{tipo}":"{git}""#,
15715            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15716            git = crate::render::DEP_SOURCE_TIPO_GIT,
15717        )));
15718        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15719        assert!(s.contains(r#""tag":"v0.1.0""#));
15720        assert!(!s.contains("rev"));
15721        assert!(!s.contains("branch"));
15722        let round: DepSource = serde_json::from_str(&s).unwrap();
15723        assert_eq!(round, src);
15724    }
15725
15726    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15727    //
15728    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15729    // attribute on [`DepSource`] pins three load-bearing byte-sequences
15730    // that flow into every serialized `Dep.fonte` block: the outer
15731    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15732    // the two admitted variant-tag values `"git"` / `"path"` the
15733    // `rename_all = "lowercase"` attribute pins as the discriminator's
15734    // closed-set arms. The three pin tests below round-trip a
15735    // fully-populated variant of each arm through
15736    // [`serde_json::to_value`] and assert each canonical byte-sequence
15737    // appears at its axis — pins a hypothetical future
15738    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15739    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15740    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15741    // at build time rather than at fetch time when the resolver's
15742    // `Dep.fonte` dispatch silently fails to match on the drifted
15743    // discriminator. Same "serialize-and-check" discipline the peer
15744    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15745    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15746    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15747    // family in caixa-core lacking a lifted peer.
15748
15749    #[test]
15750    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15751        // Fail-before-pass-after: a future `tag = "type"` at the derive
15752        // attribute would serialize under `"type":"git"`, and this test
15753        // would trip because `"tipo"` no longer appears at the emitted
15754        // discriminator key. A future `rename_all = "kebab-case"` /
15755        // `"snake_case"` (both no-ops on `Git` since it lacks internal
15756        // word boundaries) is caught by the sibling
15757        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15758        // pin below (Path has no internal boundary either but the pair
15759        // catches any per-arm inconsistency). A future variant rename
15760        // `Git` → `Repository` would emit `"tipo":"repository"` and
15761        // trip this pin.
15762        let src = DepSource::Git {
15763            repo: "github:pleme-io/caixa-teia".into(),
15764            tag: Some("v0.1.0".into()),
15765            rev: None,
15766            branch: None,
15767        };
15768        let json = serde_json::to_value(&src).unwrap();
15769        let obj = json.as_object().expect("Git serializes as a JSON object");
15770        assert_eq!(
15771            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15772                .and_then(serde_json::Value::as_str),
15773            Some(crate::render::DEP_SOURCE_TIPO_GIT),
15774            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15775             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15776             detected in {json}"
15777        );
15778    }
15779
15780    #[test]
15781    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15782        // Fail-before-pass-after: a future variant rename `Path` →
15783        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15784        // this pin. A per-consumer disambiguation as the `defcaixa`
15785        // macro stabilizes ("caminho" → "path" for English-uniformity)
15786        // is scoped to the inner field key, not the discriminator; this
15787        // pin is orthogonal to that and catches only the outer
15788        // discriminator drift.
15789        let src = DepSource::Path {
15790            caminho: "../caixa-teia".into(),
15791        };
15792        let json = serde_json::to_value(&src).unwrap();
15793        let obj = json.as_object().expect("Path serializes as a JSON object");
15794        assert_eq!(
15795            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15796                .and_then(serde_json::Value::as_str),
15797            Some(crate::render::DEP_SOURCE_TIPO_PATH),
15798            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15799             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15800             detected in {json}"
15801        );
15802    }
15803
15804    #[test]
15805    fn dep_source_key_consts_are_pairwise_distinct() {
15806        // Cross-axis collapse detector: a hypothetical future edit that
15807        // accidentally set two of the three consts to the same byte
15808        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15809        // pass every per-arm serialize pin above but silently collapse
15810        // the discriminator's closed-set arms onto one another; this pin
15811        // catches the collapse at build time.
15812        assert_ne!(
15813            crate::render::DEP_SOURCE_KEY_TIPO,
15814            crate::render::DEP_SOURCE_TIPO_GIT,
15815        );
15816        assert_ne!(
15817            crate::render::DEP_SOURCE_KEY_TIPO,
15818            crate::render::DEP_SOURCE_TIPO_PATH,
15819        );
15820        assert_ne!(
15821            crate::render::DEP_SOURCE_TIPO_GIT,
15822            crate::render::DEP_SOURCE_TIPO_PATH,
15823        );
15824    }
15825
15826    #[test]
15827    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15828        // Shape pin against `rename_all` drift: the two variant-tag
15829        // consts must be ASCII-lowercase-only to match the
15830        // `rename_all = "lowercase"` attribute the derive uses; a future
15831        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15832        // would emit `"GIT"` / `"Git"` instead and trip this pin.
15833        for (label, s) in [
15834            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15835            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15836        ] {
15837            assert!(!s.is_empty(), "{label} must not be empty");
15838            assert!(
15839                s.bytes().all(|b| b.is_ascii_lowercase()),
15840                "{label} must be ASCII-lowercase-only (matching \
15841                 rename_all = \"lowercase\"), got {s:?}",
15842            );
15843        }
15844    }
15845
15846    // ── per-entry :caracteristicas set-not-multiset gate ────────────
15847    //
15848    // Every Vec-keyed-by-name authoring surface on the typed Caixa
15849    // surface that identifies its entries by a name field now uniformly
15850    // closes the set-not-multiset discipline at build time (cite
15851    // `validate_caracteristicas`'s peer-axis enumeration). The
15852    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15853    // set-shaped (a feature is either enabled or not — there is no
15854    // `feature × 2` semantic), so two entries naming the same feature
15855    // are a redundant declaration the caixa-resolver's lacre pipeline
15856    // would silently dedup at resolve time. The empty-feature arm
15857    // closes the parallel "operationally-meaningless value" axis on
15858    // the same slot. Same linear-walk + `HashSet` + first-collision
15859    // shape every peer set gate uses; same empty-first cascade every
15860    // peer per-entry shape + duplicate gate uses (the empty-feature
15861    // axis is the more-actionable defect since two `""` entries would
15862    // both report `caracteristica: ""` under a duplicate-first
15863    // ordering, with no way to distinguish the offending site).
15864
15865    fn dep_with_features(features: &[&str]) -> Dep {
15866        Dep {
15867            nome: "caixa-teia".into(),
15868            versao: "^0.1".into(),
15869            fonte: None,
15870            opcional: false,
15871            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15872        }
15873    }
15874
15875    #[test]
15876    fn validate_rejects_empty_caracteristica() {
15877        // Fail-before-pass-after pin: every pre-gate codebase accepted
15878        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15879        // imposed no per-entry shape contract), the dep validated, and
15880        // the empty feature would have reached the future caixa-resolver
15881        // lacre pipeline as a no-op feature enable — silently dropping
15882        // the author's intent far from the source `caixa.lisp`. The new
15883        // gate surfaces the structural defect at the typed-validate
15884        // surface with a self-locating diagnostic naming the offending
15885        // dep's `:nome`.
15886        let d = dep_with_features(&[""]);
15887        assert!(
15888            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15889            "expected CaracteristicaEmpty, got {:?}",
15890            d.validate(),
15891        );
15892    }
15893
15894    #[test]
15895    fn validate_rejects_duplicate_caracteristica() {
15896        // Fail-before-pass-after pin on the set-not-multiset arm: the
15897        // feature-toggle slot is set-shaped, so `(:caracteristicas
15898        // ("http" "http"))` is a redundant declaration the lacre
15899        // pipeline dedupes silently at resolve time. The diagnostic
15900        // names the offending dep + the colliding feature verbatim so
15901        // the author can grep their caixa.lisp for `:caracteristicas`
15902        // and fix it in one edit. First-collision determinism is
15903        // pinned separately below.
15904        let d = dep_with_features(&["http", "http"]);
15905        assert!(
15906            matches!(
15907                d.validate().unwrap_err(),
15908                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15909                    if nome == "caixa-teia" && caracteristica == "http"
15910            ),
15911            "expected CaracteristicaDuplicate, got {:?}",
15912            d.validate(),
15913        );
15914    }
15915
15916    #[test]
15917    fn validate_accepts_distinct_caracteristicas() {
15918        // The canonical authoring shape — every feature distinct — must
15919        // remain a clean pass (positive control sweep). Covers the
15920        // canonical kebab-case feature names a target caixa typically
15921        // declares.
15922        dep_with_features(&["http", "json", "tls"])
15923            .validate()
15924            .unwrap();
15925    }
15926
15927    #[test]
15928    fn validate_accepts_single_caracteristica() {
15929        // Single-element list is the minimum non-empty shape; passes
15930        // the gate as the identity of the duplicate check (no second
15931        // entry to collide with).
15932        dep_with_features(&["http"]).validate().unwrap();
15933    }
15934
15935    #[test]
15936    fn validate_accepts_empty_caracteristicas_list() {
15937        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15938        // produces `caracteristicas: Vec::new()`; the empty list is
15939        // the gate's empty-set identity and passes vacuously. Pin
15940        // this so a future tightening that requires ≥1 feature
15941        // surfaces here as a test failure rather than a silent
15942        // contract narrowing.
15943        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15944        assert!(dep_with_features(&[]).validate().is_ok());
15945    }
15946
15947    #[test]
15948    fn validate_caracteristica_empty_fires_before_duplicate() {
15949        // Empty-first cascade: an entry with an empty feature *and*
15950        // duplicate entries surfaces the empty diagnostic first. The
15951        // empty-feature axis is the more-actionable defect since
15952        // `caracteristica: ""` is unambiguous; under duplicate-first
15953        // ordering the diagnostic could report the empty string from
15954        // either of two empty entries with no way to distinguish.
15955        // Mirrors the peer empty-before-duplicate ordering
15956        // discipline every per-entry shape + duplicate gate establishes
15957        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15958        // `DuplicateChildCaixa`, `validate_membros`'s
15959        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15960        let d = dep_with_features(&["", "http", "http"]);
15961        assert!(matches!(
15962            d.validate().unwrap_err(),
15963            DepError::CaracteristicaEmpty { .. }
15964        ));
15965    }
15966
15967    #[test]
15968    fn validate_caracteristica_duplicate_first_collision_determinism() {
15969        // Three matching entries: the second occurrence surfaces the
15970        // diagnostic (the second is the first *collision* — the first
15971        // entry is the establishing one, not a duplicate). Mirrors
15972        // every peer first-collision posture
15973        // (`SupervisorError::DuplicateChildCaixa` reports the second
15974        // collision, `AplicacaoError::MembroDuplicate` reports the
15975        // second, `DepError::DuplicateNome` reports the second).
15976        // Pinning this so a future shortcut that flips to last-
15977        // collision (or non-deterministic) surfaces here.
15978        let d = dep_with_features(&["http", "http", "http"]);
15979        assert!(matches!(
15980            d.validate().unwrap_err(),
15981            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15982        ));
15983    }
15984
15985    #[test]
15986    fn validate_per_entry_shape_fires_before_caracteristicas() {
15987        // Per-entry shape precedence: a dep with a malformed `:nome`
15988        // (uppercase) AND duplicate `:caracteristicas` surfaces the
15989        // narrower `NomeInvalid` diagnostic first, not the set-gate
15990        // diagnostic. The `:nome` is the self-locating axis (every
15991        // diagnostic from the caracteristicas gate quotes the
15992        // offending dep's `:nome` to anchor the grep target —
15993        // surfacing the malformed name first keeps that anchor
15994        // valid). Same precedence shape every peer per-entry-shape
15995        // arm establishes against its peer set-gate
15996        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15997        // on the cross-entry `:nome` axis).
15998        let d = Dep {
15999            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16000            versao: "^0.1".into(),
16001            fonte: None,
16002            opcional: false,
16003            caracteristicas: vec!["http".into(), "http".into()],
16004        };
16005        assert!(matches!(
16006            d.validate().unwrap_err(),
16007            DepError::NomeInvalid { .. }
16008        ));
16009    }
16010
16011    // ── per-entry :caracteristicas value-shape gate ──────────────────
16012    //
16013    // Until this gate landed `:caracteristicas` only refused the empty
16014    // string and cross-entry duplicates: a non-empty distinct but
16015    // structurally invalid feature name silently passed validate and the
16016    // failure surfaced at `cargo metadata` time as Cargo's
16017    // `restricted_names::validate_feature_name` parser rejection, far from
16018    // the source `caixa.lisp` with no field naming which `:deps` entry's
16019    // `:caracteristicas` carried the typo. The lifted predicate makes the
16020    // Cargo-feature-name-grammar intersection-floor a substrate-level
16021    // invariant at validate time. Same trajectory as the eight peer
16022    // value-shape predicates each typed surface downstream of a structured
16023    // grammar already follows.
16024
16025    #[test]
16026    fn validate_rejects_caracteristica_with_leading_plus() {
16027        // Fail-before-pass-after pin on the canonical Cargo
16028        // `+<feature>` activation-form-in-feature-name-slot footgun.
16029        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16030        // `+optional-feature` as an enablement of a previously-disabled
16031        // feature; pasting that activation form into `:caracteristicas`
16032        // (which names the feature itself) silently passed pre-gate and
16033        // failed at `cargo metadata` parse time.
16034        let d = dep_with_features(&["+http"]);
16035        let err = d.validate().unwrap_err();
16036        assert!(
16037            matches!(
16038                err,
16039                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16040                    if nome == "caixa-teia" && caracteristica == "+http"
16041            ),
16042            "expected CaracteristicaInvalid, got {err:?}"
16043        );
16044    }
16045
16046    #[test]
16047    fn validate_rejects_caracteristica_with_leading_hyphen() {
16048        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16049        // is a legitimate continuation character (kebab-case feature
16050        // names like `runtime-tokio` pass) but Cargo rejects it at the
16051        // start; the structural defect — and its CLI-argument-injection
16052        // adjacency at any downstream Cargo subprocess invocation — is
16053        // closed at validate time, not at `cargo metadata` time.
16054        let d = dep_with_features(&["-json"]);
16055        let err = d.validate().unwrap_err();
16056        assert!(
16057            matches!(
16058                err,
16059                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16060            ),
16061            "expected CaracteristicaInvalid, got {err:?}"
16062        );
16063    }
16064
16065    #[test]
16066    fn validate_rejects_caracteristica_with_leading_dot() {
16067        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16068        // a legitimate continuation character (version-suffix shapes
16069        // like `feat.v2` pass) but the leading-dot form is the
16070        // canonical dotted-version-suffix-as-feature-name confusion.
16071        let d = dep_with_features(&[".feat"]);
16072        let err = d.validate().unwrap_err();
16073        assert!(matches!(
16074            err,
16075            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16076        ));
16077    }
16078
16079    #[test]
16080    fn validate_rejects_caracteristica_with_whitespace() {
16081        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16082        // a feature name with a space inside is structurally a multi-
16083        // token blob (the canonical paste-from-doc footgun, or an
16084        // accidental `"http server"` where the author meant
16085        // `"http-server"`).
16086        let d = dep_with_features(&["http feature"]);
16087        let err = d.validate().unwrap_err();
16088        assert!(matches!(
16089            err,
16090            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16091        ));
16092    }
16093
16094    #[test]
16095    fn validate_rejects_caracteristica_with_comma() {
16096        // Fail-before-pass-after pin on the embedded-comma footgun:
16097        // the list-separator-belongs-to-the-list-grammar
16098        // miscomprehension where the author writes
16099        // `:caracteristicas ("http,json")` intending two features but
16100        // the `Vec<String>` field consumes the bare token as one entry.
16101        let d = dep_with_features(&["http,json"]);
16102        let err = d.validate().unwrap_err();
16103        assert!(matches!(
16104            err,
16105            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16106        ));
16107    }
16108
16109    #[test]
16110    fn validate_rejects_caracteristica_with_slash() {
16111        // Fail-before-pass-after pin on the embedded-slash footgun:
16112        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16113        // `[dependencies.<dep>.features]` list entries that already
16114        // name the parent dep (so the syntax says "enable feature
16115        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16116        // per-dep already (a sibling slot on the `Dep` itself), so the
16117        // segment separator within an entry must be `-`, `_`, `+`,
16118        // or `.`. The diagnostic remediation points at the canonical
16119        // Cargo namespaced-dep discipline.
16120        let d = dep_with_features(&["http/json"]);
16121        let err = d.validate().unwrap_err();
16122        assert!(matches!(
16123            err,
16124            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16125        ));
16126    }
16127
16128    #[test]
16129    fn validate_rejects_caracteristica_with_non_ascii() {
16130        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16131        // byte footgun: NFC-vs-NFD normalization across filesystems
16132        // silently rewrites the feature-key, breaking the lacre's
16133        // content-addressing invariant. Pinned at a canonical
16134        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16135        // documented APFS round-trip break.
16136        let d = dep_with_features(&["caf\u{e9}"]);
16137        let err = d.validate().unwrap_err();
16138        assert!(matches!(
16139            err,
16140            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16141        ));
16142    }
16143
16144    #[test]
16145    fn validate_rejects_caracteristica_with_control_character() {
16146        // Fail-before-pass-after pin on the embedded-control-character
16147        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16148        // feature name is the canonical paste-from-multiline-doc
16149        // footgun the predicate's reason wording specifically calls out.
16150        let d = dep_with_features(&["http\njson"]);
16151        let err = d.validate().unwrap_err();
16152        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16153    }
16154
16155    #[test]
16156    fn validate_accepts_canonical_caracteristicas_shapes() {
16157        // Positive control sweep: every canonical Cargo feature name
16158        // shape the pleme-io ecosystem uses must still pass. Mirrors
16159        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16160        // sweep — drift between either landing site and the predicate's
16161        // accepted set is a build error visible at this pair of tests,
16162        // not a per-renderer "this passed validate but failed at
16163        // cargo metadata time" surprise on the next acceptance.
16164        for s in [
16165            "http",
16166            "json",
16167            "derive",
16168            "serde_json",
16169            "runtime-tokio",
16170            "tokio.full",
16171            "v0.1",
16172            "http+json",
16173            "_internal",
16174            "__private",
16175            "default",
16176            "rt-multi-thread",
16177            "feat.v2",
16178        ] {
16179            let d = dep_with_features(&[s]);
16180            d.validate().unwrap_or_else(|e| {
16181                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16182            });
16183        }
16184    }
16185
16186    #[test]
16187    fn validate_caracteristica_empty_fires_before_invalid() {
16188        // Cascade precedence pin: an entry list with both an empty
16189        // feature AND an invalid-shape feature surfaces the
16190        // `CaracteristicaEmpty` arm first (the empty value carries no
16191        // self-locating data — `caracteristica: ""` is the diagnostic
16192        // with no way to anchor a grep target — so closing the empty
16193        // axis first preserves the per-entry-shape diagnostic's
16194        // self-locating discipline). Same empty-first cascade every
16195        // peer per-entry shape gate establishes
16196        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16197        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16198        // before `MembroCaixaInvalid`).
16199        let d = dep_with_features(&["", "+http"]);
16200        assert!(matches!(
16201            d.validate().unwrap_err(),
16202            DepError::CaracteristicaEmpty { .. }
16203        ));
16204    }
16205
16206    #[test]
16207    fn validate_caracteristica_invalid_fires_before_duplicate() {
16208        // Per-entry-shape precedence pin: an entry list with the same
16209        // invalid feature shape declared twice surfaces the
16210        // `CaracteristicaInvalid` diagnostic on the first entry, not
16211        // the `CaracteristicaDuplicate` on the second collision. The
16212        // per-entry shape gate fires before the cross-entry set gate
16213        // — same precedence shape every peer two-arm-plus-set gate
16214        // establishes (`SupervisorSpec::validate`'s
16215        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16216        // `validate_membros`'s `MembroCaixaInvalid` before
16217        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16218        // cross-list `DuplicateNome`).
16219        let d = dep_with_features(&["+http", "+http"]);
16220        assert!(matches!(
16221            d.validate().unwrap_err(),
16222            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16223        ));
16224    }
16225
16226    #[test]
16227    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16228        // Boundary pin on the 64-byte cap — both the boundary-accepting
16229        // case and the boundary-exceeding case in one place, so a
16230        // future cap shift surfaces both arms simultaneously, mirroring
16231        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16232        // predicate-level pin at the dep-axis landing site.
16233        let max_ok = "a".repeat(64);
16234        dep_with_features(&[&max_ok])
16235            .validate()
16236            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16237        let too_long = "a".repeat(65);
16238        let d = dep_with_features(&[&too_long]);
16239        assert!(matches!(
16240            d.validate().unwrap_err(),
16241            DepError::CaracteristicaInvalid { .. }
16242        ));
16243    }
16244
16245    // ── self-dep cross-slot gate ─────────────────────────────────────
16246
16247    #[test]
16248    fn validate_no_self_dep_rejects_self_in_deps() {
16249        // A caixa whose `:deps` lists its own `:nome` is a one-node
16250        // cycle in the lacre closure's dep-graph traversal — rejected,
16251        // naming the parent and the offending list tag.
16252        let deps = vec![
16253            Dep::simple("caixa-teia", "^0.1"),
16254            Dep::simple("orquestra", "^0.1"),
16255        ];
16256        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16257        assert!(
16258            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16259            "got {err:?}"
16260        );
16261    }
16262
16263    #[test]
16264    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16265        // Same gate on the `:deps-dev` axis — neither dep list is a
16266        // second-class citizen on the self-edge invariant.
16267        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16268        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16269        assert!(
16270            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16271            "got {err:?}"
16272        );
16273    }
16274
16275    #[test]
16276    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16277        // Walk order pin: a caixa that self-references on both lists
16278        // surfaces the `:deps` arm first — the load-bearing axis the
16279        // lacre closure resolves at every build. Mirrors the canonical
16280        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16281        let deps = vec![Dep::simple("orquestra", "^0.1")];
16282        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16283        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16284        assert!(
16285            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16286            "got {err:?}"
16287        );
16288    }
16289
16290    #[test]
16291    fn validate_no_self_dep_accepts_distinct_names() {
16292        // Positive control: every dep names a distinct caixa. The
16293        // canonical author surface — peer of
16294        // [`validate_no_self_supervision_accepts_distinct_children`].
16295        let deps = vec![
16296            Dep::simple("caixa-teia", "^0.1"),
16297            Dep::simple("caixa-arch", "^0.1"),
16298        ];
16299        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16300        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16301    }
16302
16303    #[test]
16304    fn validate_no_self_dep_empty_lists_pass() {
16305        // A caixa with no declared deps has nothing to self-reference —
16306        // the gate is vacuously satisfied. Peer of
16307        // [`validate_no_self_supervision_empty_children_is_ok`].
16308        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16309    }
16310
16311    #[test]
16312    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16313        // Diagnostic-shape pin (peer with
16314        // [`validate_no_self_supervision`]'s diagnostic): the error's
16315        // Display surfaces both the offending list tag and the
16316        // parent's `:nome` verbatim, so the author can grep their
16317        // caixa.lisp for the offending block in one edit. Names
16318        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16319        // surface — every legitimate "I want to use code from this
16320        // caixa" intent routes through one of those three slots.
16321        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16322        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16323            .unwrap_err()
16324            .to_string();
16325        assert!(
16326            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16327            "diagnostic must name the offending list tag: {rendered}",
16328        );
16329        assert!(
16330            rendered.contains("orquestra"),
16331            "diagnostic must quote the parent caixa name: {rendered}",
16332        );
16333        assert!(
16334            rendered.contains(":bibliotecas"),
16335            "diagnostic must point at the corrective code-surface slot: {rendered}",
16336        );
16337    }
16338
16339    #[test]
16340    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16341        // Identity is exact-string equality, not substring — a dep
16342        // named `"orquestra-helper"` is a distinct caixa even when the
16343        // parent is `"orquestra"`. Pin the exact-match discipline so a
16344        // future relaxation that uses `contains` surfaces here, peer
16345        // with the supervision-tree and Aplicacao-membership gates
16346        // which all use exact-string equality on the typed identity.
16347        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16348        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16349    }
16350
16351    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16352
16353    #[test]
16354    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16355        // Scalar-value pin: the two author-facing kebab-case labels the
16356        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16357        // the two-list dep-graph slot axis, one arm per typed slot.
16358        // Mirrors the peer scalar-value pin the sibling
16359        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16360        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16361        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16362        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16363        // (882f498) M3 top-level author-labels, and
16364        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16365        // Supervisor top-level author-labels carry, so every kind-scoped
16366        // typed-slot-family axis routes through one canonical per-arm
16367        // declaration.
16368        //
16369        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16370        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16371        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16372        // for symmetry) lands as an edit to exactly one const, and
16373        // every consumer that reaches for the label picks it up at
16374        // build time rather than at runtime as a downstream mismatch on
16375        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16376        // the rename's commit.
16377        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16378        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16379    }
16380
16381    #[test]
16382    fn dep_author_key_consts_are_pairwise_distinct() {
16383        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16384        // must not collapse onto one byte-string. A future copy-paste
16385        // slip that renamed both consts to the same value (or a rebrand
16386        // that dropped the `-dev` suffix from one but not the other)
16387        // would leave every `DepError::DuplicateNome { list: … }`
16388        // diagnostic naming an unattributable list — the linter would
16389        // route the author to the wrong caixa.lisp block, or the
16390        // cross-list precedence gate
16391        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16392        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16393        // duplicate. Peer of the sibling
16394        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16395        // other top-level kind-scoped slot-family axes carry
16396        // (implicitly held by their different byte-values today).
16397        assert_ne!(
16398            crate::render::DEP_AUTHOR_KEY_DEPS,
16399            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16400            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16401             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16402             self-locates the offending block in the author's caixa.lisp",
16403        );
16404    }
16405
16406    #[test]
16407    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16408        // Production-through-const pin: the two per-arm list tags
16409        // [`validate_no_self_dep`] threads onto the `list:` field of a
16410        // returned [`DepError::DepIsSelf`] route through the lifted
16411        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16412        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16413        // the walker (a rename that reaches one arm but not the const,
16414        // or vice versa) surfaces here at build time rather than at
16415        // runtime as a `feira lint` diagnostic naming the wrong list
16416        // tag. Mirror of the peer
16417        // [`crate::Caixa::declared_servico_slots`] production tagger
16418        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16419        // onto the two-list dep-graph gate.
16420        let deps = vec![Dep::simple("orquestra", "^0.1")];
16421        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16422        let DepError::DepIsSelf { list, .. } = err else {
16423            panic!("expected DepIsSelf from :deps walk");
16424        };
16425        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16426
16427        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16428        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16429        let DepError::DepIsSelf { list, .. } = err else {
16430            panic!("expected DepIsSelf from :deps-dev walk");
16431        };
16432        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16433    }
16434
16435    // ── Dep::nome accessor pins ───────────────────────────────────────
16436    //
16437    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16438    // projection over the plain-shorthand / explicit-git / explicit-path
16439    // fixture triad the [`Dep`] docstring lists (so the accessor's
16440    // accept-set is exercised across every author-surface `:fonte`
16441    // shape); by-borrow pointer identity so the projection stays
16442    // zero-copy at every consumer site; and validate-composition through
16443    // the [`validate_no_self_dep`] cross-slot gate reading its
16444    // parent-name equality check through the lifted accessor rather than
16445    // the raw field.
16446
16447    #[test]
16448    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16449        // Plain-shorthand form (`:fonte None`).
16450        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16451        // Explicit git-source form with a tag pin — same accessor path.
16452        assert_eq!(
16453            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16454            "caixa-teia",
16455        );
16456        // Explicit path-source form.
16457        assert_eq!(
16458            Dep {
16459                nome: "caixa-teia".to_string(),
16460                versao: "0.1.0".to_string(),
16461                fonte: Some(DepSource::Path {
16462                    caminho: "../caixa-teia".to_string(),
16463                }),
16464                opcional: false,
16465                caracteristicas: Vec::new(),
16466            }
16467            .nome(),
16468            "caixa-teia",
16469        );
16470        // The empty-string `:nome` sentinel (which [`Dep::validate`]
16471        // refuses through the [`DepError::NomeEmpty`] arm) still round-
16472        // trips as an empty `&str` through the accessor — the accessor is
16473        // a projection, not a gate; the gate is [`Dep::validate`].
16474        assert_eq!(Dep::simple("", "^0.1").nome(), "");
16475    }
16476
16477    #[test]
16478    fn dep_nome_is_by_borrow_pointer_identity() {
16479        // Zero-copy pin: the accessor must borrow into the field's own
16480        // storage, not clone. If a future rewrite regresses to
16481        // `self.nome.clone().leak()` or an owned-buffer shape, the two
16482        // pointers diverge and this pin fails at build time.
16483        let d = Dep::simple("caixa-teia", "^0.1");
16484        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16485    }
16486
16487    // ── Dep::versao_requirement accessor pins ─────────────────────────
16488    //
16489    // Three coherence pins on the lifted `Dep::versao_requirement`
16490    // accessor: byte-equal projection over the plain-shorthand /
16491    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16492    // lists plus the empty-sentinel that round-trips as `""` (the accessor
16493    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16494    // borrow pointer identity so the projection stays zero-copy at every
16495    // consumer site; and validate-composition through the
16496    // [`crate::render::require_valid_versao_requirement`] cascade reading
16497    // its requirement-shape check through the lifted accessor rather than
16498    // the raw field.
16499    #[test]
16500    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16501        // Plain-shorthand form (`:fonte None`).
16502        assert_eq!(
16503            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16504            "^0.1",
16505        );
16506        // Explicit git-source form with a tag pin — same accessor path.
16507        assert_eq!(
16508            Dep::git(
16509                "caixa-teia",
16510                "~0.1.2",
16511                "github:pleme-io/caixa-teia",
16512                "v0.1.0"
16513            )
16514            .versao_requirement(),
16515            "~0.1.2",
16516        );
16517        // Explicit path-source form.
16518        assert_eq!(
16519            Dep {
16520                nome: "caixa-teia".to_string(),
16521                versao: "0.1.0".to_string(),
16522                fonte: Some(DepSource::Path {
16523                    caminho: "../caixa-teia".to_string(),
16524                }),
16525                opcional: false,
16526                caracteristicas: Vec::new(),
16527            }
16528            .versao_requirement(),
16529            "0.1.0",
16530        );
16531        // The wildcard requirement (`"*"`) — the shorthand
16532        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16533        // verbatim through the accessor as `"*"`, same byte-shape the
16534        // author wrote.
16535        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16536        // The empty-string `:versao` sentinel (which [`Dep::validate`]
16537        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16538        // trips as an empty `&str` through the accessor — the accessor is
16539        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16540        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16541        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16542    }
16543
16544    #[test]
16545    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16546        // Zero-copy pin: the accessor must borrow into the field's own
16547        // storage, not clone. If a future rewrite regresses to
16548        // `self.versao.clone().leak()` or an owned-buffer shape, the two
16549        // pointers diverge and this pin fails at build time. Peer of the
16550        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16551        // discipline extended onto the requirement-carrying axis.
16552        let d = Dep::simple("caixa-teia", "^0.1");
16553        assert!(std::ptr::eq(
16554            d.versao_requirement().as_ptr(),
16555            d.versao.as_ptr(),
16556        ));
16557    }
16558
16559    #[test]
16560    fn dep_validate_reads_requirement_through_accessor() {
16561        // Composition pin: the [`Dep::validate`]
16562        // [`crate::render::require_valid_versao_requirement`] cascade
16563        // consumes the requirement string through the lifted accessor —
16564        // both the requirement-gate input and the
16565        // [`DepError::VersaoInvalid`] error-body carrier route through
16566        // `self.versao_requirement()`. A valid requirement passes
16567        // (positive control); a malformed-but-non-empty requirement fails
16568        // and the diagnostic quotes the offending byte-string verbatim
16569        // (same shape the accessor projects), so a future regression that
16570        // detoured the requirement carrier through a different byte-
16571        // string (say the parsed `VersionReq`'s `Display`, or a
16572        // normalized rewrite) would surface here at build time. The
16573        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16574        // ahead of the parse arm, pinning the empty-first cascade the
16575        // accessor's `""` sentinel round-trip acknowledges.
16576        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16577        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16578        assert!(
16579            matches!(
16580                &err,
16581                DepError::VersaoInvalid {
16582                    nome,
16583                    versao,
16584                    ..
16585                } if nome == "caixa-teia" && versao == "v0.1",
16586            ),
16587            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16588        );
16589        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16590        assert!(
16591            matches!(
16592                &err,
16593                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16594            ),
16595            "expected VersaoEmpty from the empty-first arm, got {err:?}",
16596        );
16597    }
16598
16599    // ── Dep::fonte accessor pins ──────────────────────────────────────
16600    //
16601    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16602    // equal projection over the plain-shorthand (`:fonte None`) /
16603    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16604    // docstring lists (so the accessor's accept-set is exercised across
16605    // every author-surface `:fonte` shape and both `DepSource` variants);
16606    // pointer identity so the borrowed reference points into the field's
16607    // own `Option<DepSource>` storage (not a cloned side-buffer); and
16608    // validate-composition through the [`Dep::validate`] gate reading
16609    // its per-`:fonte` [`DepSource::validate`] delegation through the
16610    // lifted accessor rather than the raw `if let Some(ref fonte) =
16611    // self.fonte` bracket.
16612
16613    #[test]
16614    fn dep_fonte_returns_declared_source_across_shapes() {
16615        // Plain-shorthand form — `:fonte` omitted, accessor projects
16616        // the `None` partition the resolver-side default-fill treats
16617        // as "resolve through `github:<default-org>/<nome>`".
16618        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16619        // Explicit git-source form with a tag pin — same accessor path.
16620        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16621        match git.fonte() {
16622            Some(DepSource::Git {
16623                repo,
16624                tag,
16625                rev,
16626                branch,
16627            }) => {
16628                assert_eq!(repo, "github:pleme-io/caixa-teia");
16629                assert_eq!(tag.as_deref(), Some("v0.1.0"));
16630                assert!(rev.is_none());
16631                assert!(branch.is_none());
16632            }
16633            other => panic!("expected explicit git :fonte, got {other:?}"),
16634        }
16635        // Explicit path-source form — the dev-only local-filesystem
16636        // arm the [`Dep`] docstring's third fixture carries.
16637        let path = Dep {
16638            nome: "caixa-teia".to_string(),
16639            versao: "0.1.0".to_string(),
16640            fonte: Some(DepSource::Path {
16641                caminho: "../caixa-teia".to_string(),
16642            }),
16643            opcional: false,
16644            caracteristicas: Vec::new(),
16645        };
16646        match path.fonte() {
16647            Some(DepSource::Path { caminho }) => {
16648                assert_eq!(caminho, "../caixa-teia");
16649            }
16650            other => panic!("expected explicit path :fonte, got {other:?}"),
16651        }
16652    }
16653
16654    #[test]
16655    fn dep_fonte_is_by_borrow_pointer_identity() {
16656        // Zero-copy pin: the accessor must borrow into the field's own
16657        // `Option<DepSource>` storage, not clone into a side buffer. If
16658        // a future rewrite regresses to `self.fonte.clone()` or an
16659        // owned-buffer shape, the two pointers diverge and this pin
16660        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16661        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16662        // identity pins — same by-borrow discipline extended onto the
16663        // outer-`Dep` `Option<&Composite>` composite-reference axis.
16664        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16665        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16666        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16667        assert!(std::ptr::eq(accessed, raw));
16668    }
16669
16670    #[test]
16671    fn dep_validate_reads_fonte_through_accessor() {
16672        // Composition pin: [`Dep::validate`]'s per-`:fonte`
16673        // [`DepSource::validate`] delegation consumes the typed slot
16674        // through the lifted accessor — an author-omitted `:fonte`
16675        // still passes the outer gate (positive control), an explicit
16676        // well-formed git source with exactly one pin passes, and a
16677        // malformed git source (empty `:repo`) surfaces the
16678        // [`DepError::FonteRepoEmpty`] variant quoting the offending
16679        // dep's `:nome` verbatim so a future regression that detoured
16680        // the `:fonte` delegation through a different path (say a
16681        // per-scope override projector) would surface here at build
16682        // time. Peer of the sibling
16683        // `dep_validate_reads_requirement_through_accessor` composition
16684        // pin on the `:versao` axis.
16685        // Positive control 1: no `:fonte` at all.
16686        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16687        // Positive control 2: well-formed git source.
16688        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16689            .validate()
16690            .unwrap();
16691        // Negative control: empty `:repo` — the accessor still returns
16692        // `Some(&DepSource::Git { repo: "", … })` and the delegated
16693        // `DepSource::validate` gate raises the typed carrier.
16694        let bad = Dep {
16695            nome: "caixa-teia".to_string(),
16696            versao: "^0.1".to_string(),
16697            fonte: Some(DepSource::Git {
16698                repo: String::new(),
16699                tag: Some("v0.1.0".to_string()),
16700                rev: None,
16701                branch: None,
16702            }),
16703            opcional: false,
16704            caracteristicas: Vec::new(),
16705        };
16706        let err = bad.validate().unwrap_err();
16707        assert!(
16708            matches!(
16709                &err,
16710                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16711            ),
16712            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16713        );
16714    }
16715
16716    #[test]
16717    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16718        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16719        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16720        // own `:nome` through the lifted accessor rather than the raw
16721        // field. Fails-before-passes-after: with the accessor lifted the
16722        // gate reads its equality check through `dep.nome() ==
16723        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16724        // the diagnostic still names the offending list tag as expected.
16725        let deps = vec![Dep::simple("orquestra", "^0.1")];
16726        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16727        assert!(matches!(
16728            err,
16729            DepError::DepIsSelf {
16730                ref nome,
16731                list,
16732            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16733        ));
16734        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16735        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16736        assert!(matches!(
16737            err,
16738            DepError::DepIsSelf {
16739                ref nome,
16740                list,
16741            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16742        ));
16743        // A non-matching `:nome` passes through the accessor gate.
16744        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16745        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16746    }
16747
16748    // ── Dep::caracteristicas accessor pins ────────────────────────────
16749    //
16750    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16751    // byte-equal projection over the default-empty / single-entry /
16752    // multi-entry fixture triad (so the accessor's accept-set is
16753    // exercised across every author-surface `:caracteristicas` shape,
16754    // matching the peer sibling family's fixture-triad discipline); by-
16755    // borrow pointer identity so the projection stays zero-copy at every
16756    // consumer site; and validate-composition through the
16757    // [`Dep::validate_caracteristicas`] gate reading its per-entry
16758    // linear walk through the lifted accessor rather than the raw
16759    // `for c in &self.caracteristicas` bracket.
16760
16761    #[test]
16762    fn dep_caracteristicas_returns_declared_features_across_shapes() {
16763        // Default-empty form — the [`Dep::simple`] constructor's
16764        // `Vec::new()` fill; the accessor projects the empty slice
16765        // verbatim (no `None` collapse).
16766        assert!(
16767            Dep::simple("caixa-teia", "^0.1")
16768                .caracteristicas()
16769                .is_empty(),
16770        );
16771        // Single-entry form — the canonical Cargo-shaped one-feature
16772        // enable ([`crate::render::is_cargo_feature_name`] accepts the
16773        // `"http"` byte-string as a valid feature name).
16774        let one = Dep {
16775            nome: "caixa-teia".to_string(),
16776            versao: "^0.1".to_string(),
16777            fonte: None,
16778            opcional: false,
16779            caracteristicas: vec!["http".to_string()],
16780        };
16781        assert_eq!(one.caracteristicas(), &["http".to_string()]);
16782        // Multi-entry form — the substrate's set-shaped multi-feature
16783        // enable, exercising the accessor over a length-two slice with
16784        // no duplicate collapse.
16785        let two = Dep {
16786            nome: "caixa-teia".to_string(),
16787            versao: "^0.1".to_string(),
16788            fonte: None,
16789            opcional: false,
16790            caracteristicas: vec!["http".to_string(), "json".to_string()],
16791        };
16792        assert_eq!(
16793            two.caracteristicas(),
16794            &["http".to_string(), "json".to_string()],
16795        );
16796    }
16797
16798    #[test]
16799    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16800        // Zero-copy pin: the accessor must borrow into the field's own
16801        // `Vec<String>` storage, not clone into a side buffer. If a
16802        // future rewrite regresses to `self.caracteristicas.clone()` or
16803        // an owned-buffer shape, the two pointers diverge and this pin
16804        // fails at build time. Peer of the sibling per-`Dep`
16805        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16806        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16807        // borrow discipline extended onto the outer-`Dep` `&[String]`
16808        // slice-projection axis.
16809        let d = Dep {
16810            nome: "caixa-teia".to_string(),
16811            versao: "^0.1".to_string(),
16812            fonte: None,
16813            opcional: false,
16814            caracteristicas: vec!["http".to_string(), "json".to_string()],
16815        };
16816        assert!(std::ptr::eq(
16817            d.caracteristicas().as_ptr(),
16818            d.caracteristicas.as_ptr(),
16819        ));
16820    }
16821
16822    #[test]
16823    fn dep_validate_reads_caracteristicas_through_accessor() {
16824        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16825        // linear walk consumes the feature-toggle list through the
16826        // lifted accessor — a well-formed `:caracteristicas` set passes
16827        // (positive control), an empty-string entry surfaces the
16828        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16829        // `Dep::nome`, and a within-list duplicate surfaces the
16830        // [`DepError::CaracteristicaDuplicate`] variant so a future
16831        // regression that detoured the walk through a different byte-
16832        // string list (say a per-scope override projector) would surface
16833        // here at build time. Peer of the sibling
16834        // `dep_validate_reads_fonte_through_accessor` /
16835        // `dep_validate_reads_requirement_through_accessor` composition
16836        // pins on the `:fonte` / `:versao` axes.
16837        // Positive control: two distinct well-formed feature names pass.
16838        Dep {
16839            nome: "caixa-teia".to_string(),
16840            versao: "^0.1".to_string(),
16841            fonte: None,
16842            opcional: false,
16843            caracteristicas: vec!["http".to_string(), "json".to_string()],
16844        }
16845        .validate()
16846        .unwrap();
16847        // Negative control 1: empty-string feature-name entry — the
16848        // accessor still returns `&[""]` and the walk raises the typed
16849        // empty-first carrier.
16850        let err = Dep {
16851            nome: "caixa-teia".to_string(),
16852            versao: "^0.1".to_string(),
16853            fonte: None,
16854            opcional: false,
16855            caracteristicas: vec![String::new()],
16856        }
16857        .validate()
16858        .unwrap_err();
16859        assert!(
16860            matches!(
16861                &err,
16862                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16863            ),
16864            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16865        );
16866        // Negative control 2: within-list duplicate — the accessor's
16867        // slice view carries both entries, and the walk's dedup arm
16868        // raises the typed duplicate carrier quoting the offending
16869        // feature name verbatim.
16870        let err = Dep {
16871            nome: "caixa-teia".to_string(),
16872            versao: "^0.1".to_string(),
16873            fonte: None,
16874            opcional: false,
16875            caracteristicas: vec!["http".to_string(), "http".to_string()],
16876        }
16877        .validate()
16878        .unwrap_err();
16879        assert!(
16880            matches!(
16881                &err,
16882                DepError::CaracteristicaDuplicate {
16883                    nome,
16884                    caracteristica,
16885                } if nome == "caixa-teia" && caracteristica == "http",
16886            ),
16887            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16888        );
16889    }
16890
16891    // ── Dep::opcional accessor pins ───────────────────────────────────
16892    //
16893    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16894    // equal projection over the default-`false` / explicit-`true`
16895    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16896    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16897    // exercising the accessor's accept-set over every author-surface
16898    // `:fonte` shape × every author-surface `:opcional` shape; and by-
16899    // `Copy` idempotency so the projection stays value-return (no
16900    // silent detour to a fresh `&bool` borrow that would introduce a
16901    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16902    // shape elides). No composition pin — `:opcional` does not
16903    // participate in [`Dep::validate`] (an opcional dep with any bool
16904    // value is validate-accepted; the missing-source arm is a resolver-
16905    // side runtime dispatch, not a build-time refusal), so the axis
16906    // reduces to the value-shape + `Copy` pin pair the peer
16907    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16908    // outer-`Option<Copy>` accessor pins already carry.
16909
16910    #[test]
16911    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16912        // Default-`false` form via the [`Dep::simple`] constructor —
16913        // the accessor projects the `false` bit the default-fill sets.
16914        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16915        // Default-`false` form via the [`Dep::git`] constructor — same
16916        // default fill; the accessor projects `false` regardless of the
16917        // `:fonte` arm.
16918        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16919        // Explicit-`true` form × plain-shorthand `:fonte` — the
16920        // canonical author-surface "this dep may be missing" shape.
16921        let plain_true = Dep {
16922            nome: "caixa-teia".to_string(),
16923            versao: "^0.1".to_string(),
16924            fonte: None,
16925            opcional: true,
16926            caracteristicas: Vec::new(),
16927        };
16928        assert!(plain_true.opcional());
16929        // Explicit-`true` form × explicit git-source — the accessor
16930        // projects the bit verbatim regardless of the `:fonte` arm.
16931        let git_true = Dep {
16932            nome: "caixa-teia".to_string(),
16933            versao: "^0.1".to_string(),
16934            fonte: Some(DepSource::Git {
16935                repo: "github:pleme-io/caixa-teia".to_string(),
16936                tag: Some("v0.1.0".to_string()),
16937                rev: None,
16938                branch: None,
16939            }),
16940            opcional: true,
16941            caracteristicas: Vec::new(),
16942        };
16943        assert!(git_true.opcional());
16944        // Explicit-`true` form × explicit path-source — the dev-only
16945        // local-filesystem arm the [`Dep`] docstring's third fixture
16946        // carries.
16947        let path_true = Dep {
16948            nome: "caixa-teia".to_string(),
16949            versao: "0.1.0".to_string(),
16950            fonte: Some(DepSource::Path {
16951                caminho: "../caixa-teia".to_string(),
16952            }),
16953            opcional: true,
16954            caracteristicas: Vec::new(),
16955        };
16956        assert!(path_true.opcional());
16957    }
16958
16959    #[test]
16960    fn dep_opcional_projects_bool_by_copy() {
16961        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16962        // (`bool: Copy`) — the accessor does not borrow `&self` past
16963        // the call (no lifetime on the return type), and calling the
16964        // accessor twice on the same [`Dep`] must yield discriminant-
16965        // equal values (idempotent, no side effects on `&self`). Peer
16966        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16967        // `max_restarts_projects_option_by_copy` (eba5211) /
16968        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16969        // outer-`Caixa` altitude — extended here to the outer-`Dep`
16970        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16971        // replaces the pointer-equality claim the sibling per-`Dep`
16972        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16973        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16974        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16975        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16976        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16977        // the same discriminant, so the axis reduces to discriminant
16978        // equality).
16979        //
16980        // Pins against a future silent detour that returned a fresh
16981        // `&bool` reference (which would type-check but silently
16982        // introduce a borrow of `&self` past the call, collapsing the
16983        // load-bearing "no lifetime on the return type" `Copy`
16984        // projection the plain-`Copy`-scalar axis's `bool` shape
16985        // carries) or a stale-read side effect that flipped the outer
16986        // discriminant on successive calls.
16987        for opcional in [false, true] {
16988            let d = Dep {
16989                nome: "caixa-teia".to_string(),
16990                versao: "^0.1".to_string(),
16991                fonte: None,
16992                opcional,
16993                caracteristicas: Vec::new(),
16994            };
16995            let first = d.opcional();
16996            let second = d.opcional();
16997            assert_eq!(
16998                first, second,
16999                "Dep::opcional must be idempotent — two successive calls \
17000                 on the same &self must return the same bool",
17001            );
17002            assert_eq!(
17003                first, opcional,
17004                "Dep::opcional must return :opcional verbatim by Copy — \
17005                 got {first}, expected {opcional}",
17006            );
17007            assert_eq!(
17008                d.opcional(),
17009                d.opcional,
17010                "Dep::opcional accessor and self.opcional field access \
17011                 must byte-equal — a bit-flip drift would silently split \
17012                 the paired resolver-side drop-vs-error dispatch from \
17013                 the storage-side default-fill the [`Dep::simple`] / \
17014                 [`Dep::git`] constructor pair carries",
17015            );
17016        }
17017    }
17018
17019    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17020
17021    #[test]
17022    fn sole_pin_returns_none_for_path_source() {
17023        // A path source carries no git-ref, so `sole_pin()` returns
17024        // `None` structurally — the sibling arm every git-fetching
17025        // consumer partitions off before reaching for a git-ref. Pins
17026        // the Path-arm branch of the accessor against a future silent
17027        // detour that treats a `Self::Path` as an unpinned-git source
17028        // and returns the wrong "no pin" signal (e.g. the empty string,
17029        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17030        // path-arm `git_ref` fill).
17031        let s = DepSource::Path {
17032            caminho: "../local-caixa".to_string(),
17033        };
17034        assert_eq!(s.sole_pin(), None);
17035    }
17036
17037    #[test]
17038    fn sole_pin_returns_none_for_unpinned_git_source() {
17039        // The [`DepSource::default_github`] shorthand shape carries no
17040        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17041        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17042        // materializes when the author omits `:fonte` entirely, then
17043        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17044        // on the `None` arm — the accessor's return matches the arm
17045        // the resolver's diagnostic keys off.
17046        let s = DepSource::default_github("pleme-io", "caixa-teia");
17047        assert_eq!(s.sole_pin(), None);
17048    }
17049
17050    #[test]
17051    fn sole_pin_returns_rev_when_only_rev_is_set() {
17052        let s = DepSource::Git {
17053            repo: "github:o/x".into(),
17054            tag: None,
17055            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17056            branch: None,
17057        };
17058        assert_eq!(
17059            s.sole_pin(),
17060            Some("deadbeefcafebabe1234567890abcdef12345678")
17061        );
17062    }
17063
17064    #[test]
17065    fn sole_pin_returns_tag_when_only_tag_is_set() {
17066        let s = DepSource::Git {
17067            repo: "github:o/x".into(),
17068            tag: Some("v0.1.0".into()),
17069            rev: None,
17070            branch: None,
17071        };
17072        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17073    }
17074
17075    #[test]
17076    fn sole_pin_returns_branch_when_only_branch_is_set() {
17077        let s = DepSource::Git {
17078            repo: "github:o/x".into(),
17079            tag: None,
17080            rev: None,
17081            branch: Some("main".into()),
17082        };
17083        assert_eq!(s.sole_pin(), Some("main"));
17084    }
17085
17086    #[test]
17087    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17088        // Precedence: rev > tag > branch. Validate() rejects
17089        // multiple-pin shapes, but the accessor's precedence is defined
17090        // for pre-validate consumers (the resolver's `MissingPin`
17091        // diagnostic path, the caixa-crd round-trip's default `"main"`
17092        // fallback) and as defense-in-depth if the gate is ever
17093        // bypassed. Pins the same precedence caixa-resolver's
17094        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17095        // inline.
17096        let s = DepSource::Git {
17097            repo: "github:o/x".into(),
17098            tag: Some("v1".into()),
17099            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17100            branch: Some("main".into()),
17101        };
17102        assert_eq!(
17103            s.sole_pin(),
17104            Some("deadbeefcafebabe1234567890abcdef12345678")
17105        );
17106    }
17107
17108    #[test]
17109    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17110        let s = DepSource::Git {
17111            repo: "github:o/x".into(),
17112            tag: Some("v1".into()),
17113            rev: None,
17114            branch: Some("main".into()),
17115        };
17116        assert_eq!(s.sole_pin(), Some("v1"));
17117    }
17118
17119    #[test]
17120    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17121        // Fail-before-pass-after byte-parity pin: the substrate accessor
17122        // must return byte-identical to the inline
17123        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17124        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17125        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17126        // time if the accessor's precedence silently drifts from the
17127        // consumer-side cascade — the exact drift this lift converges
17128        // to one substrate primitive to close structurally.
17129        //
17130        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17131        // branch) each-either-`None`-or-`Some`, so every arm of the
17132        // precedence cascade lands under the pin. `validate()` refuses
17133        // the 4 multi-pin combinations, but the accessor's return is
17134        // defined on all 8.
17135        let vals = [Some("R".to_string()), None];
17136        for tag in &vals {
17137            for rev in &vals {
17138                for branch in &vals {
17139                    let s = DepSource::Git {
17140                        repo: "github:o/x".into(),
17141                        tag: tag.clone(),
17142                        rev: rev.clone(),
17143                        branch: branch.clone(),
17144                    };
17145                    // The exact inline cascade the two pre-lift
17146                    // consumer sites hand-rolled, byte-for-byte.
17147                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17148                    assert_eq!(
17149                        s.sole_pin(),
17150                        expected,
17151                        "sole_pin() must byte-equal \
17152                         rev.or(tag).or(branch) for \
17153                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17154                         a drift would silently split caixa-resolver's \
17155                         fetch_git checkout target from caixa-crd's \
17156                         dep_into_ref git_ref fill",
17157                    );
17158                }
17159            }
17160        }
17161    }
17162
17163    // Fail-before-pass-after pins on the eleven
17164    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17165    // constructors folded from the [`DepSource::validate_caminho`]
17166    // wire-up sites. Each pins the generated ctor's output to the
17167    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17168    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17169    // regression on the two-field `{ nome: nome.to_string(), caminho:
17170    // caminho.to_string() }` construction surfaces here rather than at
17171    // a downstream diagnostic-shape mismatch. Peer of the sibling
17172    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17173    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17174    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17175    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17176    // pins on the peer `SupervisorError` / `AplicacaoError` /
17177    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17178
17179    #[test]
17180    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17181        assert_eq!(
17182            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17183            DepError::FonteCaminhoAbsolute {
17184                nome: "caixa-teia".to_string(),
17185                caminho: "/home/me/work/caixa-teia".to_string(),
17186            },
17187            "generated fonte_caminho_absolute ctor must produce byte-equal \
17188             DepError to the open-coded struct-literal wrap on the same \
17189             (&str, &str) fixture",
17190        );
17191    }
17192
17193    #[test]
17194    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17195        assert_eq!(
17196            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17197            DepError::FonteCaminhoTildeExpansion {
17198                nome: "caixa-teia".to_string(),
17199                caminho: "~/work/caixa-teia".to_string(),
17200            },
17201        );
17202    }
17203
17204    #[test]
17205    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17206        assert_eq!(
17207            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17208            DepError::FonteCaminhoVarExpansion {
17209                nome: "caixa-teia".to_string(),
17210                caminho: "$HOME/work/caixa-teia".to_string(),
17211            },
17212        );
17213    }
17214
17215    #[test]
17216    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17217        assert_eq!(
17218            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17219            DepError::FonteCaminhoLeadingWhitespace {
17220                nome: "caixa-teia".to_string(),
17221                caminho: " ../caixa-teia".to_string(),
17222            },
17223        );
17224    }
17225
17226    #[test]
17227    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17228        assert_eq!(
17229            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17230            DepError::FonteCaminhoLeadingHyphen {
17231                nome: "caixa-teia".to_string(),
17232                caminho: "-rf".to_string(),
17233            },
17234        );
17235    }
17236
17237    #[test]
17238    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17239        assert_eq!(
17240            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17241            DepError::FonteCaminhoBackslash {
17242                nome: "caixa-teia".to_string(),
17243                caminho: "..\\caixa-teia".to_string(),
17244            },
17245        );
17246    }
17247
17248    #[test]
17249    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17250        assert_eq!(
17251            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17252            DepError::FonteCaminhoShellPipe {
17253                nome: "caixa-teia".to_string(),
17254                caminho: "../caixa-teia|evil".to_string(),
17255            },
17256        );
17257    }
17258
17259    #[test]
17260    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17261        assert_eq!(
17262            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17263            DepError::FonteCaminhoShellSemicolon {
17264                nome: "caixa-teia".to_string(),
17265                caminho: "../caixa-teia;evil".to_string(),
17266            },
17267        );
17268    }
17269
17270    #[test]
17271    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17272        assert_eq!(
17273            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17274            DepError::FonteCaminhoShellBackground {
17275                nome: "caixa-teia".to_string(),
17276                caminho: "../caixa-teia&".to_string(),
17277            },
17278        );
17279    }
17280
17281    #[test]
17282    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17283        assert_eq!(
17284            DepError::fonte_caminho_shell_command_substitution(
17285                "caixa-teia",
17286                "../caixa-teia`whoami`",
17287            ),
17288            DepError::FonteCaminhoShellCommandSubstitution {
17289                nome: "caixa-teia".to_string(),
17290                caminho: "../caixa-teia`whoami`".to_string(),
17291            },
17292        );
17293    }
17294
17295    #[test]
17296    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17297        assert_eq!(
17298            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17299            DepError::FonteCaminhoTrailingSlash {
17300                nome: "caixa-teia".to_string(),
17301                caminho: "../caixa-teia/".to_string(),
17302            },
17303        );
17304    }
17305
17306    #[test]
17307    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17308        // Cross-axis pin: sweep the two constructor input axes
17309        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17310        // pair against every generated arm in the
17311        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17312        // / trim / truncate / re-order on the two-field
17313        // `{ nome, caminho }` construction — or a silent field swap
17314        // between the two axes at codegen time — surfaces here rather
17315        // than at a downstream diagnostic-shape mismatch. Peer of the
17316        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17317        // to_string` cross-axis routing pin on the peer
17318        // `SupervisorError` envelope, extended here onto the
17319        // `DepError` `{ nome: String, caminho: String }` envelope so
17320        // every substrate-primitive ctor family in caixa-core
17321        // guarantees each `&str`-field construction routes the
17322        // caller's `&str` verbatim through `.to_string()`.
17323        let nome = "sibling-teia";
17324        let caminho = "../workspace/sibling";
17325        let cases: [(DepError, DepError); 11] = [
17326            (
17327                DepError::fonte_caminho_absolute(nome, caminho),
17328                DepError::FonteCaminhoAbsolute {
17329                    nome: nome.to_string(),
17330                    caminho: caminho.to_string(),
17331                },
17332            ),
17333            (
17334                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17335                DepError::FonteCaminhoTildeExpansion {
17336                    nome: nome.to_string(),
17337                    caminho: caminho.to_string(),
17338                },
17339            ),
17340            (
17341                DepError::fonte_caminho_var_expansion(nome, caminho),
17342                DepError::FonteCaminhoVarExpansion {
17343                    nome: nome.to_string(),
17344                    caminho: caminho.to_string(),
17345                },
17346            ),
17347            (
17348                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17349                DepError::FonteCaminhoLeadingWhitespace {
17350                    nome: nome.to_string(),
17351                    caminho: caminho.to_string(),
17352                },
17353            ),
17354            (
17355                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17356                DepError::FonteCaminhoLeadingHyphen {
17357                    nome: nome.to_string(),
17358                    caminho: caminho.to_string(),
17359                },
17360            ),
17361            (
17362                DepError::fonte_caminho_backslash(nome, caminho),
17363                DepError::FonteCaminhoBackslash {
17364                    nome: nome.to_string(),
17365                    caminho: caminho.to_string(),
17366                },
17367            ),
17368            (
17369                DepError::fonte_caminho_shell_pipe(nome, caminho),
17370                DepError::FonteCaminhoShellPipe {
17371                    nome: nome.to_string(),
17372                    caminho: caminho.to_string(),
17373                },
17374            ),
17375            (
17376                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17377                DepError::FonteCaminhoShellSemicolon {
17378                    nome: nome.to_string(),
17379                    caminho: caminho.to_string(),
17380                },
17381            ),
17382            (
17383                DepError::fonte_caminho_shell_background(nome, caminho),
17384                DepError::FonteCaminhoShellBackground {
17385                    nome: nome.to_string(),
17386                    caminho: caminho.to_string(),
17387                },
17388            ),
17389            (
17390                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17391                DepError::FonteCaminhoShellCommandSubstitution {
17392                    nome: nome.to_string(),
17393                    caminho: caminho.to_string(),
17394                },
17395            ),
17396            (
17397                DepError::fonte_caminho_trailing_slash(nome, caminho),
17398                DepError::FonteCaminhoTrailingSlash {
17399                    nome: nome.to_string(),
17400                    caminho: caminho.to_string(),
17401                },
17402            ),
17403        ];
17404        for (via_ctor, via_struct_literal) in cases {
17405            assert_eq!(
17406                via_ctor, via_struct_literal,
17407                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17408                 through `.to_string()` in declared field order — a field-swap or \
17409                 silent-conversion regression surfaces here rather than at a \
17410                 downstream diagnostic-shape mismatch",
17411            );
17412        }
17413    }
17414
17415    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17416    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17417    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17418    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17419    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17420
17421    #[test]
17422    fn versao_empty_ctor_matches_struct_literal_wrap() {
17423        assert_eq!(
17424            DepError::versao_empty("caixa-teia"),
17425            DepError::VersaoEmpty {
17426                nome: "caixa-teia".to_string(),
17427            },
17428        );
17429    }
17430
17431    #[test]
17432    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17433        assert_eq!(
17434            DepError::fonte_repo_empty("caixa-teia"),
17435            DepError::FonteRepoEmpty {
17436                nome: "caixa-teia".to_string(),
17437            },
17438        );
17439    }
17440
17441    #[test]
17442    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17443        assert_eq!(
17444            DepError::fonte_pin_missing("caixa-teia"),
17445            DepError::FontePinMissing {
17446                nome: "caixa-teia".to_string(),
17447            },
17448        );
17449    }
17450
17451    #[test]
17452    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17453        assert_eq!(
17454            DepError::fonte_caminho_empty("caixa-teia"),
17455            DepError::FonteCaminhoEmpty {
17456                nome: "caixa-teia".to_string(),
17457            },
17458        );
17459    }
17460
17461    #[test]
17462    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17463        assert_eq!(
17464            DepError::caracteristica_empty("caixa-teia"),
17465            DepError::CaracteristicaEmpty {
17466                nome: "caixa-teia".to_string(),
17467            },
17468        );
17469    }
17470
17471    #[test]
17472    fn dep_nome_only_ctors_route_nome_through_to_string() {
17473        // Cross-axis routing pin: sweep the single constructor input
17474        // axis (`nome: &str`) through a non-default fixture against
17475        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17476        // any wrapper-side lowercase / trim / truncate at codegen time
17477        // — or a silent field re-name away from the canonical `nome`
17478        // axis on any one variant — surfaces here rather than at a
17479        // downstream diagnostic-shape mismatch. Peer of the sibling
17480        // `fonte_caminho_ctors_route_nome_and_caminho_through_
17481        // to_string` cross-axis routing pin on the same envelope's
17482        // two-slot family (f85f145) and of the peer
17483        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17484        // pin on the `SupervisorError` single-slot family (db09650).
17485        let nome = "sibling-teia";
17486        let cases: [(DepError, DepError); 5] = [
17487            (
17488                DepError::versao_empty(nome),
17489                DepError::VersaoEmpty {
17490                    nome: nome.to_string(),
17491                },
17492            ),
17493            (
17494                DepError::fonte_repo_empty(nome),
17495                DepError::FonteRepoEmpty {
17496                    nome: nome.to_string(),
17497                },
17498            ),
17499            (
17500                DepError::fonte_pin_missing(nome),
17501                DepError::FontePinMissing {
17502                    nome: nome.to_string(),
17503                },
17504            ),
17505            (
17506                DepError::fonte_caminho_empty(nome),
17507                DepError::FonteCaminhoEmpty {
17508                    nome: nome.to_string(),
17509                },
17510            ),
17511            (
17512                DepError::caracteristica_empty(nome),
17513                DepError::CaracteristicaEmpty {
17514                    nome: nome.to_string(),
17515                },
17516            ),
17517        ];
17518        for (via_ctor, via_struct_literal) in cases {
17519            assert_eq!(
17520                via_ctor, via_struct_literal,
17521                "dep_nome_only_ctors!-generated ctor must route `nome` \
17522                 through `.to_string()` onto the canonical `nome` field \
17523                 — a field-rename or silent-conversion regression surfaces \
17524                 here rather than at a downstream diagnostic-shape mismatch",
17525            );
17526        }
17527    }
17528
17529    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17530    //    &'static str }` two-slot envelope on `DepError`, strict
17531    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17532    //    same envelope's `{ nome: String }` one-slot shape and of the
17533    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
17534    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17535
17536    #[test]
17537    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17538        assert_eq!(
17539            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17540            DepError::DuplicateNome {
17541                nome: "caixa-teia".to_string(),
17542                list: crate::render::DEP_AUTHOR_KEY_DEPS,
17543            },
17544            "generated duplicate_nome ctor must produce byte-equal \
17545             `DepError::DuplicateNome` to the pre-lift struct-literal \
17546             wrap on the same scalar fixtures",
17547        );
17548    }
17549
17550    #[test]
17551    fn dep_is_self_ctor_matches_struct_literal_wrap() {
17552        assert_eq!(
17553            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17554            DepError::DepIsSelf {
17555                nome: "orquestra".to_string(),
17556                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17557            },
17558            "generated dep_is_self ctor must produce byte-equal \
17559             `DepError::DepIsSelf` to the pre-lift struct-literal \
17560             wrap on the same scalar fixtures",
17561        );
17562    }
17563
17564    #[test]
17565    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17566        // Cross-axis routing pin: sweep the two constructor input axes
17567        // (`nome: &str`, `list: &'static str`) through non-default
17568        // fixtures against every generated arm in the
17569        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17570        // lowercase / trim / truncate at codegen time — or a silent
17571        // field re-name away from the canonical `nome` / `list` axes
17572        // on any one variant, or a `list` axis silently rerouted
17573        // through `.to_string()` instead of passed as `&'static str`
17574        // verbatim — surfaces here rather than at a downstream
17575        // diagnostic-shape mismatch. Peer of the sibling
17576        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17577        // (792aa92) on the same envelope's one-slot family, and of the
17578        // peer
17579        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17580        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17581        // two-slot `{ caixa: String, reason: String }` shape.
17582        let nome = "sibling-teia";
17583        let cases: [(DepError, DepError); 4] = [
17584            (
17585                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17586                DepError::DuplicateNome {
17587                    nome: nome.to_string(),
17588                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17589                },
17590            ),
17591            (
17592                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17593                DepError::DuplicateNome {
17594                    nome: nome.to_string(),
17595                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17596                },
17597            ),
17598            (
17599                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17600                DepError::DepIsSelf {
17601                    nome: nome.to_string(),
17602                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17603                },
17604            ),
17605            (
17606                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17607                DepError::DepIsSelf {
17608                    nome: nome.to_string(),
17609                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17610                },
17611            ),
17612        ];
17613        for (via_ctor, via_struct_literal) in cases {
17614            assert_eq!(
17615                via_ctor, via_struct_literal,
17616                "dep_nome_list_ctors!-generated ctor must route `nome` \
17617                 through `.to_string()` onto the canonical `nome` field \
17618                 and pass `list` verbatim onto the canonical `&'static str` \
17619                 `list` field — a field-rename, silent-conversion, or \
17620                 axis-swap regression surfaces here rather than at a \
17621                 downstream diagnostic-shape mismatch",
17622            );
17623        }
17624    }
17625
17626    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17627    //    value: String, reason: String }` four-slot envelope on
17628    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17629    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17630    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17631    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
17632    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
17633    //    envelope. Single-variant lift closing the last open-coded ctor
17634    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
17635
17636    #[test]
17637    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17638        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17639        // ctor: sweep both wire-up-shape arms (the refname-pin arm
17640        // routing `":tag"` / `":branch"` value through
17641        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17642        // routing `":rev"` through [`crate::render::is_git_oid`]) and
17643        // assert byte-equal `PartialEq` against the pre-lift
17644        // struct-literal, so any wrapper-side field-rename /
17645        // silent-conversion regression surfaces here rather than at a
17646        // downstream diagnostic-shape mismatch. Peer of the sibling
17647        // per-envelope byte-equal ctor pins
17648        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17649        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17650        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17651        assert_eq!(
17652            DepError::fonte_pin_shape(
17653                "caixa-teia",
17654                ":tag",
17655                "v0.1.0 ",
17656                "trailing whitespace".to_string(),
17657            ),
17658            DepError::FontePinShape {
17659                nome: "caixa-teia".to_string(),
17660                pin: ":tag".to_string(),
17661                value: "v0.1.0 ".to_string(),
17662                reason: "trailing whitespace".to_string(),
17663            },
17664            "fonte_pin_shape ctor must produce byte-equal \
17665             `DepError::FontePinShape` to the pre-lift struct-literal \
17666             wrap on a refname-pin (`:tag` / `:branch`) fixture",
17667        );
17668        assert_eq!(
17669            DepError::fonte_pin_shape(
17670                "caixa-teia",
17671                ":rev",
17672                "DEADBEEF",
17673                "abbreviated OID rejected".to_string(),
17674            ),
17675            DepError::FontePinShape {
17676                nome: "caixa-teia".to_string(),
17677                pin: ":rev".to_string(),
17678                value: "DEADBEEF".to_string(),
17679                reason: "abbreviated OID rejected".to_string(),
17680            },
17681            "fonte_pin_shape ctor must produce byte-equal \
17682             `DepError::FontePinShape` to the pre-lift struct-literal \
17683             wrap on a hex-OID-pin (`:rev`) fixture",
17684        );
17685    }
17686
17687    #[test]
17688    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17689        // Cross-axis routing pin: sweep every one of the four
17690        // constructor input axes (`nome: &str`, `pin: &str`,
17691        // `value: &str`, `reason: String`) through non-default
17692        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17693        // any wrapper-side lowercase / trim / truncate at codegen time
17694        // — or a silent field re-name / axis-swap on any one of the
17695        // four fields, or a `reason` axis silently routed through
17696        // `.to_string()` instead of forwarded owned — surfaces here
17697        // rather than at a downstream diagnostic-shape mismatch. Peer
17698        // of the sibling
17699        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17700        // (792aa92) and
17701        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17702        // pin (6f5e0cd) on the same envelope's one- and two-slot
17703        // families. Distinct-per-axis fixtures rule out any two-axis
17704        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17705        // etc.) that would still pass a same-fixture-per-axis pin.
17706        let nome = "sibling-teia";
17707        let pin = ":branch";
17708        let value = "feature/bar";
17709        let reason = "embedded space".to_string();
17710        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17711        let via_struct_literal = DepError::FontePinShape {
17712            nome: nome.to_string(),
17713            pin: pin.to_string(),
17714            value: value.to_string(),
17715            reason: reason.clone(),
17716        };
17717        assert_eq!(
17718            via_ctor, via_struct_literal,
17719            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17720             through `.to_string()` onto their canonical fields and \
17721             forward `reason` owned onto the canonical `reason` field \
17722             — a field-rename, silent-conversion, or axis-swap \
17723             regression surfaces here rather than at a downstream \
17724             diagnostic-shape mismatch",
17725        );
17726        let DepError::FontePinShape {
17727            nome: n,
17728            pin: p,
17729            value: v,
17730            reason: r,
17731        } = via_ctor
17732        else {
17733            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17734        };
17735        assert_eq!(n, nome);
17736        assert_eq!(p, pin);
17737        assert_eq!(v, value);
17738        assert_eq!(r, reason);
17739    }
17740
17741    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17742    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17743    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17744    //    the same envelope's `{ nome: String, caminho: String }` two-slot
17745    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17746    //    same envelope's `{ nome: String }` one-slot shape.
17747
17748    #[test]
17749    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17750        assert_eq!(
17751            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17752            DepError::FonteCaminhoControlChar {
17753                nome: "caixa-teia".to_string(),
17754                caminho: "../caixa-teia\x00foo".to_string(),
17755                byte: 0x00,
17756            },
17757        );
17758    }
17759
17760    #[test]
17761    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17762        assert_eq!(
17763            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17764            DepError::FonteCaminhoShellRedirection {
17765                nome: "caixa-teia".to_string(),
17766                caminho: "../caixa-teia>log".to_string(),
17767                byte: b'>',
17768            },
17769        );
17770    }
17771
17772    #[test]
17773    #[allow(
17774        clippy::too_many_lines,
17775        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17776                  byte-classification arm on the {nome,caminho,byte} envelope; \
17777                  the linear per-variant repetition is exactly what the sweep \
17778                  is pinning — a helper macro would hide the shape the fold is \
17779                  keying on"
17780    )]
17781    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17782        // Cross-axis routing pin: sweep the three constructor input axes
17783        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17784        // non-default fixture triple against every generated arm in the
17785        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17786        // lowercase / trim / truncate on the two `&str` axes — a silent
17787        // field swap between `nome` and `caminho`, or a silent
17788        // re-classification of the offending byte — surfaces here rather
17789        // than at a downstream diagnostic-shape mismatch. Peer of the
17790        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17791        // to_string` cross-axis routing pin on the same envelope's
17792        // two-slot family (f85f145) and of the sibling
17793        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17794        // same envelope's one-slot family (792aa92), extended here onto
17795        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17796        // envelope so every substrate-primitive ctor family in
17797        // caixa-core's `DepError` envelope guarantees each field routes
17798        // the caller's value verbatim through `.to_string()` (or byte-
17799        // identity for `byte: u8`) in declared field order.
17800        let nome = "sibling-teia";
17801        let caminho = "../workspace/sibling";
17802        let byte = 0x2A_u8;
17803        let cases: [(DepError, DepError); 12] = [
17804            (
17805                DepError::fonte_caminho_control_char(nome, caminho, byte),
17806                DepError::FonteCaminhoControlChar {
17807                    nome: nome.to_string(),
17808                    caminho: caminho.to_string(),
17809                    byte,
17810                },
17811            ),
17812            (
17813                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17814                DepError::FonteCaminhoShellRedirection {
17815                    nome: nome.to_string(),
17816                    caminho: caminho.to_string(),
17817                    byte,
17818                },
17819            ),
17820            (
17821                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17822                DepError::FonteCaminhoShellGlob {
17823                    nome: nome.to_string(),
17824                    caminho: caminho.to_string(),
17825                    byte,
17826                },
17827            ),
17828            (
17829                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17830                DepError::FonteCaminhoShellSubshellGrouping {
17831                    nome: nome.to_string(),
17832                    caminho: caminho.to_string(),
17833                    byte,
17834                },
17835            ),
17836            (
17837                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17838                DepError::FonteCaminhoShellBraceExpansion {
17839                    nome: nome.to_string(),
17840                    caminho: caminho.to_string(),
17841                    byte,
17842                },
17843            ),
17844            (
17845                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17846                DepError::FonteCaminhoShellBracketExpansion {
17847                    nome: nome.to_string(),
17848                    caminho: caminho.to_string(),
17849                    byte,
17850                },
17851            ),
17852            (
17853                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17854                DepError::FonteCaminhoShellQuoteGrouping {
17855                    nome: nome.to_string(),
17856                    caminho: caminho.to_string(),
17857                    byte,
17858                },
17859            ),
17860            (
17861                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17862                DepError::FonteCaminhoShellComment {
17863                    nome: nome.to_string(),
17864                    caminho: caminho.to_string(),
17865                    byte,
17866                },
17867            ),
17868            (
17869                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17870                DepError::FonteCaminhoUrlPercentEncoding {
17871                    nome: nome.to_string(),
17872                    caminho: caminho.to_string(),
17873                    byte,
17874                },
17875            ),
17876            (
17877                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17878                DepError::FonteCaminhoShellVariableExpansion {
17879                    nome: nome.to_string(),
17880                    caminho: caminho.to_string(),
17881                    byte,
17882                },
17883            ),
17884            (
17885                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17886                DepError::FonteCaminhoShellHistoryExpansion {
17887                    nome: nome.to_string(),
17888                    caminho: caminho.to_string(),
17889                    byte,
17890                },
17891            ),
17892            (
17893                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17894                DepError::FonteCaminhoShellHistorySubstitution {
17895                    nome: nome.to_string(),
17896                    caminho: caminho.to_string(),
17897                    byte,
17898                },
17899            ),
17900        ];
17901        for (via_ctor, via_struct_literal) in cases {
17902            assert_eq!(
17903                via_ctor, via_struct_literal,
17904                "fonte_caminho_byte_ctors!-generated ctor must route \
17905                 (nome, caminho, byte) through `.to_string()` / byte-\
17906                 identity in declared field order — a field-swap or \
17907                 silent-conversion regression surfaces here rather than \
17908                 at a downstream diagnostic-shape mismatch",
17909            );
17910        }
17911    }
17912
17913    #[test]
17914    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17915        // Fail-before-pass-after byte-parity pin on the lifted
17916        // `impl AsRef<str> for DepList` — asserts the standard-
17917        // library trait impl and the substrate-primitive
17918        // [`super::DepList::as_str`] `pub const fn` accessor resolve
17919        // to the same `&str` per instance across the two-arm closed
17920        // set, so any future silent detour that routes the impl
17921        // through a divergent projection (a per-arm inline
17922        // `match self { DepList::Prod => ":deps", … }` re-inlining
17923        // that opens a compile-time link to the un-lifted arm-literal,
17924        // a swap onto a second projection axis) trips at caixa-core
17925        // test time under `PartialEq` rather than at a downstream
17926        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17927        // every one of the two arms [`super::DepList::ALL`] carries
17928        // so no arm's projection is covered only by the sibling
17929        // `Display` path. Peer of the sibling
17930        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17931        // (1723611) on the top-level dialect-classification closed-
17932        // set typed enum, and the peer
17933        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17934        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17935        // typed enum — the pins together close the substrate
17936        // primitive's `AsRef<str>` projection axis onto the seventh
17937        // (and last unlifted) closed-set typed enum on the caixa
17938        // surface.
17939        for &list in super::DepList::ALL {
17940            assert_eq!(
17941                <super::DepList as AsRef<str>>::as_ref(&list),
17942                list.as_str(),
17943                "AsRef<str> impl on DepList::{list:?} must byte-equal \
17944                 DepList::as_str on the same instance — divergence \
17945                 signals a silent detour off the substrate-primitive \
17946                 accessor"
17947            );
17948        }
17949    }
17950
17951    #[test]
17952    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17953        // Fail-before-pass-after byte-parity pin on the three-path
17954        // convergence discipline the [`super::DepList`] two-list
17955        // dep-graph closed-set typed enum now carries on the `&str`-
17956        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17957        // newly lifted impl), `format!("{v}")` (the pre-existing
17958        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17959        // primitive `pub const fn` accessor both trait impls delegate
17960        // through) must resolve to the same byte-string on every
17961        // instance across the two-arm closed set. Refuses any future
17962        // divergence between the two trait impls (a stray
17963        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17964        // rather than delegating through the shared accessor; a
17965        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17966        // literal cascade) that would silently split the two
17967        // projection paths of the same closed-set typed enum. Mirrors
17968        // the sibling three-path-convergence discipline the peer
17969        // [`crate::CaixaDialeto`] typed enum carries
17970        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17971        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17972        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17973        // d8136db), the peer [`crate::CaixaKind`] triple
17974        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17975        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17976        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17977        // 16d5c7e).
17978        for &list in super::DepList::ALL {
17979            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17980            let via_display: String = format!("{list}");
17981            let via_accessor: &str = list.as_str();
17982            assert_eq!(via_as_ref, via_accessor);
17983            assert_eq!(via_display, via_accessor);
17984            assert_eq!(via_as_ref, via_display.as_str());
17985        }
17986    }
17987
17988    #[test]
17989    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
17990        // Fail-before-pass-after byte-parity pin on the newly lifted
17991        // `impl TryFrom<&str> for DepList` — asserts the standard-
17992        // library trait impl and the substrate-primitive
17993        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
17994        // to the same two-arm accept-set across every arm the
17995        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
17996        // the sibling
17997        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
17998        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
17999        // and the 12 other substrate-wide trait-idiomatic reverse-
18000        // projection routes-through pins — closes the campaign's
18001        // completeness gap on the two-list dep-graph closed-set enum.
18002        for &list in super::DepList::ALL {
18003            let wire = list.as_str();
18004            assert_eq!(
18005                <super::DepList as TryFrom<&str>>::try_from(wire),
18006                Ok(list),
18007                "TryFrom<&str> impl on DepList must round-trip \
18008                 DepList::{list:?}.as_str() = {wire:?} back to \
18009                 Ok(DepList::{list:?}) — divergence from \
18010                 DepList::from_wire signals a silent detour off the \
18011                 substrate-primitive accessor"
18012            );
18013            assert_eq!(
18014                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18015                super::DepList::from_wire(wire),
18016                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18017                 DepList::from_wire on the same input"
18018            );
18019        }
18020    }
18021
18022    #[test]
18023    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18024        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18025        // sweeps candidate byte-strings outside the two-arm accept-set
18026        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18027        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18028        // future accidental widening of the trait impl's accept-set (a
18029        // stray case-fold path, a silent inclusion of a rebrand alias
18030        // like `":packages"`, an English rebrand `":dev-deps"` in
18031        // reverse arm-order that would silently swap the two arms) trips
18032        // at caixa-core test time. Peer of the sibling
18033        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18034        // (5b828ed) rejection witness.
18035        let rejected: &[&str] = &[
18036            "",
18037            " ",
18038            "\t",
18039            "\n",
18040            ":deps ",
18041            " :deps",
18042            ":DEPS",
18043            ":Deps",
18044            ":Deps-Dev",
18045            ":deps_dev",
18046            ":deps-development",
18047            ":dev-deps",
18048            ":packages",
18049            ":packages-dev",
18050            "deps",
18051            "deps-dev",
18052            "Prod",
18053            "Dev",
18054            "prod",
18055            "dev",
18056            "\":deps\"",
18057            "\":deps-dev\"",
18058            ":deps\n",
18059            ":deps-dev\n",
18060        ];
18061        for &input in rejected {
18062            assert_eq!(
18063                <super::DepList as TryFrom<&str>>::try_from(input),
18064                Err(()),
18065                "TryFrom<&str> impl on DepList must reject unknown \
18066                 byte-string {input:?} — divergence from \
18067                 DepList::from_wire on the same input signals a silent \
18068                 accept-set widening past the two lifted \
18069                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18070            );
18071            assert_eq!(
18072                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18073                super::DepList::from_wire(input),
18074                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18075                 DepList::from_wire on the same input — divergence signals \
18076                 the two reverse-projection paths have drifted onto \
18077                 different accept-sets"
18078            );
18079        }
18080    }
18081
18082    #[test]
18083    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18084        // Fail-before-pass-after byte-parity pin on the newly lifted
18085        // `impl From<DepList> for &'static str` — asserts the standard-
18086        // library trait impl and the substrate-primitive
18087        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18088        // the same two-arm emit-set across every arm the exhaustive
18089        // [`super::DepList::ALL`] slice enumerates. Materializes the
18090        // `<&'static str as From<DepList>>::from` output in a
18091        // `const`-shape binding to make the `'static` lifetime promise
18092        // a build-time invariant — a future accidental downgrade of
18093        // either arm to a non-`&'static str` (a `String::leak()`-
18094        // produced return, a `Box::leak`-cast) trips at caixa-core
18095        // build time rather than at a downstream `'static`-bound
18096        // consumer. Peer of the sibling
18097        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18098        // (523157d) and the 13 other substrate-wide forward-projection
18099        // routes-through pins.
18100        const PROD: &str = super::DepList::Prod.as_str();
18101        const DEV: &str = super::DepList::Dev.as_str();
18102        for &list in super::DepList::ALL {
18103            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18104            let via_method: &'static str = list.as_str();
18105            assert_eq!(
18106                via_trait, via_method,
18107                "From<DepList> for &'static str impl must round-trip \
18108                 DepList::{list:?} to the same lifted \
18109                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18110                 DepList::as_str returns — divergence signals a silent \
18111                 detour off the substrate-primitive accessor"
18112            );
18113            let via_into: &'static str = list.into();
18114            assert_eq!(
18115                via_into, via_method,
18116                "Into<&'static str>::into on DepList::{list:?} must \
18117                 byte-equal DepList::as_str on the same input — the \
18118                 blanket-derived Into shape must resolve to the same \
18119                 as_str dispatch as the explicit From impl"
18120            );
18121        }
18122        assert_eq!(
18123            [PROD, DEV],
18124            [
18125                crate::render::DEP_AUTHOR_KEY_DEPS,
18126                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18127            ],
18128            "const-context DepList::as_str must resolve to the two lifted \
18129             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18130             of either arm to a non-const or non-static byte-string breaks \
18131             the `&'static str`-lifetime promise the paired \
18132             From<DepList> for &'static str impl carries by construction"
18133        );
18134    }
18135
18136    #[test]
18137    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18138        // Cross-axis partition pin: the paired trait-idiomatic
18139        // `From<DepList> for &'static str` forward projection and the
18140        // method-named [`super::DepList::as_str`] forward projection
18141        // must resolve identically on every arm, locking the two paths
18142        // together so any future detour trips at caixa-core test time.
18143        // Then a round-trip witness: every arm's forward `From` output
18144        // re-parses through the paired trait-idiomatic reverse
18145        // `TryFrom<&str>` back to the original variant, closing the
18146        // two-way `DepList ↔ &'static str` round-trip on the trait-
18147        // idiomatic axis pair, mirroring the pre-existing method-named
18148        // `as_str` + `from_wire` round-trip. Peer of the sibling
18149        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18150        // (523157d).
18151        for &list in super::DepList::ALL {
18152            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18153            let via_method: &'static str = list.as_str();
18154            assert_eq!(
18155                via_trait, via_method,
18156                "From<DepList> for &'static str and DepList::as_str must \
18157                 resolve identically on DepList::{list:?} — divergence \
18158                 signals the two forward-projection paths have drifted \
18159                 onto different emit-sets"
18160            );
18161        }
18162        for &list in super::DepList::ALL {
18163            let emitted: &'static str = list.into();
18164            let re_parsed: Result<super::DepList, ()> =
18165                <super::DepList as TryFrom<&str>>::try_from(emitted);
18166            assert_eq!(
18167                re_parsed,
18168                Ok(list),
18169                "trait-idiomatic axis pair must round-trip \
18170                 DepList::{list:?} through `.into::<&'static str>()` and \
18171                 back through `TryFrom<&str>` — a break signals the \
18172                 forward-emit and reverse-parse axes have drifted onto \
18173                 different vocabularies"
18174            );
18175        }
18176    }
18177
18178    #[test]
18179    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18180        // Fail-before-pass-after byte-parity pin on the newly lifted
18181        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18182        // input standard-library trait impl and the substrate-primitive
18183        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18184        // the same two-arm emit-set across every arm the exhaustive
18185        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18186        // does not auto-derive the borrowed-input sibling from a paired
18187        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18188        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18189        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18190        // shape over [`super::DepList::ALL`] (whose iterator yields
18191        // `&DepList`, not `DepList`) reaches through this impl and no
18192        // other — the paired owned-input [`From<DepList>`] impl requires
18193        // an explicit `.copied()` / dereference before the trait fires.
18194        // Materializes the `<&'static str as From<&DepList>>::from`
18195        // output in a `const`-shape binding to make the `'static`
18196        // lifetime promise a build-time invariant.
18197        const PROD: &str = super::DepList::Prod.as_str();
18198        const DEV: &str = super::DepList::Dev.as_str();
18199        for list in super::DepList::ALL {
18200            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18201            let via_method: &'static str = list.as_str();
18202            assert_eq!(
18203                via_trait, via_method,
18204                "From<&DepList> for &'static str impl must round-trip \
18205                 &DepList::{list:?} to the same lifted \
18206                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18207                 DepList::as_str returns — divergence signals a silent \
18208                 detour off the substrate-primitive accessor"
18209            );
18210            let via_into: &'static str = list.into();
18211            assert_eq!(
18212                via_into, via_method,
18213                "Into<&'static str>::into on &DepList::{list:?} must \
18214                 byte-equal DepList::as_str on the same input — the \
18215                 blanket-derived Into shape must resolve to the same \
18216                 as_str dispatch as the explicit From impl"
18217            );
18218        }
18219        assert_eq!(
18220            [PROD, DEV],
18221            [
18222                crate::render::DEP_AUTHOR_KEY_DEPS,
18223                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18224            ],
18225            "const-context DepList::as_str must resolve to the two lifted \
18226             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18227             From<&DepList> for &'static str impl inherits its `'static` \
18228             lifetime promise from the same accessor the owned-input \
18229             sibling routes through"
18230        );
18231    }
18232
18233    #[test]
18234    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18235        // Cross-axis partition pin: the paired trait-idiomatic
18236        // owned-input `From<DepList> for &'static str` (523157d
18237        // campaign-shape) and borrowed-input `From<&DepList> for
18238        // &'static str` (this lift) forward projections must resolve
18239        // identically on every arm, locking the two input-shape paths
18240        // together so any future detour trips at caixa-core test time.
18241        // Then a witness that a `.iter().map(Into::into)` pipe over
18242        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18243        // materializes the two-arm accept-set through the borrowed-
18244        // input axis alone — the exact shape a future M4 admission-
18245        // webhook rejection body composer, a future substrate-wide
18246        // per-arm diagnostic column, or a
18247        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18248        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18249        // through — closing the two-way owned/borrowed input-shape
18250        // symmetry on the forward-projection trait-idiomatic axis.
18251        for &list in super::DepList::ALL {
18252            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18253            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18254            assert_eq!(
18255                owned, borrowed,
18256                "From<DepList> and From<&DepList> for &'static str must \
18257                 resolve identically on DepList::{list:?} — divergence \
18258                 signals the owned-input and borrowed-input forward-\
18259                 projection paths have drifted onto different emit-sets"
18260            );
18261        }
18262        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18263        let via_method: Vec<&'static str> =
18264            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18265        assert_eq!(
18266            via_iter, via_method,
18267            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18268             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18269             input `From<&DepList> for &'static str` axis is what makes \
18270             the `.iter().map(Into::into)` shape route through the \
18271             substrate-primitive `DepList::as_str` accessor rather than \
18272             through a per-call-site `.copied()` / dereference detour"
18273        );
18274    }
18275
18276    #[test]
18277    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18278        // Fail-before-pass-after byte-parity pin on the newly lifted
18279        // `impl From<DepList> for String` — asserts the owned-`String`
18280        // -returning standard-library trait impl and the substrate-
18281        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18282        // resolve to the same two-arm emit-set across every arm the
18283        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18284        // standard library does not carry a blanket
18285        // `impl<T: AsRef<str>> From<T> for String` (nor an
18286        // `impl<T: fmt::Display> From<T> for String`), so the
18287        // owned-`String` forward-projection axis is a distinct trait-
18288        // idiomatic surface that a `let key: String = list.into();`-
18289        // shaped call site reaches through this impl and no other — the
18290        // paired sibling `From<DepList> for &'static str` impl forces
18291        // every owned-`String` call site through an explicit
18292        // `.to_owned()` / `String::from` restatement. Peer of the
18293        // first-mover
18294        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18295        // (7baa18a), the second-peer
18296        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18297        // (7851725), the third-peer
18298        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18299        // (231a18c), and the fourth-peer
18300        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18301        // (88942cd) — extends the trait-idiomatic owned-`String`
18302        // forward-projection axis onto the fifth closed-set fieldless
18303        // typed enum on the caixa surface (the two-list dep-graph axis).
18304        for &variant in super::DepList::ALL {
18305            let via_trait: String = <String as From<super::DepList>>::from(variant);
18306            let via_method: &'static str = variant.as_str();
18307            assert_eq!(
18308                via_trait.as_str(),
18309                via_method,
18310                "From<DepList> for String impl must round-trip \
18311                 DepList::{variant:?} to the same lifted \
18312                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18313                 DepList::as_str returns — divergence signals a silent \
18314                 detour off the substrate-primitive accessor"
18315            );
18316            let via_into: String = variant.into();
18317            assert_eq!(
18318                via_into.as_str(),
18319                via_method,
18320                "Into<String>::into on DepList::{variant:?} must \
18321                 byte-equal DepList::as_str on the same input — the \
18322                 blanket-derived Into shape must resolve to the same \
18323                 as_str dispatch as the explicit From impl"
18324            );
18325        }
18326    }
18327
18328    #[test]
18329    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18330        // Cross-axis partition pin: the paired trait-idiomatic
18331        // owned-`String` `From<DepList> for String` (this lift) and
18332        // owned-`&'static str` `From<DepList> for &'static str`
18333        // (523157d campaign-shape) forward projections must resolve
18334        // identically on every arm, locking the two return-type-shape
18335        // paths together so any future detour trips at caixa-core test
18336        // time. Also byte-parity witness against the sibling
18337        // [`ToString::to_string`] surface routed through
18338        // [`std::fmt::Display`] — the three owned-heap-string paths
18339        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18340        // resolve identically on every arm so a future consumer that
18341        // picks any of the three lands on the same two-arm lifted
18342        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18343        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18344        // Then a `.iter().copied().map(String::from)` pipe witness
18345        // over [`super::DepList::ALL`] that materializes the two-arm
18346        // accept-set through the owned-`String` axis alone — the exact
18347        // shape a future M4 admission-webhook rejection body composer
18348        // or a
18349        // `HashMap::<String, DepList>::from_iter(
18350        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18351        // style owned-key per-list lookup reaches through — closing the
18352        // owned-`String` forward-projection axis's iterator-pipe shape.
18353        // Then a direct round-trip witness through the paired
18354        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18355        // owned-`String`'s [`String::as_str`] borrow that closes the
18356        // two-way `Self → String → Self` round-trip on the trait-
18357        // idiomatic owned-`String` forward + reverse axis pair.
18358        //
18359        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18360        // `From` emit lands on the lowercase Portuguese `as_str`
18361        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18362        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18363        // forcing the round-trip through an intermediate
18364        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18365        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18366        // parse resolve through the same lifted
18367        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18368        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18369        // construction (there is no wire/diagnostic axis split on this
18370        // enum), so the owned-`String` forward axis and the reverse
18371        // axis compose directly — matching the peer
18372        // [`crate::supervisor::RestartStrategy`] /
18373        // [`crate::supervisor::RestartPolicy`] /
18374        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18375        for &list in super::DepList::ALL {
18376            let owned_string: String = <String as From<super::DepList>>::from(list);
18377            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18378            assert_eq!(
18379                owned_string.as_str(),
18380                owned_static,
18381                "From<DepList> for String and From<DepList> for \
18382                 &'static str must resolve identically on \
18383                 DepList::{list:?} — divergence signals the owned-\
18384                 `String` and owned-`&'static str` forward-projection \
18385                 return-type-shape paths have drifted onto different \
18386                 emit-sets"
18387            );
18388            let via_to_string: String = list.to_string();
18389            assert_eq!(
18390                owned_string, via_to_string,
18391                "From<DepList> for String must byte-equal \
18392                 DepList::to_string on DepList::{list:?} — divergence \
18393                 signals the trait-idiomatic owned-`String` forward-\
18394                 projection axis and the ToString-through-Display axis \
18395                 have drifted onto different emit-sets"
18396            );
18397        }
18398        let via_iter: Vec<String> = super::DepList::ALL
18399            .iter()
18400            .copied()
18401            .map(String::from)
18402            .collect();
18403        let via_method: Vec<String> = super::DepList::ALL
18404            .iter()
18405            .map(|l| l.as_str().to_owned())
18406            .collect();
18407        assert_eq!(
18408            via_iter, via_method,
18409            "`.iter().copied().map(String::from)` over DepList::ALL must \
18410             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18411             every arm — the owned-`String` `From<DepList> for String` \
18412             axis is what makes the `String::from` composition route \
18413             through the substrate-primitive `DepList::as_str` accessor \
18414             rather than through a per-call-site `.to_owned()` / \
18415             `String::from(list.as_str())` detour"
18416        );
18417        for &variant in super::DepList::ALL {
18418            let emitted: String = variant.into();
18419            let re_parsed: Result<super::DepList, ()> =
18420                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18421            assert_eq!(
18422                re_parsed,
18423                Ok(variant),
18424                "trait-idiomatic owned-`String` forward-projection + \
18425                 reverse-projection axis pair must round-trip \
18426                 DepList::{variant:?} through `.into::<String>()` and \
18427                 back through `TryFrom<&str>` on the owned-`String`'s \
18428                 String::as_str borrow — a break signals the owned-\
18429                 `String` forward-emit and reverse-parse axes have \
18430                 drifted onto different vocabularies (unlike the peer \
18431                 CaixaKind axis pair, DepList's forward emit and \
18432                 reverse parse share the same lifted \
18433                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18434                 round-trip composes directly)"
18435            );
18436        }
18437    }
18438
18439    #[test]
18440    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18441        // Fail-before-pass-after byte-parity pin on the newly lifted
18442        // `impl From<&DepList> for String` — asserts the borrowed-input
18443        // owned-`String`-returning standard-library trait impl and the
18444        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18445        // accessor resolve to the same two-arm emit-set across every
18446        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18447        // Rust's standard library does not carry a blanket
18448        // `impl<T: AsRef<str>> From<&T> for String` (nor an
18449        // `impl<T: fmt::Display> From<&T> for String`), so the
18450        // borrowed-input owned-`String` forward-projection axis is a
18451        // distinct trait-idiomatic surface that a
18452        // `let key: String = (&list).into();`-shaped call site reaches
18453        // through this impl and no other — the paired sibling
18454        // `From<DepList> for String` impl forces every borrowed-input
18455        // call site through an explicit `Copy` deref
18456        // (`String::from(*list)`) or an `.as_str().to_owned()` /
18457        // `.to_string()` detour. Peer of the first-mover
18458        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18459        // (579385f) and the second-peer
18460        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18461        // (8465740) — extends the trait-idiomatic borrowed-input owned-
18462        // `String` forward-projection axis off the M2 OTP-shape sibling
18463        // axis pair onto the first non-M2 closed-set fieldless typed
18464        // enum peer (the two-list dep-graph axis).
18465        for &variant in super::DepList::ALL {
18466            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18467            let via_method: &'static str = variant.as_str();
18468            assert_eq!(
18469                via_trait.as_str(),
18470                via_method,
18471                "From<&DepList> for String impl must round-trip \
18472                 &DepList::{variant:?} to the same lifted \
18473                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18474                 DepList::as_str returns — divergence signals a silent \
18475                 detour off the substrate-primitive accessor"
18476            );
18477            let via_into: String = (&variant).into();
18478            assert_eq!(
18479                via_into.as_str(),
18480                via_method,
18481                "Into<String>::into on &DepList::{variant:?} must \
18482                 byte-equal DepList::as_str on the same input — the \
18483                 blanket-derived Into shape must resolve to the same \
18484                 as_str dispatch as the explicit From impl"
18485            );
18486        }
18487    }
18488
18489    #[test]
18490    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18491        // Cross-axis partition pin: the newly lifted trait-idiomatic
18492        // borrowed-input owned-`String` `From<&DepList> for String`
18493        // (this lift), the paired owned-input owned-`String`
18494        // `From<DepList> for String` (32b0ee8), the paired borrowed-
18495        // input owned-`&'static str` `From<&DepList> for &'static str`
18496        // (64aa742), and the paired owned-input owned-`&'static str`
18497        // `From<DepList> for &'static str` (3455cbf) — every corner of
18498        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18499        // idiomatic projection family — must resolve identically on
18500        // every arm, locking the four return-shape × input-shape paths
18501        // together so any future detour trips at caixa-core test time.
18502        // Also byte-parity witness against the sibling
18503        // [`ToString::to_string`] surface routed through
18504        // [`std::fmt::Display`] and a direct round-trip witness through
18505        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18506        // the owned-`String`'s [`String::as_str`] borrow that closes
18507        // the two-way `&Self → String → Self` round-trip on the trait-
18508        // idiomatic borrowed-input owned-`String` forward + reverse
18509        // axis pair. Peer of the first-mover
18510        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18511        // (579385f) and the second-peer
18512        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18513        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18514        // String}` 2×2 projection corner on the third substrate-wide
18515        // closed-set fieldless typed enum peer (the two-list dep-graph
18516        // axis, first outside the M2 OTP-shape sibling pair).
18517        //
18518        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18519        // `From` emit lands on the lowercase Portuguese `as_str`
18520        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18521        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18522        // forcing the round-trip through an intermediate
18523        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18524        // [`super::DepList::as_str`] emit and
18525        // [`super::DepList::from_wire`] parse resolve through the same
18526        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18527        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18528        // construction (there is no wire/diagnostic axis split on this
18529        // enum), so the borrowed-input owned-`String` forward axis and
18530        // the reverse axis compose directly — matching the peer
18531        // [`crate::supervisor::RestartStrategy`] /
18532        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18533        // `String` axis pairs.
18534        for &list in super::DepList::ALL {
18535            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18536            let owned_string: String = <String as From<super::DepList>>::from(list);
18537            let borrowed_static: &'static str =
18538                <&'static str as From<&super::DepList>>::from(&list);
18539            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18540            assert_eq!(
18541                borrowed_string, owned_string,
18542                "From<&DepList> for String and From<DepList> for String \
18543                 must resolve identically on DepList::{list:?} — \
18544                 divergence signals the borrowed-input and owned-input \
18545                 owned-`String` forward-projection input-shape paths \
18546                 have drifted onto different emit-sets"
18547            );
18548            assert_eq!(
18549                borrowed_string.as_str(),
18550                borrowed_static,
18551                "From<&DepList> for String and From<&DepList> for \
18552                 &'static str must resolve identically on \
18553                 DepList::{list:?} — divergence signals the borrowed-\
18554                 input `&'static str` and owned-`String` return-shape \
18555                 paths have drifted onto different emit-sets"
18556            );
18557            assert_eq!(
18558                borrowed_string.as_str(),
18559                owned_static,
18560                "From<&DepList> for String and From<DepList> for \
18561                 &'static str must resolve identically on \
18562                 DepList::{list:?} — divergence signals a break in the \
18563                 diagonal corner of the {{Self, &Self}} × {{&'static \
18564                 str, String}} 2×2 trait-idiomatic projection family"
18565            );
18566            let via_to_string: String = list.to_string();
18567            assert_eq!(
18568                borrowed_string, via_to_string,
18569                "From<&DepList> for String must byte-equal \
18570                 DepList::to_string on DepList::{list:?} — divergence \
18571                 signals the trait-idiomatic borrowed-input owned-\
18572                 `String` forward-projection axis and the ToString-\
18573                 through-Display axis have drifted onto different \
18574                 emit-sets"
18575            );
18576        }
18577        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18578        let via_method: Vec<String> = super::DepList::ALL
18579            .iter()
18580            .map(|l| l.as_str().to_owned())
18581            .collect();
18582        assert_eq!(
18583            via_iter, via_method,
18584            "`.iter().map(String::from)` over DepList::ALL — a call \
18585             site whose iteration axis holds `&DepList` by construction \
18586             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18587             on every arm — the borrowed-input owned-`String` \
18588             `From<&DepList> for String` axis is what makes the \
18589             `String::from` composition route through the substrate-\
18590             primitive `DepList::as_str` accessor without a spurious \
18591             `Copy` deref (which would only be reachable through the \
18592             owned-input `From<DepList> for String` axis by first \
18593             calling `.copied()` on the iterator)"
18594        );
18595        for &variant in super::DepList::ALL {
18596            let emitted: String = (&variant).into();
18597            let re_parsed: Result<super::DepList, ()> =
18598                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18599            assert_eq!(
18600                re_parsed,
18601                Ok(variant),
18602                "trait-idiomatic borrowed-input owned-`String` \
18603                 forward-projection + reverse-projection axis pair must \
18604                 round-trip &DepList::{variant:?} through \
18605                 `.into::<String>()` on the borrowed-input surface and \
18606                 back through `TryFrom<&str>` on the owned-`String`'s \
18607                 String::as_str borrow — a break signals the \
18608                 borrowed-input owned-`String` forward-emit and \
18609                 reverse-parse axes have drifted onto different \
18610                 vocabularies (unlike the peer CaixaKind axis pair, \
18611                 DepList's forward emit and reverse parse share the \
18612                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18613                 construction, so the round-trip composes directly)"
18614            );
18615        }
18616    }
18617
18618    #[test]
18619    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
18620        // Fail-before-pass-after byte-parity pin on the newly lifted
18621        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
18622        // asserts the standard-library trait impl and the substrate-
18623        // primitive [`super::DepList::as_str`] `pub const fn`
18624        // accessor resolve to the same two-arm emit-set across every
18625        // arm the exhaustive [`super::DepList::ALL`] slice
18626        // enumerates. Rust's standard library does not carry a
18627        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
18628        // (nor an `impl<T: fmt::Display> From<T> for
18629        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
18630        // projection axis is a distinct trait-idiomatic surface that
18631        // a `let key: Cow<'static, str> = list.into();`-shaped call
18632        // site reaches through this impl and no other — the paired
18633        // sibling `From<DepList> for &'static str` and
18634        // `From<DepList> for String` impls force every
18635        // `Cow<'static, str>`-parameterized call site through a
18636        // `Cow::Borrowed(list.as_str())` /
18637        // `Cow::Owned(list.to_string())` composition whose type
18638        // bounds have no compile-time link back to the substrate
18639        // primitive.
18640        //
18641        // Also asserts the projection lands on the zero-alloc
18642        // [`std::borrow::Cow::Borrowed`] arm (not the
18643        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18644        // [`super::DepList::as_str`] accessor's `&'static str`
18645        // return lifetime by construction (each match arm resolves
18646        // to one of the two lifted
18647        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18648        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
18649        // &str` values) makes the borrowed arm the type-correct
18650        // projection with no runtime allocation. Any future silent
18651        // detour that routes the impl through the owned arm trips
18652        // at caixa-core test time under the
18653        // [`std::borrow::Cow::Borrowed`] discriminator witness
18654        // rather than at a downstream `Cow<'static, str>`-bound
18655        // consumer's silent allocation.
18656        //
18657        // First-mover on the outside-M3 substrate-wide tier of the
18658        // substrate-wide trait-idiomatic
18659        // [`std::borrow::Cow<'static, str>`] forward-projection
18660        // campaign — extends the axis off the paired
18661        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
18662        // the paired M2 OTP-shape
18663        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
18664        // and [`crate::supervisor::RestartPolicy`] (0612398 +
18665        // ee577fd), and the paired M3-mesh-shape
18666        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
18667        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
18668        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
18669        // peers onto the first outside-M3 caixa-core peer (the two-
18670        // list dep-graph axis), opening the outside-M3 caixa-core
18671        // tier of the substrate-wide Cow<'static, str> forward-
18672        // projection campaign's owned-input corner.
18673        for &variant in super::DepList::ALL {
18674            let via_trait: std::borrow::Cow<'static, str> =
18675                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18676            let via_method: &'static str = variant.as_str();
18677            assert_eq!(
18678                via_trait.as_ref(),
18679                via_method,
18680                "From<DepList> for Cow<'static, str> impl must \
18681                 round-trip DepList::{variant:?} to the same lifted \
18682                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18683                 DepList::as_str returns — divergence signals a \
18684                 silent detour off the substrate-primitive accessor"
18685            );
18686            assert!(
18687                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
18688                "From<DepList> for Cow<'static, str> impl must land \
18689                 on the zero-alloc Cow::Borrowed arm on \
18690                 DepList::{variant:?} — a Cow::Owned outcome signals \
18691                 the projection has silently allocated where the \
18692                 substrate-primitive DepList::as_str `&'static str` \
18693                 return makes the borrowed arm the type-correct \
18694                 projection"
18695            );
18696            let via_into: std::borrow::Cow<'static, str> = variant.into();
18697            assert_eq!(
18698                via_into.as_ref(),
18699                via_method,
18700                "Into<Cow<'static, str>>::into on DepList::\
18701                 {variant:?} must byte-equal DepList::as_str on the \
18702                 same input — the blanket-derived Into shape must \
18703                 resolve to the same as_str dispatch as the explicit \
18704                 From impl"
18705            );
18706            assert!(
18707                matches!(via_into, std::borrow::Cow::Borrowed(_)),
18708                "Into<Cow<'static, str>>::into on DepList::\
18709                 {variant:?} must land on the zero-alloc \
18710                 Cow::Borrowed arm — the blanket-derived Into shape \
18711                 must resolve to the same Cow::Borrowed dispatch as \
18712                 the explicit From impl"
18713            );
18714        }
18715    }
18716
18717    #[test]
18718    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
18719        // Cross-axis partition pin: the newly lifted trait-idiomatic
18720        // `From<DepList> for std::borrow::Cow<'static, str>` (this
18721        // lift), the paired owned-input `From<DepList> for
18722        // &'static str` (3455cbf), and the paired owned-input
18723        // `From<DepList> for String` (32b0ee8) forward projections
18724        // must resolve identically on every arm, locking the three
18725        // return-shape paths together by construction so any future
18726        // detour trips at caixa-core test time. Also byte-parity
18727        // witness against the sibling [`ToString::to_string`]
18728        // surface routed through [`std::fmt::Display`] — every
18729        // owned-heap-string path (the `Cow::Owned` promotion of
18730        // this axis's `.into_owned()`, `From<DepList> for String`,
18731        // and `.to_string()`) resolves to the same two-arm lifted
18732        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18733        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
18734        // arm.
18735        //
18736        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
18737        // witness over [`super::DepList::ALL`] that materializes the
18738        // two-arm accept-set through the
18739        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
18740        // shape a future M4 admission-webhook rejection body's
18741        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
18742        // future substrate-wide per-arm diagnostic surface whose
18743        // typing rules out the sibling [`AsRef<str>`] borrowed
18744        // return, or a future per-arm dep-list emitter that binds
18745        // through a [`std::borrow::Cow<'static, str>`] boundary
18746        // reaches through — opening the composable-projection axis
18747        // on the first outside-M3 caixa-core closed-set fieldless
18748        // typed enum peer on the caixa surface. The pipe witness
18749        // also pins the zero-alloc discipline: every element in the
18750        // collected vector satisfies the
18751        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
18752        // accidental silent-allocation regression on the pipe's
18753        // iteration axis is a caixa-core-test-time failure.
18754        for &variant in super::DepList::ALL {
18755            let via_cow: std::borrow::Cow<'static, str> =
18756                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18757            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
18758            let via_string: String = <String as From<super::DepList>>::from(variant);
18759            assert_eq!(
18760                via_cow.as_ref(),
18761                via_static,
18762                "From<DepList> for Cow<'static, str> and \
18763                 From<DepList> for &'static str must resolve \
18764                 identically on DepList::{variant:?} — divergence \
18765                 signals the Cow<'static, str> and &'static str \
18766                 return-shape paths have drifted onto different \
18767                 emit-sets"
18768            );
18769            assert_eq!(
18770                via_cow.as_ref(),
18771                via_string.as_str(),
18772                "From<DepList> for Cow<'static, str> and \
18773                 From<DepList> for String must resolve identically \
18774                 on DepList::{variant:?} — divergence signals the \
18775                 Cow<'static, str> and String return-shape paths \
18776                 have drifted onto different emit-sets"
18777            );
18778            let via_to_string: String = variant.to_string();
18779            assert_eq!(
18780                via_cow.as_ref(),
18781                via_to_string.as_str(),
18782                "From<DepList> for Cow<'static, str> must byte-equal \
18783                 DepList::to_string on DepList::{variant:?} — \
18784                 divergence signals the trait-idiomatic \
18785                 Cow<'static, str> forward-projection axis and the \
18786                 ToString-through-Display axis have drifted onto \
18787                 different emit-sets"
18788            );
18789        }
18790        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18791            .iter()
18792            .copied()
18793            .map(std::borrow::Cow::from)
18794            .collect();
18795        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18796            .iter()
18797            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
18798            .collect();
18799        assert_eq!(
18800            via_iter, via_method,
18801            "`.iter().copied().map(Cow::from)` over DepList::ALL \
18802             must byte-equal `.iter().map(|l| \
18803             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
18804             idiomatic `From<DepList> for Cow<'static, str>` axis is \
18805             what makes the `Cow::from` composition route through \
18806             the substrate-primitive `DepList::as_str` accessor with \
18807             the zero-alloc Cow::Borrowed arm by construction, \
18808             rather than a per-call-site `Cow::Owned(list.to_string())` \
18809             allocation"
18810        );
18811        for cow in &via_iter {
18812            assert!(
18813                matches!(cow, std::borrow::Cow::Borrowed(_)),
18814                "every element of the .iter().copied().map(Cow::from) \
18815                 pipe over DepList::ALL must land on the zero-alloc \
18816                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
18817                 signals the pipe's iteration axis has silently \
18818                 allocated where the substrate-primitive \
18819                 DepList::as_str `&'static str` return makes the \
18820                 borrowed arm the type-correct projection"
18821            );
18822        }
18823    }
18824
18825    #[test]
18826    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
18827        // Fail-before-pass-after byte-parity pin on the newly lifted
18828        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
18829        // asserts the borrowed-input standard-library trait impl and
18830        // the substrate-primitive [`super::DepList::as_str`] `pub const
18831        // fn` accessor resolve to the same two-arm emit-set across
18832        // every arm the exhaustive [`super::DepList::ALL`] slice
18833        // enumerates. Rust's standard library does not carry a blanket
18834        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
18835        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
18836        // the borrowed-input `Cow<'static, str>` forward-projection
18837        // axis is a distinct trait-idiomatic surface that a
18838        // `let key: Cow<'static, str> = (&list).into();`-shaped call
18839        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
18840        // reaches through this impl and no other — the paired owned-
18841        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
18842        // forces every borrowed-input call site through an explicit
18843        // `Copy` deref (`Cow::from(*list)`) or a
18844        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
18845        // have no compile-time link back to the substrate primitive.
18846        //
18847        // Also asserts the projection lands on the zero-alloc
18848        // [`std::borrow::Cow::Borrowed`] arm (not the
18849        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18850        // [`super::DepList::as_str`] accessor's `&'static str` return
18851        // lifetime by construction (each match arm resolves to one of
18852        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18853        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
18854        // values) makes the borrowed arm the type-correct projection
18855        // with no runtime allocation on the borrowed-input surface
18856        // just as on the paired owned-input surface.
18857        //
18858        // Closes the `{Self, &Self}` input-shape corner on the outside-
18859        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
18860        // on the first outside-M3 caixa-core closed-set fieldless typed
18861        // enum peer on the caixa surface, exactly as afdf0f4 closed it
18862        // on the second M3-mesh-primitive peer
18863        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
18864        // the owning half (eee504d) landed, as 25690ef closed it on
18865        // the first M3-mesh-primitive peer
18866        // ([`crate::aplicacao::WitShape`]) one commit after the owning
18867        // half (8634dec) landed, as d45c409 closed it on the top-level
18868        // [`crate::CaixaKind`] one commit after the owning half
18869        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
18870        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
18871        // [`crate::supervisor::RestartPolicy`] sibling peers one
18872        // commit after (7dd28b3 / 0612398) landed.
18873        for &variant in super::DepList::ALL {
18874            let via_trait: std::borrow::Cow<'static, str> =
18875                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
18876            let via_method: &'static str = variant.as_str();
18877            assert_eq!(
18878                via_trait.as_ref(),
18879                via_method,
18880                "From<&DepList> for Cow<'static, str> impl must \
18881                 round-trip &DepList::{variant:?} to the same lifted \
18882                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18883                 DepList::as_str returns — divergence signals a silent \
18884                 detour off the substrate-primitive accessor"
18885            );
18886            assert!(
18887                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
18888                "From<&DepList> for Cow<'static, str> impl must land \
18889                 on the zero-alloc Cow::Borrowed arm on \
18890                 &DepList::{variant:?} — a Cow::Owned outcome signals \
18891                 the projection has silently allocated where the \
18892                 substrate-primitive DepList::as_str `&'static str` \
18893                 return makes the borrowed arm the type-correct \
18894                 projection"
18895            );
18896            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
18897            assert_eq!(
18898                via_into.as_ref(),
18899                via_method,
18900                "Into<Cow<'static, str>>::into on &DepList::\
18901                 {variant:?} must byte-equal DepList::as_str on the \
18902                 same input — the blanket-derived Into shape must \
18903                 resolve to the same as_str dispatch as the explicit \
18904                 From impl"
18905            );
18906            assert!(
18907                matches!(via_into, std::borrow::Cow::Borrowed(_)),
18908                "Into<Cow<'static, str>>::into on &DepList::\
18909                 {variant:?} must land on the zero-alloc \
18910                 Cow::Borrowed arm — the blanket-derived Into shape \
18911                 must resolve to the same Cow::Borrowed dispatch as \
18912                 the explicit From impl"
18913            );
18914        }
18915    }
18916
18917    #[test]
18918    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
18919        // Cross-axis partition pin: the newly lifted trait-idiomatic
18920        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
18921        // str>` (this lift), the paired owned-input `From<DepList> for
18922        // std::borrow::Cow<'static, str>` (6858bac), the paired
18923        // borrowed-input owned-`&'static str` `From<&DepList> for
18924        // &'static str` (3455cbf), and the paired borrowed-input
18925        // owned-`String` `From<&DepList> for String` must resolve
18926        // identically on every arm, locking the four return-shape ×
18927        // input-shape paths together by construction so any future
18928        // detour trips at caixa-core test time. Also byte-parity
18929        // witness against the sibling [`ToString::to_string`] surface
18930        // routed through [`std::fmt::Display`] — every owned-heap-
18931        // string path (this axis's `.into_owned()` promotion, the
18932        // paired [`From<&DepList> for String`], and `.to_string()`)
18933        // resolves to the same two-arm lifted
18934        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18935        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
18936        // arm.
18937        //
18938        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
18939        // over [`super::DepList::ALL`] — whose iterator yields
18940        // `&DepList` by construction, so the borrowed-input
18941        // [`Cow<'static, str>`] axis is what routes the pipe through
18942        // the substrate-primitive [`super::DepList::as_str`] accessor
18943        // without a spurious [`Copy`] deref (which would only be
18944        // reachable through the owned-input [`From<DepList> for
18945        // Cow<'static, str>`] axis by first calling `.copied()` on the
18946        // iterator). The pipe witness also pins the zero-alloc
18947        // discipline: every element in the collected vector satisfies
18948        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
18949        // future accidental silent-allocation regression on the pipe's
18950        // iteration axis is a caixa-core-test-time failure. Peer of
18951        // the sibling
18952        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
18953        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
18954        // axis — extends the whole borrowed-input `Cow<'static, str>`
18955        // + paired `{&'static str, String}` cross-axis-parity corner
18956        // onto the first outside-M3 caixa-core closed-set fieldless
18957        // typed enum peer on the caixa surface.
18958        for &variant in super::DepList::ALL {
18959            let borrowed_cow: std::borrow::Cow<'static, str> =
18960                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
18961            let owned_cow: std::borrow::Cow<'static, str> =
18962                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18963            let borrowed_static: &'static str =
18964                <&'static str as From<&super::DepList>>::from(&variant);
18965            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
18966            assert_eq!(
18967                borrowed_cow, owned_cow,
18968                "From<&DepList> for Cow<'static, str> and \
18969                 From<DepList> for Cow<'static, str> must resolve \
18970                 identically on DepList::{variant:?} — divergence \
18971                 signals the borrowed-input and owned-input \
18972                 Cow<'static, str> forward-projection input-shape \
18973                 paths have drifted onto different emit-sets"
18974            );
18975            assert_eq!(
18976                borrowed_cow.as_ref(),
18977                borrowed_static,
18978                "From<&DepList> for Cow<'static, str> and \
18979                 From<&DepList> for &'static str must resolve \
18980                 identically on DepList::{variant:?} — divergence \
18981                 signals the borrowed-input Cow<'static, str> and \
18982                 &'static str return-shape paths have drifted onto \
18983                 different emit-sets"
18984            );
18985            assert_eq!(
18986                borrowed_cow.as_ref(),
18987                borrowed_string.as_str(),
18988                "From<&DepList> for Cow<'static, str> and \
18989                 From<&DepList> for String must resolve identically \
18990                 on DepList::{variant:?} — divergence signals the \
18991                 borrowed-input Cow<'static, str> and owned-`String` \
18992                 return-shape paths have drifted onto different \
18993                 emit-sets"
18994            );
18995            let via_to_string: String = variant.to_string();
18996            assert_eq!(
18997                borrowed_cow.as_ref(),
18998                via_to_string.as_str(),
18999                "From<&DepList> for Cow<'static, str> must byte-equal \
19000                 DepList::to_string on DepList::{variant:?} — \
19001                 divergence signals the trait-idiomatic borrowed-input \
19002                 Cow<'static, str> forward-projection axis and the \
19003                 ToString-through-Display axis have drifted onto \
19004                 different emit-sets"
19005            );
19006        }
19007        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19008            .iter()
19009            .map(std::borrow::Cow::from)
19010            .collect();
19011        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19012            .iter()
19013            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19014            .collect();
19015        assert_eq!(
19016            via_iter, via_method,
19017            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19018             whose iteration axis holds &DepList by construction — \
19019             must byte-equal `.iter().map(|l| \
19020             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19021             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19022             str>` axis is what makes the `Cow::from` composition \
19023             route through the substrate-primitive `DepList::as_str` \
19024             accessor with the zero-alloc Cow::Borrowed arm by \
19025             construction and without a spurious `Copy` deref (which \
19026             would only be reachable through the owned-input \
19027             `From<DepList> for Cow<'static, str>` axis by first \
19028             calling `.copied()` on the iterator)"
19029        );
19030        for cow in &via_iter {
19031            assert!(
19032                matches!(cow, std::borrow::Cow::Borrowed(_)),
19033                "every element of the .iter().map(Cow::from) pipe \
19034                 over DepList::ALL must land on the zero-alloc \
19035                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19036                 signals the pipe's iteration axis has silently \
19037                 allocated where the substrate-primitive \
19038                 DepList::as_str `&'static str` return makes the \
19039                 borrowed arm the type-correct projection"
19040            );
19041        }
19042    }
19043}
19044
19045#[cfg(test)]
19046mod dep_source_is_variant_tests {
19047    use super::*;
19048
19049    fn all_variants() -> Vec<(DepSource, &'static str)> {
19050        vec![
19051            (
19052                DepSource::Git {
19053                    repo: "github:pleme-io/caixa-teia".into(),
19054                    tag: Some("v0.1.0".into()),
19055                    rev: None,
19056                    branch: None,
19057                },
19058                "Git",
19059            ),
19060            (
19061                DepSource::Path {
19062                    caminho: "../caixa-teia".into(),
19063                },
19064                "Path",
19065            ),
19066        ]
19067    }
19068
19069    fn predicate_row(s: &DepSource) -> [bool; 2] {
19070        [s.is_git(), s.is_path()]
19071    }
19072
19073    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
19074    // derive-generated per-arm predicate partition — for every variant
19075    // in `all_variants()`, the observed 2-slot predicate row must equal
19076    // a one-hot row with the `true` at exactly the same index as the
19077    // variant's declaration order. Expected rows are generated live
19078    // from the enumeration rather than transcribed by hand, so a
19079    // copy-paste flip that reroutes one arm through the wrong predicate
19080    // lane trips at the identity-diagonal assertion the way every peer
19081    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
19082    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
19083    // / [`crate::upgrade::UpgradeInstruction`] /
19084    // [`crate::aplicacao::PlacementStrategy`] /
19085    // [`crate::aplicacao::RateLimitUnit`] /
19086    // [`crate::aplicacao::WitTarget`] /
19087    // [`crate::render::PathShapeViolation`] partition pin already does.
19088    #[test]
19089    fn dep_source_is_variant_predicates_partition_the_arm_set() {
19090        let variants = all_variants();
19091        for (idx, (variant, name)) in variants.iter().enumerate() {
19092            let observed = predicate_row(variant);
19093            let mut expected = [false; 2];
19094            expected[idx] = true;
19095            assert_eq!(
19096                observed, expected,
19097                "DepSource::{name} at declaration-order slot {idx} must \
19098                 satisfy exactly one is_* predicate (its own); observed \
19099                 row must equal the one-hot expected row — a drift \
19100                 would silently reroute one `:fonte`-arm consumer \
19101                 through the wrong predicate lane"
19102            );
19103        }
19104    }
19105
19106    // Byte-parity pin on the two field-agnostic `matches!` shapes the
19107    // per-arm arm-discriminator predicates replace at any future
19108    // consumer site (a `:fonte`-shape-only lint rule that flags path
19109    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
19110    // a future admission-webhook that rejects `:fonte` shapes outside
19111    // the `is_git()` accept-set, a caixa-lacre indexing pass that
19112    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
19113    // Refuses a future accidental split between the derived predicate
19114    // and its `matches!` shape — a hand-rolled shadow impl that
19115    // overrides one path, an accidental rebrand that leaves one
19116    // consumer on the raw `matches!` form — on the two load-bearing
19117    // `:fonte`-arm-discriminator axes every downstream substrate
19118    // consumer of the dep-source axis keys off.
19119    #[test]
19120    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
19121        for (variant, name) in all_variants() {
19122            let via_matches_git = matches!(variant, DepSource::Git { .. });
19123            let via_predicate_git = variant.is_git();
19124            assert_eq!(
19125                via_predicate_git, via_matches_git,
19126                "DepSource::{name}.is_git() must byte-equal \
19127                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
19128                 future converged consumer site would silently \
19129                 disagree with its pre-lift shape"
19130            );
19131            let via_matches_path = matches!(variant, DepSource::Path { .. });
19132            let via_predicate_path = variant.is_path();
19133            assert_eq!(
19134                via_predicate_path, via_matches_path,
19135                "DepSource::{name}.is_path() must byte-equal \
19136                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
19137                 future converged consumer site would silently \
19138                 disagree with its pre-lift shape"
19139            );
19140        }
19141    }
19142
19143    // Cross-pin against every constructor path that materializes a
19144    // [`DepSource`] shape today (the [`DepSource::default_github`]
19145    // resolver-side fallback that materializes an unpinned
19146    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
19147    // surface constructor that materializes a pinned `:tag`-carrying
19148    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
19149    // fixture family builds inline). Every constructor's return must
19150    // satisfy the arm-discriminator predicate the constructor's
19151    // variant name matches — a future constructor addition (an
19152    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
19153    // enclosing docstring already names as a trajectory item) surfaces
19154    // as a build-time failure that names the offending drift when its
19155    // return arm doesn't route through the paired predicate.
19156    #[test]
19157    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
19158        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
19159        assert!(
19160            via_default_github.is_git(),
19161            "DepSource::default_github must materialize a Git-arm shape — \
19162             a future constructor that routed through a non-Git arm \
19163             (a registry-fetch pin, a `DepSource::Feira` promotion) \
19164             would silently split the resolver's unpinned-shorthand \
19165             materializer from the sole_pin() precedence cascade"
19166        );
19167        assert!(
19168            !via_default_github.is_path(),
19169            "DepSource::default_github must NOT materialize a Path-arm \
19170             shape — the paired negation pin"
19171        );
19172
19173        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
19174            .fonte
19175            .expect("Dep::git materializes a Some(fonte)");
19176        assert!(
19177            via_dep_git.is_git(),
19178            "Dep::git's `:fonte` materialization must land on the Git \
19179             arm — the author-surface pinned-git constructor's return \
19180             must route through the paired predicate"
19181        );
19182        assert!(!via_dep_git.is_path(), "paired negation pin");
19183
19184        let via_path = DepSource::Path {
19185            caminho: "../caixa-teia".into(),
19186        };
19187        assert!(
19188            via_path.is_path(),
19189            "the dev-mode Path-arm materialization must satisfy is_path()"
19190        );
19191        assert!(!via_path.is_git(), "paired negation pin");
19192    }
19193
19194    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
19195    //    String, reason: String }` three-slot envelope on `DepError`,
19196    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
19197    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
19198    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
19199    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
19200    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
19201    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
19202
19203    #[test]
19204    fn versao_invalid_ctor_matches_struct_literal_wrap() {
19205        assert_eq!(
19206            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
19207            DepError::VersaoInvalid {
19208                nome: "caixa-teia".to_string(),
19209                versao: "^0..1".to_string(),
19210                reason: "invalid comparator".to_string(),
19211            },
19212            "versao_invalid ctor must produce byte-equal \
19213             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
19214        );
19215    }
19216
19217    #[test]
19218    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
19219        assert_eq!(
19220            DepError::fonte_repo_shape(
19221                "caixa-teia",
19222                "-upload-pack=evil",
19223                "leading dash rejected".to_string(),
19224            ),
19225            DepError::FonteRepoShape {
19226                nome: "caixa-teia".to_string(),
19227                repo: "-upload-pack=evil".to_string(),
19228                reason: "leading dash rejected".to_string(),
19229            },
19230            "fonte_repo_shape ctor must produce byte-equal \
19231             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
19232        );
19233    }
19234
19235    #[test]
19236    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
19237        assert_eq!(
19238            DepError::caracteristica_invalid(
19239                "caixa-teia",
19240                "bad feature!",
19241                "embedded space rejected".to_string(),
19242            ),
19243            DepError::CaracteristicaInvalid {
19244                nome: "caixa-teia".to_string(),
19245                caracteristica: "bad feature!".to_string(),
19246                reason: "embedded space rejected".to_string(),
19247            },
19248            "caracteristica_invalid ctor must produce byte-equal \
19249             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
19250        );
19251    }
19252
19253    #[test]
19254    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
19255        // Cross-axis routing pin: sweep the three constructor input axes
19256        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
19257        // distinct-per-axis fixtures against every generated arm in the
19258        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
19259        // lowercase / trim / truncate on the two `&str` axes — a silent
19260        // field swap between `nome`, the middle `<axis>` field, and
19261        // `reason`, or a `reason` axis silently rerouted through
19262        // `.to_string()` instead of forwarded owned — surfaces here rather
19263        // than at a downstream diagnostic-shape mismatch. Peer of the
19264        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
19265        // through_to_string` (0e35793) cross-axis routing pin on the same
19266        // envelope's `{ nome, caminho, byte }` three-slot family and of
19267        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
19268        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
19269        // — extended here onto the `{ nome, <axis>: String, reason:
19270        // String }` three-slot envelope so every substrate-primitive ctor
19271        // family in caixa-core's `DepError` envelope guarantees each field
19272        // routes the caller's value verbatim through `.to_string()` (or
19273        // owned-forward for `reason: String`) in declared field order.
19274        // Distinct-per-axis fixtures rule out any two-axis swap
19275        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
19276        // same-fixture-per-axis pin.
19277        let nome = "sibling-teia";
19278        let axis = "distinct-axis-value";
19279        let reason = "distinct rejection sentence".to_string();
19280        assert_eq!(
19281            DepError::versao_invalid(nome, axis, reason.clone()),
19282            DepError::VersaoInvalid {
19283                nome: nome.to_string(),
19284                versao: axis.to_string(),
19285                reason: reason.clone(),
19286            },
19287            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
19288             `reason` → `reason` in declared field order",
19289        );
19290        assert_eq!(
19291            DepError::fonte_repo_shape(nome, axis, reason.clone()),
19292            DepError::FonteRepoShape {
19293                nome: nome.to_string(),
19294                repo: axis.to_string(),
19295                reason: reason.clone(),
19296            },
19297            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
19298             `reason` → `reason` in declared field order",
19299        );
19300        assert_eq!(
19301            DepError::caracteristica_invalid(nome, axis, reason.clone()),
19302            DepError::CaracteristicaInvalid {
19303                nome: nome.to_string(),
19304                caracteristica: axis.to_string(),
19305                reason: reason.clone(),
19306            },
19307            "caracteristica_invalid must route `nome` → `nome`, \
19308             `axis` → `caracteristica`, `reason` → `reason` in declared \
19309             field order",
19310        );
19311    }
19312
19313    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
19314    //    two-slot envelope on `DepError`, missing rung between
19315    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
19316    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
19317    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
19318    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
19319    //    two-slot `{ nome, list: &'static str }` envelope (same slot
19320    //    count, `&'static str` axis instead of owned `String` axis).
19321
19322    #[test]
19323    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
19324        assert_eq!(
19325            DepError::fonte_pin_empty("caixa-teia", ":tag"),
19326            DepError::FontePinEmpty {
19327                nome: "caixa-teia".to_string(),
19328                pin: ":tag".to_string(),
19329            },
19330            "fonte_pin_empty ctor must produce byte-equal \
19331             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
19332             on the same `(&str, &str)` fixture",
19333        );
19334    }
19335
19336    #[test]
19337    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
19338        assert_eq!(
19339            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
19340            DepError::FontePinAmbiguous {
19341                nome: "caixa-teia".to_string(),
19342                pins: ":tag, :rev".to_string(),
19343            },
19344            "fonte_pin_ambiguous ctor must produce byte-equal \
19345             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
19346             wrap on the same `(&str, &str)` fixture",
19347        );
19348    }
19349
19350    #[test]
19351    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
19352        assert_eq!(
19353            DepError::caracteristica_duplicate("caixa-teia", "http"),
19354            DepError::CaracteristicaDuplicate {
19355                nome: "caixa-teia".to_string(),
19356                caracteristica: "http".to_string(),
19357            },
19358            "caracteristica_duplicate ctor must produce byte-equal \
19359             `DepError::CaracteristicaDuplicate` to the pre-lift \
19360             struct-literal wrap on the same `(&str, &str)` fixture",
19361        );
19362    }
19363
19364    #[test]
19365    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
19366        // Owned-`String` routing pin: thread the real
19367        // `set.join(", ")` `String` carrier through the ctor's
19368        // `&str`-parameter Deref coercion, so the ambiguity-arm
19369        // wire-up site's actual `&set.join(", ")` shape stays
19370        // byte-equal to a direct `":tag, :rev"` literal. A future
19371        // parameter-shape change silently dropping the Deref
19372        // coercion route (e.g., a switch to `impl Into<String>`)
19373        // surfaces here rather than at the wire-up's compile
19374        // error far from the ctor definition.
19375        let set: Vec<&'static str> = vec![":tag", ":rev"];
19376        let joined: String = set.join(", ");
19377        assert_eq!(
19378            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
19379            DepError::FontePinAmbiguous {
19380                nome: "caixa-teia".to_string(),
19381                pins: ":tag, :rev".to_string(),
19382            },
19383            "fonte_pin_ambiguous ctor must accept an owned-`String` \
19384             `&set.join(\", \")` carrier via Deref coercion — the exact \
19385             shape the ambiguity-arm wire-up site passes into it",
19386        );
19387    }
19388
19389    #[test]
19390    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
19391        // Cross-axis routing pin: sweep the two constructor input axes
19392        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
19393        // fixtures against every generated arm in the
19394        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
19395        // trim / truncate at codegen time — a silent field swap between
19396        // `nome` and the middle `<axis>` field, or a `<axis>` axis
19397        // silently rerouted through the wrong field on any one variant
19398        // — surfaces here rather than at a downstream diagnostic-shape
19399        // mismatch. Peer of the sibling
19400        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
19401        // (6f5e0cd) pin on the same envelope's peer two-slot family
19402        // (`{ nome, list: &'static str }`) and of the sibling
19403        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19404        // (5621f8a) pin on the same envelope's three-slot `{ nome,
19405        // <axis>: String, reason: String }` family — extended here onto
19406        // the `{ nome, <axis>: String }` two-slot envelope so the last
19407        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
19408        // ladder guarantees each field routes the caller's value
19409        // verbatim through `.to_string()` in declared field order.
19410        // Distinct-per-axis fixtures rule out any two-axis swap
19411        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
19412        // per-axis pin.
19413        let nome = "sibling-teia";
19414        let axis = "distinct-axis-value";
19415        assert_eq!(
19416            DepError::fonte_pin_empty(nome, axis),
19417            DepError::FontePinEmpty {
19418                nome: nome.to_string(),
19419                pin: axis.to_string(),
19420            },
19421            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
19422             in declared field order",
19423        );
19424        assert_eq!(
19425            DepError::fonte_pin_ambiguous(nome, axis),
19426            DepError::FontePinAmbiguous {
19427                nome: nome.to_string(),
19428                pins: axis.to_string(),
19429            },
19430            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
19431             in declared field order",
19432        );
19433        assert_eq!(
19434            DepError::caracteristica_duplicate(nome, axis),
19435            DepError::CaracteristicaDuplicate {
19436                nome: nome.to_string(),
19437                caracteristica: axis.to_string(),
19438            },
19439            "caracteristica_duplicate must route `nome` → `nome`, \
19440             `axis` → `caracteristica` in declared field order",
19441        );
19442    }
19443
19444    #[test]
19445    fn nome_invalid_ctor_matches_struct_literal_wrap() {
19446        // Equivalence pin: the ctor produces byte-equal
19447        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
19448        // literal that cloned the offending `:deps :nome` verbatim and
19449        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
19450        // owned `reason` payload at the caller site inside
19451        // [`Dep::validate`]. Guards any future field-addition /
19452        // reordering / accessor-return tweak on the variant. Sibling of
19453        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
19454        // (below) and the sibling three-slot
19455        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19456        // pin on the same envelope's three-slot `{ nome, <axis>: String,
19457        // reason: String }` family.
19458        let nome = "Caixa-Teia";
19459        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
19460        let via_ctor = DepError::nome_invalid(nome, reason.clone());
19461        let via_literal = DepError::NomeInvalid {
19462            nome: nome.to_string(),
19463            reason,
19464        };
19465        assert_eq!(
19466            via_ctor, via_literal,
19467            "nome_invalid(nome, reason) must byte-equal the open-coded \
19468             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
19469        );
19470        assert_eq!(
19471            via_ctor.to_string(),
19472            via_literal.to_string(),
19473            "Display byte-string must byte-equal the open-coded struct-literal"
19474        );
19475    }
19476
19477    #[test]
19478    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
19479        // Boundary-sweep pin on the ctor's two-slot projection: sweep
19480        // the two ctor input axes (`nome: &str`, `reason: String`)
19481        // through distinct-per-axis fixtures against a representative
19482        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
19483        // wrapper-side silent lowercase / trim / truncate at codegen
19484        // time — a silent field swap between `nome` and `reason`, an
19485        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
19486        // divergence on the `reason` axis — surfaces at caixa-core
19487        // build time rather than at a downstream diagnostic consumer
19488        // that reads `err.nome` / `err.reason` back and gets a different
19489        // value than the one it stored. Peer of the sibling
19490        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
19491        // (7f7c950) pin on the same envelope's peer two-slot family
19492        // (`{ nome, <axis>: String }`) — extended here onto the
19493        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
19494        // variant carries. Distinct-per-axis fixtures rule out any
19495        // two-axis swap (`nome` ↔ `reason`) that would still pass a
19496        // same-fixture-per-axis pin. The sweep list carries a mixed
19497        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
19498        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
19499        // over-63-byte) so a future silent per-input normalization
19500        // surfaces on the arm that diverges.
19501        for nome in [
19502            "Caixa-Teia",
19503            "caixa_teia",
19504            "caixa.teia",
19505            "-caixa-teia",
19506            "caixa-teia-",
19507            "caixa/teia",
19508            &"a".repeat(64),
19509        ] {
19510            let reason = crate::render::is_dns_1123_label(nome)
19511                .expect_err("fixture must be a DNS-1123-refused label");
19512            let via_ctor = DepError::nome_invalid(nome, reason.clone());
19513            let DepError::NomeInvalid {
19514                nome: stored_nome,
19515                reason: stored_reason,
19516            } = via_ctor
19517            else {
19518                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
19519            };
19520            assert_eq!(
19521                stored_nome, nome,
19522                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
19523            );
19524            assert_eq!(
19525                stored_reason, reason,
19526                "reason slot must forward the owned `String` verbatim for {nome:?}"
19527            );
19528        }
19529    }
19530
19531    #[test]
19532    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
19533        // End-to-end pin: the sole in-crate wire-up site
19534        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
19535        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
19536        // the ctor's output on the same DNS-1123-refused `:deps :nome`
19537        // fixture, with identical `Display` rendering. A future silent
19538        // de-lift of the wire-up back to the open-coded struct-literal
19539        // trips this test at caixa-core build time rather than at a
19540        // downstream diagnostic consumer far from the wire-up commit.
19541        // Sibling of the peer
19542        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
19543        // pin on the same wire-up — extended here from a `matches!`
19544        // shape check to a byte-identity + Display parity route through
19545        // the ctor.
19546        let d = Dep::simple("Caixa_Teia", "^0.1");
19547        let observed = d.validate().unwrap_err();
19548        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
19549            .expect_err("fixture must be DNS-1123-refused");
19550        let expected = DepError::nome_invalid("Caixa_Teia", reason);
19551        assert_eq!(
19552            observed, expected,
19553            "Dep::validate's DNS-1123 refusal arm must byte-equal \
19554             nome_invalid(nome, reason)"
19555        );
19556        assert_eq!(
19557            observed.to_string(),
19558            expected.to_string(),
19559            "Display byte-string parity"
19560        );
19561    }
19562}