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/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection on
3936/// the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
3937/// fieldless typed enum. Routes byte-for-byte through the substrate-
3938/// primitive [`DepList::as_str`] `pub const fn` accessor via
3939/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
3940/// that binds a `let key: Box<str> = list.into();`-shaped call site — a
3941/// per-`:deps` / `:deps-dev` census-key materializer that stashes the
3942/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
3943/// cheap clone off an owned handle, a future M4
3944/// [`caixa.pleme.io/v1alpha1/Caixa`] CR materializer's per-list admission-
3945/// webhook rejection body whose per-arm [`Box<str>`] field composes from
3946/// an owned [`DepList`] handle naming the accepted-list-tag list, a future
3947/// `feira lint --explain-dep-list=<axis>` per-arm listing that stashes
3948/// each arm as an owned [`Box<str>`] label — reaches the same two lifted
3949/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3950/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
3951/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
3952/// forward-projection corner already returns.
3953///
3954/// Rust's standard library carries `impl From<&str> for Box<str>` and
3955/// `impl From<String> for Box<str>` but no blanket
3956/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a distinct
3957/// trait-idiomatic surface that a downstream `DepList → Box<str>`
3958/// `.into()` reaches through this impl and no other — without a
3959/// `Box::from(list.as_str())` open-code whose type bounds have no
3960/// compile-time link back to the substrate primitive.
3961///
3962/// Extends the caixa-core-internal tier of the substrate-wide trait-
3963/// idiomatic [`Box<str>`] forward-projection campaign onto the second
3964/// caixa-core-internal peer, after the render-side path-shape-diagnostic
3965/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
3966/// one axis) opened the tier. Follows the M2 OTP-shape
3967/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
3968/// pair (59ae5dc + cb1d068), the M3 mesh-shape
3969/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
3970/// [`crate::aplicacao::RateLimitUnit`] triple (6d73e84 → df7040c) that
3971/// closed the M3 mesh-shape tier, and the outside-`caixa-core` tier
3972/// (`InvariantKind` 10613a7 + 5901887, `ArchVerdict` 3e08f5a + c4319a8,
3973/// `Severity` 5116c95, `FixSafety` cf0174b, `Semantic` 0cd7dc3,
3974/// `FerriteRuntime` 14886a8) that closed one tier prior. Same discipline
3975/// as those peers: forward emit (this impl, the sibling `{&'static str,
3976/// String, Cow<'static, str>}` forward-projection corner, [`std::fmt::Display`],
3977/// [`AsRef<str>`], [`DepList::as_str`]) and reverse parse
3978/// ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the same two
3979/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3980/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
3981/// by construction, so the round-trip composes directly without the
3982/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
3983/// requires.
3984///
3985/// A future variant addition (a `Build` build-time-only dep-list axis the
3986/// CAIXA-SDLC hints name as a trajectory item once the Cargo
3987/// `[build-dependencies]` table gains substrate visibility) reaches the
3988/// paired [`Box<str>`] output axis through one match-arm edit on the
3989/// [`DepList::as_str`] `pub const fn` accessor, not a coordinated rewrite
3990/// of every downstream `Box::from(list.as_str())` open-code.
3991///
3992/// Pinned load-bearing by
3993/// [`tests::dep_list_from_into_box_str_routes_through_as_str_accessor`]
3994/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3995/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
3996/// derived [`Into`] shape witness).
3997impl From<DepList> for Box<str> {
3998    fn from(list: DepList) -> Box<str> {
3999        Box::<str>::from(list.as_str())
4000    }
4001}
4002
4003/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward projection
4004/// on the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4005/// fieldless typed enum. Routes byte-for-byte through the substrate-
4006/// primitive [`DepList::as_str`] `pub const fn` accessor via
4007/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4008/// that binds a `let key: Box<str> = (&list).into();`-shaped call site or
4009/// a `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
4010/// iterator over `&'static [DepList]` yields `&DepList` by construction)
4011/// — a per-`:deps` / `:deps-dev` census-key materializer that stashes the
4012/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4013/// cheap clone off a borrowed handle, a future M4 admission-webhook
4014/// rejection body whose per-arm [`Box<str>`] field composes from a
4015/// borrowed [`DepList`] handle off a `&DepList` borrow, a future
4016/// `feira lint --explain-dep-list` per-axis listing that iterates
4017/// [`DepList::ALL`] into per-arm owned [`Box<str>`] labels — reaches the
4018/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4019/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4020/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4021/// forward-projection corner and the paired owned-input
4022/// [`From<DepList> for Box<str>`] already return.
4023///
4024/// Rust's standard library carries `impl From<&str> for Box<str>` and
4025/// `impl From<String> for Box<str>` but no blanket
4026/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
4027/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
4028/// axis is a distinct trait-idiomatic surface that the pipe shape
4029/// [`DepList::ALL`]`.iter().map(Box::<str>::from)` reaches through this
4030/// impl and no other — without it, the same pipe would force an explicit
4031/// `.copied()` restatement (`.iter().copied().map(Box::<str>::from)`)
4032/// whose type bounds have no compile-time link back to the substrate
4033/// primitive, and a `let key: Box<str> = (&list).into();`-shaped call
4034/// site would force an explicit `Copy` deref (`Box::<str>::from(*list)`)
4035/// or a `Box::<str>::from(list.as_str())` open-code with the same defect.
4036///
4037/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4038/// core-internal closed-set fieldless typed enum peer of the substrate-
4039/// wide trait-idiomatic [`Box<str>`] forward-projection campaign — one
4040/// commit after the paired render-side path-shape-diagnostic
4041/// [`crate::render::PathShapeViolation`] pair (0d87a72) opened the caixa-
4042/// core-internal tier — matching the trajectory the paired caixa-theme
4043/// [`caixa_theme::style::Semantic`] pair (0cd7dc3, both corners in one
4044/// axis), the caixa-provedor [`caixa_provedor::FerriteRuntime`] pair
4045/// (14886a8, both corners in one axis), and the render-side
4046/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4047/// one axis) walked before it.
4048///
4049/// Same discipline as the paired outside-`caixa-core`,
4050/// [`crate::supervisor`], [`crate::aplicacao`], and [`crate::render`]
4051/// [`Box<str>`] `{Self, &Self}`-closers: forward emit (this impl, the
4052/// paired owned-input [`From<DepList> for Box<str>`] impl, the sibling
4053/// `{&'static str, String, Cow<'static, str>}` forward-projection corner,
4054/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`]) and reverse
4055/// parse ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the
4056/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4057/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4058/// by construction, so the round-trip composes directly without the
4059/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4060/// requires.
4061///
4062/// Pinned load-bearing by
4063/// [`tests::dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor`]
4064/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4065/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4066/// blanket-derived [`Into`] shape witness, plus a
4067/// `.iter().map(Box::<str>::from)` pipe witness over [`DepList::ALL`] —
4068/// whose iterator yields `&DepList` by construction, so the borrowed-
4069/// input [`Box<str>`] axis is what routes the pipe through the substrate-
4070/// primitive [`DepList::as_str`] accessor without a spurious [`Copy`]
4071/// deref).
4072impl From<&DepList> for Box<str> {
4073    fn from(list: &DepList) -> Box<str> {
4074        Box::<str>::from(list.as_str())
4075    }
4076}
4077
4078/// Errors raised by [`Dep::validate`].
4079///
4080/// Mirrors the per-axis error families the other `:versao`-carrying
4081/// typed surfaces expose
4082/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4083/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4084/// [`crate::SupervisorError::EmptyChildVersion`] /
4085/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4086/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4087#[derive(Debug, Error, PartialEq, Eq)]
4088pub enum DepError {
4089    #[error(
4090        ":deps entry has empty :nome (every dep must name a target caixa; \
4091         omit the entry instead of carrying an empty name)"
4092    )]
4093    NomeEmpty,
4094    #[error(
4095        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4096         (the value flows verbatim as the target caixa's `:nome`, the rendered \
4097         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4098         value, and the resolver's checkout-directory leaf — each apiserver-side \
4099         schema rejects non-DNS-1123 names at admission time; use a lowercase \
4100         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4101         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4102    )]
4103    NomeInvalid { nome: String, reason: String },
4104    #[error(
4105        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4106         constraint that resolves through the lacre pipeline)"
4107    )]
4108    VersaoEmpty { nome: String },
4109    #[error(
4110        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4111         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4112         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4113         and `:children :versao` carry; the lacre pipeline resolves all three \
4114         through the same parser)"
4115    )]
4116    VersaoInvalid {
4117        nome: String,
4118        versao: String,
4119        reason: String,
4120    },
4121    #[error(
4122        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4123         (every git source must name a repo — use a `github:org/repo` \
4124         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4125         entire :fonte block to fall back to the default-host resolver \
4126         convention)"
4127    )]
4128    FonteRepoEmpty { nome: String },
4129    #[error(
4130        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4131         invalid value-shape: {reason} (the value flows verbatim into the \
4132         caixa-resolver's `git clone <repo>` subprocess invocation; every \
4133         documented form carries a `:` separator and no whitespace / \
4134         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4135         an `https://host/path` / `ssh://[user@]host/path` / \
4136         `git://host/path` / `file:///path` URL, or the `git@host:path` \
4137         scp-style SSH form)"
4138    )]
4139    FonteRepoShape {
4140        nome: String,
4141        repo: String,
4142        reason: String,
4143    },
4144    #[error(
4145        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4146         (set exactly one of :tag, :rev, or :branch so the resolver \
4147         can pick a reproducible commit; omit the entire :fonte block \
4148         to fall back to the default-host resolver convention, which \
4149         resolves the latest tag matching :versao)"
4150    )]
4151    FontePinMissing { nome: String },
4152    #[error(
4153        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4154         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4155         set so the resolver's checkout target is unambiguous (the \
4156         resolver's silent precedence is :rev > :tag > :branch — if \
4157         you intended one specifically, drop the others)"
4158    )]
4159    FontePinAmbiguous { nome: String, pins: String },
4160    #[error(
4161        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4162         (a set pin must name a non-empty git ref; drop the {pin} key \
4163         entirely to fall through to another pin axis)"
4164    )]
4165    FontePinEmpty { nome: String, pin: String },
4166    #[error(
4167        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4168         value-shape: {reason} (the git porcelain enforces the same shape at \
4169         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4170         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4171         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4172         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4173         prepends at clone time, and avoid abbreviated SHAs which are \
4174         ambiguous across repository history)"
4175    )]
4176    FontePinShape {
4177        nome: String,
4178        pin: String,
4179        value: String,
4180        reason: String,
4181    },
4182    #[error(
4183        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4184         (every path source must name a non-empty filesystem path; \
4185         omit the entire :fonte block to fall back to the default-host \
4186         resolver convention)"
4187    )]
4188    FonteCaminhoEmpty { nome: String },
4189    #[error(
4190        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4191         absolute (the lacre pipeline embeds the value verbatim in its \
4192         per-dep content-address `path:{caminho}` at \
4193         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4194         BLAKE3 closure differ across machines — defeating the \
4195         reproducibility contract that's load-bearing for CSE; express \
4196         the path relative to the caixa.lisp location, e.g. \
4197         \"../caixa-teia\" for a sibling workspace dep)"
4198    )]
4199    FonteCaminhoAbsolute { nome: String, caminho: String },
4200    #[error(
4201        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4202         with `~` (the leading-tilde is a shell-expansion convention, not a \
4203         POSIX path component — `Path::is_absolute` returns false on it, so \
4204         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4205         pipeline embeds the value verbatim in its per-dep content-address \
4206         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4207         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4208         so the build looks for a literal `./{caminho}` subdirectory and \
4209         fails at resolve time far from the source caixa.lisp; even worse, a \
4210         future caixa-resolver pass that *does* expand `~` would silently \
4211         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4212         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4213         runners with different `$HOME` layouts resolve to two distinct paths \
4214         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4215         determinism contract; express the path relative to the caixa.lisp \
4216         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4217         spell out the full relative path explicitly if a workstation-rooted \
4218         dep is genuinely intended)"
4219    )]
4220    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4221    #[error(
4222        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4223         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4224         not a POSIX path component — `Path::is_absolute` returns false on it \
4225         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4226         embeds the value verbatim in its per-dep content-address \
4227         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4228         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4229         so the build looks for a literal `./{caminho}` subdirectory and \
4230         fails at resolve time far from the source caixa.lisp; even worse, a \
4231         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4232         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4233         invites) would silently re-open the host-layout-leak the b94fd83 \
4234         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4235         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4236         layouts resolve to two distinct paths for the byte-identical caixa, \
4237         defeating the THEORY.md §V.2 render-determinism contract; express \
4238         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4239         for a sibling workspace dep, or spell out the full relative path \
4240         explicitly if a workstation-rooted dep is genuinely intended)"
4241    )]
4242    FonteCaminhoVarExpansion { nome: String, caminho: String },
4243    #[error(
4244        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4245         with a space (the leading ASCII space `0x20` is the orthogonal \
4246         paste-from-aligned-doc footgun that silently passes \
4247         `Path::is_absolute` and every prior leading-byte arm — \
4248         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4249         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4250         resolve time with a non-self-locating `No such file or directory` \
4251         error far from the source caixa.lisp; the lacre pipeline embeds \
4252         the value verbatim in its per-dep content-address `path:{caminho}` \
4253         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4254         semantic-identical caixa values (` ../caixa-teia` vs \
4255         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4256         workstations whose authors differ only in paste-from-aligned- \
4257         caixa.lisp-doc whitespace habits — the most insidious failure \
4258         mode the typed slot can carry (no error surfaces; the divergence \
4259         is invisible until two machines compare lacres), defeating the \
4260         THEORY.md §V.2 render-determinism contract. The canonical \
4261         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4262         a multi-entry `:deps` block sits at the same column — an author \
4263         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4264         the rendered alignment into a fresh entry preserves the leading \
4265         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4266         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4267         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4268         `is_chart_description_shape`, `:licenca` via \
4269         `is_spdx_expression_shape`. Drop the leading space; express the \
4270         path as a bare relative single-token like \"../caixa-teia\")"
4271    )]
4272    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4273    #[error(
4274        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4275         with `-` (the canonical CLI-argument-injection footgun on the \
4276         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4277         its per-dep content-address `path:{caminho}` at \
4278         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4279         through `Path::join` looking for a literal `./{caminho}` \
4280         subdirectory. Every downstream subprocess that consumes the resolved \
4281         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4282         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4283         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4284         value as a CLI flag rather than a positional path when the invocation \
4285         does not carry a `--` argument-list terminator between the flag block \
4286         and the path (the common case at every porcelain entry point). The \
4287         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4288         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4289         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4290         CLI-arg-injection vector at every git porcelain entry point that \
4291         consumes a path or URL argument, peer with is_git_repo_url's \
4292         leading-`-` arm on the sibling `:fonte :repo` axis), \
4293         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4294         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4295         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4296         for a literal `./-rf` subdirectory that fails at resolve time with a \
4297         non-self-locating `No such file or directory` error far from the \
4298         source caixa.lisp — but on any downstream shell-out without `--` the \
4299         reinterpretation is silent and the failure mode is arbitrary-\
4300         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4301         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4302         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4303         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4304         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4305         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4306         `:children :caixa`, `:deps :nome`, cluster names); \
4307         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4308         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4309         leading `-` on the CLI positional itself. Express the path as a bare \
4310         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4311         directory name carries no leading-hyphen semantic, and `./` / `../` \
4312         prefixes structurally partition the leading-byte set to safe values.)"
4313    )]
4314    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4315    #[error(
4316        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4317         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4318         every `std::fs` syscall routes the path through `CString::new` which \
4319         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4320         value verbatim in its per-dep content-address `path:{caminho}` at \
4321         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4322         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4323         determinism contract — the canonical paste-from-multiline-doc \
4324         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4325         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4326         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4327         already gates against. Express the path as a relative single-line ASCII \
4328         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4329    )]
4330    FonteCaminhoControlChar {
4331        nome: String,
4332        caminho: String,
4333        byte: u8,
4334    },
4335    #[error(
4336        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4337         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4338         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4339         not the parent's sibling — and the caixa-resolver folds the value through \
4340         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4341         resolve time with a non-self-locating `No such file or directory` error far \
4342         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4343         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4344         resolve to two distinct directories across runner OSes — the lacre pipeline \
4345         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4346         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4347         determinism contract via the cross-host-OS-separator divergence vector. The \
4348         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4349         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4350         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4351         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4352         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4353         \"../caixa-teia\" for a sibling workspace dep)"
4354    )]
4355    FonteCaminhoBackslash { nome: String, caminho: String },
4356    #[error(
4357        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4358         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4359         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4360         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4361         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4362         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4363         as literal path-component bytes, so the resolver folds the value through \
4364         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4365         subdirectory and fails at resolve time with a non-self-locating `No such \
4366         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4367         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4368         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4369         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4370         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4371         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4372         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4373         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4374         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4375         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4376         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4377         redirection semantic.",
4378        ch = *byte as char
4379    )]
4380    FonteCaminhoShellRedirection {
4381        nome: String,
4382        caminho: String,
4383        byte: u8,
4384    },
4385    #[error(
4386        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4387         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4388         `|` as the pipe operator that wires one command's stdout to the next command's \
4389         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4390         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4391         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4392         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4393         treats `|` as a literal path-component byte, so the resolver folds the value \
4394         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4395         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4396         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4397         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4398         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4399         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4400         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4401         subprocess-argument / shell-metachar injection surface every peer single-token-\
4402         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4403         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4404         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4405         workspace directory name carries no shell-pipe semantic."
4406    )]
4407    FonteCaminhoShellPipe { nome: String, caminho: String },
4408    #[error(
4409        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4410         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4411         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4412         command regardless of the prior command's exit status, so `:caminho \
4413         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4414         footgun where an author copies a `cd path; do-thing` chain without trimming \
4415         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4416         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4417         literal path-component byte, so the resolver folds the value through \
4418         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4419         subdirectory and fails at resolve time with a non-self-locating `No such file \
4420         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4421         the value verbatim in its per-dep content-address `path:{caminho}` at \
4422         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4423         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4424         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4425         canonical shell-metachar injection surface every peer single-token-shaped \
4426         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4427         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4428         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4429         workspace directory name carries no shell-command-separator semantic."
4430    )]
4431    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4432    #[error(
4433        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4434         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4435         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4436         terminator detaching the prior command and returning control immediately to \
4437         the prompt, double `&&` as the logical-AND list operator firing the next \
4438         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4439         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4440         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4441         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4442         05c358e closed the sequential-command-separator vector, this arm closes the \
4443         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4444         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4445         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4446         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4447         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4448         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4449         surface every peer single-token-shaped typed slot already closes. The peer \
4450         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4451         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4452         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4453         shell-background / logical-AND semantic."
4454    )]
4455    FonteCaminhoShellBackground { nome: String, caminho: String },
4456    #[error(
4457        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4458         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4459         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4460         wrapper that runs the enclosed command and substitutes its standard-output \
4461         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4462         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4463         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4464         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4465         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4466         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4467         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4468         background / logical-AND vector, this arm closes the orthogonal command-\
4469         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4470         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4471         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4472         value verbatim in its per-dep content-address `path:{caminho}` at \
4473         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4474         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4475         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4476         shell-metachar injection surface every peer single-token-shaped typed slot \
4477         already closes. The peer `:entrada :paths` axis rejects the byte via \
4478         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4479         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4480         directory name carries no shell-command-substitution semantic."
4481    )]
4482    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4483    #[error(
4484        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4485         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4486         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4487         expansion wildcards: `*` matches any sequence of characters in a path component \
4488         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4489         canonical paste-from-shell-listing footgun where an author copies a \
4490         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4491         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4492         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4493         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4494         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4495         locating `No such file or directory` error far from the source caixa.lisp. The \
4496         lacre pipeline embeds the value verbatim in its per-dep content-address \
4497         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4498         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4499         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4500         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4501         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4502         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4503         reserved set. Express the path as a bare relative single-token like \
4504         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4505         / pathname-expansion semantic.",
4506        ch = *byte as char
4507    )]
4508    FonteCaminhoShellGlob {
4509        nome: String,
4510        caminho: String,
4511        byte: u8,
4512    },
4513    #[error(
4514        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4515         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4516         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4517         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4518         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4519         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4520         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4521         arm closes the leading byte of — together the two arms now structurally exclude the \
4522         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4523         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4524         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4525         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4526         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4527         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4528         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4529         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4530         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4531         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4532         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4533         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4534         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4535         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4536         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4537         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4538         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4539         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4540         subshell-grouping semantic.",
4541        ch = *byte as char
4542    )]
4543    FonteCaminhoShellSubshellGrouping {
4544        nome: String,
4545        caminho: String,
4546        byte: u8,
4547    },
4548    #[error(
4549        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4550         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4551         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4552         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4553         comma-separated members and `{{1..10}}` expands to the integer range — the \
4554         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4555         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4556         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4557         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4558         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4559         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4560         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4561         `std::path::Path` treats the byte as a literal path-component byte, so a \
4562         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4563         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4564         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4565         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4566         silently passes every prior arm and the resolver folds the value through \
4567         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4568         resolve time with a non-self-locating `No such file or directory` error far from \
4569         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4570         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4571         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4572         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4573         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4574         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4575         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4576         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4577         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4578         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4579         directory name carries no shell-brace-expansion / URI-Template-placeholder \
4580         semantic; if two siblings actually need pinning, author two separate `:deps` \
4581         entries rather than one brace-expanded `:caminho` value.",
4582        ch = *byte as char
4583    )]
4584    FonteCaminhoShellBraceExpansion {
4585        nome: String,
4586        caminho: String,
4587        byte: u8,
4588    },
4589    #[error(
4590        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4591         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4592         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4593         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4594         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4595         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4596         glob every shell-history block carries; the bracket pair additionally carries the \
4597         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4598         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4599         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4600         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4601         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4602         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4603         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4604         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4605         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4606         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4607         leak) silently passes every prior arm and the resolver folds the value through \
4608         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4609         resolve time with a non-self-locating `No such file or directory` error far from \
4610         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4611         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4612         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4613         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4614         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4615         surface every peer single-token-shaped typed slot already closes. Express the path \
4616         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4617         directory name carries no shell-bracket-expansion / glob-character-class / array-\
4618         literal semantic; if a family of sibling caixas actually needs pinning, author \
4619         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4620        ch = *byte as char
4621    )]
4622    FonteCaminhoShellBracketExpansion {
4623        nome: String,
4624        caminho: String,
4625        byte: u8,
4626    },
4627    #[error(
4628        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4629         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4630         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4631         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4632         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4633         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4634         every path-with-embedded-whitespace paste block carries and the symmetric \
4635         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4636         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4637         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4638         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4639         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4640         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4641         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4642         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4643         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4644         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4645         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4646         production. POSIX `std::path::Path` treats the byte as a literal path-component \
4647         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4648         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4649         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4650         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4651         shape) silently passes every prior arm and the resolver folds the value through \
4652         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4653         resolve time with a non-self-locating `No such file or directory` error far from \
4654         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4655         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4656         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4657         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4658         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4659         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4660         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4661         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4662         `is_git_repo_url`). Express the path as a bare relative single-token like \
4663         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4664         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4665         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4666         quoting on the outer syntactic layer, so an inner quote pair would nest and \
4667         desugar to a broken layer).",
4668        ch = *byte as char
4669    )]
4670    FonteCaminhoShellQuoteGrouping {
4671        nome: String,
4672        caminho: String,
4673        byte: u8,
4674    },
4675    #[error(
4676        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4677         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4678         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4679         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4680         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4681         discarding the byte and everything after it to the end of the physical line \
4682         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4683         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4684         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4685         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4686         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4687         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4688         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4689         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4690         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4691         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4692         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4693         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4694         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4695         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4696         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4697         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4698         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4699         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4700         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4701         fails at resolve time with a non-self-locating `No such file or directory` \
4702         error far from the source caixa.lisp — while every downstream shell / YAML / \
4703         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4704         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4705         scalar disagree with the resolver on which directory the value names. The \
4706         lacre pipeline embeds the value verbatim in its per-dep content-address \
4707         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4708         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4709         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4710         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4711         fragment-delimiter surface every peer single-token-shaped typed slot already \
4712         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4713         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4714         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4715         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4716         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4717         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4718         and drop any `#fragment` tail entirely (fragment identifiers select \
4719         renderings, not directories, and `:caminho` names a directory).",
4720        ch = *byte as char
4721    )]
4722    FonteCaminhoShellComment {
4723        nome: String,
4724        caminho: String,
4725        byte: u8,
4726    },
4727    #[error(
4728        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4729         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4730         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4731         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4732         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4733         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4734         literally inside a URL value. The canonical paste-from-browser-address-bar \
4735         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4736         encoded README hyperlink / browser address bar / percent-encoded permalink \
4737         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4738         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4739         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4740         `std::path::Path` treats the byte as a literal path-component byte, so \
4741         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4742         resolve time with a non-self-locating `No such file or directory` error far \
4743         from the source caixa.lisp — while every downstream URL parser / shell printf \
4744         builtin / YAML directive parser silently reinterprets the byte to a different \
4745         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4746         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4747         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4748         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4749         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4750         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4751         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4752         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4753         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4754         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4755         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4756         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4757         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4758         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4759         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4760         printf-format-specifier / job-control-specifier surface every peer single-\
4761         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4762         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4763         `is_git_repo_url`). Express the path as a bare relative single-token like \
4764         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4765         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4766         any `%20` percent-encoded-space with a literal space then reject the whole \
4767         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4768         directory name never carries an embedded space in practice); drop any \
4769         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4770         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4771        ch = *byte as char
4772    )]
4773    FonteCaminhoUrlPercentEncoding {
4774        nome: String,
4775        caminho: String,
4776        byte: u8,
4777    },
4778    #[error(
4779        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4780         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4781         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4782         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4783         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4784         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4785         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4786         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4787         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4788         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4789         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4790         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4791         the byte is a first-class parser byte in nearly every config / templating / \
4792         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4793         `std::path::Path` treats the byte as a literal path-component byte, so the \
4794         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4795         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4796         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4797         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4798         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4799         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4800         subdirectory that fails at resolve time with a non-self-locating `No such file \
4801         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4802         the value verbatim in its per-dep content-address `path:{caminho}` at \
4803         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4804         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4805         time lock to two distinct BLAKE3 closures across two workstations whose \
4806         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4807         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4808         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4809         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4810         is the canonical CWE-78 shell-command-injection surface every peer single-\
4811         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4812         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4813         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4814         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4815         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4816         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4817         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4818         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4819         so every position — leading and embedded — is structurally rejected. Substitute \
4820         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4821         time, or express the path as a bare relative single-token like \
4822         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4823         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4824        ch = *byte as char
4825    )]
4826    FonteCaminhoShellVariableExpansion {
4827        nome: String,
4828        caminho: String,
4829        byte: u8,
4830    },
4831    #[error(
4832        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4833         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4834         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4835         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4836         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4837         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4838         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4839         and the substitution fires at every history-expansion-enabled shell context — \
4840         `set -o histexpand` is bash's default for interactive sessions and the layer \
4841         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4842         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4843         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4844         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4845         encodes it inside a query component via the 'special-query percent-encode set' \
4846         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4847         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4848         prefix — the paste-from-source-code idiom where an author copies \
4849         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4850         the string-literal boundary); the canonical English-typography emphasis / \
4851         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4852         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4853         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4854         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4855         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4856         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4857         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4858         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4859         repeat-prior-command paste idiom), the English-typography `:caminho \
4860         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4861         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4862         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4863         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4864         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4865         subdirectory that fails at resolve time with a non-self-locating `No such file \
4866         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4867         the value verbatim in its per-dep content-address `path:{caminho}` at \
4868         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4869         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4870         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4871         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4872         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4873         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4874         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4875         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4876         name carries no shell-history-expansion / bang-operator semantic; drop any \
4877         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4878         idiom; and drop any trailing English-typography exclamation mark that pasted \
4879         from prose.",
4880        ch = *byte as char
4881    )]
4882    FonteCaminhoShellHistoryExpansion {
4883        nome: String,
4884        caminho: String,
4885        byte: u8,
4886    },
4887    #[error(
4888        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4889         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4890         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4891         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4892         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4893         substitution' history operator that rewrites the prior command's `old` string to \
4894         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4895         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4896         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4897         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4898         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4899         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4900         literal value diverges from every downstream `feira tofu` curl-invocation / \
4901         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4902         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4903         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4904         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4905         `std::path::Path` treats `^` as a literal path-component byte, so \
4906         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4907         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4908         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4909         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4910         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4911         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4912         that fails at resolve time with a non-self-locating `No such file or directory` \
4913         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4914         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4915         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4916         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4917         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4918         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4919         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4920         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4921         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4922         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4923         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4924         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4925         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4926         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4927         drop any trailing `^` history-substitution-open fragment.",
4928        ch = *byte as char
4929    )]
4930    FonteCaminhoShellHistorySubstitution {
4931        nome: String,
4932        caminho: String,
4933        byte: u8,
4934    },
4935    #[error(
4936        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4937         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4938         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4939         value verbatim in its per-dep content-address `path:{caminho}` at \
4940         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4941         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4942         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4943         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4944         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4945         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4946         trailing `/`; every `:caminho` value names a sibling-workspace directory \
4947         already, so the trailing separator carries no information. Use \
4948         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4949    )]
4950    FonteCaminhoTrailingSlash { nome: String, caminho: String },
4951    #[error(
4952        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4953         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4954         apply the same set-not-multiset discipline; one package per table), and \
4955         two entries naming the same caixa carry two version constraints / source \
4956         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4957         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4958         silently overwrites the first at the resolver-side `concrete_versao` step, \
4959         and the dropped entry's pin / features never reach the closure — far from \
4960         the source caixa.lisp, with no field naming which `:deps` entry was the \
4961         silent loser. If two version constraints are genuinely needed (the rare \
4962         multi-version closure case the lacre pipeline doesn't yet support), the \
4963         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4964         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4965    )]
4966    DuplicateNome { nome: String, list: &'static str },
4967    #[error(
4968        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4969         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4970         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4971         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4972         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4973         with the canonical kebab-case feature name the target caixa declares."
4974    )]
4975    CaracteristicaEmpty { nome: String },
4976    #[error(
4977        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4978         feature name: {reason} (the value flows verbatim into Cargo's \
4979         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4980         parser enforces the same shape at `cargo metadata` time; use a single-token \
4981         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4982         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4983         an ASCII alphanumeric or `_`)"
4984    )]
4985    CaracteristicaInvalid {
4986        nome: String,
4987        caracteristica: String,
4988        reason: String,
4989    },
4990    #[error(
4991        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4992         every feature-flag list keys its entries by name (Cargo's \
4993         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4994         per feature per dep), and two entries naming the same feature are a redundant \
4995         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4996         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4997         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4998         feature once regardless of declaration count, so the duplicate's pin / position never \
4999         reaches the closure with no field naming the silent loser. One entry per feature per \
5000         dep; if two distinct features are intended, name each verbatim."
5001    )]
5002    CaracteristicaDuplicate {
5003        nome: String,
5004        caracteristica: String,
5005    },
5006    #[error(
5007        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5008         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5009         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5010         rejects mid-traversal far from the source caixa.lisp or recurses on until \
5011         it exhausts its stack). Every :nome is globally-unique substrate identity, \
5012         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5013         *is* the parent itself, not a coincidentally-named peer. Drop the \
5014         self-referential dep entry — to reference code from this caixa, use \
5015         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5016         referencing the caixa's own code surface) instead."
5017    )]
5018    DepIsSelf { nome: String, list: &'static str },
5019}
5020
5021// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5022// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5023// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5024// variant — the paired `{ nome: String, caminho: String }` two-slot family
5025// on [`DepError`], sibling of the peer
5026// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5027// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5028// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5029// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5030// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5031// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5032// `{ de, para, wit, expected }`), and
5033// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5034// variants on `{ de, para, <field>: String, reason: String }`) on the
5035// `AplicacaoError` envelopes, the peer
5036// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5037// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5038// (0419438, 4 variants on `{ caixa, kind, slots }`),
5039// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5040// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5041// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5042// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5043// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5044// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5045// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5046// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5047//
5048// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5049// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5050// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5051// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5052// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5053// CommandSubstitution}` on the four single-byte shell operators; and the
5054// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5055// opened the identical `DepError::FonteCaminho<Variant> { nome:
5056// nome.to_string(), caminho: caminho.to_string() }` four-line
5057// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5058// — the exact "same block re-inlined at every consumer" shape the PRIME
5059// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5060// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5061// families each closed on their sibling envelopes. The eleven variants
5062// share one `{ nome: String, caminho: String }` shape, so the fold routes
5063// each wire-up site through one dispatch per typed variant.
5064//
5065// The macro below generates one `#[must_use]` inherent constructor per
5066// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5067// wire-up site collapses onto one dispatch:
5068// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5069// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5070// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5071// once — inside the macro — rather than at every wire-up site.
5072//
5073// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5074// shapes at the per-byte-classification arms — the
5075// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5076// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5077// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5078// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5079// cluster — carry an additional `byte: u8` naming the offending byte and
5080// so would break the uniform-two-field routing this macro promises. They
5081// instead fold onto the sibling three-field envelope through
5082// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5083// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5084// two-slot family is the `byte: u8` classification the arms carry. The
5085// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5086// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5087// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5088// envelope.
5089//
5090// Every future consumer that wants to construct one of these eleven
5091// variants outside the current in-crate [`DepSource::validate_caminho`]
5092// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5093// at lacre-resolve time re-checking the same value-shape axes the resolver
5094// consumes, a future `feira validate --deps` per-caixa admission verb
5095// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5096// rejecting a `:caminho` value against a cluster-local snapshot) now
5097// reaches each variant through one call rather than re-inlining the
5098// four-line struct-literal in lockstep with the eleven in-crate wire-up
5099// sites.
5100macro_rules! fonte_caminho_ctors {
5101    ($($ctor:ident => $variant:ident),* $(,)?) => {
5102        impl DepError {
5103            $(
5104                #[doc = concat!(
5105                    "Construct a [`DepError::",
5106                    stringify!($variant),
5107                    "`] naming the offending `:deps :nome` + `:fonte ",
5108                    "(:tipo path …) :caminho` pair. Folds the uniform ",
5109                    "`Self::",
5110                    stringify!($variant),
5111                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5112                    "two-slot struct-literal onto one substrate primitive so ",
5113                    "every [`DepSource::validate_caminho`] wire-up on this ",
5114                    "variant reads through one dispatch rather than the ",
5115                    "pre-lift four-line open-coded block."
5116                )]
5117                #[must_use]
5118                pub fn $ctor(nome: &str, caminho: &str) -> Self {
5119                    Self::$variant {
5120                        nome: nome.to_string(),
5121                        caminho: caminho.to_string(),
5122                    }
5123                }
5124            )*
5125        }
5126    };
5127}
5128
5129fonte_caminho_ctors! {
5130    fonte_caminho_absolute => FonteCaminhoAbsolute,
5131    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5132    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5133    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5134    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5135    fonte_caminho_backslash => FonteCaminhoBackslash,
5136    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5137    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5138    fonte_caminho_shell_background => FonteCaminhoShellBackground,
5139    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5140    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5141}
5142
5143// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5144// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5145// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5146// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5147// three-slot family on [`DepError`], strict sibling of the peer
5148// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5149// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5150// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5151// axis broke its uniform-two-field routing — the exact "future compounding
5152// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5153// here. Third fold family on this `DepError` envelope, sibling of the peer
5154// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5155// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5156// same enum.
5157//
5158// Each of the twelve wire-up sites on this shape (the control-byte arm
5159// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5160// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5161// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5162// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5163// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5164// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5165// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5166// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5167// `FonteCaminhoShellHistoryExpansion` on `!`, and
5168// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5169// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5170// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5171// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5172// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5173// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5174// closed on the sibling two-field envelope of this same enum. The twelve
5175// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5176// the fold routes each wire-up site through one dispatch per typed variant.
5177//
5178// The macro below generates one `#[must_use]` inherent constructor per
5179// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5180// so every wire-up site collapses onto one dispatch:
5181// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5182// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5183// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5184// `byte`) is spelled once — inside the macro — rather than at every wire-up
5185// site.
5186//
5187// Every future consumer that wants to construct one of these twelve
5188// variants outside the current in-crate [`DepSource::validate_caminho`]
5189// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5190// at lacre-resolve time re-checking the same value-shape axes the resolver
5191// consumes, a future `feira validate --deps` per-caixa admission verb
5192// re-checking the `:fonte :caminho` axis against the shell-metachar
5193// classification bytes this cluster catches, a per-lacre overlay resolver
5194// rejecting a `:caminho` value against a cluster-local snapshot) now
5195// reaches each variant through one call rather than re-inlining the
5196// five-line struct-literal in lockstep with the twelve in-crate wire-up
5197// sites.
5198macro_rules! fonte_caminho_byte_ctors {
5199    ($($ctor:ident => $variant:ident),* $(,)?) => {
5200        impl DepError {
5201            $(
5202                #[doc = concat!(
5203                    "Construct a [`DepError::",
5204                    stringify!($variant),
5205                    "`] naming the offending `:deps :nome` + `:fonte ",
5206                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5207                    "classification. Folds the uniform `Self::",
5208                    stringify!($variant),
5209                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5210                    "byte }` three-slot struct-literal onto one substrate ",
5211                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5212                    "on this variant reads through one dispatch rather than ",
5213                    "the pre-lift five-line open-coded block."
5214                )]
5215                #[must_use]
5216                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5217                    Self::$variant {
5218                        nome: nome.to_string(),
5219                        caminho: caminho.to_string(),
5220                        byte,
5221                    }
5222                }
5223            )*
5224        }
5225    };
5226}
5227
5228fonte_caminho_byte_ctors! {
5229    fonte_caminho_control_char => FonteCaminhoControlChar,
5230    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5231    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5232    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5233    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5234    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5235    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5236    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5237    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5238    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5239    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5240    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5241}
5242
5243// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5244// single-slot struct-variant wire-up sites scattered across
5245// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5246// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5247// substrate primitive per typed variant — the paired `{ nome: String }`
5248// single-slot family on [`DepError`], sibling of the peer
5249// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5250// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5251// the same enum, and of the peer
5252// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5253// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5254// axis. Second fold family on this `DepError` envelope, and the first on
5255// the single-`{ nome }` shape.
5256//
5257// The five wire-up sites this fold closes each opened the identical
5258// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5259// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5260// local — the exact "same block re-inlined at every consumer" shape the
5261// PRIME DIRECTIVE names as a bug. The five variants share one
5262// `{ nome: String }` shape, so the fold routes each wire-up site through
5263// one dispatch per typed variant.
5264//
5265// The macro below generates one `#[must_use]` inherent constructor per
5266// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5267// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5268// pre-lift struct-literal on the same `&str` fixture. The uniform
5269// one-field construction (`nome.to_string()`) is spelled once — inside
5270// the macro — rather than at every wire-up site. Callers that hold a
5271// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5272// and lets the macro-owned `.to_string()` produce the fresh owning copy
5273// the enum variant needs; the semantics collapse onto the same
5274// `.clone()`-equivalent one this fold replaces at every site.
5275//
5276// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5277// on the same envelope stays on its pre-lift open-coded wire-up shape —
5278// it carries no `nome` field (the offending `:nome` value *is* the empty
5279// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5280// signature this macro promises does not apply. Every future consumer
5281// that wants to construct one of these five variants outside the current
5282// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5283// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5284// re-validator at lacre-resolve time, a future `feira validate --deps`
5285// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5286// these empty-value shapes against a cluster-local snapshot) now reaches
5287// each variant through one call rather than re-inlining the three-line
5288// struct-literal in lockstep with the five in-crate wire-up sites.
5289macro_rules! dep_nome_only_ctors {
5290    ($($ctor:ident => $variant:ident),* $(,)?) => {
5291        impl DepError {
5292            $(
5293                #[doc = concat!(
5294                    "Construct a [`DepError::",
5295                    stringify!($variant),
5296                    "`] naming the offending `:deps :nome`. Folds the ",
5297                    "uniform `Self::",
5298                    stringify!($variant),
5299                    " { nome: nome.to_string() }` one-field ",
5300                    "struct-literal onto one substrate primitive so every ",
5301                    "in-crate wire-up on this variant reads through one ",
5302                    "dispatch rather than the pre-lift three-line ",
5303                    "open-coded block."
5304                )]
5305                #[must_use]
5306                pub fn $ctor(nome: &str) -> Self {
5307                    Self::$variant { nome: nome.to_string() }
5308                }
5309            )*
5310        }
5311    };
5312}
5313
5314dep_nome_only_ctors! {
5315    versao_empty => VersaoEmpty,
5316    fonte_repo_empty => FonteRepoEmpty,
5317    fonte_pin_missing => FontePinMissing,
5318    fonte_caminho_empty => FonteCaminhoEmpty,
5319    caracteristica_empty => CaracteristicaEmpty,
5320}
5321
5322// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5323// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5324// [`crate::manifest::Caixa::validate_deps`] +
5325// [`validate_no_self_dep`] onto one substrate-primitive family per
5326// typed variant — the `DepError`-side siblings of the peer
5327// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5328// on the `SupervisorError { caixa: String }` one-slot envelope and of
5329// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5330// `DepError { nome: String }` one-slot envelope. The two variants
5331// carry the same `{ nome: String, list: &'static str }` two-slot
5332// shape: the `nome` field names the offending dep the diagnostic
5333// points the author back at, and the `list` field carries the
5334// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5335// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5336// [`validate_deps`] arms, and via the paired
5337// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5338// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5339// canonicals on the [`validate_no_self_dep`] arm) so the author can
5340// grep their caixa.lisp for the offending list block in one edit.
5341//
5342// Each of the four wire-up sites opened the same struct-literal
5343// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5344// two-line block — the exact "same block re-inlined at every
5345// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5346// altitude the peer `DepError` / `SupervisorError` /
5347// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5348// already closed on their sibling envelopes. The two `#[must_use]`
5349// inherent constructors below fold each wire-up onto one dispatch:
5350// `DepError::duplicate_nome(<nome>, <list>)` and
5351// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5352// pre-lift struct-literal on the same scalar fixtures. The `list:
5353// &'static str` parameter (not `impl Into<String>`) preserves the
5354// exact wire tag every consumer already passes verbatim — no
5355// downstream diagnostic reshaping at the lift, matching the peer
5356// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5357// contract each wire-up site already keys off.
5358macro_rules! dep_nome_list_ctors {
5359    ($($ctor:ident => $variant:ident),* $(,)?) => {
5360        impl DepError {
5361            $(
5362                #[doc = concat!(
5363                    "Construct a [`DepError::",
5364                    stringify!($variant),
5365                    "`] naming the offending `:deps :nome` and the ",
5366                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5367                    "the diagnostic points the author back at. Folds ",
5368                    "the uniform `Self::",
5369                    stringify!($variant),
5370                    " { nome: nome.to_string(), list }` two-field ",
5371                    "struct-literal onto one substrate primitive so ",
5372                    "every in-crate wire-up on this variant reads ",
5373                    "through one dispatch rather than the pre-lift ",
5374                    "open-coded struct-literal block."
5375                )]
5376                #[must_use]
5377                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5378                    Self::$variant { nome: nome.to_string(), list }
5379                }
5380            )*
5381        }
5382    };
5383}
5384
5385dep_nome_list_ctors! {
5386    duplicate_nome => DuplicateNome,
5387    dep_is_self => DepIsSelf,
5388}
5389
5390// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5391// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5392// <value>.to_string(), reason }` struct-variant wire-up sites at
5393// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5394// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5395// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5396// primitive family per typed variant — the `DepError`-side siblings of the
5397// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5398// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5399// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5400// the two-slot `{ nome, caminho }` envelope, and
5401// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5402// caminho, byte }` envelope. The three variants share the same
5403// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5404// the `nome` field names the offending dep the diagnostic points the
5405// author back at, the middle `<axis>: String` field carries the offending
5406// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5407// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5408// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5409// field carries the parser-shaped rejection sentence the paired
5410// [`crate::render::require_valid_versao_requirement`] /
5411// [`crate::render::is_git_repo_url`] /
5412// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5413// axis-field name differs across variants (`versao` / `repo` /
5414// `caracteristica`) so the ctor family below takes the axis field name as
5415// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5416// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5417// -> Self` inherent constructor per typed variant that spells the uniform
5418// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5419// `reason` forwarded owned) exactly once. Peer of the sibling
5420// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5421// family on the `AplicacaoError` envelope's mirror-symmetric
5422// `{ <field>: String, reason: String }` two-slot shape — same
5423// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5424// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5425// envelope keys off (every `DepError` variant carries the offending
5426// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5427// offending block in one edit).
5428//
5429// The three wire-up sites this fold closes are:
5430// - [`DepSource::validate`]'s `:repo` value-shape arm
5431//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5432//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5433//   rejects the offending URL);
5434// - [`Dep::validate`]'s `:versao` requirement-shape arm
5435//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5436//   self.versao_requirement().to_string(), reason }` inside the
5437//   [`crate::render::require_valid_versao_requirement`] callback pair);
5438// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5439//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5440//   caracteristica: c.clone(), reason })` after
5441//   [`crate::render::is_cargo_feature_name`] rejects the offending
5442//   feature-name).
5443//
5444// Each opened the identical five-line struct-literal against the same
5445// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5446// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5447// same altitude the peer four already-lifted `DepError` ctor families
5448// closed on their sibling shape-envelopes. The three variant / axis-field
5449// discriminators are the only things that vary between them; the rest of
5450// the struct-literal is a byte-for-byte re-inline.
5451//
5452// Every future consumer wanting to raise one of these three diagnostics
5453// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5454// time re-checking each declared dep against the same requirement +
5455// git-URL + feature-name value-shape cascade, a future `feira validate
5456// --deps` per-caixa admission verb re-running the shape gates on demand,
5457// a per-lacre overlay resolver rejecting an author-supplied dep against a
5458// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5459// the five-line struct-literal in lockstep with the three in-crate
5460// wire-up sites.
5461macro_rules! dep_nome_axis_reason_ctors {
5462    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5463        impl DepError {
5464            $(
5465                #[doc = concat!(
5466                    "Construct a [`DepError::",
5467                    stringify!($variant),
5468                    "`] naming the offending `:deps :nome`, the offending ",
5469                    "`:", stringify!($axis), "` axis value, and the ",
5470                    "parser-shaped rejection `reason`. Folds the uniform ",
5471                    "`Self::",
5472                    stringify!($variant),
5473                    " { nome: nome.to_string(), ",
5474                    stringify!($axis),
5475                    ": ",
5476                    stringify!($axis),
5477                    ".to_string(), reason }` three-field struct-literal ",
5478                    "onto one substrate primitive so every in-crate ",
5479                    "wire-up on this variant reads through one dispatch ",
5480                    "rather than the pre-lift five-line open-coded block. ",
5481                    "The `nome: &str` and `",
5482                    stringify!($axis),
5483                    ": &str` parameters accept `&str` literals and ",
5484                    "`&String` (via Deref coercion) so every existing ",
5485                    "wire-up threads through the ctor without a ",
5486                    "pre-conversion; the `reason: String` parameter takes ",
5487                    "an owned `String` (not `impl Into<String>`) matching ",
5488                    "the paired `crate::render::*` predicate's ",
5489                    "`Result<(), String>` return shape every wire-up ",
5490                    "already holds owned at the call site."
5491                )]
5492                #[must_use]
5493                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5494                    Self::$variant {
5495                        nome: nome.to_string(),
5496                        $axis: $axis.to_string(),
5497                        reason,
5498                    }
5499                }
5500            )*
5501        }
5502    };
5503}
5504
5505dep_nome_axis_reason_ctors! {
5506    versao_invalid => VersaoInvalid { versao },
5507    fonte_repo_shape => FonteRepoShape { repo },
5508    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5509}
5510
5511// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5512// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5513// <value>.to_string() }` struct-variant wire-up sites at
5514// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5515// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5516// per-entry set-not-multiset dedup closure onto one substrate-primitive
5517// family per typed variant — the missing two-slot rung on the
5518// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5519// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5520// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5521// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5522// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5523// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5524// symmetric sibling of the peer
5525// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5526// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5527// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5528// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5529// owned altitude the `DepError` envelope keys off (every `DepError`
5530// variant carries the offending `:deps :nome` verbatim so the author
5531// can grep their caixa.lisp for the offending block in one edit). The
5532// three variants share the same `{ nome: String, <axis>: String }`
5533// two-slot shape: the `nome` field names the offending dep the
5534// diagnostic points the author back at, and the middle `<axis>:
5535// String` field carries the offending per-envelope axis value verbatim
5536// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5537// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5538// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5539// The middle axis-field name differs across variants (`pin` / `pins` /
5540// `caracteristica`) so the ctor family below takes the axis field name
5541// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5542// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5543// Self` inherent constructor per typed variant that spells the
5544// uniform two-field construction (`nome.to_string()` /
5545// `<axis>.to_string()`) exactly once.
5546//
5547// The three wire-up sites this fold closes are:
5548// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5549//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5550//   pin.to_string() });` inside the `set.len() == 1` branch after the
5551//   `is_some_and(String::is_empty)` iterator);
5552// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5553//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5554//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5555// - [`Dep::validate_caracteristicas`]'s per-entry
5556//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5557//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5558//   [`crate::render::insert_first_seen`]).
5559//
5560// Each opened the identical four-line struct-literal against the same
5561// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5562// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5563// same altitude the peer four already-lifted `DepError` ctor families
5564// closed on their sibling shape-envelopes. The three variant / axis-
5565// field discriminators are the only things that vary between them;
5566// the rest of the struct-literal is a byte-for-byte re-inline.
5567//
5568// Every future consumer wanting to raise one of these three
5569// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5570// at lacre-resolve time re-checking each declared dep against the
5571// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5572// set-not-multiset cascade, a future `feira validate --deps` per-
5573// caixa admission verb re-running the shape gates on demand, a
5574// per-lacre overlay resolver rejecting an author-supplied dep against
5575// a cluster-local snapshot the M4 CR materializer projects) now
5576// reaches one dispatch rather than re-inlining the four-line struct-
5577// literal in lockstep with the three in-crate wire-up sites.
5578macro_rules! dep_nome_axis_ctors {
5579    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5580        impl DepError {
5581            $(
5582                #[doc = concat!(
5583                    "Construct a [`DepError::",
5584                    stringify!($variant),
5585                    "`] naming the offending `:deps :nome` and the ",
5586                    "offending `:", stringify!($axis), "` axis value. ",
5587                    "Folds the uniform `Self::",
5588                    stringify!($variant),
5589                    " { nome: nome.to_string(), ",
5590                    stringify!($axis),
5591                    ": ",
5592                    stringify!($axis),
5593                    ".to_string() }` two-field struct-literal onto one ",
5594                    "substrate primitive so every in-crate wire-up on ",
5595                    "this variant reads through one dispatch rather than ",
5596                    "the pre-lift four-line open-coded block. Both `nome: ",
5597                    "&str` and `",
5598                    stringify!($axis),
5599                    ": &str` parameters accept `&str` literals and ",
5600                    "`&String` (via Deref coercion) so every existing ",
5601                    "wire-up threads through the ctor without a pre-",
5602                    "conversion."
5603                )]
5604                #[must_use]
5605                pub fn $ctor(nome: &str, $axis: &str) -> Self {
5606                    Self::$variant {
5607                        nome: nome.to_string(),
5608                        $axis: $axis.to_string(),
5609                    }
5610                }
5611            )*
5612        }
5613    };
5614}
5615
5616dep_nome_axis_ctors! {
5617    fonte_pin_empty => FontePinEmpty { pin },
5618    fonte_pin_ambiguous => FontePinAmbiguous { pins },
5619    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5620}
5621
5622// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5623// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5624// struct-variant wire-up sites at [`DepSource::validate`]'s
5625// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5626// the `DepError` envelope — the last open-coded ctor site remaining on
5627// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5628// carries, and the single-variant sibling of the peer four already-
5629// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5630// on the two-slot `{ nome, caminho }` envelope,
5631// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5632// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5633// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5634// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5635// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5636// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5637// `{ …, value: String, reason: String }` payload shape, one axis
5638// removed at the `nome`-only-owner altitude the `DepError` envelope
5639// keys off (no `edge_pair()` de/para pair).
5640//
5641// The two wire-up sites this fold closes are the paired refname-pin
5642// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5643// pin: pin.to_string(), value: v.clone(), reason }` inside the
5644// `[(":tag", tag), (":branch", branch)]` iterator against
5645// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5646// (`|| DepError::FontePinShape { nome: nome.to_string(),
5647// pin: ":rev".to_string(), value: v.clone(), reason }` against
5648// [`crate::render::is_git_oid`]) — each opened the identical
5649// `DepError::FontePinShape { … }` six-line struct-literal against the
5650// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5651// tuple, the exact "same block re-inlined at every consumer" shape
5652// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5653// the only thing that varies between them (`":tag"`/`":branch"` on
5654// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5655// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5656// route through the same ctor because their `pin` field carries the
5657// author-surface tag verbatim (matching the `FontePinEmpty` /
5658// `FontePinAmbiguous` sibling variants' `pin: String` axis
5659// convention), so the offending author can grep their caixa.lisp for
5660// the offending `:tag "<value>"` / `:branch "<value>"` /
5661// `:rev "<value>"` literal in one edit.
5662//
5663// The single ctor below folds each wire-up onto one dispatch:
5664// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5665// the pre-lift struct-literal on the same `(&str, &str, &str,
5666// String)` fixture. The uniform four-field construction
5667// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5668// `reason` forwarded owned) is spelled once here rather than at every
5669// wire-up site. The `reason: String` field takes an owned `String`
5670// (not `impl Into<String>`) matching the two call sites' pre-existing
5671// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5672// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5673// predicates return `Result<(), String>`, so the caller always holds
5674// an owned `String` at the wire-up site and threading it through the
5675// ctor without a `.into()` shim keeps the routing shape byte-equal to
5676// the pre-lift block. The `value: &str` parameter accepts both `&str`
5677// literals (unused today) and `&String` (from the caller-held
5678// `v: &String` on each arm, via Deref coercion), so every existing
5679// wire-up threads through the ctor without a pre-conversion.
5680//
5681// Every future consumer that wants to construct this variant outside
5682// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5683// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5684// re-checking the same value-shape axes the resolver consumes, a
5685// future `feira validate --deps` per-caixa admission verb re-checking
5686// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5687// resolver rejecting a git-pin value against a cluster-local
5688// snapshot) now reaches this variant through one call rather than
5689// re-inlining the six-line struct-literal in lockstep with the two
5690// in-crate wire-up sites.
5691impl DepError {
5692    /// Construct a [`DepError::FontePinShape`] naming the offending
5693    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5694    /// axis tag, the offending value, and the parser-shaped `reason`.
5695    /// Folds the uniform
5696    /// `Self::FontePinShape { nome: nome.to_string(),
5697    /// pin: pin.to_string(), value: value.to_string(), reason }`
5698    /// four-field struct-literal onto one substrate primitive so
5699    /// every [`DepSource::validate`] wire-up on this variant reads
5700    /// through one dispatch rather than the pre-lift six-line
5701    /// open-coded block. The `nome` string threads verbatim from
5702    /// [`Dep::nome`] at the call site; the `pin` string carries the
5703    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5704    /// `value` string carries the offending refname / hex-OID
5705    /// verbatim; and `reason` forwards the owned `String` returned
5706    /// by [`crate::render::is_git_ref_name`] /
5707    /// [`crate::render::is_git_oid`] without a `.into()` shim.
5708    #[must_use]
5709    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5710        Self::FontePinShape {
5711            nome: nome.to_string(),
5712            pin: pin.to_string(),
5713            value: value.to_string(),
5714            reason,
5715        }
5716    }
5717
5718    /// Construct a [`DepError::NomeInvalid`] naming the offending
5719    /// `:deps :nome` byte-string and the parser-shaped rejection
5720    /// `reason` returned by [`crate::render::is_dns_1123_label`].
5721    ///
5722    /// Folds the uniform
5723    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5724    /// struct-literal onto one substrate primitive so every wire-up on
5725    /// this variant reads through one dispatch rather than the pre-lift
5726    /// four-line open-coded `DepError::NomeInvalid { nome:
5727    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5728    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5729    /// ctor-family ladder (`{ nome }` one-slot →
5730    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5731    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5732    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5733    /// `{ nome, <axis>: String, reason: String }` three-slot →
5734    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5735    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5736    /// — the sole variant on the envelope carrying the
5737    /// `{ nome: String, reason: String }` two-slot shape without a
5738    /// middle axis, matching the peer
5739    /// [`crate::manifest::ManifestError::NomeInvalid`] +
5740    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5741    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5742    /// four-axis DNS-1123 caixa-identifier diagnostic family the
5743    /// existing `nome_invalid_diagnostic_carries_offending_name` test
5744    /// pins on this envelope.
5745    ///
5746    /// The `nome: &str` parameter accepts `&str` literals and `&String`
5747    /// (via Deref coercion) so the sole in-crate wire-up threads through
5748    /// the ctor without a pre-conversion; the `reason: String`
5749    /// parameter takes an owned `String` (not `impl Into<String>`)
5750    /// matching the [`crate::render::is_dns_1123_label`] predicate's
5751    /// `Result<(), String>` return shape the sole wire-up site already
5752    /// holds owned at the call site, keeping the routing byte-equal to
5753    /// the pre-lift block. Same owned-`String`-forward `reason` payload
5754    /// discipline as the sibling three-slot family
5755    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5756    /// and the four-slot [`DepError::fonte_pin_shape`] on
5757    /// `{ nome, pin, value, reason }`.
5758    ///
5759    /// Every future consumer that raises the same diagnostic outside
5760    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5761    /// re-validator at lacre-resolve time re-checking each declared
5762    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5763    /// side schema uses (the `:nome` value flows verbatim as the target
5764    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5765    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5766    /// checkout-directory leaf), a future `feira validate --deps`
5767    /// per-caixa admission verb re-running the shape gate on demand, a
5768    /// per-lacre overlay resolver rejecting an author-supplied dep's
5769    /// `:nome` against a cluster-local snapshot the M4 CR materializer
5770    /// projects, a future authoring-surface widening the field into a
5771    /// `(String, Vec<Suggestion>)` pair carrying a
5772    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5773    /// variant through one call rather than re-inlining the four-line
5774    /// struct-literal in lockstep with the one in-crate wire-up site.
5775    #[must_use]
5776    pub fn nome_invalid(nome: &str, reason: String) -> Self {
5777        Self::NomeInvalid {
5778            nome: nome.to_string(),
5779            reason,
5780        }
5781    }
5782}
5783
5784#[allow(clippy::trivially_copy_pass_by_ref)]
5785fn is_false(b: &bool) -> bool {
5786    !*b
5787}
5788
5789#[cfg(test)]
5790mod tests {
5791    use super::*;
5792
5793    #[test]
5794    fn registry_dep_is_minimal() {
5795        let d = Dep::simple("caixa-teia", "^0.1");
5796        assert_eq!(d.nome, "caixa-teia");
5797        assert_eq!(d.versao, "^0.1");
5798        assert!(d.fonte.is_none());
5799        assert!(!d.opcional());
5800        assert!(d.caracteristicas().is_empty());
5801    }
5802
5803    #[test]
5804    fn dep_string_scalar_accessor_pair_is_const_fn() {
5805        // Fail-before-pass-after pin on [`Dep::nome`] +
5806        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5807        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5808        // entry's [`String`] storage through the `pub const fn`
5809        // [`String::as_str`] (const-stable since Rust 1.87, well
5810        // within the workspace MSRV) — any future accidental
5811        // downgrade to non-`const` fails the corresponding
5812        // `<name>_via_const_fn` wrapper at caixa-core build time with
5813        // E0015 (`cannot call non-const method`), strictly stronger
5814        // than a runtime `assert!`. Sibling of the peer
5815        // per-M2/M3/universal-axis `String → &str` scalar-accessor
5816        // family pins on the sibling `const`-eval-surface passes
5817        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5818        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5819        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5820        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5821        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5822        // [`crate::aplicacao::Entrada::destination`] at the M3
5823        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5824        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5825        // M2 supervisor-tree axis,
5826        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5827        // M2 upgrade axis, and the per-`:contratos`
5828        // [`crate::aplicacao::WitContract::source`] /
5829        // [`crate::aplicacao::WitContract::destination`] /
5830        // [`crate::aplicacao::WitContract::world_ref`] trio the
5831        // sibling pin at 279823b already anchors).
5832        const fn nome_via_const_fn(d: &Dep) -> &str {
5833            d.nome()
5834        }
5835        const fn versao_via_const_fn(d: &Dep) -> &str {
5836            d.versao_requirement()
5837        }
5838        for (nome, versao) in [
5839            ("caixa-teia", "^0.1"),
5840            ("caixa-mesh", "~0.2.3"),
5841            ("caixa-helm", "*"),
5842        ] {
5843            let d = Dep::simple(nome, versao);
5844            assert_eq!(nome_via_const_fn(&d), d.nome());
5845            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5846            assert_eq!(d.nome(), nome);
5847            assert_eq!(d.versao_requirement(), versao);
5848        }
5849    }
5850
5851    #[test]
5852    fn dep_outer_accessor_family_is_const_fn() {
5853        // Fail-before-pass-after pin on [`Dep::fonte`] +
5854        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5855        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5856        // entry's composite / list storage through a `pub const fn`
5857        // stdlib method (`Option::<DepSource>::as_ref` /
5858        // `Vec::<String>::as_slice`, both const-stable since Rust
5859        // 1.83, well within the workspace MSRV). Any future
5860        // accidental downgrade to non-`const` fails the corresponding
5861        // `<name>_via_const_fn` wrapper at caixa-core build time with
5862        // E0015 (`cannot call non-const method`), strictly stronger
5863        // than a runtime `assert!` and side-stepping the destructor-
5864        // in-const restriction the `Dep` fixture's `String` /
5865        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5866        // direct-`const _: () = assert!(...)` residence.
5867        //
5868        // Peer of the sibling per-`Dep` scalar-accessor pair pin
5869        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5870        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5871        // the `const`-eval-surface discipline onto the composite-
5872        // reference and slice-return arms of the outer-`Dep` accessor
5873        // family, closing the four-slot outer surface (`:nome` +
5874        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5875        // posture. The `:opcional` `bool` arm already carries the
5876        // posture through [`Dep::opcional`]'s prior `pub const fn`
5877        // declaration, so this pin lands the last two unlifted
5878        // outer-`Dep` accessors and closes the family.
5879        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5880            d.fonte()
5881        }
5882        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5883            d.caracteristicas()
5884        }
5885        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5886        let empty = Dep::simple("caixa-teia", "^0.1");
5887        assert!(fonte_via_const_fn(&empty).is_none());
5888        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5889        assert!(caracteristicas_via_const_fn(&empty).is_empty());
5890        assert_eq!(
5891            caracteristicas_via_const_fn(&empty),
5892            empty.caracteristicas()
5893        );
5894        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5895        // still empty.
5896        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5897        assert!(fonte_via_const_fn(&git).is_some());
5898        assert_eq!(fonte_via_const_fn(&git), git.fonte());
5899        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5900        // Populated `:caracteristicas` — exercise the non-empty
5901        // slice-view arm to pin the accessor's borrow shape against
5902        // both a `Vec::new()` empty backing buffer and a populated one.
5903        let mut with_features = Dep::simple("caixa-teia", "^0.1");
5904        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5905        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5906        assert_eq!(
5907            caracteristicas_via_const_fn(&with_features),
5908            with_features.caracteristicas()
5909        );
5910    }
5911
5912    #[test]
5913    fn git_dep_carries_tag() {
5914        let d = Dep::git("t", "*", "github:o/r", "v1");
5915        match d.fonte {
5916            Some(DepSource::Git {
5917                ref repo, ref tag, ..
5918            }) => {
5919                assert_eq!(repo, "github:o/r");
5920                assert_eq!(tag.as_deref(), Some("v1"));
5921            }
5922            _ => panic!("expected Git source"),
5923        }
5924    }
5925
5926    #[test]
5927    fn validate_accepts_simple_dep() {
5928        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5929    }
5930
5931    #[test]
5932    fn validate_rejects_empty_nome() {
5933        // The fail-before-pass-after pin for `:nome ""`: the empty-name
5934        // arm fires first so the per-entry parse-side diagnostic doesn't
5935        // emit a useless `nome: ""` reference.
5936        let mut d = Dep::simple("placeholder", "^0.1");
5937        d.nome = String::new();
5938        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5939    }
5940
5941    #[test]
5942    fn validate_rejects_empty_versao() {
5943        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5944        // semver crate accepts the empty string as a wildcard match),
5945        // so the empty-`:versao` arm is structurally necessary even
5946        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5947        // `EmptyChildVersion` ordering on the other two `:versao` axes.
5948        let mut d = Dep::simple("caixa-teia", "ignored");
5949        d.versao = String::new();
5950        let err = d.validate().unwrap_err();
5951        assert!(
5952            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5953            "got {err:?}"
5954        );
5955    }
5956
5957    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5958
5959    #[test]
5960    fn validate_rejects_nome_with_uppercase() {
5961        // The fail-before-pass-after pin: a non-empty but uppercase
5962        // `:nome` silently passed `validate()` on every pre-gate
5963        // codebase because the prior shape only refused the empty
5964        // string. The DNS-1123 violation surfaced far downstream at
5965        // lacre-resolve time when the *target* caixa's `:nome` failed
5966        // its own gate — far from the `:deps` entry, with a diagnostic
5967        // naming the target rather than the dep entry that referenced
5968        // it. Same fail-before-pass-after fixture pinned for
5969        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5970        // and Caixa `:nome` (6c992f8).
5971        let d = Dep::simple("Caixa-Teia", "^0.1");
5972        let err = d.validate().unwrap_err();
5973        assert!(
5974            matches!(
5975                err,
5976                DepError::NomeInvalid { ref nome, ref reason }
5977                    if nome == "Caixa-Teia" && reason.contains("uppercase")
5978            ),
5979            "got {err:?}"
5980        );
5981    }
5982
5983    #[test]
5984    fn validate_rejects_nome_with_underscore() {
5985        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5986        // "I'm thinking of Go module names / Python identifiers" leak.
5987        // Same fixture pinned for the peer caixa-identifier axes.
5988        let d = Dep::simple("caixa_teia", "^0.1");
5989        let err = d.validate().unwrap_err();
5990        assert!(
5991            matches!(
5992                err,
5993                DepError::NomeInvalid { ref nome, ref reason }
5994                    if nome == "caixa_teia" && reason.contains('_')
5995            ),
5996            "got {err:?}"
5997        );
5998    }
5999
6000    #[test]
6001    fn validate_rejects_nome_with_dot() {
6002        // A `:deps :nome` is a single DNS-1123 *label*, not a
6003        // subdomain — dots are rejected. The `"caixa.teia"` shape is
6004        // the canonical "I confused the dep name with the FQDN /
6005        // namespace" footgun, distinct from the legitimate
6006        // `:fonte :repo "github:org/caixa-teia"` axis.
6007        let d = Dep::simple("caixa.teia", "^0.1");
6008        let err = d.validate().unwrap_err();
6009        assert!(
6010            matches!(
6011                err,
6012                DepError::NomeInvalid { ref nome, ref reason }
6013                    if nome == "caixa.teia" && reason.contains('.')
6014            ),
6015            "got {err:?}"
6016        );
6017    }
6018
6019    #[test]
6020    fn validate_rejects_nome_with_leading_hyphen() {
6021        // RFC 1123 requires alphanumeric at both label boundaries.
6022        // Pinned in parity with the peer DNS-1123 fixtures.
6023        let d = Dep::simple("-caixa-teia", "^0.1");
6024        let err = d.validate().unwrap_err();
6025        assert!(
6026            matches!(
6027                err,
6028                DepError::NomeInvalid { ref nome, ref reason }
6029                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
6030            ),
6031            "got {err:?}"
6032        );
6033    }
6034
6035    #[test]
6036    fn validate_rejects_nome_with_trailing_hyphen() {
6037        let d = Dep::simple("caixa-teia-", "^0.1");
6038        let err = d.validate().unwrap_err();
6039        assert!(
6040            matches!(
6041                err,
6042                DepError::NomeInvalid { ref nome, ref reason }
6043                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
6044            ),
6045            "got {err:?}"
6046        );
6047    }
6048
6049    #[test]
6050    fn validate_rejects_nome_with_slash() {
6051        // The canonical "I copied the GitHub repo path into `:nome`
6052        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6053        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6054        // the local-name slot. Same fixture pinned for `:membros
6055        // :caixa` (3f9d7a0).
6056        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6057        let err = d.validate().unwrap_err();
6058        assert!(
6059            matches!(
6060                err,
6061                DepError::NomeInvalid { ref nome, ref reason }
6062                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
6063            ),
6064            "got {err:?}"
6065        );
6066    }
6067
6068    #[test]
6069    fn validate_rejects_nome_too_long() {
6070        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6071        // Built from a valid character set so the length-bound
6072        // diagnostic surfaces before any per-character check (the
6073        // order pin parallel to the per-character predicates inside
6074        // [`crate::render::is_dns_1123_label`]).
6075        let long = "a".repeat(64);
6076        let d = Dep::simple(&long, "^0.1");
6077        let err = d.validate().unwrap_err();
6078        assert!(
6079            matches!(
6080                err,
6081                DepError::NomeInvalid { ref nome, ref reason }
6082                    if nome.len() == 64 && reason.contains("max length of 63")
6083            ),
6084            "got {err:?}"
6085        );
6086    }
6087
6088    #[test]
6089    fn validate_accepts_canonical_nome_labels() {
6090        // Positive-control sweep — every form the K8s apiserver
6091        // accepts as a DNS-1123 label must round-trip through
6092        // validate. Covers a hyphen-bearing label, a numeric-suffix
6093        // label, a leading-digit label, a single-character label, and
6094        // a 63-byte (exactly the cap) label — the same fixture set
6095        // the peer `:membros :caixa` / `:children :caixa` positive
6096        // controls pin.
6097        for nome in [
6098            "caixa-teia",
6099            "caixa-resolver2",
6100            "2nd-tier-cache",
6101            "x",
6102            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6103        ] {
6104            Dep::simple(nome, "^0.1")
6105                .validate()
6106                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6107        }
6108    }
6109
6110    #[test]
6111    fn nome_empty_takes_precedence_over_nome_invalid() {
6112        // Ordering pin: `NomeEmpty` is the more self-locating
6113        // diagnostic on `""` and must lead — `is_dns_1123_label` is
6114        // only reached after the empty-check fires at the call site.
6115        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6116        // (3f9d7a0) on the peer caixa-identifier axis.
6117        let mut d = Dep::simple("placeholder", "^0.1");
6118        d.nome = String::new();
6119        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6120    }
6121
6122    #[test]
6123    fn nome_invalid_fires_before_versao_empty() {
6124        // Ordering pin: a malformed `:nome` fires before any `:versao`
6125        // axis check on the *same* entry — the per-entry shape gates
6126        // run top-to-bottom (nome empty → nome shape → versao empty →
6127        // versao parse → fonte shape), so a one-entry caixa.lisp with
6128        // both wrong sees the name-side diagnostic first (the name is
6129        // the self-locating axis — without a valid name, the parse
6130        // diagnostic can't quote `:nome "<bad>"`). Same ordering
6131        // discipline as `membro_caixa_invalid_fires_before_versao_check`
6132        // (3f9d7a0).
6133        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6134        d.versao = String::new();
6135        let err = d.validate().unwrap_err();
6136        assert!(
6137            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6138            "got {err:?}"
6139        );
6140    }
6141
6142    #[test]
6143    fn nome_invalid_fires_before_versao_invalid() {
6144        // Ordering pin: a malformed `:nome` fires before the `:versao`
6145        // parse-side check on the *same* entry. Pin separately from
6146        // the empty-versao ordering so a future re-ordering surfaces
6147        // here, parallel to the b0c8389 / c4213a4 trajectory.
6148        let d = Dep::simple("Caixa-Teia", "^^0.1");
6149        let err = d.validate().unwrap_err();
6150        assert!(
6151            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6152            "got {err:?}"
6153        );
6154    }
6155
6156    #[test]
6157    fn nome_invalid_fires_before_fonte_invalid() {
6158        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6159        // shape check on the *same* entry. The `:fonte` diagnostic
6160        // names the offending dep's `:nome` verbatim (via
6161        // `DepSource::validate(&self.nome)`), so a non-self-locating
6162        // name would taint the downstream diagnostic too — the gate
6163        // ordering keeps both diagnostics individually self-locating.
6164        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6165        d.fonte = Some(DepSource::Git {
6166            repo: String::new(),
6167            tag: None,
6168            rev: None,
6169            branch: None,
6170        });
6171        let err = d.validate().unwrap_err();
6172        assert!(
6173            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6174            "got {err:?}"
6175        );
6176    }
6177
6178    #[test]
6179    fn nome_invalid_diagnostic_carries_offending_name() {
6180        // The diagnostic-shape pin: the error names the offending
6181        // `:nome` value verbatim so the author can grep their
6182        // caixa.lisp without re-running the build, and carries a
6183        // non-empty `reason` from `is_dns_1123_label` so the
6184        // predicate's own wording flows through to the diagnostic.
6185        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6186        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6187        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6188        // share a structurally-equivalent diagnostic family.
6189        let d = Dep::simple("Caixa_Teia", "^0.1");
6190        let err = d.validate().unwrap_err();
6191        let DepError::NomeInvalid { nome, reason } = err else {
6192            panic!("expected NomeInvalid, got other variant");
6193        };
6194        assert_eq!(nome, "Caixa_Teia");
6195        assert!(
6196            !reason.is_empty(),
6197            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6198        );
6199    }
6200
6201    #[test]
6202    fn validate_rejects_invalid_versao_requirement() {
6203        // The fail-before-pass-after pin: a non-empty but malformed
6204        // requirement (`"^bad-version"`) silently passed every pre-gate
6205        // codebase because `:deps :versao` wasn't validated. The parse
6206        // failure surfaced far downstream at lacre-resolve time with a
6207        // `semver::Error` that didn't name which `:deps` entry carried
6208        // the typo. The new gate moves the check to caixa-build time
6209        // at the source caixa.lisp.
6210        let d = Dep::simple("caixa-teia", "^bad-version");
6211        let err = d.validate().unwrap_err();
6212        assert!(
6213            matches!(
6214                err,
6215                DepError::VersaoInvalid { ref nome, ref versao, .. }
6216                    if nome == "caixa-teia" && versao == "^bad-version"
6217            ),
6218            "got {err:?}"
6219        );
6220    }
6221
6222    #[test]
6223    fn validate_rejects_versao_with_double_caret_typo() {
6224        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6225        // Cargo-shaped requirement on first glance but fails the parser
6226        // because semver doesn't accept stacked operators. Pin this
6227        // adjacent-shape footgun explicitly so a future relaxation that
6228        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6229        // parity with the `:membros` / `:children` fixtures.
6230        let d = Dep::simple("caixa-teia", "^^0.1");
6231        let err = d.validate().unwrap_err();
6232        assert!(
6233            matches!(
6234                err,
6235                DepError::VersaoInvalid { ref nome, ref versao, .. }
6236                    if nome == "caixa-teia" && versao == "^^0.1"
6237            ),
6238            "got {err:?}"
6239        );
6240    }
6241
6242    #[test]
6243    fn validate_rejects_versao_with_v_prefixed_tag() {
6244        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6245        // semver requirement slot" typo — an author copies the
6246        // publish-side git-tag string verbatim into `:versao`, but
6247        // Cargo's semver parser rejects the leading `v`. Same fixture
6248        // pinned for `:membros :versao` (9888b13) and `:children
6249        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6250        // are *accepted* by the semver crate as an `*` wildcard on the
6251        // patch axis — they're a Cargo-side valid shape, not a typo.)
6252        let d = Dep::simple("caixa-teia", "v0.1");
6253        let err = d.validate().unwrap_err();
6254        assert!(
6255            matches!(
6256                err,
6257                DepError::VersaoInvalid { ref nome, ref versao, .. }
6258                    if nome == "caixa-teia" && versao == "v0.1"
6259            ),
6260            "got {err:?}"
6261        );
6262    }
6263
6264    #[test]
6265    fn validate_accepts_canonical_versao_forms() {
6266        // The five Cargo-shaped requirement forms `:membros :versao`
6267        // and `:children :versao` already accept via
6268        // `crate::parse_requirement` must pass the deps gate without
6269        // re-validating at the resolver layer. Pin every leg so a
6270        // future tightening of the canonical set surfaces here as a
6271        // test failure.
6272        for form in [
6273            "^0.1",      // caret — minor-range pin (the most common shape)
6274            "~0.1.2",    // tilde — patch-range pin
6275            "0.1.0",     // exact — single-version pin
6276            "*",         // wildcard — explicitly any-version
6277            ">=0.1, <2", // multi-range — comma-separated comparators
6278        ] {
6279            Dep::simple("caixa-teia", form)
6280                .validate()
6281                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6282        }
6283    }
6284
6285    #[test]
6286    fn versao_empty_takes_precedence_over_invalid() {
6287        // Order pin: the existing `VersaoEmpty` diagnostic (which
6288        // doesn't try to parse) fires before the new `VersaoInvalid`
6289        // parse-side diagnostic, so an empty `:versao` keeps its
6290        // narrower error message — `parse_requirement("")` would
6291        // otherwise return `Ok(STAR)` and silently pass, but the empty
6292        // arm catches it first.
6293        let mut d = Dep::simple("caixa-teia", "ignored");
6294        d.versao = String::new();
6295        let err = d.validate().unwrap_err();
6296        assert!(
6297            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6298            "got {err:?}"
6299        );
6300    }
6301
6302    #[test]
6303    fn nome_empty_takes_precedence_over_versao_invalid() {
6304        // Order pin: even when `:versao` is malformed and would raise
6305        // its own diagnostic, `:nome ""` fires first because the
6306        // per-entry parse diagnostic needs a non-empty name to be
6307        // self-locating. Mirrors the
6308        // `membros_validation_runs_before_contratos_membership_check`
6309        // ordering on the typed-graph layer.
6310        let mut d = Dep::simple("placeholder", "^bad");
6311        d.nome = String::new();
6312        let err = d.validate().unwrap_err();
6313        assert_eq!(err, DepError::NomeEmpty);
6314    }
6315
6316    #[test]
6317    fn versao_invalid_diagnostic_carries_offending_versao() {
6318        // The diagnostic-shape pin: the error names the offending
6319        // `:versao` value verbatim so the author can grep their
6320        // caixa.lisp without re-running the build, and carries a
6321        // non-empty `reason` from `semver::VersionReq::parse` so the
6322        // parser's own wording flows through to the diagnostic.
6323        let d = Dep::simple("caixa-teia", "not-a-req");
6324        let err = d.validate().unwrap_err();
6325        let DepError::VersaoInvalid {
6326            nome,
6327            versao,
6328            reason,
6329        } = err
6330        else {
6331            panic!("expected VersaoInvalid, got other variant");
6332        };
6333        assert_eq!(nome, "caixa-teia");
6334        assert_eq!(versao, "not-a-req");
6335        assert!(
6336            !reason.is_empty(),
6337            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6338        );
6339    }
6340
6341    // -- :fonte value-shape gate ------------------------------------------
6342
6343    fn dep_with_fonte(fonte: DepSource) -> Dep {
6344        let mut d = Dep::simple("caixa-teia", "^0.1");
6345        d.fonte = Some(fonte);
6346        d
6347    }
6348
6349    #[test]
6350    fn validate_accepts_git_fonte_with_tag() {
6351        // The positive-control pin on the canonical git source — exactly
6352        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6353        // shape every existing caixa-resolver integration test uses.
6354        let d = dep_with_fonte(DepSource::Git {
6355            repo: "github:pleme-io/caixa-teia".into(),
6356            tag: Some("v0.1.0".into()),
6357            rev: None,
6358            branch: None,
6359        });
6360        d.validate().unwrap();
6361    }
6362
6363    #[test]
6364    fn validate_accepts_git_fonte_with_rev() {
6365        // Each of the three pin axes is independently a valid single-pin
6366        // shape; pin the :rev arm so a future relaxation that only
6367        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6368        // OID — the canonical `git rev-parse HEAD` emission shape the
6369        // `crate::render::is_git_oid` value-shape gate now requires;
6370        // abbreviated OIDs are ambiguous across repo history and
6371        // rejected at this gate (pinned separately by
6372        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6373        let d = dep_with_fonte(DepSource::Git {
6374            repo: "github:pleme-io/caixa-teia".into(),
6375            tag: None,
6376            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6377            branch: None,
6378        });
6379        d.validate().unwrap();
6380    }
6381
6382    #[test]
6383    fn validate_accepts_git_fonte_with_branch() {
6384        // The :branch arm is the third valid single-pin shape — pinned
6385        // separately so the gate-accepts-all-three-pin-axes contract is
6386        // a build-error to relax.
6387        let d = dep_with_fonte(DepSource::Git {
6388            repo: "github:pleme-io/caixa-teia".into(),
6389            tag: None,
6390            rev: None,
6391            branch: Some("main".into()),
6392        });
6393        d.validate().unwrap();
6394    }
6395
6396    #[test]
6397    fn validate_accepts_path_fonte() {
6398        // The positive-control pin on the path source — non-empty
6399        // :caminho, no pin axes (paths have no commit identity). Pinned
6400        // so a future "paths must also pin a rev" tightening surfaces
6401        // here as a structural decision, not a silent break.
6402        let d = dep_with_fonte(DepSource::Path {
6403            caminho: "../caixa-teia".into(),
6404        });
6405        d.validate().unwrap();
6406    }
6407
6408    #[test]
6409    fn validate_rejects_git_fonte_with_empty_repo() {
6410        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6411        // "v1")`: the empty-repo shape silently passed every pre-gate
6412        // codebase because `:fonte` wasn't validated. The git-clone
6413        // failure surfaced far downstream at lacre-resolve time with no
6414        // field naming which `:deps` entry carried the typo. The new
6415        // gate moves the check to caixa-build time at the source
6416        // caixa.lisp.
6417        let d = dep_with_fonte(DepSource::Git {
6418            repo: String::new(),
6419            tag: Some("v0.1.0".into()),
6420            rev: None,
6421            branch: None,
6422        });
6423        let err = d.validate().unwrap_err();
6424        assert!(
6425            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6426            "got {err:?}"
6427        );
6428    }
6429
6430    // -- :repo value-shape gate -------------------------------------------
6431    //
6432    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6433    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6434    // codebase admitted any non-empty string; the new
6435    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6436    // URL intersection-floor at validate time, peer with the three pin
6437    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6438    // `is_git_oid`). Every test in this section is a fail-before /
6439    // pass-after pin on a specific authoring footgun.
6440
6441    #[test]
6442    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6443        // The canonical paste-from-doc footgun on `:repo` — an author
6444        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6445        // a doc paragraph. Until this gate landed the empty-repo arm
6446        // passed (the string isn't empty), the resolver issued
6447        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6448        // surfaced at clone time with a quoting-confused error far from
6449        // the source caixa.lisp. Same paste-from-doc footgun the
6450        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6451        // axis — now closed on the `:repo` URL axis too.
6452        let d = dep_with_fonte(DepSource::Git {
6453            repo: "github:pleme-io/caixa-teia ".into(),
6454            tag: Some("v0.1.0".into()),
6455            rev: None,
6456            branch: None,
6457        });
6458        let err = d.validate().unwrap_err();
6459        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6460            panic!("expected FonteRepoShape, got other variant");
6461        };
6462        assert_eq!(nome, "caixa-teia");
6463        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6464        assert!(
6465            reason.contains("whitespace"),
6466            "reason must surface the whitespace arm, got {reason:?}"
6467        );
6468    }
6469
6470    #[test]
6471    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6472        // The canonical CLI-argument-injection footgun at the `git clone`
6473        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6474        // argv parser read the value as a CLI flag, escaping the
6475        // subprocess argument boundary. The `--` separator workaround
6476        // does not fix the typed slot's accepted set; the gate rejects
6477        // the shape upstream at validate time so the resolver never
6478        // invokes a `git clone -…` subprocess.
6479        let d = dep_with_fonte(DepSource::Git {
6480            repo: "-upload-pack=evil".into(),
6481            tag: Some("v0.1.0".into()),
6482            rev: None,
6483            branch: None,
6484        });
6485        let err = d.validate().unwrap_err();
6486        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6487            panic!("expected FonteRepoShape, got other variant");
6488        };
6489        assert_eq!(repo, "-upload-pack=evil");
6490        assert!(
6491            reason.contains("must not start with `-`"),
6492            "reason must surface the leading-`-` arm, got {reason:?}"
6493        );
6494    }
6495
6496    #[test]
6497    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6498        // The canonical paste-from-multiline-doc footgun — a `:repo`
6499        // string with an embedded `\n` silently breaks git's URL parser
6500        // and is a class of CRLF-injection at the subprocess-argument
6501        // boundary. Caught by the control-char arm (0x0A < 0x20).
6502        let d = dep_with_fonte(DepSource::Git {
6503            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6504            tag: Some("v0.1.0".into()),
6505            rev: None,
6506            branch: None,
6507        });
6508        let err = d.validate().unwrap_err();
6509        let DepError::FonteRepoShape { reason, .. } = err else {
6510            panic!("expected FonteRepoShape, got other variant");
6511        };
6512        assert!(
6513            reason.contains("control character"),
6514            "reason must surface the control-char arm, got {reason:?}"
6515        );
6516    }
6517
6518    #[test]
6519    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6520        // Tab is the sibling whitespace footgun (the canonical
6521        // copy-from-aligned-table paste); pinned separately from the
6522        // space arm so a future relaxation that only catches one
6523        // surfaces here.
6524        let d = dep_with_fonte(DepSource::Git {
6525            repo: "github:pleme-io/caixa-teia\t".into(),
6526            tag: Some("v0.1.0".into()),
6527            rev: None,
6528            branch: None,
6529        });
6530        let err = d.validate().unwrap_err();
6531        assert!(
6532            matches!(
6533                err,
6534                DepError::FonteRepoShape { ref reason, .. }
6535                    if reason.contains("whitespace")
6536            ),
6537            "got {err:?}"
6538        );
6539    }
6540
6541    #[test]
6542    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6543        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6544        // non-ASCII silently breaks at git's URL parser and round-trips
6545        // inconsistently across NFC/NFD normalization on APFS /
6546        // case-folding filesystems. Same intersection-floor
6547        // [`is_git_ref_name`] enforces on the refname axes.
6548        let d = dep_with_fonte(DepSource::Git {
6549            repo: "https://github.com/pleme-io/café".into(),
6550            tag: Some("v0.1.0".into()),
6551            rev: None,
6552            branch: None,
6553        });
6554        let err = d.validate().unwrap_err();
6555        assert!(
6556            matches!(
6557                err,
6558                DepError::FonteRepoShape { ref reason, .. }
6559                    if reason.contains("non-ASCII")
6560            ),
6561            "got {err:?}"
6562        );
6563    }
6564
6565    #[test]
6566    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6567        // The fail-before-pass-after pin for the canonical paste-from-
6568        // browser-address-bar footgun on `:repo`: an author copies a
6569        // GitHub permalink to a README anchor / line-permalink and
6570        // forgets to trim the `#fragment` tail. Until this arm landed
6571        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6572        // silently passed every prior arm (no whitespace, no control
6573        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6574        // or `:`), libcurl's URL parser stripped the `#readme` tail
6575        // before opening the HTTPS transport, and the lacre embedded
6576        // the value verbatim in its per-dep BLAKE3 closure — two
6577        // authors whose values differ only in their fragment anchor
6578        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6579        // `git clone` but lock to two distinct lacres, defeating the
6580        // THEORY.md §V.2 render-determinism contract. Same value-shape
6581        // axis-floor every peer typed surface enforces; peer `:fonte
6582        // :tag` / `:fonte :branch` already reject the byte-class through
6583        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6584        // URL grammar admitted) and `:entrada :paths` rejects `#` as
6585        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6586        let d = dep_with_fonte(DepSource::Git {
6587            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6588            tag: Some("v0.1.0".into()),
6589            rev: None,
6590            branch: None,
6591        });
6592        let err = d.validate().unwrap_err();
6593        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6594            panic!("expected FonteRepoShape, got other variant");
6595        };
6596        assert_eq!(nome, "caixa-teia");
6597        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6598        assert!(
6599            reason.contains("must not contain `#`"),
6600            "reason must surface the fragment-`#` arm, got {reason:?}"
6601        );
6602        assert!(
6603            reason.contains("fragment"),
6604            "reason must name the URL fragment grammar, got {reason:?}"
6605        );
6606    }
6607
6608    #[test]
6609    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6610        // The symmetric paste-from-Nix-flake-ref footgun — an author
6611        // confuses the Nix flake-reference idiom (`github:foo/
6612        // bar#packageName`, where `#packageName` selects a flake
6613        // output) with the bare git `:repo` shape. The pleme-io
6614        // substrate authors compose flakes downstream of caixa
6615        // (caixa-flake renders a flake.nix), so the cross-idiom leak
6616        // is the canonical near-miss: the author writes the
6617        // flake-ref shape into a git `:repo` slot. Pinned separately
6618        // from the HTTPS-anchor arm so a future relaxation that
6619        // narrows to one URL scheme surfaces here.
6620        let d = dep_with_fonte(DepSource::Git {
6621            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6622            tag: Some("v0.1.0".into()),
6623            rev: None,
6624            branch: None,
6625        });
6626        let err = d.validate().unwrap_err();
6627        let DepError::FonteRepoShape { reason, .. } = err else {
6628            panic!("expected FonteRepoShape, got other variant");
6629        };
6630        assert!(
6631            reason.contains("must not contain `#`"),
6632            "reason must surface the fragment-`#` arm, got {reason:?}"
6633        );
6634        assert!(
6635            reason.contains("Nix flake"),
6636            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6637        );
6638    }
6639
6640    #[test]
6641    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6642        // The fail-before-pass-after pin for the canonical paste-from-
6643        // browser-address-bar footgun on `:repo` (peer with the
6644        // a68f818 fragment-`#` arm on the same axis). An author
6645        // copies a GitHub tab deep-link out of the address bar and
6646        // forgets to trim the `?tab=…` query tail. Until this arm
6647        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6648        // silently passed every prior arm (no whitespace, no control
6649        // chars, no non-ASCII, no `#` fragment, contains a `:`,
6650        // doesn't start with `-` or `:`); GitHub silently ignored
6651        // the `?query` tail and served the same repo regardless;
6652        // the lacre embedded the value verbatim in its per-dep
6653        // BLAKE3 closure — two authors whose values differ only in
6654        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6655        // `?utm_source=twitter`) resolve to the byte-identical
6656        // upstream `git clone` but lock to two distinct lacres,
6657        // defeating the THEORY.md §V.2 render-determinism contract
6658        // on the same axis the `#` fragment arm closes. Same value-
6659        // shape axis-floor every peer typed surface enforces; peer
6660        // `:fonte :tag` / `:fonte :branch` already reject the byte-
6661        // class through `is_git_ref_name`'s alphabet (refspec glob
6662        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6663        // :paths` rejects `?` as the query separator in
6664        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6665        let d = dep_with_fonte(DepSource::Git {
6666            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6667            tag: Some("v0.1.0".into()),
6668            rev: None,
6669            branch: None,
6670        });
6671        let err = d.validate().unwrap_err();
6672        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6673            panic!("expected FonteRepoShape, got other variant");
6674        };
6675        assert_eq!(nome, "caixa-teia");
6676        assert_eq!(
6677            repo,
6678            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6679        );
6680        assert!(
6681            reason.contains("must not contain `?`"),
6682            "reason must surface the query-`?` arm, got {reason:?}"
6683        );
6684        assert!(
6685            reason.contains("query"),
6686            "reason must name the URL query grammar, got {reason:?}"
6687        );
6688    }
6689
6690    #[test]
6691    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6692        // The symmetric paste-from-social-share footgun — an author
6693        // copies a repo URL out of a Slack unfurl / Twitter share /
6694        // newsletter link / Discord embed and forgets to trim the
6695        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6696        // campaign-tracker tail. Every major social-share / unfurl /
6697        // newsletter platform appends these UTM parameters; the
6698        // canonical near-miss on the `:repo` axis. Pinned separately
6699        // from the GitHub-tab-deep-link arm so a future relaxation
6700        // that narrows to one query-parameter class surfaces here.
6701        let d = dep_with_fonte(DepSource::Git {
6702            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6703                .into(),
6704            tag: Some("v0.1.0".into()),
6705            rev: None,
6706            branch: None,
6707        });
6708        let err = d.validate().unwrap_err();
6709        let DepError::FonteRepoShape { reason, .. } = err else {
6710            panic!("expected FonteRepoShape, got other variant");
6711        };
6712        assert!(
6713            reason.contains("must not contain `?`"),
6714            "reason must surface the query-`?` arm, got {reason:?}"
6715        );
6716        assert!(
6717            reason.contains("campaign-tracker"),
6718            "reason must name the campaign-tracker paste footgun, got {reason:?}"
6719        );
6720    }
6721
6722    #[test]
6723    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6724        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6725        // both per-byte arms inside the same `for &b in s.as_bytes()`
6726        // loop, so the byte that appears first in the value's byte
6727        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6728        // (fragment before query — unusual URL-grammar but value-
6729        // disjoint at byte level) carries both `#` and `?`; the `#`
6730        // byte appears first, so the fragment-`#` arm fires, surfacing
6731        // the more self-locating diagnostic on the byte the author
6732        // pasted earliest in the URL. Mirrors the peer cascade
6733        // discipline `fonte_repo_control_char_fires_before_fragment`
6734        // pins on the prior `:repo` byte-class arm.
6735        let d = dep_with_fonte(DepSource::Git {
6736            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6737            tag: Some("v0.1.0".into()),
6738            rev: None,
6739            branch: None,
6740        });
6741        let err = d.validate().unwrap_err();
6742        let DepError::FonteRepoShape { reason, .. } = err else {
6743            panic!("expected FonteRepoShape, got other variant");
6744        };
6745        assert!(
6746            reason.contains("must not contain `#`"),
6747            "reason must surface the fragment-`#` arm (fires before query-`?` when \
6748             `#` byte appears first in value), got {reason:?}"
6749        );
6750    }
6751
6752    #[test]
6753    fn fonte_repo_control_char_fires_before_fragment() {
6754        // Cascade pin: the control-char arm structurally precedes the
6755        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6756        // positive on both arms (contains LF and `#`), but the narrower
6757        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6758        // (`control character`) wins so the author sees the more
6759        // self-locating arm first. Mirrors the peer cascade discipline
6760        // every prior `:repo` byte-class arm establishes.
6761        let d = dep_with_fonte(DepSource::Git {
6762            repo: "github:pleme-io/caixa-teia\n#readme".into(),
6763            tag: Some("v0.1.0".into()),
6764            rev: None,
6765            branch: None,
6766        });
6767        let err = d.validate().unwrap_err();
6768        let DepError::FonteRepoShape { reason, .. } = err else {
6769            panic!("expected FonteRepoShape, got other variant");
6770        };
6771        assert!(
6772            reason.contains("control character"),
6773            "reason must surface the control-char arm, got {reason:?}"
6774        );
6775    }
6776
6777    #[test]
6778    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6779        // The fail-before-pass-after pin for the canonical Windows-
6780        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6781        // backslash arm on the sibling `:caminho` path-fonte axis).
6782        // An author pastes a Windows Explorer address-bar / PowerShell
6783        // `Get-Location` output into a `file://` URL slot, producing
6784        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6785        // value silently passed every prior arm (no whitespace, no
6786        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6787        // with `-` or `:`); libcurl's URL parser silently translates
6788        // `\` → `/` on some platforms and refuses it on others, so
6789        // the byte rides verbatim into the lacre's per-dep content-
6790        // address but is silently rewritten / rejected at the wire —
6791        // two authors whose `:repo` values differ only in backslash-
6792        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6793        // resolve to the byte-identical local clone but lock to two
6794        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6795        // render-determinism contract on the same axis the `#`
6796        // fragment and `?` query arms close. Same value-shape axis-
6797        // floor every peer typed surface enforces; the `:caminho`
6798        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6799        let d = dep_with_fonte(DepSource::Git {
6800            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6801            tag: Some("v0.1.0".into()),
6802            rev: None,
6803            branch: None,
6804        });
6805        let err = d.validate().unwrap_err();
6806        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6807            panic!("expected FonteRepoShape, got other variant");
6808        };
6809        assert_eq!(nome, "caixa-teia");
6810        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6811        assert!(
6812            reason.contains("must not contain `\\`"),
6813            "reason must surface the backslash-`\\` arm, got {reason:?}"
6814        );
6815        assert!(
6816            reason.contains("Windows"),
6817            "reason must name the Windows-path-confusion footgun, got {reason:?}"
6818        );
6819    }
6820
6821    #[test]
6822    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6823        // The symmetric Win32-shell-mangled-slashes footgun — an author
6824        // copies `https://github.com/foo/bar` into a Win32 shell that
6825        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6826        // separator-coercion bug), pastes the result into a `:repo`
6827        // slot, and produces `https:\\github.com\foo\bar`. Pinned
6828        // separately from the `file://` Explorer-paste arm so a future
6829        // relaxation that narrows to one URL scheme surfaces here.
6830        let d = dep_with_fonte(DepSource::Git {
6831            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6832            tag: Some("v0.1.0".into()),
6833            rev: None,
6834            branch: None,
6835        });
6836        let err = d.validate().unwrap_err();
6837        let DepError::FonteRepoShape { reason, .. } = err else {
6838            panic!("expected FonteRepoShape, got other variant");
6839        };
6840        assert!(
6841            reason.contains("must not contain `\\`"),
6842            "reason must surface the backslash-`\\` arm, got {reason:?}"
6843        );
6844        assert!(
6845            reason.contains("path separator") || reason.contains("path-segment separator"),
6846            "reason must name the URL path-segment separator grammar, got {reason:?}"
6847        );
6848    }
6849
6850    #[test]
6851    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6852        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6853        // are both per-byte arms inside the same `for &b in s.as_bytes()`
6854        // loop, so the byte that appears first in the value's byte order
6855        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6856        // both `#` and `\`; the `#` byte appears first, so the fragment-
6857        // `#` arm fires, surfacing the more self-locating diagnostic on
6858        // the byte the author pasted earliest in the URL. Mirrors the
6859        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6860        // pins on the prior `:repo` byte-class arm.
6861        let d = dep_with_fonte(DepSource::Git {
6862            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6863            tag: Some("v0.1.0".into()),
6864            rev: None,
6865            branch: None,
6866        });
6867        let err = d.validate().unwrap_err();
6868        let DepError::FonteRepoShape { reason, .. } = err else {
6869            panic!("expected FonteRepoShape, got other variant");
6870        };
6871        assert!(
6872            reason.contains("must not contain `#`"),
6873            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6874             `#` byte appears first in value), got {reason:?}"
6875        );
6876    }
6877
6878    #[test]
6879    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6880        // The fail-before-pass-after pin for the canonical URI Template
6881        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6882        // README quick-start snippet / OpenAPI `servers:` URL / Helm
6883        // chart `home:` template that carries unresolved
6884        // `{org}` / `{repo}` placeholders and pastes the raw template
6885        // into the `:repo` slot, expecting the substrate to resolve the
6886        // placeholder downstream. Until this arm landed the value
6887        // silently passed every prior arm (no whitespace, no control
6888        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6889        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6890        // / `%7D` on the wire, so the byte rides verbatim into the
6891        // lacre's per-dep content-address but round-trips inconsistently
6892        // between the lacre's per-dep content-address and the
6893        // resolver's `git clone <repo>` invocation, defeating the
6894        // THEORY.md §V.2 render-determinism contract on the same axis
6895        // the `#` fragment, `?` query, and `\` backslash arms close;
6896        // every git porcelain entry-point additionally fetches a
6897        // nonexistent literal-`{placeholder}`-named path far from the
6898        // source caixa.lisp.
6899        let d = dep_with_fonte(DepSource::Git {
6900            repo: "https://github.com/{org}/caixa-teia".into(),
6901            tag: Some("v0.1.0".into()),
6902            rev: None,
6903            branch: None,
6904        });
6905        let err = d.validate().unwrap_err();
6906        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6907            panic!("expected FonteRepoShape, got other variant");
6908        };
6909        assert_eq!(nome, "caixa-teia");
6910        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6911        assert!(
6912            reason.contains("must not contain `{`"),
6913            "reason must surface the open-brace `{{` arm, got {reason:?}"
6914        );
6915        assert!(
6916            reason.contains("URI Template") || reason.contains("RFC 6570"),
6917            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6918        );
6919    }
6920
6921    #[test]
6922    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6923        // The symmetric Mustache / Handlebars doubled-brace
6924        // substitution-form footgun every CI / IaC templating engine
6925        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6926        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6927        // chart README quick-start snippet emits. Pinned separately
6928        // from the single-`{` `{org}` arm so a future relaxation that
6929        // narrows to one substitution-form surfaces here.
6930        let d = dep_with_fonte(DepSource::Git {
6931            repo: "https://github.com/{{org}}/caixa-teia".into(),
6932            tag: Some("v0.1.0".into()),
6933            rev: None,
6934            branch: None,
6935        });
6936        let err = d.validate().unwrap_err();
6937        let DepError::FonteRepoShape { reason, .. } = err else {
6938            panic!("expected FonteRepoShape, got other variant");
6939        };
6940        assert!(
6941            reason.contains("must not contain `{`"),
6942            "reason must surface the open-brace `{{` arm, got {reason:?}"
6943        );
6944    }
6945
6946    #[test]
6947    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6948        // Asymmetric `}`-only shape — covers the closing-brace-by-
6949        // itself footgun (an author truncated `{org}/{repo}` mid-edit
6950        // and left a trailing `}` from the prior template fragment,
6951        // or pasted a value that included a closing brace from a
6952        // surrounding shell context). Pinned to ensure the predicate
6953        // refuses each brace independently rather than only when both
6954        // appear — a future regression that ANDs the two byte tests
6955        // surfaces here.
6956        let d = dep_with_fonte(DepSource::Git {
6957            repo: "https://github.com/pleme-io/caixa-teia}".into(),
6958            tag: Some("v0.1.0".into()),
6959            rev: None,
6960            branch: None,
6961        });
6962        let err = d.validate().unwrap_err();
6963        let DepError::FonteRepoShape { reason, .. } = err else {
6964            panic!("expected FonteRepoShape, got other variant");
6965        };
6966        assert!(
6967            reason.contains("must not contain `}`"),
6968            "reason must surface the close-brace `}}` arm, got {reason:?}"
6969        );
6970    }
6971
6972    #[test]
6973    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6974        // Cascade pin: the fragment-`#` arm and the template-`{` /
6975        // `}` arm are both per-byte arms inside the same
6976        // `for &b in s.as_bytes()` loop, so the byte that appears
6977        // first in the value's byte order wins. A `:repo
6978        // "https://github.com/p/x#readme{org}"` carries both `#` and
6979        // `{`; the `#` byte appears first, so the fragment-`#` arm
6980        // fires, surfacing the more self-locating diagnostic on the
6981        // byte the author pasted earliest in the URL. Mirrors the
6982        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6983        // pins on the prior `:repo` byte-class arm.
6984        let d = dep_with_fonte(DepSource::Git {
6985            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6986            tag: Some("v0.1.0".into()),
6987            rev: None,
6988            branch: None,
6989        });
6990        let err = d.validate().unwrap_err();
6991        let DepError::FonteRepoShape { reason, .. } = err else {
6992            panic!("expected FonteRepoShape, got other variant");
6993        };
6994        assert!(
6995            reason.contains("must not contain `#`"),
6996            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6997             `#` byte appears first in value), got {reason:?}"
6998        );
6999    }
7000
7001    #[test]
7002    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7003        // The fail-before-pass-after pin for the canonical
7004        // shell-output-redirection footgun on `:repo`: an author
7005        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7006        // / `… >output.txt`) into the `:repo` slot without trimming
7007        // the redirect. Until this arm landed the value silently
7008        // passed every prior arm (no whitespace, no control chars,
7009        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7010        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7011        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7012        // percent-encode set maps `>` → `%3E` on the wire, so the
7013        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7014        // but is silently rewritten or rejected at libcurl's URL-
7015        // parser layer — two authors whose values differ only in
7016        // their redirect tail (`>build.log` vs nothing) resolve to
7017        // the byte-identical upstream `git clone` but lock to two
7018        // distinct lacres, defeating the THEORY.md §V.2 render-
7019        // determinism contract. Peer with the `:caminho` axis's
7020        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7021        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7022        // byte RFC-3986-reserved set on `:entrada :paths`.
7023        let d = dep_with_fonte(DepSource::Git {
7024            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7025            tag: Some("v0.1.0".into()),
7026            rev: None,
7027            branch: None,
7028        });
7029        let err = d.validate().unwrap_err();
7030        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7031            panic!("expected FonteRepoShape, got other variant");
7032        };
7033        assert_eq!(nome, "caixa-teia");
7034        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7035        assert!(
7036            reason.contains("must not contain `>`"),
7037            "reason must surface the output-redirection `>` arm, got {reason:?}"
7038        );
7039        assert!(
7040            reason.contains("redirection") || reason.contains("'delims'"),
7041            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7042        );
7043    }
7044
7045    #[test]
7046    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7047        // The symmetric shell-input-redirection footgun — an author
7048        // pastes a shell-pipeline head (`git clone <input.url` /
7049        // `cat <README.md`) into the `:repo` slot. Pinned separately
7050        // from the `>`-output arm so a future relaxation that only
7051        // catches one of the two redirect bytes surfaces here. Peer
7052        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7053        // arm which closes both `<` and `>` under the same banner.
7054        let d = dep_with_fonte(DepSource::Git {
7055            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7056            tag: Some("v0.1.0".into()),
7057            rev: None,
7058            branch: None,
7059        });
7060        let err = d.validate().unwrap_err();
7061        let DepError::FonteRepoShape { reason, .. } = err else {
7062            panic!("expected FonteRepoShape, got other variant");
7063        };
7064        assert!(
7065            reason.contains("must not contain `<`"),
7066            "reason must surface the input-redirection `<` arm, got {reason:?}"
7067        );
7068        assert!(
7069            reason.contains("RFC 3986") || reason.contains("'unwise'"),
7070            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7071        );
7072    }
7073
7074    #[test]
7075    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7076        // The fail-before-pass-after pin for the canonical
7077        // paste-from-shell-prompt-with-backticked-substitution footgun
7078        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7079        // `:caminho` path-fonte axis). An author pastes a URL whose
7080        // segment carries a backticked command-substitution wrapper
7081        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7082        // from a doc / README quick-start snippet that expected the
7083        // substrate to substitute the value downstream. Until this arm
7084        // landed the value silently passed every prior arm (no
7085        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7086        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7087        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7088        // 'unwise' set and the WHATWG URL spec's fragment percent-
7089        // encode set maps `` ` `` → `%60` on the wire, so the byte
7090        // rides verbatim into the lacre's per-dep BLAKE3 closure but
7091        // is silently rewritten or rejected at libcurl's URL-parser
7092        // layer — two authors whose values differ only in their
7093        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7094        // byte-identical upstream `git clone` but lock to two distinct
7095        // lacres, defeating the THEORY.md §V.2 render-determinism
7096        // contract. Peer with the `:caminho` axis's
7097        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7098        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7099        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7100        let d = dep_with_fonte(DepSource::Git {
7101            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7102            tag: Some("v0.1.0".into()),
7103            rev: None,
7104            branch: None,
7105        });
7106        let err = d.validate().unwrap_err();
7107        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7108            panic!("expected FonteRepoShape, got other variant");
7109        };
7110        assert_eq!(nome, "caixa-teia");
7111        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7112        assert!(
7113            reason.contains("must not contain `` ` ``"),
7114            "reason must surface the backtick command-substitution arm, got {reason:?}"
7115        );
7116        assert!(
7117            reason.contains("command-substitution") || reason.contains("'unwise'"),
7118            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7119             got {reason:?}"
7120        );
7121    }
7122
7123    #[test]
7124    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7125        // Cascade pin: the fragment-`#` arm and the backtick command-
7126        // substitution arm are both per-byte arms inside the same
7127        // `for &b in s.as_bytes()` loop, so the byte that appears first
7128        // in the value's byte order wins. A `:repo
7129        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7130        // and backtick; the `#` byte appears first, so the fragment-
7131        // `#` arm fires, surfacing the more self-locating diagnostic
7132        // on the byte the author pasted earliest in the URL. Mirrors
7133        // the peer cascade discipline
7134        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7135        // pins on the prior `:repo` byte-class arm.
7136        let d = dep_with_fonte(DepSource::Git {
7137            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7138            tag: Some("v0.1.0".into()),
7139            rev: None,
7140            branch: None,
7141        });
7142        let err = d.validate().unwrap_err();
7143        let DepError::FonteRepoShape { reason, .. } = err else {
7144            panic!("expected FonteRepoShape, got other variant");
7145        };
7146        assert!(
7147            reason.contains("must not contain `#`"),
7148            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7149             appears first in value), got {reason:?}"
7150        );
7151    }
7152
7153    #[test]
7154    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7155        // Cascade pin: the shell-redirection `<` / `>` arm and the
7156        // backtick command-substitution arm are both per-byte arms
7157        // inside the same `for &b in s.as_bytes()` loop, so the byte
7158        // that appears first in the value's byte order wins. A `:repo
7159        // "https://github.com/p/x>build.log/`whoami`"` carries both
7160        // `>` and backtick; the `>` byte appears first, so the
7161        // shell-redirection arm fires, surfacing the more self-
7162        // locating diagnostic on the byte the author pasted earliest
7163        // in the URL. Pins the natural-order cascade so a future
7164        // reorder of the per-byte arms surfaces here.
7165        let d = dep_with_fonte(DepSource::Git {
7166            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7167            tag: Some("v0.1.0".into()),
7168            rev: None,
7169            branch: None,
7170        });
7171        let err = d.validate().unwrap_err();
7172        let DepError::FonteRepoShape { reason, .. } = err else {
7173            panic!("expected FonteRepoShape, got other variant");
7174        };
7175        assert!(
7176            reason.contains("must not contain `>`"),
7177            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7178             `>` byte appears first in value), got {reason:?}"
7179        );
7180    }
7181
7182    #[test]
7183    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7184        // Cascade pin: the fragment-`#` arm and the shell-redirection
7185        // `<` / `>` arm are both per-byte arms inside the same
7186        // `for &b in s.as_bytes()` loop, so the byte that appears
7187        // first in the value's byte order wins. A `:repo
7188        // "https://github.com/p/x#readme>build.log"` carries both
7189        // `#` and `>`; the `#` byte appears first, so the fragment-
7190        // `#` arm fires, surfacing the more self-locating diagnostic
7191        // on the byte the author pasted earliest in the URL. Mirrors
7192        // the peer cascade discipline
7193        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7194        // pins on the prior `:repo` byte-class arm.
7195        let d = dep_with_fonte(DepSource::Git {
7196            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7197            tag: Some("v0.1.0".into()),
7198            rev: None,
7199            branch: None,
7200        });
7201        let err = d.validate().unwrap_err();
7202        let DepError::FonteRepoShape { reason, .. } = err else {
7203            panic!("expected FonteRepoShape, got other variant");
7204        };
7205        assert!(
7206            reason.contains("must not contain `#`"),
7207            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7208             `#` byte appears first in value), got {reason:?}"
7209        );
7210    }
7211
7212    #[test]
7213    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7214        // The fail-before-pass-after pin for the canonical
7215        // paste-from-shell-prompt-with-piped-pipeline footgun on
7216        // `:repo` (peer with the 124106f pipe arm on the sibling
7217        // `:caminho` path-fonte axis). An author pastes a shell
7218        // pipeline (`git clone <url> | tee build.log`,
7219        // `git ls-remote <url> | head`) into the `:repo` slot,
7220        // forgetting to trim the `| <consumer>` tail. Until this arm
7221        // landed the value silently passed every prior arm (no
7222        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7223        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7224        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7225        // 'unwise' set and the WHATWG URL spec's fragment percent-
7226        // encode set maps `|` → `%7C` on the wire, so the byte rides
7227        // verbatim into the lacre's per-dep BLAKE3 closure but is
7228        // silently rewritten or rejected at libcurl's URL-parser
7229        // layer — two authors whose values differ only in their pipe
7230        // tail (`|tee build.log` vs nothing) resolve to the byte-
7231        // identical upstream `git clone` but lock to two distinct
7232        // lacres, defeating the THEORY.md §V.2 render-determinism
7233        // contract. Peer with the `:caminho` axis's
7234        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7235        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7236        // RFC-3986-reserved set on `:entrada :paths`.
7237        let d = dep_with_fonte(DepSource::Git {
7238            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7239            tag: Some("v0.1.0".into()),
7240            rev: None,
7241            branch: None,
7242        });
7243        let err = d.validate().unwrap_err();
7244        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7245            panic!("expected FonteRepoShape, got other variant");
7246        };
7247        assert_eq!(nome, "caixa-teia");
7248        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7249        assert!(
7250            reason.contains("must not contain `|`"),
7251            "reason must surface the shell-pipe arm, got {reason:?}"
7252        );
7253        assert!(
7254            reason.contains("pipe") || reason.contains("'unwise'"),
7255            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7256        );
7257    }
7258
7259    #[test]
7260    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7261        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7262        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7263        // so the byte that appears first in the value's byte order
7264        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7265        // both `#` and `|`; the `#` byte appears first, so the
7266        // fragment-`#` arm fires, surfacing the more self-locating
7267        // diagnostic on the byte the author pasted earliest in the
7268        // URL. Mirrors the peer cascade discipline
7269        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7270        // pins on the prior `:repo` byte-class arm.
7271        let d = dep_with_fonte(DepSource::Git {
7272            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7273            tag: Some("v0.1.0".into()),
7274            rev: None,
7275            branch: None,
7276        });
7277        let err = d.validate().unwrap_err();
7278        let DepError::FonteRepoShape { reason, .. } = err else {
7279            panic!("expected FonteRepoShape, got other variant");
7280        };
7281        assert!(
7282            reason.contains("must not contain `#`"),
7283            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7284             appears first in value), got {reason:?}"
7285        );
7286    }
7287
7288    #[test]
7289    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7290        // Cascade pin: the backtick arm and the pipe arm are both per-
7291        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7292        // the byte that appears first in the value's byte order wins.
7293        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7294        // `` ` `` and `|`; the backtick byte appears first, so the
7295        // backtick arm fires, surfacing the more self-locating
7296        // diagnostic on the byte the author pasted earliest in the
7297        // URL. Pins the natural-order cascade so a future reorder of
7298        // the per-byte arms surfaces here.
7299        let d = dep_with_fonte(DepSource::Git {
7300            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7301            tag: Some("v0.1.0".into()),
7302            rev: None,
7303            branch: None,
7304        });
7305        let err = d.validate().unwrap_err();
7306        let DepError::FonteRepoShape { reason, .. } = err else {
7307            panic!("expected FonteRepoShape, got other variant");
7308        };
7309        assert!(
7310            reason.contains("must not contain `` ` ``"),
7311            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7312             appears first in value), got {reason:?}"
7313        );
7314    }
7315
7316    #[test]
7317    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7318        // The fail-before-pass-after pin for the canonical
7319        // paste-from-shell-prompt-with-sequential-command-tail footgun
7320        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7321        // `:caminho` path-fonte axis). An author pastes a shell
7322        // one-liner that chained a cleanup tail after the URL
7323        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7324        // echo done`) into the `:repo` slot, forgetting to trim the
7325        // `; <cmd>` tail. Until this arm landed the value silently
7326        // passed every prior `is_git_repo_url` arm (no whitespace, no
7327        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7328        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7329        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7330        // reserved set and the WHATWG URL spec's fragment percent-
7331        // encode set maps `;` → `%3B` on the wire, so the byte rides
7332        // verbatim into the lacre's per-dep BLAKE3 closure but is
7333        // silently rewritten at libcurl's URL-parser layer — two
7334        // authors whose values differ only in their sequential-command
7335        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7336        // identical upstream `git clone` but lock to two distinct
7337        // lacres, defeating the THEORY.md §V.2 render-determinism
7338        // contract. Peer with the `:caminho` axis's
7339        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7340        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7341        // byte RFC-3986-reserved set on `:entrada :paths`.
7342        let d = dep_with_fonte(DepSource::Git {
7343            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7344            tag: Some("v0.1.0".into()),
7345            rev: None,
7346            branch: None,
7347        });
7348        let err = d.validate().unwrap_err();
7349        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7350            panic!("expected FonteRepoShape, got other variant");
7351        };
7352        assert_eq!(nome, "caixa-teia");
7353        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7354        assert!(
7355            reason.contains("must not contain `;`"),
7356            "reason must surface the shell-command-separator arm, got {reason:?}"
7357        );
7358        assert!(
7359            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7360            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7361             rationale, got {reason:?}"
7362        );
7363    }
7364
7365    #[test]
7366    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7367        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7368        // both per-byte arms inside the same `for &b in s.as_bytes()`
7369        // loop, so the byte that appears first in the value's byte
7370        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7371        // carries both `#` and `;`; the `#` byte appears first, so the
7372        // fragment-`#` arm fires, surfacing the more self-locating
7373        // diagnostic on the byte the author pasted earliest in the URL.
7374        // Mirrors the peer cascade discipline
7375        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7376        // pins on the prior `:repo` byte-class arm.
7377        let d = dep_with_fonte(DepSource::Git {
7378            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7379            tag: Some("v0.1.0".into()),
7380            rev: None,
7381            branch: None,
7382        });
7383        let err = d.validate().unwrap_err();
7384        let DepError::FonteRepoShape { reason, .. } = err else {
7385            panic!("expected FonteRepoShape, got other variant");
7386        };
7387        assert!(
7388            reason.contains("must not contain `#`"),
7389            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7390             byte appears first in value), got {reason:?}"
7391        );
7392    }
7393
7394    #[test]
7395    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7396        // Cascade pin: the pipe arm and the semicolon arm are both
7397        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7398        // so the byte that appears first in the value's byte order
7399        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7400        // both `|` and `;`; the `|` byte appears first, so the
7401        // pipe arm fires, surfacing the more self-locating diagnostic
7402        // on the byte the author pasted earliest in the URL. Pins the
7403        // natural-order cascade so a future reorder of the per-byte
7404        // arms surfaces here.
7405        let d = dep_with_fonte(DepSource::Git {
7406            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7407            tag: Some("v0.1.0".into()),
7408            rev: None,
7409            branch: None,
7410        });
7411        let err = d.validate().unwrap_err();
7412        let DepError::FonteRepoShape { reason, .. } = err else {
7413            panic!("expected FonteRepoShape, got other variant");
7414        };
7415        assert!(
7416            reason.contains("must not contain `|`"),
7417            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7418             appears first in value), got {reason:?}"
7419        );
7420    }
7421
7422    #[test]
7423    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7424        // The fail-before-pass-after pin for the canonical
7425        // paste-from-shell-prompt-with-background-launch-tail footgun
7426        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7427        // `:caminho` path-fonte axis). An author pastes a shell one-
7428        // liner that detached the clone into the background
7429        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7430        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7431        // `&& <cmd>` tail. Until this arm landed the value silently
7432        // passed every prior `is_git_repo_url` arm (no whitespace,
7433        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7434        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7435        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7436        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7437        // fragment percent-encode set maps `&` → `%26` on the wire,
7438        // so the byte rides verbatim into the lacre's per-dep
7439        // BLAKE3 closure but is silently rewritten at libcurl's
7440        // URL-parser layer — two authors whose values differ only
7441        // in their background-launch tail (`& sleep 1` vs nothing)
7442        // resolve to the byte-identical upstream `git clone` but
7443        // lock to two distinct lacres, defeating the THEORY.md
7444        // §V.2 render-determinism contract. Peer with the
7445        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7446        // (e12e4f3) on the sibling path-fonte axis, and
7447        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7448        // reserved set on `:entrada :paths`.
7449        let d = dep_with_fonte(DepSource::Git {
7450            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7451            tag: Some("v0.1.0".into()),
7452            rev: None,
7453            branch: None,
7454        });
7455        let err = d.validate().unwrap_err();
7456        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7457            panic!("expected FonteRepoShape, got other variant");
7458        };
7459        assert_eq!(nome, "caixa-teia");
7460        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7461        assert!(
7462            reason.contains("must not contain `&`"),
7463            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7464        );
7465        assert!(
7466            reason.contains("background-task") || reason.contains("'sub-delims'"),
7467            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7468             got {reason:?}"
7469        );
7470    }
7471
7472    #[test]
7473    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7474        // The fail-before-pass-after pin for the symmetric `&&`
7475        // logical-AND build-chain paste footgun: an author pastes
7476        // a `git clone <url> && cd <repo>` build-chain one-liner
7477        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7478        // is the same `&` byte twice in a row; the per-byte arm
7479        // fires on the first `&` it sees. Pinned separately from
7480        // the single-`&` background-launch shape so a future
7481        // diagnostic-surface change that special-cased the
7482        // doubled-byte form surfaces here.
7483        let d = dep_with_fonte(DepSource::Git {
7484            repo: "github:pleme-io/caixa-teia&&echo".into(),
7485            tag: Some("v0.1.0".into()),
7486            rev: None,
7487            branch: None,
7488        });
7489        let err = d.validate().unwrap_err();
7490        let DepError::FonteRepoShape { reason, .. } = err else {
7491            panic!("expected FonteRepoShape, got other variant");
7492        };
7493        assert!(
7494            reason.contains("must not contain `&`"),
7495            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7496             shape too, got {reason:?}"
7497        );
7498    }
7499
7500    #[test]
7501    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7502        // Cascade pin: the fragment-`#` arm and the background-`&`
7503        // arm are both per-byte arms inside the same `for &b in
7504        // s.as_bytes()` loop, so the byte that appears first in the
7505        // value's byte order wins. A `:repo
7506        // "https://github.com/p/x#readme & sleep"` carries both `#`
7507        // and `&`; the `#` byte appears first, so the fragment-`#`
7508        // arm fires, surfacing the more self-locating diagnostic on
7509        // the byte the author pasted earliest in the URL. Mirrors
7510        // the peer cascade discipline
7511        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7512        // on the prior `:repo` byte-class arm.
7513        let d = dep_with_fonte(DepSource::Git {
7514            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7515            tag: Some("v0.1.0".into()),
7516            rev: None,
7517            branch: None,
7518        });
7519        let err = d.validate().unwrap_err();
7520        let DepError::FonteRepoShape { reason, .. } = err else {
7521            panic!("expected FonteRepoShape, got other variant");
7522        };
7523        assert!(
7524            reason.contains("must not contain `#`"),
7525            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7526             byte appears first in value), got {reason:?}"
7527        );
7528    }
7529
7530    #[test]
7531    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7532        // Cascade pin: the semicolon arm and the background-`&` arm
7533        // are both per-byte arms inside the same `for &b in
7534        // s.as_bytes()` loop, so the byte that appears first in the
7535        // value's byte order wins. A `:repo
7536        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7537        // `&`; the `;` byte appears first, so the semicolon arm
7538        // fires, surfacing the more self-locating diagnostic on the
7539        // byte the author pasted earliest in the URL. Pins the
7540        // natural-order cascade so a future reorder of the per-byte
7541        // arms surfaces here.
7542        let d = dep_with_fonte(DepSource::Git {
7543            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7544            tag: Some("v0.1.0".into()),
7545            rev: None,
7546            branch: None,
7547        });
7548        let err = d.validate().unwrap_err();
7549        let DepError::FonteRepoShape { reason, .. } = err else {
7550            panic!("expected FonteRepoShape, got other variant");
7551        };
7552        assert!(
7553            reason.contains("must not contain `;`"),
7554            "reason must surface the semicolon arm (fires before background-`&` when `;` \
7555             byte appears first in value), got {reason:?}"
7556        );
7557    }
7558
7559    #[test]
7560    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7561        // The fail-before-pass-after pin for the canonical
7562        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7563        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7564        // `:caminho` path-fonte axis). An author pastes a shell one-
7565        // liner that referenced an environment variable
7566        // (`git clone https://github.com/$ORG/x`, `git clone
7567        // github:$USER/repo`) into the `:repo` slot, forgetting to
7568        // substitute the literal value at author time. Until this arm
7569        // landed the value silently passed every prior
7570        // `is_git_repo_url` arm (no whitespace, no control chars, no
7571        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7572        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7573        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7574        // reserved set and the WHATWG URL spec's fragment percent-
7575        // encode set maps `$` → `%24` on the wire, so the byte rides
7576        // verbatim into the lacre's per-dep BLAKE3 closure but is
7577        // silently rewritten at libcurl's URL-parser layer — two
7578        // authors whose values differ only in their `$VAR` /
7579        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7580        // identical upstream `git clone` but lock to two distinct
7581        // lacres, defeating the THEORY.md §V.2 render-determinism
7582        // contract. Beyond determinism, the value is a structural
7583        // host-layout leak: two authors with the same `:repo` slot
7584        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7585        // different upstreams. Peer with the `:caminho` axis's
7586        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7587        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7588        // byte RFC-3986-reserved set on `:entrada :paths`.
7589        let d = dep_with_fonte(DepSource::Git {
7590            repo: "https://github.com/$ORG/caixa-teia".into(),
7591            tag: Some("v0.1.0".into()),
7592            rev: None,
7593            branch: None,
7594        });
7595        let err = d.validate().unwrap_err();
7596        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7597            panic!("expected FonteRepoShape, got other variant");
7598        };
7599        assert_eq!(nome, "caixa-teia");
7600        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7601        assert!(
7602            reason.contains("must not contain `$`"),
7603            "reason must surface the shell-variable-expansion arm, got {reason:?}"
7604        );
7605        assert!(
7606            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7607            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7608             rationale, got {reason:?}"
7609        );
7610    }
7611
7612    #[test]
7613    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7614        // The fail-before-pass-after pin for the symmetric POSIX-
7615        // shell braced `${VAR}` expansion paste footgun: an author
7616        // pastes a CI-manifest line `git clone
7617        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7618        // Actions / GitLab CI / Drone shape) and forgets to
7619        // substitute the literal value. The `${...}` shape is the
7620        // same `$` byte at the leading position of the expansion;
7621        // the per-byte arm fires on the `$`. Pinned separately from
7622        // the bare-`$VAR` shape so a future diagnostic-surface
7623        // change that special-cased the braced form surfaces here.
7624        let d = dep_with_fonte(DepSource::Git {
7625            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7626            tag: Some("v0.1.0".into()),
7627            rev: None,
7628            branch: None,
7629        });
7630        let err = d.validate().unwrap_err();
7631        let DepError::FonteRepoShape { reason, .. } = err else {
7632            panic!("expected FonteRepoShape, got other variant");
7633        };
7634        assert!(
7635            reason.contains("must not contain `$`"),
7636            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7637             shape too, got {reason:?}"
7638        );
7639    }
7640
7641    #[test]
7642    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7643        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7644        // arm are both per-byte arms inside the same `for &b in
7645        // s.as_bytes()` loop, so the byte that appears first in the
7646        // value's byte order wins. A `:repo
7647        // "https://github.com/p/x#readme$HOME"` carries both `#` and
7648        // `$`; the `#` byte appears first, so the fragment-`#` arm
7649        // fires, surfacing the more self-locating diagnostic on the
7650        // byte the author pasted earliest in the URL. Mirrors the
7651        // peer cascade discipline
7652        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7653        // on the prior `:repo` byte-class arm.
7654        let d = dep_with_fonte(DepSource::Git {
7655            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7656            tag: Some("v0.1.0".into()),
7657            rev: None,
7658            branch: None,
7659        });
7660        let err = d.validate().unwrap_err();
7661        let DepError::FonteRepoShape { reason, .. } = err else {
7662            panic!("expected FonteRepoShape, got other variant");
7663        };
7664        assert!(
7665            reason.contains("must not contain `#`"),
7666            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7667             `#` byte appears first in value), got {reason:?}"
7668        );
7669    }
7670
7671    #[test]
7672    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7673        // Cascade pin: the background-`&` arm and the
7674        // var-expansion-`$` arm are both per-byte arms inside the
7675        // same `for &b in s.as_bytes()` loop, so the byte that
7676        // appears first in the value's byte order wins. A `:repo
7677        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7678        // `$`; the `&` byte appears first, so the background arm
7679        // fires, surfacing the more self-locating diagnostic on the
7680        // byte the author pasted earliest in the URL. Pins the
7681        // natural-order cascade so a future reorder of the per-byte
7682        // arms surfaces here — `$` is the most recent byte-class arm,
7683        // so the cascade-pin sweep extends to cover every immediately
7684        // prior byte arm (`#`, `&`) firing first when ordered ahead
7685        // of `$` in the value.
7686        let d = dep_with_fonte(DepSource::Git {
7687            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7688            tag: Some("v0.1.0".into()),
7689            rev: None,
7690            branch: None,
7691        });
7692        let err = d.validate().unwrap_err();
7693        let DepError::FonteRepoShape { reason, .. } = err else {
7694            panic!("expected FonteRepoShape, got other variant");
7695        };
7696        assert!(
7697            reason.contains("must not contain `&`"),
7698            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7699             `&` byte appears first in value), got {reason:?}"
7700        );
7701    }
7702
7703    #[test]
7704    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7705        // The fail-before-pass-after pin for the canonical
7706        // paste-from-shell-prompt glob footgun on `:repo` (peer with
7707        // the cf9034b `*` / `?` arm on the sibling `:caminho`
7708        // path-fonte axis). An author pastes a shell one-liner that
7709        // referenced a glob expansion (`ls
7710        // github.com/pleme-io/caixa-*`, `git clone
7711        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7712        // to substitute the literal repo name. Until this arm landed
7713        // the `*` byte silently passed every prior `is_git_repo_url`
7714        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7715        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7716        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7717        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7718        // the WHATWG URL spec's special-query percent-encode set maps
7719        // `*` → `%2A` on the wire, so the byte rides verbatim into
7720        // the lacre's per-dep BLAKE3 closure but is silently
7721        // rewritten at libcurl's URL-parser layer — two authors
7722        // whose values differ only in their asterisk presence
7723        // resolve to the byte-identical upstream `git clone` but
7724        // lock to two distinct lacres, defeating the THEORY.md §V.2
7725        // render-determinism contract. Peer with the `:caminho`
7726        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7727        // sibling path-fonte axis, and the `is_git_ref_name`
7728        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7729        // axes.
7730        let d = dep_with_fonte(DepSource::Git {
7731            repo: "https://github.com/pleme-io/caixa-*".into(),
7732            tag: Some("v0.1.0".into()),
7733            rev: None,
7734            branch: None,
7735        });
7736        let err = d.validate().unwrap_err();
7737        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7738            panic!("expected FonteRepoShape, got other variant");
7739        };
7740        assert_eq!(nome, "caixa-teia");
7741        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7742        assert!(
7743            reason.contains("must not contain `*`"),
7744            "reason must surface the shell-glob arm, got {reason:?}"
7745        );
7746        assert!(
7747            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7748            "reason must name the shell-glob / pathname-expansion / \
7749             RFC-3986-sub-delims rationale, got {reason:?}"
7750        );
7751    }
7752
7753    #[test]
7754    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7755        // The fail-before-pass-after pin for the symmetric bash
7756        // `globstar` recursive-glob paste footgun: an author pastes
7757        // a `ls github.com/pleme-io/**/x` (the canonical
7758        // `globstar`-shopt-enabled recursive-listing tail) into the
7759        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7760        // the per-byte arm fires on the first `*`. Pinned
7761        // separately from the single-`*` shape so a future
7762        // diagnostic-surface change that special-cased the
7763        // double-`*` form surfaces here.
7764        let d = dep_with_fonte(DepSource::Git {
7765            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7766            tag: Some("v0.1.0".into()),
7767            rev: None,
7768            branch: None,
7769        });
7770        let err = d.validate().unwrap_err();
7771        let DepError::FonteRepoShape { reason, .. } = err else {
7772            panic!("expected FonteRepoShape, got other variant");
7773        };
7774        assert!(
7775            reason.contains("must not contain `*`"),
7776            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7777             got {reason:?}"
7778        );
7779    }
7780
7781    #[test]
7782    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7783        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7784        // both per-byte arms inside the same `for &b in s.as_bytes()`
7785        // loop, so the byte that appears first in the value's byte
7786        // order wins. A `:repo
7787        // "https://github.com/p/x#readme*tail"` carries both `#` and
7788        // `*`; the `#` byte appears first, so the fragment-`#` arm
7789        // fires, surfacing the more self-locating diagnostic on the
7790        // byte the author pasted earliest in the URL. Mirrors the
7791        // peer cascade discipline
7792        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7793        // on the prior `:repo` byte-class arm.
7794        let d = dep_with_fonte(DepSource::Git {
7795            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7796            tag: Some("v0.1.0".into()),
7797            rev: None,
7798            branch: None,
7799        });
7800        let err = d.validate().unwrap_err();
7801        let DepError::FonteRepoShape { reason, .. } = err else {
7802            panic!("expected FonteRepoShape, got other variant");
7803        };
7804        assert!(
7805            reason.contains("must not contain `#`"),
7806            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7807             appears first in value), got {reason:?}"
7808        );
7809    }
7810
7811    #[test]
7812    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7813        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7814        // arm are both per-byte arms inside the same `for &b in
7815        // s.as_bytes()` loop, so the byte that appears first in the
7816        // value's byte order wins. A `:repo
7817        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7818        // the `$` byte appears first, so the var-expansion arm
7819        // fires, surfacing the more self-locating diagnostic on the
7820        // byte the author pasted earliest in the URL. Pins the
7821        // natural-order cascade so a future reorder of the per-byte
7822        // arms surfaces here — `*` is the most recent byte-class
7823        // arm, so the cascade-pin sweep extends to cover the
7824        // immediately prior `$` byte arm firing first when ordered
7825        // ahead of `*` in the value.
7826        let d = dep_with_fonte(DepSource::Git {
7827            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7828            tag: Some("v0.1.0".into()),
7829            rev: None,
7830            branch: None,
7831        });
7832        let err = d.validate().unwrap_err();
7833        let DepError::FonteRepoShape { reason, .. } = err else {
7834            panic!("expected FonteRepoShape, got other variant");
7835        };
7836        assert!(
7837            reason.contains("must not contain `$`"),
7838            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7839             byte appears first in value), got {reason:?}"
7840        );
7841    }
7842
7843    #[test]
7844    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7845        // The fail-before-pass-after pin for the canonical paste-from-
7846        // shell-prompt subshell-grouping footgun on `:repo`. An author
7847        // pastes a doc / README snippet carrying a regex-alternation
7848        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7849        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7850        // `:repo` slot, forgetting to substitute one literal org name.
7851        // Until this arm landed the `(` byte silently passed every
7852        // prior `is_git_repo_url` arm (no whitespace, no control
7853        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7854        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7855        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7856        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7857        // URL spec's special-query percent-encode set maps `(` →
7858        // `%28` and `)` → `%29` on the wire, so the byte rides
7859        // verbatim into the lacre's per-dep BLAKE3 closure but is
7860        // silently rewritten at libcurl's URL-parser layer —
7861        // defeating the THEORY.md §V.2 render-determinism contract on
7862        // the same axis the prior twelve byte-class arms close.
7863        let d = dep_with_fonte(DepSource::Git {
7864            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7865            tag: Some("v0.1.0".into()),
7866            rev: None,
7867            branch: None,
7868        });
7869        let err = d.validate().unwrap_err();
7870        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7871            panic!("expected FonteRepoShape, got other variant");
7872        };
7873        assert_eq!(nome, "caixa-teia");
7874        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7875        assert!(
7876            reason.contains("must not contain `(`"),
7877            "reason must surface the subshell-open-paren arm, got {reason:?}"
7878        );
7879        assert!(
7880            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7881            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7882             got {reason:?}"
7883        );
7884    }
7885
7886    #[test]
7887    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7888        // The symmetric arm pin on the closing `)` byte: an author
7889        // pastes a `$(date)` command-substitution wrapper or a
7890        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7891        // Pinned separately from the opening `(` shape so a future
7892        // diagnostic-surface change that only checked one boundary
7893        // surfaces here. The `(` byte appears earlier in the
7894        // canonical regex / subshell wrapper so the per-byte loop
7895        // fires on `(` first; this test exercises a `:repo` value
7896        // carrying only the closing `)` byte (no opening paren) so
7897        // the `)` arm fires directly — pinning the byte-class arm
7898        // independent of order.
7899        let d = dep_with_fonte(DepSource::Git {
7900            repo: "github:pleme-io/caixa-teia)tail".into(),
7901            tag: Some("v0.1.0".into()),
7902            rev: None,
7903            branch: None,
7904        });
7905        let err = d.validate().unwrap_err();
7906        let DepError::FonteRepoShape { reason, .. } = err else {
7907            panic!("expected FonteRepoShape, got other variant");
7908        };
7909        assert!(
7910            reason.contains("must not contain `)`"),
7911            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7912             got {reason:?}"
7913        );
7914    }
7915
7916    #[test]
7917    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7918        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7919        // are both per-byte arms inside the same `for &b in
7920        // s.as_bytes()` loop, so the byte that appears first in the
7921        // value's byte order wins. A `:repo
7922        // "https://github.com/p/x#readme(tail)"` carries both `#` and
7923        // `(`; the `#` byte appears first, so the fragment-`#` arm
7924        // fires, surfacing the more self-locating diagnostic on the
7925        // byte the author pasted earliest in the URL. Mirrors the
7926        // peer cascade discipline
7927        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7928        // on the prior `:repo` byte-class arm.
7929        let d = dep_with_fonte(DepSource::Git {
7930            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7931            tag: Some("v0.1.0".into()),
7932            rev: None,
7933            branch: None,
7934        });
7935        let err = d.validate().unwrap_err();
7936        let DepError::FonteRepoShape { reason, .. } = err else {
7937            panic!("expected FonteRepoShape, got other variant");
7938        };
7939        assert!(
7940            reason.contains("must not contain `#`"),
7941            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7942             byte appears first in value), got {reason:?}"
7943        );
7944    }
7945
7946    #[test]
7947    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7948        // Cascade pin: the glob-`*` arm (the immediate-predecessor
7949        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7950        // per-byte arms inside the same `for &b in s.as_bytes()`
7951        // loop, so the byte that appears first in the value's byte
7952        // order wins. A `:repo
7953        // "https://github.com/p/x-*-(date)"` carries both `*` and
7954        // `(`; the `*` byte appears first, so the glob arm fires,
7955        // surfacing the more self-locating diagnostic on the byte
7956        // the author pasted earliest in the URL. Pins the natural-
7957        // order cascade so a future reorder of the per-byte arms
7958        // surfaces here — `(` is the most recent byte-class arm,
7959        // so the cascade-pin sweep extends to cover the immediately
7960        // prior `*` byte arm firing first when ordered ahead of `(`
7961        // in the value.
7962        let d = dep_with_fonte(DepSource::Git {
7963            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7964            tag: Some("v0.1.0".into()),
7965            rev: None,
7966            branch: None,
7967        });
7968        let err = d.validate().unwrap_err();
7969        let DepError::FonteRepoShape { reason, .. } = err else {
7970            panic!("expected FonteRepoShape, got other variant");
7971        };
7972        assert!(
7973            reason.contains("must not contain `*`"),
7974            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7975             appears first in value), got {reason:?}"
7976        );
7977    }
7978
7979    #[test]
7980    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7981        // The fail-before-pass-after pin for the canonical paste-from-
7982        // doc-shell-quoting footgun on `:repo`. An author copies a
7983        // README quick-start snippet (`$ git clone "https://github.com/
7984        // foo/bar"`) and keeps the surrounding double-quote bytes when
7985        // pasting into the `:repo` slot — the doc wraps the URL in
7986        // double quotes so the shell doesn't re-lex metachars inside,
7987        // but the typed slot is itself a byte-level string parser, not
7988        // a shell context, so the quote bytes ride into the value
7989        // verbatim. Until this arm landed the `"` byte silently passed
7990        // every prior `is_git_repo_url` arm (no whitespace, no control
7991        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7992        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7993        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7994        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7995        // `` ` ``) every URL parser is required to refuse or percent-
7996        // encode, and the WHATWG URL spec's 'C0 control percent-encode
7997        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7998        // into the lacre's per-dep BLAKE3 closure but is silently
7999        // rewritten at libcurl's URL-parser layer, defeating the
8000        // THEORY.md §V.2 render-determinism contract.
8001        let d = dep_with_fonte(DepSource::Git {
8002            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8003            tag: Some("v0.1.0".into()),
8004            rev: None,
8005            branch: None,
8006        });
8007        let err = d.validate().unwrap_err();
8008        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8009            panic!("expected FonteRepoShape, got other variant");
8010        };
8011        assert_eq!(nome, "caixa-teia");
8012        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8013        assert!(
8014            reason.contains("must not contain `\"`"),
8015            "reason must surface the shell-double-quote arm, got {reason:?}"
8016        );
8017        assert!(
8018            reason.contains("double-quote") || reason.contains("'delims'"),
8019            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8020             got {reason:?}"
8021        );
8022    }
8023
8024    #[test]
8025    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8026        // The symmetric stray-quote tail pin: an author pastes only a
8027        // closing `"` from a shell-history line like `git clone
8028        // "https://github.com/foo/bar" && cd …` (the trim went too
8029        // far in one direction but not the other) into the `:repo`
8030        // slot. Pinned separately from the wrapped-quote shape so a
8031        // future diagnostic-surface change that only checked one
8032        // boundary (only leading, only trailing, only paired) surfaces
8033        // here — the per-byte arm fires anywhere `"` appears.
8034        let d = dep_with_fonte(DepSource::Git {
8035            repo: "github:pleme-io/caixa-teia\"".into(),
8036            tag: Some("v0.1.0".into()),
8037            rev: None,
8038            branch: None,
8039        });
8040        let err = d.validate().unwrap_err();
8041        let DepError::FonteRepoShape { reason, .. } = err else {
8042            panic!("expected FonteRepoShape, got other variant");
8043        };
8044        assert!(
8045            reason.contains("must not contain `\"`"),
8046            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8047             got {reason:?}"
8048        );
8049    }
8050
8051    #[test]
8052    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8053        // Cascade pin: the fragment-`#` arm and the double-quote arm
8054        // are both per-byte arms inside the same `for &b in
8055        // s.as_bytes()` loop, so the byte that appears first in the
8056        // value's byte order wins. A `:repo
8057        // "https://github.com/p/x#readme\"tail"` carries both `#` and
8058        // `"`; the `#` byte appears first, so the fragment-`#` arm
8059        // fires, surfacing the more self-locating diagnostic on the
8060        // byte the author pasted earliest in the URL.
8061        let d = dep_with_fonte(DepSource::Git {
8062            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8063            tag: Some("v0.1.0".into()),
8064            rev: None,
8065            branch: None,
8066        });
8067        let err = d.validate().unwrap_err();
8068        let DepError::FonteRepoShape { reason, .. } = err else {
8069            panic!("expected FonteRepoShape, got other variant");
8070        };
8071        assert!(
8072            reason.contains("must not contain `#`"),
8073            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8074             byte appears first in value), got {reason:?}"
8075        );
8076    }
8077
8078    #[test]
8079    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8080        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8081        // byte-class arm, 3b99147) and the double-quote arm are both
8082        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8083        // so the byte that appears first in the value's byte order
8084        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8085        // and `"`; the `(` byte appears first, so the subshell arm
8086        // fires, surfacing the more self-locating diagnostic on the
8087        // byte the author pasted earliest in the URL. Pins the natural-
8088        // order cascade so a future reorder of the per-byte arms
8089        // surfaces here — `"` is the most recent byte-class arm, so
8090        // the cascade-pin sweep extends to cover the immediately prior
8091        // `(` byte arm firing first when ordered ahead of `"` in the
8092        // value.
8093        let d = dep_with_fonte(DepSource::Git {
8094            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8095            tag: Some("v0.1.0".into()),
8096            rev: None,
8097            branch: None,
8098        });
8099        let err = d.validate().unwrap_err();
8100        let DepError::FonteRepoShape { reason, .. } = err else {
8101            panic!("expected FonteRepoShape, got other variant");
8102        };
8103        assert!(
8104            reason.contains("must not contain `(`"),
8105            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8106             byte appears first in value), got {reason:?}"
8107        );
8108    }
8109
8110    #[test]
8111    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8112        // The fail-before-pass-after pin for the canonical paste-from-
8113        // doc-strong-quoting footgun on `:repo`. An author copies a
8114        // security-conscious README quick-start snippet (`$ git clone
8115        // 'https://github.com/foo/bar'`) and keeps the surrounding
8116        // single-quote bytes when pasting into the `:repo` slot — the
8117        // doc strong-quotes the URL so the shell suppresses every form
8118        // of expansion on the bytes inside (no `$`, no backtick, no
8119        // glob, no word-splitting), but the typed slot is itself a
8120        // byte-level string parser, not a shell context, so the quote
8121        // bytes ride into the value verbatim. Until this arm landed the
8122        // `'` byte silently passed every prior `is_git_repo_url` arm
8123        // (no whitespace, no control chars, no non-ASCII, no `#`, no
8124        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8125        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8126        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8127        // set, peer with the `\"` 'delims' double-quote arm and the
8128        // partner ASCII shell-string-delimiter byte every byte-level
8129        // string parser sharing a value-shape with a shell argument
8130        // must refuse on a URL-shaped slot.
8131        let d = dep_with_fonte(DepSource::Git {
8132            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8133            tag: Some("v0.1.0".into()),
8134            rev: None,
8135            branch: None,
8136        });
8137        let err = d.validate().unwrap_err();
8138        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8139            panic!("expected FonteRepoShape, got other variant");
8140        };
8141        assert_eq!(nome, "caixa-teia");
8142        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8143        assert!(
8144            reason.contains("must not contain `'`"),
8145            "reason must surface the shell-single-quote arm, got {reason:?}"
8146        );
8147        assert!(
8148            reason.contains("single-quote") || reason.contains("strong-quote"),
8149            "reason must name the shell-single-quote / strong-quote rationale, \
8150             got {reason:?}"
8151        );
8152    }
8153
8154    #[test]
8155    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8156        // The symmetric English-typography pin: an author writes
8157        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8158        // from-prose idiom every README / commit-message / chat-thread
8159        // reference to a repo carries) expecting the substrate to
8160        // coerce it to a kebab-case slug — but the byte rides into the
8161        // lacre verbatim. Pinned separately from the wrapped-quote
8162        // shape so a future diagnostic-surface change that only checked
8163        // the boundary positions (only leading, only trailing, only
8164        // paired) surfaces here — the per-byte arm fires anywhere `'`
8165        // appears in the value.
8166        let d = dep_with_fonte(DepSource::Git {
8167            repo: "github:pleme-io/repo's-fork".into(),
8168            tag: Some("v0.1.0".into()),
8169            rev: None,
8170            branch: None,
8171        });
8172        let err = d.validate().unwrap_err();
8173        let DepError::FonteRepoShape { reason, .. } = err else {
8174            panic!("expected FonteRepoShape, got other variant");
8175        };
8176        assert!(
8177            reason.contains("must not contain `'`"),
8178            "reason must surface the shell-single-quote arm on the mid-string \
8179             apostrophe shape, got {reason:?}"
8180        );
8181    }
8182
8183    #[test]
8184    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8185        // Cascade pin: the fragment-`#` arm and the single-quote arm
8186        // are both per-byte arms inside the same `for &b in
8187        // s.as_bytes()` loop, so the byte that appears first in the
8188        // value's byte order wins. A `:repo
8189        // "https://github.com/p/x#readme'tail"` carries both `#` and
8190        // `'`; the `#` byte appears first, so the fragment-`#` arm
8191        // fires, surfacing the more self-locating diagnostic on the
8192        // byte the author pasted earliest in the URL.
8193        let d = dep_with_fonte(DepSource::Git {
8194            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8195            tag: Some("v0.1.0".into()),
8196            rev: None,
8197            branch: None,
8198        });
8199        let err = d.validate().unwrap_err();
8200        let DepError::FonteRepoShape { reason, .. } = err else {
8201            panic!("expected FonteRepoShape, got other variant");
8202        };
8203        assert!(
8204            reason.contains("must not contain `#`"),
8205            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8206             byte appears first in value), got {reason:?}"
8207        );
8208    }
8209
8210    #[test]
8211    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8212        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8213        // byte-class arm, 4267d8b) and the single-quote arm are both
8214        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8215        // so the byte that appears first in the value's byte order
8216        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8217        // `'`; the `"` byte appears first, so the double-quote arm
8218        // fires, surfacing the more self-locating diagnostic on the
8219        // byte the author pasted earliest in the URL. Pins the natural-
8220        // order cascade so a future reorder of the per-byte arms
8221        // surfaces here — `'` is the most recent byte-class arm, so
8222        // the cascade-pin sweep extends to cover the immediately prior
8223        // `"` byte arm firing first when ordered ahead of `'` in the
8224        // value.
8225        let d = dep_with_fonte(DepSource::Git {
8226            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8227            tag: Some("v0.1.0".into()),
8228            rev: None,
8229            branch: None,
8230        });
8231        let err = d.validate().unwrap_err();
8232        let DepError::FonteRepoShape { reason, .. } = err else {
8233            panic!("expected FonteRepoShape, got other variant");
8234        };
8235        assert!(
8236            reason.contains("must not contain `\"`"),
8237            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8238             byte appears first in value), got {reason:?}"
8239        );
8240    }
8241
8242    #[test]
8243    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8244        // The fail-before-pass-after pin for the canonical paste-from-
8245        // shell-history footgun on `:repo`. An author copies a `git
8246        // clone <url>!sudo make install` one-liner from a README's
8247        // quick-start snippet, intending the trailing `!sudo` as a
8248        // shell-history-expansion reference but the typed slot is itself
8249        // a byte-level string parser, not a shell context, so the byte
8250        // rides into the value verbatim. Until this arm landed the `!`
8251        // byte silently passed every prior `is_git_repo_url` arm (no
8252        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8253        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8254        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8255        // start with `-` or `:`); bash with the default `histexpand`
8256        // mode rewrites `!command` to the most recent history entry
8257        // beginning with `command`, the canonical RCE-class injection
8258        // vector when the byte rides into a shell argument.
8259        let d = dep_with_fonte(DepSource::Git {
8260            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8261            tag: Some("v0.1.0".into()),
8262            rev: None,
8263            branch: None,
8264        });
8265        let err = d.validate().unwrap_err();
8266        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8267            panic!("expected FonteRepoShape, got other variant");
8268        };
8269        assert_eq!(nome, "caixa-teia");
8270        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8271        assert!(
8272            reason.contains("must not contain `!`"),
8273            "reason must surface the shell-history-expansion arm, got {reason:?}"
8274        );
8275        assert!(
8276            reason.contains("history-expansion") || reason.contains("bang"),
8277            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8278        );
8279    }
8280
8281    #[test]
8282    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8283        // The symmetric `!!` repeat-prior-command pin: an author paste-
8284        // trims a `git clone <url>` retry idiom from shell history that
8285        // expands to the previous command via `!!`. Pinned separately
8286        // from the wrapped `!command` shape so a future diagnostic-
8287        // surface change that only checked the leading or paired-bang
8288        // position surfaces here — the per-byte arm fires anywhere `!`
8289        // appears in the value.
8290        let d = dep_with_fonte(DepSource::Git {
8291            repo: "github:pleme-io/caixa-teia!!".into(),
8292            tag: Some("v0.1.0".into()),
8293            rev: None,
8294            branch: None,
8295        });
8296        let err = d.validate().unwrap_err();
8297        let DepError::FonteRepoShape { reason, .. } = err else {
8298            panic!("expected FonteRepoShape, got other variant");
8299        };
8300        assert!(
8301            reason.contains("must not contain `!`"),
8302            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8303             got {reason:?}"
8304        );
8305    }
8306
8307    #[test]
8308    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8309        // Cascade pin: the fragment-`#` arm and the bang arm are both
8310        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8311        // so the byte that appears first in the value's byte order
8312        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8313        // both `#` and `!`; the `#` byte appears first, so the
8314        // fragment-`#` arm fires, surfacing the more self-locating
8315        // diagnostic on the byte the author pasted earliest in the URL.
8316        let d = dep_with_fonte(DepSource::Git {
8317            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8318            tag: Some("v0.1.0".into()),
8319            rev: None,
8320            branch: None,
8321        });
8322        let err = d.validate().unwrap_err();
8323        let DepError::FonteRepoShape { reason, .. } = err else {
8324            panic!("expected FonteRepoShape, got other variant");
8325        };
8326        assert!(
8327            reason.contains("must not contain `#`"),
8328            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8329             appears first in value), got {reason:?}"
8330        );
8331    }
8332
8333    #[test]
8334    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8335        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8336        // byte-class arm, e7a109f) and the bang arm are both per-byte
8337        // arms inside the same `for &b in s.as_bytes()` loop, so the
8338        // byte that appears first in the value's byte order wins. A
8339        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8340        // `'` byte appears first, so the single-quote arm fires,
8341        // surfacing the more self-locating diagnostic on the byte the
8342        // author pasted earliest in the URL. Pins the natural-order
8343        // cascade so a future reorder of the per-byte arms surfaces
8344        // here — `!` is the most recent byte-class arm, so the
8345        // cascade-pin sweep extends to cover the immediately prior `'`
8346        // byte arm firing first when ordered ahead of `!` in the value.
8347        let d = dep_with_fonte(DepSource::Git {
8348            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8349            tag: Some("v0.1.0".into()),
8350            rev: None,
8351            branch: None,
8352        });
8353        let err = d.validate().unwrap_err();
8354        let DepError::FonteRepoShape { reason, .. } = err else {
8355            panic!("expected FonteRepoShape, got other variant");
8356        };
8357        assert!(
8358            reason.contains("must not contain `'`"),
8359            "reason must surface the single-quote arm (fires before bang when `'` byte \
8360             appears first in value), got {reason:?}"
8361        );
8362    }
8363
8364    #[test]
8365    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8366        // The fail-before-pass-after pin for the canonical
8367        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8368        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8369        // one-liner from a multi-repo bootstrap doc, intending the
8370        // comma to separate multiple repo entries but the typed
8371        // `:repo` slot names *one* repo (the list-separator belongs
8372        // to the `:deps` list grammar, not to the value). Until this
8373        // arm landed the `,` byte silently passed every prior
8374        // `is_git_repo_url` arm (no whitespace, no control chars, no
8375        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8376        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8377        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8378        // `:`); the byte rode into the lacre's per-dep content-
8379        // address and the resolver's `git clone <repo>` subprocess
8380        // invocation, where no host's repo registry resolved the
8381        // comma-bearing slug.
8382        let d = dep_with_fonte(DepSource::Git {
8383            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8384            tag: Some("v0.1.0".into()),
8385            rev: None,
8386            branch: None,
8387        });
8388        let err = d.validate().unwrap_err();
8389        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8390            panic!("expected FonteRepoShape, got other variant");
8391        };
8392        assert_eq!(nome, "caixa-teia");
8393        assert_eq!(
8394            repo,
8395            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8396        );
8397        assert!(
8398            reason.contains("must not contain `,`"),
8399            "reason must surface the list-separator-comma arm, got {reason:?}"
8400        );
8401        assert!(
8402            reason.contains("list-separator") || reason.contains("sub-delims"),
8403            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8404             got {reason:?}"
8405        );
8406    }
8407
8408    #[test]
8409    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8410        // The symmetric trailing-`,` paste-from-prose pin: an author
8411        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8412        // comma every README-prose list-of-projects sentence carries,
8413        // mistakenly retained when the slug is pasted mid-sentence)
8414        // expecting the substrate to coerce it to a kebab-case slug.
8415        // Pinned separately from the wrapped mid-token shape so a
8416        // future diagnostic-surface change that only checked the
8417        // leading or paired-comma position surfaces here — the
8418        // per-byte arm fires anywhere `,` appears in the value.
8419        let d = dep_with_fonte(DepSource::Git {
8420            repo: "github:pleme-io/caixa-feira,".into(),
8421            tag: Some("v0.1.0".into()),
8422            rev: None,
8423            branch: None,
8424        });
8425        let err = d.validate().unwrap_err();
8426        let DepError::FonteRepoShape { reason, .. } = err else {
8427            panic!("expected FonteRepoShape, got other variant");
8428        };
8429        assert!(
8430            reason.contains("must not contain `,`"),
8431            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8432             got {reason:?}"
8433        );
8434    }
8435
8436    #[test]
8437    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8438        // Cascade pin: the fragment-`#` arm and the comma arm are
8439        // both per-byte arms inside the same `for &b in s.as_bytes()`
8440        // loop, so the byte that appears first in the value's byte
8441        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8442        // carries both `#` and `,`; the `#` byte appears first, so
8443        // the fragment-`#` arm fires, surfacing the more self-
8444        // locating diagnostic on the byte the author pasted earliest
8445        // in the URL.
8446        let d = dep_with_fonte(DepSource::Git {
8447            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8448            tag: Some("v0.1.0".into()),
8449            rev: None,
8450            branch: None,
8451        });
8452        let err = d.validate().unwrap_err();
8453        let DepError::FonteRepoShape { reason, .. } = err else {
8454            panic!("expected FonteRepoShape, got other variant");
8455        };
8456        assert!(
8457            reason.contains("must not contain `#`"),
8458            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8459             appears first in value), got {reason:?}"
8460        );
8461    }
8462
8463    #[test]
8464    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8465        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8466        // byte-class arm, 7d53c68) and the comma arm are both
8467        // per-byte arms inside the same `for &b in s.as_bytes()`
8468        // loop, so the byte that appears first in the value's byte
8469        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8470        // `!` and `,`; the `!` byte appears first, so the bang arm
8471        // fires, surfacing the more self-locating diagnostic on the
8472        // byte the author pasted earliest in the URL. Pins the
8473        // natural-order cascade so a future reorder of the per-byte
8474        // arms surfaces here — `,` is the most recent byte-class
8475        // arm, so the cascade-pin sweep extends to cover the
8476        // immediately prior `!` byte arm firing first when ordered
8477        // ahead of `,` in the value.
8478        let d = dep_with_fonte(DepSource::Git {
8479            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8480            tag: Some("v0.1.0".into()),
8481            rev: None,
8482            branch: None,
8483        });
8484        let err = d.validate().unwrap_err();
8485        let DepError::FonteRepoShape { reason, .. } = err else {
8486            panic!("expected FonteRepoShape, got other variant");
8487        };
8488        assert!(
8489            reason.contains("must not contain `!`"),
8490            "reason must surface the bang arm (fires before comma when `!` byte \
8491             appears first in value), got {reason:?}"
8492        );
8493    }
8494
8495    #[test]
8496    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8497        // The fail-before-pass-after pin for the canonical
8498        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8499        // on `:repo`. An author copies
8500        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8501        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8502        // git clone <url>`, etc. — the canonical
8503        // git-troubleshooting README idiom for a one-shot env-var
8504        // scoped to the `git clone` invocation) from a shell-prompt
8505        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8506        // grammar env-var assignment but the typed `:repo` slot is
8507        // a value parser, not a shell context, so the bytes ride
8508        // into the value verbatim. Until this arm landed the `=`
8509        // byte silently passed every prior `is_git_repo_url` arm
8510        // (no whitespace, no control chars, no non-ASCII, no `#`,
8511        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8512        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8513        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8514        // the byte rode into the lacre's per-dep content-address
8515        // and the resolver's `git clone <repo>` subprocess
8516        // invocation, where the upstream host's git porcelain
8517        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8518        // path that no host's repo registry resolves.
8519        let d = dep_with_fonte(DepSource::Git {
8520            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8521            tag: Some("v0.1.0".into()),
8522            rev: None,
8523            branch: None,
8524        });
8525        let err = d.validate().unwrap_err();
8526        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8527            panic!("expected FonteRepoShape, got other variant");
8528        };
8529        assert_eq!(nome, "caixa-teia");
8530        assert_eq!(
8531            repo,
8532            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8533        );
8534        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8535        // appears before the ` ` byte at position 21, so the `=`
8536        // arm fires (not the whitespace arm) — both arms guard
8537        // the slot, but the per-byte for-loop scans left-to-right
8538        // and the first matching byte wins.
8539        assert!(
8540            reason.contains("must not contain `=`"),
8541            "reason must surface the equals-`=` arm on the env-var-assignment \
8542             paste shape, got {reason:?}"
8543        );
8544        assert!(
8545            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8546            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8547        );
8548    }
8549
8550    #[test]
8551    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8552        // The symmetric paste-from-gitconfig pin: an author copies
8553        // `url=https://github.com/p/x` from `git config --get-all
8554        // remote.origin.url` output, a `.gitconfig` `[remote
8555        // "origin"] url = https://…` ini-stanza paste, or a
8556        // `git config remote.origin.url <value>` doc snippet,
8557        // intending the `url=` prefix as the ini-key but the typed
8558        // `:repo` slot is a URL value parser, not a gitconfig
8559        // grammar. With no leading whitespace and no earlier-arm
8560        // bytes in the value, the `=` arm itself fires (rather
8561        // than cascading to the whitespace arm as in the env-var
8562        // paste shape). Pinned separately so a future diagnostic-
8563        // surface change that only checked the whitespace-leading
8564        // shape surfaces here — the per-byte arm fires anywhere
8565        // `=` appears in the value.
8566        let d = dep_with_fonte(DepSource::Git {
8567            repo: "url=https://github.com/pleme-io/caixa-feira".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 equals-`=` arm on the `url=…` gitconfig \
8579             paste shape, got {reason:?}"
8580        );
8581        assert!(
8582            reason.contains("key-value-separator") || reason.contains("sub-delims"),
8583            "reason must name the key-value-separator / RFC-3986-sub-delims \
8584             rationale, got {reason:?}"
8585        );
8586    }
8587
8588    #[test]
8589    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8590        // Cascade pin: the fragment-`#` arm and the `=` arm are
8591        // both per-byte arms inside the same `for &b in s.as_bytes()`
8592        // loop, so the byte that appears first in the value's byte
8593        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8594        // carries both `#` and `=`; the `#` byte appears first, so
8595        // the fragment-`#` arm fires, surfacing the more self-
8596        // locating diagnostic on the byte the author pasted earliest
8597        // in the URL.
8598        let d = dep_with_fonte(DepSource::Git {
8599            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8600            tag: Some("v0.1.0".into()),
8601            rev: None,
8602            branch: None,
8603        });
8604        let err = d.validate().unwrap_err();
8605        let DepError::FonteRepoShape { reason, .. } = err else {
8606            panic!("expected FonteRepoShape, got other variant");
8607        };
8608        assert!(
8609            reason.contains("must not contain `#`"),
8610            "reason must surface the fragment-`#` arm (fires before equals when \
8611             `#` byte appears first in value), got {reason:?}"
8612        );
8613    }
8614
8615    #[test]
8616    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8617        // Cascade pin: the comma-`,` arm (the immediate-predecessor
8618        // byte-class arm, 775b80e) and the `=` arm are both per-byte
8619        // arms inside the same `for &b in s.as_bytes()` loop, so
8620        // the byte that appears first in the value's byte order
8621        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8622        // and `=`; the `,` byte appears first, so the comma arm
8623        // fires, surfacing the more self-locating diagnostic on
8624        // the byte the author pasted earliest in the URL. Pins the
8625        // natural-order cascade so a future reorder of the per-byte
8626        // arms surfaces here — `=` is the most recent byte-class
8627        // arm, so the cascade-pin sweep extends to cover the
8628        // immediately prior `,` byte arm firing first when ordered
8629        // ahead of `=` in the value.
8630        let d = dep_with_fonte(DepSource::Git {
8631            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8632            tag: Some("v0.1.0".into()),
8633            rev: None,
8634            branch: None,
8635        });
8636        let err = d.validate().unwrap_err();
8637        let DepError::FonteRepoShape { reason, .. } = err else {
8638            panic!("expected FonteRepoShape, got other variant");
8639        };
8640        assert!(
8641            reason.contains("must not contain `,`"),
8642            "reason must surface the comma arm (fires before equals when `,` byte \
8643             appears first in value), got {reason:?}"
8644        );
8645    }
8646
8647    #[test]
8648    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8649        // The fail-before-pass-after pin for the canonical paste-from-
8650        // browser-address-bar percent-encoded-space footgun on `:repo`.
8651        // An author copies `https://github.com/p/x%20test` from a
8652        // browser address bar (or a percent-encoded README hyperlink,
8653        // or a `curl --data-urlencode` shell-pipeline output)
8654        // intending `%20` as the URL encoding of a literal space; the
8655        // typed `:repo` slot already rejects the literal space byte
8656        // (the whitespace arm at the top of `is_git_repo_url`), so an
8657        // author trying to express "I really meant a space" reaches
8658        // for percent-encoding. Until this arm landed the `%` byte
8659        // silently passed every prior `is_git_repo_url` arm and rode
8660        // verbatim into the lacre's per-dep content-address — but
8661        // libcurl re-percent-encodes `%` to `%25` on the wire (since
8662        // `%` is reserved as the escape-sequence lead-in), so the
8663        // wire request becomes `https://github.com/p/x%2520test`, a
8664        // path the lacre's content-address never names. The classic
8665        // render-determinism violation on the encoding-mechanism axis
8666        // itself.
8667        let d = dep_with_fonte(DepSource::Git {
8668            repo: "https://github.com/pleme-io/caixa-teia%20test".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%20test");
8679        assert!(
8680            reason.contains("must not contain `%`"),
8681            "reason must surface the percent-`%` arm on the percent-encoded-space \
8682             paste shape, got {reason:?}"
8683        );
8684        assert!(
8685            reason.contains("percent-encoding") || reason.contains("%25"),
8686            "reason must name the percent-encoding / `%25` re-encoding rationale, \
8687             got {reason:?}"
8688        );
8689    }
8690
8691    #[test]
8692    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8693        // The symmetric over-encoded-path-separator pin: an author
8694        // writes `:repo "https://github.com/p%2Fx"` intending the
8695        // `%2F` as the URL encoding of `/` (the canonical
8696        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8697        // footgun every API client library and OAuth redirect-URI
8698        // documentation surfaces — the `/` is the URL-path-separator
8699        // and some templates percent-encode it to escape interpretation
8700        // as a path separator). The GitHub Smart-HTTP transport
8701        // resolves the URL's path-segment grammar before the
8702        // percent-decoding pass, so the value identifies a different
8703        // resource on the wire than the literal-`/` form the lacre's
8704        // content-address must agree with — two authors whose `:repo`
8705        // values differ only in their `/` vs `%2F` presence lock to
8706        // two distinct BLAKE3 closures for the byte-identical upstream
8707        // `git clone`. Pinned separately so a future diagnostic
8708        // surface that only catches the `%20` shape surfaces here too.
8709        let d = dep_with_fonte(DepSource::Git {
8710            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8711            tag: Some("v0.1.0".into()),
8712            rev: None,
8713            branch: None,
8714        });
8715        let err = d.validate().unwrap_err();
8716        let DepError::FonteRepoShape { reason, .. } = err else {
8717            panic!("expected FonteRepoShape, got other variant");
8718        };
8719        assert!(
8720            reason.contains("must not contain `%`"),
8721            "reason must surface the percent-`%` arm on the over-encoded-path \
8722             shape, got {reason:?}"
8723        );
8724        assert!(
8725            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8726            "reason must name the render-determinism / BLAKE3-closure rationale, \
8727             got {reason:?}"
8728        );
8729    }
8730
8731    #[test]
8732    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8733        // Cascade pin: the fragment-`#` arm and the `%` arm are both
8734        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8735        // so the byte that appears first in the value's byte order
8736        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8737        // both `#` and `%`; the `#` byte appears first, so the
8738        // fragment-`#` arm fires, surfacing the more self-locating
8739        // diagnostic on the byte the author pasted earliest in the URL.
8740        let d = dep_with_fonte(DepSource::Git {
8741            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".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 fragment-`#` arm (fires before percent when \
8753             `#` byte appears first in value), got {reason:?}"
8754        );
8755    }
8756
8757    #[test]
8758    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8759        // Cascade pin: the equals-`=` arm (the immediate-predecessor
8760        // byte-class arm, acf99af) and the `%` arm are both per-byte
8761        // arms inside the same `for &b in s.as_bytes()` loop, so the
8762        // byte that appears first in the value's byte order wins.
8763        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8764        // the `=` byte appears first, so the equals arm fires,
8765        // surfacing the more self-locating diagnostic on the byte the
8766        // author pasted earliest in the URL. Pins the natural-order
8767        // cascade so a future reorder of the per-byte arms surfaces
8768        // here — `%` is the most recent byte-class arm, so the
8769        // cascade-pin sweep extends to cover the immediately prior
8770        // `=` byte arm firing first when ordered ahead of `%` in the
8771        // value.
8772        let d = dep_with_fonte(DepSource::Git {
8773            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8774            tag: Some("v0.1.0".into()),
8775            rev: None,
8776            branch: None,
8777        });
8778        let err = d.validate().unwrap_err();
8779        let DepError::FonteRepoShape { reason, .. } = err else {
8780            panic!("expected FonteRepoShape, got other variant");
8781        };
8782        assert!(
8783            reason.contains("must not contain `=`"),
8784            "reason must surface the equals arm (fires before percent when `=` byte \
8785             appears first in value), got {reason:?}"
8786        );
8787    }
8788
8789    #[test]
8790    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8791        // The fail-before-pass-after pin for the canonical paste-from-
8792        // shell-history footgun on `:repo`. An author copies a
8793        // `git clone <url>` line from their terminal followed by a
8794        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8795        // history shorthand (the `^old^new^` form re-runs the prior
8796        // history entry with the first `old` substituted by `new`,
8797        // bash's default behavior on interactive sessions with
8798        // `set -o histexpand`), forgetting to trim the trailing
8799        // `^...^...` shell-history fragment from the URL value. The
8800        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8801        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8802        // classes), the WHATWG URL spec's 'fragment percent-encode
8803        // set' maps `^` → `%5E` on the wire, so the byte rides
8804        // verbatim into the lacre's per-dep content-address but
8805        // libcurl re-encodes it to `%5E` at `git clone` time — the
8806        // classic render-determinism violation on the same axis the
8807        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8808        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8809        // `#` arms close.
8810        let d = dep_with_fonte(DepSource::Git {
8811            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8812            tag: Some("v0.1.0".into()),
8813            rev: None,
8814            branch: None,
8815        });
8816        let err = d.validate().unwrap_err();
8817        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8818            panic!("expected FonteRepoShape, got other variant");
8819        };
8820        assert_eq!(nome, "caixa-teia");
8821        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8822        assert!(
8823            reason.contains("must not contain `^`"),
8824            "reason must surface the caret-`^` arm on the paste-from-shell-history \
8825             shape, got {reason:?}"
8826        );
8827        assert!(
8828            reason.contains("history-substitution") || reason.contains("%5E"),
8829            "reason must name the shell-history-substitution / `%5E` wire-encoding \
8830             rationale, got {reason:?}"
8831        );
8832    }
8833
8834    #[test]
8835    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8836        // The symmetric paste-from-doc-grep-pipeline footgun: an
8837        // author writes `:repo "github:p/^archived"` after copying a
8838        // `grep '^archived'` regex-anchor / negation idiom from a
8839        // doc / README quick-listing snippet, expecting the substrate
8840        // to coerce it to a literal repo name. The byte rides
8841        // verbatim into the lacre's per-dep content-address and
8842        // diverges from the byte-identical literal `archived` form
8843        // every other author authored — the canonical render-
8844        // determinism violation pin on the second footgun shape the
8845        // caret-`^` arm closes.
8846        let d = dep_with_fonte(DepSource::Git {
8847            repo: "github:pleme-io/^archived".into(),
8848            tag: Some("v0.1.0".into()),
8849            rev: None,
8850            branch: None,
8851        });
8852        let err = d.validate().unwrap_err();
8853        let DepError::FonteRepoShape { reason, .. } = err else {
8854            panic!("expected FonteRepoShape, got other variant");
8855        };
8856        assert!(
8857            reason.contains("must not contain `^`"),
8858            "reason must surface the caret-`^` arm on the regex-anchor shape, \
8859             got {reason:?}"
8860        );
8861        assert!(
8862            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8863            "reason must name the render-determinism / BLAKE3-closure rationale, \
8864             got {reason:?}"
8865        );
8866    }
8867
8868    #[test]
8869    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8870        // Cascade pin: the `%` arm (the immediate-predecessor byte-
8871        // class arm, a323db8) and the `^` arm are both per-byte arms
8872        // inside the same `for &b in s.as_bytes()` loop, so the byte
8873        // that appears first in the value's byte order wins. A
8874        // `:repo "https://github.com/p/x%20mid^tail"` carries both
8875        // `%` and `^`; the `%` byte appears first, so the percent
8876        // arm fires, surfacing the more self-locating diagnostic on
8877        // the byte the author pasted earliest in the URL. Pins the
8878        // natural-order cascade so a future reorder of the per-byte
8879        // arms surfaces here — `^` is the most recent byte-class arm,
8880        // so the cascade-pin sweep extends to cover the immediately
8881        // prior `%` byte arm firing first when ordered ahead of `^`
8882        // in the value.
8883        let d = dep_with_fonte(DepSource::Git {
8884            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8885            tag: Some("v0.1.0".into()),
8886            rev: None,
8887            branch: None,
8888        });
8889        let err = d.validate().unwrap_err();
8890        let DepError::FonteRepoShape { reason, .. } = err else {
8891            panic!("expected FonteRepoShape, got other variant");
8892        };
8893        assert!(
8894            reason.contains("must not contain `%`"),
8895            "reason must surface the percent arm (fires before caret when `%` byte \
8896             appears first in value), got {reason:?}"
8897        );
8898    }
8899
8900    #[test]
8901    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8902        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8903        // (no `github:` prefix, no scheme). Every documented form
8904        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8905        // `file://`, or `git@host:path`); a bare `org/repo` is
8906        // ambiguous (`git clone` reads as a relative filesystem path
8907        // rather than the GitHub-shorthand expansion the author
8908        // probably intended) and the gate rejects the shape upstream.
8909        let d = dep_with_fonte(DepSource::Git {
8910            repo: "pleme-io/caixa-teia".into(),
8911            tag: Some("v0.1.0".into()),
8912            rev: None,
8913            branch: None,
8914        });
8915        let err = d.validate().unwrap_err();
8916        let DepError::FonteRepoShape { reason, .. } = err else {
8917            panic!("expected FonteRepoShape, got other variant");
8918        };
8919        assert!(
8920            reason.contains("must contain a `:`"),
8921            "reason must surface the missing-`:` arm, got {reason:?}"
8922        );
8923        assert!(
8924            reason.contains("github:"),
8925            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8926        );
8927    }
8928
8929    #[test]
8930    fn validate_rejects_git_fonte_with_repo_leading_colon() {
8931        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8932        // scheme that no git porcelain entry-point accepts. Pinned
8933        // separately from the missing-`:` arm because a value with a
8934        // leading `:` does technically contain a `:` separator; the
8935        // shape gate rejects on a dedicated arm so the diagnostic
8936        // names the specific footgun.
8937        let d = dep_with_fonte(DepSource::Git {
8938            repo: ":pleme-io/caixa-teia".into(),
8939            tag: Some("v0.1.0".into()),
8940            rev: None,
8941            branch: None,
8942        });
8943        let err = d.validate().unwrap_err();
8944        let DepError::FonteRepoShape { reason, .. } = err else {
8945            panic!("expected FonteRepoShape, got other variant");
8946        };
8947        assert!(
8948            reason.contains("must not start with `:`"),
8949            "reason must surface the leading-`:` arm, got {reason:?}"
8950        );
8951    }
8952
8953    #[test]
8954    fn validate_rejects_git_fonte_with_repo_too_long() {
8955        // The cap arm — a `:repo` value longer than
8956        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8957        // structurally untenable on every realistic landing site (the
8958        // resolver's `git clone` invocation, the future M4 CR
8959        // materializer's per-dep `repo:` axis); a value of that length
8960        // is almost certainly a paste-from-binary slug.
8961        let too_long = format!(
8962            "github:pleme-io/{}",
8963            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8964        );
8965        let d = dep_with_fonte(DepSource::Git {
8966            repo: too_long.clone(),
8967            tag: Some("v0.1.0".into()),
8968            rev: None,
8969            branch: None,
8970        });
8971        let err = d.validate().unwrap_err();
8972        let DepError::FonteRepoShape { reason, .. } = err else {
8973            panic!("expected FonteRepoShape, got other variant");
8974        };
8975        assert!(
8976            reason.contains("2048"),
8977            "reason must name the cap, got {reason:?}"
8978        );
8979    }
8980
8981    #[test]
8982    fn validate_accepts_canonical_git_fonte_repo_shapes() {
8983        // The positive-control sweep: every documented author shape on
8984        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8985        // must pass the value-shape gate. Pinned so a future tightening
8986        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8987        // here as a structural decision. Each form is exercised with the
8988        // same canonical `:tag` pin so only the `:repo` axis varies.
8989        for repo in [
8990            // The pleme-io registry-shorthand convention — `github:org/repo`.
8991            "github:pleme-io/caixa-teia",
8992            // Other host-aliased shorthands (the resolver's pluggable
8993            // host-prefix table).
8994            "gitlab:pleme-io/caixa-teia",
8995            "codeberg:pleme-io/caixa-teia",
8996            "sourcehut:~pleme-io/caixa-teia",
8997            // Full HTTPS URL with and without `.git` suffix.
8998            "https://github.com/pleme-io/caixa-teia",
8999            "https://github.com/pleme-io/caixa-teia.git",
9000            // HTTP (rare; dev / mirror).
9001            "http://example.com/pleme-io/caixa-teia.git",
9002            // SSH URL.
9003            "ssh://git@github.com/pleme-io/caixa-teia.git",
9004            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9005            // Scp-style SSH — the canonical `git@host:path` short form.
9006            "git@github.com:pleme-io/caixa-teia.git",
9007            "git@git.example.com:team/private.git",
9008            // Anonymous git protocol.
9009            "git://git.example.com/pleme-io/caixa-teia.git",
9010            // Local file URL (dev path).
9011            "file:///tmp/caixa-teia",
9012        ] {
9013            let d = dep_with_fonte(DepSource::Git {
9014                repo: repo.into(),
9015                tag: Some("v0.1.0".into()),
9016                rev: None,
9017                branch: None,
9018            });
9019            d.validate()
9020                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9021        }
9022    }
9023
9024    #[test]
9025    fn fonte_repo_empty_takes_precedence_over_shape() {
9026        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9027        // diagnostic; doesn't try to parse the URL shape) fires before
9028        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9029        // keeps its narrower error message. Mirrors
9030        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9031        // on the ordering layer.
9032        let d = dep_with_fonte(DepSource::Git {
9033            repo: String::new(),
9034            tag: Some("v0.1.0".into()),
9035            rev: None,
9036            branch: None,
9037        });
9038        let err = d.validate().unwrap_err();
9039        assert!(
9040            matches!(err, DepError::FonteRepoEmpty { .. }),
9041            "got {err:?}"
9042        );
9043    }
9044
9045    #[test]
9046    fn fonte_repo_shape_fires_before_pin_missing() {
9047        // Order pin: a malformed `:repo` value on a dep with no pin set
9048        // surfaces the `:repo` shape diagnostic (the more self-locating
9049        // axis — the `:repo` is the load-bearing identity of the source;
9050        // a missing pin is downstream from "do we even know the repo")
9051        // rather than collapsing onto the pin-missing diagnostic. The
9052        // shape gate runs inline before the pin enumeration in
9053        // `DepSource::validate`.
9054        let d = dep_with_fonte(DepSource::Git {
9055            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9056            tag: None,
9057            rev: None,
9058            branch: None,
9059        });
9060        let err = d.validate().unwrap_err();
9061        assert!(
9062            matches!(err, DepError::FonteRepoShape { .. }),
9063            "got {err:?}"
9064        );
9065    }
9066
9067    #[test]
9068    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9069        // The diagnostic-shape pin: the error names the offending
9070        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9071        // so the author can grep their caixa.lisp without re-running
9072        // the build. Mirrors the diagnostic-shape sweep on every prior
9073        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9074        let d = dep_with_fonte(DepSource::Git {
9075            repo: "pleme-io/caixa-teia".into(),
9076            tag: Some("v0.1.0".into()),
9077            rev: None,
9078            branch: None,
9079        });
9080        let err = d.validate().unwrap_err();
9081        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9082            panic!("expected FonteRepoShape, got other variant");
9083        };
9084        assert_eq!(nome, "caixa-teia");
9085        assert_eq!(repo, "pleme-io/caixa-teia");
9086        assert!(
9087            !reason.is_empty(),
9088            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9089        );
9090    }
9091
9092    #[test]
9093    fn validate_rejects_git_fonte_with_no_pin() {
9094        // The fail-before-pass-after pin for the canonical
9095        // `(:tipo git :repo "github:pleme-io/x")` shape with no
9096        // :tag/:rev/:branch — until this gate landed the resolver's
9097        // ResolveError::MissingPin surfaced at fetch time, far from the
9098        // source caixa.lisp. The new gate moves the check to validate
9099        // time and names the offending dep.
9100        let d = dep_with_fonte(DepSource::Git {
9101            repo: "github:pleme-io/caixa-teia".into(),
9102            tag: None,
9103            rev: None,
9104            branch: None,
9105        });
9106        let err = d.validate().unwrap_err();
9107        assert!(
9108            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9109            "got {err:?}"
9110        );
9111    }
9112
9113    #[test]
9114    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9115        // The canonical "pin drift" footgun: an author writes
9116        // `:tag "v1"` and later adds `:branch "main"` without removing
9117        // the :tag, and the resolver silently picks :tag (precedence
9118        // :rev > :tag > :branch). The :branch was dropped with no
9119        // diagnostic. The gate now rejects multi-pin shapes so the
9120        // author makes the precedence explicit at the source.
9121        let d = dep_with_fonte(DepSource::Git {
9122            repo: "github:pleme-io/caixa-teia".into(),
9123            tag: Some("v0.1.0".into()),
9124            rev: None,
9125            branch: Some("main".into()),
9126        });
9127        let err = d.validate().unwrap_err();
9128        let DepError::FontePinAmbiguous { nome, pins } = err else {
9129            panic!("expected FontePinAmbiguous");
9130        };
9131        assert_eq!(nome, "caixa-teia");
9132        assert!(pins.contains(":tag"));
9133        assert!(pins.contains(":branch"));
9134        assert!(!pins.contains(":rev"));
9135    }
9136
9137    #[test]
9138    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9139        // Sibling arm of the pin-drift footgun: :tag + :rev set
9140        // simultaneously. Pinned separately so a future relaxation
9141        // that only catches the (:tag, :branch) pair surfaces here.
9142        let d = dep_with_fonte(DepSource::Git {
9143            repo: "github:pleme-io/caixa-teia".into(),
9144            tag: Some("v0.1.0".into()),
9145            rev: Some("c0ffee".into()),
9146            branch: None,
9147        });
9148        let err = d.validate().unwrap_err();
9149        let DepError::FontePinAmbiguous { nome, pins } = err else {
9150            panic!("expected FontePinAmbiguous");
9151        };
9152        assert_eq!(nome, "caixa-teia");
9153        assert!(pins.contains(":tag"));
9154        assert!(pins.contains(":rev"));
9155    }
9156
9157    #[test]
9158    fn validate_rejects_git_fonte_with_all_three_pins() {
9159        // The maximal ambiguity case — every pin axis set. Pinned so a
9160        // future relaxation that only catches pairs surfaces here. The
9161        // diagnostic must enumerate every offending axis so the author
9162        // sees the full set, not just the first match.
9163        let d = dep_with_fonte(DepSource::Git {
9164            repo: "github:pleme-io/caixa-teia".into(),
9165            tag: Some("v0.1.0".into()),
9166            rev: Some("c0ffee".into()),
9167            branch: Some("main".into()),
9168        });
9169        let err = d.validate().unwrap_err();
9170        let DepError::FontePinAmbiguous { nome, pins } = err else {
9171            panic!("expected FontePinAmbiguous");
9172        };
9173        assert_eq!(nome, "caixa-teia");
9174        assert!(pins.contains(":tag"));
9175        assert!(pins.contains(":rev"));
9176        assert!(pins.contains(":branch"));
9177    }
9178
9179    #[test]
9180    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9181        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9182        // inner string is empty. Distinct from FontePinMissing (where
9183        // every axis is None) — pinned separately so a future
9184        // tightening collapsing them surfaces here as a structural
9185        // decision.
9186        let d = dep_with_fonte(DepSource::Git {
9187            repo: "github:pleme-io/caixa-teia".into(),
9188            tag: Some(String::new()),
9189            rev: None,
9190            branch: None,
9191        });
9192        let err = d.validate().unwrap_err();
9193        let DepError::FontePinEmpty { nome, pin } = err else {
9194            panic!("expected FontePinEmpty");
9195        };
9196        assert_eq!(nome, "caixa-teia");
9197        assert_eq!(pin, ":tag");
9198    }
9199
9200    #[test]
9201    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9202        // Sibling arm — the empty-pin diagnostic names which axis
9203        // carries the empty value, so the author's grep target is
9204        // unambiguous.
9205        let d = dep_with_fonte(DepSource::Git {
9206            repo: "github:pleme-io/caixa-teia".into(),
9207            tag: None,
9208            rev: Some(String::new()),
9209            branch: None,
9210        });
9211        let err = d.validate().unwrap_err();
9212        let DepError::FontePinEmpty { nome, pin } = err else {
9213            panic!("expected FontePinEmpty");
9214        };
9215        assert_eq!(nome, "caixa-teia");
9216        assert_eq!(pin, ":rev");
9217    }
9218
9219    #[test]
9220    fn validate_rejects_path_fonte_with_empty_caminho() {
9221        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9222        // until this gate landed the resolver's
9223        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9224        // fetch time — not actionable. The new gate moves the check to
9225        // validate time and names the offending dep.
9226        let d = dep_with_fonte(DepSource::Path {
9227            caminho: String::new(),
9228        });
9229        let err = d.validate().unwrap_err();
9230        assert!(
9231            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9232            "got {err:?}"
9233        );
9234    }
9235
9236    #[test]
9237    fn validate_rejects_path_fonte_with_absolute_caminho() {
9238        // The fail-before-pass-after pin for the absolute-`:caminho`
9239        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9240        // Until this gate landed an absolute `:caminho` silently
9241        // passed validate; the lacre pipeline embedded the
9242        // host-specific filesystem path verbatim in its
9243        // content-address (`conteudo: format!("path:{caminho}")`,
9244        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9245        // differed per machine — the build succeeded but two CI
9246        // runners with different `${HOME}` layouts emitted two
9247        // distinct lacres for the byte-identical caixa, silently
9248        // breaking the THEORY.md §V.2 render-determinism contract
9249        // far from the source caixa.lisp. The new gate moves the
9250        // check to validate time and names the offending dep +
9251        // caminho verbatim.
9252        let d = dep_with_fonte(DepSource::Path {
9253            caminho: "/home/me/work/caixa-teia".into(),
9254        });
9255        let err = d.validate().unwrap_err();
9256        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9257            panic!("expected FonteCaminhoAbsolute, got other variant");
9258        };
9259        assert_eq!(nome, "caixa-teia");
9260        assert_eq!(caminho, "/home/me/work/caixa-teia");
9261    }
9262
9263    #[test]
9264    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9265        // The canonical sibling-workspace dep form
9266        // (`:caminho "../caixa-teia"`) remains accepted. The
9267        // absolute-path gate above is specifically narrower than the
9268        // shared [`crate::render::is_sandboxed_relative_path`]
9269        // predicate (which additionally forbids `..` traversal): a
9270        // local-path dep's canonical author surface is the in-tree
9271        // sibling-workspace path, so a full sandboxed-relative-path
9272        // lift would structurally reject every legitimate path-fonte
9273        // dep. Pinned so a future tightening to the full predicate
9274        // surfaces here as a structural decision, not a silent break.
9275        let d = dep_with_fonte(DepSource::Path {
9276            caminho: "../caixa-teia".into(),
9277        });
9278        d.validate().unwrap();
9279    }
9280
9281    #[test]
9282    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9283        // A multi-segment relative `:caminho`
9284        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9285        // absolute-path gate brackets the host-layout-leaking shape
9286        // at the leading-`/` boundary only; every relative shape past
9287        // the empty arm continues to pass. Pinned alongside the
9288        // `..`-traversal positive control so a future tightening
9289        // surfaces the full set of legitimate relative forms here
9290        // rather than at a downstream consumer.
9291        let d = dep_with_fonte(DepSource::Path {
9292            caminho: "vendor/forks/caixa-teia".into(),
9293        });
9294        d.validate().unwrap();
9295    }
9296
9297    #[test]
9298    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9299        // The fail-before-pass-after pin for the tilde-expansion
9300        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9301        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9302        // through (`Path::is_absolute` returns false on a leading `~`
9303        // — the tilde is a shell-expansion convention, not a POSIX
9304        // path component), so the lacre embedded the value verbatim
9305        // and the resolver folded it through `Path::join` without
9306        // expansion, looking for a literal `./~/work/caixa-teia`
9307        // subdirectory and failing at resolve time with a
9308        // `No such file or directory` error far from the source
9309        // caixa.lisp. The new gate moves the check to validate time
9310        // and names the offending dep + caminho verbatim.
9311        let d = dep_with_fonte(DepSource::Path {
9312            caminho: "~/work/caixa-teia".into(),
9313        });
9314        let err = d.validate().unwrap_err();
9315        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9316            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9317        };
9318        assert_eq!(nome, "caixa-teia");
9319        assert_eq!(caminho, "~/work/caixa-teia");
9320    }
9321
9322    #[test]
9323    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9324        // The bare `~` form (canonical "I meant `$HOME` and forgot
9325        // the rest"): both the leading-tilde arm catches it and the
9326        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9327        // sweeps through the same arm. Pinned both to ensure the
9328        // gate doesn't narrow to `~/` only.
9329        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9330            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9331            let err = d.validate().unwrap_err();
9332            assert!(
9333                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9334                "{s:?} → {err:?}",
9335            );
9336        }
9337    }
9338
9339    #[test]
9340    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9341        // The leading-`~` is the canonical shell-expansion footgun —
9342        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9343        // backup-file-suffix idiom) is a legitimate POSIX path byte
9344        // with no shell-expansion semantic at the leading position.
9345        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9346        // sweep that would break every legitimate-shape backup-file
9347        // path.
9348        let d = dep_with_fonte(DepSource::Path {
9349            caminho: "../foo~bar/caixa-teia".into(),
9350        });
9351        d.validate().unwrap();
9352    }
9353
9354    #[test]
9355    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9356        // Cascade pin: the empty arm structurally precedes the
9357        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9358        // pin establishes the precedence at the diagnostic-shape
9359        // level should a future codec round-trip ever produce a
9360        // probe-as-both value. Mirrors the peer
9361        // `fonte_repo_empty_fires_before_pin_missing` cascade
9362        // discipline.
9363        let d = dep_with_fonte(DepSource::Path {
9364            caminho: String::new(),
9365        });
9366        let err = d.validate().unwrap_err();
9367        assert!(
9368            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9369            "got {err:?}",
9370        );
9371    }
9372
9373    #[test]
9374    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9375        // Diagnostic-shape pin (peer with
9376        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9377        // payload assertion): the error's Display surfaces both the
9378        // offending `:nome` and the offending `:caminho` verbatim
9379        // so a `feira lint` run can render the diagnostic without
9380        // re-parsing.
9381        let d = dep_with_fonte(DepSource::Path {
9382            caminho: "~alice/dev/caixa-teia".into(),
9383        });
9384        let rendered = d.validate().unwrap_err().to_string();
9385        assert!(
9386            rendered.contains("caixa-teia"),
9387            "diagnostic must name the offending dep: {rendered}",
9388        );
9389        assert!(
9390            rendered.contains("~alice/dev/caixa-teia"),
9391            "diagnostic must quote the offending caminho: {rendered}",
9392        );
9393        assert!(
9394            rendered.contains('~'),
9395            "diagnostic must reference the tilde footgun: {rendered}",
9396        );
9397    }
9398
9399    #[test]
9400    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9401        // The fail-before-pass-after pin for the shell-variable-
9402        // expansion `:caminho` shape: `(:tipo path :caminho
9403        // "$HOME/work/caixa-teia")`. Until this gate landed the
9404        // b94fd83 absolute arm + the a5c248e tilde arm both let
9405        // `$HOME/foo` through (`Path::is_absolute` returns false on
9406        // a leading `$` — the `$` is a shell convention, not a POSIX
9407        // path component; `starts_with('~')` returns false too), so
9408        // the lacre embedded the value verbatim and the resolver
9409        // folded it through `Path::join` without `$`-expansion,
9410        // looking for a literal `./$HOME/work/caixa-teia`
9411        // subdirectory and failing at resolve time with a
9412        // `No such file or directory` error far from the source
9413        // caixa.lisp. The new gate moves the check to validate time
9414        // and names the offending dep + caminho verbatim.
9415        let d = dep_with_fonte(DepSource::Path {
9416            caminho: "$HOME/work/caixa-teia".into(),
9417        });
9418        let err = d.validate().unwrap_err();
9419        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9420            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9421        };
9422        assert_eq!(nome, "caixa-teia");
9423        assert_eq!(caminho, "$HOME/work/caixa-teia");
9424    }
9425
9426    #[test]
9427    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9428        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9429        // form (canonical "paste-from-CI-manifest" footgun every
9430        // GitHub Actions / GitLab CI / Drone manifest carries on
9431        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9432        // canonical "I'm referencing a per-user config dir"),
9433        // and the bare `$` (canonical "I meant `$HOME` and forgot
9434        // the rest"). All shapes route through the same gate's
9435        // byte check. Pinned so the gate doesn't narrow to a
9436        // single shape (e.g. `$HOME/` only).
9437        for s in [
9438            "${HOME}/work/caixa-teia",
9439            "${WORKSPACE}/caixa-teia",
9440            "$XDG_CONFIG_HOME/caixa",
9441            "$",
9442        ] {
9443            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9444            let err = d.validate().unwrap_err();
9445            assert!(
9446                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9447                "{s:?} → {err:?}",
9448            );
9449        }
9450    }
9451
9452    #[test]
9453    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9454        // The `$` byte is the canonical shell-variable-expansion /
9455        // command-substitution / arithmetic-expansion sentinel and
9456        // is rejected at *every* position on the `:caminho` axis: the
9457        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9458        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9459        // (6620f39). Pinned so a future arm doesn't narrow the gate
9460        // back to the leading position and re-open the paste-from-
9461        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9462        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9463        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9464        // the lacre content-address (`path:{caminho}`,
9465        // caixa-resolver/src/resolve.rs:189).
9466        let d = dep_with_fonte(DepSource::Path {
9467            caminho: "../foo$bar/caixa-teia".into(),
9468        });
9469        let err = d.validate().unwrap_err();
9470        assert!(
9471            matches!(
9472                err,
9473                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9474            ),
9475            "got {err:?}",
9476        );
9477    }
9478
9479    #[test]
9480    fn fonte_caminho_tilde_fires_before_var_expansion() {
9481        // Cascade pin: the tilde arm structurally precedes the var
9482        // arm (the bytes `~` and `$` don't overlap at the leading
9483        // position), but the pin establishes the precedence at the
9484        // diagnostic-shape level should a future codec round-trip
9485        // ever produce a probe-as-both value. Mirrors the peer
9486        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9487        // discipline on the immediate-predecessor arm.
9488        let d = dep_with_fonte(DepSource::Path {
9489            caminho: "~/work/caixa-teia".into(),
9490        });
9491        let err = d.validate().unwrap_err();
9492        assert!(
9493            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9494            "got {err:?}",
9495        );
9496    }
9497
9498    #[test]
9499    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9500        // Diagnostic-shape pin (peer with
9501        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9502        // payload assertion on the immediate-predecessor arm): the
9503        // error's Display surfaces both the offending `:nome` and
9504        // the offending `:caminho` verbatim plus the `$` footgun
9505        // character itself so a `feira lint` run can render the
9506        // diagnostic without re-parsing.
9507        let d = dep_with_fonte(DepSource::Path {
9508            caminho: "${WORKSPACE}/caixa-teia".into(),
9509        });
9510        let rendered = d.validate().unwrap_err().to_string();
9511        assert!(
9512            rendered.contains("caixa-teia"),
9513            "diagnostic must name the offending dep: {rendered}",
9514        );
9515        assert!(
9516            rendered.contains("${WORKSPACE}/caixa-teia"),
9517            "diagnostic must quote the offending caminho: {rendered}",
9518        );
9519        assert!(
9520            rendered.contains('$'),
9521            "diagnostic must reference the dollar footgun: {rendered}",
9522        );
9523    }
9524
9525    #[test]
9526    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9527        // The fail-before-pass-after pin for the load-bearing NUL byte:
9528        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9529        // routes the path through `CString::new` which fails with
9530        // `NulError`); until this gate landed a `:caminho
9531        // "../caixa\0teia"` silently passed validate, the lacre
9532        // pipeline embedded the value verbatim, and the failure
9533        // surfaced at the resolver's `Path::join` → `CString::new`
9534        // boundary with a non-self-locating `NulError` far from the
9535        // source caixa.lisp. The new gate moves the check to validate
9536        // time and names the offending dep + caminho + offending byte
9537        // verbatim.
9538        let d = dep_with_fonte(DepSource::Path {
9539            caminho: "../caixa\0teia".into(),
9540        });
9541        let err = d.validate().unwrap_err();
9542        let DepError::FonteCaminhoControlChar {
9543            nome,
9544            caminho,
9545            byte,
9546        } = err
9547        else {
9548            panic!("expected FonteCaminhoControlChar, got {err:?}");
9549        };
9550        assert_eq!(nome, "caixa-teia");
9551        assert_eq!(caminho, "../caixa\0teia");
9552        assert_eq!(byte, 0x00);
9553    }
9554
9555    #[test]
9556    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9557        // The canonical paste-from-multiline-doc footgun on `:caminho`
9558        // — author copies `"../caixa-teia\n"` (trailing newline) out
9559        // of a multi-line code-fence or, worse, a `:caminho
9560        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9561        // injection sibling on the path axis the `is_git_repo_url`
9562        // control-char arm already closes on `:repo`). Pinned
9563        // separately from the NUL arm so a future relaxation that
9564        // catches one but not the other surfaces here.
9565        let d = dep_with_fonte(DepSource::Path {
9566            caminho: "../caixa-teia\n".into(),
9567        });
9568        let err = d.validate().unwrap_err();
9569        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9570            panic!("expected FonteCaminhoControlChar, got {err:?}");
9571        };
9572        assert_eq!(byte, 0x0A);
9573    }
9574
9575    #[test]
9576    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9577        // The CRLF sibling of the LF arm — Windows-line-ending
9578        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9579        // leaves a stray `\r` mid-string after the LF strip. Pinned
9580        // separately from the LF arm so a future relaxation that
9581        // only catches LF surfaces here.
9582        let d = dep_with_fonte(DepSource::Path {
9583            caminho: "../caixa-teia\r".into(),
9584        });
9585        let err = d.validate().unwrap_err();
9586        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9587            panic!("expected FonteCaminhoControlChar, got {err:?}");
9588        };
9589        assert_eq!(byte, 0x0D);
9590    }
9591
9592    #[test]
9593    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9594        // The canonical paste-from-aligned-table footgun — a `\t`
9595        // mid-`:caminho` is invisible in most editors but rides
9596        // through the lacre's content-address verbatim, so two
9597        // paste-from-distinct-tables (one editor strips tabs, one
9598        // preserves them) yield divergent lacres for the byte-
9599        // identical-looking caixa. Pinned separately from the
9600        // whitespace-shaped LF/CR arms so a future relaxation that
9601        // narrows to line-terminator-only surfaces here.
9602        let d = dep_with_fonte(DepSource::Path {
9603            caminho: "../caixa\tteia".into(),
9604        });
9605        let err = d.validate().unwrap_err();
9606        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9607            panic!("expected FonteCaminhoControlChar, got {err:?}");
9608        };
9609        assert_eq!(byte, 0x09);
9610    }
9611
9612    #[test]
9613    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9614        // The DEL byte (`0x7F`) closes the upper-end paste-from-
9615        // binary-blob footgun — the gate's contract is `b < 0x20 ||
9616        // b == 0x7F`, matching the `is_git_repo_url` /
9617        // `is_git_ref_name` predicates' control-char arms. Pinned
9618        // separately from the lower-range arms so a future narrowing
9619        // to `< 0x20` only surfaces here.
9620        let d = dep_with_fonte(DepSource::Path {
9621            caminho: "../caixa\x7fteia".into(),
9622        });
9623        let err = d.validate().unwrap_err();
9624        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9625            panic!("expected FonteCaminhoControlChar, got {err:?}");
9626        };
9627        assert_eq!(byte, 0x7F);
9628    }
9629
9630    #[test]
9631    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9632        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9633        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9634        // are opaque byte sequences and UTF-8 multi-byte sequences
9635        // are a legitimate filename shape (the `café-teia/foo` idiom).
9636        // Pinned so the gate doesn't widen to a full ASCII-only sweep
9637        // that would break every legitimate-shape UTF-8 path.
9638        let d = dep_with_fonte(DepSource::Path {
9639            caminho: "../café-teia/foo".into(),
9640        });
9641        d.validate().unwrap();
9642    }
9643
9644    #[test]
9645    fn fonte_caminho_var_fires_before_control_char() {
9646        // Cascade pin: the var-expansion arm structurally precedes the
9647        // control-char arm. A value like `"$\n"` probes positive on
9648        // both arms (`starts_with('$')` and contains LF), but the
9649        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9650        // wins so the author sees the more self-locating shell-
9651        // expansion arm first. Mirrors the
9652        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9653        // discipline on the immediate-predecessor arm.
9654        let d = dep_with_fonte(DepSource::Path {
9655            caminho: "$HOME\n".into(),
9656        });
9657        let err = d.validate().unwrap_err();
9658        assert!(
9659            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9660            "got {err:?}",
9661        );
9662    }
9663
9664    #[test]
9665    fn validate_rejects_path_fonte_with_leading_space_caminho() {
9666        // The fail-before-pass-after pin for the leading ASCII space
9667        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9668        // Until this gate landed the b94fd83 absolute arm + the a5c248e
9669        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9670        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9671        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9672        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9673        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9674        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9675        // are caught, but the most common whitespace `0x20` space is
9676        // not). The lacre embedded the value verbatim and the resolver
9677        // folded it through `Path::join` looking for a literal `./ ../
9678        // caixa-teia` subdirectory and failing at resolve time with a
9679        // non-self-locating `No such file or directory` error far from
9680        // the source caixa.lisp. The new gate moves the check to
9681        // validate time and names the offending dep + caminho verbatim.
9682        let d = dep_with_fonte(DepSource::Path {
9683            caminho: " ../caixa-teia".into(),
9684        });
9685        let err = d.validate().unwrap_err();
9686        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9687            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9688        };
9689        assert_eq!(nome, "caixa-teia");
9690        assert_eq!(caminho, " ../caixa-teia");
9691    }
9692
9693    #[test]
9694    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9695        // The aligned-doc paste footgun sweep: more than one leading
9696        // space (`"   ../caixa-teia"` — the canonical "I selected the
9697        // aligned column from a four-`:fonte`-entry `:deps` block"
9698        // paste) routes through the same gate's `starts_with(' ')`
9699        // byte check. Pinned so the gate doesn't narrow to a
9700        // single-space prefix.
9701        let d = dep_with_fonte(DepSource::Path {
9702            caminho: "   ../caixa-teia".into(),
9703        });
9704        let err = d.validate().unwrap_err();
9705        assert!(
9706            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9707            "got {err:?}",
9708        );
9709    }
9710
9711    #[test]
9712    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9713        // The leading-space is the canonical paste-from-aligned-doc
9714        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9715        // canonical "I have a directory with a space in its name"
9716        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9717        // legitimate path with no whitespace-leak semantic at the
9718        // non-leading position. Pinned so the gate doesn't widen to a
9719        // full no-space-anywhere sweep that would break every
9720        // legitimate-shape space-in-filename path.
9721        let d = dep_with_fonte(DepSource::Path {
9722            caminho: "../my dir/caixa-teia".into(),
9723        });
9724        d.validate().unwrap();
9725    }
9726
9727    #[test]
9728    fn fonte_caminho_var_fires_before_leading_whitespace() {
9729        // Cascade pin: the var-expansion arm structurally precedes the
9730        // leading-whitespace arm. A value like `"$ "` would probe positive
9731        // on var (`starts_with('$')`) but the leading-byte arms walk
9732        // left-to-right so the var arm fires on the leading `$` before
9733        // the leading-whitespace arm probes. Mirrors the
9734        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9735        // discipline on the immediate-predecessor arms.
9736        let d = dep_with_fonte(DepSource::Path {
9737            caminho: "$VAR".into(),
9738        });
9739        let err = d.validate().unwrap_err();
9740        assert!(
9741            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9742            "got {err:?}",
9743        );
9744    }
9745
9746    #[test]
9747    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9748        // Cascade pin: the leading-whitespace arm structurally precedes
9749        // the control-char arm. A value like `" ../foo\n"` probes
9750        // positive on both (starts with space AND contains LF), but
9751        // the narrower leading-byte diagnostic
9752        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9753        // more self-locating paste-from-aligned-doc arm first. Mirrors
9754        // the `fonte_caminho_var_fires_before_control_char` cascade
9755        // discipline on the immediate-predecessor arm.
9756        let d = dep_with_fonte(DepSource::Path {
9757            caminho: " ../foo\n".into(),
9758        });
9759        let err = d.validate().unwrap_err();
9760        assert!(
9761            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9762            "got {err:?}",
9763        );
9764    }
9765
9766    #[test]
9767    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9768        // Diagnostic-shape pin (peer with
9769        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9770        // payload assertion on the immediate-predecessor arm): the
9771        // error's Display surfaces both the offending `:nome` and the
9772        // offending `:caminho` verbatim, so a `feira lint` run can
9773        // render the diagnostic without re-parsing and the author can
9774        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9775        // one edit.
9776        let d = dep_with_fonte(DepSource::Path {
9777            caminho: " ../caixa-teia".into(),
9778        });
9779        let rendered = d.validate().unwrap_err().to_string();
9780        assert!(
9781            rendered.contains("caixa-teia"),
9782            "diagnostic must name the offending dep: {rendered}",
9783        );
9784        assert!(
9785            rendered.contains(" ../caixa-teia"),
9786            "diagnostic must quote the offending caminho: {rendered}",
9787        );
9788        assert!(
9789            rendered.contains("space"),
9790            "diagnostic must name the space footgun: {rendered}",
9791        );
9792    }
9793
9794    #[test]
9795    fn fonte_caminho_absolute_fires_before_control_char() {
9796        // Cascade pin on the sibling leading-byte arm: a leading `/`
9797        // value with embedded control byte (`"/etc/passwd\n"`) routes
9798        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9799        // — the host-layout-leak diagnostic is the load-bearing axis,
9800        // the control byte is the secondary observation. Same precedence
9801        // logic on every prior leading-byte arm.
9802        let d = dep_with_fonte(DepSource::Path {
9803            caminho: "/etc/passwd\n".into(),
9804        });
9805        let err = d.validate().unwrap_err();
9806        assert!(
9807            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9808            "got {err:?}",
9809        );
9810    }
9811
9812    #[test]
9813    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9814        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9815        // injection `:caminho` shape sweep. Until this gate landed
9816        // every prior leading-byte arm passed a leading-`-` value
9817        // through: `Path::is_absolute` returns false on `-` (the
9818        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9819        // `starts_with('$')` / `starts_with(' ')` all return false,
9820        // and `0x2D` sits outside the control-byte set. The lacre
9821        // embedded the value verbatim and the resolver folded it
9822        // through `Path::join` looking for a literal `./-rf` /
9823        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9824        // `Path::join` time is non-self-locating but harmless, while
9825        // the failure at every downstream `git -C {caminho}` /
9826        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9827        // is arbitrary-CLI-arg-injection because none of those
9828        // porcelains carry a `--` argument-list terminator between
9829        // the flag block and the path argument. The new arm moves the
9830        // rejection to `Caixa::from_lisp` boundary time and names
9831        // the offending dep + caminho verbatim.
9832        //
9833        // Sweep spans the canonical CLI-arg-injection shapes matching
9834        // the peer sweep on the sibling `is_git_ref_name` /
9835        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9836        // `find -rf` reinterpretation vector), `-C` (the `git -C`
9837        // change-directory-config-injection paste), long-flag
9838        // `--upload-pack=cat /etc/passwd` (the canonical
9839        // arbitrary-command-execution vector on every git porcelain
9840        // entry point), git-config-injection `--config=core.merge=ours`,
9841        // and the degenerate single-byte `-` value.
9842        for caminho in [
9843            "-rf",
9844            "-C",
9845            "--upload-pack=cat /etc/passwd",
9846            "--config=core.merge=ours",
9847            "-",
9848        ] {
9849            let d = dep_with_fonte(DepSource::Path {
9850                caminho: caminho.into(),
9851            });
9852            let err = d.validate().unwrap_err();
9853            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9854                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9855            };
9856            assert_eq!(nome, "caixa-teia");
9857            assert_eq!(got, caminho);
9858        }
9859    }
9860
9861    #[test]
9862    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9863        // The leading-`-` is the canonical CLI-arg-injection footgun
9864        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9865        // canonical kebab-separator-between-alphanumeric-segments
9866        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9867        // — a mid-path segment starting with `-`, still a legitimate
9868        // POSIX filename byte at that non-leading position because the
9869        // subprocess reads the whole `{caminho}` value as one positional
9870        // argument, so only the very first byte of the composite path
9871        // string is at the CLI-arg-injection boundary) is a legitimate
9872        // path with no CLI-flag-reinterpretation semantic at the non-
9873        // leading position of the top-level value. Pinned so the gate
9874        // doesn't widen to a full no-`-`-anywhere sweep that would
9875        // break every legitimate-shape kebab-in-filename path (i.e.
9876        // essentially every sibling-workspace caixa dep).
9877        for caminho in [
9878            "../caixa-teia",
9879            "../caixa-teia/-hidden",
9880            "./my-lib",
9881            "../foo-bar/baz",
9882        ] {
9883            let d = dep_with_fonte(DepSource::Path {
9884                caminho: caminho.into(),
9885            });
9886            d.validate()
9887                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9888        }
9889    }
9890
9891    #[test]
9892    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9893        // Cascade pin: the leading-whitespace arm structurally precedes
9894        // the leading-hyphen arm. A value like `" -rf"` probes positive
9895        // on both (leading space AND, one byte in, a `-` — though the
9896        // leading-hyphen arm probes only the very first byte so it
9897        // wouldn't fire on this value; the pin instead documents the
9898        // arm order on the more common "leading space then a hyphen"
9899        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9900        // The narrower leading-space diagnostic (the paste-from-aligned-
9901        // doc footgun) wins so the author sees the more self-locating
9902        // whitespace arm first. Mirrors the
9903        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9904        // discipline on the immediate-predecessor arm.
9905        let d = dep_with_fonte(DepSource::Path {
9906            caminho: " -rf".into(),
9907        });
9908        let err = d.validate().unwrap_err();
9909        assert!(
9910            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9911            "got {err:?}",
9912        );
9913    }
9914
9915    #[test]
9916    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9917        // Cascade pin: the leading-hyphen arm structurally precedes
9918        // the control-char arm. A value like `"-rf\n"` probes positive
9919        // on both (starts with `-` AND contains LF), but the narrower
9920        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9921        // the author sees the more self-locating CLI-arg-injection arm
9922        // first. Mirrors the
9923        // `fonte_caminho_leading_whitespace_fires_before_control_char`
9924        // cascade discipline on the immediate-predecessor arm.
9925        let d = dep_with_fonte(DepSource::Path {
9926            caminho: "-rf\n".into(),
9927        });
9928        let err = d.validate().unwrap_err();
9929        assert!(
9930            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9931            "got {err:?}",
9932        );
9933    }
9934
9935    #[test]
9936    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9937        // Diagnostic-shape pin (peer with
9938        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9939        // payload assertion on the immediate-predecessor arm): the
9940        // error's Display surfaces both the offending `:nome` and the
9941        // offending `:caminho` verbatim plus the CLI-argument-injection
9942        // vocabulary, so a `feira lint` run can render the diagnostic
9943        // without re-parsing and the author can grep their caixa.lisp
9944        // for `:caminho "<value>"` and fix it in one edit.
9945        let d = dep_with_fonte(DepSource::Path {
9946            caminho: "--upload-pack=cat /etc/passwd".into(),
9947        });
9948        let rendered = d.validate().unwrap_err().to_string();
9949        assert!(
9950            rendered.contains("caixa-teia"),
9951            "diagnostic must name the offending dep: {rendered}",
9952        );
9953        assert!(
9954            rendered.contains("--upload-pack=cat /etc/passwd"),
9955            "diagnostic must quote the offending caminho: {rendered}",
9956        );
9957        assert!(
9958            rendered.contains("CLI-argument-injection"),
9959            "diagnostic must name the CLI-argument-injection vector: {rendered}",
9960        );
9961        assert!(
9962            rendered.contains("`-`"),
9963            "diagnostic must name the offending byte: {rendered}",
9964        );
9965    }
9966
9967    #[test]
9968    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9969        // Diagnostic-shape pin (peer with
9970        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9971        // payload assertion on the immediate-predecessor arm): the
9972        // error's Display surfaces the offending `:nome`, the
9973        // offending `:caminho` verbatim, and the offending byte in
9974        // hex form (`0x09` for tab) so a `feira lint` run can render
9975        // the diagnostic without re-parsing.
9976        let d = dep_with_fonte(DepSource::Path {
9977            caminho: "../caixa\tteia".into(),
9978        });
9979        let rendered = d.validate().unwrap_err().to_string();
9980        assert!(
9981            rendered.contains("caixa-teia"),
9982            "diagnostic must name the offending dep: {rendered}",
9983        );
9984        assert!(
9985            rendered.contains("../caixa\tteia"),
9986            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9987        );
9988        assert!(
9989            rendered.contains("0x09"),
9990            "diagnostic must name the offending byte in hex: {rendered:?}",
9991        );
9992    }
9993
9994    #[test]
9995    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9996        // The fail-before-pass-after pin for the canonical Windows-
9997        // path-separator paste footgun: an author who pastes a path
9998        // from Windows-Explorer's `Copy as path`, PowerShell's
9999        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10000        // produces `..\caixa-teia`-shape values that silently passed
10001        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10002        // false; `\` is neither a leading-byte sentinel nor a
10003        // control byte). On POSIX resolvers the value rides through
10004        // `Path::join` as a literal directory name and fails at
10005        // resolve time with `No such file or directory`; on Windows
10006        // resolvers the value resolves to the parent's sibling — two
10007        // distinct directories for the byte-identical caixa.lisp.
10008        // The new arm moves the rejection to validate time and names
10009        // the offending dep + caminho verbatim.
10010        let d = dep_with_fonte(DepSource::Path {
10011            caminho: "..\\caixa-teia".into(),
10012        });
10013        let err = d.validate().unwrap_err();
10014        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10015            panic!("expected FonteCaminhoBackslash, got {err:?}");
10016        };
10017        assert_eq!(nome, "caixa-teia");
10018        assert_eq!(caminho, "..\\caixa-teia");
10019    }
10020
10021    #[test]
10022    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10023        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10024        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10025        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10026        // false (POSIX absolute paths start with `/`, drive letters
10027        // are not a POSIX concept), so the b94fd83 absolute arm
10028        // doesn't fire; the value contains `\` bytes that this arm
10029        // now catches with the more self-locating Windows-path-
10030        // separator diagnostic. Pinned separately from the bare
10031        // `..\caixa-teia` shape so a future arm that targets only
10032        // leading-`..\` doesn't regress the drive-letter coverage.
10033        let d = dep_with_fonte(DepSource::Path {
10034            caminho: "C:\\work\\caixa-teia".into(),
10035        });
10036        let err = d.validate().unwrap_err();
10037        assert!(
10038            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10039            "got {err:?}",
10040        );
10041    }
10042
10043    #[test]
10044    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10045        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10046        // PowerShell tab-completion-on-a-directory append). Pinned
10047        // separately from the embedded-`\` shape so the gate's
10048        // contract is "any `\` anywhere", not "any `\` not at end".
10049        let d = dep_with_fonte(DepSource::Path {
10050            caminho: "..\\caixa-teia\\".into(),
10051        });
10052        let err = d.validate().unwrap_err();
10053        assert!(
10054            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10055            "got {err:?}",
10056        );
10057    }
10058
10059    #[test]
10060    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10061        // The positive-control pin: the gate targets `\` only,
10062        // never `/`. The canonical relative POSIX path
10063        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10064        // so legitimate nested-directory deps aren't broken. Pinned
10065        // so the gate doesn't accidentally widen to a "no path
10066        // separators at all" sweep.
10067        let d = dep_with_fonte(DepSource::Path {
10068            caminho: "../caixa-teia/foo/bar".into(),
10069        });
10070        d.validate().unwrap();
10071    }
10072
10073    #[test]
10074    fn fonte_caminho_control_char_fires_before_backslash() {
10075        // Cascade pin: the control-char arm structurally precedes the
10076        // backslash arm. A value like `"..\caixa\0teia"` probes
10077        // positive on both (`\` byte + NUL byte), but the control-
10078        // char diagnostic wins so the author sees the more self-
10079        // locating POSIX-syscall-rejected-byte diagnostic first
10080        // (NUL outright breaks `CString::new` at every `std::fs`
10081        // syscall boundary; the `\` divergence is the cross-OS-
10082        // separator axis). Mirrors the
10083        // `fonte_caminho_var_fires_before_control_char` cascade
10084        // discipline on the immediate-predecessor arm.
10085        let d = dep_with_fonte(DepSource::Path {
10086            caminho: "..\\caixa\0teia".into(),
10087        });
10088        let err = d.validate().unwrap_err();
10089        assert!(
10090            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10091            "got {err:?}",
10092        );
10093    }
10094
10095    #[test]
10096    fn fonte_caminho_absolute_fires_before_backslash() {
10097        // Cascade pin on the load-bearing leading-byte arm: a leading
10098        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10099        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10100        // — the host-layout-leak diagnostic is the load-bearing
10101        // axis, the `\` byte is the secondary observation. Same
10102        // precedence logic as every prior leading-byte arm.
10103        let d = dep_with_fonte(DepSource::Path {
10104            caminho: "/etc/passwd\\foo".into(),
10105        });
10106        let err = d.validate().unwrap_err();
10107        assert!(
10108            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10109            "got {err:?}",
10110        );
10111    }
10112
10113    #[test]
10114    fn fonte_caminho_var_fires_before_backslash() {
10115        // Cascade pin on the var-expansion arm: a leading-`$` value
10116        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10117        // PowerShell-env-var paste-from-CI-manifest footgun) routes
10118        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10119        // The shell-expansion diagnostic is the more self-locating
10120        // axis since both the leading `$` and the embedded `\`
10121        // are Windows-shell artifacts but the `$` is the root-cause
10122        // surface (an author who removes the `$` is likely to leave
10123        // the `\` too).
10124        let d = dep_with_fonte(DepSource::Path {
10125            caminho: "$WORKSPACE\\caixa-teia".into(),
10126        });
10127        let err = d.validate().unwrap_err();
10128        assert!(
10129            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10130            "got {err:?}",
10131        );
10132    }
10133
10134    #[test]
10135    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10136        // Diagnostic-shape pin (peer with the prior
10137        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10138        // on every preceding arm): the error's Display surfaces the
10139        // offending `:nome` and the offending `:caminho` verbatim
10140        // so a `feira lint` run can render the diagnostic without
10141        // re-parsing.
10142        let d = dep_with_fonte(DepSource::Path {
10143            caminho: "..\\caixa-teia".into(),
10144        });
10145        let rendered = d.validate().unwrap_err().to_string();
10146        assert!(
10147            rendered.contains("caixa-teia"),
10148            "diagnostic must name the offending dep: {rendered}",
10149        );
10150        assert!(
10151            rendered.contains("..\\caixa-teia"),
10152            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10153        );
10154        assert!(
10155            rendered.contains('\\'),
10156            "diagnostic must reference the backslash footgun: {rendered:?}",
10157        );
10158    }
10159
10160    #[test]
10161    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10162        // The fail-before-pass-after pin for the canonical trailing-`/`
10163        // paste footgun: an author who shell-tab-completes a sibling
10164        // directory (every interactive shell — bash/zsh/fish/nushell —
10165        // appends `/` on tab-completing a directory) produces
10166        // `"../caixa-teia/"`-shape values that silently passed every
10167        // prior arm (the leading byte is `.`, no control bytes, no
10168        // backslash). `Path::join` resolves both shapes to the same
10169        // directory at the resolver, but the lacre embeds the value
10170        // verbatim and the BLAKE3 closures diverge across two
10171        // workstations whose authors differ only in tab-completion
10172        // habits.
10173        let d = dep_with_fonte(DepSource::Path {
10174            caminho: "../caixa-teia/".into(),
10175        });
10176        let err = d.validate().unwrap_err();
10177        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10178            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10179        };
10180        assert_eq!(nome, "caixa-teia");
10181        assert_eq!(caminho, "../caixa-teia/");
10182    }
10183
10184    #[test]
10185    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10186        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10187        // directory and tab-completed it" footgun). Pinned separately
10188        // from the canonical `"../caixa-teia/"` shape so the gate's
10189        // contract is "any trailing `/`", not "trailing `/` after a leaf
10190        // name".
10191        let d = dep_with_fonte(DepSource::Path {
10192            caminho: "./".into(),
10193        });
10194        let err = d.validate().unwrap_err();
10195        assert!(
10196            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10197            "got {err:?}",
10198        );
10199    }
10200
10201    #[test]
10202    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10203        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10204        // that double-templated `${VAR}/` over an already-`/`-suffixed
10205        // path" footgun). The gate fires on the last byte being `/`
10206        // regardless of how many `/` precede it; the arm contract is
10207        // "the value ends with `/`", structurally.
10208        let d = dep_with_fonte(DepSource::Path {
10209            caminho: "../caixa-teia//".into(),
10210        });
10211        let err = d.validate().unwrap_err();
10212        assert!(
10213            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10214            "got {err:?}",
10215        );
10216    }
10217
10218    #[test]
10219    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10220        // The `"../"` shape (the canonical "I want the parent" tab-
10221        // completion footgun on a bare `..` path). Pinned separately so
10222        // the gate doesn't accidentally narrow to "trailing `/` only on
10223        // multi-segment paths".
10224        let d = dep_with_fonte(DepSource::Path {
10225            caminho: "../".into(),
10226        });
10227        let err = d.validate().unwrap_err();
10228        assert!(
10229            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10230            "got {err:?}",
10231        );
10232    }
10233
10234    #[test]
10235    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10236        // The positive-control pin: the gate targets the trailing byte
10237        // only, never internal `/` separators. The canonical nested
10238        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10239        // to validate cleanly so legitimate deeply-nested deps aren't
10240        // broken. Pinned so the gate doesn't accidentally widen to a
10241        // "no `/` separators anywhere" sweep that would defeat the
10242        // entire path-fonte author surface.
10243        let d = dep_with_fonte(DepSource::Path {
10244            caminho: "../caixa-teia/foo/bar".into(),
10245        });
10246        d.validate().unwrap();
10247    }
10248
10249    #[test]
10250    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10251        // The positive-control pin on the degenerate single-`.` shape
10252        // (the canonical "the caixa.lisp's own directory" idiom). The
10253        // gate fires on the trailing byte being `/`, not on the path
10254        // being short, so `"."` (one byte, not `/`) must continue to
10255        // validate cleanly.
10256        let d = dep_with_fonte(DepSource::Path {
10257            caminho: ".".into(),
10258        });
10259        d.validate().unwrap();
10260    }
10261
10262    #[test]
10263    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10264        // Cascade pin: the control-char arm structurally precedes the
10265        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10266        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10267        // (control bytes are the paste-from-multiline-doc footgun the
10268        // d624c8d arm already closes). Mirrors the
10269        // `fonte_caminho_control_char_fires_before_backslash` cascade
10270        // discipline on the immediate-predecessor arm.
10271        let d = dep_with_fonte(DepSource::Path {
10272            caminho: "../foo\n/".into(),
10273        });
10274        let err = d.validate().unwrap_err();
10275        assert!(
10276            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10277            "got {err:?}",
10278        );
10279    }
10280
10281    #[test]
10282    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10283        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10284        // ends in `/` but the embedded `\` is the load-bearing
10285        // diagnostic (the cross-host-OS-separator divergence vector
10286        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10287        // narrower-diagnostic-first cascade.
10288        let d = dep_with_fonte(DepSource::Path {
10289            caminho: "..\\caixa-teia/".into(),
10290        });
10291        let err = d.validate().unwrap_err();
10292        assert!(
10293            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10294            "got {err:?}",
10295        );
10296    }
10297
10298    #[test]
10299    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10300        // Cascade pin on the load-bearing leading-byte arm: a leading
10301        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10302        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10303        // — the host-layout-leak diagnostic is the load-bearing axis,
10304        // the trailing `/` is the secondary observation. Same
10305        // precedence logic as every prior leading-byte arm.
10306        let d = dep_with_fonte(DepSource::Path {
10307            caminho: "/etc/passwd/".into(),
10308        });
10309        let err = d.validate().unwrap_err();
10310        assert!(
10311            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10312            "got {err:?}",
10313        );
10314    }
10315
10316    #[test]
10317    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10318        // Diagnostic-shape pin (peer with the prior
10319        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10320        // every preceding arm): the error's Display surfaces the
10321        // offending `:nome` and the offending `:caminho` verbatim so a
10322        // `feira lint` run can render the diagnostic without re-parsing.
10323        let d = dep_with_fonte(DepSource::Path {
10324            caminho: "../caixa-teia/".into(),
10325        });
10326        let rendered = d.validate().unwrap_err().to_string();
10327        assert!(
10328            rendered.contains("caixa-teia"),
10329            "diagnostic must name the offending dep: {rendered}",
10330        );
10331        assert!(
10332            rendered.contains("../caixa-teia/"),
10333            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10334        );
10335        assert!(
10336            rendered.contains("trailing"),
10337            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10338        );
10339    }
10340
10341    // -- :caminho shell-redirection metacharacter arm -----------------------
10342
10343    #[test]
10344    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10345        // The fail-before-pass-after pin for the canonical output-redirection
10346        // paste footgun: an author copies a shell pipeline tail
10347        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10348        // line including the `> build.log` redirect" idiom) and silently
10349        // passed every prior arm (`Path::is_absolute` false on `..`, no
10350        // control bytes, no backslash, doesn't end in `/`). The lacre
10351        // embedded the value verbatim, the resolver folded it through
10352        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10353        // subdirectory, and the failure surfaced at resolve time with a
10354        // non-self-locating `No such file or directory` error. The new arm
10355        // moves the rejection to validate time and names the offending dep
10356        // + caminho + byte verbatim.
10357        let d = dep_with_fonte(DepSource::Path {
10358            caminho: "../caixa-teia>build.log".into(),
10359        });
10360        let err = d.validate().unwrap_err();
10361        let DepError::FonteCaminhoShellRedirection {
10362            nome,
10363            caminho,
10364            byte,
10365        } = err
10366        else {
10367            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10368        };
10369        assert_eq!(nome, "caixa-teia");
10370        assert_eq!(caminho, "../caixa-teia>build.log");
10371        assert_eq!(byte, b'>');
10372    }
10373
10374    #[test]
10375    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10376        // The symmetric input-redirection paste shape
10377        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10378        // `command < input.lisp` line from a tatara-lisp REPL log"
10379        // idiom). Pinned separately from the `>` shape so the gate's
10380        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10381        let d = dep_with_fonte(DepSource::Path {
10382            caminho: "../caixa-teia<input.lisp".into(),
10383        });
10384        let err = d.validate().unwrap_err();
10385        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10386            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10387        };
10388        assert_eq!(byte, b'<');
10389    }
10390
10391    #[test]
10392    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10393        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10394        // "I forgot the source side of the redirect" idiom). Pinned
10395        // separately from the embedded-byte shapes so the gate covers
10396        // every position, not only mid-path.
10397        let d = dep_with_fonte(DepSource::Path {
10398            caminho: ">../caixa-teia".into(),
10399        });
10400        let err = d.validate().unwrap_err();
10401        assert!(
10402            matches!(
10403                err,
10404                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10405            ),
10406            "got {err:?}",
10407        );
10408    }
10409
10410    #[test]
10411    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10412        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10413        // the canonical "I copied a `>>` append redirect" idiom). The arm
10414        // fires on the first `>` encountered; pinned so a future arm that
10415        // tries to distinguish `>` from `>>` doesn't break the broader
10416        // contract.
10417        let d = dep_with_fonte(DepSource::Path {
10418            caminho: "../caixa-teia>>build.log".into(),
10419        });
10420        let err = d.validate().unwrap_err();
10421        assert!(
10422            matches!(
10423                err,
10424                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10425            ),
10426            "got {err:?}",
10427        );
10428    }
10429
10430    #[test]
10431    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10432        // The positive-control pin: the gate targets only `<` / `>`,
10433        // never adjacent printable ASCII or POSIX-valid bytes. The
10434        // canonical relative POSIX path (`"../caixa-teia"`) and a
10435        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10436        // continue to validate cleanly so the gate doesn't widen to a
10437        // "no printable punctuation anywhere" sweep that would defeat
10438        // the entire path-fonte author surface.
10439        let d = dep_with_fonte(DepSource::Path {
10440            caminho: "../caixa-teia/foo/bar".into(),
10441        });
10442        d.validate().unwrap();
10443    }
10444
10445    #[test]
10446    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10447        // Cascade pin on the immediate-predecessor arm: a value carrying
10448        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10449        // canonical "I pasted a Windows-shell command with output
10450        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10451        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10452        // divergence is the load-bearing axis (an author who removes
10453        // the `\` is the root-cause edit; the `>` falls away in the
10454        // same edit since it's downstream of the Windows-shell
10455        // convention).
10456        let d = dep_with_fonte(DepSource::Path {
10457            caminho: "..\\caixa-teia>build.log".into(),
10458        });
10459        let err = d.validate().unwrap_err();
10460        assert!(
10461            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10462            "got {err:?}",
10463        );
10464    }
10465
10466    #[test]
10467    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10468        // Cascade pin on the embedded-control-byte arm: a value carrying
10469        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10470        // canonical paste-from-multiline-doc footgun where a newline
10471        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10472        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10473        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10474        // load-bearing axis on every value that probes positive for
10475        // both — mirrors the cascade discipline on every prior arm.
10476        let d = dep_with_fonte(DepSource::Path {
10477            caminho: "../foo\n>bar".into(),
10478        });
10479        let err = d.validate().unwrap_err();
10480        assert!(
10481            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10482            "got {err:?}",
10483        );
10484    }
10485
10486    #[test]
10487    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10488        // Cascade pin on the load-bearing leading-byte arm: a leading
10489        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10490        // routes through `FonteCaminhoAbsolute` not
10491        // `FonteCaminhoShellRedirection` — the host-layout-leak
10492        // diagnostic is the load-bearing axis, the `>` byte is the
10493        // secondary observation. Same precedence logic as every prior
10494        // leading-byte arm.
10495        let d = dep_with_fonte(DepSource::Path {
10496            caminho: "/etc/passwd>out".into(),
10497        });
10498        let err = d.validate().unwrap_err();
10499        assert!(
10500            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10501            "got {err:?}",
10502        );
10503    }
10504
10505    #[test]
10506    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10507        // Cascade pin on the immediate-successor arm: a value carrying
10508        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10509        // canonical "I tab-completed a path that already had a
10510        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10511        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10512        // the more semantic-locating axis (an author who removes the
10513        // `<` / `>` typically also drops the trailing separator since
10514        // both are paste-from-shell artifacts).
10515        let d = dep_with_fonte(DepSource::Path {
10516            caminho: "../foo></".into(),
10517        });
10518        let err = d.validate().unwrap_err();
10519        assert!(
10520            matches!(
10521                err,
10522                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10523            ),
10524            "got {err:?}",
10525        );
10526    }
10527
10528    #[test]
10529    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10530        // Diagnostic-shape pin (peer with
10531        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10532        // payload assertion on the closest peer arm that also carries a
10533        // `byte` field): the error's Display surfaces the offending
10534        // `:nome`, the offending `:caminho` verbatim, and the offending
10535        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10536        // run can render the diagnostic without re-parsing.
10537        let d = dep_with_fonte(DepSource::Path {
10538            caminho: "../caixa-teia>build.log".into(),
10539        });
10540        let rendered = d.validate().unwrap_err().to_string();
10541        assert!(
10542            rendered.contains("caixa-teia"),
10543            "diagnostic must name the offending dep: {rendered}",
10544        );
10545        assert!(
10546            rendered.contains("../caixa-teia>build.log"),
10547            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10548        );
10549        assert!(
10550            rendered.contains("0x3e"),
10551            "diagnostic must name the offending byte in hex: {rendered:?}",
10552        );
10553        assert!(
10554            rendered.contains("redirection"),
10555            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10556        );
10557    }
10558
10559    // -- :caminho shell-pipe metacharacter arm ----------------------------
10560
10561    #[test]
10562    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10563        // The fail-before-pass-after pin for the canonical shell-pipe
10564        // paste footgun: an author copies a shell-history line
10565        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10566        // the whole `ls dir | grep` line out of zsh history") and
10567        // silently passed every prior arm (`Path::is_absolute` false
10568        // on `..`, no control bytes, no backslash, no `<` / `>`,
10569        // doesn't end in `/`). The lacre embedded the value verbatim,
10570        // the resolver folded it through `Path::join` looking for a
10571        // literal `./../caixa-teia | grep foo` subdirectory, and the
10572        // failure surfaced at resolve time with a non-self-locating
10573        // `No such file or directory` error. The new arm moves the
10574        // rejection to validate time and names the offending dep +
10575        // caminho verbatim.
10576        let d = dep_with_fonte(DepSource::Path {
10577            caminho: "../caixa-teia | grep foo".into(),
10578        });
10579        let err = d.validate().unwrap_err();
10580        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10581            panic!("expected FonteCaminhoShellPipe, got {err:?}");
10582        };
10583        assert_eq!(nome, "caixa-teia");
10584        assert_eq!(caminho, "../caixa-teia | grep foo");
10585    }
10586
10587    #[test]
10588    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10589        // Leading-position `|` shape (`"|../caixa-teia"` — the
10590        // degenerate "I forgot the source side of the pipe" idiom).
10591        // Pinned separately from the embedded-byte shape so the gate
10592        // covers every position, not only mid-path.
10593        let d = dep_with_fonte(DepSource::Path {
10594            caminho: "|../caixa-teia".into(),
10595        });
10596        let err = d.validate().unwrap_err();
10597        assert!(
10598            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10599            "got {err:?}",
10600        );
10601    }
10602
10603    #[test]
10604    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10605        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10606        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10607        // idiom). The arm fires on the first `|` encountered; pinned
10608        // so a future arm that tries to distinguish `|` from `||`
10609        // doesn't break the broader contract.
10610        let d = dep_with_fonte(DepSource::Path {
10611            caminho: "../caixa-teia||fallback".into(),
10612        });
10613        let err = d.validate().unwrap_err();
10614        assert!(
10615            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10616            "got {err:?}",
10617        );
10618    }
10619
10620    #[test]
10621    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10622        // The positive-control pin: the gate targets only `|`, never
10623        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10624        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10625        // pathed variant with adjacent printable punctuation
10626        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10627        // cleanly so the gate doesn't widen to a "no printable
10628        // punctuation anywhere" sweep that would defeat the entire
10629        // path-fonte author surface.
10630        let d = dep_with_fonte(DepSource::Path {
10631            caminho: "../caixa-teia/sub-dir.v2".into(),
10632        });
10633        d.validate().unwrap();
10634    }
10635
10636    #[test]
10637    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10638        // Cascade pin on the immediate-predecessor arm: a value carrying
10639        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10640        // canonical "I pasted a `cmd < input | tee` pipeline tail"
10641        // footgun) routes through `FonteCaminhoShellRedirection` not
10642        // `FonteCaminhoShellPipe`. The input/output redirection
10643        // metachar carries the more self-locating `byte: u8` payload
10644        // (it names which of `<` or `>` triggered), so the prior arm
10645        // wins on every probe-as-both value — same cascade discipline
10646        // every prior `:caminho` arm establishes.
10647        let d = dep_with_fonte(DepSource::Path {
10648            caminho: "../caixa-teia<input|tee".into(),
10649        });
10650        let err = d.validate().unwrap_err();
10651        assert!(
10652            matches!(
10653                err,
10654                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10655            ),
10656            "got {err:?}",
10657        );
10658    }
10659
10660    #[test]
10661    fn fonte_caminho_backslash_fires_before_shell_pipe() {
10662        // Cascade pin on the upstream backslash arm: a value carrying
10663        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10664        // "I pasted a Windows-shell command with pipe to tee"
10665        // footgun) routes through `FonteCaminhoBackslash` not
10666        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10667        // divergence is the load-bearing axis on every probe-as-both
10668        // value (an author who removes the `\` is the root-cause edit;
10669        // the `|` falls away in the same edit since it's downstream of
10670        // the Windows-shell convention).
10671        let d = dep_with_fonte(DepSource::Path {
10672            caminho: "..\\caixa-teia|tee".into(),
10673        });
10674        let err = d.validate().unwrap_err();
10675        assert!(
10676            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10677            "got {err:?}",
10678        );
10679    }
10680
10681    #[test]
10682    fn fonte_caminho_control_char_fires_before_shell_pipe() {
10683        // Cascade pin on the embedded-control-byte arm: a value
10684        // carrying both a control byte and `|` (`"../foo\n|bar"` —
10685        // the canonical paste-from-multiline-doc footgun where a
10686        // newline landed mid-caminho) routes through
10687        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10688        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10689        // diagnostic is the load-bearing axis on every value that
10690        // probes positive for both — mirrors the cascade discipline
10691        // on every prior arm.
10692        let d = dep_with_fonte(DepSource::Path {
10693            caminho: "../foo\n|bar".into(),
10694        });
10695        let err = d.validate().unwrap_err();
10696        assert!(
10697            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10698            "got {err:?}",
10699        );
10700    }
10701
10702    #[test]
10703    fn fonte_caminho_absolute_fires_before_shell_pipe() {
10704        // Cascade pin on the load-bearing leading-byte arm: a leading
10705        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10706        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10707        // — the host-layout-leak diagnostic is the load-bearing axis,
10708        // the `|` byte is the secondary observation. Same precedence
10709        // logic as every prior leading-byte arm.
10710        let d = dep_with_fonte(DepSource::Path {
10711            caminho: "/etc/passwd|tee".into(),
10712        });
10713        let err = d.validate().unwrap_err();
10714        assert!(
10715            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10716            "got {err:?}",
10717        );
10718    }
10719
10720    #[test]
10721    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10722        // Cascade pin on the immediate-successor arm: a value carrying
10723        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10724        // "I tab-completed a path that already had a pipeline tail"
10725        // footgun) routes through `FonteCaminhoShellPipe` not
10726        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10727        // the more semantic-locating axis (an author who removes the
10728        // `|` typically also drops the trailing separator since both
10729        // are paste-from-shell artifacts).
10730        let d = dep_with_fonte(DepSource::Path {
10731            caminho: "../foo|tee/".into(),
10732        });
10733        let err = d.validate().unwrap_err();
10734        assert!(
10735            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10736            "got {err:?}",
10737        );
10738    }
10739
10740    #[test]
10741    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10742        // Diagnostic-shape pin (peer with
10743        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10744        // on the closest single-byte peer arm): the error's Display
10745        // surfaces the offending `:nome` and the offending `:caminho`
10746        // verbatim, and names the shell-pipe footgun explicitly so a
10747        // `feira lint` run can render the diagnostic without
10748        // re-parsing.
10749        let d = dep_with_fonte(DepSource::Path {
10750            caminho: "../caixa-teia | grep foo".into(),
10751        });
10752        let rendered = d.validate().unwrap_err().to_string();
10753        assert!(
10754            rendered.contains("caixa-teia"),
10755            "diagnostic must name the offending dep: {rendered}",
10756        );
10757        assert!(
10758            rendered.contains("../caixa-teia | grep foo"),
10759            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10760        );
10761        assert!(
10762            rendered.contains('|'),
10763            "diagnostic must reference the pipe footgun: {rendered:?}",
10764        );
10765        assert!(
10766            rendered.contains("pipe"),
10767            "diagnostic must name the shell-pipe footgun: {rendered:?}",
10768        );
10769    }
10770
10771    // -- :caminho shell-command-separator metacharacter arm ---------------
10772
10773    #[test]
10774    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10775        // The fail-before-pass-after pin for the canonical shell-command-
10776        // separator paste footgun: an author copies a shell one-liner
10777        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10778        // whole `cd path; do-thing` chain out of a shell-history block")
10779        // and silently passed every prior arm (`Path::is_absolute` false
10780        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10781        // doesn't end in `/`). The lacre embedded the value verbatim, the
10782        // resolver folded it through `Path::join` looking for a literal
10783        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10784        // surfaced at resolve time with a non-self-locating `No such file
10785        // or directory` error. The new arm moves the rejection to validate
10786        // time and names the offending dep + caminho verbatim.
10787        let d = dep_with_fonte(DepSource::Path {
10788            caminho: "../caixa-teia; rm -rf build".into(),
10789        });
10790        let err = d.validate().unwrap_err();
10791        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10792            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10793        };
10794        assert_eq!(nome, "caixa-teia");
10795        assert_eq!(caminho, "../caixa-teia; rm -rf build");
10796    }
10797
10798    #[test]
10799    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10800        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10801        // "I forgot the prior command side of the separator" idiom).
10802        // Pinned separately from the embedded-byte shape so the gate
10803        // covers every position, not only mid-path.
10804        let d = dep_with_fonte(DepSource::Path {
10805            caminho: ";../caixa-teia".into(),
10806        });
10807        let err = d.validate().unwrap_err();
10808        assert!(
10809            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10810            "got {err:?}",
10811        );
10812    }
10813
10814    #[test]
10815    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10816        // The POSIX `case` arm `;;` terminator shape
10817        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10818        // arm tail" idiom). The arm fires on the first `;` encountered;
10819        // pinned so a future arm that tries to distinguish `;` from `;;`
10820        // doesn't break the broader contract.
10821        let d = dep_with_fonte(DepSource::Path {
10822            caminho: "../caixa-teia;;next".into(),
10823        });
10824        let err = d.validate().unwrap_err();
10825        assert!(
10826            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10827            "got {err:?}",
10828        );
10829    }
10830
10831    #[test]
10832    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10833        // The positive-control pin: the gate targets only `;`, never
10834        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10835        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10836        // pathed variant with adjacent printable punctuation
10837        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10838        // cleanly so the gate doesn't widen to a "no printable
10839        // punctuation anywhere" sweep that would defeat the entire
10840        // path-fonte author surface.
10841        let d = dep_with_fonte(DepSource::Path {
10842            caminho: "../caixa-teia/sub-dir.v2".into(),
10843        });
10844        d.validate().unwrap();
10845    }
10846
10847    #[test]
10848    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10849        // Cascade pin on the immediate-predecessor arm: a value carrying
10850        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10851        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10852        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10853        // pipeline-tail paste is the load-bearing root-cause edit on
10854        // every probe-as-both value (an author who removes the `|`
10855        // typically also drops the trailing `; cleanup` since both are
10856        // the same paste-from-shell-history artifact) — same cascade
10857        // discipline every prior `:caminho` arm establishes.
10858        let d = dep_with_fonte(DepSource::Path {
10859            caminho: "../caixa-teia | tee; rm".into(),
10860        });
10861        let err = d.validate().unwrap_err();
10862        assert!(
10863            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10864            "got {err:?}",
10865        );
10866    }
10867
10868    #[test]
10869    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10870        // Cascade pin on the upstream shell-redirection arm: a value
10871        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10872        // the canonical "I pasted a `cmd > log; cleanup` chain"
10873        // footgun) routes through `FonteCaminhoShellRedirection` not
10874        // `FonteCaminhoShellSemicolon`. The input/output redirection
10875        // metachar carries the more self-locating `byte: u8` payload
10876        // (it names which of `<` or `>` triggered), so the prior arm
10877        // wins on every probe-as-both value.
10878        let d = dep_with_fonte(DepSource::Path {
10879            caminho: "../caixa-teia>log; rm".into(),
10880        });
10881        let err = d.validate().unwrap_err();
10882        assert!(
10883            matches!(
10884                err,
10885                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10886            ),
10887            "got {err:?}",
10888        );
10889    }
10890
10891    #[test]
10892    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10893        // Cascade pin on the upstream backslash arm: a value carrying
10894        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10895        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10896        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10897        // The cross-host-OS-separator divergence is the load-bearing axis
10898        // on every probe-as-both value (an author who removes the `\` is
10899        // the root-cause edit; the `;` falls away in the same edit since
10900        // it's downstream of the Windows-shell convention).
10901        let d = dep_with_fonte(DepSource::Path {
10902            caminho: "..\\caixa-teia;rm".into(),
10903        });
10904        let err = d.validate().unwrap_err();
10905        assert!(
10906            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10907            "got {err:?}",
10908        );
10909    }
10910
10911    #[test]
10912    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10913        // Cascade pin on the embedded-control-byte arm: a value carrying
10914        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10915        // paste-from-multiline-doc footgun where a newline landed mid-
10916        // caminho) routes through `FonteCaminhoControlChar` not
10917        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10918        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10919        // on every value that probes positive for both — mirrors the
10920        // cascade discipline on every prior arm.
10921        let d = dep_with_fonte(DepSource::Path {
10922            caminho: "../foo\n;bar".into(),
10923        });
10924        let err = d.validate().unwrap_err();
10925        assert!(
10926            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10927            "got {err:?}",
10928        );
10929    }
10930
10931    #[test]
10932    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10933        // Cascade pin on the load-bearing leading-byte arm: a leading
10934        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10935        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10936        // — the host-layout-leak diagnostic is the load-bearing axis,
10937        // the `;` byte is the secondary observation. Same precedence
10938        // logic as every prior leading-byte arm.
10939        let d = dep_with_fonte(DepSource::Path {
10940            caminho: "/etc/passwd;rm".into(),
10941        });
10942        let err = d.validate().unwrap_err();
10943        assert!(
10944            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10945            "got {err:?}",
10946        );
10947    }
10948
10949    #[test]
10950    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10951        // Cascade pin on the immediate-successor arm: a value carrying
10952        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10953        // "I tab-completed a path that already had a `; cleanup` tail"
10954        // footgun) routes through `FonteCaminhoShellSemicolon` not
10955        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10956        // the more semantic-locating axis (an author who removes the
10957        // `;` typically also drops the trailing separator since both
10958        // are paste-from-shell artifacts).
10959        let d = dep_with_fonte(DepSource::Path {
10960            caminho: "../foo;rm/".into(),
10961        });
10962        let err = d.validate().unwrap_err();
10963        assert!(
10964            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10965            "got {err:?}",
10966        );
10967    }
10968
10969    #[test]
10970    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10971        // Diagnostic-shape pin (peer with
10972        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10973        // on the closest single-byte peer arm): the error's Display
10974        // surfaces the offending `:nome` and the offending `:caminho`
10975        // verbatim, and names the shell-command-separator footgun
10976        // explicitly so a `feira lint` run can render the diagnostic
10977        // without re-parsing.
10978        let d = dep_with_fonte(DepSource::Path {
10979            caminho: "../caixa-teia; rm -rf build".into(),
10980        });
10981        let rendered = d.validate().unwrap_err().to_string();
10982        assert!(
10983            rendered.contains("caixa-teia"),
10984            "diagnostic must name the offending dep: {rendered}",
10985        );
10986        assert!(
10987            rendered.contains("../caixa-teia; rm -rf build"),
10988            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10989        );
10990        assert!(
10991            rendered.contains(';'),
10992            "diagnostic must reference the semicolon footgun: {rendered:?}",
10993        );
10994        assert!(
10995            rendered.contains("command-separator"),
10996            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10997        );
10998    }
10999
11000    #[test]
11001    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11002        // The fail-before-pass-after pin for the canonical shell-
11003        // background-task paste footgun: an author copies a shell one-
11004        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11005        // the whole `cd path & sleep 1` background-launch out of a
11006        // shell-history block") and silently passed every prior arm
11007        // (`Path::is_absolute` false on `..`, no control bytes, no
11008        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11009        // The lacre embedded the value verbatim, the resolver folded it
11010        // through `Path::join` looking for a literal `./../caixa-teia &
11011        // sleep 1` subdirectory, and the failure surfaced at resolve
11012        // time with a non-self-locating `No such file or directory`
11013        // error. The new arm moves the rejection to validate time and
11014        // names the offending dep + caminho verbatim.
11015        let d = dep_with_fonte(DepSource::Path {
11016            caminho: "../caixa-teia & sleep 1".into(),
11017        });
11018        let err = d.validate().unwrap_err();
11019        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11020            panic!("expected FonteCaminhoShellBackground, got {err:?}");
11021        };
11022        assert_eq!(nome, "caixa-teia");
11023        assert_eq!(caminho, "../caixa-teia & sleep 1");
11024    }
11025
11026    #[test]
11027    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11028        // Leading-position `&` shape (`"&../caixa-teia"` — the
11029        // degenerate "I forgot the prior command side of the
11030        // background terminator" idiom). Pinned separately from the
11031        // embedded-byte shape so the gate covers every position, not
11032        // only mid-path.
11033        let d = dep_with_fonte(DepSource::Path {
11034            caminho: "&../caixa-teia".into(),
11035        });
11036        let err = d.validate().unwrap_err();
11037        assert!(
11038            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11039            "got {err:?}",
11040        );
11041    }
11042
11043    #[test]
11044    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11045        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11046        // canonical "I copied a `cd path && make` build chain" idiom
11047        // every Makefile / shell-script wraps). The arm fires on the
11048        // first `&` encountered; pinned so a future arm that tries to
11049        // distinguish `&` from `&&` doesn't break the broader contract.
11050        let d = dep_with_fonte(DepSource::Path {
11051            caminho: "../caixa-teia && make".into(),
11052        });
11053        let err = d.validate().unwrap_err();
11054        assert!(
11055            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11056            "got {err:?}",
11057        );
11058    }
11059
11060    #[test]
11061    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11062        // The positive-control pin: the gate targets only `&`, never
11063        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11064        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11065        // pathed variant with adjacent printable punctuation
11066        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11067        // cleanly so the gate doesn't widen to a "no printable
11068        // punctuation anywhere" sweep that would defeat the entire
11069        // path-fonte author surface.
11070        let d = dep_with_fonte(DepSource::Path {
11071            caminho: "../caixa-teia/sub-dir.v2".into(),
11072        });
11073        d.validate().unwrap();
11074    }
11075
11076    #[test]
11077    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11078        // Cascade pin on the immediate-predecessor arm: a value carrying
11079        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11080        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11081        // routes through `FonteCaminhoShellSemicolon` not
11082        // `FonteCaminhoShellBackground`. The sequential-command-
11083        // separator paste is the more common shell-history paste idiom
11084        // on every probe-as-both value (an author who removes the `;`
11085        // typically also drops the trailing `& sleep` since both are
11086        // paste-from-shell-history artifacts) — same cascade discipline
11087        // every prior `:caminho` arm establishes.
11088        let d = dep_with_fonte(DepSource::Path {
11089            caminho: "../caixa-teia; rm & sleep".into(),
11090        });
11091        let err = d.validate().unwrap_err();
11092        assert!(
11093            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11094            "got {err:?}",
11095        );
11096    }
11097
11098    #[test]
11099    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11100        // Cascade pin on the upstream shell-pipe arm: a value carrying
11101        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11102        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11103        // chain" footgun) routes through `FonteCaminhoShellPipe` not
11104        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11105        // load-bearing root-cause edit on every probe-as-both value.
11106        let d = dep_with_fonte(DepSource::Path {
11107            caminho: "../caixa-teia | tee & sleep".into(),
11108        });
11109        let err = d.validate().unwrap_err();
11110        assert!(
11111            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11112            "got {err:?}",
11113        );
11114    }
11115
11116    #[test]
11117    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11118        // Cascade pin on the upstream shell-redirection arm: a value
11119        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11120        // the canonical "I pasted a `cmd > log & sleep` background-
11121        // redirect chain" footgun) routes through
11122        // `FonteCaminhoShellRedirection` not
11123        // `FonteCaminhoShellBackground`. The input/output redirection
11124        // metachar carries the more self-locating `byte: u8` payload
11125        // (it names which of `<` or `>` triggered), so the prior arm
11126        // wins on every probe-as-both value.
11127        let d = dep_with_fonte(DepSource::Path {
11128            caminho: "../caixa-teia>log & sleep".into(),
11129        });
11130        let err = d.validate().unwrap_err();
11131        assert!(
11132            matches!(
11133                err,
11134                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11135            ),
11136            "got {err:?}",
11137        );
11138    }
11139
11140    #[test]
11141    fn fonte_caminho_backslash_fires_before_shell_background() {
11142        // Cascade pin on the upstream backslash arm: a value carrying
11143        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11144        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11145        // launch chain") routes through `FonteCaminhoBackslash` not
11146        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11147        // divergence is the load-bearing axis on every probe-as-both
11148        // value (an author who removes the `\` is the root-cause edit;
11149        // the `&` falls away in the same edit since it's downstream of
11150        // the Windows-shell convention).
11151        let d = dep_with_fonte(DepSource::Path {
11152            caminho: "..\\caixa-teia & sleep".into(),
11153        });
11154        let err = d.validate().unwrap_err();
11155        assert!(
11156            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11157            "got {err:?}",
11158        );
11159    }
11160
11161    #[test]
11162    fn fonte_caminho_control_char_fires_before_shell_background() {
11163        // Cascade pin on the embedded-control-byte arm: a value
11164        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11165        // the canonical paste-from-multiline-doc footgun where a
11166        // newline landed mid-caminho) routes through
11167        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11168        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11169        // diagnostic is the load-bearing axis on every value that
11170        // probes positive for both — mirrors the cascade discipline on
11171        // every prior arm.
11172        let d = dep_with_fonte(DepSource::Path {
11173            caminho: "../foo\n&sleep".into(),
11174        });
11175        let err = d.validate().unwrap_err();
11176        assert!(
11177            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11178            "got {err:?}",
11179        );
11180    }
11181
11182    #[test]
11183    fn fonte_caminho_absolute_fires_before_shell_background() {
11184        // Cascade pin on the load-bearing leading-byte arm: a leading
11185        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11186        // through `FonteCaminhoAbsolute` not
11187        // `FonteCaminhoShellBackground` — the host-layout-leak
11188        // diagnostic is the load-bearing axis, the `&` byte is the
11189        // secondary observation. Same precedence logic as every prior
11190        // leading-byte arm.
11191        let d = dep_with_fonte(DepSource::Path {
11192            caminho: "/etc/passwd & sleep".into(),
11193        });
11194        let err = d.validate().unwrap_err();
11195        assert!(
11196            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11197            "got {err:?}",
11198        );
11199    }
11200
11201    #[test]
11202    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11203        // Cascade pin on the immediate-successor arm: a value carrying
11204        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11205        // canonical "I tab-completed a path that already had a `&
11206        // sleep` background-launch tail" footgun) routes through
11207        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11208        // The embedded shell-metachar is the more semantic-locating
11209        // axis (an author who removes the `&` typically also drops
11210        // the trailing separator since both are paste-from-shell
11211        // artifacts).
11212        let d = dep_with_fonte(DepSource::Path {
11213            caminho: "../foo&sleep/".into(),
11214        });
11215        let err = d.validate().unwrap_err();
11216        assert!(
11217            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11218            "got {err:?}",
11219        );
11220    }
11221
11222    #[test]
11223    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11224        // Diagnostic-shape pin (peer with
11225        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11226        // on the closest single-byte peer arm): the error's Display
11227        // surfaces the offending `:nome` and the offending `:caminho`
11228        // verbatim, and names the shell-background / logical-AND
11229        // footgun explicitly so a `feira lint` run can render the
11230        // diagnostic without re-parsing.
11231        let d = dep_with_fonte(DepSource::Path {
11232            caminho: "../caixa-teia & sleep 1".into(),
11233        });
11234        let rendered = d.validate().unwrap_err().to_string();
11235        assert!(
11236            rendered.contains("caixa-teia"),
11237            "diagnostic must name the offending dep: {rendered}",
11238        );
11239        assert!(
11240            rendered.contains("../caixa-teia & sleep 1"),
11241            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11242        );
11243        assert!(
11244            rendered.contains('&'),
11245            "diagnostic must reference the ampersand footgun: {rendered:?}",
11246        );
11247        assert!(
11248            rendered.contains("background") || rendered.contains("list-AND"),
11249            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11250        );
11251    }
11252
11253    #[test]
11254    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11255        // The fail-before-pass-after pin for the canonical shell-
11256        // command-substitution paste footgun: an author copies a
11257        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11258        // — the canonical "I pasted a path that included a `pwd`
11259        // / `whoami` / `date` legacy command-substitution expansion
11260        // out of a shell-history block") and silently passed every
11261        // prior arm (`Path::is_absolute` false on `..`, no control
11262        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11263        // end in `/`). The lacre embedded the value verbatim, the
11264        // resolver folded it through `Path::join` looking for a
11265        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11266        // failure surfaced at resolve time with a non-self-locating
11267        // `No such file or directory` error. The new arm moves the
11268        // rejection to validate time and names the offending dep +
11269        // caminho verbatim.
11270        let d = dep_with_fonte(DepSource::Path {
11271            caminho: "../caixa-teia/`whoami`".into(),
11272        });
11273        let err = d.validate().unwrap_err();
11274        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11275            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11276        };
11277        assert_eq!(nome, "caixa-teia");
11278        assert_eq!(caminho, "../caixa-teia/`whoami`");
11279    }
11280
11281    #[test]
11282    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11283        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11284        // the canonical `<backtick>pwd<backtick>/path` working-
11285        // directory expansion shape every shell-side path-composition
11286        // idiom carries). Pinned separately from the embedded-byte
11287        // shape so the gate covers every position, not only mid-path.
11288        let d = dep_with_fonte(DepSource::Path {
11289            caminho: "`pwd`/caixa-teia".into(),
11290        });
11291        let err = d.validate().unwrap_err();
11292        assert!(
11293            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11294            "got {err:?}",
11295        );
11296    }
11297
11298    #[test]
11299    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11300        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11301        // degenerate "I selected an unbalanced backtick out of a
11302        // shell-history block" idiom that probes for the cascade's
11303        // last-byte handling). The trailing-`/` arm fires only on
11304        // last-byte `/`; an unbalanced trailing backtick must route
11305        // through this arm regardless of position.
11306        let d = dep_with_fonte(DepSource::Path {
11307            caminho: "../caixa-teia`".into(),
11308        });
11309        let err = d.validate().unwrap_err();
11310        assert!(
11311            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11312            "got {err:?}",
11313        );
11314    }
11315
11316    #[test]
11317    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11318        // The canonical balanced-pair shape (``"../<backtick>cat
11319        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11320        // command-injection paste idiom every shell-side hardening
11321        // guide enumerates first). The arm fires on the first
11322        // backtick encountered; pinned so a future arm that tries to
11323        // distinguish the opening from the closing byte doesn't break
11324        // the broader contract.
11325        let d = dep_with_fonte(DepSource::Path {
11326            caminho: "../`cat /etc/passwd`".into(),
11327        });
11328        let err = d.validate().unwrap_err();
11329        assert!(
11330            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11331            "got {err:?}",
11332        );
11333    }
11334
11335    #[test]
11336    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11337        // The positive-control pin: the gate targets only the
11338        // backtick byte, never adjacent printable ASCII or POSIX-
11339        // valid bytes. The canonical relative POSIX path
11340        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11341        // adjacent printable punctuation
11342        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11343        // cleanly so the gate doesn't widen to a "no printable
11344        // punctuation anywhere" sweep that would defeat the entire
11345        // path-fonte author surface.
11346        let d = dep_with_fonte(DepSource::Path {
11347            caminho: "../caixa-teia/sub-dir.v2".into(),
11348        });
11349        d.validate().unwrap();
11350    }
11351
11352    #[test]
11353    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11354        // Cascade pin on the immediate-predecessor arm: a value
11355        // carrying both `&` and a backtick (``"../caixa-teia &
11356        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11357        // `cmd & <backtick>sleep N<backtick>` background-launch +
11358        // command-substitution chain" footgun) routes through
11359        // `FonteCaminhoShellBackground` not
11360        // `FonteCaminhoShellCommandSubstitution`. The background-
11361        // launch tail is the more common shell-history paste idiom
11362        // on every probe-as-both value — same cascade discipline
11363        // every prior `:caminho` arm establishes.
11364        let d = dep_with_fonte(DepSource::Path {
11365            caminho: "../caixa-teia & `sleep 1`".into(),
11366        });
11367        let err = d.validate().unwrap_err();
11368        assert!(
11369            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11370            "got {err:?}",
11371        );
11372    }
11373
11374    #[test]
11375    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11376        // Cascade pin on the upstream shell-semicolon arm: a value
11377        // carrying both `;` and a backtick (``"../caixa-teia;
11378        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11379        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11380        // footgun) routes through `FonteCaminhoShellSemicolon` not
11381        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11382        // command-separator paste is the load-bearing root-cause
11383        // edit on every probe-as-both value.
11384        let d = dep_with_fonte(DepSource::Path {
11385            caminho: "../caixa-teia; `whoami`".into(),
11386        });
11387        let err = d.validate().unwrap_err();
11388        assert!(
11389            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11390            "got {err:?}",
11391        );
11392    }
11393
11394    #[test]
11395    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11396        // Cascade pin on the upstream shell-pipe arm: a value
11397        // carrying both `|` and a backtick (``"../caixa-teia |
11398        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11399        // command-substitution paste idiom) routes through
11400        // `FonteCaminhoShellPipe` not
11401        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11402        // paste is the load-bearing root-cause edit on every
11403        // probe-as-both value.
11404        let d = dep_with_fonte(DepSource::Path {
11405            caminho: "../caixa-teia | `tee log`".into(),
11406        });
11407        let err = d.validate().unwrap_err();
11408        assert!(
11409            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11410            "got {err:?}",
11411        );
11412    }
11413
11414    #[test]
11415    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11416        // Cascade pin on the upstream shell-redirection arm: a value
11417        // carrying both `>` and a backtick (``"../caixa-teia>log
11418        // <backtick>date<backtick>"`` — the canonical "I pasted a
11419        // `cmd > log <backtick>date<backtick>` redirect-plus-
11420        // substitution chain" footgun) routes through
11421        // `FonteCaminhoShellRedirection` not
11422        // `FonteCaminhoShellCommandSubstitution`. The input/output
11423        // redirection metachar carries the more self-locating `byte`
11424        // payload (it names which of `<` or `>` triggered), so the
11425        // prior arm wins on every probe-as-both value.
11426        let d = dep_with_fonte(DepSource::Path {
11427            caminho: "../caixa-teia>log `date`".into(),
11428        });
11429        let err = d.validate().unwrap_err();
11430        assert!(
11431            matches!(
11432                err,
11433                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11434            ),
11435            "got {err:?}",
11436        );
11437    }
11438
11439    #[test]
11440    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11441        // Cascade pin on the upstream backslash arm: a value
11442        // carrying both `\` and a backtick (``"..\caixa-teia
11443        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11444        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11445        // chain") routes through `FonteCaminhoBackslash` not
11446        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11447        // separator divergence is the load-bearing axis on every
11448        // probe-as-both value (an author who removes the `\` is the
11449        // root-cause edit; the backtick falls away in the same edit
11450        // since it's downstream of the Windows-shell convention).
11451        let d = dep_with_fonte(DepSource::Path {
11452            caminho: "..\\caixa-teia `whoami`".into(),
11453        });
11454        let err = d.validate().unwrap_err();
11455        assert!(
11456            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11457            "got {err:?}",
11458        );
11459    }
11460
11461    #[test]
11462    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11463        // Cascade pin on the embedded-control-byte arm: a value
11464        // carrying both a control byte and a backtick (`"../foo\n
11465        // `whoami`"` — the canonical paste-from-multiline-doc
11466        // footgun where a newline landed mid-caminho between two
11467        // paste fragments) routes through `FonteCaminhoControlChar`
11468        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11469        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11470        // is the load-bearing axis on every value that probes
11471        // positive for both — mirrors the cascade discipline on
11472        // every prior arm.
11473        let d = dep_with_fonte(DepSource::Path {
11474            caminho: "../foo\n`whoami`".into(),
11475        });
11476        let err = d.validate().unwrap_err();
11477        assert!(
11478            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11479            "got {err:?}",
11480        );
11481    }
11482
11483    #[test]
11484    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11485        // Cascade pin on the load-bearing leading-byte arm: a
11486        // leading `/` value with embedded backtick (``"/etc/passwd
11487        // <backtick>whoami<backtick>"``) routes through
11488        // `FonteCaminhoAbsolute` not
11489        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11490        // leak diagnostic is the load-bearing axis, the backtick
11491        // byte is the secondary observation. Same precedence logic
11492        // as every prior leading-byte arm.
11493        let d = dep_with_fonte(DepSource::Path {
11494            caminho: "/etc/passwd `whoami`".into(),
11495        });
11496        let err = d.validate().unwrap_err();
11497        assert!(
11498            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11499            "got {err:?}",
11500        );
11501    }
11502
11503    #[test]
11504    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11505        // Cascade pin on the immediate-successor arm: a value
11506        // carrying both a backtick and a trailing `/`
11507        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11508        // path that already had a backticked `whoami` substitution
11509        // tail" footgun) routes through
11510        // `FonteCaminhoShellCommandSubstitution` not
11511        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11512        // is the more semantic-locating axis (an author who removes
11513        // the backtick typically also drops the trailing separator
11514        // since both are paste-from-shell artifacts).
11515        let d = dep_with_fonte(DepSource::Path {
11516            caminho: "../`whoami`/".into(),
11517        });
11518        let err = d.validate().unwrap_err();
11519        assert!(
11520            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11521            "got {err:?}",
11522        );
11523    }
11524
11525    #[test]
11526    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11527        // Diagnostic-shape pin (peer with
11528        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11529        // on the closest single-byte peer arm): the error's Display
11530        // surfaces the offending `:nome` and the offending `:caminho`
11531        // verbatim, and names the shell-command-substitution footgun
11532        // explicitly so a `feira lint` run can render the diagnostic
11533        // without re-parsing.
11534        let d = dep_with_fonte(DepSource::Path {
11535            caminho: "../caixa-teia/`whoami`".into(),
11536        });
11537        let rendered = d.validate().unwrap_err().to_string();
11538        assert!(
11539            rendered.contains("caixa-teia"),
11540            "diagnostic must name the offending dep: {rendered}",
11541        );
11542        assert!(
11543            rendered.contains("../caixa-teia/`whoami`"),
11544            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11545        );
11546        assert!(
11547            rendered.contains('`'),
11548            "diagnostic must reference the backtick footgun: {rendered:?}",
11549        );
11550        assert!(
11551            rendered.contains("command-substitution"),
11552            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11553        );
11554    }
11555
11556    #[test]
11557    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11558        // The fail-before-pass-after pin for the canonical pathname-
11559        // expansion paste footgun: an author copies an `ls
11560        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11561        // slot and silently passes every prior arm
11562        // (`Path::is_absolute` false on `..`, no control bytes, no
11563        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11564        // doesn't end in `/`). The lacre embedded the value
11565        // verbatim, the resolver folded it through `Path::join`
11566        // looking for a literal `./../caixa-teia/*` subdirectory,
11567        // and the failure surfaced at resolve time with a non-self-
11568        // locating `No such file or directory` error. The new arm
11569        // moves the rejection to validate time and names the
11570        // offending dep + caminho + byte verbatim.
11571        let d = dep_with_fonte(DepSource::Path {
11572            caminho: "../caixa-teia/*".into(),
11573        });
11574        let err = d.validate().unwrap_err();
11575        let DepError::FonteCaminhoShellGlob {
11576            nome,
11577            caminho,
11578            byte,
11579        } = err
11580        else {
11581            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11582        };
11583        assert_eq!(nome, "caixa-teia");
11584        assert_eq!(caminho, "../caixa-teia/*");
11585        assert_eq!(byte, b'*');
11586    }
11587
11588    #[test]
11589    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11590        // The symmetric single-char-wildcard paste shape
11591        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11592        // out of shell history" idiom). Pinned separately from the
11593        // `*` shape so the gate's contract is "any `*` or `?`
11594        // anywhere", not single-byte coverage.
11595        let d = dep_with_fonte(DepSource::Path {
11596            caminho: "../foo?".into(),
11597        });
11598        let err = d.validate().unwrap_err();
11599        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11600            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11601        };
11602        assert_eq!(byte, b'?');
11603    }
11604
11605    #[test]
11606    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11607        // Leading-position `*` shape (`"*/caixa-teia"` — the
11608        // degenerate "I selected only the wildcard prefix out of a
11609        // shell-glob expression" idiom). Pinned separately from the
11610        // embedded-byte shapes so the gate covers every position,
11611        // not only mid-path.
11612        let d = dep_with_fonte(DepSource::Path {
11613            caminho: "*/caixa-teia".into(),
11614        });
11615        let err = d.validate().unwrap_err();
11616        assert!(
11617            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11618            "got {err:?}",
11619        );
11620    }
11621
11622    #[test]
11623    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11624        // The bash/zsh `globstar` recursive-glob shape
11625        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11626        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11627        // The arm fires on the first `*` encountered; pinned so a
11628        // future arm that tries to distinguish single `*` from
11629        // double `**` doesn't break the broader contract.
11630        let d = dep_with_fonte(DepSource::Path {
11631            caminho: "../caixa-teia/**/foo".into(),
11632        });
11633        let err = d.validate().unwrap_err();
11634        assert!(
11635            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11636            "got {err:?}",
11637        );
11638    }
11639
11640    #[test]
11641    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11642        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11643        // — the "I selected `*.lisp` to mean every Lisp source file
11644        // in the dep root" footgun the prior arms structurally
11645        // cannot catch since `.` is a POSIX-valid path-component
11646        // byte). Pinned so the gate's contract covers the most
11647        // idiomatic glob-paste shape every author meets first.
11648        let d = dep_with_fonte(DepSource::Path {
11649            caminho: "../caixa-teia/*.lisp".into(),
11650        });
11651        let err = d.validate().unwrap_err();
11652        assert!(
11653            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11654            "got {err:?}",
11655        );
11656    }
11657
11658    #[test]
11659    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11660        // The positive-control pin: the gate targets only `*` /
11661        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11662        // The canonical relative POSIX path (`"../caixa-teia"`) and
11663        // a nested deeply-pathed variant with adjacent printable
11664        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11665        // to validate cleanly so the gate doesn't widen to a "no
11666        // printable punctuation anywhere" sweep that would defeat
11667        // the entire path-fonte author surface.
11668        let d = dep_with_fonte(DepSource::Path {
11669            caminho: "../caixa-teia/sub-dir.v2".into(),
11670        });
11671        d.validate().unwrap();
11672    }
11673
11674    #[test]
11675    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11676        // Cascade pin on the immediate-predecessor arm: a value
11677        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11678        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11679        // command-substitution + glob chain") routes through
11680        // `FonteCaminhoShellCommandSubstitution` not
11681        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11682        // injection vector is the load-bearing root-cause edit on
11683        // every probe-as-both value — same cascade discipline every
11684        // prior `:caminho` arm establishes.
11685        let d = dep_with_fonte(DepSource::Path {
11686            caminho: "../`whoami`/*".into(),
11687        });
11688        let err = d.validate().unwrap_err();
11689        assert!(
11690            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11691            "got {err:?}",
11692        );
11693    }
11694
11695    #[test]
11696    fn fonte_caminho_shell_background_fires_before_shell_glob() {
11697        // Cascade pin on the upstream shell-background arm: a value
11698        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11699        // canonical "I pasted a `cmd & ls /*` background + glob
11700        // chain" footgun) routes through `FonteCaminhoShellBackground`
11701        // not `FonteCaminhoShellGlob`. The background-launch tail is
11702        // the load-bearing root-cause edit on every probe-as-both
11703        // value.
11704        let d = dep_with_fonte(DepSource::Path {
11705            caminho: "../caixa-teia & ls /*".into(),
11706        });
11707        let err = d.validate().unwrap_err();
11708        assert!(
11709            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11710            "got {err:?}",
11711        );
11712    }
11713
11714    #[test]
11715    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11716        // Cascade pin on the upstream shell-semicolon arm: a value
11717        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11718        // canonical sequential-cleanup + glob paste idiom) routes
11719        // through `FonteCaminhoShellSemicolon` not
11720        // `FonteCaminhoShellGlob`. The sequential-command-separator
11721        // paste is the load-bearing root-cause edit on every
11722        // probe-as-both value.
11723        let d = dep_with_fonte(DepSource::Path {
11724            caminho: "../caixa-teia; rm *".into(),
11725        });
11726        let err = d.validate().unwrap_err();
11727        assert!(
11728            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11729            "got {err:?}",
11730        );
11731    }
11732
11733    #[test]
11734    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11735        // Cascade pin on the upstream shell-pipe arm: a value
11736        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11737        // canonical pipeline-to-glob paste idiom) routes through
11738        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11739        // pipeline-tail paste is the load-bearing root-cause edit
11740        // on every probe-as-both value.
11741        let d = dep_with_fonte(DepSource::Path {
11742            caminho: "../caixa-teia | ls *".into(),
11743        });
11744        let err = d.validate().unwrap_err();
11745        assert!(
11746            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11747            "got {err:?}",
11748        );
11749    }
11750
11751    #[test]
11752    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11753        // Cascade pin on the upstream shell-redirection arm: a value
11754        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11755        // canonical "I pasted a `cmd > log *` redirect-plus-glob
11756        // chain" footgun) routes through
11757        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11758        // The input/output redirection metachar carries the more
11759        // self-locating `byte` payload (it names which of `<` or `>`
11760        // triggered), so the prior arm wins on every probe-as-both
11761        // value.
11762        let d = dep_with_fonte(DepSource::Path {
11763            caminho: "../caixa-teia>log *".into(),
11764        });
11765        let err = d.validate().unwrap_err();
11766        assert!(
11767            matches!(
11768                err,
11769                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11770            ),
11771            "got {err:?}",
11772        );
11773    }
11774
11775    #[test]
11776    fn fonte_caminho_backslash_fires_before_shell_glob() {
11777        // Cascade pin on the upstream backslash arm: a value
11778        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11779        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11780        // expression" footgun) routes through
11781        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11782        // cross-host-OS-separator divergence is the load-bearing
11783        // axis on every probe-as-both value (an author who removes
11784        // the `\` is the root-cause edit; the `*` falls away in the
11785        // same edit since it's downstream of the Windows-shell
11786        // convention).
11787        let d = dep_with_fonte(DepSource::Path {
11788            caminho: "..\\caixa-teia\\*".into(),
11789        });
11790        let err = d.validate().unwrap_err();
11791        assert!(
11792            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11793            "got {err:?}",
11794        );
11795    }
11796
11797    #[test]
11798    fn fonte_caminho_control_char_fires_before_shell_glob() {
11799        // Cascade pin on the embedded-control-byte arm: a value
11800        // carrying both a control byte and `*` (`"../foo\n*"` — the
11801        // canonical paste-from-multiline-doc footgun where a
11802        // newline landed mid-caminho between two paste fragments)
11803        // routes through `FonteCaminhoControlChar` not
11804        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11805        // NUL-`CString::new`-fail diagnostic is the load-bearing
11806        // axis on every value that probes positive for both —
11807        // mirrors the cascade discipline on every prior arm.
11808        let d = dep_with_fonte(DepSource::Path {
11809            caminho: "../foo\n*".into(),
11810        });
11811        let err = d.validate().unwrap_err();
11812        assert!(
11813            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11814            "got {err:?}",
11815        );
11816    }
11817
11818    #[test]
11819    fn fonte_caminho_absolute_fires_before_shell_glob() {
11820        // Cascade pin on the load-bearing leading-byte arm: a
11821        // leading `/` value with embedded `*` (`"/etc/*"`) routes
11822        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11823        // — the host-layout-leak diagnostic is the load-bearing
11824        // axis, the glob byte is the secondary observation. Same
11825        // precedence logic as every prior leading-byte arm.
11826        let d = dep_with_fonte(DepSource::Path {
11827            caminho: "/etc/*".into(),
11828        });
11829        let err = d.validate().unwrap_err();
11830        assert!(
11831            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11832            "got {err:?}",
11833        );
11834    }
11835
11836    #[test]
11837    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11838        // Cascade pin on the immediate-successor arm: a value
11839        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11840        // canonical "I tab-completed a path that already had a
11841        // glob-expansion tail" footgun) routes through
11842        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11843        // The embedded shell-metachar is the more semantic-locating
11844        // axis (an author who removes the `*` typically also drops
11845        // the trailing separator since both are paste-from-shell
11846        // artifacts).
11847        let d = dep_with_fonte(DepSource::Path {
11848            caminho: "../foo*/".into(),
11849        });
11850        let err = d.validate().unwrap_err();
11851        assert!(
11852            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11853            "got {err:?}",
11854        );
11855    }
11856
11857    #[test]
11858    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11859        // Diagnostic-shape pin (peer with
11860        // `fonte_caminho_shell_redirection_diagnostic_*` on the
11861        // closest two-byte peer arm): the error's Display surfaces
11862        // the offending `:nome`, the offending `:caminho` verbatim,
11863        // the offending byte's hex / character form, and names the
11864        // shell-glob / pathname-expansion footgun explicitly so a
11865        // `feira lint` run can render the diagnostic without
11866        // re-parsing.
11867        let d = dep_with_fonte(DepSource::Path {
11868            caminho: "../caixa-teia/*.lisp".into(),
11869        });
11870        let rendered = d.validate().unwrap_err().to_string();
11871        assert!(
11872            rendered.contains("caixa-teia"),
11873            "diagnostic must name the offending dep: {rendered}",
11874        );
11875        assert!(
11876            rendered.contains("../caixa-teia/*.lisp"),
11877            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11878        );
11879        assert!(
11880            rendered.contains("0x2a"),
11881            "diagnostic must surface the offending byte hex: {rendered:?}",
11882        );
11883        assert!(
11884            rendered.contains("glob"),
11885            "diagnostic must name the shell-glob footgun: {rendered:?}",
11886        );
11887        assert!(
11888            rendered.contains("pathname-expansion"),
11889            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11890        );
11891    }
11892
11893    #[test]
11894    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11895        // The fail-before-pass-after pin for the canonical modern-Bourne
11896        // command-substitution paste footgun: an author copies a
11897        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11898        // `$(<cmd>)` expansion would land the current date as a
11899        // subdirectory name and silently passed every prior arm
11900        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11901        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11902        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11903        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11904        // sits mid-path). The lacre embedded the value verbatim, the
11905        // resolver folded it through `Path::join` looking for a literal
11906        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11907        // surfaced at resolve time with a non-self-locating `No such
11908        // file or directory` error. The new arm moves the rejection to
11909        // validate time and names the offending dep + caminho + byte
11910        // verbatim. The arm fires on the first `(` encountered (the
11911        // opening byte of `$(date)`).
11912        let d = dep_with_fonte(DepSource::Path {
11913            caminho: "../caixa-teia/$(date)/build".into(),
11914        });
11915        let err = d.validate().unwrap_err();
11916        let DepError::FonteCaminhoShellSubshellGrouping {
11917            nome,
11918            caminho,
11919            byte,
11920        } = err
11921        else {
11922            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11923        };
11924        assert_eq!(nome, "caixa-teia");
11925        assert_eq!(caminho, "../caixa-teia/$(date)/build");
11926        assert_eq!(byte, b'(');
11927    }
11928
11929    #[test]
11930    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11931        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11932        // the degenerate "I selected an unbalanced closing paren out of
11933        // a shell-history block" idiom that probes for the cascade's
11934        // last-byte handling on a value carrying only the closing byte).
11935        // Pinned separately from the open-paren shape so the gate's
11936        // contract is "any `(` or `)` anywhere", not single-byte
11937        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11938        // caminho_carrying_question_glob` shape on the immediate-
11939        // predecessor `FonteCaminhoShellGlob` arm.
11940        let d = dep_with_fonte(DepSource::Path {
11941            caminho: "../caixa-teia)".into(),
11942        });
11943        let err = d.validate().unwrap_err();
11944        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11945            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11946        };
11947        assert_eq!(byte, b')');
11948    }
11949
11950    #[test]
11951    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11952        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11953        // canonical "I selected a `(cd foo)` subshell-grouping prefix
11954        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11955        // Pinned separately from the embedded-byte shape so the gate
11956        // covers every position, not only mid-path.
11957        let d = dep_with_fonte(DepSource::Path {
11958            caminho: "(cd foo)/caixa-teia".into(),
11959        });
11960        let err = d.validate().unwrap_err();
11961        assert!(
11962            matches!(
11963                err,
11964                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11965            ),
11966            "got {err:?}",
11967        );
11968    }
11969
11970    #[test]
11971    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11972        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11973        // — the canonical "I copied a `(pwd)` working-directory-probe
11974        // subshell-grouping idiom every shell-history block carries"
11975        // footgun). The value carries no other cascade-preceding
11976        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11977        // `*` / `?`) so the arm fires on the first `(` encountered;
11978        // pinned so a future arm that tries to distinguish the
11979        // opening from the closing byte doesn't break the broader
11980        // contract. Mirrors the peer
11981        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11982        // backtick_pair` shape on the upstream `FonteCaminhoShell\
11983        // CommandSubstitution` arm.
11984        let d = dep_with_fonte(DepSource::Path {
11985            caminho: "../(pwd)/caixa-teia".into(),
11986        });
11987        let err = d.validate().unwrap_err();
11988        assert!(
11989            matches!(
11990                err,
11991                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11992            ),
11993            "got {err:?}",
11994        );
11995    }
11996
11997    #[test]
11998    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11999        // The positive-control pin: the gate targets only `(` / `)`,
12000        // never adjacent printable ASCII or POSIX-valid bytes. The
12001        // canonical relative POSIX path (`"../caixa-teia"`) and a
12002        // nested deeply-pathed variant with adjacent printable
12003        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12004        // validate cleanly so the gate doesn't widen to a "no printable
12005        // punctuation anywhere" sweep that would defeat the entire
12006        // path-fonte author surface.
12007        let d = dep_with_fonte(DepSource::Path {
12008            caminho: "../caixa-teia/sub-dir.v2".into(),
12009        });
12010        d.validate().unwrap();
12011    }
12012
12013    #[test]
12014    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12015        // Cascade pin on the immediate-predecessor arm: a value
12016        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12017        // canonical "I pasted a glob expansion followed by a
12018        // subshell-grouping tail" footgun) routes through
12019        // `FonteCaminhoShellGlob` not
12020        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12021        // shape is the more common shell-history paste idiom on every
12022        // probe-as-both value — same cascade discipline every prior
12023        // `:caminho` arm establishes.
12024        let d = dep_with_fonte(DepSource::Path {
12025            caminho: "../caixa-teia/*(date)".into(),
12026        });
12027        let err = d.validate().unwrap_err();
12028        assert!(
12029            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12030            "got {err:?}",
12031        );
12032    }
12033
12034    #[test]
12035    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12036        // Cascade pin on the upstream shell-command-substitution arm: a
12037        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12038        // — the canonical "I pasted a legacy-backtick + modern-paren
12039        // command-substitution chain" footgun) routes through
12040        // `FonteCaminhoShellCommandSubstitution` not
12041        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12042        // command-injection vector is the load-bearing root-cause edit
12043        // on every probe-as-both value.
12044        let d = dep_with_fonte(DepSource::Path {
12045            caminho: "../`whoami`/$(date)".into(),
12046        });
12047        let err = d.validate().unwrap_err();
12048        assert!(
12049            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12050            "got {err:?}",
12051        );
12052    }
12053
12054    #[test]
12055    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12056        // Cascade pin on the upstream shell-background arm: a value
12057        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12058        // the canonical "I pasted a `cmd & (cd foo)` background-launch
12059        // + subshell-grouping chain" footgun) routes through
12060        // `FonteCaminhoShellBackground` not
12061        // `FonteCaminhoShellSubshellGrouping`. The background-launch
12062        // tail is the load-bearing root-cause edit on every probe-as-
12063        // both value.
12064        let d = dep_with_fonte(DepSource::Path {
12065            caminho: "../caixa-teia & (cd foo)".into(),
12066        });
12067        let err = d.validate().unwrap_err();
12068        assert!(
12069            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12070            "got {err:?}",
12071        );
12072    }
12073
12074    #[test]
12075    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12076        // Cascade pin on the upstream shell-semicolon arm: a value
12077        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12078        // the canonical sequential-cleanup + subshell-grouping paste
12079        // idiom) routes through `FonteCaminhoShellSemicolon` not
12080        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12081        // separator paste is the load-bearing root-cause edit on
12082        // every probe-as-both value.
12083        let d = dep_with_fonte(DepSource::Path {
12084            caminho: "../caixa-teia; (cd foo)".into(),
12085        });
12086        let err = d.validate().unwrap_err();
12087        assert!(
12088            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12089            "got {err:?}",
12090        );
12091    }
12092
12093    #[test]
12094    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12095        // Cascade pin on the upstream shell-pipe arm: a value carrying
12096        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12097        // canonical pipeline-to-subshell-grouping paste idiom) routes
12098        // through `FonteCaminhoShellPipe` not
12099        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12100        // is the load-bearing root-cause edit on every probe-as-both
12101        // value.
12102        let d = dep_with_fonte(DepSource::Path {
12103            caminho: "../caixa-teia | (tee log)".into(),
12104        });
12105        let err = d.validate().unwrap_err();
12106        assert!(
12107            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12108            "got {err:?}",
12109        );
12110    }
12111
12112    #[test]
12113    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12114        // Cascade pin on the upstream shell-redirection arm: a value
12115        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12116        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12117        // plus-subshell-grouping chain" footgun) routes through
12118        // `FonteCaminhoShellRedirection` not
12119        // `FonteCaminhoShellSubshellGrouping`. The input/output
12120        // redirection metachar carries the more self-locating `byte`
12121        // payload (it names which of `<` or `>` triggered), so the
12122        // prior arm wins on every probe-as-both value.
12123        let d = dep_with_fonte(DepSource::Path {
12124            caminho: "../caixa-teia>log (cd foo)".into(),
12125        });
12126        let err = d.validate().unwrap_err();
12127        assert!(
12128            matches!(
12129                err,
12130                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12131            ),
12132            "got {err:?}",
12133        );
12134    }
12135
12136    #[test]
12137    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12138        // Cascade pin on the upstream backslash arm: a value carrying
12139        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12140        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12141        // through `FonteCaminhoBackslash` not
12142        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12143        // separator divergence is the load-bearing axis on every
12144        // probe-as-both value (an author who removes the `\` is the
12145        // root-cause edit; the `(` falls away in the same edit since
12146        // it's downstream of the Windows-shell convention).
12147        let d = dep_with_fonte(DepSource::Path {
12148            caminho: "..\\caixa-teia\\(cd foo)".into(),
12149        });
12150        let err = d.validate().unwrap_err();
12151        assert!(
12152            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12153            "got {err:?}",
12154        );
12155    }
12156
12157    #[test]
12158    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12159        // Cascade pin on the embedded-control-byte arm: a value
12160        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12161        // the canonical paste-from-multiline-doc footgun where a
12162        // newline landed mid-caminho between two paste fragments)
12163        // routes through `FonteCaminhoControlChar` not
12164        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12165        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12166        // load-bearing axis on every value that probes positive for
12167        // both — mirrors the cascade discipline on every prior arm.
12168        let d = dep_with_fonte(DepSource::Path {
12169            caminho: "../foo\n(cd bar)".into(),
12170        });
12171        let err = d.validate().unwrap_err();
12172        assert!(
12173            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12174            "got {err:?}",
12175        );
12176    }
12177
12178    #[test]
12179    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12180        // Cascade pin on the load-bearing leading-byte arm: a leading
12181        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12182        // through `FonteCaminhoAbsolute` not
12183        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12184        // diagnostic is the load-bearing axis, the subshell-grouping
12185        // byte is the secondary observation. Same precedence logic as
12186        // every prior leading-byte arm.
12187        let d = dep_with_fonte(DepSource::Path {
12188            caminho: "/etc/(cd foo)".into(),
12189        });
12190        let err = d.validate().unwrap_err();
12191        assert!(
12192            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12193            "got {err:?}",
12194        );
12195    }
12196
12197    #[test]
12198    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12199        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12200        // value carrying both a leading `$` and a `(` (`"$(date)/\
12201        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12202        // command-substitution at the head of a sibling-workspace
12203        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12204        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12205        // shell-variable-expansion is the more self-locating diagnostic
12206        // on values that probe as both — same load-bearing-leading-
12207        // byte cascade discipline every prior `:caminho` arm
12208        // establishes. Closing both halves of `$(<cmd>)` structurally
12209        // (leading `$` here, trailing `)` on the new arm) excludes the
12210        // entire modern Bourne command-substitution surface from the
12211        // typed `:caminho` accepted set; the cascade preserves the
12212        // narrower leading-byte diagnostic on values that probe both
12213        // halves at the canonical leading position.
12214        let d = dep_with_fonte(DepSource::Path {
12215            caminho: "$(date)/caixa-teia".into(),
12216        });
12217        let err = d.validate().unwrap_err();
12218        assert!(
12219            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12220            "got {err:?}",
12221        );
12222    }
12223
12224    #[test]
12225    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12226        // Cascade pin on the immediate-successor arm: a value carrying
12227        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12228        // "I tab-completed a path that already had a subshell-grouping
12229        // expansion tail" footgun) routes through
12230        // `FonteCaminhoShellSubshellGrouping` not
12231        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12232        // the more semantic-locating axis (an author who removes the
12233        // `(` typically also drops the trailing separator since both
12234        // are paste-from-shell artifacts).
12235        let d = dep_with_fonte(DepSource::Path {
12236            caminho: "../(cd foo)/".into(),
12237        });
12238        let err = d.validate().unwrap_err();
12239        assert!(
12240            matches!(
12241                err,
12242                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12243            ),
12244            "got {err:?}",
12245        );
12246    }
12247
12248    #[test]
12249    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12250        // Diagnostic-shape pin (peer with
12251        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12252        // on the closest two-byte peer arm): the error's Display
12253        // surfaces the offending `:nome`, the offending `:caminho`
12254        // verbatim, the offending byte's hex / character form, and
12255        // names the shell-subshell-grouping footgun explicitly so a
12256        // `feira lint` run can render the diagnostic without re-
12257        // parsing.
12258        let d = dep_with_fonte(DepSource::Path {
12259            caminho: "../caixa-teia/$(date)/build".into(),
12260        });
12261        let rendered = d.validate().unwrap_err().to_string();
12262        assert!(
12263            rendered.contains("caixa-teia"),
12264            "diagnostic must name the offending dep: {rendered}",
12265        );
12266        assert!(
12267            rendered.contains("../caixa-teia/$(date)/build"),
12268            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12269        );
12270        assert!(
12271            rendered.contains("0x28"),
12272            "diagnostic must surface the offending byte hex: {rendered:?}",
12273        );
12274        assert!(
12275            rendered.contains("subshell-grouping"),
12276            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12277        );
12278        assert!(
12279            rendered.contains("command-substitution"),
12280            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12281             {rendered:?}",
12282        );
12283    }
12284
12285    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12286    //
12287    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12288    // `)`) byte-pair arm: the same per-byte cascade with the same
12289    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12290    // `}` brace-expansion / URI-Template placeholder axis. The peer
12291    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12292    // byte pair on the sibling `:fonte :repo` axis under the same
12293    // banner.
12294
12295    #[test]
12296    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12297        // The fail-before-pass-after pin for the canonical paste-from-
12298        // shell-history brace-expansion footgun: an author copies a
12299        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12300        // liner whose `{a,b}` brace expansion fans across two siblings
12301        // and silently passed every prior arm (`Path::is_absolute`
12302        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12303        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12304        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12305        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12306        // value starts with `..` not `$`). The lacre embedded the
12307        // value verbatim, the resolver folded it through `Path::join`
12308        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12309        // subdirectory, and the failure surfaced at resolve time with
12310        // a non-self-locating `No such file or directory` error. The
12311        // new arm moves the rejection to validate time and names the
12312        // offending dep + caminho + byte verbatim. The arm fires on
12313        // the first `{` encountered.
12314        let d = dep_with_fonte(DepSource::Path {
12315            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12316        });
12317        let err = d.validate().unwrap_err();
12318        let DepError::FonteCaminhoShellBraceExpansion {
12319            nome,
12320            caminho,
12321            byte,
12322        } = err
12323        else {
12324            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12325        };
12326        assert_eq!(nome, "caixa-teia");
12327        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12328        assert_eq!(byte, b'{');
12329    }
12330
12331    #[test]
12332    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12333        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12334        // the degenerate "I selected an unbalanced closing brace out
12335        // of a shell-history block" idiom that probes for the
12336        // cascade's last-byte handling on a value carrying only the
12337        // closing byte). Pinned separately from the open-brace shape
12338        // so the gate's contract is "any `{` or `}` anywhere", not
12339        // single-byte coverage. Mirrors the peer
12340        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12341        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12342        // arm.
12343        let d = dep_with_fonte(DepSource::Path {
12344            caminho: "../caixa-teia}".into(),
12345        });
12346        let err = d.validate().unwrap_err();
12347        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12348            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12349        };
12350        assert_eq!(byte, b'}');
12351    }
12352
12353    #[test]
12354    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12355        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12356        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12357        // out of a shell-history one-liner" idiom). Pinned separately
12358        // from the embedded-byte shape so the gate covers every
12359        // position, not only mid-path.
12360        let d = dep_with_fonte(DepSource::Path {
12361            caminho: "{caixa-teia,caixa-helm}/build".into(),
12362        });
12363        let err = d.validate().unwrap_err();
12364        assert!(
12365            matches!(
12366                err,
12367                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12368            ),
12369            "got {err:?}",
12370        );
12371    }
12372
12373    #[test]
12374    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12375        // The canonical URI-Template / Mustache / Helm doubled-brace
12376        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12377        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12378        // quick-start / OpenAPI spec / Helm chart `home:` template
12379        // and forgot to substitute the placeholder" footgun). The arm
12380        // fires on the first `{` encountered; pinned so the gate's
12381        // coverage extends from the bare-brace shell-history shape to
12382        // the doubled-brace URI-Template / templating-engine shape.
12383        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12384        // sibling `:fonte :repo` axis.
12385        let d = dep_with_fonte(DepSource::Path {
12386            caminho: "../{{org}}/caixa-teia".into(),
12387        });
12388        let err = d.validate().unwrap_err();
12389        assert!(
12390            matches!(
12391                err,
12392                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12393            ),
12394            "got {err:?}",
12395        );
12396    }
12397
12398    #[test]
12399    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12400        // The canonical bash brace-range-expansion shape (`"../caixa-
12401        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12402        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12403        // sequence-range form to the `{a,b,c}` comma-separated form).
12404        // The arm fires on the first `{` encountered; pinned so the
12405        // gate's coverage extends from the comma-separated form to
12406        // the integer-range form.
12407        let d = dep_with_fonte(DepSource::Path {
12408            caminho: "../caixa-v{1..10}".into(),
12409        });
12410        let err = d.validate().unwrap_err();
12411        assert!(
12412            matches!(
12413                err,
12414                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12415            ),
12416            "got {err:?}",
12417        );
12418    }
12419
12420    #[test]
12421    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12422        // The positive-control pin: the gate targets only `{` / `}`,
12423        // never adjacent printable ASCII or POSIX-valid bytes. The
12424        // canonical relative POSIX path (`"../caixa-teia"`) and a
12425        // nested deeply-pathed variant with adjacent printable
12426        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12427        // validate cleanly so the gate doesn't widen to a "no
12428        // printable punctuation anywhere" sweep that would defeat
12429        // the entire path-fonte author surface. Peer with
12430        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12431        // on the immediate-predecessor arm.
12432        let d = dep_with_fonte(DepSource::Path {
12433            caminho: "../caixa-teia/sub-dir.v2".into(),
12434        });
12435        d.validate().unwrap();
12436    }
12437
12438    #[test]
12439    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12440        // Cascade pin on the immediate-predecessor arm: a value
12441        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12442        // canonical "I pasted a subshell-grouping followed by a
12443        // brace-expansion tail" footgun) routes through
12444        // `FonteCaminhoShellSubshellGrouping` not
12445        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12446        // shape is the more semantic-locating axis on every probe-
12447        // as-both value because it closes both halves of the modern
12448        // Bourne `$(<cmd>)` command-substitution surface — same
12449        // cascade discipline every prior `:caminho` arm establishes.
12450        let d = dep_with_fonte(DepSource::Path {
12451            caminho: "../(cd foo)/{a,b}".into(),
12452        });
12453        let err = d.validate().unwrap_err();
12454        assert!(
12455            matches!(
12456                err,
12457                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12458            ),
12459            "got {err:?}",
12460        );
12461    }
12462
12463    #[test]
12464    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12465        // Cascade pin on the upstream shell-glob arm: a value carrying
12466        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12467        // "I pasted a glob expansion followed by a brace-expansion
12468        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12469        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12470        // shape is the load-bearing root-cause edit on every
12471        // probe-as-both value.
12472        let d = dep_with_fonte(DepSource::Path {
12473            caminho: "../caixa-teia/*{a,b}".into(),
12474        });
12475        let err = d.validate().unwrap_err();
12476        assert!(
12477            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12478            "got {err:?}",
12479        );
12480    }
12481
12482    #[test]
12483    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12484        // Cascade pin on the upstream shell-command-substitution arm:
12485        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12486        // — the canonical "I pasted a legacy-backtick command-
12487        // substitution followed by a brace-expansion fan-out" footgun)
12488        // routes through `FonteCaminhoShellCommandSubstitution` not
12489        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12490        // command-injection vector is the load-bearing root-cause
12491        // edit on every probe-as-both value.
12492        let d = dep_with_fonte(DepSource::Path {
12493            caminho: "../`whoami`/{a,b}".into(),
12494        });
12495        let err = d.validate().unwrap_err();
12496        assert!(
12497            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12498            "got {err:?}",
12499        );
12500    }
12501
12502    #[test]
12503    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12504        // Cascade pin on the upstream shell-background arm: a value
12505        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12506        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12507        // + brace-expansion chain" footgun) routes through
12508        // `FonteCaminhoShellBackground` not
12509        // `FonteCaminhoShellBraceExpansion`. The background-launch
12510        // tail is the load-bearing root-cause edit on every
12511        // probe-as-both value.
12512        let d = dep_with_fonte(DepSource::Path {
12513            caminho: "../caixa-teia & {a,b}".into(),
12514        });
12515        let err = d.validate().unwrap_err();
12516        assert!(
12517            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12518            "got {err:?}",
12519        );
12520    }
12521
12522    #[test]
12523    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12524        // Cascade pin on the upstream shell-semicolon arm: a value
12525        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12526        // canonical sequential-cleanup + brace-expansion paste
12527        // idiom) routes through `FonteCaminhoShellSemicolon` not
12528        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12529        // separator paste is the load-bearing root-cause edit on
12530        // every probe-as-both value.
12531        let d = dep_with_fonte(DepSource::Path {
12532            caminho: "../caixa-teia; {a,b}".into(),
12533        });
12534        let err = d.validate().unwrap_err();
12535        assert!(
12536            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12537            "got {err:?}",
12538        );
12539    }
12540
12541    #[test]
12542    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12543        // Cascade pin on the upstream shell-pipe arm: a value
12544        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12545        // — the canonical pipeline-to-brace-expansion paste idiom)
12546        // routes through `FonteCaminhoShellPipe` not
12547        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12548        // is the load-bearing root-cause edit on every probe-as-
12549        // both value.
12550        let d = dep_with_fonte(DepSource::Path {
12551            caminho: "../caixa-teia | {tee,cat}".into(),
12552        });
12553        let err = d.validate().unwrap_err();
12554        assert!(
12555            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12556            "got {err:?}",
12557        );
12558    }
12559
12560    #[test]
12561    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12562        // Cascade pin on the upstream shell-redirection arm: a value
12563        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12564        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12565        // plus-brace-expansion chain" footgun) routes through
12566        // `FonteCaminhoShellRedirection` not
12567        // `FonteCaminhoShellBraceExpansion`. The input/output
12568        // redirection metachar carries the more self-locating
12569        // `byte` payload, so the prior arm wins on every probe-
12570        // as-both value.
12571        let d = dep_with_fonte(DepSource::Path {
12572            caminho: "../caixa-teia>log {a,b}".into(),
12573        });
12574        let err = d.validate().unwrap_err();
12575        assert!(
12576            matches!(
12577                err,
12578                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12579            ),
12580            "got {err:?}",
12581        );
12582    }
12583
12584    #[test]
12585    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12586        // Cascade pin on the upstream backslash arm: a value
12587        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12588        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12589        // chain") routes through `FonteCaminhoBackslash` not
12590        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12591        // separator divergence is the load-bearing axis on every
12592        // probe-as-both value.
12593        let d = dep_with_fonte(DepSource::Path {
12594            caminho: "..\\caixa-teia\\{a,b}".into(),
12595        });
12596        let err = d.validate().unwrap_err();
12597        assert!(
12598            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12599            "got {err:?}",
12600        );
12601    }
12602
12603    #[test]
12604    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12605        // Cascade pin on the embedded-control-byte arm: a value
12606        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12607        // the canonical paste-from-multiline-doc footgun where a
12608        // newline landed mid-caminho between two paste fragments)
12609        // routes through `FonteCaminhoControlChar` not
12610        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12611        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12612        // load-bearing axis on every value that probes positive for
12613        // both — mirrors the cascade discipline on every prior arm.
12614        let d = dep_with_fonte(DepSource::Path {
12615            caminho: "../foo\n{a,b}".into(),
12616        });
12617        let err = d.validate().unwrap_err();
12618        assert!(
12619            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12620            "got {err:?}",
12621        );
12622    }
12623
12624    #[test]
12625    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12626        // Cascade pin on the load-bearing leading-byte arm: a
12627        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12628        // routes through `FonteCaminhoAbsolute` not
12629        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12630        // diagnostic is the load-bearing axis, the brace-expansion
12631        // byte is the secondary observation. Same precedence logic
12632        // as every prior leading-byte arm.
12633        let d = dep_with_fonte(DepSource::Path {
12634            caminho: "/etc/{a,b}".into(),
12635        });
12636        let err = d.validate().unwrap_err();
12637        assert!(
12638            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12639            "got {err:?}",
12640        );
12641    }
12642
12643    #[test]
12644    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12645        // Cascade pin on the upstream leading-`$` var-expansion
12646        // arm: a value carrying both a leading `$` and a `{`
12647        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12648        // `${ORG}` shell-variable + curly-brace expansion at the
12649        // head of a sibling-workspace path" footgun) routes through
12650        // `FonteCaminhoVarExpansion` not
12651        // `FonteCaminhoShellBraceExpansion`. The leading-byte
12652        // shell-variable-expansion is the more self-locating
12653        // diagnostic on values that probe as both — same
12654        // load-bearing-leading-byte cascade discipline every prior
12655        // `:caminho` arm establishes.
12656        let d = dep_with_fonte(DepSource::Path {
12657            caminho: "${ORG}/caixa-teia".into(),
12658        });
12659        let err = d.validate().unwrap_err();
12660        assert!(
12661            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12662            "got {err:?}",
12663        );
12664    }
12665
12666    #[test]
12667    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12668        // Cascade pin on the immediate-successor arm: a value
12669        // carrying both `{` and a trailing `/`
12670        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12671        // tab-completed a path that already had a brace-expansion
12672        // expansion tail" footgun) routes through
12673        // `FonteCaminhoShellBraceExpansion` not
12674        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12675        // is the more semantic-locating axis (an author who removes
12676        // the `{` typically also drops the trailing separator since
12677        // both are paste-from-shell artifacts).
12678        let d = dep_with_fonte(DepSource::Path {
12679            caminho: "../{caixa-teia,caixa-helm}/".into(),
12680        });
12681        let err = d.validate().unwrap_err();
12682        assert!(
12683            matches!(
12684                err,
12685                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12686            ),
12687            "got {err:?}",
12688        );
12689    }
12690
12691    #[test]
12692    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12693        // Diagnostic-shape pin (peer with
12694        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12695        // on the closest two-byte peer arm): the error's Display
12696        // surfaces the offending `:nome`, the offending `:caminho`
12697        // verbatim, the offending byte's hex / character form, and
12698        // names the shell-brace-expansion / URI-Template footgun
12699        // explicitly so a `feira lint` run can render the diagnostic
12700        // without re-parsing.
12701        let d = dep_with_fonte(DepSource::Path {
12702            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12703        });
12704        let rendered = d.validate().unwrap_err().to_string();
12705        assert!(
12706            rendered.contains("caixa-teia"),
12707            "diagnostic must name the offending dep: {rendered}",
12708        );
12709        assert!(
12710            rendered.contains("../{caixa-teia,caixa-helm}/build"),
12711            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12712        );
12713        assert!(
12714            rendered.contains("0x7b"),
12715            "diagnostic must surface the offending byte hex: {rendered:?}",
12716        );
12717        assert!(
12718            rendered.contains("brace-expansion"),
12719            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12720        );
12721        assert!(
12722            rendered.contains("URI Template"),
12723            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12724             {rendered:?}",
12725        );
12726    }
12727
12728    #[test]
12729    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12730        // The canonical paste-from-shell-history bracket-glob /
12731        // character-class footgun: an author copies a
12732        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12733        // `[a-z]` POSIX glob character-class matches every lowercase-
12734        // ASCII-suffix sibling caixa directory and silently passed
12735        // every prior arm (`Path::is_absolute` false on `..`, no
12736        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12737        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12738        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12739        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12740        // value starts with `..` not `$`). The lacre embedded the
12741        // value verbatim, the resolver folded it through
12742        // `Path::join` looking for a literal `./../caixa-[a-z]/
12743        // build` subdirectory, and the failure surfaced at resolve
12744        // time with a non-self-locating `No such file or directory`
12745        // error. The new arm moves the rejection to validate time
12746        // and names the offending dep + caminho + byte verbatim.
12747        // The arm fires on the first `[` encountered.
12748        let d = dep_with_fonte(DepSource::Path {
12749            caminho: "../caixa-[a-z]/build".into(),
12750        });
12751        let err = d.validate().unwrap_err();
12752        let DepError::FonteCaminhoShellBracketExpansion {
12753            nome,
12754            caminho,
12755            byte,
12756        } = err
12757        else {
12758            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12759        };
12760        assert_eq!(nome, "caixa-teia");
12761        assert_eq!(caminho, "../caixa-[a-z]/build");
12762        assert_eq!(byte, b'[');
12763    }
12764
12765    #[test]
12766    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12767        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12768        // — the degenerate "I selected an unbalanced closing bracket
12769        // out of a glob character-class block" idiom that probes for
12770        // the cascade's last-byte handling on a value carrying only
12771        // the closing byte). Pinned separately from the open-bracket
12772        // shape so the gate's contract is "any `[` or `]` anywhere",
12773        // not single-byte coverage. Mirrors the peer
12774        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12775        // shape on the immediate-predecessor
12776        // `FonteCaminhoShellBraceExpansion` arm.
12777        let d = dep_with_fonte(DepSource::Path {
12778            caminho: "../caixa-teia]".into(),
12779        });
12780        let err = d.validate().unwrap_err();
12781        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12782            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12783        };
12784        assert_eq!(byte, b']');
12785    }
12786
12787    #[test]
12788    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12789        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12790        // canonical "I selected a `[caixa-teia]` TOML-table-header /
12791        // glob-character-class prefix out of an aligned config /
12792        // shell-history one-liner" idiom). Pinned separately from
12793        // the embedded-byte shape so the gate covers every position,
12794        // not only mid-path.
12795        let d = dep_with_fonte(DepSource::Path {
12796            caminho: "[caixa-teia]/build".into(),
12797        });
12798        let err = d.validate().unwrap_err();
12799        assert!(
12800            matches!(
12801                err,
12802                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12803            ),
12804            "got {err:?}",
12805        );
12806    }
12807
12808    #[test]
12809    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12810        // The canonical TOML inline-array / YAML flow-sequence
12811        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12812        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12813        // inline-array out of a sibling-Cargo manifest" cross-idiom
12814        // leak; the symmetric YAML flow-sequence form `paths: [/a,
12815        // /b]` paste-from-values.yaml shape carries the same
12816        // bracket pair). The arm fires on the first `[` encountered;
12817        // pinned so the gate's coverage extends from the bare-
12818        // bracket glob-character-class shape to the TOML / YAML /
12819        // JSON array-literal shape.
12820        let d = dep_with_fonte(DepSource::Path {
12821            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12822        });
12823        let err = d.validate().unwrap_err();
12824        assert!(
12825            matches!(
12826                err,
12827                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12828            ),
12829            "got {err:?}",
12830        );
12831    }
12832
12833    #[test]
12834    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12835        // The canonical POSIX `test` / `[` builtin command paste
12836        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12837        // script conditional every paste-from-shell-script idiom
12838        // carries; bash's `[[ <expr> ]]` extended-test grammar
12839        // would surface the same byte pair). The arm fires on the
12840        // first `[` encountered; pinned so the gate's coverage
12841        // extends from the embedded-glob-character-class shape to
12842        // the leading-`test`-builtin / extended-test form.
12843        let d = dep_with_fonte(DepSource::Path {
12844            caminho: "../[ -d caixa-teia ]".into(),
12845        });
12846        let err = d.validate().unwrap_err();
12847        assert!(
12848            matches!(
12849                err,
12850                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12851            ),
12852            "got {err:?}",
12853        );
12854    }
12855
12856    #[test]
12857    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12858        // The positive-control pin: the gate targets only `[` /
12859        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12860        // The canonical relative POSIX path (`"../caixa-teia"`) and
12861        // a nested deeply-pathed variant with adjacent printable
12862        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12863        // to validate cleanly so the gate doesn't widen to a "no
12864        // printable punctuation anywhere" sweep that would defeat
12865        // the entire path-fonte author surface. Peer with
12866        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12867        // on the immediate-predecessor arm.
12868        let d = dep_with_fonte(DepSource::Path {
12869            caminho: "../caixa-teia/sub-dir.v2".into(),
12870        });
12871        d.validate().unwrap();
12872    }
12873
12874    #[test]
12875    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12876        // Cascade pin on the immediate-predecessor arm: a value
12877        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12878        // canonical "I pasted a brace-expansion fan followed by a
12879        // glob-character-class tail" footgun) routes through
12880        // `FonteCaminhoShellBraceExpansion` not
12881        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12882        // fan is the load-bearing root-cause edit on every
12883        // probe-as-both value because the bracket-class tail
12884        // typically rides on a prior brace-expansion expansion;
12885        // same cascade discipline every prior `:caminho` arm
12886        // establishes.
12887        let d = dep_with_fonte(DepSource::Path {
12888            caminho: "../{a,b}[ch]".into(),
12889        });
12890        let err = d.validate().unwrap_err();
12891        assert!(
12892            matches!(
12893                err,
12894                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12895            ),
12896            "got {err:?}",
12897        );
12898    }
12899
12900    #[test]
12901    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12902        // Cascade pin on the upstream shell-subshell-grouping arm:
12903        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12904        // the canonical "I pasted a subshell-grouping followed by
12905        // a glob-character-class tail" footgun) routes through
12906        // `FonteCaminhoShellSubshellGrouping` not
12907        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12908        // `$(<cmd>)` command-substitution boundary is the load-
12909        // bearing axis on every probe-as-both value.
12910        let d = dep_with_fonte(DepSource::Path {
12911            caminho: "../(cd foo)/[ch]".into(),
12912        });
12913        let err = d.validate().unwrap_err();
12914        assert!(
12915            matches!(
12916                err,
12917                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12918            ),
12919            "got {err:?}",
12920        );
12921    }
12922
12923    #[test]
12924    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12925        // Cascade pin on the upstream shell-glob arm: a value
12926        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12927        // canonical "I pasted a `*.[ch]` C-source-file glob whose
12928        // unbounded `*` precedes the bracket character-class"
12929        // footgun) routes through `FonteCaminhoShellGlob` not
12930        // `FonteCaminhoShellBracketExpansion`. The unbounded
12931        // pathname-expansion sentinel is the load-bearing root-
12932        // cause edit on every probe-as-both value — the unbounded
12933        // `*` carries the more aggressive expansion vector than
12934        // the bounded `[ch]` class, so the prior arm wins.
12935        let d = dep_with_fonte(DepSource::Path {
12936            caminho: "../caixa-teia/*[ch]".into(),
12937        });
12938        let err = d.validate().unwrap_err();
12939        assert!(
12940            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12941            "got {err:?}",
12942        );
12943    }
12944
12945    #[test]
12946    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12947        // Cascade pin on the upstream shell-command-substitution
12948        // arm: a value carrying both a backtick and `[`
12949        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12950        // legacy-backtick command-substitution followed by a
12951        // glob-character-class tail" footgun) routes through
12952        // `FonteCaminhoShellCommandSubstitution` not
12953        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12954        // command-injection vector is the load-bearing root-cause
12955        // edit on every probe-as-both value.
12956        let d = dep_with_fonte(DepSource::Path {
12957            caminho: "../`whoami`/[ch]".into(),
12958        });
12959        let err = d.validate().unwrap_err();
12960        assert!(
12961            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12962            "got {err:?}",
12963        );
12964    }
12965
12966    #[test]
12967    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12968        // Cascade pin on the upstream shell-background arm: a
12969        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12970        // — the canonical "I pasted a `cmd & [glob]` background-
12971        // launch + bracket-class chain" footgun) routes through
12972        // `FonteCaminhoShellBackground` not
12973        // `FonteCaminhoShellBracketExpansion`. The background-
12974        // launch tail is the load-bearing root-cause edit on
12975        // every probe-as-both value.
12976        let d = dep_with_fonte(DepSource::Path {
12977            caminho: "../caixa-teia & [ch]".into(),
12978        });
12979        let err = d.validate().unwrap_err();
12980        assert!(
12981            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12982            "got {err:?}",
12983        );
12984    }
12985
12986    #[test]
12987    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12988        // Cascade pin on the upstream shell-semicolon arm: a value
12989        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12990        // canonical sequential-cleanup + bracket-class paste
12991        // idiom) routes through `FonteCaminhoShellSemicolon` not
12992        // `FonteCaminhoShellBracketExpansion`. The sequential-
12993        // command-separator paste is the load-bearing root-cause
12994        // edit on every probe-as-both value.
12995        let d = dep_with_fonte(DepSource::Path {
12996            caminho: "../caixa-teia; [ch]".into(),
12997        });
12998        let err = d.validate().unwrap_err();
12999        assert!(
13000            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13001            "got {err:?}",
13002        );
13003    }
13004
13005    #[test]
13006    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13007        // Cascade pin on the upstream shell-pipe arm: a value
13008        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13009        // the canonical pipeline-to-bracket-class paste idiom)
13010        // routes through `FonteCaminhoShellPipe` not
13011        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13012        // paste is the load-bearing root-cause edit on every
13013        // probe-as-both value.
13014        let d = dep_with_fonte(DepSource::Path {
13015            caminho: "../caixa-teia | [tee]".into(),
13016        });
13017        let err = d.validate().unwrap_err();
13018        assert!(
13019            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13020            "got {err:?}",
13021        );
13022    }
13023
13024    #[test]
13025    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13026        // Cascade pin on the upstream shell-redirection arm: a
13027        // value carrying both `>` and `[` (`"../caixa-teia>log
13028        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13029        // redirect-plus-bracket chain" footgun) routes through
13030        // `FonteCaminhoShellRedirection` not
13031        // `FonteCaminhoShellBracketExpansion`. The input/output
13032        // redirection metachar carries the more self-locating
13033        // `byte` payload, so the prior arm wins on every
13034        // probe-as-both value.
13035        let d = dep_with_fonte(DepSource::Path {
13036            caminho: "../caixa-teia>log [ch]".into(),
13037        });
13038        let err = d.validate().unwrap_err();
13039        assert!(
13040            matches!(
13041                err,
13042                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13043            ),
13044            "got {err:?}",
13045        );
13046    }
13047
13048    #[test]
13049    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13050        // Cascade pin on the upstream backslash arm: a value
13051        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13052        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13053        // chain") routes through `FonteCaminhoBackslash` not
13054        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13055        // separator divergence is the load-bearing axis on every
13056        // probe-as-both value.
13057        let d = dep_with_fonte(DepSource::Path {
13058            caminho: "..\\caixa-teia\\[ch]".into(),
13059        });
13060        let err = d.validate().unwrap_err();
13061        assert!(
13062            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13063            "got {err:?}",
13064        );
13065    }
13066
13067    #[test]
13068    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13069        // Cascade pin on the embedded-control-byte arm: a value
13070        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13071        // the canonical paste-from-multiline-doc footgun where a
13072        // newline landed mid-caminho between two paste fragments)
13073        // routes through `FonteCaminhoControlChar` not
13074        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13075        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13076        // the load-bearing axis on every value that probes
13077        // positive for both — mirrors the cascade discipline on
13078        // every prior arm.
13079        let d = dep_with_fonte(DepSource::Path {
13080            caminho: "../foo\n[ch]".into(),
13081        });
13082        let err = d.validate().unwrap_err();
13083        assert!(
13084            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13085            "got {err:?}",
13086        );
13087    }
13088
13089    #[test]
13090    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13091        // Cascade pin on the load-bearing leading-byte arm: a
13092        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13093        // routes through `FonteCaminhoAbsolute` not
13094        // `FonteCaminhoShellBracketExpansion` — the host-layout-
13095        // leak diagnostic is the load-bearing axis, the bracket-
13096        // expansion byte is the secondary observation. Same
13097        // precedence logic as every prior leading-byte arm.
13098        let d = dep_with_fonte(DepSource::Path {
13099            caminho: "/etc/[ch]".into(),
13100        });
13101        let err = d.validate().unwrap_err();
13102        assert!(
13103            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13104            "got {err:?}",
13105        );
13106    }
13107
13108    #[test]
13109    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13110        // Cascade pin on the upstream leading-`$` var-expansion
13111        // arm: a value carrying both a leading `$` and a `[`
13112        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13113        // variable + bracket-class at the head of a sibling-
13114        // workspace path" footgun) routes through
13115        // `FonteCaminhoVarExpansion` not
13116        // `FonteCaminhoShellBracketExpansion`. The leading-byte
13117        // shell-variable-expansion is the more self-locating
13118        // diagnostic on values that probe as both — same
13119        // load-bearing-leading-byte cascade discipline every
13120        // prior `:caminho` arm establishes.
13121        let d = dep_with_fonte(DepSource::Path {
13122            caminho: "$DIR/[ch]".into(),
13123        });
13124        let err = d.validate().unwrap_err();
13125        assert!(
13126            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13127            "got {err:?}",
13128        );
13129    }
13130
13131    #[test]
13132    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13133        // Cascade pin on the immediate-successor arm: a value
13134        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13135        // the canonical "I tab-completed a path that already had
13136        // a bracket-glob-character-class expansion tail" footgun)
13137        // routes through `FonteCaminhoShellBracketExpansion` not
13138        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13139        // is the more semantic-locating axis (an author who
13140        // removes the `[` typically also drops the trailing
13141        // separator since both are paste-from-shell artifacts).
13142        let d = dep_with_fonte(DepSource::Path {
13143            caminho: "../[a-z]/".into(),
13144        });
13145        let err = d.validate().unwrap_err();
13146        assert!(
13147            matches!(
13148                err,
13149                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13150            ),
13151            "got {err:?}",
13152        );
13153    }
13154
13155    #[test]
13156    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13157        // Diagnostic-shape pin (peer with
13158        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13159        // on the closest two-byte peer arm): the error's Display
13160        // surfaces the offending `:nome`, the offending `:caminho`
13161        // verbatim, the offending byte's hex / character form, and
13162        // names the shell-bracket-expansion / glob-character-class
13163        // footgun explicitly so a `feira lint` run can render the
13164        // diagnostic without re-parsing.
13165        let d = dep_with_fonte(DepSource::Path {
13166            caminho: "../caixa-[a-z]/build".into(),
13167        });
13168        let rendered = d.validate().unwrap_err().to_string();
13169        assert!(
13170            rendered.contains("caixa-teia"),
13171            "diagnostic must name the offending dep: {rendered}",
13172        );
13173        assert!(
13174            rendered.contains("../caixa-[a-z]/build"),
13175            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13176        );
13177        assert!(
13178            rendered.contains("0x5b"),
13179            "diagnostic must surface the offending byte hex: {rendered:?}",
13180        );
13181        assert!(
13182            rendered.contains("bracket-expansion"),
13183            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13184        );
13185        assert!(
13186            rendered.contains("glob-character-class"),
13187            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13188             {rendered:?}",
13189        );
13190    }
13191
13192    #[test]
13193    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13194        // The canonical paste-from-shell-history strong-quoted
13195        // sibling-workspace-path footgun: an author copies a
13196        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13197        // quoting preserved the path across a whitespace paste
13198        // boundary and silently passed every prior arm
13199        // (`Path::is_absolute` false on `'..`, no control bytes, no
13200        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13201        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13202        // doesn't end in `/`; the leading-`$` f4efe9c
13203        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13204        // value starts with `'` not `$`). The lacre embedded the
13205        // value verbatim, the resolver folded it through
13206        // `Path::join` looking for a literal `./'../caixa-teia'`
13207        // subdirectory, and the failure surfaced at resolve time
13208        // with a non-self-locating `No such file or directory`
13209        // error. The new arm moves the rejection to validate time
13210        // and names the offending dep + caminho + byte verbatim.
13211        // The arm fires on the first `'` encountered.
13212        let d = dep_with_fonte(DepSource::Path {
13213            caminho: "'../caixa-teia'".into(),
13214        });
13215        let err = d.validate().unwrap_err();
13216        let DepError::FonteCaminhoShellQuoteGrouping {
13217            nome,
13218            caminho,
13219            byte,
13220        } = err
13221        else {
13222            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13223        };
13224        assert_eq!(nome, "caixa-teia");
13225        assert_eq!(caminho, "'../caixa-teia'");
13226        assert_eq!(byte, b'\'');
13227    }
13228
13229    #[test]
13230    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13231        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13232        // — the canonical paste-from-JSON-config / paste-from-YAML-
13233        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13234        // tatara-lisp-string-literal cross-idiom leak). Pinned
13235        // separately from the single-quote shape so the gate's
13236        // contract is "any `'` or `\"` anywhere", not single-byte
13237        // coverage. Mirrors the peer
13238        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13239        // shape on the immediate-predecessor
13240        // `FonteCaminhoShellBracketExpansion` arm.
13241        let d = dep_with_fonte(DepSource::Path {
13242            caminho: "\"../caixa-teia\"".into(),
13243        });
13244        let err = d.validate().unwrap_err();
13245        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13246            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13247        };
13248        assert_eq!(byte, b'"');
13249    }
13250
13251    #[test]
13252    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13253        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13254        // canonical "I pasted a JSON key-value pair fragment into
13255        // the middle of the path" idiom). Pinned separately from
13256        // the leading-byte shape so the gate covers every position,
13257        // not only leading.
13258        let d = dep_with_fonte(DepSource::Path {
13259            caminho: "../\"caixa-teia\"".into(),
13260        });
13261        let err = d.validate().unwrap_err();
13262        assert!(
13263            matches!(
13264                err,
13265                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13266            ),
13267            "got {err:?}",
13268        );
13269    }
13270
13271    #[test]
13272    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13273        // The canonical YAML double-quoted flow-scalar cross-idiom
13274        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13275        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13276        // values.yaml / K8s manifest and dropped it verbatim into
13277        // the `:caminho` slot including the `path: ` key prefix"
13278        // paste-idiom). The arm fires on the first `"` encountered;
13279        // pinned so the gate's coverage extends from the bare-quote
13280        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13281        // shape.
13282        let d = dep_with_fonte(DepSource::Path {
13283            caminho: "path: \"../caixa-teia\"".into(),
13284        });
13285        let err = d.validate().unwrap_err();
13286        assert!(
13287            matches!(
13288                err,
13289                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13290            ),
13291            "got {err:?}",
13292        );
13293    }
13294
13295    #[test]
13296    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13297        // The positive-control pin: the gate targets only `'` /
13298        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13299        // The canonical relative POSIX path (`"../caixa-teia"`) and
13300        // a nested deeply-pathed variant with adjacent printable
13301        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13302        // to validate cleanly so the gate doesn't widen to a "no
13303        // printable punctuation anywhere" sweep that would defeat
13304        // the entire path-fonte author surface. Peer with
13305        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13306        // on the immediate-predecessor arm.
13307        let d = dep_with_fonte(DepSource::Path {
13308            caminho: "../caixa-teia/sub-dir.v2".into(),
13309        });
13310        d.validate().unwrap();
13311    }
13312
13313    #[test]
13314    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13315        // Cascade pin on the immediate-predecessor arm: a value
13316        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13317        // "I pasted a glob-character-class followed by a strong-
13318        // quoted literal tail" footgun) routes through
13319        // `FonteCaminhoShellBracketExpansion` not
13320        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13321        // expansion is the load-bearing root-cause edit on every
13322        // probe-as-both value; same cascade discipline every prior
13323        // `:caminho` arm establishes.
13324        let d = dep_with_fonte(DepSource::Path {
13325            caminho: "../[a-z]'x'".into(),
13326        });
13327        let err = d.validate().unwrap_err();
13328        assert!(
13329            matches!(
13330                err,
13331                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13332            ),
13333            "got {err:?}",
13334        );
13335    }
13336
13337    #[test]
13338    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13339        // Cascade pin on the upstream shell-brace-expansion arm: a
13340        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13341        // canonical "I pasted a brace-expansion fan followed by a
13342        // strong-quoted literal tail" footgun) routes through
13343        // `FonteCaminhoShellBraceExpansion` not
13344        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13345        // is the load-bearing root-cause edit on every probe-as-
13346        // both value.
13347        let d = dep_with_fonte(DepSource::Path {
13348            caminho: "../{a,b}'x'".into(),
13349        });
13350        let err = d.validate().unwrap_err();
13351        assert!(
13352            matches!(
13353                err,
13354                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13355            ),
13356            "got {err:?}",
13357        );
13358    }
13359
13360    #[test]
13361    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13362        // Cascade pin on the upstream shell-subshell-grouping arm:
13363        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13364        // the canonical "I pasted a subshell-grouping followed by
13365        // a strong-quoted literal tail" footgun) routes through
13366        // `FonteCaminhoShellSubshellGrouping` not
13367        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13368        // `$(<cmd>)` command-substitution boundary is the load-
13369        // bearing axis on every probe-as-both value.
13370        let d = dep_with_fonte(DepSource::Path {
13371            caminho: "../(cd foo)/'x'".into(),
13372        });
13373        let err = d.validate().unwrap_err();
13374        assert!(
13375            matches!(
13376                err,
13377                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13378            ),
13379            "got {err:?}",
13380        );
13381    }
13382
13383    #[test]
13384    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13385        // Cascade pin on the upstream shell-glob arm: a value
13386        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13387        // canonical "I pasted a `*` unbounded pathname-expansion
13388        // followed by a strong-quoted literal tail" footgun) routes
13389        // through `FonteCaminhoShellGlob` not
13390        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13391        // expansion sentinel is the load-bearing root-cause edit
13392        // on every probe-as-both value.
13393        let d = dep_with_fonte(DepSource::Path {
13394            caminho: "../caixa-teia/*'x'".into(),
13395        });
13396        let err = d.validate().unwrap_err();
13397        assert!(
13398            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13399            "got {err:?}",
13400        );
13401    }
13402
13403    #[test]
13404    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13405        // Cascade pin on the upstream shell-command-substitution
13406        // arm: a value carrying both a backtick and `'`
13407        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13408        // legacy-backtick command-substitution followed by a
13409        // strong-quoted literal tail" footgun) routes through
13410        // `FonteCaminhoShellCommandSubstitution` not
13411        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13412        // command-injection vector is the load-bearing root-cause
13413        // edit on every probe-as-both value.
13414        let d = dep_with_fonte(DepSource::Path {
13415            caminho: "../`whoami`/'x'".into(),
13416        });
13417        let err = d.validate().unwrap_err();
13418        assert!(
13419            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13420            "got {err:?}",
13421        );
13422    }
13423
13424    #[test]
13425    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13426        // Cascade pin on the upstream shell-background arm: a value
13427        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13428        // canonical "I pasted a `cmd & 'literal'` background-launch
13429        // + quote chain" footgun) routes through
13430        // `FonteCaminhoShellBackground` not
13431        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13432        // tail is the load-bearing root-cause edit on every
13433        // probe-as-both value.
13434        let d = dep_with_fonte(DepSource::Path {
13435            caminho: "../caixa-teia & 'x'".into(),
13436        });
13437        let err = d.validate().unwrap_err();
13438        assert!(
13439            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13440            "got {err:?}",
13441        );
13442    }
13443
13444    #[test]
13445    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13446        // Cascade pin on the upstream shell-semicolon arm: a value
13447        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13448        // canonical sequential-cleanup + quote paste idiom) routes
13449        // through `FonteCaminhoShellSemicolon` not
13450        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13451        // separator paste is the load-bearing root-cause edit on
13452        // every probe-as-both value.
13453        let d = dep_with_fonte(DepSource::Path {
13454            caminho: "../caixa-teia; 'x'".into(),
13455        });
13456        let err = d.validate().unwrap_err();
13457        assert!(
13458            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13459            "got {err:?}",
13460        );
13461    }
13462
13463    #[test]
13464    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13465        // Cascade pin on the upstream shell-pipe arm: a value
13466        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13467        // canonical pipeline-to-quoted-literal paste idiom) routes
13468        // through `FonteCaminhoShellPipe` not
13469        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13470        // is the load-bearing root-cause edit on every probe-as-
13471        // both value.
13472        let d = dep_with_fonte(DepSource::Path {
13473            caminho: "../caixa-teia | 'x'".into(),
13474        });
13475        let err = d.validate().unwrap_err();
13476        assert!(
13477            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13478            "got {err:?}",
13479        );
13480    }
13481
13482    #[test]
13483    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13484        // Cascade pin on the upstream shell-redirection arm: a
13485        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13486        // — the canonical "I pasted a `cmd > log 'literal'`
13487        // redirect-plus-quote chain" footgun) routes through
13488        // `FonteCaminhoShellRedirection` not
13489        // `FonteCaminhoShellQuoteGrouping`. The input/output
13490        // redirection metachar carries the more self-locating
13491        // `byte` payload, so the prior arm wins on every probe-as-
13492        // both value.
13493        let d = dep_with_fonte(DepSource::Path {
13494            caminho: "../caixa-teia>log 'x'".into(),
13495        });
13496        let err = d.validate().unwrap_err();
13497        assert!(
13498            matches!(
13499                err,
13500                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13501            ),
13502            "got {err:?}",
13503        );
13504    }
13505
13506    #[test]
13507    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13508        // Cascade pin on the upstream backslash arm: a value
13509        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13510        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13511        // chain" footgun) routes through `FonteCaminhoBackslash`
13512        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13513        // separator divergence is the load-bearing axis on every
13514        // probe-as-both value.
13515        let d = dep_with_fonte(DepSource::Path {
13516            caminho: "..\\caixa-teia\\'x'".into(),
13517        });
13518        let err = d.validate().unwrap_err();
13519        assert!(
13520            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13521            "got {err:?}",
13522        );
13523    }
13524
13525    #[test]
13526    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13527        // Cascade pin on the embedded-control-byte arm: a value
13528        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13529        // the canonical paste-from-multiline-doc footgun where a
13530        // newline landed mid-caminho between two paste fragments)
13531        // routes through `FonteCaminhoControlChar` not
13532        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13533        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13534        // the load-bearing axis on every value that probes
13535        // positive for both — mirrors the cascade discipline on
13536        // every prior arm.
13537        let d = dep_with_fonte(DepSource::Path {
13538            caminho: "../foo\n'x'".into(),
13539        });
13540        let err = d.validate().unwrap_err();
13541        assert!(
13542            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13543            "got {err:?}",
13544        );
13545    }
13546
13547    #[test]
13548    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13549        // Cascade pin on the load-bearing leading-byte arm: a
13550        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13551        // through `FonteCaminhoAbsolute` not
13552        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13553        // diagnostic is the load-bearing axis, the quote byte is
13554        // the secondary observation. Same precedence logic as every
13555        // prior leading-byte arm.
13556        let d = dep_with_fonte(DepSource::Path {
13557            caminho: "/etc/'x'".into(),
13558        });
13559        let err = d.validate().unwrap_err();
13560        assert!(
13561            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13562            "got {err:?}",
13563        );
13564    }
13565
13566    #[test]
13567    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13568        // Cascade pin on the upstream leading-`$` var-expansion
13569        // arm: a value carrying both a leading `$` and a `'`
13570        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13571        // variable + quoted literal at the head of a sibling-
13572        // workspace path" footgun) routes through
13573        // `FonteCaminhoVarExpansion` not
13574        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13575        // shell-variable-expansion is the more self-locating
13576        // diagnostic on values that probe as both — same
13577        // load-bearing-leading-byte cascade discipline every
13578        // prior `:caminho` arm establishes.
13579        let d = dep_with_fonte(DepSource::Path {
13580            caminho: "$DIR/'x'".into(),
13581        });
13582        let err = d.validate().unwrap_err();
13583        assert!(
13584            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13585            "got {err:?}",
13586        );
13587    }
13588
13589    #[test]
13590    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13591        // Cascade pin on the immediate-successor arm: a value
13592        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13593        // — the canonical "I tab-completed a path whose strong-
13594        // quoted body already carried the quoting from a shell-
13595        // history paste" footgun) routes through
13596        // `FonteCaminhoShellQuoteGrouping` not
13597        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13598        // is the more semantic-locating axis (an author who removes
13599        // the `'` typically also drops the trailing separator since
13600        // both are paste-from-shell artifacts).
13601        let d = dep_with_fonte(DepSource::Path {
13602            caminho: "../'caixa-teia'/".into(),
13603        });
13604        let err = d.validate().unwrap_err();
13605        assert!(
13606            matches!(
13607                err,
13608                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13609            ),
13610            "got {err:?}",
13611        );
13612    }
13613
13614    #[test]
13615    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13616        // Diagnostic-shape pin (peer with
13617        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13618        // on the closest two-byte peer arm): the error's Display
13619        // surfaces the offending `:nome`, the offending `:caminho`
13620        // verbatim, the offending byte's hex / character form, and
13621        // names the shell-quote-grouping / cross-config-DSL-string-
13622        // literal-delimiter footgun explicitly so a `feira lint`
13623        // run can render the diagnostic without re-parsing.
13624        let d = dep_with_fonte(DepSource::Path {
13625            caminho: "'../caixa-teia'".into(),
13626        });
13627        let rendered = d.validate().unwrap_err().to_string();
13628        assert!(
13629            rendered.contains("caixa-teia"),
13630            "diagnostic must name the offending dep: {rendered}",
13631        );
13632        assert!(
13633            rendered.contains("'../caixa-teia'"),
13634            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13635        );
13636        assert!(
13637            rendered.contains("0x27"),
13638            "diagnostic must surface the offending byte hex: {rendered:?}",
13639        );
13640        assert!(
13641            rendered.contains("quote-grouping"),
13642            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13643        );
13644        assert!(
13645            rendered.contains("string-literal"),
13646            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13647             vocabulary: {rendered:?}",
13648        );
13649    }
13650
13651    #[test]
13652    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13653        // The canonical paste-from-shell-history-with-trailing-
13654        // annotation footgun: an author pastes a `cd ../caixa-teia
13655        // # legacy sibling` shell-history one-liner whose unquoted `#`
13656        // comment-lead separates the path from an inline annotation.
13657        // The POSIX shell trims the annotation to `../caixa-teia`
13658        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13659        // `Path::is_absolute` returns false on `..`, `#` is neither
13660        // a leading-byte sentinel nor a control byte nor `\` nor
13661        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13662        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13663        // `"`, and the value's last byte isn't `/` — so the value
13664        // silently passed every prior arm. The resolver folded the
13665        // value through `Path::join` looking for a literal
13666        // `./../caixa-teia # legacy sibling` subdirectory and the
13667        // failure surfaced at resolve time with a non-self-locating
13668        // `No such file or directory` error. The new arm moves the
13669        // rejection to validate time and names the offending dep +
13670        // caminho + byte verbatim.
13671        let d = dep_with_fonte(DepSource::Path {
13672            caminho: "../caixa-teia # legacy sibling".into(),
13673        });
13674        let err = d.validate().unwrap_err();
13675        let DepError::FonteCaminhoShellComment {
13676            nome,
13677            caminho,
13678            byte,
13679        } = err
13680        else {
13681            panic!("expected FonteCaminhoShellComment, got {err:?}");
13682        };
13683        assert_eq!(nome, "caixa-teia");
13684        assert_eq!(caminho, "../caixa-teia # legacy sibling");
13685        assert_eq!(byte, b'#');
13686    }
13687
13688    #[test]
13689    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13690        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13691        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
13692        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
13693        // scalar-plus-comment entry out of an aligned values.yaml and
13694        // dropped it verbatim into the `:caminho` slot" paste-idiom).
13695        // Pinned separately from the shell-history shape so the
13696        // gate's coverage extends from the single-space `#` shape to
13697        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
13698        // requires the `#` to be preceded by whitespace to lex as a
13699        // comment (bare `foo#bar` is a single scalar); the double-
13700        // space paste from an aligned manifest is the canonical
13701        // shape.
13702        let d = dep_with_fonte(DepSource::Path {
13703            caminho: "../caixa-teia  # pin".into(),
13704        });
13705        let err = d.validate().unwrap_err();
13706        assert!(
13707            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13708            "got {err:?}",
13709        );
13710    }
13711
13712    #[test]
13713    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13714        // The URL-fragment-identifier paste shape
13715        // (`"../caixa-teia#readme"` — the canonical
13716        // paste-from-browser-address-bar permalink shape where the
13717        // browser preserved the `#anchor` tail on the copy). Pinned
13718        // separately from the whitespace-separated shell / YAML
13719        // comment shapes so the gate covers the unpadded RFC 3986
13720        // §3.5 fragment-delimiter position too, not only positions
13721        // preceded by unquoted whitespace. Peer with the immediate-
13722        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13723        // (a68f818) which closes the same byte under the same URL-
13724        // fragment-identifier banner.
13725        let d = dep_with_fonte(DepSource::Path {
13726            caminho: "../caixa-teia#readme".into(),
13727        });
13728        let err = d.validate().unwrap_err();
13729        assert!(
13730            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13731            "got {err:?}",
13732        );
13733    }
13734
13735    #[test]
13736    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13737        // Leading-position `#` shape (`"#../caixa-teia"` — the
13738        // "I copied a shell-comment-out entry from a commented-out
13739        // dep row" footgun). Pinned separately from the embedded
13740        // shapes so the gate covers every position, not only
13741        // whitespace-preceded / mid-value.
13742        let d = dep_with_fonte(DepSource::Path {
13743            caminho: "#../caixa-teia".into(),
13744        });
13745        let err = d.validate().unwrap_err();
13746        assert!(
13747            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13748            "got {err:?}",
13749        );
13750    }
13751
13752    #[test]
13753    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13754        // The positive-control pin: the gate targets only `#`,
13755        // never adjacent printable ASCII or POSIX-valid bytes. The
13756        // canonical relative POSIX path (`"../caixa-teia"`) and a
13757        // nested deeply-pathed variant with adjacent printable
13758        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13759        // to validate cleanly so the gate doesn't widen to a "no
13760        // printable punctuation anywhere" sweep that would defeat
13761        // the entire path-fonte author surface. Peer with
13762        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13763        // on the immediate-predecessor arm.
13764        let d = dep_with_fonte(DepSource::Path {
13765            caminho: "../caixa-teia/sub-dir.v2".into(),
13766        });
13767        d.validate().unwrap();
13768    }
13769
13770    #[test]
13771    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13772        // Cascade pin on the immediate-predecessor arm: a value
13773        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13774        // "I pasted a strong-quoted literal followed by a URL-
13775        // fragment permalink tail" footgun) routes through
13776        // `FonteCaminhoShellQuoteGrouping` not
13777        // `FonteCaminhoShellComment`. The shell-string-literal-
13778        // delimiter is the load-bearing root-cause edit on every
13779        // probe-as-both value; same cascade discipline every prior
13780        // `:caminho` arm establishes.
13781        let d = dep_with_fonte(DepSource::Path {
13782            caminho: "../'x'#pin".into(),
13783        });
13784        let err = d.validate().unwrap_err();
13785        assert!(
13786            matches!(
13787                err,
13788                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13789            ),
13790            "got {err:?}",
13791        );
13792    }
13793
13794    #[test]
13795    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13796        // Cascade pin on the upstream shell-bracket-expansion arm:
13797        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13798        // canonical "I pasted a glob-character-class followed by a
13799        // URL-fragment tail" footgun) routes through
13800        // `FonteCaminhoShellBracketExpansion` not
13801        // `FonteCaminhoShellComment`. The glob-character-class
13802        // expansion is the load-bearing root-cause edit on every
13803        // probe-as-both value.
13804        let d = dep_with_fonte(DepSource::Path {
13805            caminho: "../[a-z]#pin".into(),
13806        });
13807        let err = d.validate().unwrap_err();
13808        assert!(
13809            matches!(
13810                err,
13811                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13812            ),
13813            "got {err:?}",
13814        );
13815    }
13816
13817    #[test]
13818    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13819        // Cascade pin on the upstream shell-brace-expansion arm: a
13820        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13821        // canonical "I pasted a brace-expansion fan followed by a
13822        // URL-fragment tail" footgun) routes through
13823        // `FonteCaminhoShellBraceExpansion` not
13824        // `FonteCaminhoShellComment`. The brace-expansion fan is the
13825        // load-bearing root-cause edit on every probe-as-both value.
13826        let d = dep_with_fonte(DepSource::Path {
13827            caminho: "../{a,b}#pin".into(),
13828        });
13829        let err = d.validate().unwrap_err();
13830        assert!(
13831            matches!(
13832                err,
13833                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13834            ),
13835            "got {err:?}",
13836        );
13837    }
13838
13839    #[test]
13840    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13841        // Cascade pin on the upstream shell-subshell-grouping arm:
13842        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13843        // the canonical "I pasted a subshell-grouping followed by a
13844        // URL-fragment tail" footgun) routes through
13845        // `FonteCaminhoShellSubshellGrouping` not
13846        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13847        // command-substitution boundary is the load-bearing axis on
13848        // every probe-as-both value.
13849        let d = dep_with_fonte(DepSource::Path {
13850            caminho: "../(cd foo)#pin".into(),
13851        });
13852        let err = d.validate().unwrap_err();
13853        assert!(
13854            matches!(
13855                err,
13856                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13857            ),
13858            "got {err:?}",
13859        );
13860    }
13861
13862    #[test]
13863    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13864        // Cascade pin on the upstream shell-glob arm: a value
13865        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13866        // canonical "I pasted a `*` unbounded pathname-expansion
13867        // followed by a URL-fragment tail" footgun) routes through
13868        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13869        // The unbounded pathname-expansion sentinel is the load-
13870        // bearing root-cause edit on every probe-as-both value.
13871        let d = dep_with_fonte(DepSource::Path {
13872            caminho: "../caixa-teia/*#pin".into(),
13873        });
13874        let err = d.validate().unwrap_err();
13875        assert!(
13876            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13877            "got {err:?}",
13878        );
13879    }
13880
13881    #[test]
13882    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13883        // Cascade pin on the upstream shell-command-substitution
13884        // arm: a value carrying both a backtick and `#`
13885        // (``"../`whoami`#pin"`` — the canonical "I pasted a
13886        // legacy-backtick command-substitution followed by a URL-
13887        // fragment tail" footgun) routes through
13888        // `FonteCaminhoShellCommandSubstitution` not
13889        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13890        // injection vector is the load-bearing root-cause edit on
13891        // every probe-as-both value.
13892        let d = dep_with_fonte(DepSource::Path {
13893            caminho: "../`whoami`#pin".into(),
13894        });
13895        let err = d.validate().unwrap_err();
13896        assert!(
13897            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13898            "got {err:?}",
13899        );
13900    }
13901
13902    #[test]
13903    fn fonte_caminho_shell_background_fires_before_shell_comment() {
13904        // Cascade pin on the upstream shell-background arm: a value
13905        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13906        // the canonical "I pasted a `cmd &` background-launch
13907        // followed by a URL-fragment tail" footgun) routes through
13908        // `FonteCaminhoShellBackground` not
13909        // `FonteCaminhoShellComment`. The background-launch tail is
13910        // the load-bearing root-cause edit on every probe-as-both
13911        // value.
13912        let d = dep_with_fonte(DepSource::Path {
13913            caminho: "../caixa-teia&pin#tail".into(),
13914        });
13915        let err = d.validate().unwrap_err();
13916        assert!(
13917            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13918            "got {err:?}",
13919        );
13920    }
13921
13922    #[test]
13923    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13924        // Cascade pin on the upstream shell-semicolon arm: a value
13925        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13926        // the canonical sequential-cleanup + URL-fragment paste
13927        // idiom) routes through `FonteCaminhoShellSemicolon` not
13928        // `FonteCaminhoShellComment`. The sequential-command-
13929        // separator paste is the load-bearing root-cause edit on
13930        // every probe-as-both value.
13931        let d = dep_with_fonte(DepSource::Path {
13932            caminho: "../caixa-teia;pin#tail".into(),
13933        });
13934        let err = d.validate().unwrap_err();
13935        assert!(
13936            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13937            "got {err:?}",
13938        );
13939    }
13940
13941    #[test]
13942    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13943        // Cascade pin on the upstream shell-pipe arm: a value
13944        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13945        // the canonical pipeline-to-URL-fragment paste idiom) routes
13946        // through `FonteCaminhoShellPipe` not
13947        // `FonteCaminhoShellComment`. The pipeline-tail paste is
13948        // the load-bearing root-cause edit on every probe-as-both
13949        // value.
13950        let d = dep_with_fonte(DepSource::Path {
13951            caminho: "../caixa-teia|pin#tail".into(),
13952        });
13953        let err = d.validate().unwrap_err();
13954        assert!(
13955            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13956            "got {err:?}",
13957        );
13958    }
13959
13960    #[test]
13961    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13962        // Cascade pin on the upstream shell-redirection arm: a
13963        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13964        // — the canonical "I pasted a `cmd > log` redirect followed
13965        // by a URL-fragment tail" footgun) routes through
13966        // `FonteCaminhoShellRedirection` not
13967        // `FonteCaminhoShellComment`. The input/output redirection
13968        // metachar carries the more self-locating `byte` payload,
13969        // so the prior arm wins on every probe-as-both value.
13970        let d = dep_with_fonte(DepSource::Path {
13971            caminho: "../caixa-teia>log#pin".into(),
13972        });
13973        let err = d.validate().unwrap_err();
13974        assert!(
13975            matches!(
13976                err,
13977                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13978            ),
13979            "got {err:?}",
13980        );
13981    }
13982
13983    #[test]
13984    fn fonte_caminho_backslash_fires_before_shell_comment() {
13985        // Cascade pin on the upstream backslash arm: a value
13986        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13987        // canonical "I pasted a Windows-shell path followed by a
13988        // URL-fragment tail" footgun) routes through
13989        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13990        // The cross-host-OS-separator divergence is the load-
13991        // bearing axis on every probe-as-both value.
13992        let d = dep_with_fonte(DepSource::Path {
13993            caminho: "..\\caixa-teia#pin".into(),
13994        });
13995        let err = d.validate().unwrap_err();
13996        assert!(
13997            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13998            "got {err:?}",
13999        );
14000    }
14001
14002    #[test]
14003    fn fonte_caminho_control_char_fires_before_shell_comment() {
14004        // Cascade pin on the embedded-control-byte arm: a value
14005        // carrying both a control byte and `#` (`"../foo\n#pin"` —
14006        // the canonical paste-from-multiline-doc footgun where a
14007        // newline landed mid-caminho between the path and an
14008        // annotation) routes through `FonteCaminhoControlChar` not
14009        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14010        // byte diagnostic is the load-bearing axis on every value
14011        // that probes positive for both — mirrors the cascade
14012        // discipline on every prior arm.
14013        let d = dep_with_fonte(DepSource::Path {
14014            caminho: "../foo\n#pin".into(),
14015        });
14016        let err = d.validate().unwrap_err();
14017        assert!(
14018            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14019            "got {err:?}",
14020        );
14021    }
14022
14023    #[test]
14024    fn fonte_caminho_absolute_fires_before_shell_comment() {
14025        // Cascade pin on the load-bearing leading-byte arm: a
14026        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14027        // routes through `FonteCaminhoAbsolute` not
14028        // `FonteCaminhoShellComment` — the host-layout-leak
14029        // diagnostic is the load-bearing axis, the fragment byte is
14030        // the secondary observation. Same precedence logic as every
14031        // prior leading-byte arm.
14032        let d = dep_with_fonte(DepSource::Path {
14033            caminho: "/etc/foo#pin".into(),
14034        });
14035        let err = d.validate().unwrap_err();
14036        assert!(
14037            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14038            "got {err:?}",
14039        );
14040    }
14041
14042    #[test]
14043    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14044        // Cascade pin on the upstream leading-`$` var-expansion
14045        // arm: a value carrying both a leading `$` and a `#`
14046        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14047        // shell-variable at the head of a sibling-workspace path
14048        // followed by a URL-fragment tail" footgun) routes through
14049        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14050        // The leading-byte shell-variable-expansion is the more
14051        // self-locating diagnostic on values that probe as both.
14052        let d = dep_with_fonte(DepSource::Path {
14053            caminho: "$DIR/foo#pin".into(),
14054        });
14055        let err = d.validate().unwrap_err();
14056        assert!(
14057            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14058            "got {err:?}",
14059        );
14060    }
14061
14062    #[test]
14063    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14064        // Cascade pin on the immediate-successor arm: a value
14065        // carrying both `#` and a trailing `/`
14066        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14067        // a URL-fragment-carrying path" footgun) routes through
14068        // `FonteCaminhoShellComment` not
14069        // `FonteCaminhoTrailingSlash`. The embedded fragment /
14070        // comment-lead byte is the more semantic-locating axis (an
14071        // author who removes the `#pin` fragment typically also
14072        // drops the trailing separator since both are paste-from-
14073        // URL / paste-from-shell-tab-completion artifacts).
14074        let d = dep_with_fonte(DepSource::Path {
14075            caminho: "../caixa-teia#pin/".into(),
14076        });
14077        let err = d.validate().unwrap_err();
14078        assert!(
14079            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14080            "got {err:?}",
14081        );
14082    }
14083
14084    #[test]
14085    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14086        // Diagnostic-shape pin (peer with
14087        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14088        // on the immediate-predecessor arm): the error's Display
14089        // surfaces the offending `:nome`, the offending `:caminho`
14090        // verbatim, the offending byte's hex / character form, and
14091        // names the shell-comment / URL-fragment-identifier /
14092        // YAML-comment cross-config-DSL footgun explicitly so a
14093        // `feira lint` run can render the diagnostic without
14094        // re-parsing.
14095        let d = dep_with_fonte(DepSource::Path {
14096            caminho: "../caixa-teia#readme".into(),
14097        });
14098        let rendered = d.validate().unwrap_err().to_string();
14099        assert!(
14100            rendered.contains("caixa-teia"),
14101            "diagnostic must name the offending dep: {rendered}",
14102        );
14103        assert!(
14104            rendered.contains("../caixa-teia#readme"),
14105            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14106        );
14107        assert!(
14108            rendered.contains("0x23"),
14109            "diagnostic must surface the offending byte hex: {rendered:?}",
14110        );
14111        assert!(
14112            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14113            "diagnostic must name the shell-comment footgun: {rendered:?}",
14114        );
14115        assert!(
14116            rendered.contains("fragment") || rendered.contains("URL-fragment"),
14117            "diagnostic must reference the URL-fragment-identifier vocabulary: \
14118             {rendered:?}",
14119        );
14120    }
14121
14122    #[test]
14123    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14124        // The canonical paste-from-browser-address-bar percent-
14125        // encoded-space footgun: an author copies `../caixa%20teia`
14126        // out of a URL-encoded README hyperlink / browser address
14127        // bar / percent-encoded permalink expecting `%20` to decode
14128        // to a literal space at the filesystem layer. POSIX
14129        // `std::path::Path` treats `%` as a literal path-component
14130        // byte, so `Path::join` looks for a literal
14131        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14132        // returns false on `..`, `%` is neither a leading-byte
14133        // sentinel nor a control byte nor `\` nor `<` / `>` nor
14134        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14135        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14136        // and the value's last byte isn't `/` — so the value
14137        // silently passed every prior arm. The new arm moves the
14138        // rejection to validate time and names the offending dep +
14139        // caminho + byte verbatim.
14140        let d = dep_with_fonte(DepSource::Path {
14141            caminho: "../caixa%20teia".into(),
14142        });
14143        let err = d.validate().unwrap_err();
14144        let DepError::FonteCaminhoUrlPercentEncoding {
14145            nome,
14146            caminho,
14147            byte,
14148        } = err
14149        else {
14150            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14151        };
14152        assert_eq!(nome, "caixa-teia");
14153        assert_eq!(caminho, "../caixa%20teia");
14154        assert_eq!(byte, b'%');
14155    }
14156
14157    #[test]
14158    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14159        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14160        // intending the `%2F` as the URL encoding of `/`) locks a
14161        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14162        // the byte-identical `path:../caixa/teia` form. Pinned
14163        // separately from the space-encoded shape so the gate's
14164        // coverage extends past the single canonical `%20` example
14165        // to any two-hex-digit percent-encoded sequence.
14166        let d = dep_with_fonte(DepSource::Path {
14167            caminho: "../caixa%2Fteia".into(),
14168        });
14169        let err = d.validate().unwrap_err();
14170        assert!(
14171            matches!(
14172                err,
14173                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14174            ),
14175            "got {err:?}",
14176        );
14177    }
14178
14179    #[test]
14180    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14181        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14182        // where `%` isn't followed by two hex digits) — every
14183        // WHATWG-conformant URL parser rejects the value at parse
14184        // time per RFC 3986 §2.1, but the byte would silently ride
14185        // into the lacre before the resolver subprocess crosses the
14186        // URL-parser boundary. Pinned separately from the well-
14187        // formed `%HH` shapes so the gate covers every percent-
14188        // occurrence, not only strictly-conformant escapes.
14189        let d = dep_with_fonte(DepSource::Path {
14190            caminho: "../caixa-teia%foo".into(),
14191        });
14192        let err = d.validate().unwrap_err();
14193        assert!(
14194            matches!(
14195                err,
14196                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14197            ),
14198            "got {err:?}",
14199        );
14200    }
14201
14202    #[test]
14203    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14204        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14205        // — the canonical paste-from-top-of-doc YAML directive
14206        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14207        // separately from embedded shapes so the gate covers the
14208        // leading-position `%` too, not only mid-value occurrences.
14209        let d = dep_with_fonte(DepSource::Path {
14210            caminho: "%YAML/../caixa-teia".into(),
14211        });
14212        let err = d.validate().unwrap_err();
14213        assert!(
14214            matches!(
14215                err,
14216                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14217            ),
14218            "got {err:?}",
14219        );
14220    }
14221
14222    #[test]
14223    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14224        // The printf-format-specifier paste shape
14225        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14226        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14227        // 134 format-string-injection vector). Pinned separately
14228        // from the URL-encoding shapes so the gate's rationale
14229        // extends past the RFC 3986 axis to the C / POSIX printf
14230        // format-directive-lead axis.
14231        let d = dep_with_fonte(DepSource::Path {
14232            caminho: "../caixa-%s-teia".into(),
14233        });
14234        let err = d.validate().unwrap_err();
14235        assert!(
14236            matches!(
14237                err,
14238                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14239            ),
14240            "got {err:?}",
14241        );
14242    }
14243
14244    #[test]
14245    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14246        // The positive-control pin: the gate targets only `%`,
14247        // never adjacent printable ASCII or POSIX-valid bytes. The
14248        // canonical relative POSIX path (`"../caixa-teia"`) and a
14249        // nested deeply-pathed variant with adjacent printable
14250        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14251        // to validate cleanly so the gate doesn't widen to a "no
14252        // printable punctuation anywhere" sweep that would defeat
14253        // the entire path-fonte author surface. Peer with
14254        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14255        // on the immediate-predecessor arm.
14256        let d = dep_with_fonte(DepSource::Path {
14257            caminho: "../caixa-teia/sub-dir.v2".into(),
14258        });
14259        d.validate().unwrap();
14260    }
14261
14262    #[test]
14263    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14264        // Cascade pin on the immediate-predecessor arm: a value
14265        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14266        // canonical "I pasted a URL-fragment permalink followed by a
14267        // percent-encoded space tail" footgun) routes through
14268        // `FonteCaminhoShellComment` not
14269        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14270        // identifier is the load-bearing downstream-truncation edit
14271        // on every probe-as-both value; same cascade discipline
14272        // every prior `:caminho` arm establishes.
14273        let d = dep_with_fonte(DepSource::Path {
14274            caminho: "../caixa-teia#pin%20".into(),
14275        });
14276        let err = d.validate().unwrap_err();
14277        assert!(
14278            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14279            "got {err:?}",
14280        );
14281    }
14282
14283    #[test]
14284    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14285        // Cascade pin on the upstream shell-quote-grouping arm: a
14286        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14287        // canonical "I pasted a strong-quoted literal followed by
14288        // a percent-encoded space" footgun) routes through
14289        // `FonteCaminhoShellQuoteGrouping` not
14290        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14291        // literal-delimiter is the load-bearing root-cause edit on
14292        // every probe-as-both value.
14293        let d = dep_with_fonte(DepSource::Path {
14294            caminho: "../'x'%20teia".into(),
14295        });
14296        let err = d.validate().unwrap_err();
14297        assert!(
14298            matches!(
14299                err,
14300                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14301            ),
14302            "got {err:?}",
14303        );
14304    }
14305
14306    #[test]
14307    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14308        // Cascade pin on the upstream backslash arm: a value
14309        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14310        // canonical "I pasted a Windows-shell path followed by a
14311        // percent-encoded space" footgun) routes through
14312        // `FonteCaminhoBackslash` not
14313        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14314        // separator divergence is the load-bearing root-cause edit
14315        // on every probe-as-both value.
14316        let d = dep_with_fonte(DepSource::Path {
14317            caminho: "..\\caixa%20teia".into(),
14318        });
14319        let err = d.validate().unwrap_err();
14320        assert!(
14321            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14322            "got {err:?}",
14323        );
14324    }
14325
14326    #[test]
14327    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14328        // Cascade pin on the upstream control-char arm: a value
14329        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14330        // the canonical "I pasted a paste-from-binary-blob path
14331        // followed by a percent-encoded space" footgun) routes
14332        // through `FonteCaminhoControlChar` not
14333        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14334        // rejected byte is the load-bearing root-cause edit on
14335        // every probe-as-both value.
14336        let d = dep_with_fonte(DepSource::Path {
14337            caminho: "../caixa\0%20teia".into(),
14338        });
14339        let err = d.validate().unwrap_err();
14340        assert!(
14341            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14342            "got {err:?}",
14343        );
14344    }
14345
14346    #[test]
14347    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14348        // Cascade pin on the upstream absolute-path arm: a value
14349        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14350        // — the canonical "I pasted an absolute path with a
14351        // percent-encoded space tail" footgun) routes through
14352        // `FonteCaminhoAbsolute` not
14353        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14354        // the load-bearing root-cause edit on every probe-as-both
14355        // value.
14356        let d = dep_with_fonte(DepSource::Path {
14357            caminho: "/etc/passwd%20".into(),
14358        });
14359        let err = d.validate().unwrap_err();
14360        assert!(
14361            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14362            "got {err:?}",
14363        );
14364    }
14365
14366    #[test]
14367    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14368        // Cascade pin on the upstream var-expansion arm: a value
14369        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14370        // — the canonical "I pasted a `$HOME`-rooted path with a
14371        // percent-encoded space" footgun) routes through
14372        // `FonteCaminhoVarExpansion` not
14373        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14374        // expansion is the load-bearing root-cause edit on every
14375        // probe-as-both value.
14376        let d = dep_with_fonte(DepSource::Path {
14377            caminho: "$HOME/caixa%20teia".into(),
14378        });
14379        let err = d.validate().unwrap_err();
14380        assert!(
14381            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14382            "got {err:?}",
14383        );
14384    }
14385
14386    #[test]
14387    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14388        // Cascade pin on the immediate-successor arm: a value
14389        // carrying both `%` and a trailing `/`
14390        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14391        // percent-encoded-space-carrying path" footgun) routes
14392        // through `FonteCaminhoUrlPercentEncoding` not
14393        // `FonteCaminhoTrailingSlash`. The embedded percent-
14394        // encoding-escape byte is the more semantic-locating axis
14395        // (an author who decodes the `%20` to a literal space is
14396        // likely to also tab-strip the trailing separator since
14397        // both are paste-from-URL / paste-from-shell-tab-completion
14398        // artifacts).
14399        let d = dep_with_fonte(DepSource::Path {
14400            caminho: "../caixa%20teia/".into(),
14401        });
14402        let err = d.validate().unwrap_err();
14403        assert!(
14404            matches!(
14405                err,
14406                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14407            ),
14408            "got {err:?}",
14409        );
14410    }
14411
14412    #[test]
14413    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14414        // Diagnostic-shape pin (peer with
14415        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14416        // on the immediate-predecessor arm): the error's Display
14417        // surfaces the offending `:nome`, the offending `:caminho`
14418        // verbatim, the offending byte's hex / character form, and
14419        // names the URL-percent-encoding-escape / printf-format-
14420        // specifier footgun explicitly so a `feira lint` run can
14421        // render the diagnostic without re-parsing.
14422        let d = dep_with_fonte(DepSource::Path {
14423            caminho: "../caixa%20teia".into(),
14424        });
14425        let rendered = d.validate().unwrap_err().to_string();
14426        assert!(
14427            rendered.contains("caixa-teia"),
14428            "diagnostic must name the offending dep: {rendered}",
14429        );
14430        assert!(
14431            rendered.contains("../caixa%20teia"),
14432            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14433        );
14434        assert!(
14435            rendered.contains("0x25"),
14436            "diagnostic must surface the offending byte hex: {rendered:?}",
14437        );
14438        assert!(
14439            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14440            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14441        );
14442        assert!(
14443            rendered.contains("printf") || rendered.contains("format-specifier"),
14444            "diagnostic must reference the printf-format-specifier vocabulary: \
14445             {rendered:?}",
14446        );
14447    }
14448
14449    #[test]
14450    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14451        // The canonical embedded-`$` shell-variable-expansion paste
14452        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14453        // substituted shell one-liner where the leading segment is a
14454        // literal `../foo` while the mid segment carries the un-
14455        // substituted `$HOME` template). The leading-`$` position is
14456        // already gated by the f4efe9c leading-byte arm which routes
14457        // through `FonteCaminhoVarExpansion`; this arm closes the
14458        // last positional gap on `$` — every position on the axis is
14459        // structurally rejected.
14460        let d = dep_with_fonte(DepSource::Path {
14461            caminho: "../foo$HOME/bar".into(),
14462        });
14463        let err = d.validate().unwrap_err();
14464        let DepError::FonteCaminhoShellVariableExpansion {
14465            nome,
14466            caminho,
14467            byte,
14468        } = err
14469        else {
14470            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14471        };
14472        assert_eq!(nome, "caixa-teia");
14473        assert_eq!(caminho, "../foo$HOME/bar");
14474        assert_eq!(byte, b'$');
14475    }
14476
14477    #[test]
14478    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14479        // The symmetric braced-CI-manifest paste shape
14480        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14481        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14482        // footgun). Pinned separately from the bare-`$VAR` shape so
14483        // the gate covers both POSIX shell §2.6 Parameter Expansion
14484        // syntactic forms, not only the unbraced variant. The
14485        // embedded `{` byte in `${...}` is also caught by the 598b770
14486        // shell-brace-expansion arm but that arm fires earlier in
14487        // the cascade — the `$` arm's coverage extends to `${...}`
14488        // structurally, so the diagnostic asserted here is the
14489        // brace-expansion one (which is a valid outcome; the point
14490        // of the pin is that the value never survives validation).
14491        let d = dep_with_fonte(DepSource::Path {
14492            caminho: "../foo${WORKSPACE}/bar".into(),
14493        });
14494        let err = d.validate().unwrap_err();
14495        assert!(
14496            matches!(
14497                err,
14498                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14499                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14500            ),
14501            "got {err:?}",
14502        );
14503    }
14504
14505    #[test]
14506    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14507        // The paste-from-shell-prompt command-substitution idiom
14508        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14509        // `$VAR` shape so the gate's rationale extends to POSIX shell
14510        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14511        // legacy `` `<cmd>` `` form is already closed by the c370458
14512        // backtick arm). The embedded `(` byte in `$(...)` is also
14513        // caught structurally by the 0633c91 shell-subshell-grouping
14514        // arm which fires earlier in the cascade — the diagnostic
14515        // asserted here is either outcome, since both structurally
14516        // reject the value; the point of the pin is that the value
14517        // never survives validation.
14518        let d = dep_with_fonte(DepSource::Path {
14519            caminho: "../foo$(whoami)/bar".into(),
14520        });
14521        let err = d.validate().unwrap_err();
14522        assert!(
14523            matches!(
14524                err,
14525                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14526                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14527            ),
14528            "got {err:?}",
14529        );
14530    }
14531
14532    #[test]
14533    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14534        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14535        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14536        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14537        // idiom copied into a caminho template). None of the prior
14538        // shell-metachar arms cover this shape (`1` is a bare digit;
14539        // no `(` / `{` / letter follows the `$`), so the arm is the
14540        // sole gate on the shape.
14541        let d = dep_with_fonte(DepSource::Path {
14542            caminho: "../foo$1/bar".into(),
14543        });
14544        let err = d.validate().unwrap_err();
14545        assert!(
14546            matches!(
14547                err,
14548                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14549            ),
14550            "got {err:?}",
14551        );
14552    }
14553
14554    #[test]
14555    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14556        // The positive-control pin (peer with
14557        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14558        // on the immediate-predecessor arm): the gate targets only
14559        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14560        // A relative POSIX path carrying dashes / dots / slashes /
14561        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14562        // validate cleanly so the gate doesn't widen to a "no
14563        // printable punctuation anywhere" sweep that would defeat
14564        // the entire path-fonte author surface.
14565        let d = dep_with_fonte(DepSource::Path {
14566            caminho: "../caixa-teia/sub-dir.v2".into(),
14567        });
14568        d.validate().unwrap();
14569    }
14570
14571    #[test]
14572    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14573        // Cascade pin on the leading-`$` sibling arm at line 540: a
14574        // value starting with `$` and carrying an embedded `$` too
14575        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14576        // fully-templated CI path with two un-substituted variables")
14577        // routes through `FonteCaminhoVarExpansion` not
14578        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14579        // host-layout-leak is the load-bearing self-locating axis
14580        // (the leading position dominates the semantic-locating
14581        // rationale on every probe-as-both value); the embedded
14582        // arm's positional-agnostic sweep catches only values whose
14583        // leading byte doesn't route through the earlier leading-
14584        // byte arms.
14585        let d = dep_with_fonte(DepSource::Path {
14586            caminho: "$HOME/foo$WORKSPACE/bar".into(),
14587        });
14588        let err = d.validate().unwrap_err();
14589        assert!(
14590            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14591            "got {err:?}",
14592        );
14593    }
14594
14595    #[test]
14596    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14597        // Cascade pin on the immediate-predecessor arm: a value
14598        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14599        // — the canonical "I pasted a percent-encoded space adjacent
14600        // to a `$HOME` template") routes through
14601        // `FonteCaminhoUrlPercentEncoding` not
14602        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14603        // encoding-escape byte is the more semantic-locating axis
14604        // (the paste-from-browser-address-bar shape is the load-
14605        // bearing self-locating edit); same cascade discipline every
14606        // prior `:caminho` arm establishes.
14607        let d = dep_with_fonte(DepSource::Path {
14608            caminho: "../foo%20$HOME/bar".into(),
14609        });
14610        let err = d.validate().unwrap_err();
14611        assert!(
14612            matches!(
14613                err,
14614                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14615            ),
14616            "got {err:?}",
14617        );
14618    }
14619
14620    #[test]
14621    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14622        // Cascade pin on the immediate-successor arm: a value
14623        // carrying both embedded `$` and a trailing `/`
14624        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14625        // `$HOME`-template-carrying path") routes through
14626        // `FonteCaminhoShellVariableExpansion` not
14627        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14628        // expansion byte is the more semantic-locating axis on
14629        // probe-as-both values (an author who substitutes the
14630        // `$HOME` template with a literal value is likely to also
14631        // tab-strip the trailing separator).
14632        let d = dep_with_fonte(DepSource::Path {
14633            caminho: "../foo$HOME/bar/".into(),
14634        });
14635        let err = d.validate().unwrap_err();
14636        assert!(
14637            matches!(
14638                err,
14639                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14640            ),
14641            "got {err:?}",
14642        );
14643    }
14644
14645    #[test]
14646    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14647        // Diagnostic-shape pin (peer with
14648        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14649        // on the immediate-predecessor arm): the error's Display
14650        // surfaces the offending `:nome`, the offending `:caminho`
14651        // verbatim, the offending byte's hex / character form, and
14652        // names the shell-variable-expansion / command-substitution
14653        // footgun explicitly so a `feira lint` run can render the
14654        // diagnostic without re-parsing.
14655        let d = dep_with_fonte(DepSource::Path {
14656            caminho: "../foo$HOME/bar".into(),
14657        });
14658        let rendered = d.validate().unwrap_err().to_string();
14659        assert!(
14660            rendered.contains("caixa-teia"),
14661            "diagnostic must name the offending dep: {rendered}",
14662        );
14663        assert!(
14664            rendered.contains("../foo$HOME/bar"),
14665            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14666        );
14667        assert!(
14668            rendered.contains("0x24"),
14669            "diagnostic must surface the offending byte hex: {rendered:?}",
14670        );
14671        assert!(
14672            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14673            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14674        );
14675        assert!(
14676            rendered.contains("command-substitution") || rendered.contains("command substitution"),
14677            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14678        );
14679    }
14680
14681    #[test]
14682    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14683        // The fail-before-pass-after pin for the canonical paste-from-
14684        // shell-history footgun on `:caminho`. An author copies a `cd
14685        // ../caixa-teia && !sudo make install` one-liner from a quick-
14686        // start README, intending the trailing `!sudo` as a shell-
14687        // history-expansion reference but the typed slot is itself a
14688        // byte-level string parser, not a shell context, so the byte
14689        // rides into the value verbatim. Until this arm landed the `!`
14690        // byte silently passed every prior `:caminho` cascade arm
14691        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14692        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14693        // `#` / `%` / `$`); bash with the default `histexpand` mode
14694        // rewrites `!command` to the most recent history entry
14695        // beginning with `command`, the canonical RCE-class injection
14696        // vector when the byte rides into a shell argument executed
14697        // under `bash -i` (the operator-notebook interactive shell).
14698        let d = dep_with_fonte(DepSource::Path {
14699            caminho: "../caixa-teia!sudo".into(),
14700        });
14701        let err = d.validate().unwrap_err();
14702        let DepError::FonteCaminhoShellHistoryExpansion {
14703            nome,
14704            caminho,
14705            byte,
14706        } = err
14707        else {
14708            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14709        };
14710        assert_eq!(nome, "caixa-teia");
14711        assert_eq!(caminho, "../caixa-teia!sudo");
14712        assert_eq!(byte, b'!');
14713    }
14714
14715    #[test]
14716    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14717        // The symmetric `!!` repeat-prior-command paste idiom (peer with
14718        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14719        // on `is_git_repo_url`). Pinned separately from the wrapped
14720        // `!command` shape so a future diagnostic-surface change that
14721        // only checked the leading or paired-bang position surfaces
14722        // here — the per-byte arm fires anywhere `!` appears in the
14723        // value, including at consecutive positions in the middle.
14724        let d = dep_with_fonte(DepSource::Path {
14725            caminho: "../foo!!/bar".into(),
14726        });
14727        let err = d.validate().unwrap_err();
14728        assert!(
14729            matches!(
14730                err,
14731                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14732            ),
14733            "got {err:?}",
14734        );
14735    }
14736
14737    #[test]
14738    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14739        // The English-typography enthusiasm-form paste-from-prose
14740        // idiom: an author writes `:caminho "../caixa-teia!"`
14741        // expecting the substrate to coerce it to a kebab-case slug.
14742        // Pinned separately from the `!<word>` shell-history shape so
14743        // the gate's rationale extends to the paste-from-prose surface
14744        // (the same rationale the peer `is_git_repo_url` bang arm at
14745        // 7d53c68 covers). None of the prior shell-metachar arms cover
14746        // this shape (no `!<word>` reference and no `!!` repeat), so
14747        // the arm is the sole gate on the shape.
14748        let d = dep_with_fonte(DepSource::Path {
14749            caminho: "../caixa-teia!".into(),
14750        });
14751        let err = d.validate().unwrap_err();
14752        assert!(
14753            matches!(
14754                err,
14755                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14756            ),
14757            "got {err:?}",
14758        );
14759    }
14760
14761    #[test]
14762    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14763        // The positive-control pin (peer with
14764        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14765        // on the immediate-predecessor arm): the gate targets only
14766        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14767        // A relative POSIX path carrying dashes / dots / slashes /
14768        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14769        // validate cleanly so the gate doesn't widen to a "no
14770        // printable punctuation anywhere" sweep that would defeat
14771        // the entire path-fonte author surface.
14772        let d = dep_with_fonte(DepSource::Path {
14773            caminho: "../caixa-teia/sub-dir.v2".into(),
14774        });
14775        d.validate().unwrap();
14776    }
14777
14778    #[test]
14779    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14780        // Cascade pin on the immediate-predecessor arm: a value
14781        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14782        // — the canonical "I pasted a `$HOME`-templated path adjacent
14783        // to a trailing `!sudo` history-expansion") routes through
14784        // `FonteCaminhoShellVariableExpansion` not
14785        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14786        // expansion byte is the more semantic-locating axis on
14787        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14788        // template shape is the load-bearing self-locating edit);
14789        // same cascade discipline every prior `:caminho` arm
14790        // establishes.
14791        let d = dep_with_fonte(DepSource::Path {
14792            caminho: "../foo$HOME/bar!sudo".into(),
14793        });
14794        let err = d.validate().unwrap_err();
14795        assert!(
14796            matches!(
14797                err,
14798                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14799            ),
14800            "got {err:?}",
14801        );
14802    }
14803
14804    #[test]
14805    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14806        // Cascade pin on the immediate-successor arm: a value carrying
14807        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14808        // — the canonical "I tab-completed a `!sudo`-carrying path")
14809        // routes through `FonteCaminhoShellHistoryExpansion` not
14810        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14811        // expansion byte is the more semantic-locating axis on probe-
14812        // as-both values (an author who removes the `!sudo` history
14813        // reference is likely to also tab-strip the trailing separator).
14814        let d = dep_with_fonte(DepSource::Path {
14815            caminho: "../caixa-teia!sudo/".into(),
14816        });
14817        let err = d.validate().unwrap_err();
14818        assert!(
14819            matches!(
14820                err,
14821                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14822            ),
14823            "got {err:?}",
14824        );
14825    }
14826
14827    #[test]
14828    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14829        // Diagnostic-shape pin (peer with
14830        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14831        // on the immediate-predecessor arm): the error's Display
14832        // surfaces the offending `:nome`, the offending `:caminho`
14833        // verbatim, the offending byte's hex / character form, and
14834        // names the shell-history-expansion / bang-operator footgun
14835        // explicitly so a `feira lint` run can render the diagnostic
14836        // without re-parsing.
14837        let d = dep_with_fonte(DepSource::Path {
14838            caminho: "../caixa-teia!sudo".into(),
14839        });
14840        let rendered = d.validate().unwrap_err().to_string();
14841        assert!(
14842            rendered.contains("caixa-teia"),
14843            "diagnostic must name the offending dep: {rendered}",
14844        );
14845        assert!(
14846            rendered.contains("../caixa-teia!sudo"),
14847            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14848        );
14849        assert!(
14850            rendered.contains("0x21"),
14851            "diagnostic must surface the offending byte hex: {rendered:?}",
14852        );
14853        assert!(
14854            rendered.contains("history-expansion") || rendered.contains("history expansion"),
14855            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14856        );
14857        assert!(
14858            rendered.contains("bang"),
14859            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14860        );
14861    }
14862
14863    #[test]
14864    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14865        // The fail-before-pass-after pin for the canonical paste-from-
14866        // shell-history-quick-substitution footgun on `:caminho`. An
14867        // author copies a `git clone <bad-url>` line from their terminal,
14868        // corrects it via bash's `^bad^good` quick-substitution history
14869        // operator (bash reference §9.3, `set -o histexpand` mode's
14870        // default for interactive sessions), and pastes the trailing
14871        // `^bad^good` substitution fragment into a `:caminho` value
14872        // without trimming the leading `git clone` prefix — the byte
14873        // rides into the manifest verbatim. Until this arm landed the
14874        // `^` byte silently passed every prior `:caminho` cascade arm
14875        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14876        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14877        // `%` / `$` / `!`); bash with the default `histexpand` mode
14878        // rewrites the prior command's `bad` string to `good` and re-
14879        // executes it, the paired-operator half of the `set -o
14880        // histexpand` feature the peer `!` arm already closes the prefix
14881        // half of. The peer `is_git_repo_url` axis rejects the byte at
14882        // 49e142f under the same shell-history-substitution / RFC-3986-
14883        // unwise banner.
14884        let d = dep_with_fonte(DepSource::Path {
14885            caminho: "../foo^bad^good".into(),
14886        });
14887        let err = d.validate().unwrap_err();
14888        let DepError::FonteCaminhoShellHistorySubstitution {
14889            nome,
14890            caminho,
14891            byte,
14892        } = err
14893        else {
14894            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14895        };
14896        assert_eq!(nome, "caixa-teia");
14897        assert_eq!(caminho, "../foo^bad^good");
14898        assert_eq!(byte, b'^');
14899    }
14900
14901    #[test]
14902    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14903        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14904        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14905        // on `is_git_repo_url`). An author copies a `grep '^archived'`
14906        // regex-anchor / negation idiom from a doc snippet and the byte
14907        // rides in verbatim. Pinned separately from the `^old^new^`
14908        // quick-substitution shape so a future diagnostic-surface change
14909        // that only checked the paired-caret history-substitution
14910        // position surfaces here — the per-byte arm fires anywhere `^`
14911        // appears in the value, including at a solitary leading-of-
14912        // segment position.
14913        let d = dep_with_fonte(DepSource::Path {
14914            caminho: "../foo/^archived".into(),
14915        });
14916        let err = d.validate().unwrap_err();
14917        assert!(
14918            matches!(
14919                err,
14920                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14921            ),
14922            "got {err:?}",
14923        );
14924    }
14925
14926    #[test]
14927    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14928        // The trailing-`^` history-substitution-open shape — an author
14929        // starts typing a `^bad^good` quick-substitution but pastes only
14930        // the leading `^` sentinel before context-switching (a bash-
14931        // reference §9.3 valid histexpand prefix on its own — even a
14932        // solitary `^` on the prior command's whole re-execution shape).
14933        // Pinned separately from the `^old^new^` full-form and the leading-
14934        // of-segment `^archived` regex-anchor shape so the gate's
14935        // rationale extends to the paste-from-shell-history-with-only-
14936        // the-first-byte-selected surface. None of the prior shell-
14937        // metachar arms cover this shape.
14938        let d = dep_with_fonte(DepSource::Path {
14939            caminho: "../caixa-teia^".into(),
14940        });
14941        let err = d.validate().unwrap_err();
14942        assert!(
14943            matches!(
14944                err,
14945                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14946            ),
14947            "got {err:?}",
14948        );
14949    }
14950
14951    #[test]
14952    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14953        // The positive-control pin (peer with
14954        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14955        // on the immediate-predecessor arm): the gate targets only
14956        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14957        // A relative POSIX path carrying dashes / dots / slashes /
14958        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14959        // continue to validate cleanly so the gate doesn't widen to
14960        // a "no printable punctuation anywhere" sweep that would
14961        // defeat the entire path-fonte author surface.
14962        let d = dep_with_fonte(DepSource::Path {
14963            caminho: "../caixa-teia/sub_v2.rc".into(),
14964        });
14965        d.validate().unwrap();
14966    }
14967
14968    #[test]
14969    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14970        // Cascade pin on the immediate-predecessor arm: a value carrying
14971        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14972        // canonical "I pasted a `!sudo` history-reference next to a
14973        // `^bad^good` quick-substitution") routes through
14974        // `FonteCaminhoShellHistoryExpansion` not
14975        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14976        // the more semantic-locating axis on probe-as-both values (an
14977        // author who removes the `!sudo` reference is likely to also
14978        // strip the paired `^` substitution fragment); same cascade
14979        // discipline every prior `:caminho` arm establishes.
14980        let d = dep_with_fonte(DepSource::Path {
14981            caminho: "../foo!sudo^bad^good".into(),
14982        });
14983        let err = d.validate().unwrap_err();
14984        assert!(
14985            matches!(
14986                err,
14987                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14988            ),
14989            "got {err:?}",
14990        );
14991    }
14992
14993    #[test]
14994    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14995        // Cascade pin on the immediate-successor arm: a value carrying
14996        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14997        // the canonical "I tab-completed a `^bad^good`-carrying path")
14998        // routes through `FonteCaminhoShellHistorySubstitution` not
14999        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15000        // substitution byte is the more semantic-locating axis on probe-
15001        // as-both values (an author who removes the `^bad^good`
15002        // substitution fragment is likely to also tab-strip the trailing
15003        // separator).
15004        let d = dep_with_fonte(DepSource::Path {
15005            caminho: "../foo^bad^good/".into(),
15006        });
15007        let err = d.validate().unwrap_err();
15008        assert!(
15009            matches!(
15010                err,
15011                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15012            ),
15013            "got {err:?}",
15014        );
15015    }
15016
15017    #[test]
15018    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15019    {
15020        // Diagnostic-shape pin (peer with
15021        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15022        // on the immediate-predecessor arm): the error's Display
15023        // surfaces the offending `:nome`, the offending `:caminho`
15024        // verbatim, the offending byte's hex form, and names the
15025        // shell-history-substitution / RFC-3986-'unwise' / regex-
15026        // negation footgun explicitly so a `feira lint` run can render
15027        // the diagnostic without re-parsing.
15028        let d = dep_with_fonte(DepSource::Path {
15029            caminho: "../foo^bad^good".into(),
15030        });
15031        let rendered = d.validate().unwrap_err().to_string();
15032        assert!(
15033            rendered.contains("caixa-teia"),
15034            "diagnostic must name the offending dep: {rendered}",
15035        );
15036        assert!(
15037            rendered.contains("../foo^bad^good"),
15038            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15039        );
15040        assert!(
15041            rendered.contains("0x5e") || rendered.contains("0x5E"),
15042            "diagnostic must surface the offending byte hex: {rendered:?}",
15043        );
15044        assert!(
15045            rendered.contains("history-substitution") || rendered.contains("history substitution"),
15046            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15047        );
15048        assert!(
15049            rendered.contains("unwise"),
15050            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15051        );
15052    }
15053
15054    #[test]
15055    fn fonte_repo_empty_fires_before_pin_missing() {
15056        // Order pin: empty `:repo` is the more self-locating diagnostic
15057        // (every git source needs a repo; the pin discussion is
15058        // secondary), so it fires before the pin-missing arm even when
15059        // both are violated. Mirrors the
15060        // `nome_empty_takes_precedence_over_versao_invalid` ordering
15061        // discipline on the per-entry layer.
15062        let d = dep_with_fonte(DepSource::Git {
15063            repo: String::new(),
15064            tag: None,
15065            rev: None,
15066            branch: None,
15067        });
15068        let err = d.validate().unwrap_err();
15069        assert!(
15070            matches!(err, DepError::FonteRepoEmpty { .. }),
15071            "got {err:?}"
15072        );
15073    }
15074
15075    #[test]
15076    fn fonte_pin_missing_fires_before_pin_empty() {
15077        // Order pin: a fully-None pin set is structurally distinct from
15078        // a Some(empty) pin — the first surfaces as FontePinMissing
15079        // (no axis chosen), the second as FontePinEmpty (axis chosen
15080        // but value blank). Pin the disjoint relationship so a future
15081        // unification collapses to one variant only as a structural
15082        // decision.
15083        let d = dep_with_fonte(DepSource::Git {
15084            repo: "github:pleme-io/caixa-teia".into(),
15085            tag: None,
15086            rev: None,
15087            branch: None,
15088        });
15089        assert!(matches!(
15090            d.validate().unwrap_err(),
15091            DepError::FontePinMissing { .. }
15092        ));
15093    }
15094
15095    #[test]
15096    fn nome_empty_takes_precedence_over_fonte_invalid() {
15097        // Order pin: a per-entry diagnostic without a non-empty :nome
15098        // can't be self-locating, so :nome "" fires first even when
15099        // :fonte is also malformed. Mirrors
15100        // `nome_empty_takes_precedence_over_versao_invalid` on the
15101        // adjacent axis.
15102        let mut d = dep_with_fonte(DepSource::Git {
15103            repo: String::new(),
15104            tag: None,
15105            rev: None,
15106            branch: None,
15107        });
15108        d.nome = String::new();
15109        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15110    }
15111
15112    #[test]
15113    fn versao_invalid_takes_precedence_over_fonte_invalid() {
15114        // Order pin: the :versao parse-side diagnostic is narrower than
15115        // the :fonte shape diagnostic — a malformed :versao always names
15116        // the parser's reason, which is more actionable than the
15117        // :fonte gate's "the pins are wrong" wording. Pin the ordering
15118        // so a re-ordering surfaces here.
15119        let mut d = dep_with_fonte(DepSource::Git {
15120            repo: String::new(),
15121            tag: None,
15122            rev: None,
15123            branch: None,
15124        });
15125        d.versao = "v0.1".into();
15126        let err = d.validate().unwrap_err();
15127        assert!(
15128            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15129            "got {err:?}"
15130        );
15131    }
15132
15133    #[test]
15134    fn fonte_invalid_diagnostic_carries_offending_nome() {
15135        // The diagnostic-shape pin: every :fonte error variant names
15136        // the offending dep's :nome verbatim, so the author can grep
15137        // caixa.lisp for the `:nome "<n>"` block and fix it in one
15138        // edit. Cover all seven variants so a future variant addition
15139        // forces a parallel diagnostic-shape decision.
15140        for (case, fonte) in [
15141            (
15142                "repo-empty",
15143                DepSource::Git {
15144                    repo: String::new(),
15145                    tag: Some("v1".into()),
15146                    rev: None,
15147                    branch: None,
15148                },
15149            ),
15150            (
15151                "repo-shape",
15152                DepSource::Git {
15153                    repo: "github:p/x ".into(),
15154                    tag: Some("v1".into()),
15155                    rev: None,
15156                    branch: None,
15157                },
15158            ),
15159            (
15160                "pin-missing",
15161                DepSource::Git {
15162                    repo: "github:p/x".into(),
15163                    tag: None,
15164                    rev: None,
15165                    branch: None,
15166                },
15167            ),
15168            (
15169                "pin-ambiguous",
15170                DepSource::Git {
15171                    repo: "github:p/x".into(),
15172                    tag: Some("v1".into()),
15173                    rev: None,
15174                    branch: Some("main".into()),
15175                },
15176            ),
15177            (
15178                "pin-empty",
15179                DepSource::Git {
15180                    repo: "github:p/x".into(),
15181                    tag: Some(String::new()),
15182                    rev: None,
15183                    branch: None,
15184                },
15185            ),
15186            (
15187                "caminho-empty",
15188                DepSource::Path {
15189                    caminho: String::new(),
15190                },
15191            ),
15192            (
15193                "caminho-absolute",
15194                DepSource::Path {
15195                    caminho: "/home/me/work/caixa-teia".into(),
15196                },
15197            ),
15198        ] {
15199            let d = dep_with_fonte(fonte);
15200            let msg = d
15201                .validate()
15202                .expect_err(&format!("{case}: expected fonte error"))
15203                .to_string();
15204            assert!(
15205                msg.contains("\"caixa-teia\""),
15206                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15207            );
15208        }
15209    }
15210
15211    // -- :tag / :branch value-shape gate ----------------------------------
15212
15213    #[test]
15214    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15215        // The canonical paste-from-doc footgun on `:tag` — author
15216        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15217        // paragraph. Until this gate landed the empty-pin arm passed
15218        // (the string isn't empty), the resolver issued
15219        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15220        // surfaced at clone time with a quoting-confused git error
15221        // far from the source caixa.lisp. The new gate moves the
15222        // check to caixa-build time and names the offending dep +
15223        // pin + value verbatim.
15224        let d = dep_with_fonte(DepSource::Git {
15225            repo: "github:pleme-io/caixa-teia".into(),
15226            tag: Some("v0.1.0 ".into()),
15227            rev: None,
15228            branch: None,
15229        });
15230        let err = d.validate().unwrap_err();
15231        let DepError::FontePinShape {
15232            nome,
15233            pin,
15234            value,
15235            reason,
15236        } = err
15237        else {
15238            panic!("expected FontePinShape, got other variant");
15239        };
15240        assert_eq!(nome, "caixa-teia");
15241        assert_eq!(pin, ":tag");
15242        assert_eq!(value, "v0.1.0 ");
15243        assert!(
15244            reason.contains("whitespace"),
15245            "reason must surface the whitespace arm, got {reason:?}"
15246        );
15247    }
15248
15249    #[test]
15250    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15251        // The `.lock` suffix is git's atomic-rename guard for
15252        // in-flight ref updates — a refname ending in `.lock` is
15253        // unwritable on disk. Pinned separately from the whitespace
15254        // arm so a future relaxation that admits one but not the
15255        // other surfaces here.
15256        let d = dep_with_fonte(DepSource::Git {
15257            repo: "github:pleme-io/caixa-teia".into(),
15258            tag: Some("v0.1.0.lock".into()),
15259            rev: None,
15260            branch: None,
15261        });
15262        let err = d.validate().unwrap_err();
15263        let DepError::FontePinShape {
15264            pin, value, reason, ..
15265        } = err
15266        else {
15267            panic!("expected FontePinShape, got other variant");
15268        };
15269        assert_eq!(pin, ":tag");
15270        assert_eq!(value, "v0.1.0.lock");
15271        assert!(
15272            reason.contains(".lock"),
15273            "reason must surface the .lock arm, got {reason:?}"
15274        );
15275    }
15276
15277    #[test]
15278    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15279        // The canonical "branch name with spaces" footgun (`feature
15280        // foo`, `release branch`) — git's refname parser rejects raw
15281        // whitespace, and the failure surfaces at `git checkout
15282        // 'feature foo'` time with a quoting-confused error far from
15283        // the source caixa.lisp. Pinned on the `:branch` axis so the
15284        // gate-applies-to-both-:tag-and-:branch contract is a build-
15285        // error to relax.
15286        let d = dep_with_fonte(DepSource::Git {
15287            repo: "github:pleme-io/caixa-teia".into(),
15288            tag: None,
15289            rev: None,
15290            branch: Some("feature/foo bar".into()),
15291        });
15292        let err = d.validate().unwrap_err();
15293        let DepError::FontePinShape {
15294            pin, value, reason, ..
15295        } = err
15296        else {
15297            panic!("expected FontePinShape, got other variant");
15298        };
15299        assert_eq!(pin, ":branch");
15300        assert_eq!(value, "feature/foo bar");
15301        assert!(
15302            reason.contains("whitespace"),
15303            "reason must surface the whitespace arm, got {reason:?}"
15304        );
15305    }
15306
15307    #[test]
15308    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15309        // The `refs/heads/main` shape — the canonical "I copied the
15310        // fully-qualified ref out of `git show-ref` instead of the
15311        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15312        // at clone time, so this resolves to a literal ref named
15313        // `refs/heads/refs/heads/main` on disk; the silent double-
15314        // prefix is the load-bearing reason to gate at validate.
15315        // The diagnostic must enumerate the leaf the author probably
15316        // meant (`"main"`) so the fix is one edit.
15317        let d = dep_with_fonte(DepSource::Git {
15318            repo: "github:pleme-io/caixa-teia".into(),
15319            tag: None,
15320            rev: None,
15321            branch: Some("refs/heads/main".into()),
15322        });
15323        let err = d.validate().unwrap_err();
15324        let DepError::FontePinShape {
15325            pin, value, reason, ..
15326        } = err
15327        else {
15328            panic!("expected FontePinShape, got other variant");
15329        };
15330        assert_eq!(pin, ":branch");
15331        assert_eq!(value, "refs/heads/main");
15332        assert!(
15333            reason.contains("fully-qualified"),
15334            "reason must surface the qualified-prefix arm, got {reason:?}"
15335        );
15336        assert!(
15337            reason.contains("\"main\""),
15338            "reason must quote the leaf the author probably meant, got {reason:?}"
15339        );
15340    }
15341
15342    #[test]
15343    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15344        // Sibling arm of the qualified-prefix gate on the `:tag`
15345        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15346        // footgun). Pinned separately so a future relaxation that
15347        // only catches the `:branch` arm surfaces here.
15348        let d = dep_with_fonte(DepSource::Git {
15349            repo: "github:pleme-io/caixa-teia".into(),
15350            tag: Some("refs/tags/v0.1.0".into()),
15351            rev: None,
15352            branch: None,
15353        });
15354        let err = d.validate().unwrap_err();
15355        let DepError::FontePinShape {
15356            pin, value, reason, ..
15357        } = err
15358        else {
15359            panic!("expected FontePinShape, got other variant");
15360        };
15361        assert_eq!(pin, ":tag");
15362        assert_eq!(value, "refs/tags/v0.1.0");
15363        assert!(
15364            reason.contains("fully-qualified"),
15365            "reason must surface the qualified-prefix arm, got {reason:?}"
15366        );
15367        assert!(
15368            reason.contains("\"v0.1.0\""),
15369            "reason must quote the leaf the author probably meant, got {reason:?}"
15370        );
15371    }
15372
15373    #[test]
15374    fn validate_rejects_git_fonte_with_branch_named_at() {
15375        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15376        // unsourceable. Pinned so a future relaxation that admits
15377        // any single-character refname surfaces here.
15378        let d = dep_with_fonte(DepSource::Git {
15379            repo: "github:pleme-io/caixa-teia".into(),
15380            tag: None,
15381            rev: None,
15382            branch: Some("@".into()),
15383        });
15384        let err = d.validate().unwrap_err();
15385        let DepError::FontePinShape { pin, value, .. } = err else {
15386            panic!("expected FontePinShape, got other variant");
15387        };
15388        assert_eq!(pin, ":branch");
15389        assert_eq!(value, "@");
15390    }
15391
15392    #[test]
15393    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15394        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15395        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15396        // passes parse and surfaces as a refname-parse error or, on
15397        // older git, a literal `../escape` checkout that escapes the
15398        // refs/ directory tree. Pinned separately from the
15399        // qualified-prefix arm so a future relaxation that catches
15400        // one but not the other surfaces here.
15401        let d = dep_with_fonte(DepSource::Git {
15402            repo: "github:pleme-io/caixa-teia".into(),
15403            tag: Some("../escape".into()),
15404            rev: None,
15405            branch: None,
15406        });
15407        let err = d.validate().unwrap_err();
15408        let DepError::FontePinShape { pin, value, .. } = err else {
15409            panic!("expected FontePinShape, got other variant");
15410        };
15411        assert_eq!(pin, ":tag");
15412        assert_eq!(value, "../escape");
15413    }
15414
15415    #[test]
15416    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15417        // The positive-control pin: hierarchical refnames with one or
15418        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15419        // canonical idiom) round-trip through the gate. Pinned
15420        // separately from the leaf-`"main"` positive control so a
15421        // future tightening that rejects all multi-component refnames
15422        // surfaces here.
15423        let d = dep_with_fonte(DepSource::Git {
15424            repo: "github:pleme-io/caixa-teia".into(),
15425            tag: None,
15426            rev: None,
15427            branch: Some("feature/checkout-rewrite".into()),
15428        });
15429        d.validate().unwrap();
15430    }
15431
15432    #[test]
15433    fn validate_accepts_git_fonte_with_prerelease_tag() {
15434        // The positive-control pin: semver pre-release shape
15435        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15436        // (only consecutive `..` and trailing `.` are rejected), the
15437        // mid-component hyphen is allowed. Pinned separately from
15438        // the bare-`"v0.1.0"` positive control so a future tightening
15439        // that rejects pre-release tags surfaces here.
15440        let d = dep_with_fonte(DepSource::Git {
15441            repo: "github:pleme-io/caixa-teia".into(),
15442            tag: Some("v0.1.0-alpha.1".into()),
15443            rev: None,
15444            branch: None,
15445        });
15446        d.validate().unwrap();
15447    }
15448
15449    #[test]
15450    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15451        // The `:rev` axis is routed through `crate::render::is_git_oid`
15452        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15453        // value with refname-shape punctuation (here, a `:` mid-string
15454        // — would be a refname violation under `is_git_ref_name` too)
15455        // is rejected at the OID-shape gate. The two predicates
15456        // partition the `:fonte` pin axes structurally: an `:rev` value
15457        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15458        // *still* rejected here because every refname character outside
15459        // `[0-9a-f]` fails the OID gate. Same shape as
15460        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15461        // on the refname-shaped axes — the diagnostic names the
15462        // offending dep + pin + value verbatim. The flip-from-accept
15463        // case the prior `:tag`/`:branch` gate left as a "future axis"
15464        // (e70d213) — now landed.
15465        let d = dep_with_fonte(DepSource::Git {
15466            repo: "github:pleme-io/caixa-teia".into(),
15467            tag: None,
15468            rev: Some("c0ffee:notarefname".into()),
15469            branch: None,
15470        });
15471        let err = d.validate().unwrap_err();
15472        let DepError::FontePinShape {
15473            nome,
15474            pin,
15475            value,
15476            reason,
15477        } = err
15478        else {
15479            panic!("expected FontePinShape, got other variant");
15480        };
15481        assert_eq!(nome, "caixa-teia");
15482        assert_eq!(pin, ":rev");
15483        assert_eq!(value, "c0ffee:notarefname");
15484        assert!(
15485            !reason.is_empty(),
15486            "FontePinShape `reason` must carry the predicate's wording verbatim"
15487        );
15488    }
15489
15490    #[test]
15491    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15492        // The positive-control pin on the SHA-1 OID width: exactly 40
15493        // lowercase hex characters — the canonical `git rev-parse HEAD`
15494        // emission on a SHA-1-hashed repository (the default on every
15495        // pre-2.42 git and the canonical pleme-io substrate hash).
15496        // Pinned separately from the SHA-256 positive control so a
15497        // future tightening that only admits one width surfaces here.
15498        let d = dep_with_fonte(DepSource::Git {
15499            repo: "github:pleme-io/caixa-teia".into(),
15500            tag: None,
15501            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15502            branch: None,
15503        });
15504        d.validate().unwrap();
15505    }
15506
15507    #[test]
15508    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15509        // The positive-control pin on the SHA-256 OID width: exactly
15510        // 64 lowercase hex characters — `git`'s
15511        // `extensions.objectFormat = sha256` emission (GA since Git
15512        // 2.42 / Oct 2023). The substrate admits either canonical
15513        // width so an `:rev` authored against a SHA-256-hashed
15514        // upstream round-trips through the gate without per-repo
15515        // configuration. Pinned separately from the SHA-1 positive
15516        // control so a future tightening that drops one width surfaces
15517        // here as a structural decision.
15518        let d = dep_with_fonte(DepSource::Git {
15519            repo: "github:pleme-io/caixa-teia".into(),
15520            tag: None,
15521            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15522            branch: None,
15523        });
15524        d.validate().unwrap();
15525    }
15526
15527    #[test]
15528    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15529        // The canonical `git log --short` / `git rev-parse --short HEAD`
15530        // paste-from-release-notes footgun: a 7-char prefix (git's
15531        // default `core.abbrev`) silently passes string emptiness
15532        // checks and resolves to one commit today, but becomes ambiguous
15533        // tomorrow as the repo grows. Until this gate landed the empty-
15534        // pin arm passed (the string isn't empty) and the resolver
15535        // accepted the prefix through git's separate prefix-lookup pass
15536        // — defeating the reproducibility contract `:rev` carries vs.
15537        // `:tag` / `:branch`. The new gate moves the check to caixa-
15538        // build time and names the offending dep + pin + value verbatim.
15539        let d = dep_with_fonte(DepSource::Git {
15540            repo: "github:pleme-io/caixa-teia".into(),
15541            tag: None,
15542            rev: Some("c0ffee0".into()),
15543            branch: None,
15544        });
15545        let err = d.validate().unwrap_err();
15546        let DepError::FontePinShape {
15547            pin, value, reason, ..
15548        } = err
15549        else {
15550            panic!("expected FontePinShape, got other variant");
15551        };
15552        assert_eq!(pin, ":rev");
15553        assert_eq!(value, "c0ffee0");
15554        assert!(
15555            reason.contains("abbreviated") || reason.contains("ambiguous"),
15556            "reason must surface the abbreviation arm, got {reason:?}"
15557        );
15558    }
15559
15560    #[test]
15561    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15562        // The canonical "I pasted the SHA in uppercase" footgun: `git
15563        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15564        // bearing `:rev` round-trips inconsistently across the
15565        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15566        // equality-check pipeline and fails the lacre's content-
15567        // addressing probe with a confusing case-only diff. Pinned
15568        // separately from the non-hex arm so a future relaxation that
15569        // admits one but not the other surfaces here.
15570        let d = dep_with_fonte(DepSource::Git {
15571            repo: "github:pleme-io/caixa-teia".into(),
15572            tag: None,
15573            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15574            branch: None,
15575        });
15576        let err = d.validate().unwrap_err();
15577        let DepError::FontePinShape {
15578            pin, value, reason, ..
15579        } = err
15580        else {
15581            panic!("expected FontePinShape, got other variant");
15582        };
15583        assert_eq!(pin, ":rev");
15584        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15585        assert!(
15586            reason.contains("uppercase"),
15587            "reason must surface the uppercase arm, got {reason:?}"
15588        );
15589    }
15590
15591    #[test]
15592    fn validate_rejects_git_fonte_with_rev_refname_value() {
15593        // The cross-axis mis-slot footgun: `:rev "main"` — the author
15594        // conflated `:rev` (hex commit ID, immutable) and `:branch`
15595        // (mutable ref pointing at whatever HEAD is today). Until this
15596        // gate landed the resolver silently dispatched on the value
15597        // shape ("`main` doesn't look like a SHA, fall back to
15598        // refname"), defeating the `:rev` reproducibility contract.
15599        // The new gate rejects every non-hex value on the `:rev` axis,
15600        // so the `:rev`/`:branch` boundary is structurally enforced —
15601        // a refname in the `:rev` slot is a build error, not a
15602        // resolver-time silent reinterpretation.
15603        let d = dep_with_fonte(DepSource::Git {
15604            repo: "github:pleme-io/caixa-teia".into(),
15605            tag: None,
15606            rev: Some("main".into()),
15607            branch: None,
15608        });
15609        let err = d.validate().unwrap_err();
15610        let DepError::FontePinShape {
15611            pin, value, reason, ..
15612        } = err
15613        else {
15614            panic!("expected FontePinShape, got other variant");
15615        };
15616        assert_eq!(pin, ":rev");
15617        assert_eq!(value, "main");
15618        // 4 chars `main` fails the length arm before the character arm,
15619        // so the diagnostic surfaces the abbreviation wording (same
15620        // path the `c0ffee0` 7-char fixture lands on); the structural
15621        // assertion is just that the `:rev "main"` value is rejected.
15622        assert!(
15623            !reason.is_empty(),
15624            "FontePinShape reason must be non-empty for refname-shaped :rev"
15625        );
15626    }
15627
15628    #[test]
15629    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15630        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15631        // conflated `:rev` and `:tag`. Pinned separately from the
15632        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15633        // that catches one but not the other surfaces here. The
15634        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15635        // assertion is just that the cross-axis mis-slot is a build
15636        // error, regardless of which sub-arm surfaces the diagnostic
15637        // (`is_git_oid` rejects at the first violation; longer
15638        // tag-shape values would hit the non-hex arm instead).
15639        let d = dep_with_fonte(DepSource::Git {
15640            repo: "github:pleme-io/caixa-teia".into(),
15641            tag: None,
15642            rev: Some("v0.1.0".into()),
15643            branch: None,
15644        });
15645        let err = d.validate().unwrap_err();
15646        let DepError::FontePinShape {
15647            pin, value, reason, ..
15648        } = err
15649        else {
15650            panic!("expected FontePinShape, got other variant");
15651        };
15652        assert_eq!(pin, ":rev");
15653        assert_eq!(value, "v0.1.0");
15654        assert!(
15655            !reason.is_empty(),
15656            "FontePinShape reason must be non-empty for tag-shaped :rev"
15657        );
15658    }
15659
15660    #[test]
15661    fn validate_rejects_git_fonte_with_rev_too_long() {
15662        // Boundary case on the upper end: 41 hex chars — one past the
15663        // SHA-1 width, well below the SHA-256 width. Pin so a future
15664        // relaxation that admits "long enough to be a SHA" without
15665        // matching either canonical width surfaces here. The diagnostic
15666        // names the offending length verbatim so the author's grep
15667        // target is unambiguous (either trim one char or paste the
15668        // full SHA-256).
15669        let too_long: String = "0".repeat(41);
15670        let d = dep_with_fonte(DepSource::Git {
15671            repo: "github:pleme-io/caixa-teia".into(),
15672            tag: None,
15673            rev: Some(too_long.clone()),
15674            branch: None,
15675        });
15676        let err = d.validate().unwrap_err();
15677        let DepError::FontePinShape {
15678            pin, value, reason, ..
15679        } = err
15680        else {
15681            panic!("expected FontePinShape, got other variant");
15682        };
15683        assert_eq!(pin, ":rev");
15684        assert_eq!(value, too_long);
15685        assert!(
15686            reason.contains("41"),
15687            "reason must surface the offending length verbatim, got {reason:?}"
15688        );
15689    }
15690
15691    #[test]
15692    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15693        // The canonical paste-from-doc footgun on `:rev` — author
15694        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15695        // commit-message paragraph. Until this gate landed the empty-
15696        // pin arm passed (the string isn't empty), the resolver issued
15697        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15698        // clone time with a quoting-confused git error far from the
15699        // source caixa.lisp. The new gate moves the check to caixa-
15700        // build time. Length is 41 (40 hex + space) so the length arm
15701        // fires first — pinned separately from the pure-length arm to
15702        // ensure the diagnostic surfaces *some* parser wording, not
15703        // silently pass through.
15704        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15705        let d = dep_with_fonte(DepSource::Git {
15706            repo: "github:pleme-io/caixa-teia".into(),
15707            tag: None,
15708            rev: Some(with_space.clone()),
15709            branch: None,
15710        });
15711        let err = d.validate().unwrap_err();
15712        let DepError::FontePinShape {
15713            pin, value, reason, ..
15714        } = err
15715        else {
15716            panic!("expected FontePinShape, got other variant");
15717        };
15718        assert_eq!(pin, ":rev");
15719        assert_eq!(value, with_space);
15720        assert!(
15721            !reason.is_empty(),
15722            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15723        );
15724    }
15725
15726    #[test]
15727    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15728        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15729        // variant on this axis names the offending dep's `:nome` + the
15730        // `:rev` axis + the offending value verbatim, so the author's
15731        // grep target is the literal `:rev "<value>"` block in
15732        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15733        // carries_offending_nome_pin_value` test on the refname-shaped
15734        // (`:tag` / `:branch`) axes.
15735        let d = dep_with_fonte(DepSource::Git {
15736            repo: "github:p/x".into(),
15737            tag: None,
15738            rev: Some("not-a-sha".into()),
15739            branch: None,
15740        });
15741        let msg = d
15742            .validate()
15743            .expect_err(":rev: expected FontePinShape")
15744            .to_string();
15745        assert!(
15746            msg.contains("\"caixa-teia\""),
15747            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15748        );
15749        assert!(
15750            msg.contains(":rev"),
15751            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15752        );
15753        assert!(
15754            msg.contains("not-a-sha"),
15755            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15756        );
15757    }
15758
15759    #[test]
15760    fn fonte_pin_empty_fires_before_pin_shape() {
15761        // Order pin: a `Some("")` `:tag` is the more self-locating
15762        // diagnostic (the author chose an axis but left it blank;
15763        // grep is unambiguous), so it fires before the shape gate
15764        // even when both arms would match. Pinned so a future
15765        // reordering surfaces here. Mirrors the
15766        // `fonte_repo_empty_fires_before_pin_missing` ordering
15767        // discipline on the peer per-axis arms.
15768        let d = dep_with_fonte(DepSource::Git {
15769            repo: "github:pleme-io/caixa-teia".into(),
15770            tag: Some(String::new()),
15771            rev: None,
15772            branch: None,
15773        });
15774        assert!(matches!(
15775            d.validate().unwrap_err(),
15776            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15777        ));
15778    }
15779
15780    #[test]
15781    fn fonte_pin_shape_fires_after_repo_empty() {
15782        // Order pin: `:repo ""` is the more self-locating axis
15783        // (every git source needs a repo; the per-pin shape gate is
15784        // secondary), so the repo-empty arm fires before the
15785        // per-pin shape arm even when both are violated. Pinned so
15786        // a future reordering surfaces here. Mirrors
15787        // `fonte_repo_empty_fires_before_pin_missing` on the
15788        // adjacent axis pair.
15789        let d = dep_with_fonte(DepSource::Git {
15790            repo: String::new(),
15791            tag: Some("v0.1.0 ".into()),
15792            rev: None,
15793            branch: None,
15794        });
15795        assert!(matches!(
15796            d.validate().unwrap_err(),
15797            DepError::FonteRepoEmpty { .. }
15798        ));
15799    }
15800
15801    #[test]
15802    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15803        // Diagnostic-shape pin across both refname-shaped axes
15804        // (`:tag` + `:branch`): every `FontePinShape` variant names
15805        // the offending dep's `:nome` + the offending pin axis + the
15806        // offending value verbatim, so the author's grep target is
15807        // unambiguous (the literal `:tag "<value>"` / `:branch
15808        // "<value>"` lands in caixa.lisp with quotes). Cover both
15809        // pin axes so a future variant addition forces a parallel
15810        // diagnostic-shape decision.
15811        for (pin_label, fonte) in [
15812            (
15813                ":tag",
15814                DepSource::Git {
15815                    repo: "github:p/x".into(),
15816                    tag: Some("v0.1.0~1".into()),
15817                    rev: None,
15818                    branch: None,
15819                },
15820            ),
15821            (
15822                ":branch",
15823                DepSource::Git {
15824                    repo: "github:p/x".into(),
15825                    tag: None,
15826                    rev: None,
15827                    branch: Some("feature/foo*".into()),
15828                },
15829            ),
15830        ] {
15831            let d = dep_with_fonte(fonte);
15832            let msg = d
15833                .validate()
15834                .expect_err(&format!("{pin_label}: expected FontePinShape"))
15835                .to_string();
15836            assert!(
15837                msg.contains("\"caixa-teia\""),
15838                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15839            );
15840            assert!(
15841                msg.contains(pin_label),
15842                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15843            );
15844        }
15845    }
15846
15847    #[test]
15848    fn git_source_json_round_trip() {
15849        let src = DepSource::Git {
15850            repo: "github:pleme-io/caixa-teia".into(),
15851            tag: Some("v0.1.0".into()),
15852            rev: None,
15853            branch: None,
15854        };
15855        let s = serde_json::to_string(&src).unwrap();
15856        assert!(s.contains(&format!(
15857            r#""{tipo}":"{git}""#,
15858            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15859            git = crate::render::DEP_SOURCE_TIPO_GIT,
15860        )));
15861        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15862        assert!(s.contains(r#""tag":"v0.1.0""#));
15863        assert!(!s.contains("rev"));
15864        assert!(!s.contains("branch"));
15865        let round: DepSource = serde_json::from_str(&s).unwrap();
15866        assert_eq!(round, src);
15867    }
15868
15869    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15870    //
15871    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15872    // attribute on [`DepSource`] pins three load-bearing byte-sequences
15873    // that flow into every serialized `Dep.fonte` block: the outer
15874    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15875    // the two admitted variant-tag values `"git"` / `"path"` the
15876    // `rename_all = "lowercase"` attribute pins as the discriminator's
15877    // closed-set arms. The three pin tests below round-trip a
15878    // fully-populated variant of each arm through
15879    // [`serde_json::to_value`] and assert each canonical byte-sequence
15880    // appears at its axis — pins a hypothetical future
15881    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15882    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15883    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15884    // at build time rather than at fetch time when the resolver's
15885    // `Dep.fonte` dispatch silently fails to match on the drifted
15886    // discriminator. Same "serialize-and-check" discipline the peer
15887    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15888    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15889    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15890    // family in caixa-core lacking a lifted peer.
15891
15892    #[test]
15893    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15894        // Fail-before-pass-after: a future `tag = "type"` at the derive
15895        // attribute would serialize under `"type":"git"`, and this test
15896        // would trip because `"tipo"` no longer appears at the emitted
15897        // discriminator key. A future `rename_all = "kebab-case"` /
15898        // `"snake_case"` (both no-ops on `Git` since it lacks internal
15899        // word boundaries) is caught by the sibling
15900        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15901        // pin below (Path has no internal boundary either but the pair
15902        // catches any per-arm inconsistency). A future variant rename
15903        // `Git` → `Repository` would emit `"tipo":"repository"` and
15904        // trip this pin.
15905        let src = DepSource::Git {
15906            repo: "github:pleme-io/caixa-teia".into(),
15907            tag: Some("v0.1.0".into()),
15908            rev: None,
15909            branch: None,
15910        };
15911        let json = serde_json::to_value(&src).unwrap();
15912        let obj = json.as_object().expect("Git serializes as a JSON object");
15913        assert_eq!(
15914            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15915                .and_then(serde_json::Value::as_str),
15916            Some(crate::render::DEP_SOURCE_TIPO_GIT),
15917            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15918             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15919             detected in {json}"
15920        );
15921    }
15922
15923    #[test]
15924    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15925        // Fail-before-pass-after: a future variant rename `Path` →
15926        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15927        // this pin. A per-consumer disambiguation as the `defcaixa`
15928        // macro stabilizes ("caminho" → "path" for English-uniformity)
15929        // is scoped to the inner field key, not the discriminator; this
15930        // pin is orthogonal to that and catches only the outer
15931        // discriminator drift.
15932        let src = DepSource::Path {
15933            caminho: "../caixa-teia".into(),
15934        };
15935        let json = serde_json::to_value(&src).unwrap();
15936        let obj = json.as_object().expect("Path serializes as a JSON object");
15937        assert_eq!(
15938            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15939                .and_then(serde_json::Value::as_str),
15940            Some(crate::render::DEP_SOURCE_TIPO_PATH),
15941            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15942             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15943             detected in {json}"
15944        );
15945    }
15946
15947    #[test]
15948    fn dep_source_key_consts_are_pairwise_distinct() {
15949        // Cross-axis collapse detector: a hypothetical future edit that
15950        // accidentally set two of the three consts to the same byte
15951        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15952        // pass every per-arm serialize pin above but silently collapse
15953        // the discriminator's closed-set arms onto one another; this pin
15954        // catches the collapse at build time.
15955        assert_ne!(
15956            crate::render::DEP_SOURCE_KEY_TIPO,
15957            crate::render::DEP_SOURCE_TIPO_GIT,
15958        );
15959        assert_ne!(
15960            crate::render::DEP_SOURCE_KEY_TIPO,
15961            crate::render::DEP_SOURCE_TIPO_PATH,
15962        );
15963        assert_ne!(
15964            crate::render::DEP_SOURCE_TIPO_GIT,
15965            crate::render::DEP_SOURCE_TIPO_PATH,
15966        );
15967    }
15968
15969    #[test]
15970    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15971        // Shape pin against `rename_all` drift: the two variant-tag
15972        // consts must be ASCII-lowercase-only to match the
15973        // `rename_all = "lowercase"` attribute the derive uses; a future
15974        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15975        // would emit `"GIT"` / `"Git"` instead and trip this pin.
15976        for (label, s) in [
15977            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15978            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15979        ] {
15980            assert!(!s.is_empty(), "{label} must not be empty");
15981            assert!(
15982                s.bytes().all(|b| b.is_ascii_lowercase()),
15983                "{label} must be ASCII-lowercase-only (matching \
15984                 rename_all = \"lowercase\"), got {s:?}",
15985            );
15986        }
15987    }
15988
15989    // ── per-entry :caracteristicas set-not-multiset gate ────────────
15990    //
15991    // Every Vec-keyed-by-name authoring surface on the typed Caixa
15992    // surface that identifies its entries by a name field now uniformly
15993    // closes the set-not-multiset discipline at build time (cite
15994    // `validate_caracteristicas`'s peer-axis enumeration). The
15995    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15996    // set-shaped (a feature is either enabled or not — there is no
15997    // `feature × 2` semantic), so two entries naming the same feature
15998    // are a redundant declaration the caixa-resolver's lacre pipeline
15999    // would silently dedup at resolve time. The empty-feature arm
16000    // closes the parallel "operationally-meaningless value" axis on
16001    // the same slot. Same linear-walk + `HashSet` + first-collision
16002    // shape every peer set gate uses; same empty-first cascade every
16003    // peer per-entry shape + duplicate gate uses (the empty-feature
16004    // axis is the more-actionable defect since two `""` entries would
16005    // both report `caracteristica: ""` under a duplicate-first
16006    // ordering, with no way to distinguish the offending site).
16007
16008    fn dep_with_features(features: &[&str]) -> Dep {
16009        Dep {
16010            nome: "caixa-teia".into(),
16011            versao: "^0.1".into(),
16012            fonte: None,
16013            opcional: false,
16014            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16015        }
16016    }
16017
16018    #[test]
16019    fn validate_rejects_empty_caracteristica() {
16020        // Fail-before-pass-after pin: every pre-gate codebase accepted
16021        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16022        // imposed no per-entry shape contract), the dep validated, and
16023        // the empty feature would have reached the future caixa-resolver
16024        // lacre pipeline as a no-op feature enable — silently dropping
16025        // the author's intent far from the source `caixa.lisp`. The new
16026        // gate surfaces the structural defect at the typed-validate
16027        // surface with a self-locating diagnostic naming the offending
16028        // dep's `:nome`.
16029        let d = dep_with_features(&[""]);
16030        assert!(
16031            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16032            "expected CaracteristicaEmpty, got {:?}",
16033            d.validate(),
16034        );
16035    }
16036
16037    #[test]
16038    fn validate_rejects_duplicate_caracteristica() {
16039        // Fail-before-pass-after pin on the set-not-multiset arm: the
16040        // feature-toggle slot is set-shaped, so `(:caracteristicas
16041        // ("http" "http"))` is a redundant declaration the lacre
16042        // pipeline dedupes silently at resolve time. The diagnostic
16043        // names the offending dep + the colliding feature verbatim so
16044        // the author can grep their caixa.lisp for `:caracteristicas`
16045        // and fix it in one edit. First-collision determinism is
16046        // pinned separately below.
16047        let d = dep_with_features(&["http", "http"]);
16048        assert!(
16049            matches!(
16050                d.validate().unwrap_err(),
16051                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16052                    if nome == "caixa-teia" && caracteristica == "http"
16053            ),
16054            "expected CaracteristicaDuplicate, got {:?}",
16055            d.validate(),
16056        );
16057    }
16058
16059    #[test]
16060    fn validate_accepts_distinct_caracteristicas() {
16061        // The canonical authoring shape — every feature distinct — must
16062        // remain a clean pass (positive control sweep). Covers the
16063        // canonical kebab-case feature names a target caixa typically
16064        // declares.
16065        dep_with_features(&["http", "json", "tls"])
16066            .validate()
16067            .unwrap();
16068    }
16069
16070    #[test]
16071    fn validate_accepts_single_caracteristica() {
16072        // Single-element list is the minimum non-empty shape; passes
16073        // the gate as the identity of the duplicate check (no second
16074        // entry to collide with).
16075        dep_with_features(&["http"]).validate().unwrap();
16076    }
16077
16078    #[test]
16079    fn validate_accepts_empty_caracteristicas_list() {
16080        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16081        // produces `caracteristicas: Vec::new()`; the empty list is
16082        // the gate's empty-set identity and passes vacuously. Pin
16083        // this so a future tightening that requires ≥1 feature
16084        // surfaces here as a test failure rather than a silent
16085        // contract narrowing.
16086        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16087        assert!(dep_with_features(&[]).validate().is_ok());
16088    }
16089
16090    #[test]
16091    fn validate_caracteristica_empty_fires_before_duplicate() {
16092        // Empty-first cascade: an entry with an empty feature *and*
16093        // duplicate entries surfaces the empty diagnostic first. The
16094        // empty-feature axis is the more-actionable defect since
16095        // `caracteristica: ""` is unambiguous; under duplicate-first
16096        // ordering the diagnostic could report the empty string from
16097        // either of two empty entries with no way to distinguish.
16098        // Mirrors the peer empty-before-duplicate ordering
16099        // discipline every per-entry shape + duplicate gate establishes
16100        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16101        // `DuplicateChildCaixa`, `validate_membros`'s
16102        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16103        let d = dep_with_features(&["", "http", "http"]);
16104        assert!(matches!(
16105            d.validate().unwrap_err(),
16106            DepError::CaracteristicaEmpty { .. }
16107        ));
16108    }
16109
16110    #[test]
16111    fn validate_caracteristica_duplicate_first_collision_determinism() {
16112        // Three matching entries: the second occurrence surfaces the
16113        // diagnostic (the second is the first *collision* — the first
16114        // entry is the establishing one, not a duplicate). Mirrors
16115        // every peer first-collision posture
16116        // (`SupervisorError::DuplicateChildCaixa` reports the second
16117        // collision, `AplicacaoError::MembroDuplicate` reports the
16118        // second, `DepError::DuplicateNome` reports the second).
16119        // Pinning this so a future shortcut that flips to last-
16120        // collision (or non-deterministic) surfaces here.
16121        let d = dep_with_features(&["http", "http", "http"]);
16122        assert!(matches!(
16123            d.validate().unwrap_err(),
16124            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16125        ));
16126    }
16127
16128    #[test]
16129    fn validate_per_entry_shape_fires_before_caracteristicas() {
16130        // Per-entry shape precedence: a dep with a malformed `:nome`
16131        // (uppercase) AND duplicate `:caracteristicas` surfaces the
16132        // narrower `NomeInvalid` diagnostic first, not the set-gate
16133        // diagnostic. The `:nome` is the self-locating axis (every
16134        // diagnostic from the caracteristicas gate quotes the
16135        // offending dep's `:nome` to anchor the grep target —
16136        // surfacing the malformed name first keeps that anchor
16137        // valid). Same precedence shape every peer per-entry-shape
16138        // arm establishes against its peer set-gate
16139        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16140        // on the cross-entry `:nome` axis).
16141        let d = Dep {
16142            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16143            versao: "^0.1".into(),
16144            fonte: None,
16145            opcional: false,
16146            caracteristicas: vec!["http".into(), "http".into()],
16147        };
16148        assert!(matches!(
16149            d.validate().unwrap_err(),
16150            DepError::NomeInvalid { .. }
16151        ));
16152    }
16153
16154    // ── per-entry :caracteristicas value-shape gate ──────────────────
16155    //
16156    // Until this gate landed `:caracteristicas` only refused the empty
16157    // string and cross-entry duplicates: a non-empty distinct but
16158    // structurally invalid feature name silently passed validate and the
16159    // failure surfaced at `cargo metadata` time as Cargo's
16160    // `restricted_names::validate_feature_name` parser rejection, far from
16161    // the source `caixa.lisp` with no field naming which `:deps` entry's
16162    // `:caracteristicas` carried the typo. The lifted predicate makes the
16163    // Cargo-feature-name-grammar intersection-floor a substrate-level
16164    // invariant at validate time. Same trajectory as the eight peer
16165    // value-shape predicates each typed surface downstream of a structured
16166    // grammar already follows.
16167
16168    #[test]
16169    fn validate_rejects_caracteristica_with_leading_plus() {
16170        // Fail-before-pass-after pin on the canonical Cargo
16171        // `+<feature>` activation-form-in-feature-name-slot footgun.
16172        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16173        // `+optional-feature` as an enablement of a previously-disabled
16174        // feature; pasting that activation form into `:caracteristicas`
16175        // (which names the feature itself) silently passed pre-gate and
16176        // failed at `cargo metadata` parse time.
16177        let d = dep_with_features(&["+http"]);
16178        let err = d.validate().unwrap_err();
16179        assert!(
16180            matches!(
16181                err,
16182                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16183                    if nome == "caixa-teia" && caracteristica == "+http"
16184            ),
16185            "expected CaracteristicaInvalid, got {err:?}"
16186        );
16187    }
16188
16189    #[test]
16190    fn validate_rejects_caracteristica_with_leading_hyphen() {
16191        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16192        // is a legitimate continuation character (kebab-case feature
16193        // names like `runtime-tokio` pass) but Cargo rejects it at the
16194        // start; the structural defect — and its CLI-argument-injection
16195        // adjacency at any downstream Cargo subprocess invocation — is
16196        // closed at validate time, not at `cargo metadata` time.
16197        let d = dep_with_features(&["-json"]);
16198        let err = d.validate().unwrap_err();
16199        assert!(
16200            matches!(
16201                err,
16202                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16203            ),
16204            "expected CaracteristicaInvalid, got {err:?}"
16205        );
16206    }
16207
16208    #[test]
16209    fn validate_rejects_caracteristica_with_leading_dot() {
16210        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16211        // a legitimate continuation character (version-suffix shapes
16212        // like `feat.v2` pass) but the leading-dot form is the
16213        // canonical dotted-version-suffix-as-feature-name confusion.
16214        let d = dep_with_features(&[".feat"]);
16215        let err = d.validate().unwrap_err();
16216        assert!(matches!(
16217            err,
16218            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16219        ));
16220    }
16221
16222    #[test]
16223    fn validate_rejects_caracteristica_with_whitespace() {
16224        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16225        // a feature name with a space inside is structurally a multi-
16226        // token blob (the canonical paste-from-doc footgun, or an
16227        // accidental `"http server"` where the author meant
16228        // `"http-server"`).
16229        let d = dep_with_features(&["http feature"]);
16230        let err = d.validate().unwrap_err();
16231        assert!(matches!(
16232            err,
16233            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16234        ));
16235    }
16236
16237    #[test]
16238    fn validate_rejects_caracteristica_with_comma() {
16239        // Fail-before-pass-after pin on the embedded-comma footgun:
16240        // the list-separator-belongs-to-the-list-grammar
16241        // miscomprehension where the author writes
16242        // `:caracteristicas ("http,json")` intending two features but
16243        // the `Vec<String>` field consumes the bare token as one entry.
16244        let d = dep_with_features(&["http,json"]);
16245        let err = d.validate().unwrap_err();
16246        assert!(matches!(
16247            err,
16248            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16249        ));
16250    }
16251
16252    #[test]
16253    fn validate_rejects_caracteristica_with_slash() {
16254        // Fail-before-pass-after pin on the embedded-slash footgun:
16255        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16256        // `[dependencies.<dep>.features]` list entries that already
16257        // name the parent dep (so the syntax says "enable feature
16258        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16259        // per-dep already (a sibling slot on the `Dep` itself), so the
16260        // segment separator within an entry must be `-`, `_`, `+`,
16261        // or `.`. The diagnostic remediation points at the canonical
16262        // Cargo namespaced-dep discipline.
16263        let d = dep_with_features(&["http/json"]);
16264        let err = d.validate().unwrap_err();
16265        assert!(matches!(
16266            err,
16267            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16268        ));
16269    }
16270
16271    #[test]
16272    fn validate_rejects_caracteristica_with_non_ascii() {
16273        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16274        // byte footgun: NFC-vs-NFD normalization across filesystems
16275        // silently rewrites the feature-key, breaking the lacre's
16276        // content-addressing invariant. Pinned at a canonical
16277        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16278        // documented APFS round-trip break.
16279        let d = dep_with_features(&["caf\u{e9}"]);
16280        let err = d.validate().unwrap_err();
16281        assert!(matches!(
16282            err,
16283            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16284        ));
16285    }
16286
16287    #[test]
16288    fn validate_rejects_caracteristica_with_control_character() {
16289        // Fail-before-pass-after pin on the embedded-control-character
16290        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16291        // feature name is the canonical paste-from-multiline-doc
16292        // footgun the predicate's reason wording specifically calls out.
16293        let d = dep_with_features(&["http\njson"]);
16294        let err = d.validate().unwrap_err();
16295        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16296    }
16297
16298    #[test]
16299    fn validate_accepts_canonical_caracteristicas_shapes() {
16300        // Positive control sweep: every canonical Cargo feature name
16301        // shape the pleme-io ecosystem uses must still pass. Mirrors
16302        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16303        // sweep — drift between either landing site and the predicate's
16304        // accepted set is a build error visible at this pair of tests,
16305        // not a per-renderer "this passed validate but failed at
16306        // cargo metadata time" surprise on the next acceptance.
16307        for s in [
16308            "http",
16309            "json",
16310            "derive",
16311            "serde_json",
16312            "runtime-tokio",
16313            "tokio.full",
16314            "v0.1",
16315            "http+json",
16316            "_internal",
16317            "__private",
16318            "default",
16319            "rt-multi-thread",
16320            "feat.v2",
16321        ] {
16322            let d = dep_with_features(&[s]);
16323            d.validate().unwrap_or_else(|e| {
16324                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16325            });
16326        }
16327    }
16328
16329    #[test]
16330    fn validate_caracteristica_empty_fires_before_invalid() {
16331        // Cascade precedence pin: an entry list with both an empty
16332        // feature AND an invalid-shape feature surfaces the
16333        // `CaracteristicaEmpty` arm first (the empty value carries no
16334        // self-locating data — `caracteristica: ""` is the diagnostic
16335        // with no way to anchor a grep target — so closing the empty
16336        // axis first preserves the per-entry-shape diagnostic's
16337        // self-locating discipline). Same empty-first cascade every
16338        // peer per-entry shape gate establishes
16339        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16340        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16341        // before `MembroCaixaInvalid`).
16342        let d = dep_with_features(&["", "+http"]);
16343        assert!(matches!(
16344            d.validate().unwrap_err(),
16345            DepError::CaracteristicaEmpty { .. }
16346        ));
16347    }
16348
16349    #[test]
16350    fn validate_caracteristica_invalid_fires_before_duplicate() {
16351        // Per-entry-shape precedence pin: an entry list with the same
16352        // invalid feature shape declared twice surfaces the
16353        // `CaracteristicaInvalid` diagnostic on the first entry, not
16354        // the `CaracteristicaDuplicate` on the second collision. The
16355        // per-entry shape gate fires before the cross-entry set gate
16356        // — same precedence shape every peer two-arm-plus-set gate
16357        // establishes (`SupervisorSpec::validate`'s
16358        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16359        // `validate_membros`'s `MembroCaixaInvalid` before
16360        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16361        // cross-list `DuplicateNome`).
16362        let d = dep_with_features(&["+http", "+http"]);
16363        assert!(matches!(
16364            d.validate().unwrap_err(),
16365            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16366        ));
16367    }
16368
16369    #[test]
16370    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16371        // Boundary pin on the 64-byte cap — both the boundary-accepting
16372        // case and the boundary-exceeding case in one place, so a
16373        // future cap shift surfaces both arms simultaneously, mirroring
16374        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16375        // predicate-level pin at the dep-axis landing site.
16376        let max_ok = "a".repeat(64);
16377        dep_with_features(&[&max_ok])
16378            .validate()
16379            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16380        let too_long = "a".repeat(65);
16381        let d = dep_with_features(&[&too_long]);
16382        assert!(matches!(
16383            d.validate().unwrap_err(),
16384            DepError::CaracteristicaInvalid { .. }
16385        ));
16386    }
16387
16388    // ── self-dep cross-slot gate ─────────────────────────────────────
16389
16390    #[test]
16391    fn validate_no_self_dep_rejects_self_in_deps() {
16392        // A caixa whose `:deps` lists its own `:nome` is a one-node
16393        // cycle in the lacre closure's dep-graph traversal — rejected,
16394        // naming the parent and the offending list tag.
16395        let deps = vec![
16396            Dep::simple("caixa-teia", "^0.1"),
16397            Dep::simple("orquestra", "^0.1"),
16398        ];
16399        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16400        assert!(
16401            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16402            "got {err:?}"
16403        );
16404    }
16405
16406    #[test]
16407    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16408        // Same gate on the `:deps-dev` axis — neither dep list is a
16409        // second-class citizen on the self-edge invariant.
16410        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16411        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16412        assert!(
16413            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16414            "got {err:?}"
16415        );
16416    }
16417
16418    #[test]
16419    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16420        // Walk order pin: a caixa that self-references on both lists
16421        // surfaces the `:deps` arm first — the load-bearing axis the
16422        // lacre closure resolves at every build. Mirrors the canonical
16423        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16424        let deps = vec![Dep::simple("orquestra", "^0.1")];
16425        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16426        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16427        assert!(
16428            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16429            "got {err:?}"
16430        );
16431    }
16432
16433    #[test]
16434    fn validate_no_self_dep_accepts_distinct_names() {
16435        // Positive control: every dep names a distinct caixa. The
16436        // canonical author surface — peer of
16437        // [`validate_no_self_supervision_accepts_distinct_children`].
16438        let deps = vec![
16439            Dep::simple("caixa-teia", "^0.1"),
16440            Dep::simple("caixa-arch", "^0.1"),
16441        ];
16442        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16443        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16444    }
16445
16446    #[test]
16447    fn validate_no_self_dep_empty_lists_pass() {
16448        // A caixa with no declared deps has nothing to self-reference —
16449        // the gate is vacuously satisfied. Peer of
16450        // [`validate_no_self_supervision_empty_children_is_ok`].
16451        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16452    }
16453
16454    #[test]
16455    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16456        // Diagnostic-shape pin (peer with
16457        // [`validate_no_self_supervision`]'s diagnostic): the error's
16458        // Display surfaces both the offending list tag and the
16459        // parent's `:nome` verbatim, so the author can grep their
16460        // caixa.lisp for the offending block in one edit. Names
16461        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16462        // surface — every legitimate "I want to use code from this
16463        // caixa" intent routes through one of those three slots.
16464        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16465        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16466            .unwrap_err()
16467            .to_string();
16468        assert!(
16469            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16470            "diagnostic must name the offending list tag: {rendered}",
16471        );
16472        assert!(
16473            rendered.contains("orquestra"),
16474            "diagnostic must quote the parent caixa name: {rendered}",
16475        );
16476        assert!(
16477            rendered.contains(":bibliotecas"),
16478            "diagnostic must point at the corrective code-surface slot: {rendered}",
16479        );
16480    }
16481
16482    #[test]
16483    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16484        // Identity is exact-string equality, not substring — a dep
16485        // named `"orquestra-helper"` is a distinct caixa even when the
16486        // parent is `"orquestra"`. Pin the exact-match discipline so a
16487        // future relaxation that uses `contains` surfaces here, peer
16488        // with the supervision-tree and Aplicacao-membership gates
16489        // which all use exact-string equality on the typed identity.
16490        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16491        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16492    }
16493
16494    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16495
16496    #[test]
16497    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16498        // Scalar-value pin: the two author-facing kebab-case labels the
16499        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16500        // the two-list dep-graph slot axis, one arm per typed slot.
16501        // Mirrors the peer scalar-value pin the sibling
16502        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16503        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16504        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16505        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16506        // (882f498) M3 top-level author-labels, and
16507        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16508        // Supervisor top-level author-labels carry, so every kind-scoped
16509        // typed-slot-family axis routes through one canonical per-arm
16510        // declaration.
16511        //
16512        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16513        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16514        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16515        // for symmetry) lands as an edit to exactly one const, and
16516        // every consumer that reaches for the label picks it up at
16517        // build time rather than at runtime as a downstream mismatch on
16518        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16519        // the rename's commit.
16520        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16521        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16522    }
16523
16524    #[test]
16525    fn dep_author_key_consts_are_pairwise_distinct() {
16526        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16527        // must not collapse onto one byte-string. A future copy-paste
16528        // slip that renamed both consts to the same value (or a rebrand
16529        // that dropped the `-dev` suffix from one but not the other)
16530        // would leave every `DepError::DuplicateNome { list: … }`
16531        // diagnostic naming an unattributable list — the linter would
16532        // route the author to the wrong caixa.lisp block, or the
16533        // cross-list precedence gate
16534        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16535        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16536        // duplicate. Peer of the sibling
16537        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16538        // other top-level kind-scoped slot-family axes carry
16539        // (implicitly held by their different byte-values today).
16540        assert_ne!(
16541            crate::render::DEP_AUTHOR_KEY_DEPS,
16542            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16543            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16544             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16545             self-locates the offending block in the author's caixa.lisp",
16546        );
16547    }
16548
16549    #[test]
16550    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16551        // Production-through-const pin: the two per-arm list tags
16552        // [`validate_no_self_dep`] threads onto the `list:` field of a
16553        // returned [`DepError::DepIsSelf`] route through the lifted
16554        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16555        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16556        // the walker (a rename that reaches one arm but not the const,
16557        // or vice versa) surfaces here at build time rather than at
16558        // runtime as a `feira lint` diagnostic naming the wrong list
16559        // tag. Mirror of the peer
16560        // [`crate::Caixa::declared_servico_slots`] production tagger
16561        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16562        // onto the two-list dep-graph gate.
16563        let deps = vec![Dep::simple("orquestra", "^0.1")];
16564        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16565        let DepError::DepIsSelf { list, .. } = err else {
16566            panic!("expected DepIsSelf from :deps walk");
16567        };
16568        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16569
16570        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16571        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16572        let DepError::DepIsSelf { list, .. } = err else {
16573            panic!("expected DepIsSelf from :deps-dev walk");
16574        };
16575        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16576    }
16577
16578    // ── Dep::nome accessor pins ───────────────────────────────────────
16579    //
16580    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16581    // projection over the plain-shorthand / explicit-git / explicit-path
16582    // fixture triad the [`Dep`] docstring lists (so the accessor's
16583    // accept-set is exercised across every author-surface `:fonte`
16584    // shape); by-borrow pointer identity so the projection stays
16585    // zero-copy at every consumer site; and validate-composition through
16586    // the [`validate_no_self_dep`] cross-slot gate reading its
16587    // parent-name equality check through the lifted accessor rather than
16588    // the raw field.
16589
16590    #[test]
16591    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16592        // Plain-shorthand form (`:fonte None`).
16593        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16594        // Explicit git-source form with a tag pin — same accessor path.
16595        assert_eq!(
16596            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16597            "caixa-teia",
16598        );
16599        // Explicit path-source form.
16600        assert_eq!(
16601            Dep {
16602                nome: "caixa-teia".to_string(),
16603                versao: "0.1.0".to_string(),
16604                fonte: Some(DepSource::Path {
16605                    caminho: "../caixa-teia".to_string(),
16606                }),
16607                opcional: false,
16608                caracteristicas: Vec::new(),
16609            }
16610            .nome(),
16611            "caixa-teia",
16612        );
16613        // The empty-string `:nome` sentinel (which [`Dep::validate`]
16614        // refuses through the [`DepError::NomeEmpty`] arm) still round-
16615        // trips as an empty `&str` through the accessor — the accessor is
16616        // a projection, not a gate; the gate is [`Dep::validate`].
16617        assert_eq!(Dep::simple("", "^0.1").nome(), "");
16618    }
16619
16620    #[test]
16621    fn dep_nome_is_by_borrow_pointer_identity() {
16622        // Zero-copy pin: the accessor must borrow into the field's own
16623        // storage, not clone. If a future rewrite regresses to
16624        // `self.nome.clone().leak()` or an owned-buffer shape, the two
16625        // pointers diverge and this pin fails at build time.
16626        let d = Dep::simple("caixa-teia", "^0.1");
16627        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16628    }
16629
16630    // ── Dep::versao_requirement accessor pins ─────────────────────────
16631    //
16632    // Three coherence pins on the lifted `Dep::versao_requirement`
16633    // accessor: byte-equal projection over the plain-shorthand /
16634    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16635    // lists plus the empty-sentinel that round-trips as `""` (the accessor
16636    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16637    // borrow pointer identity so the projection stays zero-copy at every
16638    // consumer site; and validate-composition through the
16639    // [`crate::render::require_valid_versao_requirement`] cascade reading
16640    // its requirement-shape check through the lifted accessor rather than
16641    // the raw field.
16642    #[test]
16643    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16644        // Plain-shorthand form (`:fonte None`).
16645        assert_eq!(
16646            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16647            "^0.1",
16648        );
16649        // Explicit git-source form with a tag pin — same accessor path.
16650        assert_eq!(
16651            Dep::git(
16652                "caixa-teia",
16653                "~0.1.2",
16654                "github:pleme-io/caixa-teia",
16655                "v0.1.0"
16656            )
16657            .versao_requirement(),
16658            "~0.1.2",
16659        );
16660        // Explicit path-source form.
16661        assert_eq!(
16662            Dep {
16663                nome: "caixa-teia".to_string(),
16664                versao: "0.1.0".to_string(),
16665                fonte: Some(DepSource::Path {
16666                    caminho: "../caixa-teia".to_string(),
16667                }),
16668                opcional: false,
16669                caracteristicas: Vec::new(),
16670            }
16671            .versao_requirement(),
16672            "0.1.0",
16673        );
16674        // The wildcard requirement (`"*"`) — the shorthand
16675        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16676        // verbatim through the accessor as `"*"`, same byte-shape the
16677        // author wrote.
16678        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16679        // The empty-string `:versao` sentinel (which [`Dep::validate`]
16680        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16681        // trips as an empty `&str` through the accessor — the accessor is
16682        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16683        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16684        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16685    }
16686
16687    #[test]
16688    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16689        // Zero-copy pin: the accessor must borrow into the field's own
16690        // storage, not clone. If a future rewrite regresses to
16691        // `self.versao.clone().leak()` or an owned-buffer shape, the two
16692        // pointers diverge and this pin fails at build time. Peer of the
16693        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16694        // discipline extended onto the requirement-carrying axis.
16695        let d = Dep::simple("caixa-teia", "^0.1");
16696        assert!(std::ptr::eq(
16697            d.versao_requirement().as_ptr(),
16698            d.versao.as_ptr(),
16699        ));
16700    }
16701
16702    #[test]
16703    fn dep_validate_reads_requirement_through_accessor() {
16704        // Composition pin: the [`Dep::validate`]
16705        // [`crate::render::require_valid_versao_requirement`] cascade
16706        // consumes the requirement string through the lifted accessor —
16707        // both the requirement-gate input and the
16708        // [`DepError::VersaoInvalid`] error-body carrier route through
16709        // `self.versao_requirement()`. A valid requirement passes
16710        // (positive control); a malformed-but-non-empty requirement fails
16711        // and the diagnostic quotes the offending byte-string verbatim
16712        // (same shape the accessor projects), so a future regression that
16713        // detoured the requirement carrier through a different byte-
16714        // string (say the parsed `VersionReq`'s `Display`, or a
16715        // normalized rewrite) would surface here at build time. The
16716        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16717        // ahead of the parse arm, pinning the empty-first cascade the
16718        // accessor's `""` sentinel round-trip acknowledges.
16719        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16720        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16721        assert!(
16722            matches!(
16723                &err,
16724                DepError::VersaoInvalid {
16725                    nome,
16726                    versao,
16727                    ..
16728                } if nome == "caixa-teia" && versao == "v0.1",
16729            ),
16730            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16731        );
16732        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16733        assert!(
16734            matches!(
16735                &err,
16736                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16737            ),
16738            "expected VersaoEmpty from the empty-first arm, got {err:?}",
16739        );
16740    }
16741
16742    // ── Dep::fonte accessor pins ──────────────────────────────────────
16743    //
16744    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16745    // equal projection over the plain-shorthand (`:fonte None`) /
16746    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16747    // docstring lists (so the accessor's accept-set is exercised across
16748    // every author-surface `:fonte` shape and both `DepSource` variants);
16749    // pointer identity so the borrowed reference points into the field's
16750    // own `Option<DepSource>` storage (not a cloned side-buffer); and
16751    // validate-composition through the [`Dep::validate`] gate reading
16752    // its per-`:fonte` [`DepSource::validate`] delegation through the
16753    // lifted accessor rather than the raw `if let Some(ref fonte) =
16754    // self.fonte` bracket.
16755
16756    #[test]
16757    fn dep_fonte_returns_declared_source_across_shapes() {
16758        // Plain-shorthand form — `:fonte` omitted, accessor projects
16759        // the `None` partition the resolver-side default-fill treats
16760        // as "resolve through `github:<default-org>/<nome>`".
16761        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16762        // Explicit git-source form with a tag pin — same accessor path.
16763        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16764        match git.fonte() {
16765            Some(DepSource::Git {
16766                repo,
16767                tag,
16768                rev,
16769                branch,
16770            }) => {
16771                assert_eq!(repo, "github:pleme-io/caixa-teia");
16772                assert_eq!(tag.as_deref(), Some("v0.1.0"));
16773                assert!(rev.is_none());
16774                assert!(branch.is_none());
16775            }
16776            other => panic!("expected explicit git :fonte, got {other:?}"),
16777        }
16778        // Explicit path-source form — the dev-only local-filesystem
16779        // arm the [`Dep`] docstring's third fixture carries.
16780        let path = Dep {
16781            nome: "caixa-teia".to_string(),
16782            versao: "0.1.0".to_string(),
16783            fonte: Some(DepSource::Path {
16784                caminho: "../caixa-teia".to_string(),
16785            }),
16786            opcional: false,
16787            caracteristicas: Vec::new(),
16788        };
16789        match path.fonte() {
16790            Some(DepSource::Path { caminho }) => {
16791                assert_eq!(caminho, "../caixa-teia");
16792            }
16793            other => panic!("expected explicit path :fonte, got {other:?}"),
16794        }
16795    }
16796
16797    #[test]
16798    fn dep_fonte_is_by_borrow_pointer_identity() {
16799        // Zero-copy pin: the accessor must borrow into the field's own
16800        // `Option<DepSource>` storage, not clone into a side buffer. If
16801        // a future rewrite regresses to `self.fonte.clone()` or an
16802        // owned-buffer shape, the two pointers diverge and this pin
16803        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16804        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16805        // identity pins — same by-borrow discipline extended onto the
16806        // outer-`Dep` `Option<&Composite>` composite-reference axis.
16807        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16808        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16809        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16810        assert!(std::ptr::eq(accessed, raw));
16811    }
16812
16813    #[test]
16814    fn dep_validate_reads_fonte_through_accessor() {
16815        // Composition pin: [`Dep::validate`]'s per-`:fonte`
16816        // [`DepSource::validate`] delegation consumes the typed slot
16817        // through the lifted accessor — an author-omitted `:fonte`
16818        // still passes the outer gate (positive control), an explicit
16819        // well-formed git source with exactly one pin passes, and a
16820        // malformed git source (empty `:repo`) surfaces the
16821        // [`DepError::FonteRepoEmpty`] variant quoting the offending
16822        // dep's `:nome` verbatim so a future regression that detoured
16823        // the `:fonte` delegation through a different path (say a
16824        // per-scope override projector) would surface here at build
16825        // time. Peer of the sibling
16826        // `dep_validate_reads_requirement_through_accessor` composition
16827        // pin on the `:versao` axis.
16828        // Positive control 1: no `:fonte` at all.
16829        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16830        // Positive control 2: well-formed git source.
16831        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16832            .validate()
16833            .unwrap();
16834        // Negative control: empty `:repo` — the accessor still returns
16835        // `Some(&DepSource::Git { repo: "", … })` and the delegated
16836        // `DepSource::validate` gate raises the typed carrier.
16837        let bad = Dep {
16838            nome: "caixa-teia".to_string(),
16839            versao: "^0.1".to_string(),
16840            fonte: Some(DepSource::Git {
16841                repo: String::new(),
16842                tag: Some("v0.1.0".to_string()),
16843                rev: None,
16844                branch: None,
16845            }),
16846            opcional: false,
16847            caracteristicas: Vec::new(),
16848        };
16849        let err = bad.validate().unwrap_err();
16850        assert!(
16851            matches!(
16852                &err,
16853                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16854            ),
16855            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16856        );
16857    }
16858
16859    #[test]
16860    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16861        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16862        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16863        // own `:nome` through the lifted accessor rather than the raw
16864        // field. Fails-before-passes-after: with the accessor lifted the
16865        // gate reads its equality check through `dep.nome() ==
16866        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16867        // the diagnostic still names the offending list tag as expected.
16868        let deps = vec![Dep::simple("orquestra", "^0.1")];
16869        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16870        assert!(matches!(
16871            err,
16872            DepError::DepIsSelf {
16873                ref nome,
16874                list,
16875            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16876        ));
16877        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16878        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16879        assert!(matches!(
16880            err,
16881            DepError::DepIsSelf {
16882                ref nome,
16883                list,
16884            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16885        ));
16886        // A non-matching `:nome` passes through the accessor gate.
16887        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16888        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16889    }
16890
16891    // ── Dep::caracteristicas accessor pins ────────────────────────────
16892    //
16893    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16894    // byte-equal projection over the default-empty / single-entry /
16895    // multi-entry fixture triad (so the accessor's accept-set is
16896    // exercised across every author-surface `:caracteristicas` shape,
16897    // matching the peer sibling family's fixture-triad discipline); by-
16898    // borrow pointer identity so the projection stays zero-copy at every
16899    // consumer site; and validate-composition through the
16900    // [`Dep::validate_caracteristicas`] gate reading its per-entry
16901    // linear walk through the lifted accessor rather than the raw
16902    // `for c in &self.caracteristicas` bracket.
16903
16904    #[test]
16905    fn dep_caracteristicas_returns_declared_features_across_shapes() {
16906        // Default-empty form — the [`Dep::simple`] constructor's
16907        // `Vec::new()` fill; the accessor projects the empty slice
16908        // verbatim (no `None` collapse).
16909        assert!(
16910            Dep::simple("caixa-teia", "^0.1")
16911                .caracteristicas()
16912                .is_empty(),
16913        );
16914        // Single-entry form — the canonical Cargo-shaped one-feature
16915        // enable ([`crate::render::is_cargo_feature_name`] accepts the
16916        // `"http"` byte-string as a valid feature name).
16917        let one = Dep {
16918            nome: "caixa-teia".to_string(),
16919            versao: "^0.1".to_string(),
16920            fonte: None,
16921            opcional: false,
16922            caracteristicas: vec!["http".to_string()],
16923        };
16924        assert_eq!(one.caracteristicas(), &["http".to_string()]);
16925        // Multi-entry form — the substrate's set-shaped multi-feature
16926        // enable, exercising the accessor over a length-two slice with
16927        // no duplicate collapse.
16928        let two = Dep {
16929            nome: "caixa-teia".to_string(),
16930            versao: "^0.1".to_string(),
16931            fonte: None,
16932            opcional: false,
16933            caracteristicas: vec!["http".to_string(), "json".to_string()],
16934        };
16935        assert_eq!(
16936            two.caracteristicas(),
16937            &["http".to_string(), "json".to_string()],
16938        );
16939    }
16940
16941    #[test]
16942    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16943        // Zero-copy pin: the accessor must borrow into the field's own
16944        // `Vec<String>` storage, not clone into a side buffer. If a
16945        // future rewrite regresses to `self.caracteristicas.clone()` or
16946        // an owned-buffer shape, the two pointers diverge and this pin
16947        // fails at build time. Peer of the sibling per-`Dep`
16948        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16949        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16950        // borrow discipline extended onto the outer-`Dep` `&[String]`
16951        // slice-projection axis.
16952        let d = Dep {
16953            nome: "caixa-teia".to_string(),
16954            versao: "^0.1".to_string(),
16955            fonte: None,
16956            opcional: false,
16957            caracteristicas: vec!["http".to_string(), "json".to_string()],
16958        };
16959        assert!(std::ptr::eq(
16960            d.caracteristicas().as_ptr(),
16961            d.caracteristicas.as_ptr(),
16962        ));
16963    }
16964
16965    #[test]
16966    fn dep_validate_reads_caracteristicas_through_accessor() {
16967        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16968        // linear walk consumes the feature-toggle list through the
16969        // lifted accessor — a well-formed `:caracteristicas` set passes
16970        // (positive control), an empty-string entry surfaces the
16971        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16972        // `Dep::nome`, and a within-list duplicate surfaces the
16973        // [`DepError::CaracteristicaDuplicate`] variant so a future
16974        // regression that detoured the walk through a different byte-
16975        // string list (say a per-scope override projector) would surface
16976        // here at build time. Peer of the sibling
16977        // `dep_validate_reads_fonte_through_accessor` /
16978        // `dep_validate_reads_requirement_through_accessor` composition
16979        // pins on the `:fonte` / `:versao` axes.
16980        // Positive control: two distinct well-formed feature names pass.
16981        Dep {
16982            nome: "caixa-teia".to_string(),
16983            versao: "^0.1".to_string(),
16984            fonte: None,
16985            opcional: false,
16986            caracteristicas: vec!["http".to_string(), "json".to_string()],
16987        }
16988        .validate()
16989        .unwrap();
16990        // Negative control 1: empty-string feature-name entry — the
16991        // accessor still returns `&[""]` and the walk raises the typed
16992        // empty-first carrier.
16993        let err = Dep {
16994            nome: "caixa-teia".to_string(),
16995            versao: "^0.1".to_string(),
16996            fonte: None,
16997            opcional: false,
16998            caracteristicas: vec![String::new()],
16999        }
17000        .validate()
17001        .unwrap_err();
17002        assert!(
17003            matches!(
17004                &err,
17005                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17006            ),
17007            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17008        );
17009        // Negative control 2: within-list duplicate — the accessor's
17010        // slice view carries both entries, and the walk's dedup arm
17011        // raises the typed duplicate carrier quoting the offending
17012        // feature name verbatim.
17013        let err = Dep {
17014            nome: "caixa-teia".to_string(),
17015            versao: "^0.1".to_string(),
17016            fonte: None,
17017            opcional: false,
17018            caracteristicas: vec!["http".to_string(), "http".to_string()],
17019        }
17020        .validate()
17021        .unwrap_err();
17022        assert!(
17023            matches!(
17024                &err,
17025                DepError::CaracteristicaDuplicate {
17026                    nome,
17027                    caracteristica,
17028                } if nome == "caixa-teia" && caracteristica == "http",
17029            ),
17030            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17031        );
17032    }
17033
17034    // ── Dep::opcional accessor pins ───────────────────────────────────
17035    //
17036    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17037    // equal projection over the default-`false` / explicit-`true`
17038    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17039    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17040    // exercising the accessor's accept-set over every author-surface
17041    // `:fonte` shape × every author-surface `:opcional` shape; and by-
17042    // `Copy` idempotency so the projection stays value-return (no
17043    // silent detour to a fresh `&bool` borrow that would introduce a
17044    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17045    // shape elides). No composition pin — `:opcional` does not
17046    // participate in [`Dep::validate`] (an opcional dep with any bool
17047    // value is validate-accepted; the missing-source arm is a resolver-
17048    // side runtime dispatch, not a build-time refusal), so the axis
17049    // reduces to the value-shape + `Copy` pin pair the peer
17050    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17051    // outer-`Option<Copy>` accessor pins already carry.
17052
17053    #[test]
17054    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17055        // Default-`false` form via the [`Dep::simple`] constructor —
17056        // the accessor projects the `false` bit the default-fill sets.
17057        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17058        // Default-`false` form via the [`Dep::git`] constructor — same
17059        // default fill; the accessor projects `false` regardless of the
17060        // `:fonte` arm.
17061        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17062        // Explicit-`true` form × plain-shorthand `:fonte` — the
17063        // canonical author-surface "this dep may be missing" shape.
17064        let plain_true = Dep {
17065            nome: "caixa-teia".to_string(),
17066            versao: "^0.1".to_string(),
17067            fonte: None,
17068            opcional: true,
17069            caracteristicas: Vec::new(),
17070        };
17071        assert!(plain_true.opcional());
17072        // Explicit-`true` form × explicit git-source — the accessor
17073        // projects the bit verbatim regardless of the `:fonte` arm.
17074        let git_true = Dep {
17075            nome: "caixa-teia".to_string(),
17076            versao: "^0.1".to_string(),
17077            fonte: Some(DepSource::Git {
17078                repo: "github:pleme-io/caixa-teia".to_string(),
17079                tag: Some("v0.1.0".to_string()),
17080                rev: None,
17081                branch: None,
17082            }),
17083            opcional: true,
17084            caracteristicas: Vec::new(),
17085        };
17086        assert!(git_true.opcional());
17087        // Explicit-`true` form × explicit path-source — the dev-only
17088        // local-filesystem arm the [`Dep`] docstring's third fixture
17089        // carries.
17090        let path_true = Dep {
17091            nome: "caixa-teia".to_string(),
17092            versao: "0.1.0".to_string(),
17093            fonte: Some(DepSource::Path {
17094                caminho: "../caixa-teia".to_string(),
17095            }),
17096            opcional: true,
17097            caracteristicas: Vec::new(),
17098        };
17099        assert!(path_true.opcional());
17100    }
17101
17102    #[test]
17103    fn dep_opcional_projects_bool_by_copy() {
17104        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17105        // (`bool: Copy`) — the accessor does not borrow `&self` past
17106        // the call (no lifetime on the return type), and calling the
17107        // accessor twice on the same [`Dep`] must yield discriminant-
17108        // equal values (idempotent, no side effects on `&self`). Peer
17109        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17110        // `max_restarts_projects_option_by_copy` (eba5211) /
17111        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17112        // outer-`Caixa` altitude — extended here to the outer-`Dep`
17113        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17114        // replaces the pointer-equality claim the sibling per-`Dep`
17115        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17116        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17117        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17118        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17119        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17120        // the same discriminant, so the axis reduces to discriminant
17121        // equality).
17122        //
17123        // Pins against a future silent detour that returned a fresh
17124        // `&bool` reference (which would type-check but silently
17125        // introduce a borrow of `&self` past the call, collapsing the
17126        // load-bearing "no lifetime on the return type" `Copy`
17127        // projection the plain-`Copy`-scalar axis's `bool` shape
17128        // carries) or a stale-read side effect that flipped the outer
17129        // discriminant on successive calls.
17130        for opcional in [false, true] {
17131            let d = Dep {
17132                nome: "caixa-teia".to_string(),
17133                versao: "^0.1".to_string(),
17134                fonte: None,
17135                opcional,
17136                caracteristicas: Vec::new(),
17137            };
17138            let first = d.opcional();
17139            let second = d.opcional();
17140            assert_eq!(
17141                first, second,
17142                "Dep::opcional must be idempotent — two successive calls \
17143                 on the same &self must return the same bool",
17144            );
17145            assert_eq!(
17146                first, opcional,
17147                "Dep::opcional must return :opcional verbatim by Copy — \
17148                 got {first}, expected {opcional}",
17149            );
17150            assert_eq!(
17151                d.opcional(),
17152                d.opcional,
17153                "Dep::opcional accessor and self.opcional field access \
17154                 must byte-equal — a bit-flip drift would silently split \
17155                 the paired resolver-side drop-vs-error dispatch from \
17156                 the storage-side default-fill the [`Dep::simple`] / \
17157                 [`Dep::git`] constructor pair carries",
17158            );
17159        }
17160    }
17161
17162    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17163
17164    #[test]
17165    fn sole_pin_returns_none_for_path_source() {
17166        // A path source carries no git-ref, so `sole_pin()` returns
17167        // `None` structurally — the sibling arm every git-fetching
17168        // consumer partitions off before reaching for a git-ref. Pins
17169        // the Path-arm branch of the accessor against a future silent
17170        // detour that treats a `Self::Path` as an unpinned-git source
17171        // and returns the wrong "no pin" signal (e.g. the empty string,
17172        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17173        // path-arm `git_ref` fill).
17174        let s = DepSource::Path {
17175            caminho: "../local-caixa".to_string(),
17176        };
17177        assert_eq!(s.sole_pin(), None);
17178    }
17179
17180    #[test]
17181    fn sole_pin_returns_none_for_unpinned_git_source() {
17182        // The [`DepSource::default_github`] shorthand shape carries no
17183        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17184        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17185        // materializes when the author omits `:fonte` entirely, then
17186        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17187        // on the `None` arm — the accessor's return matches the arm
17188        // the resolver's diagnostic keys off.
17189        let s = DepSource::default_github("pleme-io", "caixa-teia");
17190        assert_eq!(s.sole_pin(), None);
17191    }
17192
17193    #[test]
17194    fn sole_pin_returns_rev_when_only_rev_is_set() {
17195        let s = DepSource::Git {
17196            repo: "github:o/x".into(),
17197            tag: None,
17198            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17199            branch: None,
17200        };
17201        assert_eq!(
17202            s.sole_pin(),
17203            Some("deadbeefcafebabe1234567890abcdef12345678")
17204        );
17205    }
17206
17207    #[test]
17208    fn sole_pin_returns_tag_when_only_tag_is_set() {
17209        let s = DepSource::Git {
17210            repo: "github:o/x".into(),
17211            tag: Some("v0.1.0".into()),
17212            rev: None,
17213            branch: None,
17214        };
17215        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17216    }
17217
17218    #[test]
17219    fn sole_pin_returns_branch_when_only_branch_is_set() {
17220        let s = DepSource::Git {
17221            repo: "github:o/x".into(),
17222            tag: None,
17223            rev: None,
17224            branch: Some("main".into()),
17225        };
17226        assert_eq!(s.sole_pin(), Some("main"));
17227    }
17228
17229    #[test]
17230    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17231        // Precedence: rev > tag > branch. Validate() rejects
17232        // multiple-pin shapes, but the accessor's precedence is defined
17233        // for pre-validate consumers (the resolver's `MissingPin`
17234        // diagnostic path, the caixa-crd round-trip's default `"main"`
17235        // fallback) and as defense-in-depth if the gate is ever
17236        // bypassed. Pins the same precedence caixa-resolver's
17237        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17238        // inline.
17239        let s = DepSource::Git {
17240            repo: "github:o/x".into(),
17241            tag: Some("v1".into()),
17242            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17243            branch: Some("main".into()),
17244        };
17245        assert_eq!(
17246            s.sole_pin(),
17247            Some("deadbeefcafebabe1234567890abcdef12345678")
17248        );
17249    }
17250
17251    #[test]
17252    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17253        let s = DepSource::Git {
17254            repo: "github:o/x".into(),
17255            tag: Some("v1".into()),
17256            rev: None,
17257            branch: Some("main".into()),
17258        };
17259        assert_eq!(s.sole_pin(), Some("v1"));
17260    }
17261
17262    #[test]
17263    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17264        // Fail-before-pass-after byte-parity pin: the substrate accessor
17265        // must return byte-identical to the inline
17266        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17267        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17268        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17269        // time if the accessor's precedence silently drifts from the
17270        // consumer-side cascade — the exact drift this lift converges
17271        // to one substrate primitive to close structurally.
17272        //
17273        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17274        // branch) each-either-`None`-or-`Some`, so every arm of the
17275        // precedence cascade lands under the pin. `validate()` refuses
17276        // the 4 multi-pin combinations, but the accessor's return is
17277        // defined on all 8.
17278        let vals = [Some("R".to_string()), None];
17279        for tag in &vals {
17280            for rev in &vals {
17281                for branch in &vals {
17282                    let s = DepSource::Git {
17283                        repo: "github:o/x".into(),
17284                        tag: tag.clone(),
17285                        rev: rev.clone(),
17286                        branch: branch.clone(),
17287                    };
17288                    // The exact inline cascade the two pre-lift
17289                    // consumer sites hand-rolled, byte-for-byte.
17290                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17291                    assert_eq!(
17292                        s.sole_pin(),
17293                        expected,
17294                        "sole_pin() must byte-equal \
17295                         rev.or(tag).or(branch) for \
17296                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17297                         a drift would silently split caixa-resolver's \
17298                         fetch_git checkout target from caixa-crd's \
17299                         dep_into_ref git_ref fill",
17300                    );
17301                }
17302            }
17303        }
17304    }
17305
17306    // Fail-before-pass-after pins on the eleven
17307    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17308    // constructors folded from the [`DepSource::validate_caminho`]
17309    // wire-up sites. Each pins the generated ctor's output to the
17310    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17311    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17312    // regression on the two-field `{ nome: nome.to_string(), caminho:
17313    // caminho.to_string() }` construction surfaces here rather than at
17314    // a downstream diagnostic-shape mismatch. Peer of the sibling
17315    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17316    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17317    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17318    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17319    // pins on the peer `SupervisorError` / `AplicacaoError` /
17320    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17321
17322    #[test]
17323    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17324        assert_eq!(
17325            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17326            DepError::FonteCaminhoAbsolute {
17327                nome: "caixa-teia".to_string(),
17328                caminho: "/home/me/work/caixa-teia".to_string(),
17329            },
17330            "generated fonte_caminho_absolute ctor must produce byte-equal \
17331             DepError to the open-coded struct-literal wrap on the same \
17332             (&str, &str) fixture",
17333        );
17334    }
17335
17336    #[test]
17337    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17338        assert_eq!(
17339            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17340            DepError::FonteCaminhoTildeExpansion {
17341                nome: "caixa-teia".to_string(),
17342                caminho: "~/work/caixa-teia".to_string(),
17343            },
17344        );
17345    }
17346
17347    #[test]
17348    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17349        assert_eq!(
17350            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17351            DepError::FonteCaminhoVarExpansion {
17352                nome: "caixa-teia".to_string(),
17353                caminho: "$HOME/work/caixa-teia".to_string(),
17354            },
17355        );
17356    }
17357
17358    #[test]
17359    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17360        assert_eq!(
17361            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17362            DepError::FonteCaminhoLeadingWhitespace {
17363                nome: "caixa-teia".to_string(),
17364                caminho: " ../caixa-teia".to_string(),
17365            },
17366        );
17367    }
17368
17369    #[test]
17370    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17371        assert_eq!(
17372            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17373            DepError::FonteCaminhoLeadingHyphen {
17374                nome: "caixa-teia".to_string(),
17375                caminho: "-rf".to_string(),
17376            },
17377        );
17378    }
17379
17380    #[test]
17381    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17382        assert_eq!(
17383            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17384            DepError::FonteCaminhoBackslash {
17385                nome: "caixa-teia".to_string(),
17386                caminho: "..\\caixa-teia".to_string(),
17387            },
17388        );
17389    }
17390
17391    #[test]
17392    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17393        assert_eq!(
17394            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17395            DepError::FonteCaminhoShellPipe {
17396                nome: "caixa-teia".to_string(),
17397                caminho: "../caixa-teia|evil".to_string(),
17398            },
17399        );
17400    }
17401
17402    #[test]
17403    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17404        assert_eq!(
17405            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17406            DepError::FonteCaminhoShellSemicolon {
17407                nome: "caixa-teia".to_string(),
17408                caminho: "../caixa-teia;evil".to_string(),
17409            },
17410        );
17411    }
17412
17413    #[test]
17414    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17415        assert_eq!(
17416            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17417            DepError::FonteCaminhoShellBackground {
17418                nome: "caixa-teia".to_string(),
17419                caminho: "../caixa-teia&".to_string(),
17420            },
17421        );
17422    }
17423
17424    #[test]
17425    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17426        assert_eq!(
17427            DepError::fonte_caminho_shell_command_substitution(
17428                "caixa-teia",
17429                "../caixa-teia`whoami`",
17430            ),
17431            DepError::FonteCaminhoShellCommandSubstitution {
17432                nome: "caixa-teia".to_string(),
17433                caminho: "../caixa-teia`whoami`".to_string(),
17434            },
17435        );
17436    }
17437
17438    #[test]
17439    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17440        assert_eq!(
17441            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17442            DepError::FonteCaminhoTrailingSlash {
17443                nome: "caixa-teia".to_string(),
17444                caminho: "../caixa-teia/".to_string(),
17445            },
17446        );
17447    }
17448
17449    #[test]
17450    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17451        // Cross-axis pin: sweep the two constructor input axes
17452        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17453        // pair against every generated arm in the
17454        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17455        // / trim / truncate / re-order on the two-field
17456        // `{ nome, caminho }` construction — or a silent field swap
17457        // between the two axes at codegen time — surfaces here rather
17458        // than at a downstream diagnostic-shape mismatch. Peer of the
17459        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17460        // to_string` cross-axis routing pin on the peer
17461        // `SupervisorError` envelope, extended here onto the
17462        // `DepError` `{ nome: String, caminho: String }` envelope so
17463        // every substrate-primitive ctor family in caixa-core
17464        // guarantees each `&str`-field construction routes the
17465        // caller's `&str` verbatim through `.to_string()`.
17466        let nome = "sibling-teia";
17467        let caminho = "../workspace/sibling";
17468        let cases: [(DepError, DepError); 11] = [
17469            (
17470                DepError::fonte_caminho_absolute(nome, caminho),
17471                DepError::FonteCaminhoAbsolute {
17472                    nome: nome.to_string(),
17473                    caminho: caminho.to_string(),
17474                },
17475            ),
17476            (
17477                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17478                DepError::FonteCaminhoTildeExpansion {
17479                    nome: nome.to_string(),
17480                    caminho: caminho.to_string(),
17481                },
17482            ),
17483            (
17484                DepError::fonte_caminho_var_expansion(nome, caminho),
17485                DepError::FonteCaminhoVarExpansion {
17486                    nome: nome.to_string(),
17487                    caminho: caminho.to_string(),
17488                },
17489            ),
17490            (
17491                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17492                DepError::FonteCaminhoLeadingWhitespace {
17493                    nome: nome.to_string(),
17494                    caminho: caminho.to_string(),
17495                },
17496            ),
17497            (
17498                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17499                DepError::FonteCaminhoLeadingHyphen {
17500                    nome: nome.to_string(),
17501                    caminho: caminho.to_string(),
17502                },
17503            ),
17504            (
17505                DepError::fonte_caminho_backslash(nome, caminho),
17506                DepError::FonteCaminhoBackslash {
17507                    nome: nome.to_string(),
17508                    caminho: caminho.to_string(),
17509                },
17510            ),
17511            (
17512                DepError::fonte_caminho_shell_pipe(nome, caminho),
17513                DepError::FonteCaminhoShellPipe {
17514                    nome: nome.to_string(),
17515                    caminho: caminho.to_string(),
17516                },
17517            ),
17518            (
17519                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17520                DepError::FonteCaminhoShellSemicolon {
17521                    nome: nome.to_string(),
17522                    caminho: caminho.to_string(),
17523                },
17524            ),
17525            (
17526                DepError::fonte_caminho_shell_background(nome, caminho),
17527                DepError::FonteCaminhoShellBackground {
17528                    nome: nome.to_string(),
17529                    caminho: caminho.to_string(),
17530                },
17531            ),
17532            (
17533                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17534                DepError::FonteCaminhoShellCommandSubstitution {
17535                    nome: nome.to_string(),
17536                    caminho: caminho.to_string(),
17537                },
17538            ),
17539            (
17540                DepError::fonte_caminho_trailing_slash(nome, caminho),
17541                DepError::FonteCaminhoTrailingSlash {
17542                    nome: nome.to_string(),
17543                    caminho: caminho.to_string(),
17544                },
17545            ),
17546        ];
17547        for (via_ctor, via_struct_literal) in cases {
17548            assert_eq!(
17549                via_ctor, via_struct_literal,
17550                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17551                 through `.to_string()` in declared field order — a field-swap or \
17552                 silent-conversion regression surfaces here rather than at a \
17553                 downstream diagnostic-shape mismatch",
17554            );
17555        }
17556    }
17557
17558    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17559    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17560    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17561    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17562    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17563
17564    #[test]
17565    fn versao_empty_ctor_matches_struct_literal_wrap() {
17566        assert_eq!(
17567            DepError::versao_empty("caixa-teia"),
17568            DepError::VersaoEmpty {
17569                nome: "caixa-teia".to_string(),
17570            },
17571        );
17572    }
17573
17574    #[test]
17575    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17576        assert_eq!(
17577            DepError::fonte_repo_empty("caixa-teia"),
17578            DepError::FonteRepoEmpty {
17579                nome: "caixa-teia".to_string(),
17580            },
17581        );
17582    }
17583
17584    #[test]
17585    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17586        assert_eq!(
17587            DepError::fonte_pin_missing("caixa-teia"),
17588            DepError::FontePinMissing {
17589                nome: "caixa-teia".to_string(),
17590            },
17591        );
17592    }
17593
17594    #[test]
17595    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17596        assert_eq!(
17597            DepError::fonte_caminho_empty("caixa-teia"),
17598            DepError::FonteCaminhoEmpty {
17599                nome: "caixa-teia".to_string(),
17600            },
17601        );
17602    }
17603
17604    #[test]
17605    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17606        assert_eq!(
17607            DepError::caracteristica_empty("caixa-teia"),
17608            DepError::CaracteristicaEmpty {
17609                nome: "caixa-teia".to_string(),
17610            },
17611        );
17612    }
17613
17614    #[test]
17615    fn dep_nome_only_ctors_route_nome_through_to_string() {
17616        // Cross-axis routing pin: sweep the single constructor input
17617        // axis (`nome: &str`) through a non-default fixture against
17618        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17619        // any wrapper-side lowercase / trim / truncate at codegen time
17620        // — or a silent field re-name away from the canonical `nome`
17621        // axis on any one variant — surfaces here rather than at a
17622        // downstream diagnostic-shape mismatch. Peer of the sibling
17623        // `fonte_caminho_ctors_route_nome_and_caminho_through_
17624        // to_string` cross-axis routing pin on the same envelope's
17625        // two-slot family (f85f145) and of the peer
17626        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17627        // pin on the `SupervisorError` single-slot family (db09650).
17628        let nome = "sibling-teia";
17629        let cases: [(DepError, DepError); 5] = [
17630            (
17631                DepError::versao_empty(nome),
17632                DepError::VersaoEmpty {
17633                    nome: nome.to_string(),
17634                },
17635            ),
17636            (
17637                DepError::fonte_repo_empty(nome),
17638                DepError::FonteRepoEmpty {
17639                    nome: nome.to_string(),
17640                },
17641            ),
17642            (
17643                DepError::fonte_pin_missing(nome),
17644                DepError::FontePinMissing {
17645                    nome: nome.to_string(),
17646                },
17647            ),
17648            (
17649                DepError::fonte_caminho_empty(nome),
17650                DepError::FonteCaminhoEmpty {
17651                    nome: nome.to_string(),
17652                },
17653            ),
17654            (
17655                DepError::caracteristica_empty(nome),
17656                DepError::CaracteristicaEmpty {
17657                    nome: nome.to_string(),
17658                },
17659            ),
17660        ];
17661        for (via_ctor, via_struct_literal) in cases {
17662            assert_eq!(
17663                via_ctor, via_struct_literal,
17664                "dep_nome_only_ctors!-generated ctor must route `nome` \
17665                 through `.to_string()` onto the canonical `nome` field \
17666                 — a field-rename or silent-conversion regression surfaces \
17667                 here rather than at a downstream diagnostic-shape mismatch",
17668            );
17669        }
17670    }
17671
17672    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17673    //    &'static str }` two-slot envelope on `DepError`, strict
17674    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17675    //    same envelope's `{ nome: String }` one-slot shape and of the
17676    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
17677    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17678
17679    #[test]
17680    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17681        assert_eq!(
17682            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17683            DepError::DuplicateNome {
17684                nome: "caixa-teia".to_string(),
17685                list: crate::render::DEP_AUTHOR_KEY_DEPS,
17686            },
17687            "generated duplicate_nome ctor must produce byte-equal \
17688             `DepError::DuplicateNome` to the pre-lift struct-literal \
17689             wrap on the same scalar fixtures",
17690        );
17691    }
17692
17693    #[test]
17694    fn dep_is_self_ctor_matches_struct_literal_wrap() {
17695        assert_eq!(
17696            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17697            DepError::DepIsSelf {
17698                nome: "orquestra".to_string(),
17699                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17700            },
17701            "generated dep_is_self ctor must produce byte-equal \
17702             `DepError::DepIsSelf` to the pre-lift struct-literal \
17703             wrap on the same scalar fixtures",
17704        );
17705    }
17706
17707    #[test]
17708    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17709        // Cross-axis routing pin: sweep the two constructor input axes
17710        // (`nome: &str`, `list: &'static str`) through non-default
17711        // fixtures against every generated arm in the
17712        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17713        // lowercase / trim / truncate at codegen time — or a silent
17714        // field re-name away from the canonical `nome` / `list` axes
17715        // on any one variant, or a `list` axis silently rerouted
17716        // through `.to_string()` instead of passed as `&'static str`
17717        // verbatim — surfaces here rather than at a downstream
17718        // diagnostic-shape mismatch. Peer of the sibling
17719        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17720        // (792aa92) on the same envelope's one-slot family, and of the
17721        // peer
17722        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17723        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17724        // two-slot `{ caixa: String, reason: String }` shape.
17725        let nome = "sibling-teia";
17726        let cases: [(DepError, DepError); 4] = [
17727            (
17728                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17729                DepError::DuplicateNome {
17730                    nome: nome.to_string(),
17731                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17732                },
17733            ),
17734            (
17735                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17736                DepError::DuplicateNome {
17737                    nome: nome.to_string(),
17738                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17739                },
17740            ),
17741            (
17742                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17743                DepError::DepIsSelf {
17744                    nome: nome.to_string(),
17745                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17746                },
17747            ),
17748            (
17749                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17750                DepError::DepIsSelf {
17751                    nome: nome.to_string(),
17752                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17753                },
17754            ),
17755        ];
17756        for (via_ctor, via_struct_literal) in cases {
17757            assert_eq!(
17758                via_ctor, via_struct_literal,
17759                "dep_nome_list_ctors!-generated ctor must route `nome` \
17760                 through `.to_string()` onto the canonical `nome` field \
17761                 and pass `list` verbatim onto the canonical `&'static str` \
17762                 `list` field — a field-rename, silent-conversion, or \
17763                 axis-swap regression surfaces here rather than at a \
17764                 downstream diagnostic-shape mismatch",
17765            );
17766        }
17767    }
17768
17769    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17770    //    value: String, reason: String }` four-slot envelope on
17771    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17772    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17773    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17774    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
17775    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
17776    //    envelope. Single-variant lift closing the last open-coded ctor
17777    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
17778
17779    #[test]
17780    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17781        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17782        // ctor: sweep both wire-up-shape arms (the refname-pin arm
17783        // routing `":tag"` / `":branch"` value through
17784        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17785        // routing `":rev"` through [`crate::render::is_git_oid`]) and
17786        // assert byte-equal `PartialEq` against the pre-lift
17787        // struct-literal, so any wrapper-side field-rename /
17788        // silent-conversion regression surfaces here rather than at a
17789        // downstream diagnostic-shape mismatch. Peer of the sibling
17790        // per-envelope byte-equal ctor pins
17791        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17792        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17793        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17794        assert_eq!(
17795            DepError::fonte_pin_shape(
17796                "caixa-teia",
17797                ":tag",
17798                "v0.1.0 ",
17799                "trailing whitespace".to_string(),
17800            ),
17801            DepError::FontePinShape {
17802                nome: "caixa-teia".to_string(),
17803                pin: ":tag".to_string(),
17804                value: "v0.1.0 ".to_string(),
17805                reason: "trailing whitespace".to_string(),
17806            },
17807            "fonte_pin_shape ctor must produce byte-equal \
17808             `DepError::FontePinShape` to the pre-lift struct-literal \
17809             wrap on a refname-pin (`:tag` / `:branch`) fixture",
17810        );
17811        assert_eq!(
17812            DepError::fonte_pin_shape(
17813                "caixa-teia",
17814                ":rev",
17815                "DEADBEEF",
17816                "abbreviated OID rejected".to_string(),
17817            ),
17818            DepError::FontePinShape {
17819                nome: "caixa-teia".to_string(),
17820                pin: ":rev".to_string(),
17821                value: "DEADBEEF".to_string(),
17822                reason: "abbreviated OID rejected".to_string(),
17823            },
17824            "fonte_pin_shape ctor must produce byte-equal \
17825             `DepError::FontePinShape` to the pre-lift struct-literal \
17826             wrap on a hex-OID-pin (`:rev`) fixture",
17827        );
17828    }
17829
17830    #[test]
17831    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17832        // Cross-axis routing pin: sweep every one of the four
17833        // constructor input axes (`nome: &str`, `pin: &str`,
17834        // `value: &str`, `reason: String`) through non-default
17835        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17836        // any wrapper-side lowercase / trim / truncate at codegen time
17837        // — or a silent field re-name / axis-swap on any one of the
17838        // four fields, or a `reason` axis silently routed through
17839        // `.to_string()` instead of forwarded owned — surfaces here
17840        // rather than at a downstream diagnostic-shape mismatch. Peer
17841        // of the sibling
17842        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17843        // (792aa92) and
17844        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17845        // pin (6f5e0cd) on the same envelope's one- and two-slot
17846        // families. Distinct-per-axis fixtures rule out any two-axis
17847        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17848        // etc.) that would still pass a same-fixture-per-axis pin.
17849        let nome = "sibling-teia";
17850        let pin = ":branch";
17851        let value = "feature/bar";
17852        let reason = "embedded space".to_string();
17853        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17854        let via_struct_literal = DepError::FontePinShape {
17855            nome: nome.to_string(),
17856            pin: pin.to_string(),
17857            value: value.to_string(),
17858            reason: reason.clone(),
17859        };
17860        assert_eq!(
17861            via_ctor, via_struct_literal,
17862            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17863             through `.to_string()` onto their canonical fields and \
17864             forward `reason` owned onto the canonical `reason` field \
17865             — a field-rename, silent-conversion, or axis-swap \
17866             regression surfaces here rather than at a downstream \
17867             diagnostic-shape mismatch",
17868        );
17869        let DepError::FontePinShape {
17870            nome: n,
17871            pin: p,
17872            value: v,
17873            reason: r,
17874        } = via_ctor
17875        else {
17876            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17877        };
17878        assert_eq!(n, nome);
17879        assert_eq!(p, pin);
17880        assert_eq!(v, value);
17881        assert_eq!(r, reason);
17882    }
17883
17884    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17885    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17886    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17887    //    the same envelope's `{ nome: String, caminho: String }` two-slot
17888    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17889    //    same envelope's `{ nome: String }` one-slot shape.
17890
17891    #[test]
17892    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17893        assert_eq!(
17894            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17895            DepError::FonteCaminhoControlChar {
17896                nome: "caixa-teia".to_string(),
17897                caminho: "../caixa-teia\x00foo".to_string(),
17898                byte: 0x00,
17899            },
17900        );
17901    }
17902
17903    #[test]
17904    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17905        assert_eq!(
17906            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17907            DepError::FonteCaminhoShellRedirection {
17908                nome: "caixa-teia".to_string(),
17909                caminho: "../caixa-teia>log".to_string(),
17910                byte: b'>',
17911            },
17912        );
17913    }
17914
17915    #[test]
17916    #[allow(
17917        clippy::too_many_lines,
17918        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17919                  byte-classification arm on the {nome,caminho,byte} envelope; \
17920                  the linear per-variant repetition is exactly what the sweep \
17921                  is pinning — a helper macro would hide the shape the fold is \
17922                  keying on"
17923    )]
17924    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17925        // Cross-axis routing pin: sweep the three constructor input axes
17926        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17927        // non-default fixture triple against every generated arm in the
17928        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17929        // lowercase / trim / truncate on the two `&str` axes — a silent
17930        // field swap between `nome` and `caminho`, or a silent
17931        // re-classification of the offending byte — surfaces here rather
17932        // than at a downstream diagnostic-shape mismatch. Peer of the
17933        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17934        // to_string` cross-axis routing pin on the same envelope's
17935        // two-slot family (f85f145) and of the sibling
17936        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17937        // same envelope's one-slot family (792aa92), extended here onto
17938        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17939        // envelope so every substrate-primitive ctor family in
17940        // caixa-core's `DepError` envelope guarantees each field routes
17941        // the caller's value verbatim through `.to_string()` (or byte-
17942        // identity for `byte: u8`) in declared field order.
17943        let nome = "sibling-teia";
17944        let caminho = "../workspace/sibling";
17945        let byte = 0x2A_u8;
17946        let cases: [(DepError, DepError); 12] = [
17947            (
17948                DepError::fonte_caminho_control_char(nome, caminho, byte),
17949                DepError::FonteCaminhoControlChar {
17950                    nome: nome.to_string(),
17951                    caminho: caminho.to_string(),
17952                    byte,
17953                },
17954            ),
17955            (
17956                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17957                DepError::FonteCaminhoShellRedirection {
17958                    nome: nome.to_string(),
17959                    caminho: caminho.to_string(),
17960                    byte,
17961                },
17962            ),
17963            (
17964                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17965                DepError::FonteCaminhoShellGlob {
17966                    nome: nome.to_string(),
17967                    caminho: caminho.to_string(),
17968                    byte,
17969                },
17970            ),
17971            (
17972                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17973                DepError::FonteCaminhoShellSubshellGrouping {
17974                    nome: nome.to_string(),
17975                    caminho: caminho.to_string(),
17976                    byte,
17977                },
17978            ),
17979            (
17980                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17981                DepError::FonteCaminhoShellBraceExpansion {
17982                    nome: nome.to_string(),
17983                    caminho: caminho.to_string(),
17984                    byte,
17985                },
17986            ),
17987            (
17988                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17989                DepError::FonteCaminhoShellBracketExpansion {
17990                    nome: nome.to_string(),
17991                    caminho: caminho.to_string(),
17992                    byte,
17993                },
17994            ),
17995            (
17996                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17997                DepError::FonteCaminhoShellQuoteGrouping {
17998                    nome: nome.to_string(),
17999                    caminho: caminho.to_string(),
18000                    byte,
18001                },
18002            ),
18003            (
18004                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18005                DepError::FonteCaminhoShellComment {
18006                    nome: nome.to_string(),
18007                    caminho: caminho.to_string(),
18008                    byte,
18009                },
18010            ),
18011            (
18012                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18013                DepError::FonteCaminhoUrlPercentEncoding {
18014                    nome: nome.to_string(),
18015                    caminho: caminho.to_string(),
18016                    byte,
18017                },
18018            ),
18019            (
18020                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18021                DepError::FonteCaminhoShellVariableExpansion {
18022                    nome: nome.to_string(),
18023                    caminho: caminho.to_string(),
18024                    byte,
18025                },
18026            ),
18027            (
18028                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18029                DepError::FonteCaminhoShellHistoryExpansion {
18030                    nome: nome.to_string(),
18031                    caminho: caminho.to_string(),
18032                    byte,
18033                },
18034            ),
18035            (
18036                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18037                DepError::FonteCaminhoShellHistorySubstitution {
18038                    nome: nome.to_string(),
18039                    caminho: caminho.to_string(),
18040                    byte,
18041                },
18042            ),
18043        ];
18044        for (via_ctor, via_struct_literal) in cases {
18045            assert_eq!(
18046                via_ctor, via_struct_literal,
18047                "fonte_caminho_byte_ctors!-generated ctor must route \
18048                 (nome, caminho, byte) through `.to_string()` / byte-\
18049                 identity in declared field order — a field-swap or \
18050                 silent-conversion regression surfaces here rather than \
18051                 at a downstream diagnostic-shape mismatch",
18052            );
18053        }
18054    }
18055
18056    #[test]
18057    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18058        // Fail-before-pass-after byte-parity pin on the lifted
18059        // `impl AsRef<str> for DepList` — asserts the standard-
18060        // library trait impl and the substrate-primitive
18061        // [`super::DepList::as_str`] `pub const fn` accessor resolve
18062        // to the same `&str` per instance across the two-arm closed
18063        // set, so any future silent detour that routes the impl
18064        // through a divergent projection (a per-arm inline
18065        // `match self { DepList::Prod => ":deps", … }` re-inlining
18066        // that opens a compile-time link to the un-lifted arm-literal,
18067        // a swap onto a second projection axis) trips at caixa-core
18068        // test time under `PartialEq` rather than at a downstream
18069        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18070        // every one of the two arms [`super::DepList::ALL`] carries
18071        // so no arm's projection is covered only by the sibling
18072        // `Display` path. Peer of the sibling
18073        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18074        // (1723611) on the top-level dialect-classification closed-
18075        // set typed enum, and the peer
18076        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18077        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18078        // typed enum — the pins together close the substrate
18079        // primitive's `AsRef<str>` projection axis onto the seventh
18080        // (and last unlifted) closed-set typed enum on the caixa
18081        // surface.
18082        for &list in super::DepList::ALL {
18083            assert_eq!(
18084                <super::DepList as AsRef<str>>::as_ref(&list),
18085                list.as_str(),
18086                "AsRef<str> impl on DepList::{list:?} must byte-equal \
18087                 DepList::as_str on the same instance — divergence \
18088                 signals a silent detour off the substrate-primitive \
18089                 accessor"
18090            );
18091        }
18092    }
18093
18094    #[test]
18095    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18096        // Fail-before-pass-after byte-parity pin on the three-path
18097        // convergence discipline the [`super::DepList`] two-list
18098        // dep-graph closed-set typed enum now carries on the `&str`-
18099        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18100        // newly lifted impl), `format!("{v}")` (the pre-existing
18101        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18102        // primitive `pub const fn` accessor both trait impls delegate
18103        // through) must resolve to the same byte-string on every
18104        // instance across the two-arm closed set. Refuses any future
18105        // divergence between the two trait impls (a stray
18106        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18107        // rather than delegating through the shared accessor; a
18108        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18109        // literal cascade) that would silently split the two
18110        // projection paths of the same closed-set typed enum. Mirrors
18111        // the sibling three-path-convergence discipline the peer
18112        // [`crate::CaixaDialeto`] typed enum carries
18113        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18114        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18115        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18116        // d8136db), the peer [`crate::CaixaKind`] triple
18117        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18118        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18119        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18120        // 16d5c7e).
18121        for &list in super::DepList::ALL {
18122            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18123            let via_display: String = format!("{list}");
18124            let via_accessor: &str = list.as_str();
18125            assert_eq!(via_as_ref, via_accessor);
18126            assert_eq!(via_display, via_accessor);
18127            assert_eq!(via_as_ref, via_display.as_str());
18128        }
18129    }
18130
18131    #[test]
18132    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18133        // Fail-before-pass-after byte-parity pin on the newly lifted
18134        // `impl TryFrom<&str> for DepList` — asserts the standard-
18135        // library trait impl and the substrate-primitive
18136        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18137        // to the same two-arm accept-set across every arm the
18138        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18139        // the sibling
18140        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18141        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18142        // and the 12 other substrate-wide trait-idiomatic reverse-
18143        // projection routes-through pins — closes the campaign's
18144        // completeness gap on the two-list dep-graph closed-set enum.
18145        for &list in super::DepList::ALL {
18146            let wire = list.as_str();
18147            assert_eq!(
18148                <super::DepList as TryFrom<&str>>::try_from(wire),
18149                Ok(list),
18150                "TryFrom<&str> impl on DepList must round-trip \
18151                 DepList::{list:?}.as_str() = {wire:?} back to \
18152                 Ok(DepList::{list:?}) — divergence from \
18153                 DepList::from_wire signals a silent detour off the \
18154                 substrate-primitive accessor"
18155            );
18156            assert_eq!(
18157                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18158                super::DepList::from_wire(wire),
18159                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18160                 DepList::from_wire on the same input"
18161            );
18162        }
18163    }
18164
18165    #[test]
18166    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18167        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18168        // sweeps candidate byte-strings outside the two-arm accept-set
18169        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18170        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18171        // future accidental widening of the trait impl's accept-set (a
18172        // stray case-fold path, a silent inclusion of a rebrand alias
18173        // like `":packages"`, an English rebrand `":dev-deps"` in
18174        // reverse arm-order that would silently swap the two arms) trips
18175        // at caixa-core test time. Peer of the sibling
18176        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18177        // (5b828ed) rejection witness.
18178        let rejected: &[&str] = &[
18179            "",
18180            " ",
18181            "\t",
18182            "\n",
18183            ":deps ",
18184            " :deps",
18185            ":DEPS",
18186            ":Deps",
18187            ":Deps-Dev",
18188            ":deps_dev",
18189            ":deps-development",
18190            ":dev-deps",
18191            ":packages",
18192            ":packages-dev",
18193            "deps",
18194            "deps-dev",
18195            "Prod",
18196            "Dev",
18197            "prod",
18198            "dev",
18199            "\":deps\"",
18200            "\":deps-dev\"",
18201            ":deps\n",
18202            ":deps-dev\n",
18203        ];
18204        for &input in rejected {
18205            assert_eq!(
18206                <super::DepList as TryFrom<&str>>::try_from(input),
18207                Err(()),
18208                "TryFrom<&str> impl on DepList must reject unknown \
18209                 byte-string {input:?} — divergence from \
18210                 DepList::from_wire on the same input signals a silent \
18211                 accept-set widening past the two lifted \
18212                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18213            );
18214            assert_eq!(
18215                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18216                super::DepList::from_wire(input),
18217                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18218                 DepList::from_wire on the same input — divergence signals \
18219                 the two reverse-projection paths have drifted onto \
18220                 different accept-sets"
18221            );
18222        }
18223    }
18224
18225    #[test]
18226    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18227        // Fail-before-pass-after byte-parity pin on the newly lifted
18228        // `impl From<DepList> for &'static str` — asserts the standard-
18229        // library trait impl and the substrate-primitive
18230        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18231        // the same two-arm emit-set across every arm the exhaustive
18232        // [`super::DepList::ALL`] slice enumerates. Materializes the
18233        // `<&'static str as From<DepList>>::from` output in a
18234        // `const`-shape binding to make the `'static` lifetime promise
18235        // a build-time invariant — a future accidental downgrade of
18236        // either arm to a non-`&'static str` (a `String::leak()`-
18237        // produced return, a `Box::leak`-cast) trips at caixa-core
18238        // build time rather than at a downstream `'static`-bound
18239        // consumer. Peer of the sibling
18240        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18241        // (523157d) and the 13 other substrate-wide forward-projection
18242        // routes-through pins.
18243        const PROD: &str = super::DepList::Prod.as_str();
18244        const DEV: &str = super::DepList::Dev.as_str();
18245        for &list in super::DepList::ALL {
18246            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18247            let via_method: &'static str = list.as_str();
18248            assert_eq!(
18249                via_trait, via_method,
18250                "From<DepList> for &'static str impl must round-trip \
18251                 DepList::{list:?} to the same lifted \
18252                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18253                 DepList::as_str returns — divergence signals a silent \
18254                 detour off the substrate-primitive accessor"
18255            );
18256            let via_into: &'static str = list.into();
18257            assert_eq!(
18258                via_into, via_method,
18259                "Into<&'static str>::into on DepList::{list:?} must \
18260                 byte-equal DepList::as_str on the same input — the \
18261                 blanket-derived Into shape must resolve to the same \
18262                 as_str dispatch as the explicit From impl"
18263            );
18264        }
18265        assert_eq!(
18266            [PROD, DEV],
18267            [
18268                crate::render::DEP_AUTHOR_KEY_DEPS,
18269                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18270            ],
18271            "const-context DepList::as_str must resolve to the two lifted \
18272             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18273             of either arm to a non-const or non-static byte-string breaks \
18274             the `&'static str`-lifetime promise the paired \
18275             From<DepList> for &'static str impl carries by construction"
18276        );
18277    }
18278
18279    #[test]
18280    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18281        // Cross-axis partition pin: the paired trait-idiomatic
18282        // `From<DepList> for &'static str` forward projection and the
18283        // method-named [`super::DepList::as_str`] forward projection
18284        // must resolve identically on every arm, locking the two paths
18285        // together so any future detour trips at caixa-core test time.
18286        // Then a round-trip witness: every arm's forward `From` output
18287        // re-parses through the paired trait-idiomatic reverse
18288        // `TryFrom<&str>` back to the original variant, closing the
18289        // two-way `DepList ↔ &'static str` round-trip on the trait-
18290        // idiomatic axis pair, mirroring the pre-existing method-named
18291        // `as_str` + `from_wire` round-trip. Peer of the sibling
18292        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18293        // (523157d).
18294        for &list in super::DepList::ALL {
18295            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18296            let via_method: &'static str = list.as_str();
18297            assert_eq!(
18298                via_trait, via_method,
18299                "From<DepList> for &'static str and DepList::as_str must \
18300                 resolve identically on DepList::{list:?} — divergence \
18301                 signals the two forward-projection paths have drifted \
18302                 onto different emit-sets"
18303            );
18304        }
18305        for &list in super::DepList::ALL {
18306            let emitted: &'static str = list.into();
18307            let re_parsed: Result<super::DepList, ()> =
18308                <super::DepList as TryFrom<&str>>::try_from(emitted);
18309            assert_eq!(
18310                re_parsed,
18311                Ok(list),
18312                "trait-idiomatic axis pair must round-trip \
18313                 DepList::{list:?} through `.into::<&'static str>()` and \
18314                 back through `TryFrom<&str>` — a break signals the \
18315                 forward-emit and reverse-parse axes have drifted onto \
18316                 different vocabularies"
18317            );
18318        }
18319    }
18320
18321    #[test]
18322    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18323        // Fail-before-pass-after byte-parity pin on the newly lifted
18324        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18325        // input standard-library trait impl and the substrate-primitive
18326        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18327        // the same two-arm emit-set across every arm the exhaustive
18328        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18329        // does not auto-derive the borrowed-input sibling from a paired
18330        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18331        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18332        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18333        // shape over [`super::DepList::ALL`] (whose iterator yields
18334        // `&DepList`, not `DepList`) reaches through this impl and no
18335        // other — the paired owned-input [`From<DepList>`] impl requires
18336        // an explicit `.copied()` / dereference before the trait fires.
18337        // Materializes the `<&'static str as From<&DepList>>::from`
18338        // output in a `const`-shape binding to make the `'static`
18339        // lifetime promise a build-time invariant.
18340        const PROD: &str = super::DepList::Prod.as_str();
18341        const DEV: &str = super::DepList::Dev.as_str();
18342        for list in super::DepList::ALL {
18343            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18344            let via_method: &'static str = list.as_str();
18345            assert_eq!(
18346                via_trait, via_method,
18347                "From<&DepList> for &'static str impl must round-trip \
18348                 &DepList::{list:?} to the same lifted \
18349                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18350                 DepList::as_str returns — divergence signals a silent \
18351                 detour off the substrate-primitive accessor"
18352            );
18353            let via_into: &'static str = list.into();
18354            assert_eq!(
18355                via_into, via_method,
18356                "Into<&'static str>::into on &DepList::{list:?} must \
18357                 byte-equal DepList::as_str on the same input — the \
18358                 blanket-derived Into shape must resolve to the same \
18359                 as_str dispatch as the explicit From impl"
18360            );
18361        }
18362        assert_eq!(
18363            [PROD, DEV],
18364            [
18365                crate::render::DEP_AUTHOR_KEY_DEPS,
18366                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18367            ],
18368            "const-context DepList::as_str must resolve to the two lifted \
18369             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18370             From<&DepList> for &'static str impl inherits its `'static` \
18371             lifetime promise from the same accessor the owned-input \
18372             sibling routes through"
18373        );
18374    }
18375
18376    #[test]
18377    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18378        // Cross-axis partition pin: the paired trait-idiomatic
18379        // owned-input `From<DepList> for &'static str` (523157d
18380        // campaign-shape) and borrowed-input `From<&DepList> for
18381        // &'static str` (this lift) forward projections must resolve
18382        // identically on every arm, locking the two input-shape paths
18383        // together so any future detour trips at caixa-core test time.
18384        // Then a witness that a `.iter().map(Into::into)` pipe over
18385        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18386        // materializes the two-arm accept-set through the borrowed-
18387        // input axis alone — the exact shape a future M4 admission-
18388        // webhook rejection body composer, a future substrate-wide
18389        // per-arm diagnostic column, or a
18390        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18391        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18392        // through — closing the two-way owned/borrowed input-shape
18393        // symmetry on the forward-projection trait-idiomatic axis.
18394        for &list in super::DepList::ALL {
18395            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18396            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18397            assert_eq!(
18398                owned, borrowed,
18399                "From<DepList> and From<&DepList> for &'static str must \
18400                 resolve identically on DepList::{list:?} — divergence \
18401                 signals the owned-input and borrowed-input forward-\
18402                 projection paths have drifted onto different emit-sets"
18403            );
18404        }
18405        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18406        let via_method: Vec<&'static str> =
18407            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18408        assert_eq!(
18409            via_iter, via_method,
18410            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18411             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18412             input `From<&DepList> for &'static str` axis is what makes \
18413             the `.iter().map(Into::into)` shape route through the \
18414             substrate-primitive `DepList::as_str` accessor rather than \
18415             through a per-call-site `.copied()` / dereference detour"
18416        );
18417    }
18418
18419    #[test]
18420    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18421        // Fail-before-pass-after byte-parity pin on the newly lifted
18422        // `impl From<DepList> for String` — asserts the owned-`String`
18423        // -returning standard-library trait impl and the substrate-
18424        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18425        // resolve to the same two-arm emit-set across every arm the
18426        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18427        // standard library does not carry a blanket
18428        // `impl<T: AsRef<str>> From<T> for String` (nor an
18429        // `impl<T: fmt::Display> From<T> for String`), so the
18430        // owned-`String` forward-projection axis is a distinct trait-
18431        // idiomatic surface that a `let key: String = list.into();`-
18432        // shaped call site reaches through this impl and no other — the
18433        // paired sibling `From<DepList> for &'static str` impl forces
18434        // every owned-`String` call site through an explicit
18435        // `.to_owned()` / `String::from` restatement. Peer of the
18436        // first-mover
18437        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18438        // (7baa18a), the second-peer
18439        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18440        // (7851725), the third-peer
18441        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18442        // (231a18c), and the fourth-peer
18443        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18444        // (88942cd) — extends the trait-idiomatic owned-`String`
18445        // forward-projection axis onto the fifth closed-set fieldless
18446        // typed enum on the caixa surface (the two-list dep-graph axis).
18447        for &variant in super::DepList::ALL {
18448            let via_trait: String = <String as From<super::DepList>>::from(variant);
18449            let via_method: &'static str = variant.as_str();
18450            assert_eq!(
18451                via_trait.as_str(),
18452                via_method,
18453                "From<DepList> for String impl must round-trip \
18454                 DepList::{variant:?} to the same lifted \
18455                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18456                 DepList::as_str returns — divergence signals a silent \
18457                 detour off the substrate-primitive accessor"
18458            );
18459            let via_into: String = variant.into();
18460            assert_eq!(
18461                via_into.as_str(),
18462                via_method,
18463                "Into<String>::into on DepList::{variant:?} must \
18464                 byte-equal DepList::as_str on the same input — the \
18465                 blanket-derived Into shape must resolve to the same \
18466                 as_str dispatch as the explicit From impl"
18467            );
18468        }
18469    }
18470
18471    #[test]
18472    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18473        // Cross-axis partition pin: the paired trait-idiomatic
18474        // owned-`String` `From<DepList> for String` (this lift) and
18475        // owned-`&'static str` `From<DepList> for &'static str`
18476        // (523157d campaign-shape) forward projections must resolve
18477        // identically on every arm, locking the two return-type-shape
18478        // paths together so any future detour trips at caixa-core test
18479        // time. Also byte-parity witness against the sibling
18480        // [`ToString::to_string`] surface routed through
18481        // [`std::fmt::Display`] — the three owned-heap-string paths
18482        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18483        // resolve identically on every arm so a future consumer that
18484        // picks any of the three lands on the same two-arm lifted
18485        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18486        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18487        // Then a `.iter().copied().map(String::from)` pipe witness
18488        // over [`super::DepList::ALL`] that materializes the two-arm
18489        // accept-set through the owned-`String` axis alone — the exact
18490        // shape a future M4 admission-webhook rejection body composer
18491        // or a
18492        // `HashMap::<String, DepList>::from_iter(
18493        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18494        // style owned-key per-list lookup reaches through — closing the
18495        // owned-`String` forward-projection axis's iterator-pipe shape.
18496        // Then a direct round-trip witness through the paired
18497        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18498        // owned-`String`'s [`String::as_str`] borrow that closes the
18499        // two-way `Self → String → Self` round-trip on the trait-
18500        // idiomatic owned-`String` forward + reverse axis pair.
18501        //
18502        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18503        // `From` emit lands on the lowercase Portuguese `as_str`
18504        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18505        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18506        // forcing the round-trip through an intermediate
18507        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18508        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18509        // parse resolve through the same lifted
18510        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18511        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18512        // construction (there is no wire/diagnostic axis split on this
18513        // enum), so the owned-`String` forward axis and the reverse
18514        // axis compose directly — matching the peer
18515        // [`crate::supervisor::RestartStrategy`] /
18516        // [`crate::supervisor::RestartPolicy`] /
18517        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18518        for &list in super::DepList::ALL {
18519            let owned_string: String = <String as From<super::DepList>>::from(list);
18520            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18521            assert_eq!(
18522                owned_string.as_str(),
18523                owned_static,
18524                "From<DepList> for String and From<DepList> for \
18525                 &'static str must resolve identically on \
18526                 DepList::{list:?} — divergence signals the owned-\
18527                 `String` and owned-`&'static str` forward-projection \
18528                 return-type-shape paths have drifted onto different \
18529                 emit-sets"
18530            );
18531            let via_to_string: String = list.to_string();
18532            assert_eq!(
18533                owned_string, via_to_string,
18534                "From<DepList> for String must byte-equal \
18535                 DepList::to_string on DepList::{list:?} — divergence \
18536                 signals the trait-idiomatic owned-`String` forward-\
18537                 projection axis and the ToString-through-Display axis \
18538                 have drifted onto different emit-sets"
18539            );
18540        }
18541        let via_iter: Vec<String> = super::DepList::ALL
18542            .iter()
18543            .copied()
18544            .map(String::from)
18545            .collect();
18546        let via_method: Vec<String> = super::DepList::ALL
18547            .iter()
18548            .map(|l| l.as_str().to_owned())
18549            .collect();
18550        assert_eq!(
18551            via_iter, via_method,
18552            "`.iter().copied().map(String::from)` over DepList::ALL must \
18553             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18554             every arm — the owned-`String` `From<DepList> for String` \
18555             axis is what makes the `String::from` composition route \
18556             through the substrate-primitive `DepList::as_str` accessor \
18557             rather than through a per-call-site `.to_owned()` / \
18558             `String::from(list.as_str())` detour"
18559        );
18560        for &variant in super::DepList::ALL {
18561            let emitted: String = variant.into();
18562            let re_parsed: Result<super::DepList, ()> =
18563                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18564            assert_eq!(
18565                re_parsed,
18566                Ok(variant),
18567                "trait-idiomatic owned-`String` forward-projection + \
18568                 reverse-projection axis pair must round-trip \
18569                 DepList::{variant:?} through `.into::<String>()` and \
18570                 back through `TryFrom<&str>` on the owned-`String`'s \
18571                 String::as_str borrow — a break signals the owned-\
18572                 `String` forward-emit and reverse-parse axes have \
18573                 drifted onto different vocabularies (unlike the peer \
18574                 CaixaKind axis pair, DepList's forward emit and \
18575                 reverse parse share the same lifted \
18576                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18577                 round-trip composes directly)"
18578            );
18579        }
18580    }
18581
18582    #[test]
18583    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18584        // Fail-before-pass-after byte-parity pin on the newly lifted
18585        // `impl From<&DepList> for String` — asserts the borrowed-input
18586        // owned-`String`-returning standard-library trait impl and the
18587        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18588        // accessor resolve to the same two-arm emit-set across every
18589        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18590        // Rust's standard library does not carry a blanket
18591        // `impl<T: AsRef<str>> From<&T> for String` (nor an
18592        // `impl<T: fmt::Display> From<&T> for String`), so the
18593        // borrowed-input owned-`String` forward-projection axis is a
18594        // distinct trait-idiomatic surface that a
18595        // `let key: String = (&list).into();`-shaped call site reaches
18596        // through this impl and no other — the paired sibling
18597        // `From<DepList> for String` impl forces every borrowed-input
18598        // call site through an explicit `Copy` deref
18599        // (`String::from(*list)`) or an `.as_str().to_owned()` /
18600        // `.to_string()` detour. Peer of the first-mover
18601        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18602        // (579385f) and the second-peer
18603        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18604        // (8465740) — extends the trait-idiomatic borrowed-input owned-
18605        // `String` forward-projection axis off the M2 OTP-shape sibling
18606        // axis pair onto the first non-M2 closed-set fieldless typed
18607        // enum peer (the two-list dep-graph axis).
18608        for &variant in super::DepList::ALL {
18609            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18610            let via_method: &'static str = variant.as_str();
18611            assert_eq!(
18612                via_trait.as_str(),
18613                via_method,
18614                "From<&DepList> for String impl must round-trip \
18615                 &DepList::{variant:?} to the same lifted \
18616                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18617                 DepList::as_str returns — divergence signals a silent \
18618                 detour off the substrate-primitive accessor"
18619            );
18620            let via_into: String = (&variant).into();
18621            assert_eq!(
18622                via_into.as_str(),
18623                via_method,
18624                "Into<String>::into on &DepList::{variant:?} must \
18625                 byte-equal DepList::as_str on the same input — the \
18626                 blanket-derived Into shape must resolve to the same \
18627                 as_str dispatch as the explicit From impl"
18628            );
18629        }
18630    }
18631
18632    #[test]
18633    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18634        // Cross-axis partition pin: the newly lifted trait-idiomatic
18635        // borrowed-input owned-`String` `From<&DepList> for String`
18636        // (this lift), the paired owned-input owned-`String`
18637        // `From<DepList> for String` (32b0ee8), the paired borrowed-
18638        // input owned-`&'static str` `From<&DepList> for &'static str`
18639        // (64aa742), and the paired owned-input owned-`&'static str`
18640        // `From<DepList> for &'static str` (3455cbf) — every corner of
18641        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18642        // idiomatic projection family — must resolve identically on
18643        // every arm, locking the four return-shape × input-shape paths
18644        // together so any future detour trips at caixa-core test time.
18645        // Also byte-parity witness against the sibling
18646        // [`ToString::to_string`] surface routed through
18647        // [`std::fmt::Display`] and a direct round-trip witness through
18648        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18649        // the owned-`String`'s [`String::as_str`] borrow that closes
18650        // the two-way `&Self → String → Self` round-trip on the trait-
18651        // idiomatic borrowed-input owned-`String` forward + reverse
18652        // axis pair. Peer of the first-mover
18653        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18654        // (579385f) and the second-peer
18655        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18656        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18657        // String}` 2×2 projection corner on the third substrate-wide
18658        // closed-set fieldless typed enum peer (the two-list dep-graph
18659        // axis, first outside the M2 OTP-shape sibling pair).
18660        //
18661        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18662        // `From` emit lands on the lowercase Portuguese `as_str`
18663        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18664        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18665        // forcing the round-trip through an intermediate
18666        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18667        // [`super::DepList::as_str`] emit and
18668        // [`super::DepList::from_wire`] parse resolve through the same
18669        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18670        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18671        // construction (there is no wire/diagnostic axis split on this
18672        // enum), so the borrowed-input owned-`String` forward axis and
18673        // the reverse axis compose directly — matching the peer
18674        // [`crate::supervisor::RestartStrategy`] /
18675        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18676        // `String` axis pairs.
18677        for &list in super::DepList::ALL {
18678            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18679            let owned_string: String = <String as From<super::DepList>>::from(list);
18680            let borrowed_static: &'static str =
18681                <&'static str as From<&super::DepList>>::from(&list);
18682            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18683            assert_eq!(
18684                borrowed_string, owned_string,
18685                "From<&DepList> for String and From<DepList> for String \
18686                 must resolve identically on DepList::{list:?} — \
18687                 divergence signals the borrowed-input and owned-input \
18688                 owned-`String` forward-projection input-shape paths \
18689                 have drifted onto different emit-sets"
18690            );
18691            assert_eq!(
18692                borrowed_string.as_str(),
18693                borrowed_static,
18694                "From<&DepList> for String and From<&DepList> for \
18695                 &'static str must resolve identically on \
18696                 DepList::{list:?} — divergence signals the borrowed-\
18697                 input `&'static str` and owned-`String` return-shape \
18698                 paths have drifted onto different emit-sets"
18699            );
18700            assert_eq!(
18701                borrowed_string.as_str(),
18702                owned_static,
18703                "From<&DepList> for String and From<DepList> for \
18704                 &'static str must resolve identically on \
18705                 DepList::{list:?} — divergence signals a break in the \
18706                 diagonal corner of the {{Self, &Self}} × {{&'static \
18707                 str, String}} 2×2 trait-idiomatic projection family"
18708            );
18709            let via_to_string: String = list.to_string();
18710            assert_eq!(
18711                borrowed_string, via_to_string,
18712                "From<&DepList> for String must byte-equal \
18713                 DepList::to_string on DepList::{list:?} — divergence \
18714                 signals the trait-idiomatic borrowed-input owned-\
18715                 `String` forward-projection axis and the ToString-\
18716                 through-Display axis have drifted onto different \
18717                 emit-sets"
18718            );
18719        }
18720        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18721        let via_method: Vec<String> = super::DepList::ALL
18722            .iter()
18723            .map(|l| l.as_str().to_owned())
18724            .collect();
18725        assert_eq!(
18726            via_iter, via_method,
18727            "`.iter().map(String::from)` over DepList::ALL — a call \
18728             site whose iteration axis holds `&DepList` by construction \
18729             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18730             on every arm — the borrowed-input owned-`String` \
18731             `From<&DepList> for String` axis is what makes the \
18732             `String::from` composition route through the substrate-\
18733             primitive `DepList::as_str` accessor without a spurious \
18734             `Copy` deref (which would only be reachable through the \
18735             owned-input `From<DepList> for String` axis by first \
18736             calling `.copied()` on the iterator)"
18737        );
18738        for &variant in super::DepList::ALL {
18739            let emitted: String = (&variant).into();
18740            let re_parsed: Result<super::DepList, ()> =
18741                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18742            assert_eq!(
18743                re_parsed,
18744                Ok(variant),
18745                "trait-idiomatic borrowed-input owned-`String` \
18746                 forward-projection + reverse-projection axis pair must \
18747                 round-trip &DepList::{variant:?} through \
18748                 `.into::<String>()` on the borrowed-input surface and \
18749                 back through `TryFrom<&str>` on the owned-`String`'s \
18750                 String::as_str borrow — a break signals the \
18751                 borrowed-input owned-`String` forward-emit and \
18752                 reverse-parse axes have drifted onto different \
18753                 vocabularies (unlike the peer CaixaKind axis pair, \
18754                 DepList's forward emit and reverse parse share the \
18755                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18756                 construction, so the round-trip composes directly)"
18757            );
18758        }
18759    }
18760
18761    #[test]
18762    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
18763        // Fail-before-pass-after byte-parity pin on the newly lifted
18764        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
18765        // asserts the standard-library trait impl and the substrate-
18766        // primitive [`super::DepList::as_str`] `pub const fn`
18767        // accessor resolve to the same two-arm emit-set across every
18768        // arm the exhaustive [`super::DepList::ALL`] slice
18769        // enumerates. Rust's standard library does not carry a
18770        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
18771        // (nor an `impl<T: fmt::Display> From<T> for
18772        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
18773        // projection axis is a distinct trait-idiomatic surface that
18774        // a `let key: Cow<'static, str> = list.into();`-shaped call
18775        // site reaches through this impl and no other — the paired
18776        // sibling `From<DepList> for &'static str` and
18777        // `From<DepList> for String` impls force every
18778        // `Cow<'static, str>`-parameterized call site through a
18779        // `Cow::Borrowed(list.as_str())` /
18780        // `Cow::Owned(list.to_string())` composition whose type
18781        // bounds have no compile-time link back to the substrate
18782        // primitive.
18783        //
18784        // Also asserts the projection lands on the zero-alloc
18785        // [`std::borrow::Cow::Borrowed`] arm (not the
18786        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18787        // [`super::DepList::as_str`] accessor's `&'static str`
18788        // return lifetime by construction (each match arm resolves
18789        // to one of the two lifted
18790        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18791        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
18792        // &str` values) makes the borrowed arm the type-correct
18793        // projection with no runtime allocation. Any future silent
18794        // detour that routes the impl through the owned arm trips
18795        // at caixa-core test time under the
18796        // [`std::borrow::Cow::Borrowed`] discriminator witness
18797        // rather than at a downstream `Cow<'static, str>`-bound
18798        // consumer's silent allocation.
18799        //
18800        // First-mover on the outside-M3 substrate-wide tier of the
18801        // substrate-wide trait-idiomatic
18802        // [`std::borrow::Cow<'static, str>`] forward-projection
18803        // campaign — extends the axis off the paired
18804        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
18805        // the paired M2 OTP-shape
18806        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
18807        // and [`crate::supervisor::RestartPolicy`] (0612398 +
18808        // ee577fd), and the paired M3-mesh-shape
18809        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
18810        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
18811        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
18812        // peers onto the first outside-M3 caixa-core peer (the two-
18813        // list dep-graph axis), opening the outside-M3 caixa-core
18814        // tier of the substrate-wide Cow<'static, str> forward-
18815        // projection campaign's owned-input corner.
18816        for &variant in super::DepList::ALL {
18817            let via_trait: std::borrow::Cow<'static, str> =
18818                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18819            let via_method: &'static str = variant.as_str();
18820            assert_eq!(
18821                via_trait.as_ref(),
18822                via_method,
18823                "From<DepList> for Cow<'static, str> impl must \
18824                 round-trip DepList::{variant:?} to the same lifted \
18825                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18826                 DepList::as_str returns — divergence signals a \
18827                 silent detour off the substrate-primitive accessor"
18828            );
18829            assert!(
18830                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
18831                "From<DepList> for Cow<'static, str> impl must land \
18832                 on the zero-alloc Cow::Borrowed arm on \
18833                 DepList::{variant:?} — a Cow::Owned outcome signals \
18834                 the projection has silently allocated where the \
18835                 substrate-primitive DepList::as_str `&'static str` \
18836                 return makes the borrowed arm the type-correct \
18837                 projection"
18838            );
18839            let via_into: std::borrow::Cow<'static, str> = variant.into();
18840            assert_eq!(
18841                via_into.as_ref(),
18842                via_method,
18843                "Into<Cow<'static, str>>::into on DepList::\
18844                 {variant:?} must byte-equal DepList::as_str on the \
18845                 same input — the blanket-derived Into shape must \
18846                 resolve to the same as_str dispatch as the explicit \
18847                 From impl"
18848            );
18849            assert!(
18850                matches!(via_into, std::borrow::Cow::Borrowed(_)),
18851                "Into<Cow<'static, str>>::into on DepList::\
18852                 {variant:?} must land on the zero-alloc \
18853                 Cow::Borrowed arm — the blanket-derived Into shape \
18854                 must resolve to the same Cow::Borrowed dispatch as \
18855                 the explicit From impl"
18856            );
18857        }
18858    }
18859
18860    #[test]
18861    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
18862        // Cross-axis partition pin: the newly lifted trait-idiomatic
18863        // `From<DepList> for std::borrow::Cow<'static, str>` (this
18864        // lift), the paired owned-input `From<DepList> for
18865        // &'static str` (3455cbf), and the paired owned-input
18866        // `From<DepList> for String` (32b0ee8) forward projections
18867        // must resolve identically on every arm, locking the three
18868        // return-shape paths together by construction so any future
18869        // detour trips at caixa-core test time. Also byte-parity
18870        // witness against the sibling [`ToString::to_string`]
18871        // surface routed through [`std::fmt::Display`] — every
18872        // owned-heap-string path (the `Cow::Owned` promotion of
18873        // this axis's `.into_owned()`, `From<DepList> for String`,
18874        // and `.to_string()`) resolves to the same two-arm lifted
18875        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18876        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
18877        // arm.
18878        //
18879        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
18880        // witness over [`super::DepList::ALL`] that materializes the
18881        // two-arm accept-set through the
18882        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
18883        // shape a future M4 admission-webhook rejection body's
18884        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
18885        // future substrate-wide per-arm diagnostic surface whose
18886        // typing rules out the sibling [`AsRef<str>`] borrowed
18887        // return, or a future per-arm dep-list emitter that binds
18888        // through a [`std::borrow::Cow<'static, str>`] boundary
18889        // reaches through — opening the composable-projection axis
18890        // on the first outside-M3 caixa-core closed-set fieldless
18891        // typed enum peer on the caixa surface. The pipe witness
18892        // also pins the zero-alloc discipline: every element in the
18893        // collected vector satisfies the
18894        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
18895        // accidental silent-allocation regression on the pipe's
18896        // iteration axis is a caixa-core-test-time failure.
18897        for &variant in super::DepList::ALL {
18898            let via_cow: std::borrow::Cow<'static, str> =
18899                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18900            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
18901            let via_string: String = <String as From<super::DepList>>::from(variant);
18902            assert_eq!(
18903                via_cow.as_ref(),
18904                via_static,
18905                "From<DepList> for Cow<'static, str> and \
18906                 From<DepList> for &'static str must resolve \
18907                 identically on DepList::{variant:?} — divergence \
18908                 signals the Cow<'static, str> and &'static str \
18909                 return-shape paths have drifted onto different \
18910                 emit-sets"
18911            );
18912            assert_eq!(
18913                via_cow.as_ref(),
18914                via_string.as_str(),
18915                "From<DepList> for Cow<'static, str> and \
18916                 From<DepList> for String must resolve identically \
18917                 on DepList::{variant:?} — divergence signals the \
18918                 Cow<'static, str> and String return-shape paths \
18919                 have drifted onto different emit-sets"
18920            );
18921            let via_to_string: String = variant.to_string();
18922            assert_eq!(
18923                via_cow.as_ref(),
18924                via_to_string.as_str(),
18925                "From<DepList> for Cow<'static, str> must byte-equal \
18926                 DepList::to_string on DepList::{variant:?} — \
18927                 divergence signals the trait-idiomatic \
18928                 Cow<'static, str> forward-projection axis and the \
18929                 ToString-through-Display axis have drifted onto \
18930                 different emit-sets"
18931            );
18932        }
18933        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18934            .iter()
18935            .copied()
18936            .map(std::borrow::Cow::from)
18937            .collect();
18938        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18939            .iter()
18940            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
18941            .collect();
18942        assert_eq!(
18943            via_iter, via_method,
18944            "`.iter().copied().map(Cow::from)` over DepList::ALL \
18945             must byte-equal `.iter().map(|l| \
18946             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
18947             idiomatic `From<DepList> for Cow<'static, str>` axis is \
18948             what makes the `Cow::from` composition route through \
18949             the substrate-primitive `DepList::as_str` accessor with \
18950             the zero-alloc Cow::Borrowed arm by construction, \
18951             rather than a per-call-site `Cow::Owned(list.to_string())` \
18952             allocation"
18953        );
18954        for cow in &via_iter {
18955            assert!(
18956                matches!(cow, std::borrow::Cow::Borrowed(_)),
18957                "every element of the .iter().copied().map(Cow::from) \
18958                 pipe over DepList::ALL must land on the zero-alloc \
18959                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
18960                 signals the pipe's iteration axis has silently \
18961                 allocated where the substrate-primitive \
18962                 DepList::as_str `&'static str` return makes the \
18963                 borrowed arm the type-correct projection"
18964            );
18965        }
18966    }
18967
18968    #[test]
18969    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
18970        // Fail-before-pass-after byte-parity pin on the newly lifted
18971        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
18972        // asserts the borrowed-input standard-library trait impl and
18973        // the substrate-primitive [`super::DepList::as_str`] `pub const
18974        // fn` accessor resolve to the same two-arm emit-set across
18975        // every arm the exhaustive [`super::DepList::ALL`] slice
18976        // enumerates. Rust's standard library does not carry a blanket
18977        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
18978        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
18979        // the borrowed-input `Cow<'static, str>` forward-projection
18980        // axis is a distinct trait-idiomatic surface that a
18981        // `let key: Cow<'static, str> = (&list).into();`-shaped call
18982        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
18983        // reaches through this impl and no other — the paired owned-
18984        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
18985        // forces every borrowed-input call site through an explicit
18986        // `Copy` deref (`Cow::from(*list)`) or a
18987        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
18988        // have no compile-time link back to the substrate primitive.
18989        //
18990        // Also asserts the projection lands on the zero-alloc
18991        // [`std::borrow::Cow::Borrowed`] arm (not the
18992        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18993        // [`super::DepList::as_str`] accessor's `&'static str` return
18994        // lifetime by construction (each match arm resolves to one of
18995        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18996        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
18997        // values) makes the borrowed arm the type-correct projection
18998        // with no runtime allocation on the borrowed-input surface
18999        // just as on the paired owned-input surface.
19000        //
19001        // Closes the `{Self, &Self}` input-shape corner on the outside-
19002        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19003        // on the first outside-M3 caixa-core closed-set fieldless typed
19004        // enum peer on the caixa surface, exactly as afdf0f4 closed it
19005        // on the second M3-mesh-primitive peer
19006        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19007        // the owning half (eee504d) landed, as 25690ef closed it on
19008        // the first M3-mesh-primitive peer
19009        // ([`crate::aplicacao::WitShape`]) one commit after the owning
19010        // half (8634dec) landed, as d45c409 closed it on the top-level
19011        // [`crate::CaixaKind`] one commit after the owning half
19012        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19013        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19014        // [`crate::supervisor::RestartPolicy`] sibling peers one
19015        // commit after (7dd28b3 / 0612398) landed.
19016        for &variant in super::DepList::ALL {
19017            let via_trait: std::borrow::Cow<'static, str> =
19018                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19019            let via_method: &'static str = variant.as_str();
19020            assert_eq!(
19021                via_trait.as_ref(),
19022                via_method,
19023                "From<&DepList> for Cow<'static, str> impl must \
19024                 round-trip &DepList::{variant:?} to the same lifted \
19025                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19026                 DepList::as_str returns — divergence signals a silent \
19027                 detour off the substrate-primitive accessor"
19028            );
19029            assert!(
19030                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19031                "From<&DepList> for Cow<'static, str> impl must land \
19032                 on the zero-alloc Cow::Borrowed arm on \
19033                 &DepList::{variant:?} — a Cow::Owned outcome signals \
19034                 the projection has silently allocated where the \
19035                 substrate-primitive DepList::as_str `&'static str` \
19036                 return makes the borrowed arm the type-correct \
19037                 projection"
19038            );
19039            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19040            assert_eq!(
19041                via_into.as_ref(),
19042                via_method,
19043                "Into<Cow<'static, str>>::into on &DepList::\
19044                 {variant:?} must byte-equal DepList::as_str on the \
19045                 same input — the blanket-derived Into shape must \
19046                 resolve to the same as_str dispatch as the explicit \
19047                 From impl"
19048            );
19049            assert!(
19050                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19051                "Into<Cow<'static, str>>::into on &DepList::\
19052                 {variant:?} must land on the zero-alloc \
19053                 Cow::Borrowed arm — the blanket-derived Into shape \
19054                 must resolve to the same Cow::Borrowed dispatch as \
19055                 the explicit From impl"
19056            );
19057        }
19058    }
19059
19060    #[test]
19061    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19062        // Cross-axis partition pin: the newly lifted trait-idiomatic
19063        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19064        // str>` (this lift), the paired owned-input `From<DepList> for
19065        // std::borrow::Cow<'static, str>` (6858bac), the paired
19066        // borrowed-input owned-`&'static str` `From<&DepList> for
19067        // &'static str` (3455cbf), and the paired borrowed-input
19068        // owned-`String` `From<&DepList> for String` must resolve
19069        // identically on every arm, locking the four return-shape ×
19070        // input-shape paths together by construction so any future
19071        // detour trips at caixa-core test time. Also byte-parity
19072        // witness against the sibling [`ToString::to_string`] surface
19073        // routed through [`std::fmt::Display`] — every owned-heap-
19074        // string path (this axis's `.into_owned()` promotion, the
19075        // paired [`From<&DepList> for String`], and `.to_string()`)
19076        // resolves to the same two-arm lifted
19077        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19078        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19079        // arm.
19080        //
19081        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19082        // over [`super::DepList::ALL`] — whose iterator yields
19083        // `&DepList` by construction, so the borrowed-input
19084        // [`Cow<'static, str>`] axis is what routes the pipe through
19085        // the substrate-primitive [`super::DepList::as_str`] accessor
19086        // without a spurious [`Copy`] deref (which would only be
19087        // reachable through the owned-input [`From<DepList> for
19088        // Cow<'static, str>`] axis by first calling `.copied()` on the
19089        // iterator). The pipe witness also pins the zero-alloc
19090        // discipline: every element in the collected vector satisfies
19091        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19092        // future accidental silent-allocation regression on the pipe's
19093        // iteration axis is a caixa-core-test-time failure. Peer of
19094        // the sibling
19095        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19096        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19097        // axis — extends the whole borrowed-input `Cow<'static, str>`
19098        // + paired `{&'static str, String}` cross-axis-parity corner
19099        // onto the first outside-M3 caixa-core closed-set fieldless
19100        // typed enum peer on the caixa surface.
19101        for &variant in super::DepList::ALL {
19102            let borrowed_cow: std::borrow::Cow<'static, str> =
19103                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19104            let owned_cow: std::borrow::Cow<'static, str> =
19105                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19106            let borrowed_static: &'static str =
19107                <&'static str as From<&super::DepList>>::from(&variant);
19108            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19109            assert_eq!(
19110                borrowed_cow, owned_cow,
19111                "From<&DepList> for Cow<'static, str> and \
19112                 From<DepList> for Cow<'static, str> must resolve \
19113                 identically on DepList::{variant:?} — divergence \
19114                 signals the borrowed-input and owned-input \
19115                 Cow<'static, str> forward-projection input-shape \
19116                 paths have drifted onto different emit-sets"
19117            );
19118            assert_eq!(
19119                borrowed_cow.as_ref(),
19120                borrowed_static,
19121                "From<&DepList> for Cow<'static, str> and \
19122                 From<&DepList> for &'static str must resolve \
19123                 identically on DepList::{variant:?} — divergence \
19124                 signals the borrowed-input Cow<'static, str> and \
19125                 &'static str return-shape paths have drifted onto \
19126                 different emit-sets"
19127            );
19128            assert_eq!(
19129                borrowed_cow.as_ref(),
19130                borrowed_string.as_str(),
19131                "From<&DepList> for Cow<'static, str> and \
19132                 From<&DepList> for String must resolve identically \
19133                 on DepList::{variant:?} — divergence signals the \
19134                 borrowed-input Cow<'static, str> and owned-`String` \
19135                 return-shape paths have drifted onto different \
19136                 emit-sets"
19137            );
19138            let via_to_string: String = variant.to_string();
19139            assert_eq!(
19140                borrowed_cow.as_ref(),
19141                via_to_string.as_str(),
19142                "From<&DepList> for Cow<'static, str> must byte-equal \
19143                 DepList::to_string on DepList::{variant:?} — \
19144                 divergence signals the trait-idiomatic borrowed-input \
19145                 Cow<'static, str> forward-projection axis and the \
19146                 ToString-through-Display axis have drifted onto \
19147                 different emit-sets"
19148            );
19149        }
19150        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19151            .iter()
19152            .map(std::borrow::Cow::from)
19153            .collect();
19154        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19155            .iter()
19156            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19157            .collect();
19158        assert_eq!(
19159            via_iter, via_method,
19160            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19161             whose iteration axis holds &DepList by construction — \
19162             must byte-equal `.iter().map(|l| \
19163             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19164             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19165             str>` axis is what makes the `Cow::from` composition \
19166             route through the substrate-primitive `DepList::as_str` \
19167             accessor with the zero-alloc Cow::Borrowed arm by \
19168             construction and without a spurious `Copy` deref (which \
19169             would only be reachable through the owned-input \
19170             `From<DepList> for Cow<'static, str>` axis by first \
19171             calling `.copied()` on the iterator)"
19172        );
19173        for cow in &via_iter {
19174            assert!(
19175                matches!(cow, std::borrow::Cow::Borrowed(_)),
19176                "every element of the .iter().map(Cow::from) pipe \
19177                 over DepList::ALL must land on the zero-alloc \
19178                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19179                 signals the pipe's iteration axis has silently \
19180                 allocated where the substrate-primitive \
19181                 DepList::as_str `&'static str` return makes the \
19182                 borrowed arm the type-correct projection"
19183            );
19184        }
19185    }
19186
19187    #[test]
19188    fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19189        // Fail-before-pass-after byte-parity pin on the newly lifted
19190        // `impl From<DepList> for Box<str>` — asserts the owned-input
19191        // standard-library trait impl and the substrate-primitive
19192        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19193        // the same two-arm emit-set (the paired
19194        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19195        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19196        // byte-strings) across every arm the exhaustive
19197        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19198        // core-internal tier of the substrate-wide [`Box<str>`] forward-
19199        // projection campaign onto the second caixa-core-internal peer,
19200        // after the render-side path-shape-diagnostic
19201        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19202        // both corners in one axis) opened the tier. Rust's standard
19203        // library carries `impl From<&str> for Box<str>` and
19204        // `impl From<String> for Box<str>` but no blanket
19205        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19206        // distinct trait-idiomatic surface that a
19207        // `let key: Box<str> = list.into();`-shaped call site reaches
19208        // through this impl and no other — a paired
19209        // `Box::from(list.as_str())` open-code has no compile-time link
19210        // back to the substrate primitive.
19211        for &variant in super::DepList::ALL {
19212            let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19213            let via_method: &'static str = variant.as_str();
19214            assert_eq!(
19215                via_trait.as_ref(),
19216                via_method,
19217                "From<DepList> for Box<str> impl must round-trip \
19218                 DepList::{variant:?} to the same lifted \
19219                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19220                 DepList::as_str returns — divergence signals a silent \
19221                 detour off the substrate-primitive accessor"
19222            );
19223            let via_into: Box<str> = variant.into();
19224            assert_eq!(
19225                via_into.as_ref(),
19226                via_method,
19227                "Into<Box<str>>::into on DepList::{variant:?} must \
19228                 byte-equal DepList::as_str on the same input — the \
19229                 blanket-derived Into shape must resolve to the same \
19230                 as_str dispatch as the explicit From impl"
19231            );
19232        }
19233    }
19234
19235    #[test]
19236    fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19237        // Fail-before-pass-after byte-parity pin on the newly lifted
19238        // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19239        // standard-library trait impl and the substrate-primitive
19240        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19241        // the same two-arm emit-set (the paired
19242        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19243        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19244        // byte-strings) across every arm the exhaustive
19245        // [`super::DepList::ALL`] slice enumerates. Rust's standard
19246        // library carries `impl From<&str> for Box<str>` and
19247        // `impl From<String> for Box<str>` but no blanket
19248        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19249        // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19250        // input [`Box<str>`] forward-projection axis is a distinct
19251        // trait-idiomatic surface that a
19252        // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19253        // iterator over `&'static [DepList]` yields `&DepList` by
19254        // construction) or a `let key: Box<str> = (&list).into();`-shaped
19255        // call site reaches through this impl and no other — the paired
19256        // owned-input `From<DepList> for Box<str>` impl alone would force
19257        // every borrowed-input call site through an explicit `Copy` deref
19258        // (`Box::<str>::from(*list)`) or a
19259        // `Box::<str>::from(list.as_str())` open-code whose type bounds
19260        // have no compile-time link back to the substrate primitive.
19261        //
19262        // Closes the `{Self, &Self}` input-shape corner on the second
19263        // caixa-core-internal closed-set fieldless typed enum peer of
19264        // the substrate-wide [`Box<str>`] forward-projection campaign —
19265        // one commit after the paired render-side path-shape-diagnostic
19266        // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19267        // opened the caixa-core-internal tier — matching the trajectory
19268        // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19269        // in one axis), the caixa-provedor `FerriteRuntime` pair
19270        // (14886a8, both corners in one axis), and the render-side
19271        // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19272        // walked before it.
19273        for &variant in super::DepList::ALL {
19274            let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19275            let via_method: &'static str = variant.as_str();
19276            assert_eq!(
19277                via_trait.as_ref(),
19278                via_method,
19279                "From<&DepList> for Box<str> impl must round-trip \
19280                 &DepList::{variant:?} to the same lifted \
19281                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19282                 DepList::as_str returns — divergence signals a silent \
19283                 detour off the substrate-primitive accessor"
19284            );
19285            let via_into: Box<str> = (&variant).into();
19286            assert_eq!(
19287                via_into.as_ref(),
19288                via_method,
19289                "Into<Box<str>>::into on &DepList::{variant:?} must \
19290                 byte-equal DepList::as_str on the same input — the \
19291                 blanket-derived Into shape on the borrowed-input \
19292                 surface must resolve to the same as_str dispatch as \
19293                 the explicit From impl"
19294            );
19295        }
19296
19297        // Pipe witness — the distinguishing shape that forces the
19298        // borrowed-input axis to be independent of the owned-input
19299        // peer. `DepList::ALL.iter()` yields `&DepList` by
19300        // construction, so `.map(Box::<str>::from)` resolves through
19301        // the borrowed-input `From<&DepList> for Box<str>` impl and
19302        // no other — without this axis, the same pipe would force an
19303        // explicit `.copied()` restatement whose type bounds bypass
19304        // the substrate primitive.
19305        let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19306        let via_accessor: Vec<&'static str> =
19307            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19308        assert_eq!(
19309            via_pipe.len(),
19310            via_accessor.len(),
19311            "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19312             preserve arity against the paired DepList::as_str \
19313             accessor — a length divergence signals the borrowed-input \
19314             axis has silently rejected an arm"
19315        );
19316        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19317            assert_eq!(
19318                pipe_arm.as_ref(),
19319                *accessor_arm,
19320                "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19321                 byte-equal the paired \
19322                 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19323                 arm — divergence signals the borrowed-input \
19324                 `From<&DepList> for Box<str>` axis has silently \
19325                 detoured off the substrate-primitive accessor"
19326            );
19327        }
19328    }
19329}
19330
19331#[cfg(test)]
19332mod dep_source_is_variant_tests {
19333    use super::*;
19334
19335    fn all_variants() -> Vec<(DepSource, &'static str)> {
19336        vec![
19337            (
19338                DepSource::Git {
19339                    repo: "github:pleme-io/caixa-teia".into(),
19340                    tag: Some("v0.1.0".into()),
19341                    rev: None,
19342                    branch: None,
19343                },
19344                "Git",
19345            ),
19346            (
19347                DepSource::Path {
19348                    caminho: "../caixa-teia".into(),
19349                },
19350                "Path",
19351            ),
19352        ]
19353    }
19354
19355    fn predicate_row(s: &DepSource) -> [bool; 2] {
19356        [s.is_git(), s.is_path()]
19357    }
19358
19359    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
19360    // derive-generated per-arm predicate partition — for every variant
19361    // in `all_variants()`, the observed 2-slot predicate row must equal
19362    // a one-hot row with the `true` at exactly the same index as the
19363    // variant's declaration order. Expected rows are generated live
19364    // from the enumeration rather than transcribed by hand, so a
19365    // copy-paste flip that reroutes one arm through the wrong predicate
19366    // lane trips at the identity-diagonal assertion the way every peer
19367    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
19368    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
19369    // / [`crate::upgrade::UpgradeInstruction`] /
19370    // [`crate::aplicacao::PlacementStrategy`] /
19371    // [`crate::aplicacao::RateLimitUnit`] /
19372    // [`crate::aplicacao::WitTarget`] /
19373    // [`crate::render::PathShapeViolation`] partition pin already does.
19374    #[test]
19375    fn dep_source_is_variant_predicates_partition_the_arm_set() {
19376        let variants = all_variants();
19377        for (idx, (variant, name)) in variants.iter().enumerate() {
19378            let observed = predicate_row(variant);
19379            let mut expected = [false; 2];
19380            expected[idx] = true;
19381            assert_eq!(
19382                observed, expected,
19383                "DepSource::{name} at declaration-order slot {idx} must \
19384                 satisfy exactly one is_* predicate (its own); observed \
19385                 row must equal the one-hot expected row — a drift \
19386                 would silently reroute one `:fonte`-arm consumer \
19387                 through the wrong predicate lane"
19388            );
19389        }
19390    }
19391
19392    // Byte-parity pin on the two field-agnostic `matches!` shapes the
19393    // per-arm arm-discriminator predicates replace at any future
19394    // consumer site (a `:fonte`-shape-only lint rule that flags path
19395    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
19396    // a future admission-webhook that rejects `:fonte` shapes outside
19397    // the `is_git()` accept-set, a caixa-lacre indexing pass that
19398    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
19399    // Refuses a future accidental split between the derived predicate
19400    // and its `matches!` shape — a hand-rolled shadow impl that
19401    // overrides one path, an accidental rebrand that leaves one
19402    // consumer on the raw `matches!` form — on the two load-bearing
19403    // `:fonte`-arm-discriminator axes every downstream substrate
19404    // consumer of the dep-source axis keys off.
19405    #[test]
19406    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
19407        for (variant, name) in all_variants() {
19408            let via_matches_git = matches!(variant, DepSource::Git { .. });
19409            let via_predicate_git = variant.is_git();
19410            assert_eq!(
19411                via_predicate_git, via_matches_git,
19412                "DepSource::{name}.is_git() must byte-equal \
19413                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
19414                 future converged consumer site would silently \
19415                 disagree with its pre-lift shape"
19416            );
19417            let via_matches_path = matches!(variant, DepSource::Path { .. });
19418            let via_predicate_path = variant.is_path();
19419            assert_eq!(
19420                via_predicate_path, via_matches_path,
19421                "DepSource::{name}.is_path() must byte-equal \
19422                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
19423                 future converged consumer site would silently \
19424                 disagree with its pre-lift shape"
19425            );
19426        }
19427    }
19428
19429    // Cross-pin against every constructor path that materializes a
19430    // [`DepSource`] shape today (the [`DepSource::default_github`]
19431    // resolver-side fallback that materializes an unpinned
19432    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
19433    // surface constructor that materializes a pinned `:tag`-carrying
19434    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
19435    // fixture family builds inline). Every constructor's return must
19436    // satisfy the arm-discriminator predicate the constructor's
19437    // variant name matches — a future constructor addition (an
19438    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
19439    // enclosing docstring already names as a trajectory item) surfaces
19440    // as a build-time failure that names the offending drift when its
19441    // return arm doesn't route through the paired predicate.
19442    #[test]
19443    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
19444        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
19445        assert!(
19446            via_default_github.is_git(),
19447            "DepSource::default_github must materialize a Git-arm shape — \
19448             a future constructor that routed through a non-Git arm \
19449             (a registry-fetch pin, a `DepSource::Feira` promotion) \
19450             would silently split the resolver's unpinned-shorthand \
19451             materializer from the sole_pin() precedence cascade"
19452        );
19453        assert!(
19454            !via_default_github.is_path(),
19455            "DepSource::default_github must NOT materialize a Path-arm \
19456             shape — the paired negation pin"
19457        );
19458
19459        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
19460            .fonte
19461            .expect("Dep::git materializes a Some(fonte)");
19462        assert!(
19463            via_dep_git.is_git(),
19464            "Dep::git's `:fonte` materialization must land on the Git \
19465             arm — the author-surface pinned-git constructor's return \
19466             must route through the paired predicate"
19467        );
19468        assert!(!via_dep_git.is_path(), "paired negation pin");
19469
19470        let via_path = DepSource::Path {
19471            caminho: "../caixa-teia".into(),
19472        };
19473        assert!(
19474            via_path.is_path(),
19475            "the dev-mode Path-arm materialization must satisfy is_path()"
19476        );
19477        assert!(!via_path.is_git(), "paired negation pin");
19478    }
19479
19480    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
19481    //    String, reason: String }` three-slot envelope on `DepError`,
19482    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
19483    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
19484    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
19485    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
19486    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
19487    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
19488
19489    #[test]
19490    fn versao_invalid_ctor_matches_struct_literal_wrap() {
19491        assert_eq!(
19492            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
19493            DepError::VersaoInvalid {
19494                nome: "caixa-teia".to_string(),
19495                versao: "^0..1".to_string(),
19496                reason: "invalid comparator".to_string(),
19497            },
19498            "versao_invalid ctor must produce byte-equal \
19499             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
19500        );
19501    }
19502
19503    #[test]
19504    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
19505        assert_eq!(
19506            DepError::fonte_repo_shape(
19507                "caixa-teia",
19508                "-upload-pack=evil",
19509                "leading dash rejected".to_string(),
19510            ),
19511            DepError::FonteRepoShape {
19512                nome: "caixa-teia".to_string(),
19513                repo: "-upload-pack=evil".to_string(),
19514                reason: "leading dash rejected".to_string(),
19515            },
19516            "fonte_repo_shape ctor must produce byte-equal \
19517             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
19518        );
19519    }
19520
19521    #[test]
19522    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
19523        assert_eq!(
19524            DepError::caracteristica_invalid(
19525                "caixa-teia",
19526                "bad feature!",
19527                "embedded space rejected".to_string(),
19528            ),
19529            DepError::CaracteristicaInvalid {
19530                nome: "caixa-teia".to_string(),
19531                caracteristica: "bad feature!".to_string(),
19532                reason: "embedded space rejected".to_string(),
19533            },
19534            "caracteristica_invalid ctor must produce byte-equal \
19535             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
19536        );
19537    }
19538
19539    #[test]
19540    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
19541        // Cross-axis routing pin: sweep the three constructor input axes
19542        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
19543        // distinct-per-axis fixtures against every generated arm in the
19544        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
19545        // lowercase / trim / truncate on the two `&str` axes — a silent
19546        // field swap between `nome`, the middle `<axis>` field, and
19547        // `reason`, or a `reason` axis silently rerouted through
19548        // `.to_string()` instead of forwarded owned — surfaces here rather
19549        // than at a downstream diagnostic-shape mismatch. Peer of the
19550        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
19551        // through_to_string` (0e35793) cross-axis routing pin on the same
19552        // envelope's `{ nome, caminho, byte }` three-slot family and of
19553        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
19554        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
19555        // — extended here onto the `{ nome, <axis>: String, reason:
19556        // String }` three-slot envelope so every substrate-primitive ctor
19557        // family in caixa-core's `DepError` envelope guarantees each field
19558        // routes the caller's value verbatim through `.to_string()` (or
19559        // owned-forward for `reason: String`) in declared field order.
19560        // Distinct-per-axis fixtures rule out any two-axis swap
19561        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
19562        // same-fixture-per-axis pin.
19563        let nome = "sibling-teia";
19564        let axis = "distinct-axis-value";
19565        let reason = "distinct rejection sentence".to_string();
19566        assert_eq!(
19567            DepError::versao_invalid(nome, axis, reason.clone()),
19568            DepError::VersaoInvalid {
19569                nome: nome.to_string(),
19570                versao: axis.to_string(),
19571                reason: reason.clone(),
19572            },
19573            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
19574             `reason` → `reason` in declared field order",
19575        );
19576        assert_eq!(
19577            DepError::fonte_repo_shape(nome, axis, reason.clone()),
19578            DepError::FonteRepoShape {
19579                nome: nome.to_string(),
19580                repo: axis.to_string(),
19581                reason: reason.clone(),
19582            },
19583            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
19584             `reason` → `reason` in declared field order",
19585        );
19586        assert_eq!(
19587            DepError::caracteristica_invalid(nome, axis, reason.clone()),
19588            DepError::CaracteristicaInvalid {
19589                nome: nome.to_string(),
19590                caracteristica: axis.to_string(),
19591                reason: reason.clone(),
19592            },
19593            "caracteristica_invalid must route `nome` → `nome`, \
19594             `axis` → `caracteristica`, `reason` → `reason` in declared \
19595             field order",
19596        );
19597    }
19598
19599    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
19600    //    two-slot envelope on `DepError`, missing rung between
19601    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
19602    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
19603    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
19604    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
19605    //    two-slot `{ nome, list: &'static str }` envelope (same slot
19606    //    count, `&'static str` axis instead of owned `String` axis).
19607
19608    #[test]
19609    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
19610        assert_eq!(
19611            DepError::fonte_pin_empty("caixa-teia", ":tag"),
19612            DepError::FontePinEmpty {
19613                nome: "caixa-teia".to_string(),
19614                pin: ":tag".to_string(),
19615            },
19616            "fonte_pin_empty ctor must produce byte-equal \
19617             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
19618             on the same `(&str, &str)` fixture",
19619        );
19620    }
19621
19622    #[test]
19623    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
19624        assert_eq!(
19625            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
19626            DepError::FontePinAmbiguous {
19627                nome: "caixa-teia".to_string(),
19628                pins: ":tag, :rev".to_string(),
19629            },
19630            "fonte_pin_ambiguous ctor must produce byte-equal \
19631             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
19632             wrap on the same `(&str, &str)` fixture",
19633        );
19634    }
19635
19636    #[test]
19637    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
19638        assert_eq!(
19639            DepError::caracteristica_duplicate("caixa-teia", "http"),
19640            DepError::CaracteristicaDuplicate {
19641                nome: "caixa-teia".to_string(),
19642                caracteristica: "http".to_string(),
19643            },
19644            "caracteristica_duplicate ctor must produce byte-equal \
19645             `DepError::CaracteristicaDuplicate` to the pre-lift \
19646             struct-literal wrap on the same `(&str, &str)` fixture",
19647        );
19648    }
19649
19650    #[test]
19651    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
19652        // Owned-`String` routing pin: thread the real
19653        // `set.join(", ")` `String` carrier through the ctor's
19654        // `&str`-parameter Deref coercion, so the ambiguity-arm
19655        // wire-up site's actual `&set.join(", ")` shape stays
19656        // byte-equal to a direct `":tag, :rev"` literal. A future
19657        // parameter-shape change silently dropping the Deref
19658        // coercion route (e.g., a switch to `impl Into<String>`)
19659        // surfaces here rather than at the wire-up's compile
19660        // error far from the ctor definition.
19661        let set: Vec<&'static str> = vec![":tag", ":rev"];
19662        let joined: String = set.join(", ");
19663        assert_eq!(
19664            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
19665            DepError::FontePinAmbiguous {
19666                nome: "caixa-teia".to_string(),
19667                pins: ":tag, :rev".to_string(),
19668            },
19669            "fonte_pin_ambiguous ctor must accept an owned-`String` \
19670             `&set.join(\", \")` carrier via Deref coercion — the exact \
19671             shape the ambiguity-arm wire-up site passes into it",
19672        );
19673    }
19674
19675    #[test]
19676    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
19677        // Cross-axis routing pin: sweep the two constructor input axes
19678        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
19679        // fixtures against every generated arm in the
19680        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
19681        // trim / truncate at codegen time — a silent field swap between
19682        // `nome` and the middle `<axis>` field, or a `<axis>` axis
19683        // silently rerouted through the wrong field on any one variant
19684        // — surfaces here rather than at a downstream diagnostic-shape
19685        // mismatch. Peer of the sibling
19686        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
19687        // (6f5e0cd) pin on the same envelope's peer two-slot family
19688        // (`{ nome, list: &'static str }`) and of the sibling
19689        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19690        // (5621f8a) pin on the same envelope's three-slot `{ nome,
19691        // <axis>: String, reason: String }` family — extended here onto
19692        // the `{ nome, <axis>: String }` two-slot envelope so the last
19693        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
19694        // ladder guarantees each field routes the caller's value
19695        // verbatim through `.to_string()` in declared field order.
19696        // Distinct-per-axis fixtures rule out any two-axis swap
19697        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
19698        // per-axis pin.
19699        let nome = "sibling-teia";
19700        let axis = "distinct-axis-value";
19701        assert_eq!(
19702            DepError::fonte_pin_empty(nome, axis),
19703            DepError::FontePinEmpty {
19704                nome: nome.to_string(),
19705                pin: axis.to_string(),
19706            },
19707            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
19708             in declared field order",
19709        );
19710        assert_eq!(
19711            DepError::fonte_pin_ambiguous(nome, axis),
19712            DepError::FontePinAmbiguous {
19713                nome: nome.to_string(),
19714                pins: axis.to_string(),
19715            },
19716            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
19717             in declared field order",
19718        );
19719        assert_eq!(
19720            DepError::caracteristica_duplicate(nome, axis),
19721            DepError::CaracteristicaDuplicate {
19722                nome: nome.to_string(),
19723                caracteristica: axis.to_string(),
19724            },
19725            "caracteristica_duplicate must route `nome` → `nome`, \
19726             `axis` → `caracteristica` in declared field order",
19727        );
19728    }
19729
19730    #[test]
19731    fn nome_invalid_ctor_matches_struct_literal_wrap() {
19732        // Equivalence pin: the ctor produces byte-equal
19733        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
19734        // literal that cloned the offending `:deps :nome` verbatim and
19735        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
19736        // owned `reason` payload at the caller site inside
19737        // [`Dep::validate`]. Guards any future field-addition /
19738        // reordering / accessor-return tweak on the variant. Sibling of
19739        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
19740        // (below) and the sibling three-slot
19741        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19742        // pin on the same envelope's three-slot `{ nome, <axis>: String,
19743        // reason: String }` family.
19744        let nome = "Caixa-Teia";
19745        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
19746        let via_ctor = DepError::nome_invalid(nome, reason.clone());
19747        let via_literal = DepError::NomeInvalid {
19748            nome: nome.to_string(),
19749            reason,
19750        };
19751        assert_eq!(
19752            via_ctor, via_literal,
19753            "nome_invalid(nome, reason) must byte-equal the open-coded \
19754             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
19755        );
19756        assert_eq!(
19757            via_ctor.to_string(),
19758            via_literal.to_string(),
19759            "Display byte-string must byte-equal the open-coded struct-literal"
19760        );
19761    }
19762
19763    #[test]
19764    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
19765        // Boundary-sweep pin on the ctor's two-slot projection: sweep
19766        // the two ctor input axes (`nome: &str`, `reason: String`)
19767        // through distinct-per-axis fixtures against a representative
19768        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
19769        // wrapper-side silent lowercase / trim / truncate at codegen
19770        // time — a silent field swap between `nome` and `reason`, an
19771        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
19772        // divergence on the `reason` axis — surfaces at caixa-core
19773        // build time rather than at a downstream diagnostic consumer
19774        // that reads `err.nome` / `err.reason` back and gets a different
19775        // value than the one it stored. Peer of the sibling
19776        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
19777        // (7f7c950) pin on the same envelope's peer two-slot family
19778        // (`{ nome, <axis>: String }`) — extended here onto the
19779        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
19780        // variant carries. Distinct-per-axis fixtures rule out any
19781        // two-axis swap (`nome` ↔ `reason`) that would still pass a
19782        // same-fixture-per-axis pin. The sweep list carries a mixed
19783        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
19784        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
19785        // over-63-byte) so a future silent per-input normalization
19786        // surfaces on the arm that diverges.
19787        for nome in [
19788            "Caixa-Teia",
19789            "caixa_teia",
19790            "caixa.teia",
19791            "-caixa-teia",
19792            "caixa-teia-",
19793            "caixa/teia",
19794            &"a".repeat(64),
19795        ] {
19796            let reason = crate::render::is_dns_1123_label(nome)
19797                .expect_err("fixture must be a DNS-1123-refused label");
19798            let via_ctor = DepError::nome_invalid(nome, reason.clone());
19799            let DepError::NomeInvalid {
19800                nome: stored_nome,
19801                reason: stored_reason,
19802            } = via_ctor
19803            else {
19804                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
19805            };
19806            assert_eq!(
19807                stored_nome, nome,
19808                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
19809            );
19810            assert_eq!(
19811                stored_reason, reason,
19812                "reason slot must forward the owned `String` verbatim for {nome:?}"
19813            );
19814        }
19815    }
19816
19817    #[test]
19818    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
19819        // End-to-end pin: the sole in-crate wire-up site
19820        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
19821        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
19822        // the ctor's output on the same DNS-1123-refused `:deps :nome`
19823        // fixture, with identical `Display` rendering. A future silent
19824        // de-lift of the wire-up back to the open-coded struct-literal
19825        // trips this test at caixa-core build time rather than at a
19826        // downstream diagnostic consumer far from the wire-up commit.
19827        // Sibling of the peer
19828        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
19829        // pin on the same wire-up — extended here from a `matches!`
19830        // shape check to a byte-identity + Display parity route through
19831        // the ctor.
19832        let d = Dep::simple("Caixa_Teia", "^0.1");
19833        let observed = d.validate().unwrap_err();
19834        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
19835            .expect_err("fixture must be DNS-1123-refused");
19836        let expected = DepError::nome_invalid("Caixa_Teia", reason);
19837        assert_eq!(
19838            observed, expected,
19839            "Dep::validate's DNS-1123 refusal arm must byte-equal \
19840             nome_invalid(nome, reason)"
19841        );
19842        assert_eq!(
19843            observed.to_string(),
19844            expected.to_string(),
19845            "Display byte-string parity"
19846        );
19847    }
19848}