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/// Trait-idiomatic *owned-input, [`std::sync::Arc<str>`] output* forward
4079/// projection on the outside-M3 caixa-core two-list dep-graph [`DepList`]
4080/// closed-set fieldless typed enum. Routes byte-for-byte through the
4081/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor via
4082/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4083/// every consumer that binds a
4084/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4085/// the same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4086/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4087/// the sibling
4088/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4089/// forward-projection corner already returns.
4090///
4091/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4092/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4093/// `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
4094/// `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so this axis
4095/// is a distinct trait-idiomatic surface that a
4096/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4097/// through this impl and no other — a paired
4098/// `std::sync::Arc::<str>::from(list.as_str())` open-code has no compile-
4099/// time link back to the substrate primitive, and a two-step
4100/// `std::sync::Arc::<str>::from(String::from(list))` composition through
4101/// the owned-`String` axis allocates twice (once into the intermediate
4102/// `String`, once into the [`std::sync::Arc<str>`] on the `From<String>`
4103/// conversion) where the single-step trait impl allocates once. The
4104/// shared-ownership + [`Sync`] + [`Send`] contract [`std::sync::Arc<str>`]
4105/// provides is the distinct value the sibling [`Box<str>`] axis's owned-
4106/// move return-shape cannot provide — a per-`:deps` / `:deps-dev` census
4107/// key reachable from multiple concurrent per-Caixa reconcile / per-lint
4108/// tasks through the same two lifted
4109/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4110/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-strings, without a
4111/// `.clone()`-per-task materialization the owned-move [`Box<str>`] axis
4112/// would force.
4113///
4114/// Extends the caixa-core-internal tier of the substrate-wide trait-
4115/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
4116/// second caixa-core-internal peer, after the top-level
4117/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) opened
4118/// the tier. Follows the M2 OTP-shape
4119/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4120/// pair (bca2ec8 + b3e72d7 / b05724e + ea91551), the M3 mesh-shape
4121/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4122/// [`crate::aplicacao::RateLimitUnit`] triple (977d577 → dae722f), and
4123/// the outside-`caixa-core` tier (`InvariantKind` 4e923c1 + 03c043f,
4124/// `ArchVerdict` 1682f8b + 92ddfb2, `Severity` a7a9a6d + 4f041e1,
4125/// `FixSafety` fb73edb + 822138e, `Semantic` 65dbcff + f3a55c7,
4126/// `FerriteRuntime` 938d915 + 0afef4b) that closed prior tiers on this
4127/// same Arc<str> axis. Same discipline as those peers: forward emit
4128/// (this impl, the sibling
4129/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4130/// forward-projection corner, [`std::fmt::Display`], [`AsRef<str>`],
4131/// [`DepList::as_str`]) and reverse parse ([`DepList::from_wire`],
4132/// [`TryFrom<&str>`]) route through the same two lifted
4133/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4134/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4135/// strings by construction, so the round-trip composes directly without
4136/// the wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis
4137/// pair requires.
4138///
4139/// A future variant addition (a `Build` build-time-only dep-list axis the
4140/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4141/// `[build-dependencies]` table gains substrate visibility) reaches the
4142/// paired [`std::sync::Arc<str>`] output axis through one match-arm edit
4143/// on the [`DepList::as_str`] `pub const fn` accessor, not a coordinated
4144/// rewrite of every downstream
4145/// `std::sync::Arc::<str>::from(list.as_str())` open-code.
4146///
4147/// Pinned load-bearing by
4148/// [`tests::dep_list_from_into_arc_str_routes_through_as_str_accessor`]
4149/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4150/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4151/// derived [`Into`] shape witness and cross-axis byte-parity pins against
4152/// the sibling owned-input
4153/// `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape
4154/// axes).
4155impl From<DepList> for std::sync::Arc<str> {
4156    fn from(list: DepList) -> std::sync::Arc<str> {
4157        std::sync::Arc::<str>::from(list.as_str())
4158    }
4159}
4160
4161/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<str>`] output*
4162/// forward projection on the outside-M3 caixa-core two-list dep-graph
4163/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4164/// companion to the paired owned-input
4165/// [`From<DepList> for std::sync::Arc<str>`] impl immediately above.
4166/// Routes byte-for-byte through the substrate-primitive
4167/// [`DepList::as_str`] `pub const fn` accessor via
4168/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4169/// every consumer that binds a
4170/// `let key: std::sync::Arc<str> = (&list).into();`-shaped call site or a
4171/// `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped pipe
4172/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4173/// construction) reaches the same two lifted
4174/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4175/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4176/// strings the paired owned-input
4177/// [`From<DepList> for std::sync::Arc<str>`] and the sibling
4178/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4179/// forward-projection corner already return.
4180///
4181/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4182/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4183/// `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a `Copy`-
4184/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4185/// input axis is a distinct trait-idiomatic surface that the pipe shape
4186/// [`DepList::ALL`]`.iter().map(std::sync::Arc::<str>::from)` reaches
4187/// through this impl and no other — without it, the same pipe would
4188/// force a spurious [`Copy`] deref
4189/// (`std::sync::Arc::<str>::from((*list).as_str())`) or a `.copied()`
4190/// restatement whose type bounds have no compile-time link back to the
4191/// substrate primitive.
4192///
4193/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4194/// core-internal closed-set fieldless typed enum peer of the substrate-
4195/// wide trait-idiomatic [`std::sync::Arc<str>`] forward-projection
4196/// campaign — one commit after the paired top-level [`crate::CaixaKind`]
4197/// pair (c17be64) opened the caixa-core-internal Arc<str> tier — matching
4198/// the trajectory the paired top-level [`crate::CaixaKind`] pair
4199/// (c17be64, both corners in one axis) walked before it. Leaves the
4200/// remaining caixa-core-internal closed-set fieldless typed enum peers
4201/// ([`crate::dialeto::CaixaDialeto`],
4202/// [`crate::render::PathShapeViolation`]) as the campaign's next multi-
4203/// peer targets on the caixa-core-internal tier of the Arc<str> axis.
4204///
4205/// Pinned load-bearing by
4206/// [`tests::dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor`]
4207/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4208/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4209/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4210/// against the paired owned-input
4211/// [`From<DepList> for std::sync::Arc<str>`] and the sibling borrowed-
4212/// input `{&'static str, String, Cow<'static, str>, Box<str>}` return-
4213/// shape axes, and a `.iter().map(std::sync::Arc::<str>::from)` pipe
4214/// witness over [`DepList::ALL`] that resolves through the borrowed-
4215/// input axis without a spurious [`Copy`] deref).
4216impl From<&DepList> for std::sync::Arc<str> {
4217    fn from(list: &DepList) -> std::sync::Arc<str> {
4218        std::sync::Arc::<str>::from(list.as_str())
4219    }
4220}
4221
4222/// Errors raised by [`Dep::validate`].
4223///
4224/// Mirrors the per-axis error families the other `:versao`-carrying
4225/// typed surfaces expose
4226/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4227/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4228/// [`crate::SupervisorError::EmptyChildVersion`] /
4229/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4230/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4231#[derive(Debug, Error, PartialEq, Eq)]
4232pub enum DepError {
4233    #[error(
4234        ":deps entry has empty :nome (every dep must name a target caixa; \
4235         omit the entry instead of carrying an empty name)"
4236    )]
4237    NomeEmpty,
4238    #[error(
4239        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4240         (the value flows verbatim as the target caixa's `:nome`, the rendered \
4241         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4242         value, and the resolver's checkout-directory leaf — each apiserver-side \
4243         schema rejects non-DNS-1123 names at admission time; use a lowercase \
4244         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4245         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4246    )]
4247    NomeInvalid { nome: String, reason: String },
4248    #[error(
4249        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4250         constraint that resolves through the lacre pipeline)"
4251    )]
4252    VersaoEmpty { nome: String },
4253    #[error(
4254        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4255         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4256         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4257         and `:children :versao` carry; the lacre pipeline resolves all three \
4258         through the same parser)"
4259    )]
4260    VersaoInvalid {
4261        nome: String,
4262        versao: String,
4263        reason: String,
4264    },
4265    #[error(
4266        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4267         (every git source must name a repo — use a `github:org/repo` \
4268         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4269         entire :fonte block to fall back to the default-host resolver \
4270         convention)"
4271    )]
4272    FonteRepoEmpty { nome: String },
4273    #[error(
4274        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4275         invalid value-shape: {reason} (the value flows verbatim into the \
4276         caixa-resolver's `git clone <repo>` subprocess invocation; every \
4277         documented form carries a `:` separator and no whitespace / \
4278         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4279         an `https://host/path` / `ssh://[user@]host/path` / \
4280         `git://host/path` / `file:///path` URL, or the `git@host:path` \
4281         scp-style SSH form)"
4282    )]
4283    FonteRepoShape {
4284        nome: String,
4285        repo: String,
4286        reason: String,
4287    },
4288    #[error(
4289        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4290         (set exactly one of :tag, :rev, or :branch so the resolver \
4291         can pick a reproducible commit; omit the entire :fonte block \
4292         to fall back to the default-host resolver convention, which \
4293         resolves the latest tag matching :versao)"
4294    )]
4295    FontePinMissing { nome: String },
4296    #[error(
4297        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4298         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4299         set so the resolver's checkout target is unambiguous (the \
4300         resolver's silent precedence is :rev > :tag > :branch — if \
4301         you intended one specifically, drop the others)"
4302    )]
4303    FontePinAmbiguous { nome: String, pins: String },
4304    #[error(
4305        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4306         (a set pin must name a non-empty git ref; drop the {pin} key \
4307         entirely to fall through to another pin axis)"
4308    )]
4309    FontePinEmpty { nome: String, pin: String },
4310    #[error(
4311        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4312         value-shape: {reason} (the git porcelain enforces the same shape at \
4313         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4314         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4315         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4316         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4317         prepends at clone time, and avoid abbreviated SHAs which are \
4318         ambiguous across repository history)"
4319    )]
4320    FontePinShape {
4321        nome: String,
4322        pin: String,
4323        value: String,
4324        reason: String,
4325    },
4326    #[error(
4327        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4328         (every path source must name a non-empty filesystem path; \
4329         omit the entire :fonte block to fall back to the default-host \
4330         resolver convention)"
4331    )]
4332    FonteCaminhoEmpty { nome: String },
4333    #[error(
4334        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4335         absolute (the lacre pipeline embeds the value verbatim in its \
4336         per-dep content-address `path:{caminho}` at \
4337         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4338         BLAKE3 closure differ across machines — defeating the \
4339         reproducibility contract that's load-bearing for CSE; express \
4340         the path relative to the caixa.lisp location, e.g. \
4341         \"../caixa-teia\" for a sibling workspace dep)"
4342    )]
4343    FonteCaminhoAbsolute { nome: String, caminho: String },
4344    #[error(
4345        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4346         with `~` (the leading-tilde is a shell-expansion convention, not a \
4347         POSIX path component — `Path::is_absolute` returns false on it, so \
4348         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4349         pipeline embeds the value verbatim in its per-dep content-address \
4350         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4351         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4352         so the build looks for a literal `./{caminho}` subdirectory and \
4353         fails at resolve time far from the source caixa.lisp; even worse, a \
4354         future caixa-resolver pass that *does* expand `~` would silently \
4355         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4356         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4357         runners with different `$HOME` layouts resolve to two distinct paths \
4358         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4359         determinism contract; express the path relative to the caixa.lisp \
4360         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4361         spell out the full relative path explicitly if a workstation-rooted \
4362         dep is genuinely intended)"
4363    )]
4364    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4365    #[error(
4366        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4367         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4368         not a POSIX path component — `Path::is_absolute` returns false on it \
4369         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4370         embeds the value verbatim in its per-dep content-address \
4371         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4372         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4373         so the build looks for a literal `./{caminho}` subdirectory and \
4374         fails at resolve time far from the source caixa.lisp; even worse, a \
4375         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4376         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4377         invites) would silently re-open the host-layout-leak the b94fd83 \
4378         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4379         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4380         layouts resolve to two distinct paths for the byte-identical caixa, \
4381         defeating the THEORY.md §V.2 render-determinism contract; express \
4382         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4383         for a sibling workspace dep, or spell out the full relative path \
4384         explicitly if a workstation-rooted dep is genuinely intended)"
4385    )]
4386    FonteCaminhoVarExpansion { nome: String, caminho: String },
4387    #[error(
4388        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4389         with a space (the leading ASCII space `0x20` is the orthogonal \
4390         paste-from-aligned-doc footgun that silently passes \
4391         `Path::is_absolute` and every prior leading-byte arm — \
4392         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4393         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4394         resolve time with a non-self-locating `No such file or directory` \
4395         error far from the source caixa.lisp; the lacre pipeline embeds \
4396         the value verbatim in its per-dep content-address `path:{caminho}` \
4397         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4398         semantic-identical caixa values (` ../caixa-teia` vs \
4399         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4400         workstations whose authors differ only in paste-from-aligned- \
4401         caixa.lisp-doc whitespace habits — the most insidious failure \
4402         mode the typed slot can carry (no error surfaces; the divergence \
4403         is invisible until two machines compare lacres), defeating the \
4404         THEORY.md §V.2 render-determinism contract. The canonical \
4405         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4406         a multi-entry `:deps` block sits at the same column — an author \
4407         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4408         the rendered alignment into a fresh entry preserves the leading \
4409         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4410         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4411         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4412         `is_chart_description_shape`, `:licenca` via \
4413         `is_spdx_expression_shape`. Drop the leading space; express the \
4414         path as a bare relative single-token like \"../caixa-teia\")"
4415    )]
4416    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4417    #[error(
4418        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4419         with `-` (the canonical CLI-argument-injection footgun on the \
4420         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4421         its per-dep content-address `path:{caminho}` at \
4422         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4423         through `Path::join` looking for a literal `./{caminho}` \
4424         subdirectory. Every downstream subprocess that consumes the resolved \
4425         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4426         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4427         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4428         value as a CLI flag rather than a positional path when the invocation \
4429         does not carry a `--` argument-list terminator between the flag block \
4430         and the path (the common case at every porcelain entry point). The \
4431         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4432         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4433         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4434         CLI-arg-injection vector at every git porcelain entry point that \
4435         consumes a path or URL argument, peer with is_git_repo_url's \
4436         leading-`-` arm on the sibling `:fonte :repo` axis), \
4437         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4438         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4439         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4440         for a literal `./-rf` subdirectory that fails at resolve time with a \
4441         non-self-locating `No such file or directory` error far from the \
4442         source caixa.lisp — but on any downstream shell-out without `--` the \
4443         reinterpretation is silent and the failure mode is arbitrary-\
4444         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4445         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4446         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4447         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4448         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4449         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4450         `:children :caixa`, `:deps :nome`, cluster names); \
4451         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4452         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4453         leading `-` on the CLI positional itself. Express the path as a bare \
4454         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4455         directory name carries no leading-hyphen semantic, and `./` / `../` \
4456         prefixes structurally partition the leading-byte set to safe values.)"
4457    )]
4458    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4459    #[error(
4460        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4461         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4462         every `std::fs` syscall routes the path through `CString::new` which \
4463         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4464         value verbatim in its per-dep content-address `path:{caminho}` at \
4465         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4466         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4467         determinism contract — the canonical paste-from-multiline-doc \
4468         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4469         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4470         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4471         already gates against. Express the path as a relative single-line ASCII \
4472         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4473    )]
4474    FonteCaminhoControlChar {
4475        nome: String,
4476        caminho: String,
4477        byte: u8,
4478    },
4479    #[error(
4480        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4481         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4482         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4483         not the parent's sibling — and the caixa-resolver folds the value through \
4484         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4485         resolve time with a non-self-locating `No such file or directory` error far \
4486         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4487         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4488         resolve to two distinct directories across runner OSes — the lacre pipeline \
4489         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4490         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4491         determinism contract via the cross-host-OS-separator divergence vector. The \
4492         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4493         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4494         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4495         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4496         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4497         \"../caixa-teia\" for a sibling workspace dep)"
4498    )]
4499    FonteCaminhoBackslash { nome: String, caminho: String },
4500    #[error(
4501        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4502         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4503         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4504         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4505         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4506         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4507         as literal path-component bytes, so the resolver folds the value through \
4508         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4509         subdirectory and fails at resolve time with a non-self-locating `No such \
4510         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4511         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4512         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4513         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4514         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4515         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4516         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4517         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4518         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4519         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4520         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4521         redirection semantic.",
4522        ch = *byte as char
4523    )]
4524    FonteCaminhoShellRedirection {
4525        nome: String,
4526        caminho: String,
4527        byte: u8,
4528    },
4529    #[error(
4530        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4531         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4532         `|` as the pipe operator that wires one command's stdout to the next command's \
4533         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4534         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4535         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4536         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4537         treats `|` as a literal path-component byte, so the resolver folds the value \
4538         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4539         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4540         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4541         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4542         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4543         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4544         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4545         subprocess-argument / shell-metachar injection surface every peer single-token-\
4546         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4547         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4548         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4549         workspace directory name carries no shell-pipe semantic."
4550    )]
4551    FonteCaminhoShellPipe { nome: String, caminho: String },
4552    #[error(
4553        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4554         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4555         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4556         command regardless of the prior command's exit status, so `:caminho \
4557         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4558         footgun where an author copies a `cd path; do-thing` chain without trimming \
4559         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4560         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4561         literal path-component byte, so the resolver folds the value through \
4562         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4563         subdirectory and fails at resolve time with a non-self-locating `No such file \
4564         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4565         the value verbatim in its per-dep content-address `path:{caminho}` at \
4566         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4567         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4568         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4569         canonical shell-metachar injection surface every peer single-token-shaped \
4570         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4571         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4572         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4573         workspace directory name carries no shell-command-separator semantic."
4574    )]
4575    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4576    #[error(
4577        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4578         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4579         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4580         terminator detaching the prior command and returning control immediately to \
4581         the prompt, double `&&` as the logical-AND list operator firing the next \
4582         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4583         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4584         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4585         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4586         05c358e closed the sequential-command-separator vector, this arm closes the \
4587         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4588         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4589         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4590         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4591         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4592         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4593         surface every peer single-token-shaped typed slot already closes. The peer \
4594         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4595         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4596         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4597         shell-background / logical-AND semantic."
4598    )]
4599    FonteCaminhoShellBackground { nome: String, caminho: String },
4600    #[error(
4601        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4602         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4603         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4604         wrapper that runs the enclosed command and substitutes its standard-output \
4605         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4606         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4607         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4608         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4609         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4610         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4611         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4612         background / logical-AND vector, this arm closes the orthogonal command-\
4613         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4614         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4615         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4616         value verbatim in its per-dep content-address `path:{caminho}` at \
4617         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4618         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4619         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4620         shell-metachar injection surface every peer single-token-shaped typed slot \
4621         already closes. The peer `:entrada :paths` axis rejects the byte via \
4622         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4623         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4624         directory name carries no shell-command-substitution semantic."
4625    )]
4626    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4627    #[error(
4628        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4629         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4630         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4631         expansion wildcards: `*` matches any sequence of characters in a path component \
4632         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4633         canonical paste-from-shell-listing footgun where an author copies a \
4634         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4635         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4636         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4637         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4638         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4639         locating `No such file or directory` error far from the source caixa.lisp. The \
4640         lacre pipeline embeds the value verbatim in its per-dep content-address \
4641         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4642         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4643         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4644         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4645         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4646         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4647         reserved set. Express the path as a bare relative single-token like \
4648         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4649         / pathname-expansion semantic.",
4650        ch = *byte as char
4651    )]
4652    FonteCaminhoShellGlob {
4653        nome: String,
4654        caminho: String,
4655        byte: u8,
4656    },
4657    #[error(
4658        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4659         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4660         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4661         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4662         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4663         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4664         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4665         arm closes the leading byte of — together the two arms now structurally exclude the \
4666         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4667         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4668         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4669         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4670         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4671         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4672         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4673         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4674         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4675         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4676         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4677         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4678         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4679         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4680         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4681         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4682         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4683         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4684         subshell-grouping semantic.",
4685        ch = *byte as char
4686    )]
4687    FonteCaminhoShellSubshellGrouping {
4688        nome: String,
4689        caminho: String,
4690        byte: u8,
4691    },
4692    #[error(
4693        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4694         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4695         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4696         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4697         comma-separated members and `{{1..10}}` expands to the integer range — the \
4698         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4699         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4700         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4701         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4702         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4703         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4704         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4705         `std::path::Path` treats the byte as a literal path-component byte, so a \
4706         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4707         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4708         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4709         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4710         silently passes every prior arm and the resolver folds the value through \
4711         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4712         resolve time with a non-self-locating `No such file or directory` error far from \
4713         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4714         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4715         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4716         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4717         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4718         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4719         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4720         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4721         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4722         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4723         directory name carries no shell-brace-expansion / URI-Template-placeholder \
4724         semantic; if two siblings actually need pinning, author two separate `:deps` \
4725         entries rather than one brace-expanded `:caminho` value.",
4726        ch = *byte as char
4727    )]
4728    FonteCaminhoShellBraceExpansion {
4729        nome: String,
4730        caminho: String,
4731        byte: u8,
4732    },
4733    #[error(
4734        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4735         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4736         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4737         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4738         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4739         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4740         glob every shell-history block carries; the bracket pair additionally carries the \
4741         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4742         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4743         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4744         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4745         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4746         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4747         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4748         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4749         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4750         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4751         leak) silently passes every prior arm and the resolver folds the value through \
4752         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4753         resolve time with a non-self-locating `No such file or directory` error far from \
4754         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4755         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4756         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4757         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4758         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4759         surface every peer single-token-shaped typed slot already closes. Express the path \
4760         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4761         directory name carries no shell-bracket-expansion / glob-character-class / array-\
4762         literal semantic; if a family of sibling caixas actually needs pinning, author \
4763         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4764        ch = *byte as char
4765    )]
4766    FonteCaminhoShellBracketExpansion {
4767        nome: String,
4768        caminho: String,
4769        byte: u8,
4770    },
4771    #[error(
4772        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4773         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4774         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4775         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4776         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4777         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4778         every path-with-embedded-whitespace paste block carries and the symmetric \
4779         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4780         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4781         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4782         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4783         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4784         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4785         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4786         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4787         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4788         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4789         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4790         production. POSIX `std::path::Path` treats the byte as a literal path-component \
4791         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4792         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4793         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4794         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4795         shape) silently passes every prior arm and the resolver folds the value through \
4796         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4797         resolve time with a non-self-locating `No such file or directory` error far from \
4798         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4799         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4800         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4801         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4802         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4803         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4804         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4805         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4806         `is_git_repo_url`). Express the path as a bare relative single-token like \
4807         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4808         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4809         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4810         quoting on the outer syntactic layer, so an inner quote pair would nest and \
4811         desugar to a broken layer).",
4812        ch = *byte as char
4813    )]
4814    FonteCaminhoShellQuoteGrouping {
4815        nome: String,
4816        caminho: String,
4817        byte: u8,
4818    },
4819    #[error(
4820        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4821         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4822         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4823         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4824         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4825         discarding the byte and everything after it to the end of the physical line \
4826         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4827         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4828         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4829         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4830         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4831         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4832         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4833         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4834         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4835         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4836         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4837         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4838         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4839         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4840         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4841         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4842         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4843         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4844         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4845         fails at resolve time with a non-self-locating `No such file or directory` \
4846         error far from the source caixa.lisp — while every downstream shell / YAML / \
4847         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4848         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4849         scalar disagree with the resolver on which directory the value names. The \
4850         lacre pipeline embeds the value verbatim in its per-dep content-address \
4851         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4852         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4853         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4854         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4855         fragment-delimiter surface every peer single-token-shaped typed slot already \
4856         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4857         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4858         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4859         workspace directory name carries no shell-comment / URL-fragment / YAML-\
4860         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4861         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4862         and drop any `#fragment` tail entirely (fragment identifiers select \
4863         renderings, not directories, and `:caminho` names a directory).",
4864        ch = *byte as char
4865    )]
4866    FonteCaminhoShellComment {
4867        nome: String,
4868        caminho: String,
4869        byte: u8,
4870    },
4871    #[error(
4872        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4873         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4874         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4875         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4876         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4877         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4878         literally inside a URL value. The canonical paste-from-browser-address-bar \
4879         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4880         encoded README hyperlink / browser address bar / percent-encoded permalink \
4881         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4882         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4883         what the author intended as the byte-identical sibling-workspace dep. POSIX \
4884         `std::path::Path` treats the byte as a literal path-component byte, so \
4885         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4886         resolve time with a non-self-locating `No such file or directory` error far \
4887         from the source caixa.lisp — while every downstream URL parser / shell printf \
4888         builtin / YAML directive parser silently reinterprets the byte to a different \
4889         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4890         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4891         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4892         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4893         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4894         recent job whose command started with `foo`\" — a future `kill %1` invocation \
4895         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4896         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4897         directive block cross-idiom leak); and the Windows-shell env-var-reference \
4898         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4899         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4900         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4901         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4902         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4903         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4904         printf-format-specifier / job-control-specifier surface every peer single-\
4905         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4906         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4907         `is_git_repo_url`). Express the path as a bare relative single-token like \
4908         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4909         percent-encoding-escape / format-specifier / job-control semantic; substitute \
4910         any `%20` percent-encoded-space with a literal space then reject the whole \
4911         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4912         directory name never carries an embedded space in practice); drop any \
4913         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4914         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4915        ch = *byte as char
4916    )]
4917    FonteCaminhoUrlPercentEncoding {
4918        nome: String,
4919        caminho: String,
4920        byte: u8,
4921    },
4922    #[error(
4923        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4924         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4925         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4926         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4927         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4928         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4929         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4930         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4931         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4932         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4933         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4934         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4935         the byte is a first-class parser byte in nearly every config / templating / \
4936         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4937         `std::path::Path` treats the byte as a literal path-component byte, so the \
4938         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4939         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4940         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4941         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4942         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4943         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4944         subdirectory that fails at resolve time with a non-self-locating `No such file \
4945         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4946         the value verbatim in its per-dep content-address `path:{caminho}` at \
4947         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4948         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4949         time lock to two distinct BLAKE3 closures across two workstations whose \
4950         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4951         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4952         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4953         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4954         is the canonical CWE-78 shell-command-injection surface every peer single-\
4955         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4956         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4957         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4958         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4959         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4960         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4961         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4962         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4963         so every position — leading and embedded — is structurally rejected. Substitute \
4964         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4965         time, or express the path as a bare relative single-token like \
4966         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4967         variable-expansion / command-substitution / arithmetic-expansion semantic.",
4968        ch = *byte as char
4969    )]
4970    FonteCaminhoShellVariableExpansion {
4971        nome: String,
4972        caminho: String,
4973        byte: u8,
4974    },
4975    #[error(
4976        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4977         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4978         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4979         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4980         reference §9.3: `!command` re-runs the most recent history entry beginning with \
4981         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4982         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4983         and the substitution fires at every history-expansion-enabled shell context — \
4984         `set -o histexpand` is bash's default for interactive sessions and the layer \
4985         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4986         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4987         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4988         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4989         encodes it inside a query component via the 'special-query percent-encode set' \
4990         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4991         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4992         prefix — the paste-from-source-code idiom where an author copies \
4993         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4994         the string-literal boundary); the canonical English-typography emphasis / \
4995         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4996         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4997         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4998         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4999         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5000         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5001         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5002         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5003         repeat-prior-command paste idiom), the English-typography `:caminho \
5004         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5005         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5006         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5007         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5008         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5009         subdirectory that fails at resolve time with a non-self-locating `No such file \
5010         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5011         the value verbatim in its per-dep content-address `path:{caminho}` at \
5012         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5013         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5014         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5015         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5016         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5017         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5018         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5019         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5020         name carries no shell-history-expansion / bang-operator semantic; drop any \
5021         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5022         idiom; and drop any trailing English-typography exclamation mark that pasted \
5023         from prose.",
5024        ch = *byte as char
5025    )]
5026    FonteCaminhoShellHistoryExpansion {
5027        nome: String,
5028        caminho: String,
5029        byte: u8,
5030    },
5031    #[error(
5032        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5033         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5034         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5035         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5036         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5037         substitution' history operator that rewrites the prior command's `old` string to \
5038         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5039         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5040         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5041         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5042         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5043         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5044         literal value diverges from every downstream `feira tofu` curl-invocation / \
5045         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5046         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5047         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5048         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5049         `std::path::Path` treats `^` as a literal path-component byte, so \
5050         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5051         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5052         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5053         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5054         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5055         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5056         that fails at resolve time with a non-self-locating `No such file or directory` \
5057         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5058         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5059         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5060         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5061         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5062         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5063         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5064         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5065         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5066         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5067         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5068         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5069         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5070         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5071         drop any trailing `^` history-substitution-open fragment.",
5072        ch = *byte as char
5073    )]
5074    FonteCaminhoShellHistorySubstitution {
5075        nome: String,
5076        caminho: String,
5077        byte: u8,
5078    },
5079    #[error(
5080        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5081         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5082         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5083         value verbatim in its per-dep content-address `path:{caminho}` at \
5084         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5085         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5086         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5087         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5088         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5089         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5090         trailing `/`; every `:caminho` value names a sibling-workspace directory \
5091         already, so the trailing separator carries no information. Use \
5092         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5093    )]
5094    FonteCaminhoTrailingSlash { nome: String, caminho: String },
5095    #[error(
5096        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5097         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5098         apply the same set-not-multiset discipline; one package per table), and \
5099         two entries naming the same caixa carry two version constraints / source \
5100         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5101         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5102         silently overwrites the first at the resolver-side `concrete_versao` step, \
5103         and the dropped entry's pin / features never reach the closure — far from \
5104         the source caixa.lisp, with no field naming which `:deps` entry was the \
5105         silent loser. If two version constraints are genuinely needed (the rare \
5106         multi-version closure case the lacre pipeline doesn't yet support), the \
5107         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5108         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5109    )]
5110    DuplicateNome { nome: String, list: &'static str },
5111    #[error(
5112        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5113         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5114         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5115         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5116         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5117         with the canonical kebab-case feature name the target caixa declares."
5118    )]
5119    CaracteristicaEmpty { nome: String },
5120    #[error(
5121        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5122         feature name: {reason} (the value flows verbatim into Cargo's \
5123         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5124         parser enforces the same shape at `cargo metadata` time; use a single-token \
5125         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5126         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5127         an ASCII alphanumeric or `_`)"
5128    )]
5129    CaracteristicaInvalid {
5130        nome: String,
5131        caracteristica: String,
5132        reason: String,
5133    },
5134    #[error(
5135        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5136         every feature-flag list keys its entries by name (Cargo's \
5137         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5138         per feature per dep), and two entries naming the same feature are a redundant \
5139         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5140         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5141         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5142         feature once regardless of declaration count, so the duplicate's pin / position never \
5143         reaches the closure with no field naming the silent loser. One entry per feature per \
5144         dep; if two distinct features are intended, name each verbatim."
5145    )]
5146    CaracteristicaDuplicate {
5147        nome: String,
5148        caracteristica: String,
5149    },
5150    #[error(
5151        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5152         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5153         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5154         rejects mid-traversal far from the source caixa.lisp or recurses on until \
5155         it exhausts its stack). Every :nome is globally-unique substrate identity, \
5156         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5157         *is* the parent itself, not a coincidentally-named peer. Drop the \
5158         self-referential dep entry — to reference code from this caixa, use \
5159         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5160         referencing the caixa's own code surface) instead."
5161    )]
5162    DepIsSelf { nome: String, list: &'static str },
5163}
5164
5165// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5166// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5167// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5168// variant — the paired `{ nome: String, caminho: String }` two-slot family
5169// on [`DepError`], sibling of the peer
5170// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5171// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5172// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5173// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5174// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5175// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5176// `{ de, para, wit, expected }`), and
5177// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5178// variants on `{ de, para, <field>: String, reason: String }`) on the
5179// `AplicacaoError` envelopes, the peer
5180// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5181// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5182// (0419438, 4 variants on `{ caixa, kind, slots }`),
5183// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5184// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5185// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5186// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5187// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5188// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5189// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5190// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5191//
5192// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5193// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5194// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5195// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5196// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5197// CommandSubstitution}` on the four single-byte shell operators; and the
5198// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5199// opened the identical `DepError::FonteCaminho<Variant> { nome:
5200// nome.to_string(), caminho: caminho.to_string() }` four-line
5201// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5202// — the exact "same block re-inlined at every consumer" shape the PRIME
5203// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5204// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5205// families each closed on their sibling envelopes. The eleven variants
5206// share one `{ nome: String, caminho: String }` shape, so the fold routes
5207// each wire-up site through one dispatch per typed variant.
5208//
5209// The macro below generates one `#[must_use]` inherent constructor per
5210// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5211// wire-up site collapses onto one dispatch:
5212// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5213// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5214// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5215// once — inside the macro — rather than at every wire-up site.
5216//
5217// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5218// shapes at the per-byte-classification arms — the
5219// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5220// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5221// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5222// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5223// cluster — carry an additional `byte: u8` naming the offending byte and
5224// so would break the uniform-two-field routing this macro promises. They
5225// instead fold onto the sibling three-field envelope through
5226// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5227// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5228// two-slot family is the `byte: u8` classification the arms carry. The
5229// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5230// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5231// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5232// envelope.
5233//
5234// Every future consumer that wants to construct one of these eleven
5235// variants outside the current in-crate [`DepSource::validate_caminho`]
5236// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5237// at lacre-resolve time re-checking the same value-shape axes the resolver
5238// consumes, a future `feira validate --deps` per-caixa admission verb
5239// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5240// rejecting a `:caminho` value against a cluster-local snapshot) now
5241// reaches each variant through one call rather than re-inlining the
5242// four-line struct-literal in lockstep with the eleven in-crate wire-up
5243// sites.
5244macro_rules! fonte_caminho_ctors {
5245    ($($ctor:ident => $variant:ident),* $(,)?) => {
5246        impl DepError {
5247            $(
5248                #[doc = concat!(
5249                    "Construct a [`DepError::",
5250                    stringify!($variant),
5251                    "`] naming the offending `:deps :nome` + `:fonte ",
5252                    "(:tipo path …) :caminho` pair. Folds the uniform ",
5253                    "`Self::",
5254                    stringify!($variant),
5255                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5256                    "two-slot struct-literal onto one substrate primitive so ",
5257                    "every [`DepSource::validate_caminho`] wire-up on this ",
5258                    "variant reads through one dispatch rather than the ",
5259                    "pre-lift four-line open-coded block."
5260                )]
5261                #[must_use]
5262                pub fn $ctor(nome: &str, caminho: &str) -> Self {
5263                    Self::$variant {
5264                        nome: nome.to_string(),
5265                        caminho: caminho.to_string(),
5266                    }
5267                }
5268            )*
5269        }
5270    };
5271}
5272
5273fonte_caminho_ctors! {
5274    fonte_caminho_absolute => FonteCaminhoAbsolute,
5275    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5276    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5277    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5278    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5279    fonte_caminho_backslash => FonteCaminhoBackslash,
5280    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5281    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5282    fonte_caminho_shell_background => FonteCaminhoShellBackground,
5283    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5284    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5285}
5286
5287// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5288// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5289// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5290// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5291// three-slot family on [`DepError`], strict sibling of the peer
5292// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5293// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5294// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5295// axis broke its uniform-two-field routing — the exact "future compounding
5296// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5297// here. Third fold family on this `DepError` envelope, sibling of the peer
5298// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5299// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5300// same enum.
5301//
5302// Each of the twelve wire-up sites on this shape (the control-byte arm
5303// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5304// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5305// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5306// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5307// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5308// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5309// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5310// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5311// `FonteCaminhoShellHistoryExpansion` on `!`, and
5312// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5313// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5314// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5315// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5316// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5317// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5318// closed on the sibling two-field envelope of this same enum. The twelve
5319// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5320// the fold routes each wire-up site through one dispatch per typed variant.
5321//
5322// The macro below generates one `#[must_use]` inherent constructor per
5323// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5324// so every wire-up site collapses onto one dispatch:
5325// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5326// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5327// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5328// `byte`) is spelled once — inside the macro — rather than at every wire-up
5329// site.
5330//
5331// Every future consumer that wants to construct one of these twelve
5332// variants outside the current in-crate [`DepSource::validate_caminho`]
5333// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5334// at lacre-resolve time re-checking the same value-shape axes the resolver
5335// consumes, a future `feira validate --deps` per-caixa admission verb
5336// re-checking the `:fonte :caminho` axis against the shell-metachar
5337// classification bytes this cluster catches, a per-lacre overlay resolver
5338// rejecting a `:caminho` value against a cluster-local snapshot) now
5339// reaches each variant through one call rather than re-inlining the
5340// five-line struct-literal in lockstep with the twelve in-crate wire-up
5341// sites.
5342macro_rules! fonte_caminho_byte_ctors {
5343    ($($ctor:ident => $variant:ident),* $(,)?) => {
5344        impl DepError {
5345            $(
5346                #[doc = concat!(
5347                    "Construct a [`DepError::",
5348                    stringify!($variant),
5349                    "`] naming the offending `:deps :nome` + `:fonte ",
5350                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5351                    "classification. Folds the uniform `Self::",
5352                    stringify!($variant),
5353                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5354                    "byte }` three-slot struct-literal onto one substrate ",
5355                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5356                    "on this variant reads through one dispatch rather than ",
5357                    "the pre-lift five-line open-coded block."
5358                )]
5359                #[must_use]
5360                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5361                    Self::$variant {
5362                        nome: nome.to_string(),
5363                        caminho: caminho.to_string(),
5364                        byte,
5365                    }
5366                }
5367            )*
5368        }
5369    };
5370}
5371
5372fonte_caminho_byte_ctors! {
5373    fonte_caminho_control_char => FonteCaminhoControlChar,
5374    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5375    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5376    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5377    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5378    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5379    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5380    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5381    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5382    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5383    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5384    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5385}
5386
5387// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5388// single-slot struct-variant wire-up sites scattered across
5389// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5390// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5391// substrate primitive per typed variant — the paired `{ nome: String }`
5392// single-slot family on [`DepError`], sibling of the peer
5393// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5394// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5395// the same enum, and of the peer
5396// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5397// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5398// axis. Second fold family on this `DepError` envelope, and the first on
5399// the single-`{ nome }` shape.
5400//
5401// The five wire-up sites this fold closes each opened the identical
5402// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5403// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5404// local — the exact "same block re-inlined at every consumer" shape the
5405// PRIME DIRECTIVE names as a bug. The five variants share one
5406// `{ nome: String }` shape, so the fold routes each wire-up site through
5407// one dispatch per typed variant.
5408//
5409// The macro below generates one `#[must_use]` inherent constructor per
5410// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5411// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5412// pre-lift struct-literal on the same `&str` fixture. The uniform
5413// one-field construction (`nome.to_string()`) is spelled once — inside
5414// the macro — rather than at every wire-up site. Callers that hold a
5415// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5416// and lets the macro-owned `.to_string()` produce the fresh owning copy
5417// the enum variant needs; the semantics collapse onto the same
5418// `.clone()`-equivalent one this fold replaces at every site.
5419//
5420// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5421// on the same envelope stays on its pre-lift open-coded wire-up shape —
5422// it carries no `nome` field (the offending `:nome` value *is* the empty
5423// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5424// signature this macro promises does not apply. Every future consumer
5425// that wants to construct one of these five variants outside the current
5426// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5427// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5428// re-validator at lacre-resolve time, a future `feira validate --deps`
5429// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5430// these empty-value shapes against a cluster-local snapshot) now reaches
5431// each variant through one call rather than re-inlining the three-line
5432// struct-literal in lockstep with the five in-crate wire-up sites.
5433macro_rules! dep_nome_only_ctors {
5434    ($($ctor:ident => $variant:ident),* $(,)?) => {
5435        impl DepError {
5436            $(
5437                #[doc = concat!(
5438                    "Construct a [`DepError::",
5439                    stringify!($variant),
5440                    "`] naming the offending `:deps :nome`. Folds the ",
5441                    "uniform `Self::",
5442                    stringify!($variant),
5443                    " { nome: nome.to_string() }` one-field ",
5444                    "struct-literal onto one substrate primitive so every ",
5445                    "in-crate wire-up on this variant reads through one ",
5446                    "dispatch rather than the pre-lift three-line ",
5447                    "open-coded block."
5448                )]
5449                #[must_use]
5450                pub fn $ctor(nome: &str) -> Self {
5451                    Self::$variant { nome: nome.to_string() }
5452                }
5453            )*
5454        }
5455    };
5456}
5457
5458dep_nome_only_ctors! {
5459    versao_empty => VersaoEmpty,
5460    fonte_repo_empty => FonteRepoEmpty,
5461    fonte_pin_missing => FontePinMissing,
5462    fonte_caminho_empty => FonteCaminhoEmpty,
5463    caracteristica_empty => CaracteristicaEmpty,
5464}
5465
5466// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5467// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5468// [`crate::manifest::Caixa::validate_deps`] +
5469// [`validate_no_self_dep`] onto one substrate-primitive family per
5470// typed variant — the `DepError`-side siblings of the peer
5471// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5472// on the `SupervisorError { caixa: String }` one-slot envelope and of
5473// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5474// `DepError { nome: String }` one-slot envelope. The two variants
5475// carry the same `{ nome: String, list: &'static str }` two-slot
5476// shape: the `nome` field names the offending dep the diagnostic
5477// points the author back at, and the `list` field carries the
5478// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5479// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5480// [`validate_deps`] arms, and via the paired
5481// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5482// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5483// canonicals on the [`validate_no_self_dep`] arm) so the author can
5484// grep their caixa.lisp for the offending list block in one edit.
5485//
5486// Each of the four wire-up sites opened the same struct-literal
5487// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5488// two-line block — the exact "same block re-inlined at every
5489// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5490// altitude the peer `DepError` / `SupervisorError` /
5491// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5492// already closed on their sibling envelopes. The two `#[must_use]`
5493// inherent constructors below fold each wire-up onto one dispatch:
5494// `DepError::duplicate_nome(<nome>, <list>)` and
5495// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5496// pre-lift struct-literal on the same scalar fixtures. The `list:
5497// &'static str` parameter (not `impl Into<String>`) preserves the
5498// exact wire tag every consumer already passes verbatim — no
5499// downstream diagnostic reshaping at the lift, matching the peer
5500// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5501// contract each wire-up site already keys off.
5502macro_rules! dep_nome_list_ctors {
5503    ($($ctor:ident => $variant:ident),* $(,)?) => {
5504        impl DepError {
5505            $(
5506                #[doc = concat!(
5507                    "Construct a [`DepError::",
5508                    stringify!($variant),
5509                    "`] naming the offending `:deps :nome` and the ",
5510                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5511                    "the diagnostic points the author back at. Folds ",
5512                    "the uniform `Self::",
5513                    stringify!($variant),
5514                    " { nome: nome.to_string(), list }` two-field ",
5515                    "struct-literal onto one substrate primitive so ",
5516                    "every in-crate wire-up on this variant reads ",
5517                    "through one dispatch rather than the pre-lift ",
5518                    "open-coded struct-literal block."
5519                )]
5520                #[must_use]
5521                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5522                    Self::$variant { nome: nome.to_string(), list }
5523                }
5524            )*
5525        }
5526    };
5527}
5528
5529dep_nome_list_ctors! {
5530    duplicate_nome => DuplicateNome,
5531    dep_is_self => DepIsSelf,
5532}
5533
5534// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5535// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5536// <value>.to_string(), reason }` struct-variant wire-up sites at
5537// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5538// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5539// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5540// primitive family per typed variant — the `DepError`-side siblings of the
5541// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5542// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5543// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5544// the two-slot `{ nome, caminho }` envelope, and
5545// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5546// caminho, byte }` envelope. The three variants share the same
5547// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5548// the `nome` field names the offending dep the diagnostic points the
5549// author back at, the middle `<axis>: String` field carries the offending
5550// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5551// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5552// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5553// field carries the parser-shaped rejection sentence the paired
5554// [`crate::render::require_valid_versao_requirement`] /
5555// [`crate::render::is_git_repo_url`] /
5556// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5557// axis-field name differs across variants (`versao` / `repo` /
5558// `caracteristica`) so the ctor family below takes the axis field name as
5559// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5560// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5561// -> Self` inherent constructor per typed variant that spells the uniform
5562// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5563// `reason` forwarded owned) exactly once. Peer of the sibling
5564// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5565// family on the `AplicacaoError` envelope's mirror-symmetric
5566// `{ <field>: String, reason: String }` two-slot shape — same
5567// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5568// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5569// envelope keys off (every `DepError` variant carries the offending
5570// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5571// offending block in one edit).
5572//
5573// The three wire-up sites this fold closes are:
5574// - [`DepSource::validate`]'s `:repo` value-shape arm
5575//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5576//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5577//   rejects the offending URL);
5578// - [`Dep::validate`]'s `:versao` requirement-shape arm
5579//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5580//   self.versao_requirement().to_string(), reason }` inside the
5581//   [`crate::render::require_valid_versao_requirement`] callback pair);
5582// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5583//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5584//   caracteristica: c.clone(), reason })` after
5585//   [`crate::render::is_cargo_feature_name`] rejects the offending
5586//   feature-name).
5587//
5588// Each opened the identical five-line struct-literal against the same
5589// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5590// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5591// same altitude the peer four already-lifted `DepError` ctor families
5592// closed on their sibling shape-envelopes. The three variant / axis-field
5593// discriminators are the only things that vary between them; the rest of
5594// the struct-literal is a byte-for-byte re-inline.
5595//
5596// Every future consumer wanting to raise one of these three diagnostics
5597// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5598// time re-checking each declared dep against the same requirement +
5599// git-URL + feature-name value-shape cascade, a future `feira validate
5600// --deps` per-caixa admission verb re-running the shape gates on demand,
5601// a per-lacre overlay resolver rejecting an author-supplied dep against a
5602// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5603// the five-line struct-literal in lockstep with the three in-crate
5604// wire-up sites.
5605macro_rules! dep_nome_axis_reason_ctors {
5606    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5607        impl DepError {
5608            $(
5609                #[doc = concat!(
5610                    "Construct a [`DepError::",
5611                    stringify!($variant),
5612                    "`] naming the offending `:deps :nome`, the offending ",
5613                    "`:", stringify!($axis), "` axis value, and the ",
5614                    "parser-shaped rejection `reason`. Folds the uniform ",
5615                    "`Self::",
5616                    stringify!($variant),
5617                    " { nome: nome.to_string(), ",
5618                    stringify!($axis),
5619                    ": ",
5620                    stringify!($axis),
5621                    ".to_string(), reason }` three-field struct-literal ",
5622                    "onto one substrate primitive so every in-crate ",
5623                    "wire-up on this variant reads through one dispatch ",
5624                    "rather than the pre-lift five-line open-coded block. ",
5625                    "The `nome: &str` and `",
5626                    stringify!($axis),
5627                    ": &str` parameters accept `&str` literals and ",
5628                    "`&String` (via Deref coercion) so every existing ",
5629                    "wire-up threads through the ctor without a ",
5630                    "pre-conversion; the `reason: String` parameter takes ",
5631                    "an owned `String` (not `impl Into<String>`) matching ",
5632                    "the paired `crate::render::*` predicate's ",
5633                    "`Result<(), String>` return shape every wire-up ",
5634                    "already holds owned at the call site."
5635                )]
5636                #[must_use]
5637                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5638                    Self::$variant {
5639                        nome: nome.to_string(),
5640                        $axis: $axis.to_string(),
5641                        reason,
5642                    }
5643                }
5644            )*
5645        }
5646    };
5647}
5648
5649dep_nome_axis_reason_ctors! {
5650    versao_invalid => VersaoInvalid { versao },
5651    fonte_repo_shape => FonteRepoShape { repo },
5652    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5653}
5654
5655// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5656// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5657// <value>.to_string() }` struct-variant wire-up sites at
5658// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5659// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5660// per-entry set-not-multiset dedup closure onto one substrate-primitive
5661// family per typed variant — the missing two-slot rung on the
5662// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5663// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5664// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5665// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5666// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5667// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5668// symmetric sibling of the peer
5669// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5670// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5671// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5672// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5673// owned altitude the `DepError` envelope keys off (every `DepError`
5674// variant carries the offending `:deps :nome` verbatim so the author
5675// can grep their caixa.lisp for the offending block in one edit). The
5676// three variants share the same `{ nome: String, <axis>: String }`
5677// two-slot shape: the `nome` field names the offending dep the
5678// diagnostic points the author back at, and the middle `<axis>:
5679// String` field carries the offending per-envelope axis value verbatim
5680// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5681// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5682// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5683// The middle axis-field name differs across variants (`pin` / `pins` /
5684// `caracteristica`) so the ctor family below takes the axis field name
5685// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5686// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5687// Self` inherent constructor per typed variant that spells the
5688// uniform two-field construction (`nome.to_string()` /
5689// `<axis>.to_string()`) exactly once.
5690//
5691// The three wire-up sites this fold closes are:
5692// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5693//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5694//   pin.to_string() });` inside the `set.len() == 1` branch after the
5695//   `is_some_and(String::is_empty)` iterator);
5696// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5697//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5698//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5699// - [`Dep::validate_caracteristicas`]'s per-entry
5700//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5701//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5702//   [`crate::render::insert_first_seen`]).
5703//
5704// Each opened the identical four-line struct-literal against the same
5705// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5706// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5707// same altitude the peer four already-lifted `DepError` ctor families
5708// closed on their sibling shape-envelopes. The three variant / axis-
5709// field discriminators are the only things that vary between them;
5710// the rest of the struct-literal is a byte-for-byte re-inline.
5711//
5712// Every future consumer wanting to raise one of these three
5713// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5714// at lacre-resolve time re-checking each declared dep against the
5715// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5716// set-not-multiset cascade, a future `feira validate --deps` per-
5717// caixa admission verb re-running the shape gates on demand, a
5718// per-lacre overlay resolver rejecting an author-supplied dep against
5719// a cluster-local snapshot the M4 CR materializer projects) now
5720// reaches one dispatch rather than re-inlining the four-line struct-
5721// literal in lockstep with the three in-crate wire-up sites.
5722macro_rules! dep_nome_axis_ctors {
5723    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5724        impl DepError {
5725            $(
5726                #[doc = concat!(
5727                    "Construct a [`DepError::",
5728                    stringify!($variant),
5729                    "`] naming the offending `:deps :nome` and the ",
5730                    "offending `:", stringify!($axis), "` axis value. ",
5731                    "Folds the uniform `Self::",
5732                    stringify!($variant),
5733                    " { nome: nome.to_string(), ",
5734                    stringify!($axis),
5735                    ": ",
5736                    stringify!($axis),
5737                    ".to_string() }` two-field struct-literal onto one ",
5738                    "substrate primitive so every in-crate wire-up on ",
5739                    "this variant reads through one dispatch rather than ",
5740                    "the pre-lift four-line open-coded block. Both `nome: ",
5741                    "&str` and `",
5742                    stringify!($axis),
5743                    ": &str` parameters accept `&str` literals and ",
5744                    "`&String` (via Deref coercion) so every existing ",
5745                    "wire-up threads through the ctor without a pre-",
5746                    "conversion."
5747                )]
5748                #[must_use]
5749                pub fn $ctor(nome: &str, $axis: &str) -> Self {
5750                    Self::$variant {
5751                        nome: nome.to_string(),
5752                        $axis: $axis.to_string(),
5753                    }
5754                }
5755            )*
5756        }
5757    };
5758}
5759
5760dep_nome_axis_ctors! {
5761    fonte_pin_empty => FontePinEmpty { pin },
5762    fonte_pin_ambiguous => FontePinAmbiguous { pins },
5763    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5764}
5765
5766// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5767// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5768// struct-variant wire-up sites at [`DepSource::validate`]'s
5769// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5770// the `DepError` envelope — the last open-coded ctor site remaining on
5771// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5772// carries, and the single-variant sibling of the peer four already-
5773// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5774// on the two-slot `{ nome, caminho }` envelope,
5775// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5776// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5777// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5778// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5779// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5780// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5781// `{ …, value: String, reason: String }` payload shape, one axis
5782// removed at the `nome`-only-owner altitude the `DepError` envelope
5783// keys off (no `edge_pair()` de/para pair).
5784//
5785// The two wire-up sites this fold closes are the paired refname-pin
5786// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5787// pin: pin.to_string(), value: v.clone(), reason }` inside the
5788// `[(":tag", tag), (":branch", branch)]` iterator against
5789// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5790// (`|| DepError::FontePinShape { nome: nome.to_string(),
5791// pin: ":rev".to_string(), value: v.clone(), reason }` against
5792// [`crate::render::is_git_oid`]) — each opened the identical
5793// `DepError::FontePinShape { … }` six-line struct-literal against the
5794// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5795// tuple, the exact "same block re-inlined at every consumer" shape
5796// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5797// the only thing that varies between them (`":tag"`/`":branch"` on
5798// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5799// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5800// route through the same ctor because their `pin` field carries the
5801// author-surface tag verbatim (matching the `FontePinEmpty` /
5802// `FontePinAmbiguous` sibling variants' `pin: String` axis
5803// convention), so the offending author can grep their caixa.lisp for
5804// the offending `:tag "<value>"` / `:branch "<value>"` /
5805// `:rev "<value>"` literal in one edit.
5806//
5807// The single ctor below folds each wire-up onto one dispatch:
5808// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5809// the pre-lift struct-literal on the same `(&str, &str, &str,
5810// String)` fixture. The uniform four-field construction
5811// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5812// `reason` forwarded owned) is spelled once here rather than at every
5813// wire-up site. The `reason: String` field takes an owned `String`
5814// (not `impl Into<String>`) matching the two call sites' pre-existing
5815// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5816// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5817// predicates return `Result<(), String>`, so the caller always holds
5818// an owned `String` at the wire-up site and threading it through the
5819// ctor without a `.into()` shim keeps the routing shape byte-equal to
5820// the pre-lift block. The `value: &str` parameter accepts both `&str`
5821// literals (unused today) and `&String` (from the caller-held
5822// `v: &String` on each arm, via Deref coercion), so every existing
5823// wire-up threads through the ctor without a pre-conversion.
5824//
5825// Every future consumer that wants to construct this variant outside
5826// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5827// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5828// re-checking the same value-shape axes the resolver consumes, a
5829// future `feira validate --deps` per-caixa admission verb re-checking
5830// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5831// resolver rejecting a git-pin value against a cluster-local
5832// snapshot) now reaches this variant through one call rather than
5833// re-inlining the six-line struct-literal in lockstep with the two
5834// in-crate wire-up sites.
5835impl DepError {
5836    /// Construct a [`DepError::FontePinShape`] naming the offending
5837    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5838    /// axis tag, the offending value, and the parser-shaped `reason`.
5839    /// Folds the uniform
5840    /// `Self::FontePinShape { nome: nome.to_string(),
5841    /// pin: pin.to_string(), value: value.to_string(), reason }`
5842    /// four-field struct-literal onto one substrate primitive so
5843    /// every [`DepSource::validate`] wire-up on this variant reads
5844    /// through one dispatch rather than the pre-lift six-line
5845    /// open-coded block. The `nome` string threads verbatim from
5846    /// [`Dep::nome`] at the call site; the `pin` string carries the
5847    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5848    /// `value` string carries the offending refname / hex-OID
5849    /// verbatim; and `reason` forwards the owned `String` returned
5850    /// by [`crate::render::is_git_ref_name`] /
5851    /// [`crate::render::is_git_oid`] without a `.into()` shim.
5852    #[must_use]
5853    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5854        Self::FontePinShape {
5855            nome: nome.to_string(),
5856            pin: pin.to_string(),
5857            value: value.to_string(),
5858            reason,
5859        }
5860    }
5861
5862    /// Construct a [`DepError::NomeInvalid`] naming the offending
5863    /// `:deps :nome` byte-string and the parser-shaped rejection
5864    /// `reason` returned by [`crate::render::is_dns_1123_label`].
5865    ///
5866    /// Folds the uniform
5867    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5868    /// struct-literal onto one substrate primitive so every wire-up on
5869    /// this variant reads through one dispatch rather than the pre-lift
5870    /// four-line open-coded `DepError::NomeInvalid { nome:
5871    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5872    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5873    /// ctor-family ladder (`{ nome }` one-slot →
5874    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5875    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5876    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5877    /// `{ nome, <axis>: String, reason: String }` three-slot →
5878    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5879    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5880    /// — the sole variant on the envelope carrying the
5881    /// `{ nome: String, reason: String }` two-slot shape without a
5882    /// middle axis, matching the peer
5883    /// [`crate::manifest::ManifestError::NomeInvalid`] +
5884    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5885    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5886    /// four-axis DNS-1123 caixa-identifier diagnostic family the
5887    /// existing `nome_invalid_diagnostic_carries_offending_name` test
5888    /// pins on this envelope.
5889    ///
5890    /// The `nome: &str` parameter accepts `&str` literals and `&String`
5891    /// (via Deref coercion) so the sole in-crate wire-up threads through
5892    /// the ctor without a pre-conversion; the `reason: String`
5893    /// parameter takes an owned `String` (not `impl Into<String>`)
5894    /// matching the [`crate::render::is_dns_1123_label`] predicate's
5895    /// `Result<(), String>` return shape the sole wire-up site already
5896    /// holds owned at the call site, keeping the routing byte-equal to
5897    /// the pre-lift block. Same owned-`String`-forward `reason` payload
5898    /// discipline as the sibling three-slot family
5899    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5900    /// and the four-slot [`DepError::fonte_pin_shape`] on
5901    /// `{ nome, pin, value, reason }`.
5902    ///
5903    /// Every future consumer that raises the same diagnostic outside
5904    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5905    /// re-validator at lacre-resolve time re-checking each declared
5906    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5907    /// side schema uses (the `:nome` value flows verbatim as the target
5908    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5909    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5910    /// checkout-directory leaf), a future `feira validate --deps`
5911    /// per-caixa admission verb re-running the shape gate on demand, a
5912    /// per-lacre overlay resolver rejecting an author-supplied dep's
5913    /// `:nome` against a cluster-local snapshot the M4 CR materializer
5914    /// projects, a future authoring-surface widening the field into a
5915    /// `(String, Vec<Suggestion>)` pair carrying a
5916    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5917    /// variant through one call rather than re-inlining the four-line
5918    /// struct-literal in lockstep with the one in-crate wire-up site.
5919    #[must_use]
5920    pub fn nome_invalid(nome: &str, reason: String) -> Self {
5921        Self::NomeInvalid {
5922            nome: nome.to_string(),
5923            reason,
5924        }
5925    }
5926}
5927
5928#[allow(clippy::trivially_copy_pass_by_ref)]
5929fn is_false(b: &bool) -> bool {
5930    !*b
5931}
5932
5933#[cfg(test)]
5934mod tests {
5935    use super::*;
5936
5937    #[test]
5938    fn registry_dep_is_minimal() {
5939        let d = Dep::simple("caixa-teia", "^0.1");
5940        assert_eq!(d.nome, "caixa-teia");
5941        assert_eq!(d.versao, "^0.1");
5942        assert!(d.fonte.is_none());
5943        assert!(!d.opcional());
5944        assert!(d.caracteristicas().is_empty());
5945    }
5946
5947    #[test]
5948    fn dep_string_scalar_accessor_pair_is_const_fn() {
5949        // Fail-before-pass-after pin on [`Dep::nome`] +
5950        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5951        // Each accessor projects the per-`:deps` / per-`:deps-dev`
5952        // entry's [`String`] storage through the `pub const fn`
5953        // [`String::as_str`] (const-stable since Rust 1.87, well
5954        // within the workspace MSRV) — any future accidental
5955        // downgrade to non-`const` fails the corresponding
5956        // `<name>_via_const_fn` wrapper at caixa-core build time with
5957        // E0015 (`cannot call non-const method`), strictly stronger
5958        // than a runtime `assert!`. Sibling of the peer
5959        // per-M2/M3/universal-axis `String → &str` scalar-accessor
5960        // family pins on the sibling `const`-eval-surface passes
5961        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5962        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5963        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5964        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5965        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5966        // [`crate::aplicacao::Entrada::destination`] at the M3
5967        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5968        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5969        // M2 supervisor-tree axis,
5970        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5971        // M2 upgrade axis, and the per-`:contratos`
5972        // [`crate::aplicacao::WitContract::source`] /
5973        // [`crate::aplicacao::WitContract::destination`] /
5974        // [`crate::aplicacao::WitContract::world_ref`] trio the
5975        // sibling pin at 279823b already anchors).
5976        const fn nome_via_const_fn(d: &Dep) -> &str {
5977            d.nome()
5978        }
5979        const fn versao_via_const_fn(d: &Dep) -> &str {
5980            d.versao_requirement()
5981        }
5982        for (nome, versao) in [
5983            ("caixa-teia", "^0.1"),
5984            ("caixa-mesh", "~0.2.3"),
5985            ("caixa-helm", "*"),
5986        ] {
5987            let d = Dep::simple(nome, versao);
5988            assert_eq!(nome_via_const_fn(&d), d.nome());
5989            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5990            assert_eq!(d.nome(), nome);
5991            assert_eq!(d.versao_requirement(), versao);
5992        }
5993    }
5994
5995    #[test]
5996    fn dep_outer_accessor_family_is_const_fn() {
5997        // Fail-before-pass-after pin on [`Dep::fonte`] +
5998        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5999        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6000        // entry's composite / list storage through a `pub const fn`
6001        // stdlib method (`Option::<DepSource>::as_ref` /
6002        // `Vec::<String>::as_slice`, both const-stable since Rust
6003        // 1.83, well within the workspace MSRV). Any future
6004        // accidental downgrade to non-`const` fails the corresponding
6005        // `<name>_via_const_fn` wrapper at caixa-core build time with
6006        // E0015 (`cannot call non-const method`), strictly stronger
6007        // than a runtime `assert!` and side-stepping the destructor-
6008        // in-const restriction the `Dep` fixture's `String` /
6009        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6010        // direct-`const _: () = assert!(...)` residence.
6011        //
6012        // Peer of the sibling per-`Dep` scalar-accessor pair pin
6013        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6014        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6015        // the `const`-eval-surface discipline onto the composite-
6016        // reference and slice-return arms of the outer-`Dep` accessor
6017        // family, closing the four-slot outer surface (`:nome` +
6018        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6019        // posture. The `:opcional` `bool` arm already carries the
6020        // posture through [`Dep::opcional`]'s prior `pub const fn`
6021        // declaration, so this pin lands the last two unlifted
6022        // outer-`Dep` accessors and closes the family.
6023        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6024            d.fonte()
6025        }
6026        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6027            d.caracteristicas()
6028        }
6029        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6030        let empty = Dep::simple("caixa-teia", "^0.1");
6031        assert!(fonte_via_const_fn(&empty).is_none());
6032        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6033        assert!(caracteristicas_via_const_fn(&empty).is_empty());
6034        assert_eq!(
6035            caracteristicas_via_const_fn(&empty),
6036            empty.caracteristicas()
6037        );
6038        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6039        // still empty.
6040        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6041        assert!(fonte_via_const_fn(&git).is_some());
6042        assert_eq!(fonte_via_const_fn(&git), git.fonte());
6043        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6044        // Populated `:caracteristicas` — exercise the non-empty
6045        // slice-view arm to pin the accessor's borrow shape against
6046        // both a `Vec::new()` empty backing buffer and a populated one.
6047        let mut with_features = Dep::simple("caixa-teia", "^0.1");
6048        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6049        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6050        assert_eq!(
6051            caracteristicas_via_const_fn(&with_features),
6052            with_features.caracteristicas()
6053        );
6054    }
6055
6056    #[test]
6057    fn git_dep_carries_tag() {
6058        let d = Dep::git("t", "*", "github:o/r", "v1");
6059        match d.fonte {
6060            Some(DepSource::Git {
6061                ref repo, ref tag, ..
6062            }) => {
6063                assert_eq!(repo, "github:o/r");
6064                assert_eq!(tag.as_deref(), Some("v1"));
6065            }
6066            _ => panic!("expected Git source"),
6067        }
6068    }
6069
6070    #[test]
6071    fn validate_accepts_simple_dep() {
6072        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6073    }
6074
6075    #[test]
6076    fn validate_rejects_empty_nome() {
6077        // The fail-before-pass-after pin for `:nome ""`: the empty-name
6078        // arm fires first so the per-entry parse-side diagnostic doesn't
6079        // emit a useless `nome: ""` reference.
6080        let mut d = Dep::simple("placeholder", "^0.1");
6081        d.nome = String::new();
6082        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6083    }
6084
6085    #[test]
6086    fn validate_rejects_empty_versao() {
6087        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6088        // semver crate accepts the empty string as a wildcard match),
6089        // so the empty-`:versao` arm is structurally necessary even
6090        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6091        // `EmptyChildVersion` ordering on the other two `:versao` axes.
6092        let mut d = Dep::simple("caixa-teia", "ignored");
6093        d.versao = String::new();
6094        let err = d.validate().unwrap_err();
6095        assert!(
6096            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6097            "got {err:?}"
6098        );
6099    }
6100
6101    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6102
6103    #[test]
6104    fn validate_rejects_nome_with_uppercase() {
6105        // The fail-before-pass-after pin: a non-empty but uppercase
6106        // `:nome` silently passed `validate()` on every pre-gate
6107        // codebase because the prior shape only refused the empty
6108        // string. The DNS-1123 violation surfaced far downstream at
6109        // lacre-resolve time when the *target* caixa's `:nome` failed
6110        // its own gate — far from the `:deps` entry, with a diagnostic
6111        // naming the target rather than the dep entry that referenced
6112        // it. Same fail-before-pass-after fixture pinned for
6113        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6114        // and Caixa `:nome` (6c992f8).
6115        let d = Dep::simple("Caixa-Teia", "^0.1");
6116        let err = d.validate().unwrap_err();
6117        assert!(
6118            matches!(
6119                err,
6120                DepError::NomeInvalid { ref nome, ref reason }
6121                    if nome == "Caixa-Teia" && reason.contains("uppercase")
6122            ),
6123            "got {err:?}"
6124        );
6125    }
6126
6127    #[test]
6128    fn validate_rejects_nome_with_underscore() {
6129        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6130        // "I'm thinking of Go module names / Python identifiers" leak.
6131        // Same fixture pinned for the peer caixa-identifier axes.
6132        let d = Dep::simple("caixa_teia", "^0.1");
6133        let err = d.validate().unwrap_err();
6134        assert!(
6135            matches!(
6136                err,
6137                DepError::NomeInvalid { ref nome, ref reason }
6138                    if nome == "caixa_teia" && reason.contains('_')
6139            ),
6140            "got {err:?}"
6141        );
6142    }
6143
6144    #[test]
6145    fn validate_rejects_nome_with_dot() {
6146        // A `:deps :nome` is a single DNS-1123 *label*, not a
6147        // subdomain — dots are rejected. The `"caixa.teia"` shape is
6148        // the canonical "I confused the dep name with the FQDN /
6149        // namespace" footgun, distinct from the legitimate
6150        // `:fonte :repo "github:org/caixa-teia"` axis.
6151        let d = Dep::simple("caixa.teia", "^0.1");
6152        let err = d.validate().unwrap_err();
6153        assert!(
6154            matches!(
6155                err,
6156                DepError::NomeInvalid { ref nome, ref reason }
6157                    if nome == "caixa.teia" && reason.contains('.')
6158            ),
6159            "got {err:?}"
6160        );
6161    }
6162
6163    #[test]
6164    fn validate_rejects_nome_with_leading_hyphen() {
6165        // RFC 1123 requires alphanumeric at both label boundaries.
6166        // Pinned in parity with the peer DNS-1123 fixtures.
6167        let d = Dep::simple("-caixa-teia", "^0.1");
6168        let err = d.validate().unwrap_err();
6169        assert!(
6170            matches!(
6171                err,
6172                DepError::NomeInvalid { ref nome, ref reason }
6173                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
6174            ),
6175            "got {err:?}"
6176        );
6177    }
6178
6179    #[test]
6180    fn validate_rejects_nome_with_trailing_hyphen() {
6181        let d = Dep::simple("caixa-teia-", "^0.1");
6182        let err = d.validate().unwrap_err();
6183        assert!(
6184            matches!(
6185                err,
6186                DepError::NomeInvalid { ref nome, ref reason }
6187                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
6188            ),
6189            "got {err:?}"
6190        );
6191    }
6192
6193    #[test]
6194    fn validate_rejects_nome_with_slash() {
6195        // The canonical "I copied the GitHub repo path into `:nome`
6196        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6197        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6198        // the local-name slot. Same fixture pinned for `:membros
6199        // :caixa` (3f9d7a0).
6200        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6201        let err = d.validate().unwrap_err();
6202        assert!(
6203            matches!(
6204                err,
6205                DepError::NomeInvalid { ref nome, ref reason }
6206                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
6207            ),
6208            "got {err:?}"
6209        );
6210    }
6211
6212    #[test]
6213    fn validate_rejects_nome_too_long() {
6214        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6215        // Built from a valid character set so the length-bound
6216        // diagnostic surfaces before any per-character check (the
6217        // order pin parallel to the per-character predicates inside
6218        // [`crate::render::is_dns_1123_label`]).
6219        let long = "a".repeat(64);
6220        let d = Dep::simple(&long, "^0.1");
6221        let err = d.validate().unwrap_err();
6222        assert!(
6223            matches!(
6224                err,
6225                DepError::NomeInvalid { ref nome, ref reason }
6226                    if nome.len() == 64 && reason.contains("max length of 63")
6227            ),
6228            "got {err:?}"
6229        );
6230    }
6231
6232    #[test]
6233    fn validate_accepts_canonical_nome_labels() {
6234        // Positive-control sweep — every form the K8s apiserver
6235        // accepts as a DNS-1123 label must round-trip through
6236        // validate. Covers a hyphen-bearing label, a numeric-suffix
6237        // label, a leading-digit label, a single-character label, and
6238        // a 63-byte (exactly the cap) label — the same fixture set
6239        // the peer `:membros :caixa` / `:children :caixa` positive
6240        // controls pin.
6241        for nome in [
6242            "caixa-teia",
6243            "caixa-resolver2",
6244            "2nd-tier-cache",
6245            "x",
6246            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6247        ] {
6248            Dep::simple(nome, "^0.1")
6249                .validate()
6250                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6251        }
6252    }
6253
6254    #[test]
6255    fn nome_empty_takes_precedence_over_nome_invalid() {
6256        // Ordering pin: `NomeEmpty` is the more self-locating
6257        // diagnostic on `""` and must lead — `is_dns_1123_label` is
6258        // only reached after the empty-check fires at the call site.
6259        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6260        // (3f9d7a0) on the peer caixa-identifier axis.
6261        let mut d = Dep::simple("placeholder", "^0.1");
6262        d.nome = String::new();
6263        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6264    }
6265
6266    #[test]
6267    fn nome_invalid_fires_before_versao_empty() {
6268        // Ordering pin: a malformed `:nome` fires before any `:versao`
6269        // axis check on the *same* entry — the per-entry shape gates
6270        // run top-to-bottom (nome empty → nome shape → versao empty →
6271        // versao parse → fonte shape), so a one-entry caixa.lisp with
6272        // both wrong sees the name-side diagnostic first (the name is
6273        // the self-locating axis — without a valid name, the parse
6274        // diagnostic can't quote `:nome "<bad>"`). Same ordering
6275        // discipline as `membro_caixa_invalid_fires_before_versao_check`
6276        // (3f9d7a0).
6277        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6278        d.versao = String::new();
6279        let err = d.validate().unwrap_err();
6280        assert!(
6281            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6282            "got {err:?}"
6283        );
6284    }
6285
6286    #[test]
6287    fn nome_invalid_fires_before_versao_invalid() {
6288        // Ordering pin: a malformed `:nome` fires before the `:versao`
6289        // parse-side check on the *same* entry. Pin separately from
6290        // the empty-versao ordering so a future re-ordering surfaces
6291        // here, parallel to the b0c8389 / c4213a4 trajectory.
6292        let d = Dep::simple("Caixa-Teia", "^^0.1");
6293        let err = d.validate().unwrap_err();
6294        assert!(
6295            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6296            "got {err:?}"
6297        );
6298    }
6299
6300    #[test]
6301    fn nome_invalid_fires_before_fonte_invalid() {
6302        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6303        // shape check on the *same* entry. The `:fonte` diagnostic
6304        // names the offending dep's `:nome` verbatim (via
6305        // `DepSource::validate(&self.nome)`), so a non-self-locating
6306        // name would taint the downstream diagnostic too — the gate
6307        // ordering keeps both diagnostics individually self-locating.
6308        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6309        d.fonte = Some(DepSource::Git {
6310            repo: String::new(),
6311            tag: None,
6312            rev: None,
6313            branch: None,
6314        });
6315        let err = d.validate().unwrap_err();
6316        assert!(
6317            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6318            "got {err:?}"
6319        );
6320    }
6321
6322    #[test]
6323    fn nome_invalid_diagnostic_carries_offending_name() {
6324        // The diagnostic-shape pin: the error names the offending
6325        // `:nome` value verbatim so the author can grep their
6326        // caixa.lisp without re-running the build, and carries a
6327        // non-empty `reason` from `is_dns_1123_label` so the
6328        // predicate's own wording flows through to the diagnostic.
6329        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6330        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6331        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6332        // share a structurally-equivalent diagnostic family.
6333        let d = Dep::simple("Caixa_Teia", "^0.1");
6334        let err = d.validate().unwrap_err();
6335        let DepError::NomeInvalid { nome, reason } = err else {
6336            panic!("expected NomeInvalid, got other variant");
6337        };
6338        assert_eq!(nome, "Caixa_Teia");
6339        assert!(
6340            !reason.is_empty(),
6341            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6342        );
6343    }
6344
6345    #[test]
6346    fn validate_rejects_invalid_versao_requirement() {
6347        // The fail-before-pass-after pin: a non-empty but malformed
6348        // requirement (`"^bad-version"`) silently passed every pre-gate
6349        // codebase because `:deps :versao` wasn't validated. The parse
6350        // failure surfaced far downstream at lacre-resolve time with a
6351        // `semver::Error` that didn't name which `:deps` entry carried
6352        // the typo. The new gate moves the check to caixa-build time
6353        // at the source caixa.lisp.
6354        let d = Dep::simple("caixa-teia", "^bad-version");
6355        let err = d.validate().unwrap_err();
6356        assert!(
6357            matches!(
6358                err,
6359                DepError::VersaoInvalid { ref nome, ref versao, .. }
6360                    if nome == "caixa-teia" && versao == "^bad-version"
6361            ),
6362            "got {err:?}"
6363        );
6364    }
6365
6366    #[test]
6367    fn validate_rejects_versao_with_double_caret_typo() {
6368        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6369        // Cargo-shaped requirement on first glance but fails the parser
6370        // because semver doesn't accept stacked operators. Pin this
6371        // adjacent-shape footgun explicitly so a future relaxation that
6372        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6373        // parity with the `:membros` / `:children` fixtures.
6374        let d = Dep::simple("caixa-teia", "^^0.1");
6375        let err = d.validate().unwrap_err();
6376        assert!(
6377            matches!(
6378                err,
6379                DepError::VersaoInvalid { ref nome, ref versao, .. }
6380                    if nome == "caixa-teia" && versao == "^^0.1"
6381            ),
6382            "got {err:?}"
6383        );
6384    }
6385
6386    #[test]
6387    fn validate_rejects_versao_with_v_prefixed_tag() {
6388        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6389        // semver requirement slot" typo — an author copies the
6390        // publish-side git-tag string verbatim into `:versao`, but
6391        // Cargo's semver parser rejects the leading `v`. Same fixture
6392        // pinned for `:membros :versao` (9888b13) and `:children
6393        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6394        // are *accepted* by the semver crate as an `*` wildcard on the
6395        // patch axis — they're a Cargo-side valid shape, not a typo.)
6396        let d = Dep::simple("caixa-teia", "v0.1");
6397        let err = d.validate().unwrap_err();
6398        assert!(
6399            matches!(
6400                err,
6401                DepError::VersaoInvalid { ref nome, ref versao, .. }
6402                    if nome == "caixa-teia" && versao == "v0.1"
6403            ),
6404            "got {err:?}"
6405        );
6406    }
6407
6408    #[test]
6409    fn validate_accepts_canonical_versao_forms() {
6410        // The five Cargo-shaped requirement forms `:membros :versao`
6411        // and `:children :versao` already accept via
6412        // `crate::parse_requirement` must pass the deps gate without
6413        // re-validating at the resolver layer. Pin every leg so a
6414        // future tightening of the canonical set surfaces here as a
6415        // test failure.
6416        for form in [
6417            "^0.1",      // caret — minor-range pin (the most common shape)
6418            "~0.1.2",    // tilde — patch-range pin
6419            "0.1.0",     // exact — single-version pin
6420            "*",         // wildcard — explicitly any-version
6421            ">=0.1, <2", // multi-range — comma-separated comparators
6422        ] {
6423            Dep::simple("caixa-teia", form)
6424                .validate()
6425                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6426        }
6427    }
6428
6429    #[test]
6430    fn versao_empty_takes_precedence_over_invalid() {
6431        // Order pin: the existing `VersaoEmpty` diagnostic (which
6432        // doesn't try to parse) fires before the new `VersaoInvalid`
6433        // parse-side diagnostic, so an empty `:versao` keeps its
6434        // narrower error message — `parse_requirement("")` would
6435        // otherwise return `Ok(STAR)` and silently pass, but the empty
6436        // arm catches it first.
6437        let mut d = Dep::simple("caixa-teia", "ignored");
6438        d.versao = String::new();
6439        let err = d.validate().unwrap_err();
6440        assert!(
6441            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6442            "got {err:?}"
6443        );
6444    }
6445
6446    #[test]
6447    fn nome_empty_takes_precedence_over_versao_invalid() {
6448        // Order pin: even when `:versao` is malformed and would raise
6449        // its own diagnostic, `:nome ""` fires first because the
6450        // per-entry parse diagnostic needs a non-empty name to be
6451        // self-locating. Mirrors the
6452        // `membros_validation_runs_before_contratos_membership_check`
6453        // ordering on the typed-graph layer.
6454        let mut d = Dep::simple("placeholder", "^bad");
6455        d.nome = String::new();
6456        let err = d.validate().unwrap_err();
6457        assert_eq!(err, DepError::NomeEmpty);
6458    }
6459
6460    #[test]
6461    fn versao_invalid_diagnostic_carries_offending_versao() {
6462        // The diagnostic-shape pin: the error names the offending
6463        // `:versao` value verbatim so the author can grep their
6464        // caixa.lisp without re-running the build, and carries a
6465        // non-empty `reason` from `semver::VersionReq::parse` so the
6466        // parser's own wording flows through to the diagnostic.
6467        let d = Dep::simple("caixa-teia", "not-a-req");
6468        let err = d.validate().unwrap_err();
6469        let DepError::VersaoInvalid {
6470            nome,
6471            versao,
6472            reason,
6473        } = err
6474        else {
6475            panic!("expected VersaoInvalid, got other variant");
6476        };
6477        assert_eq!(nome, "caixa-teia");
6478        assert_eq!(versao, "not-a-req");
6479        assert!(
6480            !reason.is_empty(),
6481            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6482        );
6483    }
6484
6485    // -- :fonte value-shape gate ------------------------------------------
6486
6487    fn dep_with_fonte(fonte: DepSource) -> Dep {
6488        let mut d = Dep::simple("caixa-teia", "^0.1");
6489        d.fonte = Some(fonte);
6490        d
6491    }
6492
6493    #[test]
6494    fn validate_accepts_git_fonte_with_tag() {
6495        // The positive-control pin on the canonical git source — exactly
6496        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6497        // shape every existing caixa-resolver integration test uses.
6498        let d = dep_with_fonte(DepSource::Git {
6499            repo: "github:pleme-io/caixa-teia".into(),
6500            tag: Some("v0.1.0".into()),
6501            rev: None,
6502            branch: None,
6503        });
6504        d.validate().unwrap();
6505    }
6506
6507    #[test]
6508    fn validate_accepts_git_fonte_with_rev() {
6509        // Each of the three pin axes is independently a valid single-pin
6510        // shape; pin the :rev arm so a future relaxation that only
6511        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6512        // OID — the canonical `git rev-parse HEAD` emission shape the
6513        // `crate::render::is_git_oid` value-shape gate now requires;
6514        // abbreviated OIDs are ambiguous across repo history and
6515        // rejected at this gate (pinned separately by
6516        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6517        let d = dep_with_fonte(DepSource::Git {
6518            repo: "github:pleme-io/caixa-teia".into(),
6519            tag: None,
6520            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6521            branch: None,
6522        });
6523        d.validate().unwrap();
6524    }
6525
6526    #[test]
6527    fn validate_accepts_git_fonte_with_branch() {
6528        // The :branch arm is the third valid single-pin shape — pinned
6529        // separately so the gate-accepts-all-three-pin-axes contract is
6530        // a build-error to relax.
6531        let d = dep_with_fonte(DepSource::Git {
6532            repo: "github:pleme-io/caixa-teia".into(),
6533            tag: None,
6534            rev: None,
6535            branch: Some("main".into()),
6536        });
6537        d.validate().unwrap();
6538    }
6539
6540    #[test]
6541    fn validate_accepts_path_fonte() {
6542        // The positive-control pin on the path source — non-empty
6543        // :caminho, no pin axes (paths have no commit identity). Pinned
6544        // so a future "paths must also pin a rev" tightening surfaces
6545        // here as a structural decision, not a silent break.
6546        let d = dep_with_fonte(DepSource::Path {
6547            caminho: "../caixa-teia".into(),
6548        });
6549        d.validate().unwrap();
6550    }
6551
6552    #[test]
6553    fn validate_rejects_git_fonte_with_empty_repo() {
6554        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6555        // "v1")`: the empty-repo shape silently passed every pre-gate
6556        // codebase because `:fonte` wasn't validated. The git-clone
6557        // failure surfaced far downstream at lacre-resolve time with no
6558        // field naming which `:deps` entry carried the typo. The new
6559        // gate moves the check to caixa-build time at the source
6560        // caixa.lisp.
6561        let d = dep_with_fonte(DepSource::Git {
6562            repo: String::new(),
6563            tag: Some("v0.1.0".into()),
6564            rev: None,
6565            branch: None,
6566        });
6567        let err = d.validate().unwrap_err();
6568        assert!(
6569            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6570            "got {err:?}"
6571        );
6572    }
6573
6574    // -- :repo value-shape gate -------------------------------------------
6575    //
6576    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6577    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6578    // codebase admitted any non-empty string; the new
6579    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6580    // URL intersection-floor at validate time, peer with the three pin
6581    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6582    // `is_git_oid`). Every test in this section is a fail-before /
6583    // pass-after pin on a specific authoring footgun.
6584
6585    #[test]
6586    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6587        // The canonical paste-from-doc footgun on `:repo` — an author
6588        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6589        // a doc paragraph. Until this gate landed the empty-repo arm
6590        // passed (the string isn't empty), the resolver issued
6591        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6592        // surfaced at clone time with a quoting-confused error far from
6593        // the source caixa.lisp. Same paste-from-doc footgun the
6594        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6595        // axis — now closed on the `:repo` URL axis too.
6596        let d = dep_with_fonte(DepSource::Git {
6597            repo: "github:pleme-io/caixa-teia ".into(),
6598            tag: Some("v0.1.0".into()),
6599            rev: None,
6600            branch: None,
6601        });
6602        let err = d.validate().unwrap_err();
6603        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6604            panic!("expected FonteRepoShape, got other variant");
6605        };
6606        assert_eq!(nome, "caixa-teia");
6607        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6608        assert!(
6609            reason.contains("whitespace"),
6610            "reason must surface the whitespace arm, got {reason:?}"
6611        );
6612    }
6613
6614    #[test]
6615    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6616        // The canonical CLI-argument-injection footgun at the `git clone`
6617        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6618        // argv parser read the value as a CLI flag, escaping the
6619        // subprocess argument boundary. The `--` separator workaround
6620        // does not fix the typed slot's accepted set; the gate rejects
6621        // the shape upstream at validate time so the resolver never
6622        // invokes a `git clone -…` subprocess.
6623        let d = dep_with_fonte(DepSource::Git {
6624            repo: "-upload-pack=evil".into(),
6625            tag: Some("v0.1.0".into()),
6626            rev: None,
6627            branch: None,
6628        });
6629        let err = d.validate().unwrap_err();
6630        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6631            panic!("expected FonteRepoShape, got other variant");
6632        };
6633        assert_eq!(repo, "-upload-pack=evil");
6634        assert!(
6635            reason.contains("must not start with `-`"),
6636            "reason must surface the leading-`-` arm, got {reason:?}"
6637        );
6638    }
6639
6640    #[test]
6641    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6642        // The canonical paste-from-multiline-doc footgun — a `:repo`
6643        // string with an embedded `\n` silently breaks git's URL parser
6644        // and is a class of CRLF-injection at the subprocess-argument
6645        // boundary. Caught by the control-char arm (0x0A < 0x20).
6646        let d = dep_with_fonte(DepSource::Git {
6647            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6648            tag: Some("v0.1.0".into()),
6649            rev: None,
6650            branch: None,
6651        });
6652        let err = d.validate().unwrap_err();
6653        let DepError::FonteRepoShape { reason, .. } = err else {
6654            panic!("expected FonteRepoShape, got other variant");
6655        };
6656        assert!(
6657            reason.contains("control character"),
6658            "reason must surface the control-char arm, got {reason:?}"
6659        );
6660    }
6661
6662    #[test]
6663    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6664        // Tab is the sibling whitespace footgun (the canonical
6665        // copy-from-aligned-table paste); pinned separately from the
6666        // space arm so a future relaxation that only catches one
6667        // surfaces here.
6668        let d = dep_with_fonte(DepSource::Git {
6669            repo: "github:pleme-io/caixa-teia\t".into(),
6670            tag: Some("v0.1.0".into()),
6671            rev: None,
6672            branch: None,
6673        });
6674        let err = d.validate().unwrap_err();
6675        assert!(
6676            matches!(
6677                err,
6678                DepError::FonteRepoShape { ref reason, .. }
6679                    if reason.contains("whitespace")
6680            ),
6681            "got {err:?}"
6682        );
6683    }
6684
6685    #[test]
6686    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6687        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6688        // non-ASCII silently breaks at git's URL parser and round-trips
6689        // inconsistently across NFC/NFD normalization on APFS /
6690        // case-folding filesystems. Same intersection-floor
6691        // [`is_git_ref_name`] enforces on the refname axes.
6692        let d = dep_with_fonte(DepSource::Git {
6693            repo: "https://github.com/pleme-io/café".into(),
6694            tag: Some("v0.1.0".into()),
6695            rev: None,
6696            branch: None,
6697        });
6698        let err = d.validate().unwrap_err();
6699        assert!(
6700            matches!(
6701                err,
6702                DepError::FonteRepoShape { ref reason, .. }
6703                    if reason.contains("non-ASCII")
6704            ),
6705            "got {err:?}"
6706        );
6707    }
6708
6709    #[test]
6710    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6711        // The fail-before-pass-after pin for the canonical paste-from-
6712        // browser-address-bar footgun on `:repo`: an author copies a
6713        // GitHub permalink to a README anchor / line-permalink and
6714        // forgets to trim the `#fragment` tail. Until this arm landed
6715        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6716        // silently passed every prior arm (no whitespace, no control
6717        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6718        // or `:`), libcurl's URL parser stripped the `#readme` tail
6719        // before opening the HTTPS transport, and the lacre embedded
6720        // the value verbatim in its per-dep BLAKE3 closure — two
6721        // authors whose values differ only in their fragment anchor
6722        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6723        // `git clone` but lock to two distinct lacres, defeating the
6724        // THEORY.md §V.2 render-determinism contract. Same value-shape
6725        // axis-floor every peer typed surface enforces; peer `:fonte
6726        // :tag` / `:fonte :branch` already reject the byte-class through
6727        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6728        // URL grammar admitted) and `:entrada :paths` rejects `#` as
6729        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6730        let d = dep_with_fonte(DepSource::Git {
6731            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6732            tag: Some("v0.1.0".into()),
6733            rev: None,
6734            branch: None,
6735        });
6736        let err = d.validate().unwrap_err();
6737        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6738            panic!("expected FonteRepoShape, got other variant");
6739        };
6740        assert_eq!(nome, "caixa-teia");
6741        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6742        assert!(
6743            reason.contains("must not contain `#`"),
6744            "reason must surface the fragment-`#` arm, got {reason:?}"
6745        );
6746        assert!(
6747            reason.contains("fragment"),
6748            "reason must name the URL fragment grammar, got {reason:?}"
6749        );
6750    }
6751
6752    #[test]
6753    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6754        // The symmetric paste-from-Nix-flake-ref footgun — an author
6755        // confuses the Nix flake-reference idiom (`github:foo/
6756        // bar#packageName`, where `#packageName` selects a flake
6757        // output) with the bare git `:repo` shape. The pleme-io
6758        // substrate authors compose flakes downstream of caixa
6759        // (caixa-flake renders a flake.nix), so the cross-idiom leak
6760        // is the canonical near-miss: the author writes the
6761        // flake-ref shape into a git `:repo` slot. Pinned separately
6762        // from the HTTPS-anchor arm so a future relaxation that
6763        // narrows to one URL scheme surfaces here.
6764        let d = dep_with_fonte(DepSource::Git {
6765            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6766            tag: Some("v0.1.0".into()),
6767            rev: None,
6768            branch: None,
6769        });
6770        let err = d.validate().unwrap_err();
6771        let DepError::FonteRepoShape { reason, .. } = err else {
6772            panic!("expected FonteRepoShape, got other variant");
6773        };
6774        assert!(
6775            reason.contains("must not contain `#`"),
6776            "reason must surface the fragment-`#` arm, got {reason:?}"
6777        );
6778        assert!(
6779            reason.contains("Nix flake"),
6780            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6781        );
6782    }
6783
6784    #[test]
6785    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6786        // The fail-before-pass-after pin for the canonical paste-from-
6787        // browser-address-bar footgun on `:repo` (peer with the
6788        // a68f818 fragment-`#` arm on the same axis). An author
6789        // copies a GitHub tab deep-link out of the address bar and
6790        // forgets to trim the `?tab=…` query tail. Until this arm
6791        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6792        // silently passed every prior arm (no whitespace, no control
6793        // chars, no non-ASCII, no `#` fragment, contains a `:`,
6794        // doesn't start with `-` or `:`); GitHub silently ignored
6795        // the `?query` tail and served the same repo regardless;
6796        // the lacre embedded the value verbatim in its per-dep
6797        // BLAKE3 closure — two authors whose values differ only in
6798        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6799        // `?utm_source=twitter`) resolve to the byte-identical
6800        // upstream `git clone` but lock to two distinct lacres,
6801        // defeating the THEORY.md §V.2 render-determinism contract
6802        // on the same axis the `#` fragment arm closes. Same value-
6803        // shape axis-floor every peer typed surface enforces; peer
6804        // `:fonte :tag` / `:fonte :branch` already reject the byte-
6805        // class through `is_git_ref_name`'s alphabet (refspec glob
6806        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6807        // :paths` rejects `?` as the query separator in
6808        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6809        let d = dep_with_fonte(DepSource::Git {
6810            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6811            tag: Some("v0.1.0".into()),
6812            rev: None,
6813            branch: None,
6814        });
6815        let err = d.validate().unwrap_err();
6816        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6817            panic!("expected FonteRepoShape, got other variant");
6818        };
6819        assert_eq!(nome, "caixa-teia");
6820        assert_eq!(
6821            repo,
6822            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6823        );
6824        assert!(
6825            reason.contains("must not contain `?`"),
6826            "reason must surface the query-`?` arm, got {reason:?}"
6827        );
6828        assert!(
6829            reason.contains("query"),
6830            "reason must name the URL query grammar, got {reason:?}"
6831        );
6832    }
6833
6834    #[test]
6835    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6836        // The symmetric paste-from-social-share footgun — an author
6837        // copies a repo URL out of a Slack unfurl / Twitter share /
6838        // newsletter link / Discord embed and forgets to trim the
6839        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6840        // campaign-tracker tail. Every major social-share / unfurl /
6841        // newsletter platform appends these UTM parameters; the
6842        // canonical near-miss on the `:repo` axis. Pinned separately
6843        // from the GitHub-tab-deep-link arm so a future relaxation
6844        // that narrows to one query-parameter class surfaces here.
6845        let d = dep_with_fonte(DepSource::Git {
6846            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6847                .into(),
6848            tag: Some("v0.1.0".into()),
6849            rev: None,
6850            branch: None,
6851        });
6852        let err = d.validate().unwrap_err();
6853        let DepError::FonteRepoShape { reason, .. } = err else {
6854            panic!("expected FonteRepoShape, got other variant");
6855        };
6856        assert!(
6857            reason.contains("must not contain `?`"),
6858            "reason must surface the query-`?` arm, got {reason:?}"
6859        );
6860        assert!(
6861            reason.contains("campaign-tracker"),
6862            "reason must name the campaign-tracker paste footgun, got {reason:?}"
6863        );
6864    }
6865
6866    #[test]
6867    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6868        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6869        // both per-byte arms inside the same `for &b in s.as_bytes()`
6870        // loop, so the byte that appears first in the value's byte
6871        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6872        // (fragment before query — unusual URL-grammar but value-
6873        // disjoint at byte level) carries both `#` and `?`; the `#`
6874        // byte appears first, so the fragment-`#` arm fires, surfacing
6875        // the more self-locating diagnostic on the byte the author
6876        // pasted earliest in the URL. Mirrors the peer cascade
6877        // discipline `fonte_repo_control_char_fires_before_fragment`
6878        // pins on the prior `:repo` byte-class arm.
6879        let d = dep_with_fonte(DepSource::Git {
6880            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6881            tag: Some("v0.1.0".into()),
6882            rev: None,
6883            branch: None,
6884        });
6885        let err = d.validate().unwrap_err();
6886        let DepError::FonteRepoShape { reason, .. } = err else {
6887            panic!("expected FonteRepoShape, got other variant");
6888        };
6889        assert!(
6890            reason.contains("must not contain `#`"),
6891            "reason must surface the fragment-`#` arm (fires before query-`?` when \
6892             `#` byte appears first in value), got {reason:?}"
6893        );
6894    }
6895
6896    #[test]
6897    fn fonte_repo_control_char_fires_before_fragment() {
6898        // Cascade pin: the control-char arm structurally precedes the
6899        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6900        // positive on both arms (contains LF and `#`), but the narrower
6901        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6902        // (`control character`) wins so the author sees the more
6903        // self-locating arm first. Mirrors the peer cascade discipline
6904        // every prior `:repo` byte-class arm establishes.
6905        let d = dep_with_fonte(DepSource::Git {
6906            repo: "github:pleme-io/caixa-teia\n#readme".into(),
6907            tag: Some("v0.1.0".into()),
6908            rev: None,
6909            branch: None,
6910        });
6911        let err = d.validate().unwrap_err();
6912        let DepError::FonteRepoShape { reason, .. } = err else {
6913            panic!("expected FonteRepoShape, got other variant");
6914        };
6915        assert!(
6916            reason.contains("control character"),
6917            "reason must surface the control-char arm, got {reason:?}"
6918        );
6919    }
6920
6921    #[test]
6922    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6923        // The fail-before-pass-after pin for the canonical Windows-
6924        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6925        // backslash arm on the sibling `:caminho` path-fonte axis).
6926        // An author pastes a Windows Explorer address-bar / PowerShell
6927        // `Get-Location` output into a `file://` URL slot, producing
6928        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6929        // value silently passed every prior arm (no whitespace, no
6930        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6931        // with `-` or `:`); libcurl's URL parser silently translates
6932        // `\` → `/` on some platforms and refuses it on others, so
6933        // the byte rides verbatim into the lacre's per-dep content-
6934        // address but is silently rewritten / rejected at the wire —
6935        // two authors whose `:repo` values differ only in backslash-
6936        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6937        // resolve to the byte-identical local clone but lock to two
6938        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6939        // render-determinism contract on the same axis the `#`
6940        // fragment and `?` query arms close. Same value-shape axis-
6941        // floor every peer typed surface enforces; the `:caminho`
6942        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6943        let d = dep_with_fonte(DepSource::Git {
6944            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6945            tag: Some("v0.1.0".into()),
6946            rev: None,
6947            branch: None,
6948        });
6949        let err = d.validate().unwrap_err();
6950        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6951            panic!("expected FonteRepoShape, got other variant");
6952        };
6953        assert_eq!(nome, "caixa-teia");
6954        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6955        assert!(
6956            reason.contains("must not contain `\\`"),
6957            "reason must surface the backslash-`\\` arm, got {reason:?}"
6958        );
6959        assert!(
6960            reason.contains("Windows"),
6961            "reason must name the Windows-path-confusion footgun, got {reason:?}"
6962        );
6963    }
6964
6965    #[test]
6966    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6967        // The symmetric Win32-shell-mangled-slashes footgun — an author
6968        // copies `https://github.com/foo/bar` into a Win32 shell that
6969        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6970        // separator-coercion bug), pastes the result into a `:repo`
6971        // slot, and produces `https:\\github.com\foo\bar`. Pinned
6972        // separately from the `file://` Explorer-paste arm so a future
6973        // relaxation that narrows to one URL scheme surfaces here.
6974        let d = dep_with_fonte(DepSource::Git {
6975            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6976            tag: Some("v0.1.0".into()),
6977            rev: None,
6978            branch: None,
6979        });
6980        let err = d.validate().unwrap_err();
6981        let DepError::FonteRepoShape { reason, .. } = err else {
6982            panic!("expected FonteRepoShape, got other variant");
6983        };
6984        assert!(
6985            reason.contains("must not contain `\\`"),
6986            "reason must surface the backslash-`\\` arm, got {reason:?}"
6987        );
6988        assert!(
6989            reason.contains("path separator") || reason.contains("path-segment separator"),
6990            "reason must name the URL path-segment separator grammar, got {reason:?}"
6991        );
6992    }
6993
6994    #[test]
6995    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6996        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6997        // are both per-byte arms inside the same `for &b in s.as_bytes()`
6998        // loop, so the byte that appears first in the value's byte order
6999        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7000        // both `#` and `\`; the `#` byte appears first, so the fragment-
7001        // `#` arm fires, surfacing the more self-locating diagnostic on
7002        // the byte the author pasted earliest in the URL. Mirrors the
7003        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7004        // pins on the prior `:repo` byte-class arm.
7005        let d = dep_with_fonte(DepSource::Git {
7006            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7007            tag: Some("v0.1.0".into()),
7008            rev: None,
7009            branch: None,
7010        });
7011        let err = d.validate().unwrap_err();
7012        let DepError::FonteRepoShape { reason, .. } = err else {
7013            panic!("expected FonteRepoShape, got other variant");
7014        };
7015        assert!(
7016            reason.contains("must not contain `#`"),
7017            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7018             `#` byte appears first in value), got {reason:?}"
7019        );
7020    }
7021
7022    #[test]
7023    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7024        // The fail-before-pass-after pin for the canonical URI Template
7025        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7026        // README quick-start snippet / OpenAPI `servers:` URL / Helm
7027        // chart `home:` template that carries unresolved
7028        // `{org}` / `{repo}` placeholders and pastes the raw template
7029        // into the `:repo` slot, expecting the substrate to resolve the
7030        // placeholder downstream. Until this arm landed the value
7031        // silently passed every prior arm (no whitespace, no control
7032        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7033        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7034        // / `%7D` on the wire, so the byte rides verbatim into the
7035        // lacre's per-dep content-address but round-trips inconsistently
7036        // between the lacre's per-dep content-address and the
7037        // resolver's `git clone <repo>` invocation, defeating the
7038        // THEORY.md §V.2 render-determinism contract on the same axis
7039        // the `#` fragment, `?` query, and `\` backslash arms close;
7040        // every git porcelain entry-point additionally fetches a
7041        // nonexistent literal-`{placeholder}`-named path far from the
7042        // source caixa.lisp.
7043        let d = dep_with_fonte(DepSource::Git {
7044            repo: "https://github.com/{org}/caixa-teia".into(),
7045            tag: Some("v0.1.0".into()),
7046            rev: None,
7047            branch: None,
7048        });
7049        let err = d.validate().unwrap_err();
7050        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7051            panic!("expected FonteRepoShape, got other variant");
7052        };
7053        assert_eq!(nome, "caixa-teia");
7054        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7055        assert!(
7056            reason.contains("must not contain `{`"),
7057            "reason must surface the open-brace `{{` arm, got {reason:?}"
7058        );
7059        assert!(
7060            reason.contains("URI Template") || reason.contains("RFC 6570"),
7061            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7062        );
7063    }
7064
7065    #[test]
7066    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7067        // The symmetric Mustache / Handlebars doubled-brace
7068        // substitution-form footgun every CI / IaC templating engine
7069        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7070        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7071        // chart README quick-start snippet emits. Pinned separately
7072        // from the single-`{` `{org}` arm so a future relaxation that
7073        // narrows to one substitution-form surfaces here.
7074        let d = dep_with_fonte(DepSource::Git {
7075            repo: "https://github.com/{{org}}/caixa-teia".into(),
7076            tag: Some("v0.1.0".into()),
7077            rev: None,
7078            branch: None,
7079        });
7080        let err = d.validate().unwrap_err();
7081        let DepError::FonteRepoShape { reason, .. } = err else {
7082            panic!("expected FonteRepoShape, got other variant");
7083        };
7084        assert!(
7085            reason.contains("must not contain `{`"),
7086            "reason must surface the open-brace `{{` arm, got {reason:?}"
7087        );
7088    }
7089
7090    #[test]
7091    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7092        // Asymmetric `}`-only shape — covers the closing-brace-by-
7093        // itself footgun (an author truncated `{org}/{repo}` mid-edit
7094        // and left a trailing `}` from the prior template fragment,
7095        // or pasted a value that included a closing brace from a
7096        // surrounding shell context). Pinned to ensure the predicate
7097        // refuses each brace independently rather than only when both
7098        // appear — a future regression that ANDs the two byte tests
7099        // surfaces here.
7100        let d = dep_with_fonte(DepSource::Git {
7101            repo: "https://github.com/pleme-io/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 { reason, .. } = err else {
7108            panic!("expected FonteRepoShape, got other variant");
7109        };
7110        assert!(
7111            reason.contains("must not contain `}`"),
7112            "reason must surface the close-brace `}}` arm, got {reason:?}"
7113        );
7114    }
7115
7116    #[test]
7117    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7118        // Cascade pin: the fragment-`#` arm and the template-`{` /
7119        // `}` arm are both per-byte arms inside the same
7120        // `for &b in s.as_bytes()` loop, so the byte that appears
7121        // first in the value's byte order wins. A `:repo
7122        // "https://github.com/p/x#readme{org}"` carries both `#` and
7123        // `{`; the `#` byte appears first, so the fragment-`#` arm
7124        // fires, surfacing the more self-locating diagnostic on the
7125        // byte the author pasted earliest in the URL. Mirrors the
7126        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7127        // pins on the prior `:repo` byte-class arm.
7128        let d = dep_with_fonte(DepSource::Git {
7129            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7130            tag: Some("v0.1.0".into()),
7131            rev: None,
7132            branch: None,
7133        });
7134        let err = d.validate().unwrap_err();
7135        let DepError::FonteRepoShape { reason, .. } = err else {
7136            panic!("expected FonteRepoShape, got other variant");
7137        };
7138        assert!(
7139            reason.contains("must not contain `#`"),
7140            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7141             `#` byte appears first in value), got {reason:?}"
7142        );
7143    }
7144
7145    #[test]
7146    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7147        // The fail-before-pass-after pin for the canonical
7148        // shell-output-redirection footgun on `:repo`: an author
7149        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7150        // / `… >output.txt`) into the `:repo` slot without trimming
7151        // the redirect. Until this arm landed the value silently
7152        // passed every prior arm (no whitespace, no control chars,
7153        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7154        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7155        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7156        // percent-encode set maps `>` → `%3E` on the wire, so the
7157        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7158        // but is silently rewritten or rejected at libcurl's URL-
7159        // parser layer — two authors whose values differ only in
7160        // their redirect tail (`>build.log` vs nothing) resolve to
7161        // the byte-identical upstream `git clone` but lock to two
7162        // distinct lacres, defeating the THEORY.md §V.2 render-
7163        // determinism contract. Peer with the `:caminho` axis's
7164        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7165        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7166        // byte RFC-3986-reserved set on `:entrada :paths`.
7167        let d = dep_with_fonte(DepSource::Git {
7168            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7169            tag: Some("v0.1.0".into()),
7170            rev: None,
7171            branch: None,
7172        });
7173        let err = d.validate().unwrap_err();
7174        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7175            panic!("expected FonteRepoShape, got other variant");
7176        };
7177        assert_eq!(nome, "caixa-teia");
7178        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7179        assert!(
7180            reason.contains("must not contain `>`"),
7181            "reason must surface the output-redirection `>` arm, got {reason:?}"
7182        );
7183        assert!(
7184            reason.contains("redirection") || reason.contains("'delims'"),
7185            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7186        );
7187    }
7188
7189    #[test]
7190    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7191        // The symmetric shell-input-redirection footgun — an author
7192        // pastes a shell-pipeline head (`git clone <input.url` /
7193        // `cat <README.md`) into the `:repo` slot. Pinned separately
7194        // from the `>`-output arm so a future relaxation that only
7195        // catches one of the two redirect bytes surfaces here. Peer
7196        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7197        // arm which closes both `<` and `>` under the same banner.
7198        let d = dep_with_fonte(DepSource::Git {
7199            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7200            tag: Some("v0.1.0".into()),
7201            rev: None,
7202            branch: None,
7203        });
7204        let err = d.validate().unwrap_err();
7205        let DepError::FonteRepoShape { reason, .. } = err else {
7206            panic!("expected FonteRepoShape, got other variant");
7207        };
7208        assert!(
7209            reason.contains("must not contain `<`"),
7210            "reason must surface the input-redirection `<` arm, got {reason:?}"
7211        );
7212        assert!(
7213            reason.contains("RFC 3986") || reason.contains("'unwise'"),
7214            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7215        );
7216    }
7217
7218    #[test]
7219    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7220        // The fail-before-pass-after pin for the canonical
7221        // paste-from-shell-prompt-with-backticked-substitution footgun
7222        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7223        // `:caminho` path-fonte axis). An author pastes a URL whose
7224        // segment carries a backticked command-substitution wrapper
7225        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7226        // from a doc / README quick-start snippet that expected the
7227        // substrate to substitute the value downstream. Until this arm
7228        // landed the value silently passed every prior arm (no
7229        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7230        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7231        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7232        // 'unwise' set and the WHATWG URL spec's fragment percent-
7233        // encode set maps `` ` `` → `%60` on the wire, so the byte
7234        // rides verbatim into the lacre's per-dep BLAKE3 closure but
7235        // is silently rewritten or rejected at libcurl's URL-parser
7236        // layer — two authors whose values differ only in their
7237        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7238        // byte-identical upstream `git clone` but lock to two distinct
7239        // lacres, defeating the THEORY.md §V.2 render-determinism
7240        // contract. Peer with the `:caminho` axis's
7241        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7242        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7243        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7244        let d = dep_with_fonte(DepSource::Git {
7245            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7246            tag: Some("v0.1.0".into()),
7247            rev: None,
7248            branch: None,
7249        });
7250        let err = d.validate().unwrap_err();
7251        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7252            panic!("expected FonteRepoShape, got other variant");
7253        };
7254        assert_eq!(nome, "caixa-teia");
7255        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7256        assert!(
7257            reason.contains("must not contain `` ` ``"),
7258            "reason must surface the backtick command-substitution arm, got {reason:?}"
7259        );
7260        assert!(
7261            reason.contains("command-substitution") || reason.contains("'unwise'"),
7262            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7263             got {reason:?}"
7264        );
7265    }
7266
7267    #[test]
7268    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7269        // Cascade pin: the fragment-`#` arm and the backtick command-
7270        // substitution arm are both per-byte arms inside the same
7271        // `for &b in s.as_bytes()` loop, so the byte that appears first
7272        // in the value's byte order wins. A `:repo
7273        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7274        // and backtick; the `#` byte appears first, so the fragment-
7275        // `#` arm fires, surfacing the more self-locating diagnostic
7276        // on the byte the author pasted earliest in the URL. Mirrors
7277        // the peer cascade discipline
7278        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7279        // pins on the prior `:repo` byte-class arm.
7280        let d = dep_with_fonte(DepSource::Git {
7281            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7282            tag: Some("v0.1.0".into()),
7283            rev: None,
7284            branch: None,
7285        });
7286        let err = d.validate().unwrap_err();
7287        let DepError::FonteRepoShape { reason, .. } = err else {
7288            panic!("expected FonteRepoShape, got other variant");
7289        };
7290        assert!(
7291            reason.contains("must not contain `#`"),
7292            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7293             appears first in value), got {reason:?}"
7294        );
7295    }
7296
7297    #[test]
7298    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7299        // Cascade pin: the shell-redirection `<` / `>` arm and the
7300        // backtick command-substitution arm are both per-byte arms
7301        // inside the same `for &b in s.as_bytes()` loop, so the byte
7302        // that appears first in the value's byte order wins. A `:repo
7303        // "https://github.com/p/x>build.log/`whoami`"` carries both
7304        // `>` and backtick; the `>` byte appears first, so the
7305        // shell-redirection arm fires, surfacing the more self-
7306        // locating diagnostic on the byte the author pasted earliest
7307        // in the URL. Pins the natural-order cascade so a future
7308        // reorder of the per-byte arms surfaces here.
7309        let d = dep_with_fonte(DepSource::Git {
7310            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7311            tag: Some("v0.1.0".into()),
7312            rev: None,
7313            branch: None,
7314        });
7315        let err = d.validate().unwrap_err();
7316        let DepError::FonteRepoShape { reason, .. } = err else {
7317            panic!("expected FonteRepoShape, got other variant");
7318        };
7319        assert!(
7320            reason.contains("must not contain `>`"),
7321            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7322             `>` byte appears first in value), got {reason:?}"
7323        );
7324    }
7325
7326    #[test]
7327    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7328        // Cascade pin: the fragment-`#` arm and the shell-redirection
7329        // `<` / `>` arm are both per-byte arms inside the same
7330        // `for &b in s.as_bytes()` loop, so the byte that appears
7331        // first in the value's byte order wins. A `:repo
7332        // "https://github.com/p/x#readme>build.log"` carries both
7333        // `#` and `>`; the `#` byte appears first, so the fragment-
7334        // `#` arm fires, surfacing the more self-locating diagnostic
7335        // on the byte the author pasted earliest in the URL. Mirrors
7336        // the peer cascade discipline
7337        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7338        // pins on the prior `:repo` byte-class arm.
7339        let d = dep_with_fonte(DepSource::Git {
7340            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7341            tag: Some("v0.1.0".into()),
7342            rev: None,
7343            branch: None,
7344        });
7345        let err = d.validate().unwrap_err();
7346        let DepError::FonteRepoShape { reason, .. } = err else {
7347            panic!("expected FonteRepoShape, got other variant");
7348        };
7349        assert!(
7350            reason.contains("must not contain `#`"),
7351            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7352             `#` byte appears first in value), got {reason:?}"
7353        );
7354    }
7355
7356    #[test]
7357    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7358        // The fail-before-pass-after pin for the canonical
7359        // paste-from-shell-prompt-with-piped-pipeline footgun on
7360        // `:repo` (peer with the 124106f pipe arm on the sibling
7361        // `:caminho` path-fonte axis). An author pastes a shell
7362        // pipeline (`git clone <url> | tee build.log`,
7363        // `git ls-remote <url> | head`) into the `:repo` slot,
7364        // forgetting to trim the `| <consumer>` tail. Until this arm
7365        // landed the value silently passed every prior arm (no
7366        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7367        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7368        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7369        // 'unwise' set and the WHATWG URL spec's fragment percent-
7370        // encode set maps `|` → `%7C` on the wire, so the byte rides
7371        // verbatim into the lacre's per-dep BLAKE3 closure but is
7372        // silently rewritten or rejected at libcurl's URL-parser
7373        // layer — two authors whose values differ only in their pipe
7374        // tail (`|tee build.log` vs nothing) resolve to the byte-
7375        // identical upstream `git clone` but lock to two distinct
7376        // lacres, defeating the THEORY.md §V.2 render-determinism
7377        // contract. Peer with the `:caminho` axis's
7378        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7379        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7380        // RFC-3986-reserved set on `:entrada :paths`.
7381        let d = dep_with_fonte(DepSource::Git {
7382            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7383            tag: Some("v0.1.0".into()),
7384            rev: None,
7385            branch: None,
7386        });
7387        let err = d.validate().unwrap_err();
7388        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7389            panic!("expected FonteRepoShape, got other variant");
7390        };
7391        assert_eq!(nome, "caixa-teia");
7392        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7393        assert!(
7394            reason.contains("must not contain `|`"),
7395            "reason must surface the shell-pipe arm, got {reason:?}"
7396        );
7397        assert!(
7398            reason.contains("pipe") || reason.contains("'unwise'"),
7399            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7400        );
7401    }
7402
7403    #[test]
7404    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7405        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7406        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7407        // so the byte that appears first in the value's byte order
7408        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7409        // both `#` and `|`; the `#` byte appears first, so the
7410        // fragment-`#` arm fires, surfacing the more self-locating
7411        // diagnostic on the byte the author pasted earliest in the
7412        // URL. Mirrors the peer cascade discipline
7413        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7414        // pins on the prior `:repo` byte-class arm.
7415        let d = dep_with_fonte(DepSource::Git {
7416            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7417            tag: Some("v0.1.0".into()),
7418            rev: None,
7419            branch: None,
7420        });
7421        let err = d.validate().unwrap_err();
7422        let DepError::FonteRepoShape { reason, .. } = err else {
7423            panic!("expected FonteRepoShape, got other variant");
7424        };
7425        assert!(
7426            reason.contains("must not contain `#`"),
7427            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7428             appears first in value), got {reason:?}"
7429        );
7430    }
7431
7432    #[test]
7433    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7434        // Cascade pin: the backtick arm and the pipe arm are both per-
7435        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7436        // the byte that appears first in the value's byte order wins.
7437        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7438        // `` ` `` and `|`; the backtick byte appears first, so the
7439        // backtick arm fires, surfacing the more self-locating
7440        // diagnostic on the byte the author pasted earliest in the
7441        // URL. Pins the natural-order cascade so a future reorder of
7442        // the per-byte arms surfaces here.
7443        let d = dep_with_fonte(DepSource::Git {
7444            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7445            tag: Some("v0.1.0".into()),
7446            rev: None,
7447            branch: None,
7448        });
7449        let err = d.validate().unwrap_err();
7450        let DepError::FonteRepoShape { reason, .. } = err else {
7451            panic!("expected FonteRepoShape, got other variant");
7452        };
7453        assert!(
7454            reason.contains("must not contain `` ` ``"),
7455            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7456             appears first in value), got {reason:?}"
7457        );
7458    }
7459
7460    #[test]
7461    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7462        // The fail-before-pass-after pin for the canonical
7463        // paste-from-shell-prompt-with-sequential-command-tail footgun
7464        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7465        // `:caminho` path-fonte axis). An author pastes a shell
7466        // one-liner that chained a cleanup tail after the URL
7467        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7468        // echo done`) into the `:repo` slot, forgetting to trim the
7469        // `; <cmd>` tail. Until this arm landed the value silently
7470        // passed every prior `is_git_repo_url` arm (no whitespace, no
7471        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7472        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7473        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7474        // reserved set and the WHATWG URL spec's fragment percent-
7475        // encode set maps `;` → `%3B` on the wire, so the byte rides
7476        // verbatim into the lacre's per-dep BLAKE3 closure but is
7477        // silently rewritten at libcurl's URL-parser layer — two
7478        // authors whose values differ only in their sequential-command
7479        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7480        // identical upstream `git clone` but lock to two distinct
7481        // lacres, defeating the THEORY.md §V.2 render-determinism
7482        // contract. Peer with the `:caminho` axis's
7483        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7484        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7485        // byte RFC-3986-reserved set on `:entrada :paths`.
7486        let d = dep_with_fonte(DepSource::Git {
7487            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7488            tag: Some("v0.1.0".into()),
7489            rev: None,
7490            branch: None,
7491        });
7492        let err = d.validate().unwrap_err();
7493        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7494            panic!("expected FonteRepoShape, got other variant");
7495        };
7496        assert_eq!(nome, "caixa-teia");
7497        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7498        assert!(
7499            reason.contains("must not contain `;`"),
7500            "reason must surface the shell-command-separator arm, got {reason:?}"
7501        );
7502        assert!(
7503            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7504            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7505             rationale, got {reason:?}"
7506        );
7507    }
7508
7509    #[test]
7510    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7511        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7512        // both per-byte arms inside the same `for &b in s.as_bytes()`
7513        // loop, so the byte that appears first in the value's byte
7514        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7515        // carries both `#` and `;`; the `#` byte appears first, so the
7516        // fragment-`#` arm fires, surfacing the more self-locating
7517        // diagnostic on the byte the author pasted earliest in the URL.
7518        // Mirrors the peer cascade discipline
7519        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7520        // pins on the prior `:repo` byte-class arm.
7521        let d = dep_with_fonte(DepSource::Git {
7522            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7523            tag: Some("v0.1.0".into()),
7524            rev: None,
7525            branch: None,
7526        });
7527        let err = d.validate().unwrap_err();
7528        let DepError::FonteRepoShape { reason, .. } = err else {
7529            panic!("expected FonteRepoShape, got other variant");
7530        };
7531        assert!(
7532            reason.contains("must not contain `#`"),
7533            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7534             byte appears first in value), got {reason:?}"
7535        );
7536    }
7537
7538    #[test]
7539    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7540        // Cascade pin: the pipe arm and the semicolon arm are both
7541        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7542        // so the byte that appears first in the value's byte order
7543        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7544        // both `|` and `;`; the `|` byte appears first, so the
7545        // pipe arm fires, surfacing the more self-locating diagnostic
7546        // on the byte the author pasted earliest in the URL. Pins the
7547        // natural-order cascade so a future reorder of the per-byte
7548        // arms surfaces here.
7549        let d = dep_with_fonte(DepSource::Git {
7550            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7551            tag: Some("v0.1.0".into()),
7552            rev: None,
7553            branch: None,
7554        });
7555        let err = d.validate().unwrap_err();
7556        let DepError::FonteRepoShape { reason, .. } = err else {
7557            panic!("expected FonteRepoShape, got other variant");
7558        };
7559        assert!(
7560            reason.contains("must not contain `|`"),
7561            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7562             appears first in value), got {reason:?}"
7563        );
7564    }
7565
7566    #[test]
7567    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7568        // The fail-before-pass-after pin for the canonical
7569        // paste-from-shell-prompt-with-background-launch-tail footgun
7570        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7571        // `:caminho` path-fonte axis). An author pastes a shell one-
7572        // liner that detached the clone into the background
7573        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7574        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7575        // `&& <cmd>` tail. Until this arm landed the value silently
7576        // passed every prior `is_git_repo_url` arm (no whitespace,
7577        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7578        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7579        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7580        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7581        // fragment percent-encode set maps `&` → `%26` on the wire,
7582        // so the byte rides verbatim into the lacre's per-dep
7583        // BLAKE3 closure but is silently rewritten at libcurl's
7584        // URL-parser layer — two authors whose values differ only
7585        // in their background-launch tail (`& sleep 1` vs nothing)
7586        // resolve to the byte-identical upstream `git clone` but
7587        // lock to two distinct lacres, defeating the THEORY.md
7588        // §V.2 render-determinism contract. Peer with the
7589        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7590        // (e12e4f3) on the sibling path-fonte axis, and
7591        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7592        // reserved set on `:entrada :paths`.
7593        let d = dep_with_fonte(DepSource::Git {
7594            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7595            tag: Some("v0.1.0".into()),
7596            rev: None,
7597            branch: None,
7598        });
7599        let err = d.validate().unwrap_err();
7600        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7601            panic!("expected FonteRepoShape, got other variant");
7602        };
7603        assert_eq!(nome, "caixa-teia");
7604        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7605        assert!(
7606            reason.contains("must not contain `&`"),
7607            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7608        );
7609        assert!(
7610            reason.contains("background-task") || reason.contains("'sub-delims'"),
7611            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7612             got {reason:?}"
7613        );
7614    }
7615
7616    #[test]
7617    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7618        // The fail-before-pass-after pin for the symmetric `&&`
7619        // logical-AND build-chain paste footgun: an author pastes
7620        // a `git clone <url> && cd <repo>` build-chain one-liner
7621        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7622        // is the same `&` byte twice in a row; the per-byte arm
7623        // fires on the first `&` it sees. Pinned separately from
7624        // the single-`&` background-launch shape so a future
7625        // diagnostic-surface change that special-cased the
7626        // doubled-byte form surfaces here.
7627        let d = dep_with_fonte(DepSource::Git {
7628            repo: "github:pleme-io/caixa-teia&&echo".into(),
7629            tag: Some("v0.1.0".into()),
7630            rev: None,
7631            branch: None,
7632        });
7633        let err = d.validate().unwrap_err();
7634        let DepError::FonteRepoShape { reason, .. } = err else {
7635            panic!("expected FonteRepoShape, got other variant");
7636        };
7637        assert!(
7638            reason.contains("must not contain `&`"),
7639            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7640             shape too, got {reason:?}"
7641        );
7642    }
7643
7644    #[test]
7645    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7646        // Cascade pin: the fragment-`#` arm and the background-`&`
7647        // arm are both per-byte arms inside the same `for &b in
7648        // s.as_bytes()` loop, so the byte that appears first in the
7649        // value's byte order wins. A `:repo
7650        // "https://github.com/p/x#readme & sleep"` carries both `#`
7651        // and `&`; the `#` byte appears first, so the fragment-`#`
7652        // arm fires, surfacing the more self-locating diagnostic on
7653        // the byte the author pasted earliest in the URL. Mirrors
7654        // the peer cascade discipline
7655        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7656        // on the prior `:repo` byte-class arm.
7657        let d = dep_with_fonte(DepSource::Git {
7658            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7659            tag: Some("v0.1.0".into()),
7660            rev: None,
7661            branch: None,
7662        });
7663        let err = d.validate().unwrap_err();
7664        let DepError::FonteRepoShape { reason, .. } = err else {
7665            panic!("expected FonteRepoShape, got other variant");
7666        };
7667        assert!(
7668            reason.contains("must not contain `#`"),
7669            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7670             byte appears first in value), got {reason:?}"
7671        );
7672    }
7673
7674    #[test]
7675    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7676        // Cascade pin: the semicolon arm and the background-`&` arm
7677        // are both per-byte arms inside the same `for &b in
7678        // s.as_bytes()` loop, so the byte that appears first in the
7679        // value's byte order wins. A `:repo
7680        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7681        // `&`; the `;` byte appears first, so the semicolon arm
7682        // fires, surfacing the more self-locating diagnostic on the
7683        // byte the author pasted earliest in the URL. Pins the
7684        // natural-order cascade so a future reorder of the per-byte
7685        // arms surfaces here.
7686        let d = dep_with_fonte(DepSource::Git {
7687            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".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 semicolon arm (fires before background-`&` when `;` \
7699             byte appears first in value), got {reason:?}"
7700        );
7701    }
7702
7703    #[test]
7704    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7705        // The fail-before-pass-after pin for the canonical
7706        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7707        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7708        // `:caminho` path-fonte axis). An author pastes a shell one-
7709        // liner that referenced an environment variable
7710        // (`git clone https://github.com/$ORG/x`, `git clone
7711        // github:$USER/repo`) into the `:repo` slot, forgetting to
7712        // substitute the literal value at author time. Until this arm
7713        // landed the value silently passed every prior
7714        // `is_git_repo_url` arm (no whitespace, no control chars, no
7715        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7716        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7717        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7718        // reserved set and the WHATWG URL spec's fragment percent-
7719        // encode set maps `$` → `%24` on the wire, so the byte rides
7720        // verbatim into the lacre's per-dep BLAKE3 closure but is
7721        // silently rewritten at libcurl's URL-parser layer — two
7722        // authors whose values differ only in their `$VAR` /
7723        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7724        // identical upstream `git clone` but lock to two distinct
7725        // lacres, defeating the THEORY.md §V.2 render-determinism
7726        // contract. Beyond determinism, the value is a structural
7727        // host-layout leak: two authors with the same `:repo` slot
7728        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7729        // different upstreams. Peer with the `:caminho` axis's
7730        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7731        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7732        // byte RFC-3986-reserved set on `:entrada :paths`.
7733        let d = dep_with_fonte(DepSource::Git {
7734            repo: "https://github.com/$ORG/caixa-teia".into(),
7735            tag: Some("v0.1.0".into()),
7736            rev: None,
7737            branch: None,
7738        });
7739        let err = d.validate().unwrap_err();
7740        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7741            panic!("expected FonteRepoShape, got other variant");
7742        };
7743        assert_eq!(nome, "caixa-teia");
7744        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7745        assert!(
7746            reason.contains("must not contain `$`"),
7747            "reason must surface the shell-variable-expansion arm, got {reason:?}"
7748        );
7749        assert!(
7750            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7751            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7752             rationale, got {reason:?}"
7753        );
7754    }
7755
7756    #[test]
7757    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7758        // The fail-before-pass-after pin for the symmetric POSIX-
7759        // shell braced `${VAR}` expansion paste footgun: an author
7760        // pastes a CI-manifest line `git clone
7761        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7762        // Actions / GitLab CI / Drone shape) and forgets to
7763        // substitute the literal value. The `${...}` shape is the
7764        // same `$` byte at the leading position of the expansion;
7765        // the per-byte arm fires on the `$`. Pinned separately from
7766        // the bare-`$VAR` shape so a future diagnostic-surface
7767        // change that special-cased the braced form surfaces here.
7768        let d = dep_with_fonte(DepSource::Git {
7769            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7770            tag: Some("v0.1.0".into()),
7771            rev: None,
7772            branch: None,
7773        });
7774        let err = d.validate().unwrap_err();
7775        let DepError::FonteRepoShape { reason, .. } = err else {
7776            panic!("expected FonteRepoShape, got other variant");
7777        };
7778        assert!(
7779            reason.contains("must not contain `$`"),
7780            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7781             shape too, got {reason:?}"
7782        );
7783    }
7784
7785    #[test]
7786    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7787        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7788        // arm are both per-byte arms inside the same `for &b in
7789        // s.as_bytes()` loop, so the byte that appears first in the
7790        // value's byte order wins. A `:repo
7791        // "https://github.com/p/x#readme$HOME"` carries both `#` and
7792        // `$`; the `#` byte appears first, so the fragment-`#` arm
7793        // fires, surfacing the more self-locating diagnostic on the
7794        // byte the author pasted earliest in the URL. Mirrors the
7795        // peer cascade discipline
7796        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7797        // on the prior `:repo` byte-class arm.
7798        let d = dep_with_fonte(DepSource::Git {
7799            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7800            tag: Some("v0.1.0".into()),
7801            rev: None,
7802            branch: None,
7803        });
7804        let err = d.validate().unwrap_err();
7805        let DepError::FonteRepoShape { reason, .. } = err else {
7806            panic!("expected FonteRepoShape, got other variant");
7807        };
7808        assert!(
7809            reason.contains("must not contain `#`"),
7810            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7811             `#` byte appears first in value), got {reason:?}"
7812        );
7813    }
7814
7815    #[test]
7816    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7817        // Cascade pin: the background-`&` arm and the
7818        // var-expansion-`$` arm are both per-byte arms inside the
7819        // same `for &b in s.as_bytes()` loop, so the byte that
7820        // appears first in the value's byte order wins. A `:repo
7821        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7822        // `$`; the `&` byte appears first, so the background arm
7823        // fires, surfacing the more self-locating diagnostic on the
7824        // byte the author pasted earliest in the URL. Pins the
7825        // natural-order cascade so a future reorder of the per-byte
7826        // arms surfaces here — `$` is the most recent byte-class arm,
7827        // so the cascade-pin sweep extends to cover every immediately
7828        // prior byte arm (`#`, `&`) firing first when ordered ahead
7829        // of `$` in the value.
7830        let d = dep_with_fonte(DepSource::Git {
7831            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7832            tag: Some("v0.1.0".into()),
7833            rev: None,
7834            branch: None,
7835        });
7836        let err = d.validate().unwrap_err();
7837        let DepError::FonteRepoShape { reason, .. } = err else {
7838            panic!("expected FonteRepoShape, got other variant");
7839        };
7840        assert!(
7841            reason.contains("must not contain `&`"),
7842            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7843             `&` byte appears first in value), got {reason:?}"
7844        );
7845    }
7846
7847    #[test]
7848    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7849        // The fail-before-pass-after pin for the canonical
7850        // paste-from-shell-prompt glob footgun on `:repo` (peer with
7851        // the cf9034b `*` / `?` arm on the sibling `:caminho`
7852        // path-fonte axis). An author pastes a shell one-liner that
7853        // referenced a glob expansion (`ls
7854        // github.com/pleme-io/caixa-*`, `git clone
7855        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7856        // to substitute the literal repo name. Until this arm landed
7857        // the `*` byte silently passed every prior `is_git_repo_url`
7858        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7859        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7860        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7861        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7862        // the WHATWG URL spec's special-query percent-encode set maps
7863        // `*` → `%2A` on the wire, so the byte rides verbatim into
7864        // the lacre's per-dep BLAKE3 closure but is silently
7865        // rewritten at libcurl's URL-parser layer — two authors
7866        // whose values differ only in their asterisk presence
7867        // resolve to the byte-identical upstream `git clone` but
7868        // lock to two distinct lacres, defeating the THEORY.md §V.2
7869        // render-determinism contract. Peer with the `:caminho`
7870        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7871        // sibling path-fonte axis, and the `is_git_ref_name`
7872        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7873        // axes.
7874        let d = dep_with_fonte(DepSource::Git {
7875            repo: "https://github.com/pleme-io/caixa-*".into(),
7876            tag: Some("v0.1.0".into()),
7877            rev: None,
7878            branch: None,
7879        });
7880        let err = d.validate().unwrap_err();
7881        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7882            panic!("expected FonteRepoShape, got other variant");
7883        };
7884        assert_eq!(nome, "caixa-teia");
7885        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7886        assert!(
7887            reason.contains("must not contain `*`"),
7888            "reason must surface the shell-glob arm, got {reason:?}"
7889        );
7890        assert!(
7891            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7892            "reason must name the shell-glob / pathname-expansion / \
7893             RFC-3986-sub-delims rationale, got {reason:?}"
7894        );
7895    }
7896
7897    #[test]
7898    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7899        // The fail-before-pass-after pin for the symmetric bash
7900        // `globstar` recursive-glob paste footgun: an author pastes
7901        // a `ls github.com/pleme-io/**/x` (the canonical
7902        // `globstar`-shopt-enabled recursive-listing tail) into the
7903        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7904        // the per-byte arm fires on the first `*`. Pinned
7905        // separately from the single-`*` shape so a future
7906        // diagnostic-surface change that special-cased the
7907        // double-`*` form surfaces here.
7908        let d = dep_with_fonte(DepSource::Git {
7909            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7910            tag: Some("v0.1.0".into()),
7911            rev: None,
7912            branch: None,
7913        });
7914        let err = d.validate().unwrap_err();
7915        let DepError::FonteRepoShape { reason, .. } = err else {
7916            panic!("expected FonteRepoShape, got other variant");
7917        };
7918        assert!(
7919            reason.contains("must not contain `*`"),
7920            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7921             got {reason:?}"
7922        );
7923    }
7924
7925    #[test]
7926    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7927        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7928        // both per-byte arms inside the same `for &b in s.as_bytes()`
7929        // loop, so the byte that appears first in the value's byte
7930        // order wins. A `:repo
7931        // "https://github.com/p/x#readme*tail"` carries both `#` and
7932        // `*`; the `#` byte appears first, so the fragment-`#` arm
7933        // fires, surfacing the more self-locating diagnostic on the
7934        // byte the author pasted earliest in the URL. Mirrors the
7935        // peer cascade discipline
7936        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7937        // on the prior `:repo` byte-class arm.
7938        let d = dep_with_fonte(DepSource::Git {
7939            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7940            tag: Some("v0.1.0".into()),
7941            rev: None,
7942            branch: None,
7943        });
7944        let err = d.validate().unwrap_err();
7945        let DepError::FonteRepoShape { reason, .. } = err else {
7946            panic!("expected FonteRepoShape, got other variant");
7947        };
7948        assert!(
7949            reason.contains("must not contain `#`"),
7950            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7951             appears first in value), got {reason:?}"
7952        );
7953    }
7954
7955    #[test]
7956    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7957        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7958        // arm are both per-byte arms inside the same `for &b in
7959        // s.as_bytes()` loop, so the byte that appears first in the
7960        // value's byte order wins. A `:repo
7961        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7962        // the `$` byte appears first, so the var-expansion arm
7963        // fires, surfacing the more self-locating diagnostic on the
7964        // byte the author pasted earliest in the URL. Pins the
7965        // natural-order cascade so a future reorder of the per-byte
7966        // arms surfaces here — `*` is the most recent byte-class
7967        // arm, so the cascade-pin sweep extends to cover the
7968        // immediately prior `$` byte arm firing first when ordered
7969        // ahead of `*` in the value.
7970        let d = dep_with_fonte(DepSource::Git {
7971            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7972            tag: Some("v0.1.0".into()),
7973            rev: None,
7974            branch: None,
7975        });
7976        let err = d.validate().unwrap_err();
7977        let DepError::FonteRepoShape { reason, .. } = err else {
7978            panic!("expected FonteRepoShape, got other variant");
7979        };
7980        assert!(
7981            reason.contains("must not contain `$`"),
7982            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7983             byte appears first in value), got {reason:?}"
7984        );
7985    }
7986
7987    #[test]
7988    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7989        // The fail-before-pass-after pin for the canonical paste-from-
7990        // shell-prompt subshell-grouping footgun on `:repo`. An author
7991        // pastes a doc / README snippet carrying a regex-alternation
7992        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7993        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7994        // `:repo` slot, forgetting to substitute one literal org name.
7995        // Until this arm landed the `(` byte silently passed every
7996        // prior `is_git_repo_url` arm (no whitespace, no control
7997        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7998        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7999        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8000        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8001        // URL spec's special-query percent-encode set maps `(` →
8002        // `%28` and `)` → `%29` on the wire, so the byte rides
8003        // verbatim into the lacre's per-dep BLAKE3 closure but is
8004        // silently rewritten at libcurl's URL-parser layer —
8005        // defeating the THEORY.md §V.2 render-determinism contract on
8006        // the same axis the prior twelve byte-class arms close.
8007        let d = dep_with_fonte(DepSource::Git {
8008            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8009            tag: Some("v0.1.0".into()),
8010            rev: None,
8011            branch: None,
8012        });
8013        let err = d.validate().unwrap_err();
8014        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8015            panic!("expected FonteRepoShape, got other variant");
8016        };
8017        assert_eq!(nome, "caixa-teia");
8018        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8019        assert!(
8020            reason.contains("must not contain `(`"),
8021            "reason must surface the subshell-open-paren arm, got {reason:?}"
8022        );
8023        assert!(
8024            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8025            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8026             got {reason:?}"
8027        );
8028    }
8029
8030    #[test]
8031    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8032        // The symmetric arm pin on the closing `)` byte: an author
8033        // pastes a `$(date)` command-substitution wrapper or a
8034        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8035        // Pinned separately from the opening `(` shape so a future
8036        // diagnostic-surface change that only checked one boundary
8037        // surfaces here. The `(` byte appears earlier in the
8038        // canonical regex / subshell wrapper so the per-byte loop
8039        // fires on `(` first; this test exercises a `:repo` value
8040        // carrying only the closing `)` byte (no opening paren) so
8041        // the `)` arm fires directly — pinning the byte-class arm
8042        // independent of order.
8043        let d = dep_with_fonte(DepSource::Git {
8044            repo: "github:pleme-io/caixa-teia)tail".into(),
8045            tag: Some("v0.1.0".into()),
8046            rev: None,
8047            branch: None,
8048        });
8049        let err = d.validate().unwrap_err();
8050        let DepError::FonteRepoShape { reason, .. } = err else {
8051            panic!("expected FonteRepoShape, got other variant");
8052        };
8053        assert!(
8054            reason.contains("must not contain `)`"),
8055            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8056             got {reason:?}"
8057        );
8058    }
8059
8060    #[test]
8061    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8062        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8063        // are both per-byte arms inside the same `for &b in
8064        // s.as_bytes()` loop, so the byte that appears first in the
8065        // value's byte order wins. A `:repo
8066        // "https://github.com/p/x#readme(tail)"` carries both `#` and
8067        // `(`; the `#` byte appears first, so the fragment-`#` arm
8068        // fires, surfacing the more self-locating diagnostic on the
8069        // byte the author pasted earliest in the URL. Mirrors the
8070        // peer cascade discipline
8071        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8072        // on the prior `:repo` byte-class arm.
8073        let d = dep_with_fonte(DepSource::Git {
8074            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8075            tag: Some("v0.1.0".into()),
8076            rev: None,
8077            branch: None,
8078        });
8079        let err = d.validate().unwrap_err();
8080        let DepError::FonteRepoShape { reason, .. } = err else {
8081            panic!("expected FonteRepoShape, got other variant");
8082        };
8083        assert!(
8084            reason.contains("must not contain `#`"),
8085            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8086             byte appears first in value), got {reason:?}"
8087        );
8088    }
8089
8090    #[test]
8091    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8092        // Cascade pin: the glob-`*` arm (the immediate-predecessor
8093        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8094        // per-byte arms inside the same `for &b in s.as_bytes()`
8095        // loop, so the byte that appears first in the value's byte
8096        // order wins. A `:repo
8097        // "https://github.com/p/x-*-(date)"` carries both `*` and
8098        // `(`; the `*` byte appears first, so the glob arm fires,
8099        // surfacing the more self-locating diagnostic on the byte
8100        // the author pasted earliest in the URL. Pins the natural-
8101        // order cascade so a future reorder of the per-byte arms
8102        // surfaces here — `(` is the most recent byte-class arm,
8103        // so the cascade-pin sweep extends to cover the immediately
8104        // prior `*` byte arm firing first when ordered ahead of `(`
8105        // in the value.
8106        let d = dep_with_fonte(DepSource::Git {
8107            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8108            tag: Some("v0.1.0".into()),
8109            rev: None,
8110            branch: None,
8111        });
8112        let err = d.validate().unwrap_err();
8113        let DepError::FonteRepoShape { reason, .. } = err else {
8114            panic!("expected FonteRepoShape, got other variant");
8115        };
8116        assert!(
8117            reason.contains("must not contain `*`"),
8118            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8119             appears first in value), got {reason:?}"
8120        );
8121    }
8122
8123    #[test]
8124    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8125        // The fail-before-pass-after pin for the canonical paste-from-
8126        // doc-shell-quoting footgun on `:repo`. An author copies a
8127        // README quick-start snippet (`$ git clone "https://github.com/
8128        // foo/bar"`) and keeps the surrounding double-quote bytes when
8129        // pasting into the `:repo` slot — the doc wraps the URL in
8130        // double quotes so the shell doesn't re-lex metachars inside,
8131        // but the typed slot is itself a byte-level string parser, not
8132        // a shell context, so the quote bytes ride into the value
8133        // verbatim. Until this arm landed the `"` byte silently passed
8134        // every prior `is_git_repo_url` arm (no whitespace, no control
8135        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8136        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8137        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8138        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8139        // `` ` ``) every URL parser is required to refuse or percent-
8140        // encode, and the WHATWG URL spec's 'C0 control percent-encode
8141        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8142        // into the lacre's per-dep BLAKE3 closure but is silently
8143        // rewritten at libcurl's URL-parser layer, defeating the
8144        // THEORY.md §V.2 render-determinism contract.
8145        let d = dep_with_fonte(DepSource::Git {
8146            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8147            tag: Some("v0.1.0".into()),
8148            rev: None,
8149            branch: None,
8150        });
8151        let err = d.validate().unwrap_err();
8152        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8153            panic!("expected FonteRepoShape, got other variant");
8154        };
8155        assert_eq!(nome, "caixa-teia");
8156        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8157        assert!(
8158            reason.contains("must not contain `\"`"),
8159            "reason must surface the shell-double-quote arm, got {reason:?}"
8160        );
8161        assert!(
8162            reason.contains("double-quote") || reason.contains("'delims'"),
8163            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8164             got {reason:?}"
8165        );
8166    }
8167
8168    #[test]
8169    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8170        // The symmetric stray-quote tail pin: an author pastes only a
8171        // closing `"` from a shell-history line like `git clone
8172        // "https://github.com/foo/bar" && cd …` (the trim went too
8173        // far in one direction but not the other) into the `:repo`
8174        // slot. Pinned separately from the wrapped-quote shape so a
8175        // future diagnostic-surface change that only checked one
8176        // boundary (only leading, only trailing, only paired) surfaces
8177        // here — the per-byte arm fires anywhere `"` appears.
8178        let d = dep_with_fonte(DepSource::Git {
8179            repo: "github:pleme-io/caixa-teia\"".into(),
8180            tag: Some("v0.1.0".into()),
8181            rev: None,
8182            branch: None,
8183        });
8184        let err = d.validate().unwrap_err();
8185        let DepError::FonteRepoShape { reason, .. } = err else {
8186            panic!("expected FonteRepoShape, got other variant");
8187        };
8188        assert!(
8189            reason.contains("must not contain `\"`"),
8190            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8191             got {reason:?}"
8192        );
8193    }
8194
8195    #[test]
8196    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8197        // Cascade pin: the fragment-`#` arm and the double-quote arm
8198        // are both per-byte arms inside the same `for &b in
8199        // s.as_bytes()` loop, so the byte that appears first in the
8200        // value's byte order wins. A `:repo
8201        // "https://github.com/p/x#readme\"tail"` carries both `#` and
8202        // `"`; the `#` byte appears first, so the fragment-`#` arm
8203        // fires, surfacing the more self-locating diagnostic on the
8204        // byte the author pasted earliest in the URL.
8205        let d = dep_with_fonte(DepSource::Git {
8206            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8207            tag: Some("v0.1.0".into()),
8208            rev: None,
8209            branch: None,
8210        });
8211        let err = d.validate().unwrap_err();
8212        let DepError::FonteRepoShape { reason, .. } = err else {
8213            panic!("expected FonteRepoShape, got other variant");
8214        };
8215        assert!(
8216            reason.contains("must not contain `#`"),
8217            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8218             byte appears first in value), got {reason:?}"
8219        );
8220    }
8221
8222    #[test]
8223    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8224        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8225        // byte-class arm, 3b99147) and the double-quote arm are both
8226        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8227        // so the byte that appears first in the value's byte order
8228        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8229        // and `"`; the `(` byte appears first, so the subshell arm
8230        // fires, surfacing the more self-locating diagnostic on the
8231        // byte the author pasted earliest in the URL. Pins the natural-
8232        // order cascade so a future reorder of the per-byte arms
8233        // surfaces here — `"` is the most recent byte-class arm, so
8234        // the cascade-pin sweep extends to cover the immediately prior
8235        // `(` byte arm firing first when ordered ahead of `"` in the
8236        // value.
8237        let d = dep_with_fonte(DepSource::Git {
8238            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8239            tag: Some("v0.1.0".into()),
8240            rev: None,
8241            branch: None,
8242        });
8243        let err = d.validate().unwrap_err();
8244        let DepError::FonteRepoShape { reason, .. } = err else {
8245            panic!("expected FonteRepoShape, got other variant");
8246        };
8247        assert!(
8248            reason.contains("must not contain `(`"),
8249            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8250             byte appears first in value), got {reason:?}"
8251        );
8252    }
8253
8254    #[test]
8255    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8256        // The fail-before-pass-after pin for the canonical paste-from-
8257        // doc-strong-quoting footgun on `:repo`. An author copies a
8258        // security-conscious README quick-start snippet (`$ git clone
8259        // 'https://github.com/foo/bar'`) and keeps the surrounding
8260        // single-quote bytes when pasting into the `:repo` slot — the
8261        // doc strong-quotes the URL so the shell suppresses every form
8262        // of expansion on the bytes inside (no `$`, no backtick, no
8263        // glob, no word-splitting), but the typed slot is itself a
8264        // byte-level string parser, not a shell context, so the quote
8265        // bytes ride into the value verbatim. Until this arm landed the
8266        // `'` byte silently passed every prior `is_git_repo_url` arm
8267        // (no whitespace, no control chars, no non-ASCII, no `#`, no
8268        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8269        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8270        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8271        // set, peer with the `\"` 'delims' double-quote arm and the
8272        // partner ASCII shell-string-delimiter byte every byte-level
8273        // string parser sharing a value-shape with a shell argument
8274        // must refuse on a URL-shaped slot.
8275        let d = dep_with_fonte(DepSource::Git {
8276            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8277            tag: Some("v0.1.0".into()),
8278            rev: None,
8279            branch: None,
8280        });
8281        let err = d.validate().unwrap_err();
8282        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8283            panic!("expected FonteRepoShape, got other variant");
8284        };
8285        assert_eq!(nome, "caixa-teia");
8286        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8287        assert!(
8288            reason.contains("must not contain `'`"),
8289            "reason must surface the shell-single-quote arm, got {reason:?}"
8290        );
8291        assert!(
8292            reason.contains("single-quote") || reason.contains("strong-quote"),
8293            "reason must name the shell-single-quote / strong-quote rationale, \
8294             got {reason:?}"
8295        );
8296    }
8297
8298    #[test]
8299    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8300        // The symmetric English-typography pin: an author writes
8301        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8302        // from-prose idiom every README / commit-message / chat-thread
8303        // reference to a repo carries) expecting the substrate to
8304        // coerce it to a kebab-case slug — but the byte rides into the
8305        // lacre verbatim. Pinned separately from the wrapped-quote
8306        // shape so a future diagnostic-surface change that only checked
8307        // the boundary positions (only leading, only trailing, only
8308        // paired) surfaces here — the per-byte arm fires anywhere `'`
8309        // appears in the value.
8310        let d = dep_with_fonte(DepSource::Git {
8311            repo: "github:pleme-io/repo's-fork".into(),
8312            tag: Some("v0.1.0".into()),
8313            rev: None,
8314            branch: None,
8315        });
8316        let err = d.validate().unwrap_err();
8317        let DepError::FonteRepoShape { reason, .. } = err else {
8318            panic!("expected FonteRepoShape, got other variant");
8319        };
8320        assert!(
8321            reason.contains("must not contain `'`"),
8322            "reason must surface the shell-single-quote arm on the mid-string \
8323             apostrophe shape, got {reason:?}"
8324        );
8325    }
8326
8327    #[test]
8328    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8329        // Cascade pin: the fragment-`#` arm and the single-quote arm
8330        // are both per-byte arms inside the same `for &b in
8331        // s.as_bytes()` loop, so the byte that appears first in the
8332        // value's byte order wins. A `:repo
8333        // "https://github.com/p/x#readme'tail"` carries both `#` and
8334        // `'`; the `#` byte appears first, so the fragment-`#` arm
8335        // fires, surfacing the more self-locating diagnostic on the
8336        // byte the author pasted earliest in the URL.
8337        let d = dep_with_fonte(DepSource::Git {
8338            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8339            tag: Some("v0.1.0".into()),
8340            rev: None,
8341            branch: None,
8342        });
8343        let err = d.validate().unwrap_err();
8344        let DepError::FonteRepoShape { reason, .. } = err else {
8345            panic!("expected FonteRepoShape, got other variant");
8346        };
8347        assert!(
8348            reason.contains("must not contain `#`"),
8349            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8350             byte appears first in value), got {reason:?}"
8351        );
8352    }
8353
8354    #[test]
8355    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8356        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8357        // byte-class arm, 4267d8b) and the single-quote arm are both
8358        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8359        // so the byte that appears first in the value's byte order
8360        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8361        // `'`; the `"` byte appears first, so the double-quote arm
8362        // fires, surfacing the more self-locating diagnostic on the
8363        // byte the author pasted earliest in the URL. Pins the natural-
8364        // order cascade so a future reorder of the per-byte arms
8365        // surfaces here — `'` is the most recent byte-class arm, so
8366        // the cascade-pin sweep extends to cover the immediately prior
8367        // `"` byte arm firing first when ordered ahead of `'` in the
8368        // value.
8369        let d = dep_with_fonte(DepSource::Git {
8370            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8371            tag: Some("v0.1.0".into()),
8372            rev: None,
8373            branch: None,
8374        });
8375        let err = d.validate().unwrap_err();
8376        let DepError::FonteRepoShape { reason, .. } = err else {
8377            panic!("expected FonteRepoShape, got other variant");
8378        };
8379        assert!(
8380            reason.contains("must not contain `\"`"),
8381            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8382             byte appears first in value), got {reason:?}"
8383        );
8384    }
8385
8386    #[test]
8387    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8388        // The fail-before-pass-after pin for the canonical paste-from-
8389        // shell-history footgun on `:repo`. An author copies a `git
8390        // clone <url>!sudo make install` one-liner from a README's
8391        // quick-start snippet, intending the trailing `!sudo` as a
8392        // shell-history-expansion reference but the typed slot is itself
8393        // a byte-level string parser, not a shell context, so the byte
8394        // rides into the value verbatim. Until this arm landed the `!`
8395        // byte silently passed every prior `is_git_repo_url` arm (no
8396        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8397        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8398        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8399        // start with `-` or `:`); bash with the default `histexpand`
8400        // mode rewrites `!command` to the most recent history entry
8401        // beginning with `command`, the canonical RCE-class injection
8402        // vector when the byte rides into a shell argument.
8403        let d = dep_with_fonte(DepSource::Git {
8404            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8405            tag: Some("v0.1.0".into()),
8406            rev: None,
8407            branch: None,
8408        });
8409        let err = d.validate().unwrap_err();
8410        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8411            panic!("expected FonteRepoShape, got other variant");
8412        };
8413        assert_eq!(nome, "caixa-teia");
8414        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8415        assert!(
8416            reason.contains("must not contain `!`"),
8417            "reason must surface the shell-history-expansion arm, got {reason:?}"
8418        );
8419        assert!(
8420            reason.contains("history-expansion") || reason.contains("bang"),
8421            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8422        );
8423    }
8424
8425    #[test]
8426    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8427        // The symmetric `!!` repeat-prior-command pin: an author paste-
8428        // trims a `git clone <url>` retry idiom from shell history that
8429        // expands to the previous command via `!!`. Pinned separately
8430        // from the wrapped `!command` shape so a future diagnostic-
8431        // surface change that only checked the leading or paired-bang
8432        // position surfaces here — the per-byte arm fires anywhere `!`
8433        // appears in the value.
8434        let d = dep_with_fonte(DepSource::Git {
8435            repo: "github:pleme-io/caixa-teia!!".into(),
8436            tag: Some("v0.1.0".into()),
8437            rev: None,
8438            branch: None,
8439        });
8440        let err = d.validate().unwrap_err();
8441        let DepError::FonteRepoShape { reason, .. } = err else {
8442            panic!("expected FonteRepoShape, got other variant");
8443        };
8444        assert!(
8445            reason.contains("must not contain `!`"),
8446            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8447             got {reason:?}"
8448        );
8449    }
8450
8451    #[test]
8452    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8453        // Cascade pin: the fragment-`#` arm and the bang arm are both
8454        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8455        // so the byte that appears first in the value's byte order
8456        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8457        // both `#` and `!`; the `#` byte appears first, so the
8458        // fragment-`#` arm fires, surfacing the more self-locating
8459        // diagnostic on the byte the author pasted earliest in the URL.
8460        let d = dep_with_fonte(DepSource::Git {
8461            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8462            tag: Some("v0.1.0".into()),
8463            rev: None,
8464            branch: None,
8465        });
8466        let err = d.validate().unwrap_err();
8467        let DepError::FonteRepoShape { reason, .. } = err else {
8468            panic!("expected FonteRepoShape, got other variant");
8469        };
8470        assert!(
8471            reason.contains("must not contain `#`"),
8472            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8473             appears first in value), got {reason:?}"
8474        );
8475    }
8476
8477    #[test]
8478    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8479        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8480        // byte-class arm, e7a109f) and the bang arm are both per-byte
8481        // arms inside the same `for &b in s.as_bytes()` loop, so the
8482        // byte that appears first in the value's byte order wins. A
8483        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8484        // `'` byte appears first, so the single-quote arm fires,
8485        // surfacing the more self-locating diagnostic on the byte the
8486        // author pasted earliest in the URL. Pins the natural-order
8487        // cascade so a future reorder of the per-byte arms surfaces
8488        // here — `!` is the most recent byte-class arm, so the
8489        // cascade-pin sweep extends to cover the immediately prior `'`
8490        // byte arm firing first when ordered ahead of `!` in the value.
8491        let d = dep_with_fonte(DepSource::Git {
8492            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8493            tag: Some("v0.1.0".into()),
8494            rev: None,
8495            branch: None,
8496        });
8497        let err = d.validate().unwrap_err();
8498        let DepError::FonteRepoShape { reason, .. } = err else {
8499            panic!("expected FonteRepoShape, got other variant");
8500        };
8501        assert!(
8502            reason.contains("must not contain `'`"),
8503            "reason must surface the single-quote arm (fires before bang when `'` byte \
8504             appears first in value), got {reason:?}"
8505        );
8506    }
8507
8508    #[test]
8509    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8510        // The fail-before-pass-after pin for the canonical
8511        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8512        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8513        // one-liner from a multi-repo bootstrap doc, intending the
8514        // comma to separate multiple repo entries but the typed
8515        // `:repo` slot names *one* repo (the list-separator belongs
8516        // to the `:deps` list grammar, not to the value). Until this
8517        // arm landed the `,` byte silently passed every prior
8518        // `is_git_repo_url` arm (no whitespace, no control chars, no
8519        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8520        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8521        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8522        // `:`); the byte rode into the lacre's per-dep content-
8523        // address and the resolver's `git clone <repo>` subprocess
8524        // invocation, where no host's repo registry resolved the
8525        // comma-bearing slug.
8526        let d = dep_with_fonte(DepSource::Git {
8527            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8528            tag: Some("v0.1.0".into()),
8529            rev: None,
8530            branch: None,
8531        });
8532        let err = d.validate().unwrap_err();
8533        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8534            panic!("expected FonteRepoShape, got other variant");
8535        };
8536        assert_eq!(nome, "caixa-teia");
8537        assert_eq!(
8538            repo,
8539            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8540        );
8541        assert!(
8542            reason.contains("must not contain `,`"),
8543            "reason must surface the list-separator-comma arm, got {reason:?}"
8544        );
8545        assert!(
8546            reason.contains("list-separator") || reason.contains("sub-delims"),
8547            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8548             got {reason:?}"
8549        );
8550    }
8551
8552    #[test]
8553    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8554        // The symmetric trailing-`,` paste-from-prose pin: an author
8555        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8556        // comma every README-prose list-of-projects sentence carries,
8557        // mistakenly retained when the slug is pasted mid-sentence)
8558        // expecting the substrate to coerce it to a kebab-case slug.
8559        // Pinned separately from the wrapped mid-token shape so a
8560        // future diagnostic-surface change that only checked the
8561        // leading or paired-comma position surfaces here — the
8562        // per-byte arm fires anywhere `,` appears in the value.
8563        let d = dep_with_fonte(DepSource::Git {
8564            repo: "github:pleme-io/caixa-feira,".into(),
8565            tag: Some("v0.1.0".into()),
8566            rev: None,
8567            branch: None,
8568        });
8569        let err = d.validate().unwrap_err();
8570        let DepError::FonteRepoShape { reason, .. } = err else {
8571            panic!("expected FonteRepoShape, got other variant");
8572        };
8573        assert!(
8574            reason.contains("must not contain `,`"),
8575            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8576             got {reason:?}"
8577        );
8578    }
8579
8580    #[test]
8581    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8582        // Cascade pin: the fragment-`#` arm and the comma arm are
8583        // both per-byte arms inside the same `for &b in s.as_bytes()`
8584        // loop, so the byte that appears first in the value's byte
8585        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8586        // carries both `#` and `,`; the `#` byte appears first, so
8587        // the fragment-`#` arm fires, surfacing the more self-
8588        // locating diagnostic on the byte the author pasted earliest
8589        // in the URL.
8590        let d = dep_with_fonte(DepSource::Git {
8591            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8592            tag: Some("v0.1.0".into()),
8593            rev: None,
8594            branch: None,
8595        });
8596        let err = d.validate().unwrap_err();
8597        let DepError::FonteRepoShape { reason, .. } = err else {
8598            panic!("expected FonteRepoShape, got other variant");
8599        };
8600        assert!(
8601            reason.contains("must not contain `#`"),
8602            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8603             appears first in value), got {reason:?}"
8604        );
8605    }
8606
8607    #[test]
8608    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8609        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8610        // byte-class arm, 7d53c68) and the comma arm are both
8611        // per-byte arms inside the same `for &b in s.as_bytes()`
8612        // loop, so the byte that appears first in the value's byte
8613        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8614        // `!` and `,`; the `!` byte appears first, so the bang arm
8615        // fires, surfacing the more self-locating diagnostic on the
8616        // byte the author pasted earliest in the URL. Pins the
8617        // natural-order cascade so a future reorder of the per-byte
8618        // arms surfaces here — `,` is the most recent byte-class
8619        // arm, so the cascade-pin sweep extends to cover the
8620        // immediately prior `!` byte arm firing first when ordered
8621        // ahead of `,` in the value.
8622        let d = dep_with_fonte(DepSource::Git {
8623            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8624            tag: Some("v0.1.0".into()),
8625            rev: None,
8626            branch: None,
8627        });
8628        let err = d.validate().unwrap_err();
8629        let DepError::FonteRepoShape { reason, .. } = err else {
8630            panic!("expected FonteRepoShape, got other variant");
8631        };
8632        assert!(
8633            reason.contains("must not contain `!`"),
8634            "reason must surface the bang arm (fires before comma when `!` byte \
8635             appears first in value), got {reason:?}"
8636        );
8637    }
8638
8639    #[test]
8640    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8641        // The fail-before-pass-after pin for the canonical
8642        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8643        // on `:repo`. An author copies
8644        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8645        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8646        // git clone <url>`, etc. — the canonical
8647        // git-troubleshooting README idiom for a one-shot env-var
8648        // scoped to the `git clone` invocation) from a shell-prompt
8649        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8650        // grammar env-var assignment but the typed `:repo` slot is
8651        // a value parser, not a shell context, so the bytes ride
8652        // into the value verbatim. Until this arm landed the `=`
8653        // byte silently passed every prior `is_git_repo_url` arm
8654        // (no whitespace, no control chars, no non-ASCII, no `#`,
8655        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8656        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8657        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8658        // the byte rode into the lacre's per-dep content-address
8659        // and the resolver's `git clone <repo>` subprocess
8660        // invocation, where the upstream host's git porcelain
8661        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8662        // path that no host's repo registry resolves.
8663        let d = dep_with_fonte(DepSource::Git {
8664            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8665            tag: Some("v0.1.0".into()),
8666            rev: None,
8667            branch: None,
8668        });
8669        let err = d.validate().unwrap_err();
8670        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8671            panic!("expected FonteRepoShape, got other variant");
8672        };
8673        assert_eq!(nome, "caixa-teia");
8674        assert_eq!(
8675            repo,
8676            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8677        );
8678        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8679        // appears before the ` ` byte at position 21, so the `=`
8680        // arm fires (not the whitespace arm) — both arms guard
8681        // the slot, but the per-byte for-loop scans left-to-right
8682        // and the first matching byte wins.
8683        assert!(
8684            reason.contains("must not contain `=`"),
8685            "reason must surface the equals-`=` arm on the env-var-assignment \
8686             paste shape, got {reason:?}"
8687        );
8688        assert!(
8689            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8690            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8691        );
8692    }
8693
8694    #[test]
8695    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8696        // The symmetric paste-from-gitconfig pin: an author copies
8697        // `url=https://github.com/p/x` from `git config --get-all
8698        // remote.origin.url` output, a `.gitconfig` `[remote
8699        // "origin"] url = https://…` ini-stanza paste, or a
8700        // `git config remote.origin.url <value>` doc snippet,
8701        // intending the `url=` prefix as the ini-key but the typed
8702        // `:repo` slot is a URL value parser, not a gitconfig
8703        // grammar. With no leading whitespace and no earlier-arm
8704        // bytes in the value, the `=` arm itself fires (rather
8705        // than cascading to the whitespace arm as in the env-var
8706        // paste shape). Pinned separately so a future diagnostic-
8707        // surface change that only checked the whitespace-leading
8708        // shape surfaces here — the per-byte arm fires anywhere
8709        // `=` appears in the value.
8710        let d = dep_with_fonte(DepSource::Git {
8711            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8712            tag: Some("v0.1.0".into()),
8713            rev: None,
8714            branch: None,
8715        });
8716        let err = d.validate().unwrap_err();
8717        let DepError::FonteRepoShape { reason, .. } = err else {
8718            panic!("expected FonteRepoShape, got other variant");
8719        };
8720        assert!(
8721            reason.contains("must not contain `=`"),
8722            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8723             paste shape, got {reason:?}"
8724        );
8725        assert!(
8726            reason.contains("key-value-separator") || reason.contains("sub-delims"),
8727            "reason must name the key-value-separator / RFC-3986-sub-delims \
8728             rationale, got {reason:?}"
8729        );
8730    }
8731
8732    #[test]
8733    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8734        // Cascade pin: the fragment-`#` arm and the `=` arm are
8735        // both per-byte arms inside the same `for &b in s.as_bytes()`
8736        // loop, so the byte that appears first in the value's byte
8737        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8738        // carries both `#` and `=`; the `#` byte appears first, so
8739        // the fragment-`#` arm fires, surfacing the more self-
8740        // locating diagnostic on the byte the author pasted earliest
8741        // in the URL.
8742        let d = dep_with_fonte(DepSource::Git {
8743            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8744            tag: Some("v0.1.0".into()),
8745            rev: None,
8746            branch: None,
8747        });
8748        let err = d.validate().unwrap_err();
8749        let DepError::FonteRepoShape { reason, .. } = err else {
8750            panic!("expected FonteRepoShape, got other variant");
8751        };
8752        assert!(
8753            reason.contains("must not contain `#`"),
8754            "reason must surface the fragment-`#` arm (fires before equals when \
8755             `#` byte appears first in value), got {reason:?}"
8756        );
8757    }
8758
8759    #[test]
8760    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8761        // Cascade pin: the comma-`,` arm (the immediate-predecessor
8762        // byte-class arm, 775b80e) and the `=` arm are both per-byte
8763        // arms inside the same `for &b in s.as_bytes()` loop, so
8764        // the byte that appears first in the value's byte order
8765        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8766        // and `=`; the `,` byte appears first, so the comma arm
8767        // fires, surfacing the more self-locating diagnostic on
8768        // the byte the author pasted earliest in the URL. Pins the
8769        // natural-order cascade so a future reorder of the per-byte
8770        // arms surfaces here — `=` is the most recent byte-class
8771        // arm, so the cascade-pin sweep extends to cover the
8772        // immediately prior `,` byte arm firing first when ordered
8773        // ahead of `=` in the value.
8774        let d = dep_with_fonte(DepSource::Git {
8775            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8776            tag: Some("v0.1.0".into()),
8777            rev: None,
8778            branch: None,
8779        });
8780        let err = d.validate().unwrap_err();
8781        let DepError::FonteRepoShape { reason, .. } = err else {
8782            panic!("expected FonteRepoShape, got other variant");
8783        };
8784        assert!(
8785            reason.contains("must not contain `,`"),
8786            "reason must surface the comma arm (fires before equals when `,` byte \
8787             appears first in value), got {reason:?}"
8788        );
8789    }
8790
8791    #[test]
8792    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8793        // The fail-before-pass-after pin for the canonical paste-from-
8794        // browser-address-bar percent-encoded-space footgun on `:repo`.
8795        // An author copies `https://github.com/p/x%20test` from a
8796        // browser address bar (or a percent-encoded README hyperlink,
8797        // or a `curl --data-urlencode` shell-pipeline output)
8798        // intending `%20` as the URL encoding of a literal space; the
8799        // typed `:repo` slot already rejects the literal space byte
8800        // (the whitespace arm at the top of `is_git_repo_url`), so an
8801        // author trying to express "I really meant a space" reaches
8802        // for percent-encoding. Until this arm landed the `%` byte
8803        // silently passed every prior `is_git_repo_url` arm and rode
8804        // verbatim into the lacre's per-dep content-address — but
8805        // libcurl re-percent-encodes `%` to `%25` on the wire (since
8806        // `%` is reserved as the escape-sequence lead-in), so the
8807        // wire request becomes `https://github.com/p/x%2520test`, a
8808        // path the lacre's content-address never names. The classic
8809        // render-determinism violation on the encoding-mechanism axis
8810        // itself.
8811        let d = dep_with_fonte(DepSource::Git {
8812            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8813            tag: Some("v0.1.0".into()),
8814            rev: None,
8815            branch: None,
8816        });
8817        let err = d.validate().unwrap_err();
8818        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8819            panic!("expected FonteRepoShape, got other variant");
8820        };
8821        assert_eq!(nome, "caixa-teia");
8822        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8823        assert!(
8824            reason.contains("must not contain `%`"),
8825            "reason must surface the percent-`%` arm on the percent-encoded-space \
8826             paste shape, got {reason:?}"
8827        );
8828        assert!(
8829            reason.contains("percent-encoding") || reason.contains("%25"),
8830            "reason must name the percent-encoding / `%25` re-encoding rationale, \
8831             got {reason:?}"
8832        );
8833    }
8834
8835    #[test]
8836    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8837        // The symmetric over-encoded-path-separator pin: an author
8838        // writes `:repo "https://github.com/p%2Fx"` intending the
8839        // `%2F` as the URL encoding of `/` (the canonical
8840        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8841        // footgun every API client library and OAuth redirect-URI
8842        // documentation surfaces — the `/` is the URL-path-separator
8843        // and some templates percent-encode it to escape interpretation
8844        // as a path separator). The GitHub Smart-HTTP transport
8845        // resolves the URL's path-segment grammar before the
8846        // percent-decoding pass, so the value identifies a different
8847        // resource on the wire than the literal-`/` form the lacre's
8848        // content-address must agree with — two authors whose `:repo`
8849        // values differ only in their `/` vs `%2F` presence lock to
8850        // two distinct BLAKE3 closures for the byte-identical upstream
8851        // `git clone`. Pinned separately so a future diagnostic
8852        // surface that only catches the `%20` shape surfaces here too.
8853        let d = dep_with_fonte(DepSource::Git {
8854            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8855            tag: Some("v0.1.0".into()),
8856            rev: None,
8857            branch: None,
8858        });
8859        let err = d.validate().unwrap_err();
8860        let DepError::FonteRepoShape { reason, .. } = err else {
8861            panic!("expected FonteRepoShape, got other variant");
8862        };
8863        assert!(
8864            reason.contains("must not contain `%`"),
8865            "reason must surface the percent-`%` arm on the over-encoded-path \
8866             shape, got {reason:?}"
8867        );
8868        assert!(
8869            reason.contains("render-determinism") || reason.contains("BLAKE3"),
8870            "reason must name the render-determinism / BLAKE3-closure rationale, \
8871             got {reason:?}"
8872        );
8873    }
8874
8875    #[test]
8876    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8877        // Cascade pin: the fragment-`#` arm and the `%` arm are both
8878        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8879        // so the byte that appears first in the value's byte order
8880        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8881        // both `#` and `%`; the `#` byte appears first, so the
8882        // fragment-`#` arm fires, surfacing the more self-locating
8883        // diagnostic on the byte the author pasted earliest in the URL.
8884        let d = dep_with_fonte(DepSource::Git {
8885            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8886            tag: Some("v0.1.0".into()),
8887            rev: None,
8888            branch: None,
8889        });
8890        let err = d.validate().unwrap_err();
8891        let DepError::FonteRepoShape { reason, .. } = err else {
8892            panic!("expected FonteRepoShape, got other variant");
8893        };
8894        assert!(
8895            reason.contains("must not contain `#`"),
8896            "reason must surface the fragment-`#` arm (fires before percent when \
8897             `#` byte appears first in value), got {reason:?}"
8898        );
8899    }
8900
8901    #[test]
8902    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8903        // Cascade pin: the equals-`=` arm (the immediate-predecessor
8904        // byte-class arm, acf99af) and the `%` arm are both per-byte
8905        // arms inside the same `for &b in s.as_bytes()` loop, so the
8906        // byte that appears first in the value's byte order wins.
8907        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8908        // the `=` byte appears first, so the equals arm fires,
8909        // surfacing the more self-locating diagnostic on the byte the
8910        // author pasted earliest in the URL. Pins the natural-order
8911        // cascade so a future reorder of the per-byte arms surfaces
8912        // here — `%` is the most recent byte-class arm, so the
8913        // cascade-pin sweep extends to cover the immediately prior
8914        // `=` byte arm firing first when ordered ahead of `%` in the
8915        // value.
8916        let d = dep_with_fonte(DepSource::Git {
8917            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8918            tag: Some("v0.1.0".into()),
8919            rev: None,
8920            branch: None,
8921        });
8922        let err = d.validate().unwrap_err();
8923        let DepError::FonteRepoShape { reason, .. } = err else {
8924            panic!("expected FonteRepoShape, got other variant");
8925        };
8926        assert!(
8927            reason.contains("must not contain `=`"),
8928            "reason must surface the equals arm (fires before percent when `=` byte \
8929             appears first in value), got {reason:?}"
8930        );
8931    }
8932
8933    #[test]
8934    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8935        // The fail-before-pass-after pin for the canonical paste-from-
8936        // shell-history footgun on `:repo`. An author copies a
8937        // `git clone <url>` line from their terminal followed by a
8938        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8939        // history shorthand (the `^old^new^` form re-runs the prior
8940        // history entry with the first `old` substituted by `new`,
8941        // bash's default behavior on interactive sessions with
8942        // `set -o histexpand`), forgetting to trim the trailing
8943        // `^...^...` shell-history fragment from the URL value. The
8944        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8945        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8946        // classes), the WHATWG URL spec's 'fragment percent-encode
8947        // set' maps `^` → `%5E` on the wire, so the byte rides
8948        // verbatim into the lacre's per-dep content-address but
8949        // libcurl re-encodes it to `%5E` at `git clone` time — the
8950        // classic render-determinism violation on the same axis the
8951        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8952        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8953        // `#` arms close.
8954        let d = dep_with_fonte(DepSource::Git {
8955            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8956            tag: Some("v0.1.0".into()),
8957            rev: None,
8958            branch: None,
8959        });
8960        let err = d.validate().unwrap_err();
8961        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8962            panic!("expected FonteRepoShape, got other variant");
8963        };
8964        assert_eq!(nome, "caixa-teia");
8965        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8966        assert!(
8967            reason.contains("must not contain `^`"),
8968            "reason must surface the caret-`^` arm on the paste-from-shell-history \
8969             shape, got {reason:?}"
8970        );
8971        assert!(
8972            reason.contains("history-substitution") || reason.contains("%5E"),
8973            "reason must name the shell-history-substitution / `%5E` wire-encoding \
8974             rationale, got {reason:?}"
8975        );
8976    }
8977
8978    #[test]
8979    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8980        // The symmetric paste-from-doc-grep-pipeline footgun: an
8981        // author writes `:repo "github:p/^archived"` after copying a
8982        // `grep '^archived'` regex-anchor / negation idiom from a
8983        // doc / README quick-listing snippet, expecting the substrate
8984        // to coerce it to a literal repo name. The byte rides
8985        // verbatim into the lacre's per-dep content-address and
8986        // diverges from the byte-identical literal `archived` form
8987        // every other author authored — the canonical render-
8988        // determinism violation pin on the second footgun shape the
8989        // caret-`^` arm closes.
8990        let d = dep_with_fonte(DepSource::Git {
8991            repo: "github:pleme-io/^archived".into(),
8992            tag: Some("v0.1.0".into()),
8993            rev: None,
8994            branch: None,
8995        });
8996        let err = d.validate().unwrap_err();
8997        let DepError::FonteRepoShape { reason, .. } = err else {
8998            panic!("expected FonteRepoShape, got other variant");
8999        };
9000        assert!(
9001            reason.contains("must not contain `^`"),
9002            "reason must surface the caret-`^` arm on the regex-anchor shape, \
9003             got {reason:?}"
9004        );
9005        assert!(
9006            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9007            "reason must name the render-determinism / BLAKE3-closure rationale, \
9008             got {reason:?}"
9009        );
9010    }
9011
9012    #[test]
9013    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9014        // Cascade pin: the `%` arm (the immediate-predecessor byte-
9015        // class arm, a323db8) and the `^` arm are both per-byte arms
9016        // inside the same `for &b in s.as_bytes()` loop, so the byte
9017        // that appears first in the value's byte order wins. A
9018        // `:repo "https://github.com/p/x%20mid^tail"` carries both
9019        // `%` and `^`; the `%` byte appears first, so the percent
9020        // arm fires, surfacing the more self-locating diagnostic on
9021        // the byte the author pasted earliest in the URL. Pins the
9022        // natural-order cascade so a future reorder of the per-byte
9023        // arms surfaces here — `^` is the most recent byte-class arm,
9024        // so the cascade-pin sweep extends to cover the immediately
9025        // prior `%` byte arm firing first when ordered ahead of `^`
9026        // in the value.
9027        let d = dep_with_fonte(DepSource::Git {
9028            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9029            tag: Some("v0.1.0".into()),
9030            rev: None,
9031            branch: None,
9032        });
9033        let err = d.validate().unwrap_err();
9034        let DepError::FonteRepoShape { reason, .. } = err else {
9035            panic!("expected FonteRepoShape, got other variant");
9036        };
9037        assert!(
9038            reason.contains("must not contain `%`"),
9039            "reason must surface the percent arm (fires before caret when `%` byte \
9040             appears first in value), got {reason:?}"
9041        );
9042    }
9043
9044    #[test]
9045    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9046        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9047        // (no `github:` prefix, no scheme). Every documented form
9048        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9049        // `file://`, or `git@host:path`); a bare `org/repo` is
9050        // ambiguous (`git clone` reads as a relative filesystem path
9051        // rather than the GitHub-shorthand expansion the author
9052        // probably intended) and the gate rejects the shape upstream.
9053        let d = dep_with_fonte(DepSource::Git {
9054            repo: "pleme-io/caixa-teia".into(),
9055            tag: Some("v0.1.0".into()),
9056            rev: None,
9057            branch: None,
9058        });
9059        let err = d.validate().unwrap_err();
9060        let DepError::FonteRepoShape { reason, .. } = err else {
9061            panic!("expected FonteRepoShape, got other variant");
9062        };
9063        assert!(
9064            reason.contains("must contain a `:`"),
9065            "reason must surface the missing-`:` arm, got {reason:?}"
9066        );
9067        assert!(
9068            reason.contains("github:"),
9069            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9070        );
9071    }
9072
9073    #[test]
9074    fn validate_rejects_git_fonte_with_repo_leading_colon() {
9075        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9076        // scheme that no git porcelain entry-point accepts. Pinned
9077        // separately from the missing-`:` arm because a value with a
9078        // leading `:` does technically contain a `:` separator; the
9079        // shape gate rejects on a dedicated arm so the diagnostic
9080        // names the specific footgun.
9081        let d = dep_with_fonte(DepSource::Git {
9082            repo: ":pleme-io/caixa-teia".into(),
9083            tag: Some("v0.1.0".into()),
9084            rev: None,
9085            branch: None,
9086        });
9087        let err = d.validate().unwrap_err();
9088        let DepError::FonteRepoShape { reason, .. } = err else {
9089            panic!("expected FonteRepoShape, got other variant");
9090        };
9091        assert!(
9092            reason.contains("must not start with `:`"),
9093            "reason must surface the leading-`:` arm, got {reason:?}"
9094        );
9095    }
9096
9097    #[test]
9098    fn validate_rejects_git_fonte_with_repo_too_long() {
9099        // The cap arm — a `:repo` value longer than
9100        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9101        // structurally untenable on every realistic landing site (the
9102        // resolver's `git clone` invocation, the future M4 CR
9103        // materializer's per-dep `repo:` axis); a value of that length
9104        // is almost certainly a paste-from-binary slug.
9105        let too_long = format!(
9106            "github:pleme-io/{}",
9107            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9108        );
9109        let d = dep_with_fonte(DepSource::Git {
9110            repo: too_long.clone(),
9111            tag: Some("v0.1.0".into()),
9112            rev: None,
9113            branch: None,
9114        });
9115        let err = d.validate().unwrap_err();
9116        let DepError::FonteRepoShape { reason, .. } = err else {
9117            panic!("expected FonteRepoShape, got other variant");
9118        };
9119        assert!(
9120            reason.contains("2048"),
9121            "reason must name the cap, got {reason:?}"
9122        );
9123    }
9124
9125    #[test]
9126    fn validate_accepts_canonical_git_fonte_repo_shapes() {
9127        // The positive-control sweep: every documented author shape on
9128        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9129        // must pass the value-shape gate. Pinned so a future tightening
9130        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9131        // here as a structural decision. Each form is exercised with the
9132        // same canonical `:tag` pin so only the `:repo` axis varies.
9133        for repo in [
9134            // The pleme-io registry-shorthand convention — `github:org/repo`.
9135            "github:pleme-io/caixa-teia",
9136            // Other host-aliased shorthands (the resolver's pluggable
9137            // host-prefix table).
9138            "gitlab:pleme-io/caixa-teia",
9139            "codeberg:pleme-io/caixa-teia",
9140            "sourcehut:~pleme-io/caixa-teia",
9141            // Full HTTPS URL with and without `.git` suffix.
9142            "https://github.com/pleme-io/caixa-teia",
9143            "https://github.com/pleme-io/caixa-teia.git",
9144            // HTTP (rare; dev / mirror).
9145            "http://example.com/pleme-io/caixa-teia.git",
9146            // SSH URL.
9147            "ssh://git@github.com/pleme-io/caixa-teia.git",
9148            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9149            // Scp-style SSH — the canonical `git@host:path` short form.
9150            "git@github.com:pleme-io/caixa-teia.git",
9151            "git@git.example.com:team/private.git",
9152            // Anonymous git protocol.
9153            "git://git.example.com/pleme-io/caixa-teia.git",
9154            // Local file URL (dev path).
9155            "file:///tmp/caixa-teia",
9156        ] {
9157            let d = dep_with_fonte(DepSource::Git {
9158                repo: repo.into(),
9159                tag: Some("v0.1.0".into()),
9160                rev: None,
9161                branch: None,
9162            });
9163            d.validate()
9164                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9165        }
9166    }
9167
9168    #[test]
9169    fn fonte_repo_empty_takes_precedence_over_shape() {
9170        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9171        // diagnostic; doesn't try to parse the URL shape) fires before
9172        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9173        // keeps its narrower error message. Mirrors
9174        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9175        // on the ordering layer.
9176        let d = dep_with_fonte(DepSource::Git {
9177            repo: String::new(),
9178            tag: Some("v0.1.0".into()),
9179            rev: None,
9180            branch: None,
9181        });
9182        let err = d.validate().unwrap_err();
9183        assert!(
9184            matches!(err, DepError::FonteRepoEmpty { .. }),
9185            "got {err:?}"
9186        );
9187    }
9188
9189    #[test]
9190    fn fonte_repo_shape_fires_before_pin_missing() {
9191        // Order pin: a malformed `:repo` value on a dep with no pin set
9192        // surfaces the `:repo` shape diagnostic (the more self-locating
9193        // axis — the `:repo` is the load-bearing identity of the source;
9194        // a missing pin is downstream from "do we even know the repo")
9195        // rather than collapsing onto the pin-missing diagnostic. The
9196        // shape gate runs inline before the pin enumeration in
9197        // `DepSource::validate`.
9198        let d = dep_with_fonte(DepSource::Git {
9199            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9200            tag: None,
9201            rev: None,
9202            branch: None,
9203        });
9204        let err = d.validate().unwrap_err();
9205        assert!(
9206            matches!(err, DepError::FonteRepoShape { .. }),
9207            "got {err:?}"
9208        );
9209    }
9210
9211    #[test]
9212    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9213        // The diagnostic-shape pin: the error names the offending
9214        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9215        // so the author can grep their caixa.lisp without re-running
9216        // the build. Mirrors the diagnostic-shape sweep on every prior
9217        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9218        let d = dep_with_fonte(DepSource::Git {
9219            repo: "pleme-io/caixa-teia".into(),
9220            tag: Some("v0.1.0".into()),
9221            rev: None,
9222            branch: None,
9223        });
9224        let err = d.validate().unwrap_err();
9225        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9226            panic!("expected FonteRepoShape, got other variant");
9227        };
9228        assert_eq!(nome, "caixa-teia");
9229        assert_eq!(repo, "pleme-io/caixa-teia");
9230        assert!(
9231            !reason.is_empty(),
9232            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9233        );
9234    }
9235
9236    #[test]
9237    fn validate_rejects_git_fonte_with_no_pin() {
9238        // The fail-before-pass-after pin for the canonical
9239        // `(:tipo git :repo "github:pleme-io/x")` shape with no
9240        // :tag/:rev/:branch — until this gate landed the resolver's
9241        // ResolveError::MissingPin surfaced at fetch time, far from the
9242        // source caixa.lisp. The new gate moves the check to validate
9243        // time and names the offending dep.
9244        let d = dep_with_fonte(DepSource::Git {
9245            repo: "github:pleme-io/caixa-teia".into(),
9246            tag: None,
9247            rev: None,
9248            branch: None,
9249        });
9250        let err = d.validate().unwrap_err();
9251        assert!(
9252            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9253            "got {err:?}"
9254        );
9255    }
9256
9257    #[test]
9258    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9259        // The canonical "pin drift" footgun: an author writes
9260        // `:tag "v1"` and later adds `:branch "main"` without removing
9261        // the :tag, and the resolver silently picks :tag (precedence
9262        // :rev > :tag > :branch). The :branch was dropped with no
9263        // diagnostic. The gate now rejects multi-pin shapes so the
9264        // author makes the precedence explicit at the source.
9265        let d = dep_with_fonte(DepSource::Git {
9266            repo: "github:pleme-io/caixa-teia".into(),
9267            tag: Some("v0.1.0".into()),
9268            rev: None,
9269            branch: Some("main".into()),
9270        });
9271        let err = d.validate().unwrap_err();
9272        let DepError::FontePinAmbiguous { nome, pins } = err else {
9273            panic!("expected FontePinAmbiguous");
9274        };
9275        assert_eq!(nome, "caixa-teia");
9276        assert!(pins.contains(":tag"));
9277        assert!(pins.contains(":branch"));
9278        assert!(!pins.contains(":rev"));
9279    }
9280
9281    #[test]
9282    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9283        // Sibling arm of the pin-drift footgun: :tag + :rev set
9284        // simultaneously. Pinned separately so a future relaxation
9285        // that only catches the (:tag, :branch) pair surfaces here.
9286        let d = dep_with_fonte(DepSource::Git {
9287            repo: "github:pleme-io/caixa-teia".into(),
9288            tag: Some("v0.1.0".into()),
9289            rev: Some("c0ffee".into()),
9290            branch: None,
9291        });
9292        let err = d.validate().unwrap_err();
9293        let DepError::FontePinAmbiguous { nome, pins } = err else {
9294            panic!("expected FontePinAmbiguous");
9295        };
9296        assert_eq!(nome, "caixa-teia");
9297        assert!(pins.contains(":tag"));
9298        assert!(pins.contains(":rev"));
9299    }
9300
9301    #[test]
9302    fn validate_rejects_git_fonte_with_all_three_pins() {
9303        // The maximal ambiguity case — every pin axis set. Pinned so a
9304        // future relaxation that only catches pairs surfaces here. The
9305        // diagnostic must enumerate every offending axis so the author
9306        // sees the full set, not just the first match.
9307        let d = dep_with_fonte(DepSource::Git {
9308            repo: "github:pleme-io/caixa-teia".into(),
9309            tag: Some("v0.1.0".into()),
9310            rev: Some("c0ffee".into()),
9311            branch: Some("main".into()),
9312        });
9313        let err = d.validate().unwrap_err();
9314        let DepError::FontePinAmbiguous { nome, pins } = err else {
9315            panic!("expected FontePinAmbiguous");
9316        };
9317        assert_eq!(nome, "caixa-teia");
9318        assert!(pins.contains(":tag"));
9319        assert!(pins.contains(":rev"));
9320        assert!(pins.contains(":branch"));
9321    }
9322
9323    #[test]
9324    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9325        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9326        // inner string is empty. Distinct from FontePinMissing (where
9327        // every axis is None) — pinned separately so a future
9328        // tightening collapsing them surfaces here as a structural
9329        // decision.
9330        let d = dep_with_fonte(DepSource::Git {
9331            repo: "github:pleme-io/caixa-teia".into(),
9332            tag: Some(String::new()),
9333            rev: None,
9334            branch: None,
9335        });
9336        let err = d.validate().unwrap_err();
9337        let DepError::FontePinEmpty { nome, pin } = err else {
9338            panic!("expected FontePinEmpty");
9339        };
9340        assert_eq!(nome, "caixa-teia");
9341        assert_eq!(pin, ":tag");
9342    }
9343
9344    #[test]
9345    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9346        // Sibling arm — the empty-pin diagnostic names which axis
9347        // carries the empty value, so the author's grep target is
9348        // unambiguous.
9349        let d = dep_with_fonte(DepSource::Git {
9350            repo: "github:pleme-io/caixa-teia".into(),
9351            tag: None,
9352            rev: Some(String::new()),
9353            branch: None,
9354        });
9355        let err = d.validate().unwrap_err();
9356        let DepError::FontePinEmpty { nome, pin } = err else {
9357            panic!("expected FontePinEmpty");
9358        };
9359        assert_eq!(nome, "caixa-teia");
9360        assert_eq!(pin, ":rev");
9361    }
9362
9363    #[test]
9364    fn validate_rejects_path_fonte_with_empty_caminho() {
9365        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9366        // until this gate landed the resolver's
9367        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9368        // fetch time — not actionable. The new gate moves the check to
9369        // validate time and names the offending dep.
9370        let d = dep_with_fonte(DepSource::Path {
9371            caminho: String::new(),
9372        });
9373        let err = d.validate().unwrap_err();
9374        assert!(
9375            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9376            "got {err:?}"
9377        );
9378    }
9379
9380    #[test]
9381    fn validate_rejects_path_fonte_with_absolute_caminho() {
9382        // The fail-before-pass-after pin for the absolute-`:caminho`
9383        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9384        // Until this gate landed an absolute `:caminho` silently
9385        // passed validate; the lacre pipeline embedded the
9386        // host-specific filesystem path verbatim in its
9387        // content-address (`conteudo: format!("path:{caminho}")`,
9388        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9389        // differed per machine — the build succeeded but two CI
9390        // runners with different `${HOME}` layouts emitted two
9391        // distinct lacres for the byte-identical caixa, silently
9392        // breaking the THEORY.md §V.2 render-determinism contract
9393        // far from the source caixa.lisp. The new gate moves the
9394        // check to validate time and names the offending dep +
9395        // caminho verbatim.
9396        let d = dep_with_fonte(DepSource::Path {
9397            caminho: "/home/me/work/caixa-teia".into(),
9398        });
9399        let err = d.validate().unwrap_err();
9400        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9401            panic!("expected FonteCaminhoAbsolute, got other variant");
9402        };
9403        assert_eq!(nome, "caixa-teia");
9404        assert_eq!(caminho, "/home/me/work/caixa-teia");
9405    }
9406
9407    #[test]
9408    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9409        // The canonical sibling-workspace dep form
9410        // (`:caminho "../caixa-teia"`) remains accepted. The
9411        // absolute-path gate above is specifically narrower than the
9412        // shared [`crate::render::is_sandboxed_relative_path`]
9413        // predicate (which additionally forbids `..` traversal): a
9414        // local-path dep's canonical author surface is the in-tree
9415        // sibling-workspace path, so a full sandboxed-relative-path
9416        // lift would structurally reject every legitimate path-fonte
9417        // dep. Pinned so a future tightening to the full predicate
9418        // surfaces here as a structural decision, not a silent break.
9419        let d = dep_with_fonte(DepSource::Path {
9420            caminho: "../caixa-teia".into(),
9421        });
9422        d.validate().unwrap();
9423    }
9424
9425    #[test]
9426    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9427        // A multi-segment relative `:caminho`
9428        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9429        // absolute-path gate brackets the host-layout-leaking shape
9430        // at the leading-`/` boundary only; every relative shape past
9431        // the empty arm continues to pass. Pinned alongside the
9432        // `..`-traversal positive control so a future tightening
9433        // surfaces the full set of legitimate relative forms here
9434        // rather than at a downstream consumer.
9435        let d = dep_with_fonte(DepSource::Path {
9436            caminho: "vendor/forks/caixa-teia".into(),
9437        });
9438        d.validate().unwrap();
9439    }
9440
9441    #[test]
9442    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9443        // The fail-before-pass-after pin for the tilde-expansion
9444        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9445        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9446        // through (`Path::is_absolute` returns false on a leading `~`
9447        // — the tilde is a shell-expansion convention, not a POSIX
9448        // path component), so the lacre embedded the value verbatim
9449        // and the resolver folded it through `Path::join` without
9450        // expansion, looking for a literal `./~/work/caixa-teia`
9451        // subdirectory and failing at resolve time with a
9452        // `No such file or directory` error far from the source
9453        // caixa.lisp. The new gate moves the check to validate time
9454        // and names the offending dep + caminho verbatim.
9455        let d = dep_with_fonte(DepSource::Path {
9456            caminho: "~/work/caixa-teia".into(),
9457        });
9458        let err = d.validate().unwrap_err();
9459        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9460            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9461        };
9462        assert_eq!(nome, "caixa-teia");
9463        assert_eq!(caminho, "~/work/caixa-teia");
9464    }
9465
9466    #[test]
9467    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9468        // The bare `~` form (canonical "I meant `$HOME` and forgot
9469        // the rest"): both the leading-tilde arm catches it and the
9470        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9471        // sweeps through the same arm. Pinned both to ensure the
9472        // gate doesn't narrow to `~/` only.
9473        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9474            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9475            let err = d.validate().unwrap_err();
9476            assert!(
9477                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9478                "{s:?} → {err:?}",
9479            );
9480        }
9481    }
9482
9483    #[test]
9484    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9485        // The leading-`~` is the canonical shell-expansion footgun —
9486        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9487        // backup-file-suffix idiom) is a legitimate POSIX path byte
9488        // with no shell-expansion semantic at the leading position.
9489        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9490        // sweep that would break every legitimate-shape backup-file
9491        // path.
9492        let d = dep_with_fonte(DepSource::Path {
9493            caminho: "../foo~bar/caixa-teia".into(),
9494        });
9495        d.validate().unwrap();
9496    }
9497
9498    #[test]
9499    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9500        // Cascade pin: the empty arm structurally precedes the
9501        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9502        // pin establishes the precedence at the diagnostic-shape
9503        // level should a future codec round-trip ever produce a
9504        // probe-as-both value. Mirrors the peer
9505        // `fonte_repo_empty_fires_before_pin_missing` cascade
9506        // discipline.
9507        let d = dep_with_fonte(DepSource::Path {
9508            caminho: String::new(),
9509        });
9510        let err = d.validate().unwrap_err();
9511        assert!(
9512            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9513            "got {err:?}",
9514        );
9515    }
9516
9517    #[test]
9518    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9519        // Diagnostic-shape pin (peer with
9520        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9521        // payload assertion): the error's Display surfaces both the
9522        // offending `:nome` and the offending `:caminho` verbatim
9523        // so a `feira lint` run can render the diagnostic without
9524        // re-parsing.
9525        let d = dep_with_fonte(DepSource::Path {
9526            caminho: "~alice/dev/caixa-teia".into(),
9527        });
9528        let rendered = d.validate().unwrap_err().to_string();
9529        assert!(
9530            rendered.contains("caixa-teia"),
9531            "diagnostic must name the offending dep: {rendered}",
9532        );
9533        assert!(
9534            rendered.contains("~alice/dev/caixa-teia"),
9535            "diagnostic must quote the offending caminho: {rendered}",
9536        );
9537        assert!(
9538            rendered.contains('~'),
9539            "diagnostic must reference the tilde footgun: {rendered}",
9540        );
9541    }
9542
9543    #[test]
9544    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9545        // The fail-before-pass-after pin for the shell-variable-
9546        // expansion `:caminho` shape: `(:tipo path :caminho
9547        // "$HOME/work/caixa-teia")`. Until this gate landed the
9548        // b94fd83 absolute arm + the a5c248e tilde arm both let
9549        // `$HOME/foo` through (`Path::is_absolute` returns false on
9550        // a leading `$` — the `$` is a shell convention, not a POSIX
9551        // path component; `starts_with('~')` returns false too), so
9552        // the lacre embedded the value verbatim and the resolver
9553        // folded it through `Path::join` without `$`-expansion,
9554        // looking for a literal `./$HOME/work/caixa-teia`
9555        // subdirectory and failing at resolve time with a
9556        // `No such file or directory` error far from the source
9557        // caixa.lisp. The new gate moves the check to validate time
9558        // and names the offending dep + caminho verbatim.
9559        let d = dep_with_fonte(DepSource::Path {
9560            caminho: "$HOME/work/caixa-teia".into(),
9561        });
9562        let err = d.validate().unwrap_err();
9563        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9564            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9565        };
9566        assert_eq!(nome, "caixa-teia");
9567        assert_eq!(caminho, "$HOME/work/caixa-teia");
9568    }
9569
9570    #[test]
9571    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9572        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9573        // form (canonical "paste-from-CI-manifest" footgun every
9574        // GitHub Actions / GitLab CI / Drone manifest carries on
9575        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9576        // canonical "I'm referencing a per-user config dir"),
9577        // and the bare `$` (canonical "I meant `$HOME` and forgot
9578        // the rest"). All shapes route through the same gate's
9579        // byte check. Pinned so the gate doesn't narrow to a
9580        // single shape (e.g. `$HOME/` only).
9581        for s in [
9582            "${HOME}/work/caixa-teia",
9583            "${WORKSPACE}/caixa-teia",
9584            "$XDG_CONFIG_HOME/caixa",
9585            "$",
9586        ] {
9587            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9588            let err = d.validate().unwrap_err();
9589            assert!(
9590                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9591                "{s:?} → {err:?}",
9592            );
9593        }
9594    }
9595
9596    #[test]
9597    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9598        // The `$` byte is the canonical shell-variable-expansion /
9599        // command-substitution / arithmetic-expansion sentinel and
9600        // is rejected at *every* position on the `:caminho` axis: the
9601        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9602        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9603        // (6620f39). Pinned so a future arm doesn't narrow the gate
9604        // back to the leading position and re-open the paste-from-
9605        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9606        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9607        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9608        // the lacre content-address (`path:{caminho}`,
9609        // caixa-resolver/src/resolve.rs:189).
9610        let d = dep_with_fonte(DepSource::Path {
9611            caminho: "../foo$bar/caixa-teia".into(),
9612        });
9613        let err = d.validate().unwrap_err();
9614        assert!(
9615            matches!(
9616                err,
9617                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9618            ),
9619            "got {err:?}",
9620        );
9621    }
9622
9623    #[test]
9624    fn fonte_caminho_tilde_fires_before_var_expansion() {
9625        // Cascade pin: the tilde arm structurally precedes the var
9626        // arm (the bytes `~` and `$` don't overlap at the leading
9627        // position), but the pin establishes the precedence at the
9628        // diagnostic-shape level should a future codec round-trip
9629        // ever produce a probe-as-both value. Mirrors the peer
9630        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9631        // discipline on the immediate-predecessor arm.
9632        let d = dep_with_fonte(DepSource::Path {
9633            caminho: "~/work/caixa-teia".into(),
9634        });
9635        let err = d.validate().unwrap_err();
9636        assert!(
9637            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9638            "got {err:?}",
9639        );
9640    }
9641
9642    #[test]
9643    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9644        // Diagnostic-shape pin (peer with
9645        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9646        // payload assertion on the immediate-predecessor arm): the
9647        // error's Display surfaces both the offending `:nome` and
9648        // the offending `:caminho` verbatim plus the `$` footgun
9649        // character itself so a `feira lint` run can render the
9650        // diagnostic without re-parsing.
9651        let d = dep_with_fonte(DepSource::Path {
9652            caminho: "${WORKSPACE}/caixa-teia".into(),
9653        });
9654        let rendered = d.validate().unwrap_err().to_string();
9655        assert!(
9656            rendered.contains("caixa-teia"),
9657            "diagnostic must name the offending dep: {rendered}",
9658        );
9659        assert!(
9660            rendered.contains("${WORKSPACE}/caixa-teia"),
9661            "diagnostic must quote the offending caminho: {rendered}",
9662        );
9663        assert!(
9664            rendered.contains('$'),
9665            "diagnostic must reference the dollar footgun: {rendered}",
9666        );
9667    }
9668
9669    #[test]
9670    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9671        // The fail-before-pass-after pin for the load-bearing NUL byte:
9672        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9673        // routes the path through `CString::new` which fails with
9674        // `NulError`); until this gate landed a `:caminho
9675        // "../caixa\0teia"` silently passed validate, the lacre
9676        // pipeline embedded the value verbatim, and the failure
9677        // surfaced at the resolver's `Path::join` → `CString::new`
9678        // boundary with a non-self-locating `NulError` far from the
9679        // source caixa.lisp. The new gate moves the check to validate
9680        // time and names the offending dep + caminho + offending byte
9681        // verbatim.
9682        let d = dep_with_fonte(DepSource::Path {
9683            caminho: "../caixa\0teia".into(),
9684        });
9685        let err = d.validate().unwrap_err();
9686        let DepError::FonteCaminhoControlChar {
9687            nome,
9688            caminho,
9689            byte,
9690        } = err
9691        else {
9692            panic!("expected FonteCaminhoControlChar, got {err:?}");
9693        };
9694        assert_eq!(nome, "caixa-teia");
9695        assert_eq!(caminho, "../caixa\0teia");
9696        assert_eq!(byte, 0x00);
9697    }
9698
9699    #[test]
9700    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9701        // The canonical paste-from-multiline-doc footgun on `:caminho`
9702        // — author copies `"../caixa-teia\n"` (trailing newline) out
9703        // of a multi-line code-fence or, worse, a `:caminho
9704        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9705        // injection sibling on the path axis the `is_git_repo_url`
9706        // control-char arm already closes on `:repo`). Pinned
9707        // separately from the NUL arm so a future relaxation that
9708        // catches one but not the other surfaces here.
9709        let d = dep_with_fonte(DepSource::Path {
9710            caminho: "../caixa-teia\n".into(),
9711        });
9712        let err = d.validate().unwrap_err();
9713        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9714            panic!("expected FonteCaminhoControlChar, got {err:?}");
9715        };
9716        assert_eq!(byte, 0x0A);
9717    }
9718
9719    #[test]
9720    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9721        // The CRLF sibling of the LF arm — Windows-line-ending
9722        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9723        // leaves a stray `\r` mid-string after the LF strip. Pinned
9724        // separately from the LF arm so a future relaxation that
9725        // only catches LF surfaces here.
9726        let d = dep_with_fonte(DepSource::Path {
9727            caminho: "../caixa-teia\r".into(),
9728        });
9729        let err = d.validate().unwrap_err();
9730        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9731            panic!("expected FonteCaminhoControlChar, got {err:?}");
9732        };
9733        assert_eq!(byte, 0x0D);
9734    }
9735
9736    #[test]
9737    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9738        // The canonical paste-from-aligned-table footgun — a `\t`
9739        // mid-`:caminho` is invisible in most editors but rides
9740        // through the lacre's content-address verbatim, so two
9741        // paste-from-distinct-tables (one editor strips tabs, one
9742        // preserves them) yield divergent lacres for the byte-
9743        // identical-looking caixa. Pinned separately from the
9744        // whitespace-shaped LF/CR arms so a future relaxation that
9745        // narrows to line-terminator-only surfaces here.
9746        let d = dep_with_fonte(DepSource::Path {
9747            caminho: "../caixa\tteia".into(),
9748        });
9749        let err = d.validate().unwrap_err();
9750        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9751            panic!("expected FonteCaminhoControlChar, got {err:?}");
9752        };
9753        assert_eq!(byte, 0x09);
9754    }
9755
9756    #[test]
9757    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9758        // The DEL byte (`0x7F`) closes the upper-end paste-from-
9759        // binary-blob footgun — the gate's contract is `b < 0x20 ||
9760        // b == 0x7F`, matching the `is_git_repo_url` /
9761        // `is_git_ref_name` predicates' control-char arms. Pinned
9762        // separately from the lower-range arms so a future narrowing
9763        // to `< 0x20` only surfaces here.
9764        let d = dep_with_fonte(DepSource::Path {
9765            caminho: "../caixa\x7fteia".into(),
9766        });
9767        let err = d.validate().unwrap_err();
9768        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9769            panic!("expected FonteCaminhoControlChar, got {err:?}");
9770        };
9771        assert_eq!(byte, 0x7F);
9772    }
9773
9774    #[test]
9775    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9776        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9777        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9778        // are opaque byte sequences and UTF-8 multi-byte sequences
9779        // are a legitimate filename shape (the `café-teia/foo` idiom).
9780        // Pinned so the gate doesn't widen to a full ASCII-only sweep
9781        // that would break every legitimate-shape UTF-8 path.
9782        let d = dep_with_fonte(DepSource::Path {
9783            caminho: "../café-teia/foo".into(),
9784        });
9785        d.validate().unwrap();
9786    }
9787
9788    #[test]
9789    fn fonte_caminho_var_fires_before_control_char() {
9790        // Cascade pin: the var-expansion arm structurally precedes the
9791        // control-char arm. A value like `"$\n"` probes positive on
9792        // both arms (`starts_with('$')` and contains LF), but the
9793        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9794        // wins so the author sees the more self-locating shell-
9795        // expansion arm first. Mirrors the
9796        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9797        // discipline on the immediate-predecessor arm.
9798        let d = dep_with_fonte(DepSource::Path {
9799            caminho: "$HOME\n".into(),
9800        });
9801        let err = d.validate().unwrap_err();
9802        assert!(
9803            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9804            "got {err:?}",
9805        );
9806    }
9807
9808    #[test]
9809    fn validate_rejects_path_fonte_with_leading_space_caminho() {
9810        // The fail-before-pass-after pin for the leading ASCII space
9811        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9812        // Until this gate landed the b94fd83 absolute arm + the a5c248e
9813        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9814        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9815        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9816        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9817        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9818        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9819        // are caught, but the most common whitespace `0x20` space is
9820        // not). The lacre embedded the value verbatim and the resolver
9821        // folded it through `Path::join` looking for a literal `./ ../
9822        // caixa-teia` subdirectory and failing at resolve time with a
9823        // non-self-locating `No such file or directory` error far from
9824        // the source caixa.lisp. The new gate moves the check to
9825        // validate time and names the offending dep + caminho verbatim.
9826        let d = dep_with_fonte(DepSource::Path {
9827            caminho: " ../caixa-teia".into(),
9828        });
9829        let err = d.validate().unwrap_err();
9830        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9831            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9832        };
9833        assert_eq!(nome, "caixa-teia");
9834        assert_eq!(caminho, " ../caixa-teia");
9835    }
9836
9837    #[test]
9838    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9839        // The aligned-doc paste footgun sweep: more than one leading
9840        // space (`"   ../caixa-teia"` — the canonical "I selected the
9841        // aligned column from a four-`:fonte`-entry `:deps` block"
9842        // paste) routes through the same gate's `starts_with(' ')`
9843        // byte check. Pinned so the gate doesn't narrow to a
9844        // single-space prefix.
9845        let d = dep_with_fonte(DepSource::Path {
9846            caminho: "   ../caixa-teia".into(),
9847        });
9848        let err = d.validate().unwrap_err();
9849        assert!(
9850            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9851            "got {err:?}",
9852        );
9853    }
9854
9855    #[test]
9856    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9857        // The leading-space is the canonical paste-from-aligned-doc
9858        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9859        // canonical "I have a directory with a space in its name"
9860        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9861        // legitimate path with no whitespace-leak semantic at the
9862        // non-leading position. Pinned so the gate doesn't widen to a
9863        // full no-space-anywhere sweep that would break every
9864        // legitimate-shape space-in-filename path.
9865        let d = dep_with_fonte(DepSource::Path {
9866            caminho: "../my dir/caixa-teia".into(),
9867        });
9868        d.validate().unwrap();
9869    }
9870
9871    #[test]
9872    fn fonte_caminho_var_fires_before_leading_whitespace() {
9873        // Cascade pin: the var-expansion arm structurally precedes the
9874        // leading-whitespace arm. A value like `"$ "` would probe positive
9875        // on var (`starts_with('$')`) but the leading-byte arms walk
9876        // left-to-right so the var arm fires on the leading `$` before
9877        // the leading-whitespace arm probes. Mirrors the
9878        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9879        // discipline on the immediate-predecessor arms.
9880        let d = dep_with_fonte(DepSource::Path {
9881            caminho: "$VAR".into(),
9882        });
9883        let err = d.validate().unwrap_err();
9884        assert!(
9885            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9886            "got {err:?}",
9887        );
9888    }
9889
9890    #[test]
9891    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9892        // Cascade pin: the leading-whitespace arm structurally precedes
9893        // the control-char arm. A value like `" ../foo\n"` probes
9894        // positive on both (starts with space AND contains LF), but
9895        // the narrower leading-byte diagnostic
9896        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9897        // more self-locating paste-from-aligned-doc arm first. Mirrors
9898        // the `fonte_caminho_var_fires_before_control_char` cascade
9899        // discipline on the immediate-predecessor arm.
9900        let d = dep_with_fonte(DepSource::Path {
9901            caminho: " ../foo\n".into(),
9902        });
9903        let err = d.validate().unwrap_err();
9904        assert!(
9905            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9906            "got {err:?}",
9907        );
9908    }
9909
9910    #[test]
9911    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9912        // Diagnostic-shape pin (peer with
9913        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9914        // payload assertion on the immediate-predecessor arm): the
9915        // error's Display surfaces both the offending `:nome` and the
9916        // offending `:caminho` verbatim, so a `feira lint` run can
9917        // render the diagnostic without re-parsing and the author can
9918        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9919        // one edit.
9920        let d = dep_with_fonte(DepSource::Path {
9921            caminho: " ../caixa-teia".into(),
9922        });
9923        let rendered = d.validate().unwrap_err().to_string();
9924        assert!(
9925            rendered.contains("caixa-teia"),
9926            "diagnostic must name the offending dep: {rendered}",
9927        );
9928        assert!(
9929            rendered.contains(" ../caixa-teia"),
9930            "diagnostic must quote the offending caminho: {rendered}",
9931        );
9932        assert!(
9933            rendered.contains("space"),
9934            "diagnostic must name the space footgun: {rendered}",
9935        );
9936    }
9937
9938    #[test]
9939    fn fonte_caminho_absolute_fires_before_control_char() {
9940        // Cascade pin on the sibling leading-byte arm: a leading `/`
9941        // value with embedded control byte (`"/etc/passwd\n"`) routes
9942        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9943        // — the host-layout-leak diagnostic is the load-bearing axis,
9944        // the control byte is the secondary observation. Same precedence
9945        // logic on every prior leading-byte arm.
9946        let d = dep_with_fonte(DepSource::Path {
9947            caminho: "/etc/passwd\n".into(),
9948        });
9949        let err = d.validate().unwrap_err();
9950        assert!(
9951            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9952            "got {err:?}",
9953        );
9954    }
9955
9956    #[test]
9957    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9958        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9959        // injection `:caminho` shape sweep. Until this gate landed
9960        // every prior leading-byte arm passed a leading-`-` value
9961        // through: `Path::is_absolute` returns false on `-` (the
9962        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9963        // `starts_with('$')` / `starts_with(' ')` all return false,
9964        // and `0x2D` sits outside the control-byte set. The lacre
9965        // embedded the value verbatim and the resolver folded it
9966        // through `Path::join` looking for a literal `./-rf` /
9967        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9968        // `Path::join` time is non-self-locating but harmless, while
9969        // the failure at every downstream `git -C {caminho}` /
9970        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9971        // is arbitrary-CLI-arg-injection because none of those
9972        // porcelains carry a `--` argument-list terminator between
9973        // the flag block and the path argument. The new arm moves the
9974        // rejection to `Caixa::from_lisp` boundary time and names
9975        // the offending dep + caminho verbatim.
9976        //
9977        // Sweep spans the canonical CLI-arg-injection shapes matching
9978        // the peer sweep on the sibling `is_git_ref_name` /
9979        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9980        // `find -rf` reinterpretation vector), `-C` (the `git -C`
9981        // change-directory-config-injection paste), long-flag
9982        // `--upload-pack=cat /etc/passwd` (the canonical
9983        // arbitrary-command-execution vector on every git porcelain
9984        // entry point), git-config-injection `--config=core.merge=ours`,
9985        // and the degenerate single-byte `-` value.
9986        for caminho in [
9987            "-rf",
9988            "-C",
9989            "--upload-pack=cat /etc/passwd",
9990            "--config=core.merge=ours",
9991            "-",
9992        ] {
9993            let d = dep_with_fonte(DepSource::Path {
9994                caminho: caminho.into(),
9995            });
9996            let err = d.validate().unwrap_err();
9997            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9998                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9999            };
10000            assert_eq!(nome, "caixa-teia");
10001            assert_eq!(got, caminho);
10002        }
10003    }
10004
10005    #[test]
10006    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10007        // The leading-`-` is the canonical CLI-arg-injection footgun
10008        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10009        // canonical kebab-separator-between-alphanumeric-segments
10010        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10011        // — a mid-path segment starting with `-`, still a legitimate
10012        // POSIX filename byte at that non-leading position because the
10013        // subprocess reads the whole `{caminho}` value as one positional
10014        // argument, so only the very first byte of the composite path
10015        // string is at the CLI-arg-injection boundary) is a legitimate
10016        // path with no CLI-flag-reinterpretation semantic at the non-
10017        // leading position of the top-level value. Pinned so the gate
10018        // doesn't widen to a full no-`-`-anywhere sweep that would
10019        // break every legitimate-shape kebab-in-filename path (i.e.
10020        // essentially every sibling-workspace caixa dep).
10021        for caminho in [
10022            "../caixa-teia",
10023            "../caixa-teia/-hidden",
10024            "./my-lib",
10025            "../foo-bar/baz",
10026        ] {
10027            let d = dep_with_fonte(DepSource::Path {
10028                caminho: caminho.into(),
10029            });
10030            d.validate()
10031                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10032        }
10033    }
10034
10035    #[test]
10036    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10037        // Cascade pin: the leading-whitespace arm structurally precedes
10038        // the leading-hyphen arm. A value like `" -rf"` probes positive
10039        // on both (leading space AND, one byte in, a `-` — though the
10040        // leading-hyphen arm probes only the very first byte so it
10041        // wouldn't fire on this value; the pin instead documents the
10042        // arm order on the more common "leading space then a hyphen"
10043        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10044        // The narrower leading-space diagnostic (the paste-from-aligned-
10045        // doc footgun) wins so the author sees the more self-locating
10046        // whitespace arm first. Mirrors the
10047        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10048        // discipline on the immediate-predecessor arm.
10049        let d = dep_with_fonte(DepSource::Path {
10050            caminho: " -rf".into(),
10051        });
10052        let err = d.validate().unwrap_err();
10053        assert!(
10054            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10055            "got {err:?}",
10056        );
10057    }
10058
10059    #[test]
10060    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10061        // Cascade pin: the leading-hyphen arm structurally precedes
10062        // the control-char arm. A value like `"-rf\n"` probes positive
10063        // on both (starts with `-` AND contains LF), but the narrower
10064        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10065        // the author sees the more self-locating CLI-arg-injection arm
10066        // first. Mirrors the
10067        // `fonte_caminho_leading_whitespace_fires_before_control_char`
10068        // cascade discipline on the immediate-predecessor arm.
10069        let d = dep_with_fonte(DepSource::Path {
10070            caminho: "-rf\n".into(),
10071        });
10072        let err = d.validate().unwrap_err();
10073        assert!(
10074            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10075            "got {err:?}",
10076        );
10077    }
10078
10079    #[test]
10080    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10081        // Diagnostic-shape pin (peer with
10082        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10083        // payload assertion on the immediate-predecessor arm): the
10084        // error's Display surfaces both the offending `:nome` and the
10085        // offending `:caminho` verbatim plus the CLI-argument-injection
10086        // vocabulary, so a `feira lint` run can render the diagnostic
10087        // without re-parsing and the author can grep their caixa.lisp
10088        // for `:caminho "<value>"` and fix it in one edit.
10089        let d = dep_with_fonte(DepSource::Path {
10090            caminho: "--upload-pack=cat /etc/passwd".into(),
10091        });
10092        let rendered = d.validate().unwrap_err().to_string();
10093        assert!(
10094            rendered.contains("caixa-teia"),
10095            "diagnostic must name the offending dep: {rendered}",
10096        );
10097        assert!(
10098            rendered.contains("--upload-pack=cat /etc/passwd"),
10099            "diagnostic must quote the offending caminho: {rendered}",
10100        );
10101        assert!(
10102            rendered.contains("CLI-argument-injection"),
10103            "diagnostic must name the CLI-argument-injection vector: {rendered}",
10104        );
10105        assert!(
10106            rendered.contains("`-`"),
10107            "diagnostic must name the offending byte: {rendered}",
10108        );
10109    }
10110
10111    #[test]
10112    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10113        // Diagnostic-shape pin (peer with
10114        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10115        // payload assertion on the immediate-predecessor arm): the
10116        // error's Display surfaces the offending `:nome`, the
10117        // offending `:caminho` verbatim, and the offending byte in
10118        // hex form (`0x09` for tab) so a `feira lint` run can render
10119        // the diagnostic without re-parsing.
10120        let d = dep_with_fonte(DepSource::Path {
10121            caminho: "../caixa\tteia".into(),
10122        });
10123        let rendered = d.validate().unwrap_err().to_string();
10124        assert!(
10125            rendered.contains("caixa-teia"),
10126            "diagnostic must name the offending dep: {rendered}",
10127        );
10128        assert!(
10129            rendered.contains("../caixa\tteia"),
10130            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10131        );
10132        assert!(
10133            rendered.contains("0x09"),
10134            "diagnostic must name the offending byte in hex: {rendered:?}",
10135        );
10136    }
10137
10138    #[test]
10139    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10140        // The fail-before-pass-after pin for the canonical Windows-
10141        // path-separator paste footgun: an author who pastes a path
10142        // from Windows-Explorer's `Copy as path`, PowerShell's
10143        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10144        // produces `..\caixa-teia`-shape values that silently passed
10145        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10146        // false; `\` is neither a leading-byte sentinel nor a
10147        // control byte). On POSIX resolvers the value rides through
10148        // `Path::join` as a literal directory name and fails at
10149        // resolve time with `No such file or directory`; on Windows
10150        // resolvers the value resolves to the parent's sibling — two
10151        // distinct directories for the byte-identical caixa.lisp.
10152        // The new arm moves the rejection to validate time and names
10153        // the offending dep + caminho verbatim.
10154        let d = dep_with_fonte(DepSource::Path {
10155            caminho: "..\\caixa-teia".into(),
10156        });
10157        let err = d.validate().unwrap_err();
10158        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10159            panic!("expected FonteCaminhoBackslash, got {err:?}");
10160        };
10161        assert_eq!(nome, "caixa-teia");
10162        assert_eq!(caminho, "..\\caixa-teia");
10163    }
10164
10165    #[test]
10166    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10167        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10168        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10169        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10170        // false (POSIX absolute paths start with `/`, drive letters
10171        // are not a POSIX concept), so the b94fd83 absolute arm
10172        // doesn't fire; the value contains `\` bytes that this arm
10173        // now catches with the more self-locating Windows-path-
10174        // separator diagnostic. Pinned separately from the bare
10175        // `..\caixa-teia` shape so a future arm that targets only
10176        // leading-`..\` doesn't regress the drive-letter coverage.
10177        let d = dep_with_fonte(DepSource::Path {
10178            caminho: "C:\\work\\caixa-teia".into(),
10179        });
10180        let err = d.validate().unwrap_err();
10181        assert!(
10182            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10183            "got {err:?}",
10184        );
10185    }
10186
10187    #[test]
10188    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10189        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10190        // PowerShell tab-completion-on-a-directory append). Pinned
10191        // separately from the embedded-`\` shape so the gate's
10192        // contract is "any `\` anywhere", not "any `\` not at end".
10193        let d = dep_with_fonte(DepSource::Path {
10194            caminho: "..\\caixa-teia\\".into(),
10195        });
10196        let err = d.validate().unwrap_err();
10197        assert!(
10198            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10199            "got {err:?}",
10200        );
10201    }
10202
10203    #[test]
10204    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10205        // The positive-control pin: the gate targets `\` only,
10206        // never `/`. The canonical relative POSIX path
10207        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10208        // so legitimate nested-directory deps aren't broken. Pinned
10209        // so the gate doesn't accidentally widen to a "no path
10210        // separators at all" sweep.
10211        let d = dep_with_fonte(DepSource::Path {
10212            caminho: "../caixa-teia/foo/bar".into(),
10213        });
10214        d.validate().unwrap();
10215    }
10216
10217    #[test]
10218    fn fonte_caminho_control_char_fires_before_backslash() {
10219        // Cascade pin: the control-char arm structurally precedes the
10220        // backslash arm. A value like `"..\caixa\0teia"` probes
10221        // positive on both (`\` byte + NUL byte), but the control-
10222        // char diagnostic wins so the author sees the more self-
10223        // locating POSIX-syscall-rejected-byte diagnostic first
10224        // (NUL outright breaks `CString::new` at every `std::fs`
10225        // syscall boundary; the `\` divergence is the cross-OS-
10226        // separator axis). Mirrors the
10227        // `fonte_caminho_var_fires_before_control_char` cascade
10228        // discipline on the immediate-predecessor arm.
10229        let d = dep_with_fonte(DepSource::Path {
10230            caminho: "..\\caixa\0teia".into(),
10231        });
10232        let err = d.validate().unwrap_err();
10233        assert!(
10234            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10235            "got {err:?}",
10236        );
10237    }
10238
10239    #[test]
10240    fn fonte_caminho_absolute_fires_before_backslash() {
10241        // Cascade pin on the load-bearing leading-byte arm: a leading
10242        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10243        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10244        // — the host-layout-leak diagnostic is the load-bearing
10245        // axis, the `\` byte is the secondary observation. Same
10246        // precedence logic as every prior leading-byte arm.
10247        let d = dep_with_fonte(DepSource::Path {
10248            caminho: "/etc/passwd\\foo".into(),
10249        });
10250        let err = d.validate().unwrap_err();
10251        assert!(
10252            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10253            "got {err:?}",
10254        );
10255    }
10256
10257    #[test]
10258    fn fonte_caminho_var_fires_before_backslash() {
10259        // Cascade pin on the var-expansion arm: a leading-`$` value
10260        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10261        // PowerShell-env-var paste-from-CI-manifest footgun) routes
10262        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10263        // The shell-expansion diagnostic is the more self-locating
10264        // axis since both the leading `$` and the embedded `\`
10265        // are Windows-shell artifacts but the `$` is the root-cause
10266        // surface (an author who removes the `$` is likely to leave
10267        // the `\` too).
10268        let d = dep_with_fonte(DepSource::Path {
10269            caminho: "$WORKSPACE\\caixa-teia".into(),
10270        });
10271        let err = d.validate().unwrap_err();
10272        assert!(
10273            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10274            "got {err:?}",
10275        );
10276    }
10277
10278    #[test]
10279    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10280        // Diagnostic-shape pin (peer with the prior
10281        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10282        // on every preceding arm): the error's Display surfaces the
10283        // offending `:nome` and the offending `:caminho` verbatim
10284        // so a `feira lint` run can render the diagnostic without
10285        // re-parsing.
10286        let d = dep_with_fonte(DepSource::Path {
10287            caminho: "..\\caixa-teia".into(),
10288        });
10289        let rendered = d.validate().unwrap_err().to_string();
10290        assert!(
10291            rendered.contains("caixa-teia"),
10292            "diagnostic must name the offending dep: {rendered}",
10293        );
10294        assert!(
10295            rendered.contains("..\\caixa-teia"),
10296            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10297        );
10298        assert!(
10299            rendered.contains('\\'),
10300            "diagnostic must reference the backslash footgun: {rendered:?}",
10301        );
10302    }
10303
10304    #[test]
10305    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10306        // The fail-before-pass-after pin for the canonical trailing-`/`
10307        // paste footgun: an author who shell-tab-completes a sibling
10308        // directory (every interactive shell — bash/zsh/fish/nushell —
10309        // appends `/` on tab-completing a directory) produces
10310        // `"../caixa-teia/"`-shape values that silently passed every
10311        // prior arm (the leading byte is `.`, no control bytes, no
10312        // backslash). `Path::join` resolves both shapes to the same
10313        // directory at the resolver, but the lacre embeds the value
10314        // verbatim and the BLAKE3 closures diverge across two
10315        // workstations whose authors differ only in tab-completion
10316        // habits.
10317        let d = dep_with_fonte(DepSource::Path {
10318            caminho: "../caixa-teia/".into(),
10319        });
10320        let err = d.validate().unwrap_err();
10321        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10322            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10323        };
10324        assert_eq!(nome, "caixa-teia");
10325        assert_eq!(caminho, "../caixa-teia/");
10326    }
10327
10328    #[test]
10329    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10330        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10331        // directory and tab-completed it" footgun). Pinned separately
10332        // from the canonical `"../caixa-teia/"` shape so the gate's
10333        // contract is "any trailing `/`", not "trailing `/` after a leaf
10334        // name".
10335        let d = dep_with_fonte(DepSource::Path {
10336            caminho: "./".into(),
10337        });
10338        let err = d.validate().unwrap_err();
10339        assert!(
10340            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10341            "got {err:?}",
10342        );
10343    }
10344
10345    #[test]
10346    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10347        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10348        // that double-templated `${VAR}/` over an already-`/`-suffixed
10349        // path" footgun). The gate fires on the last byte being `/`
10350        // regardless of how many `/` precede it; the arm contract is
10351        // "the value ends with `/`", structurally.
10352        let d = dep_with_fonte(DepSource::Path {
10353            caminho: "../caixa-teia//".into(),
10354        });
10355        let err = d.validate().unwrap_err();
10356        assert!(
10357            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10358            "got {err:?}",
10359        );
10360    }
10361
10362    #[test]
10363    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10364        // The `"../"` shape (the canonical "I want the parent" tab-
10365        // completion footgun on a bare `..` path). Pinned separately so
10366        // the gate doesn't accidentally narrow to "trailing `/` only on
10367        // multi-segment paths".
10368        let d = dep_with_fonte(DepSource::Path {
10369            caminho: "../".into(),
10370        });
10371        let err = d.validate().unwrap_err();
10372        assert!(
10373            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10374            "got {err:?}",
10375        );
10376    }
10377
10378    #[test]
10379    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10380        // The positive-control pin: the gate targets the trailing byte
10381        // only, never internal `/` separators. The canonical nested
10382        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10383        // to validate cleanly so legitimate deeply-nested deps aren't
10384        // broken. Pinned so the gate doesn't accidentally widen to a
10385        // "no `/` separators anywhere" sweep that would defeat the
10386        // entire path-fonte author surface.
10387        let d = dep_with_fonte(DepSource::Path {
10388            caminho: "../caixa-teia/foo/bar".into(),
10389        });
10390        d.validate().unwrap();
10391    }
10392
10393    #[test]
10394    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10395        // The positive-control pin on the degenerate single-`.` shape
10396        // (the canonical "the caixa.lisp's own directory" idiom). The
10397        // gate fires on the trailing byte being `/`, not on the path
10398        // being short, so `"."` (one byte, not `/`) must continue to
10399        // validate cleanly.
10400        let d = dep_with_fonte(DepSource::Path {
10401            caminho: ".".into(),
10402        });
10403        d.validate().unwrap();
10404    }
10405
10406    #[test]
10407    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10408        // Cascade pin: the control-char arm structurally precedes the
10409        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10410        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10411        // (control bytes are the paste-from-multiline-doc footgun the
10412        // d624c8d arm already closes). Mirrors the
10413        // `fonte_caminho_control_char_fires_before_backslash` cascade
10414        // discipline on the immediate-predecessor arm.
10415        let d = dep_with_fonte(DepSource::Path {
10416            caminho: "../foo\n/".into(),
10417        });
10418        let err = d.validate().unwrap_err();
10419        assert!(
10420            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10421            "got {err:?}",
10422        );
10423    }
10424
10425    #[test]
10426    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10427        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10428        // ends in `/` but the embedded `\` is the load-bearing
10429        // diagnostic (the cross-host-OS-separator divergence vector
10430        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10431        // narrower-diagnostic-first cascade.
10432        let d = dep_with_fonte(DepSource::Path {
10433            caminho: "..\\caixa-teia/".into(),
10434        });
10435        let err = d.validate().unwrap_err();
10436        assert!(
10437            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10438            "got {err:?}",
10439        );
10440    }
10441
10442    #[test]
10443    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10444        // Cascade pin on the load-bearing leading-byte arm: a leading
10445        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10446        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10447        // — the host-layout-leak diagnostic is the load-bearing axis,
10448        // the trailing `/` is the secondary observation. Same
10449        // precedence logic as every prior leading-byte arm.
10450        let d = dep_with_fonte(DepSource::Path {
10451            caminho: "/etc/passwd/".into(),
10452        });
10453        let err = d.validate().unwrap_err();
10454        assert!(
10455            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10456            "got {err:?}",
10457        );
10458    }
10459
10460    #[test]
10461    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10462        // Diagnostic-shape pin (peer with the prior
10463        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10464        // every preceding arm): the error's Display surfaces the
10465        // offending `:nome` and the offending `:caminho` verbatim so a
10466        // `feira lint` run can render the diagnostic without re-parsing.
10467        let d = dep_with_fonte(DepSource::Path {
10468            caminho: "../caixa-teia/".into(),
10469        });
10470        let rendered = d.validate().unwrap_err().to_string();
10471        assert!(
10472            rendered.contains("caixa-teia"),
10473            "diagnostic must name the offending dep: {rendered}",
10474        );
10475        assert!(
10476            rendered.contains("../caixa-teia/"),
10477            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10478        );
10479        assert!(
10480            rendered.contains("trailing"),
10481            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10482        );
10483    }
10484
10485    // -- :caminho shell-redirection metacharacter arm -----------------------
10486
10487    #[test]
10488    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10489        // The fail-before-pass-after pin for the canonical output-redirection
10490        // paste footgun: an author copies a shell pipeline tail
10491        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10492        // line including the `> build.log` redirect" idiom) and silently
10493        // passed every prior arm (`Path::is_absolute` false on `..`, no
10494        // control bytes, no backslash, doesn't end in `/`). The lacre
10495        // embedded the value verbatim, the resolver folded it through
10496        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10497        // subdirectory, and the failure surfaced at resolve time with a
10498        // non-self-locating `No such file or directory` error. The new arm
10499        // moves the rejection to validate time and names the offending dep
10500        // + caminho + byte verbatim.
10501        let d = dep_with_fonte(DepSource::Path {
10502            caminho: "../caixa-teia>build.log".into(),
10503        });
10504        let err = d.validate().unwrap_err();
10505        let DepError::FonteCaminhoShellRedirection {
10506            nome,
10507            caminho,
10508            byte,
10509        } = err
10510        else {
10511            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10512        };
10513        assert_eq!(nome, "caixa-teia");
10514        assert_eq!(caminho, "../caixa-teia>build.log");
10515        assert_eq!(byte, b'>');
10516    }
10517
10518    #[test]
10519    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10520        // The symmetric input-redirection paste shape
10521        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10522        // `command < input.lisp` line from a tatara-lisp REPL log"
10523        // idiom). Pinned separately from the `>` shape so the gate's
10524        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10525        let d = dep_with_fonte(DepSource::Path {
10526            caminho: "../caixa-teia<input.lisp".into(),
10527        });
10528        let err = d.validate().unwrap_err();
10529        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10530            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10531        };
10532        assert_eq!(byte, b'<');
10533    }
10534
10535    #[test]
10536    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10537        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10538        // "I forgot the source side of the redirect" idiom). Pinned
10539        // separately from the embedded-byte shapes so the gate covers
10540        // every position, not only mid-path.
10541        let d = dep_with_fonte(DepSource::Path {
10542            caminho: ">../caixa-teia".into(),
10543        });
10544        let err = d.validate().unwrap_err();
10545        assert!(
10546            matches!(
10547                err,
10548                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10549            ),
10550            "got {err:?}",
10551        );
10552    }
10553
10554    #[test]
10555    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10556        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10557        // the canonical "I copied a `>>` append redirect" idiom). The arm
10558        // fires on the first `>` encountered; pinned so a future arm that
10559        // tries to distinguish `>` from `>>` doesn't break the broader
10560        // contract.
10561        let d = dep_with_fonte(DepSource::Path {
10562            caminho: "../caixa-teia>>build.log".into(),
10563        });
10564        let err = d.validate().unwrap_err();
10565        assert!(
10566            matches!(
10567                err,
10568                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10569            ),
10570            "got {err:?}",
10571        );
10572    }
10573
10574    #[test]
10575    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10576        // The positive-control pin: the gate targets only `<` / `>`,
10577        // never adjacent printable ASCII or POSIX-valid bytes. The
10578        // canonical relative POSIX path (`"../caixa-teia"`) and a
10579        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10580        // continue to validate cleanly so the gate doesn't widen to a
10581        // "no printable punctuation anywhere" sweep that would defeat
10582        // the entire path-fonte author surface.
10583        let d = dep_with_fonte(DepSource::Path {
10584            caminho: "../caixa-teia/foo/bar".into(),
10585        });
10586        d.validate().unwrap();
10587    }
10588
10589    #[test]
10590    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10591        // Cascade pin on the immediate-predecessor arm: a value carrying
10592        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10593        // canonical "I pasted a Windows-shell command with output
10594        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10595        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10596        // divergence is the load-bearing axis (an author who removes
10597        // the `\` is the root-cause edit; the `>` falls away in the
10598        // same edit since it's downstream of the Windows-shell
10599        // convention).
10600        let d = dep_with_fonte(DepSource::Path {
10601            caminho: "..\\caixa-teia>build.log".into(),
10602        });
10603        let err = d.validate().unwrap_err();
10604        assert!(
10605            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10606            "got {err:?}",
10607        );
10608    }
10609
10610    #[test]
10611    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10612        // Cascade pin on the embedded-control-byte arm: a value carrying
10613        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10614        // canonical paste-from-multiline-doc footgun where a newline
10615        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10616        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10617        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10618        // load-bearing axis on every value that probes positive for
10619        // both — mirrors the cascade discipline on every prior arm.
10620        let d = dep_with_fonte(DepSource::Path {
10621            caminho: "../foo\n>bar".into(),
10622        });
10623        let err = d.validate().unwrap_err();
10624        assert!(
10625            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10626            "got {err:?}",
10627        );
10628    }
10629
10630    #[test]
10631    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10632        // Cascade pin on the load-bearing leading-byte arm: a leading
10633        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10634        // routes through `FonteCaminhoAbsolute` not
10635        // `FonteCaminhoShellRedirection` — the host-layout-leak
10636        // diagnostic is the load-bearing axis, the `>` byte is the
10637        // secondary observation. Same precedence logic as every prior
10638        // leading-byte arm.
10639        let d = dep_with_fonte(DepSource::Path {
10640            caminho: "/etc/passwd>out".into(),
10641        });
10642        let err = d.validate().unwrap_err();
10643        assert!(
10644            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10645            "got {err:?}",
10646        );
10647    }
10648
10649    #[test]
10650    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10651        // Cascade pin on the immediate-successor arm: a value carrying
10652        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10653        // canonical "I tab-completed a path that already had a
10654        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10655        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10656        // the more semantic-locating axis (an author who removes the
10657        // `<` / `>` typically also drops the trailing separator since
10658        // both are paste-from-shell artifacts).
10659        let d = dep_with_fonte(DepSource::Path {
10660            caminho: "../foo></".into(),
10661        });
10662        let err = d.validate().unwrap_err();
10663        assert!(
10664            matches!(
10665                err,
10666                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10667            ),
10668            "got {err:?}",
10669        );
10670    }
10671
10672    #[test]
10673    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10674        // Diagnostic-shape pin (peer with
10675        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10676        // payload assertion on the closest peer arm that also carries a
10677        // `byte` field): the error's Display surfaces the offending
10678        // `:nome`, the offending `:caminho` verbatim, and the offending
10679        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10680        // run can render the diagnostic without re-parsing.
10681        let d = dep_with_fonte(DepSource::Path {
10682            caminho: "../caixa-teia>build.log".into(),
10683        });
10684        let rendered = d.validate().unwrap_err().to_string();
10685        assert!(
10686            rendered.contains("caixa-teia"),
10687            "diagnostic must name the offending dep: {rendered}",
10688        );
10689        assert!(
10690            rendered.contains("../caixa-teia>build.log"),
10691            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10692        );
10693        assert!(
10694            rendered.contains("0x3e"),
10695            "diagnostic must name the offending byte in hex: {rendered:?}",
10696        );
10697        assert!(
10698            rendered.contains("redirection"),
10699            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10700        );
10701    }
10702
10703    // -- :caminho shell-pipe metacharacter arm ----------------------------
10704
10705    #[test]
10706    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10707        // The fail-before-pass-after pin for the canonical shell-pipe
10708        // paste footgun: an author copies a shell-history line
10709        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10710        // the whole `ls dir | grep` line out of zsh history") and
10711        // silently passed every prior arm (`Path::is_absolute` false
10712        // on `..`, no control bytes, no backslash, no `<` / `>`,
10713        // doesn't end in `/`). The lacre embedded the value verbatim,
10714        // the resolver folded it through `Path::join` looking for a
10715        // literal `./../caixa-teia | grep foo` subdirectory, and the
10716        // failure surfaced at resolve time with a non-self-locating
10717        // `No such file or directory` error. The new arm moves the
10718        // rejection to validate time and names the offending dep +
10719        // caminho verbatim.
10720        let d = dep_with_fonte(DepSource::Path {
10721            caminho: "../caixa-teia | grep foo".into(),
10722        });
10723        let err = d.validate().unwrap_err();
10724        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10725            panic!("expected FonteCaminhoShellPipe, got {err:?}");
10726        };
10727        assert_eq!(nome, "caixa-teia");
10728        assert_eq!(caminho, "../caixa-teia | grep foo");
10729    }
10730
10731    #[test]
10732    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10733        // Leading-position `|` shape (`"|../caixa-teia"` — the
10734        // degenerate "I forgot the source side of the pipe" idiom).
10735        // Pinned separately from the embedded-byte shape so the gate
10736        // covers every position, not only mid-path.
10737        let d = dep_with_fonte(DepSource::Path {
10738            caminho: "|../caixa-teia".into(),
10739        });
10740        let err = d.validate().unwrap_err();
10741        assert!(
10742            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10743            "got {err:?}",
10744        );
10745    }
10746
10747    #[test]
10748    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10749        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10750        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10751        // idiom). The arm fires on the first `|` encountered; pinned
10752        // so a future arm that tries to distinguish `|` from `||`
10753        // doesn't break the broader contract.
10754        let d = dep_with_fonte(DepSource::Path {
10755            caminho: "../caixa-teia||fallback".into(),
10756        });
10757        let err = d.validate().unwrap_err();
10758        assert!(
10759            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10760            "got {err:?}",
10761        );
10762    }
10763
10764    #[test]
10765    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10766        // The positive-control pin: the gate targets only `|`, never
10767        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10768        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10769        // pathed variant with adjacent printable punctuation
10770        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10771        // cleanly so the gate doesn't widen to a "no printable
10772        // punctuation anywhere" sweep that would defeat the entire
10773        // path-fonte author surface.
10774        let d = dep_with_fonte(DepSource::Path {
10775            caminho: "../caixa-teia/sub-dir.v2".into(),
10776        });
10777        d.validate().unwrap();
10778    }
10779
10780    #[test]
10781    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10782        // Cascade pin on the immediate-predecessor arm: a value carrying
10783        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10784        // canonical "I pasted a `cmd < input | tee` pipeline tail"
10785        // footgun) routes through `FonteCaminhoShellRedirection` not
10786        // `FonteCaminhoShellPipe`. The input/output redirection
10787        // metachar carries the more self-locating `byte: u8` payload
10788        // (it names which of `<` or `>` triggered), so the prior arm
10789        // wins on every probe-as-both value — same cascade discipline
10790        // every prior `:caminho` arm establishes.
10791        let d = dep_with_fonte(DepSource::Path {
10792            caminho: "../caixa-teia<input|tee".into(),
10793        });
10794        let err = d.validate().unwrap_err();
10795        assert!(
10796            matches!(
10797                err,
10798                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10799            ),
10800            "got {err:?}",
10801        );
10802    }
10803
10804    #[test]
10805    fn fonte_caminho_backslash_fires_before_shell_pipe() {
10806        // Cascade pin on the upstream backslash arm: a value carrying
10807        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10808        // "I pasted a Windows-shell command with pipe to tee"
10809        // footgun) routes through `FonteCaminhoBackslash` not
10810        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10811        // divergence is the load-bearing axis on every probe-as-both
10812        // value (an author who removes the `\` is the root-cause edit;
10813        // the `|` falls away in the same edit since it's downstream of
10814        // the Windows-shell convention).
10815        let d = dep_with_fonte(DepSource::Path {
10816            caminho: "..\\caixa-teia|tee".into(),
10817        });
10818        let err = d.validate().unwrap_err();
10819        assert!(
10820            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10821            "got {err:?}",
10822        );
10823    }
10824
10825    #[test]
10826    fn fonte_caminho_control_char_fires_before_shell_pipe() {
10827        // Cascade pin on the embedded-control-byte arm: a value
10828        // carrying both a control byte and `|` (`"../foo\n|bar"` —
10829        // the canonical paste-from-multiline-doc footgun where a
10830        // newline landed mid-caminho) routes through
10831        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10832        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10833        // diagnostic is the load-bearing axis on every value that
10834        // probes positive for both — mirrors the cascade discipline
10835        // on every prior arm.
10836        let d = dep_with_fonte(DepSource::Path {
10837            caminho: "../foo\n|bar".into(),
10838        });
10839        let err = d.validate().unwrap_err();
10840        assert!(
10841            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10842            "got {err:?}",
10843        );
10844    }
10845
10846    #[test]
10847    fn fonte_caminho_absolute_fires_before_shell_pipe() {
10848        // Cascade pin on the load-bearing leading-byte arm: a leading
10849        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10850        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10851        // — the host-layout-leak diagnostic is the load-bearing axis,
10852        // the `|` byte is the secondary observation. Same precedence
10853        // logic as every prior leading-byte arm.
10854        let d = dep_with_fonte(DepSource::Path {
10855            caminho: "/etc/passwd|tee".into(),
10856        });
10857        let err = d.validate().unwrap_err();
10858        assert!(
10859            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10860            "got {err:?}",
10861        );
10862    }
10863
10864    #[test]
10865    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10866        // Cascade pin on the immediate-successor arm: a value carrying
10867        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10868        // "I tab-completed a path that already had a pipeline tail"
10869        // footgun) routes through `FonteCaminhoShellPipe` not
10870        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10871        // the more semantic-locating axis (an author who removes the
10872        // `|` typically also drops the trailing separator since both
10873        // are paste-from-shell artifacts).
10874        let d = dep_with_fonte(DepSource::Path {
10875            caminho: "../foo|tee/".into(),
10876        });
10877        let err = d.validate().unwrap_err();
10878        assert!(
10879            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10880            "got {err:?}",
10881        );
10882    }
10883
10884    #[test]
10885    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10886        // Diagnostic-shape pin (peer with
10887        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10888        // on the closest single-byte peer arm): the error's Display
10889        // surfaces the offending `:nome` and the offending `:caminho`
10890        // verbatim, and names the shell-pipe footgun explicitly so a
10891        // `feira lint` run can render the diagnostic without
10892        // re-parsing.
10893        let d = dep_with_fonte(DepSource::Path {
10894            caminho: "../caixa-teia | grep foo".into(),
10895        });
10896        let rendered = d.validate().unwrap_err().to_string();
10897        assert!(
10898            rendered.contains("caixa-teia"),
10899            "diagnostic must name the offending dep: {rendered}",
10900        );
10901        assert!(
10902            rendered.contains("../caixa-teia | grep foo"),
10903            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10904        );
10905        assert!(
10906            rendered.contains('|'),
10907            "diagnostic must reference the pipe footgun: {rendered:?}",
10908        );
10909        assert!(
10910            rendered.contains("pipe"),
10911            "diagnostic must name the shell-pipe footgun: {rendered:?}",
10912        );
10913    }
10914
10915    // -- :caminho shell-command-separator metacharacter arm ---------------
10916
10917    #[test]
10918    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10919        // The fail-before-pass-after pin for the canonical shell-command-
10920        // separator paste footgun: an author copies a shell one-liner
10921        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10922        // whole `cd path; do-thing` chain out of a shell-history block")
10923        // and silently passed every prior arm (`Path::is_absolute` false
10924        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10925        // doesn't end in `/`). The lacre embedded the value verbatim, the
10926        // resolver folded it through `Path::join` looking for a literal
10927        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10928        // surfaced at resolve time with a non-self-locating `No such file
10929        // or directory` error. The new arm moves the rejection to validate
10930        // time and names the offending dep + caminho verbatim.
10931        let d = dep_with_fonte(DepSource::Path {
10932            caminho: "../caixa-teia; rm -rf build".into(),
10933        });
10934        let err = d.validate().unwrap_err();
10935        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10936            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10937        };
10938        assert_eq!(nome, "caixa-teia");
10939        assert_eq!(caminho, "../caixa-teia; rm -rf build");
10940    }
10941
10942    #[test]
10943    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10944        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10945        // "I forgot the prior command side of the separator" idiom).
10946        // Pinned separately from the embedded-byte shape so the gate
10947        // covers every position, not only mid-path.
10948        let d = dep_with_fonte(DepSource::Path {
10949            caminho: ";../caixa-teia".into(),
10950        });
10951        let err = d.validate().unwrap_err();
10952        assert!(
10953            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10954            "got {err:?}",
10955        );
10956    }
10957
10958    #[test]
10959    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10960        // The POSIX `case` arm `;;` terminator shape
10961        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10962        // arm tail" idiom). The arm fires on the first `;` encountered;
10963        // pinned so a future arm that tries to distinguish `;` from `;;`
10964        // doesn't break the broader contract.
10965        let d = dep_with_fonte(DepSource::Path {
10966            caminho: "../caixa-teia;;next".into(),
10967        });
10968        let err = d.validate().unwrap_err();
10969        assert!(
10970            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10971            "got {err:?}",
10972        );
10973    }
10974
10975    #[test]
10976    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10977        // The positive-control pin: the gate targets only `;`, never
10978        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10979        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10980        // pathed variant with adjacent printable punctuation
10981        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10982        // cleanly so the gate doesn't widen to a "no printable
10983        // punctuation anywhere" sweep that would defeat the entire
10984        // path-fonte author surface.
10985        let d = dep_with_fonte(DepSource::Path {
10986            caminho: "../caixa-teia/sub-dir.v2".into(),
10987        });
10988        d.validate().unwrap();
10989    }
10990
10991    #[test]
10992    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10993        // Cascade pin on the immediate-predecessor arm: a value carrying
10994        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10995        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10996        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10997        // pipeline-tail paste is the load-bearing root-cause edit on
10998        // every probe-as-both value (an author who removes the `|`
10999        // typically also drops the trailing `; cleanup` since both are
11000        // the same paste-from-shell-history artifact) — same cascade
11001        // discipline every prior `:caminho` arm establishes.
11002        let d = dep_with_fonte(DepSource::Path {
11003            caminho: "../caixa-teia | tee; rm".into(),
11004        });
11005        let err = d.validate().unwrap_err();
11006        assert!(
11007            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11008            "got {err:?}",
11009        );
11010    }
11011
11012    #[test]
11013    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11014        // Cascade pin on the upstream shell-redirection arm: a value
11015        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11016        // the canonical "I pasted a `cmd > log; cleanup` chain"
11017        // footgun) routes through `FonteCaminhoShellRedirection` not
11018        // `FonteCaminhoShellSemicolon`. The input/output redirection
11019        // metachar carries the more self-locating `byte: u8` payload
11020        // (it names which of `<` or `>` triggered), so the prior arm
11021        // wins on every probe-as-both value.
11022        let d = dep_with_fonte(DepSource::Path {
11023            caminho: "../caixa-teia>log; rm".into(),
11024        });
11025        let err = d.validate().unwrap_err();
11026        assert!(
11027            matches!(
11028                err,
11029                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11030            ),
11031            "got {err:?}",
11032        );
11033    }
11034
11035    #[test]
11036    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11037        // Cascade pin on the upstream backslash arm: a value carrying
11038        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11039        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11040        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11041        // The cross-host-OS-separator divergence is the load-bearing axis
11042        // on every probe-as-both value (an author who removes the `\` is
11043        // the root-cause edit; the `;` falls away in the same edit since
11044        // it's downstream of the Windows-shell convention).
11045        let d = dep_with_fonte(DepSource::Path {
11046            caminho: "..\\caixa-teia;rm".into(),
11047        });
11048        let err = d.validate().unwrap_err();
11049        assert!(
11050            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11051            "got {err:?}",
11052        );
11053    }
11054
11055    #[test]
11056    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11057        // Cascade pin on the embedded-control-byte arm: a value carrying
11058        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11059        // paste-from-multiline-doc footgun where a newline landed mid-
11060        // caminho) routes through `FonteCaminhoControlChar` not
11061        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11062        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11063        // on every value that probes positive for both — mirrors the
11064        // cascade discipline on every prior arm.
11065        let d = dep_with_fonte(DepSource::Path {
11066            caminho: "../foo\n;bar".into(),
11067        });
11068        let err = d.validate().unwrap_err();
11069        assert!(
11070            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11071            "got {err:?}",
11072        );
11073    }
11074
11075    #[test]
11076    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11077        // Cascade pin on the load-bearing leading-byte arm: a leading
11078        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11079        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11080        // — the host-layout-leak diagnostic is the load-bearing axis,
11081        // the `;` byte is the secondary observation. Same precedence
11082        // logic as every prior leading-byte arm.
11083        let d = dep_with_fonte(DepSource::Path {
11084            caminho: "/etc/passwd;rm".into(),
11085        });
11086        let err = d.validate().unwrap_err();
11087        assert!(
11088            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11089            "got {err:?}",
11090        );
11091    }
11092
11093    #[test]
11094    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11095        // Cascade pin on the immediate-successor arm: a value carrying
11096        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11097        // "I tab-completed a path that already had a `; cleanup` tail"
11098        // footgun) routes through `FonteCaminhoShellSemicolon` not
11099        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11100        // the more semantic-locating axis (an author who removes the
11101        // `;` typically also drops the trailing separator since both
11102        // are paste-from-shell artifacts).
11103        let d = dep_with_fonte(DepSource::Path {
11104            caminho: "../foo;rm/".into(),
11105        });
11106        let err = d.validate().unwrap_err();
11107        assert!(
11108            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11109            "got {err:?}",
11110        );
11111    }
11112
11113    #[test]
11114    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11115        // Diagnostic-shape pin (peer with
11116        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11117        // on the closest single-byte peer arm): the error's Display
11118        // surfaces the offending `:nome` and the offending `:caminho`
11119        // verbatim, and names the shell-command-separator footgun
11120        // explicitly so a `feira lint` run can render the diagnostic
11121        // without re-parsing.
11122        let d = dep_with_fonte(DepSource::Path {
11123            caminho: "../caixa-teia; rm -rf build".into(),
11124        });
11125        let rendered = d.validate().unwrap_err().to_string();
11126        assert!(
11127            rendered.contains("caixa-teia"),
11128            "diagnostic must name the offending dep: {rendered}",
11129        );
11130        assert!(
11131            rendered.contains("../caixa-teia; rm -rf build"),
11132            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11133        );
11134        assert!(
11135            rendered.contains(';'),
11136            "diagnostic must reference the semicolon footgun: {rendered:?}",
11137        );
11138        assert!(
11139            rendered.contains("command-separator"),
11140            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11141        );
11142    }
11143
11144    #[test]
11145    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11146        // The fail-before-pass-after pin for the canonical shell-
11147        // background-task paste footgun: an author copies a shell one-
11148        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11149        // the whole `cd path & sleep 1` background-launch out of a
11150        // shell-history block") and silently passed every prior arm
11151        // (`Path::is_absolute` false on `..`, no control bytes, no
11152        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11153        // The lacre embedded the value verbatim, the resolver folded it
11154        // through `Path::join` looking for a literal `./../caixa-teia &
11155        // sleep 1` subdirectory, and the failure surfaced at resolve
11156        // time with a non-self-locating `No such file or directory`
11157        // error. The new arm moves the rejection to validate time and
11158        // names the offending dep + caminho verbatim.
11159        let d = dep_with_fonte(DepSource::Path {
11160            caminho: "../caixa-teia & sleep 1".into(),
11161        });
11162        let err = d.validate().unwrap_err();
11163        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11164            panic!("expected FonteCaminhoShellBackground, got {err:?}");
11165        };
11166        assert_eq!(nome, "caixa-teia");
11167        assert_eq!(caminho, "../caixa-teia & sleep 1");
11168    }
11169
11170    #[test]
11171    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11172        // Leading-position `&` shape (`"&../caixa-teia"` — the
11173        // degenerate "I forgot the prior command side of the
11174        // background terminator" idiom). Pinned separately from the
11175        // embedded-byte shape so the gate covers every position, not
11176        // only mid-path.
11177        let d = dep_with_fonte(DepSource::Path {
11178            caminho: "&../caixa-teia".into(),
11179        });
11180        let err = d.validate().unwrap_err();
11181        assert!(
11182            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11183            "got {err:?}",
11184        );
11185    }
11186
11187    #[test]
11188    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11189        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11190        // canonical "I copied a `cd path && make` build chain" idiom
11191        // every Makefile / shell-script wraps). The arm fires on the
11192        // first `&` encountered; pinned so a future arm that tries to
11193        // distinguish `&` from `&&` doesn't break the broader contract.
11194        let d = dep_with_fonte(DepSource::Path {
11195            caminho: "../caixa-teia && make".into(),
11196        });
11197        let err = d.validate().unwrap_err();
11198        assert!(
11199            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11200            "got {err:?}",
11201        );
11202    }
11203
11204    #[test]
11205    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11206        // The positive-control pin: the gate targets only `&`, never
11207        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11208        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11209        // pathed variant with adjacent printable punctuation
11210        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11211        // cleanly so the gate doesn't widen to a "no printable
11212        // punctuation anywhere" sweep that would defeat the entire
11213        // path-fonte author surface.
11214        let d = dep_with_fonte(DepSource::Path {
11215            caminho: "../caixa-teia/sub-dir.v2".into(),
11216        });
11217        d.validate().unwrap();
11218    }
11219
11220    #[test]
11221    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11222        // Cascade pin on the immediate-predecessor arm: a value carrying
11223        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11224        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11225        // routes through `FonteCaminhoShellSemicolon` not
11226        // `FonteCaminhoShellBackground`. The sequential-command-
11227        // separator paste is the more common shell-history paste idiom
11228        // on every probe-as-both value (an author who removes the `;`
11229        // typically also drops the trailing `& sleep` since both are
11230        // paste-from-shell-history artifacts) — same cascade discipline
11231        // every prior `:caminho` arm establishes.
11232        let d = dep_with_fonte(DepSource::Path {
11233            caminho: "../caixa-teia; rm & sleep".into(),
11234        });
11235        let err = d.validate().unwrap_err();
11236        assert!(
11237            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11238            "got {err:?}",
11239        );
11240    }
11241
11242    #[test]
11243    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11244        // Cascade pin on the upstream shell-pipe arm: a value carrying
11245        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11246        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11247        // chain" footgun) routes through `FonteCaminhoShellPipe` not
11248        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11249        // load-bearing root-cause edit on every probe-as-both value.
11250        let d = dep_with_fonte(DepSource::Path {
11251            caminho: "../caixa-teia | tee & sleep".into(),
11252        });
11253        let err = d.validate().unwrap_err();
11254        assert!(
11255            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11256            "got {err:?}",
11257        );
11258    }
11259
11260    #[test]
11261    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11262        // Cascade pin on the upstream shell-redirection arm: a value
11263        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11264        // the canonical "I pasted a `cmd > log & sleep` background-
11265        // redirect chain" footgun) routes through
11266        // `FonteCaminhoShellRedirection` not
11267        // `FonteCaminhoShellBackground`. The input/output redirection
11268        // metachar carries the more self-locating `byte: u8` payload
11269        // (it names which of `<` or `>` triggered), so the prior arm
11270        // wins on every probe-as-both value.
11271        let d = dep_with_fonte(DepSource::Path {
11272            caminho: "../caixa-teia>log & sleep".into(),
11273        });
11274        let err = d.validate().unwrap_err();
11275        assert!(
11276            matches!(
11277                err,
11278                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11279            ),
11280            "got {err:?}",
11281        );
11282    }
11283
11284    #[test]
11285    fn fonte_caminho_backslash_fires_before_shell_background() {
11286        // Cascade pin on the upstream backslash arm: a value carrying
11287        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11288        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11289        // launch chain") routes through `FonteCaminhoBackslash` not
11290        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11291        // divergence is the load-bearing axis on every probe-as-both
11292        // value (an author who removes the `\` is the root-cause edit;
11293        // the `&` falls away in the same edit since it's downstream of
11294        // the Windows-shell convention).
11295        let d = dep_with_fonte(DepSource::Path {
11296            caminho: "..\\caixa-teia & sleep".into(),
11297        });
11298        let err = d.validate().unwrap_err();
11299        assert!(
11300            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11301            "got {err:?}",
11302        );
11303    }
11304
11305    #[test]
11306    fn fonte_caminho_control_char_fires_before_shell_background() {
11307        // Cascade pin on the embedded-control-byte arm: a value
11308        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11309        // the canonical paste-from-multiline-doc footgun where a
11310        // newline landed mid-caminho) routes through
11311        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11312        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11313        // diagnostic is the load-bearing axis on every value that
11314        // probes positive for both — mirrors the cascade discipline on
11315        // every prior arm.
11316        let d = dep_with_fonte(DepSource::Path {
11317            caminho: "../foo\n&sleep".into(),
11318        });
11319        let err = d.validate().unwrap_err();
11320        assert!(
11321            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11322            "got {err:?}",
11323        );
11324    }
11325
11326    #[test]
11327    fn fonte_caminho_absolute_fires_before_shell_background() {
11328        // Cascade pin on the load-bearing leading-byte arm: a leading
11329        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11330        // through `FonteCaminhoAbsolute` not
11331        // `FonteCaminhoShellBackground` — the host-layout-leak
11332        // diagnostic is the load-bearing axis, the `&` byte is the
11333        // secondary observation. Same precedence logic as every prior
11334        // leading-byte arm.
11335        let d = dep_with_fonte(DepSource::Path {
11336            caminho: "/etc/passwd & sleep".into(),
11337        });
11338        let err = d.validate().unwrap_err();
11339        assert!(
11340            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11341            "got {err:?}",
11342        );
11343    }
11344
11345    #[test]
11346    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11347        // Cascade pin on the immediate-successor arm: a value carrying
11348        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11349        // canonical "I tab-completed a path that already had a `&
11350        // sleep` background-launch tail" footgun) routes through
11351        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11352        // The embedded shell-metachar is the more semantic-locating
11353        // axis (an author who removes the `&` typically also drops
11354        // the trailing separator since both are paste-from-shell
11355        // artifacts).
11356        let d = dep_with_fonte(DepSource::Path {
11357            caminho: "../foo&sleep/".into(),
11358        });
11359        let err = d.validate().unwrap_err();
11360        assert!(
11361            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11362            "got {err:?}",
11363        );
11364    }
11365
11366    #[test]
11367    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11368        // Diagnostic-shape pin (peer with
11369        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11370        // on the closest single-byte peer arm): the error's Display
11371        // surfaces the offending `:nome` and the offending `:caminho`
11372        // verbatim, and names the shell-background / logical-AND
11373        // footgun explicitly so a `feira lint` run can render the
11374        // diagnostic without re-parsing.
11375        let d = dep_with_fonte(DepSource::Path {
11376            caminho: "../caixa-teia & sleep 1".into(),
11377        });
11378        let rendered = d.validate().unwrap_err().to_string();
11379        assert!(
11380            rendered.contains("caixa-teia"),
11381            "diagnostic must name the offending dep: {rendered}",
11382        );
11383        assert!(
11384            rendered.contains("../caixa-teia & sleep 1"),
11385            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11386        );
11387        assert!(
11388            rendered.contains('&'),
11389            "diagnostic must reference the ampersand footgun: {rendered:?}",
11390        );
11391        assert!(
11392            rendered.contains("background") || rendered.contains("list-AND"),
11393            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11394        );
11395    }
11396
11397    #[test]
11398    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11399        // The fail-before-pass-after pin for the canonical shell-
11400        // command-substitution paste footgun: an author copies a
11401        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11402        // — the canonical "I pasted a path that included a `pwd`
11403        // / `whoami` / `date` legacy command-substitution expansion
11404        // out of a shell-history block") and silently passed every
11405        // prior arm (`Path::is_absolute` false on `..`, no control
11406        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11407        // end in `/`). The lacre embedded the value verbatim, the
11408        // resolver folded it through `Path::join` looking for a
11409        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11410        // failure surfaced at resolve time with a non-self-locating
11411        // `No such file or directory` error. The new arm moves the
11412        // rejection to validate time and names the offending dep +
11413        // caminho verbatim.
11414        let d = dep_with_fonte(DepSource::Path {
11415            caminho: "../caixa-teia/`whoami`".into(),
11416        });
11417        let err = d.validate().unwrap_err();
11418        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11419            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11420        };
11421        assert_eq!(nome, "caixa-teia");
11422        assert_eq!(caminho, "../caixa-teia/`whoami`");
11423    }
11424
11425    #[test]
11426    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11427        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11428        // the canonical `<backtick>pwd<backtick>/path` working-
11429        // directory expansion shape every shell-side path-composition
11430        // idiom carries). Pinned separately from the embedded-byte
11431        // shape so the gate covers every position, not only mid-path.
11432        let d = dep_with_fonte(DepSource::Path {
11433            caminho: "`pwd`/caixa-teia".into(),
11434        });
11435        let err = d.validate().unwrap_err();
11436        assert!(
11437            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11438            "got {err:?}",
11439        );
11440    }
11441
11442    #[test]
11443    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11444        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11445        // degenerate "I selected an unbalanced backtick out of a
11446        // shell-history block" idiom that probes for the cascade's
11447        // last-byte handling). The trailing-`/` arm fires only on
11448        // last-byte `/`; an unbalanced trailing backtick must route
11449        // through this arm regardless of position.
11450        let d = dep_with_fonte(DepSource::Path {
11451            caminho: "../caixa-teia`".into(),
11452        });
11453        let err = d.validate().unwrap_err();
11454        assert!(
11455            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11456            "got {err:?}",
11457        );
11458    }
11459
11460    #[test]
11461    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11462        // The canonical balanced-pair shape (``"../<backtick>cat
11463        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11464        // command-injection paste idiom every shell-side hardening
11465        // guide enumerates first). The arm fires on the first
11466        // backtick encountered; pinned so a future arm that tries to
11467        // distinguish the opening from the closing byte doesn't break
11468        // the broader contract.
11469        let d = dep_with_fonte(DepSource::Path {
11470            caminho: "../`cat /etc/passwd`".into(),
11471        });
11472        let err = d.validate().unwrap_err();
11473        assert!(
11474            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11475            "got {err:?}",
11476        );
11477    }
11478
11479    #[test]
11480    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11481        // The positive-control pin: the gate targets only the
11482        // backtick byte, never adjacent printable ASCII or POSIX-
11483        // valid bytes. The canonical relative POSIX path
11484        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11485        // adjacent printable punctuation
11486        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11487        // cleanly so the gate doesn't widen to a "no printable
11488        // punctuation anywhere" sweep that would defeat the entire
11489        // path-fonte author surface.
11490        let d = dep_with_fonte(DepSource::Path {
11491            caminho: "../caixa-teia/sub-dir.v2".into(),
11492        });
11493        d.validate().unwrap();
11494    }
11495
11496    #[test]
11497    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11498        // Cascade pin on the immediate-predecessor arm: a value
11499        // carrying both `&` and a backtick (``"../caixa-teia &
11500        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11501        // `cmd & <backtick>sleep N<backtick>` background-launch +
11502        // command-substitution chain" footgun) routes through
11503        // `FonteCaminhoShellBackground` not
11504        // `FonteCaminhoShellCommandSubstitution`. The background-
11505        // launch tail is the more common shell-history paste idiom
11506        // on every probe-as-both value — same cascade discipline
11507        // every prior `:caminho` arm establishes.
11508        let d = dep_with_fonte(DepSource::Path {
11509            caminho: "../caixa-teia & `sleep 1`".into(),
11510        });
11511        let err = d.validate().unwrap_err();
11512        assert!(
11513            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11514            "got {err:?}",
11515        );
11516    }
11517
11518    #[test]
11519    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11520        // Cascade pin on the upstream shell-semicolon arm: a value
11521        // carrying both `;` and a backtick (``"../caixa-teia;
11522        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11523        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11524        // footgun) routes through `FonteCaminhoShellSemicolon` not
11525        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11526        // command-separator paste is the load-bearing root-cause
11527        // edit on every probe-as-both value.
11528        let d = dep_with_fonte(DepSource::Path {
11529            caminho: "../caixa-teia; `whoami`".into(),
11530        });
11531        let err = d.validate().unwrap_err();
11532        assert!(
11533            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11534            "got {err:?}",
11535        );
11536    }
11537
11538    #[test]
11539    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11540        // Cascade pin on the upstream shell-pipe arm: a value
11541        // carrying both `|` and a backtick (``"../caixa-teia |
11542        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11543        // command-substitution paste idiom) routes through
11544        // `FonteCaminhoShellPipe` not
11545        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11546        // paste is the load-bearing root-cause edit on every
11547        // probe-as-both value.
11548        let d = dep_with_fonte(DepSource::Path {
11549            caminho: "../caixa-teia | `tee log`".into(),
11550        });
11551        let err = d.validate().unwrap_err();
11552        assert!(
11553            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11554            "got {err:?}",
11555        );
11556    }
11557
11558    #[test]
11559    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11560        // Cascade pin on the upstream shell-redirection arm: a value
11561        // carrying both `>` and a backtick (``"../caixa-teia>log
11562        // <backtick>date<backtick>"`` — the canonical "I pasted a
11563        // `cmd > log <backtick>date<backtick>` redirect-plus-
11564        // substitution chain" footgun) routes through
11565        // `FonteCaminhoShellRedirection` not
11566        // `FonteCaminhoShellCommandSubstitution`. The input/output
11567        // redirection metachar carries the more self-locating `byte`
11568        // payload (it names which of `<` or `>` triggered), so the
11569        // prior arm wins on every probe-as-both value.
11570        let d = dep_with_fonte(DepSource::Path {
11571            caminho: "../caixa-teia>log `date`".into(),
11572        });
11573        let err = d.validate().unwrap_err();
11574        assert!(
11575            matches!(
11576                err,
11577                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11578            ),
11579            "got {err:?}",
11580        );
11581    }
11582
11583    #[test]
11584    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11585        // Cascade pin on the upstream backslash arm: a value
11586        // carrying both `\` and a backtick (``"..\caixa-teia
11587        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11588        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11589        // chain") routes through `FonteCaminhoBackslash` not
11590        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11591        // separator divergence is the load-bearing axis on every
11592        // probe-as-both value (an author who removes the `\` is the
11593        // root-cause edit; the backtick falls away in the same edit
11594        // since it's downstream of the Windows-shell convention).
11595        let d = dep_with_fonte(DepSource::Path {
11596            caminho: "..\\caixa-teia `whoami`".into(),
11597        });
11598        let err = d.validate().unwrap_err();
11599        assert!(
11600            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11601            "got {err:?}",
11602        );
11603    }
11604
11605    #[test]
11606    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11607        // Cascade pin on the embedded-control-byte arm: a value
11608        // carrying both a control byte and a backtick (`"../foo\n
11609        // `whoami`"` — the canonical paste-from-multiline-doc
11610        // footgun where a newline landed mid-caminho between two
11611        // paste fragments) routes through `FonteCaminhoControlChar`
11612        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11613        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11614        // is the load-bearing axis on every value that probes
11615        // positive for both — mirrors the cascade discipline on
11616        // every prior arm.
11617        let d = dep_with_fonte(DepSource::Path {
11618            caminho: "../foo\n`whoami`".into(),
11619        });
11620        let err = d.validate().unwrap_err();
11621        assert!(
11622            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11623            "got {err:?}",
11624        );
11625    }
11626
11627    #[test]
11628    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11629        // Cascade pin on the load-bearing leading-byte arm: a
11630        // leading `/` value with embedded backtick (``"/etc/passwd
11631        // <backtick>whoami<backtick>"``) routes through
11632        // `FonteCaminhoAbsolute` not
11633        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11634        // leak diagnostic is the load-bearing axis, the backtick
11635        // byte is the secondary observation. Same precedence logic
11636        // as every prior leading-byte arm.
11637        let d = dep_with_fonte(DepSource::Path {
11638            caminho: "/etc/passwd `whoami`".into(),
11639        });
11640        let err = d.validate().unwrap_err();
11641        assert!(
11642            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11643            "got {err:?}",
11644        );
11645    }
11646
11647    #[test]
11648    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11649        // Cascade pin on the immediate-successor arm: a value
11650        // carrying both a backtick and a trailing `/`
11651        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11652        // path that already had a backticked `whoami` substitution
11653        // tail" footgun) routes through
11654        // `FonteCaminhoShellCommandSubstitution` not
11655        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11656        // is the more semantic-locating axis (an author who removes
11657        // the backtick typically also drops the trailing separator
11658        // since both are paste-from-shell artifacts).
11659        let d = dep_with_fonte(DepSource::Path {
11660            caminho: "../`whoami`/".into(),
11661        });
11662        let err = d.validate().unwrap_err();
11663        assert!(
11664            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11665            "got {err:?}",
11666        );
11667    }
11668
11669    #[test]
11670    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11671        // Diagnostic-shape pin (peer with
11672        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11673        // on the closest single-byte peer arm): the error's Display
11674        // surfaces the offending `:nome` and the offending `:caminho`
11675        // verbatim, and names the shell-command-substitution footgun
11676        // explicitly so a `feira lint` run can render the diagnostic
11677        // without re-parsing.
11678        let d = dep_with_fonte(DepSource::Path {
11679            caminho: "../caixa-teia/`whoami`".into(),
11680        });
11681        let rendered = d.validate().unwrap_err().to_string();
11682        assert!(
11683            rendered.contains("caixa-teia"),
11684            "diagnostic must name the offending dep: {rendered}",
11685        );
11686        assert!(
11687            rendered.contains("../caixa-teia/`whoami`"),
11688            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11689        );
11690        assert!(
11691            rendered.contains('`'),
11692            "diagnostic must reference the backtick footgun: {rendered:?}",
11693        );
11694        assert!(
11695            rendered.contains("command-substitution"),
11696            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11697        );
11698    }
11699
11700    #[test]
11701    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11702        // The fail-before-pass-after pin for the canonical pathname-
11703        // expansion paste footgun: an author copies an `ls
11704        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11705        // slot and silently passes every prior arm
11706        // (`Path::is_absolute` false on `..`, no control bytes, no
11707        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11708        // doesn't end in `/`). The lacre embedded the value
11709        // verbatim, the resolver folded it through `Path::join`
11710        // looking for a literal `./../caixa-teia/*` subdirectory,
11711        // and the failure surfaced at resolve time with a non-self-
11712        // locating `No such file or directory` error. The new arm
11713        // moves the rejection to validate time and names the
11714        // offending dep + caminho + byte verbatim.
11715        let d = dep_with_fonte(DepSource::Path {
11716            caminho: "../caixa-teia/*".into(),
11717        });
11718        let err = d.validate().unwrap_err();
11719        let DepError::FonteCaminhoShellGlob {
11720            nome,
11721            caminho,
11722            byte,
11723        } = err
11724        else {
11725            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11726        };
11727        assert_eq!(nome, "caixa-teia");
11728        assert_eq!(caminho, "../caixa-teia/*");
11729        assert_eq!(byte, b'*');
11730    }
11731
11732    #[test]
11733    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11734        // The symmetric single-char-wildcard paste shape
11735        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11736        // out of shell history" idiom). Pinned separately from the
11737        // `*` shape so the gate's contract is "any `*` or `?`
11738        // anywhere", not single-byte coverage.
11739        let d = dep_with_fonte(DepSource::Path {
11740            caminho: "../foo?".into(),
11741        });
11742        let err = d.validate().unwrap_err();
11743        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11744            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11745        };
11746        assert_eq!(byte, b'?');
11747    }
11748
11749    #[test]
11750    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11751        // Leading-position `*` shape (`"*/caixa-teia"` — the
11752        // degenerate "I selected only the wildcard prefix out of a
11753        // shell-glob expression" idiom). Pinned separately from the
11754        // embedded-byte shapes so the gate covers every position,
11755        // not only mid-path.
11756        let d = dep_with_fonte(DepSource::Path {
11757            caminho: "*/caixa-teia".into(),
11758        });
11759        let err = d.validate().unwrap_err();
11760        assert!(
11761            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11762            "got {err:?}",
11763        );
11764    }
11765
11766    #[test]
11767    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11768        // The bash/zsh `globstar` recursive-glob shape
11769        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11770        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11771        // The arm fires on the first `*` encountered; pinned so a
11772        // future arm that tries to distinguish single `*` from
11773        // double `**` doesn't break the broader contract.
11774        let d = dep_with_fonte(DepSource::Path {
11775            caminho: "../caixa-teia/**/foo".into(),
11776        });
11777        let err = d.validate().unwrap_err();
11778        assert!(
11779            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11780            "got {err:?}",
11781        );
11782    }
11783
11784    #[test]
11785    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11786        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11787        // — the "I selected `*.lisp` to mean every Lisp source file
11788        // in the dep root" footgun the prior arms structurally
11789        // cannot catch since `.` is a POSIX-valid path-component
11790        // byte). Pinned so the gate's contract covers the most
11791        // idiomatic glob-paste shape every author meets first.
11792        let d = dep_with_fonte(DepSource::Path {
11793            caminho: "../caixa-teia/*.lisp".into(),
11794        });
11795        let err = d.validate().unwrap_err();
11796        assert!(
11797            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11798            "got {err:?}",
11799        );
11800    }
11801
11802    #[test]
11803    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11804        // The positive-control pin: the gate targets only `*` /
11805        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11806        // The canonical relative POSIX path (`"../caixa-teia"`) and
11807        // a nested deeply-pathed variant with adjacent printable
11808        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11809        // to validate cleanly so the gate doesn't widen to a "no
11810        // printable punctuation anywhere" sweep that would defeat
11811        // the entire path-fonte author surface.
11812        let d = dep_with_fonte(DepSource::Path {
11813            caminho: "../caixa-teia/sub-dir.v2".into(),
11814        });
11815        d.validate().unwrap();
11816    }
11817
11818    #[test]
11819    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11820        // Cascade pin on the immediate-predecessor arm: a value
11821        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11822        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11823        // command-substitution + glob chain") routes through
11824        // `FonteCaminhoShellCommandSubstitution` not
11825        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11826        // injection vector is the load-bearing root-cause edit on
11827        // every probe-as-both value — same cascade discipline every
11828        // prior `:caminho` arm establishes.
11829        let d = dep_with_fonte(DepSource::Path {
11830            caminho: "../`whoami`/*".into(),
11831        });
11832        let err = d.validate().unwrap_err();
11833        assert!(
11834            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11835            "got {err:?}",
11836        );
11837    }
11838
11839    #[test]
11840    fn fonte_caminho_shell_background_fires_before_shell_glob() {
11841        // Cascade pin on the upstream shell-background arm: a value
11842        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11843        // canonical "I pasted a `cmd & ls /*` background + glob
11844        // chain" footgun) routes through `FonteCaminhoShellBackground`
11845        // not `FonteCaminhoShellGlob`. The background-launch tail is
11846        // the load-bearing root-cause edit on every probe-as-both
11847        // value.
11848        let d = dep_with_fonte(DepSource::Path {
11849            caminho: "../caixa-teia & ls /*".into(),
11850        });
11851        let err = d.validate().unwrap_err();
11852        assert!(
11853            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11854            "got {err:?}",
11855        );
11856    }
11857
11858    #[test]
11859    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11860        // Cascade pin on the upstream shell-semicolon arm: a value
11861        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11862        // canonical sequential-cleanup + glob paste idiom) routes
11863        // through `FonteCaminhoShellSemicolon` not
11864        // `FonteCaminhoShellGlob`. The sequential-command-separator
11865        // paste is the load-bearing root-cause edit on every
11866        // probe-as-both value.
11867        let d = dep_with_fonte(DepSource::Path {
11868            caminho: "../caixa-teia; rm *".into(),
11869        });
11870        let err = d.validate().unwrap_err();
11871        assert!(
11872            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11873            "got {err:?}",
11874        );
11875    }
11876
11877    #[test]
11878    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11879        // Cascade pin on the upstream shell-pipe arm: a value
11880        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11881        // canonical pipeline-to-glob paste idiom) routes through
11882        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11883        // pipeline-tail paste is the load-bearing root-cause edit
11884        // on every probe-as-both value.
11885        let d = dep_with_fonte(DepSource::Path {
11886            caminho: "../caixa-teia | ls *".into(),
11887        });
11888        let err = d.validate().unwrap_err();
11889        assert!(
11890            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11891            "got {err:?}",
11892        );
11893    }
11894
11895    #[test]
11896    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11897        // Cascade pin on the upstream shell-redirection arm: a value
11898        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11899        // canonical "I pasted a `cmd > log *` redirect-plus-glob
11900        // chain" footgun) routes through
11901        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11902        // The input/output redirection metachar carries the more
11903        // self-locating `byte` payload (it names which of `<` or `>`
11904        // triggered), so the prior arm wins on every probe-as-both
11905        // value.
11906        let d = dep_with_fonte(DepSource::Path {
11907            caminho: "../caixa-teia>log *".into(),
11908        });
11909        let err = d.validate().unwrap_err();
11910        assert!(
11911            matches!(
11912                err,
11913                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11914            ),
11915            "got {err:?}",
11916        );
11917    }
11918
11919    #[test]
11920    fn fonte_caminho_backslash_fires_before_shell_glob() {
11921        // Cascade pin on the upstream backslash arm: a value
11922        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11923        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11924        // expression" footgun) routes through
11925        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11926        // cross-host-OS-separator divergence is the load-bearing
11927        // axis on every probe-as-both value (an author who removes
11928        // the `\` is the root-cause edit; the `*` falls away in the
11929        // same edit since it's downstream of the Windows-shell
11930        // convention).
11931        let d = dep_with_fonte(DepSource::Path {
11932            caminho: "..\\caixa-teia\\*".into(),
11933        });
11934        let err = d.validate().unwrap_err();
11935        assert!(
11936            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11937            "got {err:?}",
11938        );
11939    }
11940
11941    #[test]
11942    fn fonte_caminho_control_char_fires_before_shell_glob() {
11943        // Cascade pin on the embedded-control-byte arm: a value
11944        // carrying both a control byte and `*` (`"../foo\n*"` — the
11945        // canonical paste-from-multiline-doc footgun where a
11946        // newline landed mid-caminho between two paste fragments)
11947        // routes through `FonteCaminhoControlChar` not
11948        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11949        // NUL-`CString::new`-fail diagnostic is the load-bearing
11950        // axis on every value that probes positive for both —
11951        // mirrors the cascade discipline on every prior arm.
11952        let d = dep_with_fonte(DepSource::Path {
11953            caminho: "../foo\n*".into(),
11954        });
11955        let err = d.validate().unwrap_err();
11956        assert!(
11957            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11958            "got {err:?}",
11959        );
11960    }
11961
11962    #[test]
11963    fn fonte_caminho_absolute_fires_before_shell_glob() {
11964        // Cascade pin on the load-bearing leading-byte arm: a
11965        // leading `/` value with embedded `*` (`"/etc/*"`) routes
11966        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11967        // — the host-layout-leak diagnostic is the load-bearing
11968        // axis, the glob byte is the secondary observation. Same
11969        // precedence logic as every prior leading-byte arm.
11970        let d = dep_with_fonte(DepSource::Path {
11971            caminho: "/etc/*".into(),
11972        });
11973        let err = d.validate().unwrap_err();
11974        assert!(
11975            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11976            "got {err:?}",
11977        );
11978    }
11979
11980    #[test]
11981    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11982        // Cascade pin on the immediate-successor arm: a value
11983        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11984        // canonical "I tab-completed a path that already had a
11985        // glob-expansion tail" footgun) routes through
11986        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11987        // The embedded shell-metachar is the more semantic-locating
11988        // axis (an author who removes the `*` typically also drops
11989        // the trailing separator since both are paste-from-shell
11990        // artifacts).
11991        let d = dep_with_fonte(DepSource::Path {
11992            caminho: "../foo*/".into(),
11993        });
11994        let err = d.validate().unwrap_err();
11995        assert!(
11996            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11997            "got {err:?}",
11998        );
11999    }
12000
12001    #[test]
12002    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12003        // Diagnostic-shape pin (peer with
12004        // `fonte_caminho_shell_redirection_diagnostic_*` on the
12005        // closest two-byte peer arm): the error's Display surfaces
12006        // the offending `:nome`, the offending `:caminho` verbatim,
12007        // the offending byte's hex / character form, and names the
12008        // shell-glob / pathname-expansion footgun explicitly so a
12009        // `feira lint` run can render the diagnostic without
12010        // re-parsing.
12011        let d = dep_with_fonte(DepSource::Path {
12012            caminho: "../caixa-teia/*.lisp".into(),
12013        });
12014        let rendered = d.validate().unwrap_err().to_string();
12015        assert!(
12016            rendered.contains("caixa-teia"),
12017            "diagnostic must name the offending dep: {rendered}",
12018        );
12019        assert!(
12020            rendered.contains("../caixa-teia/*.lisp"),
12021            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12022        );
12023        assert!(
12024            rendered.contains("0x2a"),
12025            "diagnostic must surface the offending byte hex: {rendered:?}",
12026        );
12027        assert!(
12028            rendered.contains("glob"),
12029            "diagnostic must name the shell-glob footgun: {rendered:?}",
12030        );
12031        assert!(
12032            rendered.contains("pathname-expansion"),
12033            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12034        );
12035    }
12036
12037    #[test]
12038    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12039        // The fail-before-pass-after pin for the canonical modern-Bourne
12040        // command-substitution paste footgun: an author copies a
12041        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12042        // `$(<cmd>)` expansion would land the current date as a
12043        // subdirectory name and silently passed every prior arm
12044        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12045        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12046        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12047        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12048        // sits mid-path). The lacre embedded the value verbatim, the
12049        // resolver folded it through `Path::join` looking for a literal
12050        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12051        // surfaced at resolve time with a non-self-locating `No such
12052        // file or directory` error. The new arm moves the rejection to
12053        // validate time and names the offending dep + caminho + byte
12054        // verbatim. The arm fires on the first `(` encountered (the
12055        // opening byte of `$(date)`).
12056        let d = dep_with_fonte(DepSource::Path {
12057            caminho: "../caixa-teia/$(date)/build".into(),
12058        });
12059        let err = d.validate().unwrap_err();
12060        let DepError::FonteCaminhoShellSubshellGrouping {
12061            nome,
12062            caminho,
12063            byte,
12064        } = err
12065        else {
12066            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12067        };
12068        assert_eq!(nome, "caixa-teia");
12069        assert_eq!(caminho, "../caixa-teia/$(date)/build");
12070        assert_eq!(byte, b'(');
12071    }
12072
12073    #[test]
12074    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12075        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12076        // the degenerate "I selected an unbalanced closing paren out of
12077        // a shell-history block" idiom that probes for the cascade's
12078        // last-byte handling on a value carrying only the closing byte).
12079        // Pinned separately from the open-paren shape so the gate's
12080        // contract is "any `(` or `)` anywhere", not single-byte
12081        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12082        // caminho_carrying_question_glob` shape on the immediate-
12083        // predecessor `FonteCaminhoShellGlob` arm.
12084        let d = dep_with_fonte(DepSource::Path {
12085            caminho: "../caixa-teia)".into(),
12086        });
12087        let err = d.validate().unwrap_err();
12088        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12089            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12090        };
12091        assert_eq!(byte, b')');
12092    }
12093
12094    #[test]
12095    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12096        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12097        // canonical "I selected a `(cd foo)` subshell-grouping prefix
12098        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12099        // Pinned separately from the embedded-byte shape so the gate
12100        // covers every position, not only mid-path.
12101        let d = dep_with_fonte(DepSource::Path {
12102            caminho: "(cd foo)/caixa-teia".into(),
12103        });
12104        let err = d.validate().unwrap_err();
12105        assert!(
12106            matches!(
12107                err,
12108                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12109            ),
12110            "got {err:?}",
12111        );
12112    }
12113
12114    #[test]
12115    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12116        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12117        // — the canonical "I copied a `(pwd)` working-directory-probe
12118        // subshell-grouping idiom every shell-history block carries"
12119        // footgun). The value carries no other cascade-preceding
12120        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12121        // `*` / `?`) so the arm fires on the first `(` encountered;
12122        // pinned so a future arm that tries to distinguish the
12123        // opening from the closing byte doesn't break the broader
12124        // contract. Mirrors the peer
12125        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12126        // backtick_pair` shape on the upstream `FonteCaminhoShell\
12127        // CommandSubstitution` arm.
12128        let d = dep_with_fonte(DepSource::Path {
12129            caminho: "../(pwd)/caixa-teia".into(),
12130        });
12131        let err = d.validate().unwrap_err();
12132        assert!(
12133            matches!(
12134                err,
12135                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12136            ),
12137            "got {err:?}",
12138        );
12139    }
12140
12141    #[test]
12142    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12143        // The positive-control pin: the gate targets only `(` / `)`,
12144        // never adjacent printable ASCII or POSIX-valid bytes. The
12145        // canonical relative POSIX path (`"../caixa-teia"`) and a
12146        // nested deeply-pathed variant with adjacent printable
12147        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12148        // validate cleanly so the gate doesn't widen to a "no printable
12149        // punctuation anywhere" sweep that would defeat the entire
12150        // path-fonte author surface.
12151        let d = dep_with_fonte(DepSource::Path {
12152            caminho: "../caixa-teia/sub-dir.v2".into(),
12153        });
12154        d.validate().unwrap();
12155    }
12156
12157    #[test]
12158    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12159        // Cascade pin on the immediate-predecessor arm: a value
12160        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12161        // canonical "I pasted a glob expansion followed by a
12162        // subshell-grouping tail" footgun) routes through
12163        // `FonteCaminhoShellGlob` not
12164        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12165        // shape is the more common shell-history paste idiom on every
12166        // probe-as-both value — same cascade discipline every prior
12167        // `:caminho` arm establishes.
12168        let d = dep_with_fonte(DepSource::Path {
12169            caminho: "../caixa-teia/*(date)".into(),
12170        });
12171        let err = d.validate().unwrap_err();
12172        assert!(
12173            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12174            "got {err:?}",
12175        );
12176    }
12177
12178    #[test]
12179    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12180        // Cascade pin on the upstream shell-command-substitution arm: a
12181        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12182        // — the canonical "I pasted a legacy-backtick + modern-paren
12183        // command-substitution chain" footgun) routes through
12184        // `FonteCaminhoShellCommandSubstitution` not
12185        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12186        // command-injection vector is the load-bearing root-cause edit
12187        // on every probe-as-both value.
12188        let d = dep_with_fonte(DepSource::Path {
12189            caminho: "../`whoami`/$(date)".into(),
12190        });
12191        let err = d.validate().unwrap_err();
12192        assert!(
12193            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12194            "got {err:?}",
12195        );
12196    }
12197
12198    #[test]
12199    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12200        // Cascade pin on the upstream shell-background arm: a value
12201        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12202        // the canonical "I pasted a `cmd & (cd foo)` background-launch
12203        // + subshell-grouping chain" footgun) routes through
12204        // `FonteCaminhoShellBackground` not
12205        // `FonteCaminhoShellSubshellGrouping`. The background-launch
12206        // tail is the load-bearing root-cause edit on every probe-as-
12207        // both value.
12208        let d = dep_with_fonte(DepSource::Path {
12209            caminho: "../caixa-teia & (cd foo)".into(),
12210        });
12211        let err = d.validate().unwrap_err();
12212        assert!(
12213            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12214            "got {err:?}",
12215        );
12216    }
12217
12218    #[test]
12219    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12220        // Cascade pin on the upstream shell-semicolon arm: a value
12221        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12222        // the canonical sequential-cleanup + subshell-grouping paste
12223        // idiom) routes through `FonteCaminhoShellSemicolon` not
12224        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12225        // separator paste is the load-bearing root-cause edit on
12226        // every probe-as-both value.
12227        let d = dep_with_fonte(DepSource::Path {
12228            caminho: "../caixa-teia; (cd foo)".into(),
12229        });
12230        let err = d.validate().unwrap_err();
12231        assert!(
12232            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12233            "got {err:?}",
12234        );
12235    }
12236
12237    #[test]
12238    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12239        // Cascade pin on the upstream shell-pipe arm: a value carrying
12240        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12241        // canonical pipeline-to-subshell-grouping paste idiom) routes
12242        // through `FonteCaminhoShellPipe` not
12243        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12244        // is the load-bearing root-cause edit on every probe-as-both
12245        // value.
12246        let d = dep_with_fonte(DepSource::Path {
12247            caminho: "../caixa-teia | (tee log)".into(),
12248        });
12249        let err = d.validate().unwrap_err();
12250        assert!(
12251            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12252            "got {err:?}",
12253        );
12254    }
12255
12256    #[test]
12257    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12258        // Cascade pin on the upstream shell-redirection arm: a value
12259        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12260        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12261        // plus-subshell-grouping chain" footgun) routes through
12262        // `FonteCaminhoShellRedirection` not
12263        // `FonteCaminhoShellSubshellGrouping`. The input/output
12264        // redirection metachar carries the more self-locating `byte`
12265        // payload (it names which of `<` or `>` triggered), so the
12266        // prior arm wins on every probe-as-both value.
12267        let d = dep_with_fonte(DepSource::Path {
12268            caminho: "../caixa-teia>log (cd foo)".into(),
12269        });
12270        let err = d.validate().unwrap_err();
12271        assert!(
12272            matches!(
12273                err,
12274                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12275            ),
12276            "got {err:?}",
12277        );
12278    }
12279
12280    #[test]
12281    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12282        // Cascade pin on the upstream backslash arm: a value carrying
12283        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12284        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12285        // through `FonteCaminhoBackslash` not
12286        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12287        // separator divergence is the load-bearing axis on every
12288        // probe-as-both value (an author who removes the `\` is the
12289        // root-cause edit; the `(` falls away in the same edit since
12290        // it's downstream of the Windows-shell convention).
12291        let d = dep_with_fonte(DepSource::Path {
12292            caminho: "..\\caixa-teia\\(cd foo)".into(),
12293        });
12294        let err = d.validate().unwrap_err();
12295        assert!(
12296            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12297            "got {err:?}",
12298        );
12299    }
12300
12301    #[test]
12302    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12303        // Cascade pin on the embedded-control-byte arm: a value
12304        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12305        // the canonical paste-from-multiline-doc footgun where a
12306        // newline landed mid-caminho between two paste fragments)
12307        // routes through `FonteCaminhoControlChar` not
12308        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12309        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12310        // load-bearing axis on every value that probes positive for
12311        // both — mirrors the cascade discipline on every prior arm.
12312        let d = dep_with_fonte(DepSource::Path {
12313            caminho: "../foo\n(cd bar)".into(),
12314        });
12315        let err = d.validate().unwrap_err();
12316        assert!(
12317            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12318            "got {err:?}",
12319        );
12320    }
12321
12322    #[test]
12323    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12324        // Cascade pin on the load-bearing leading-byte arm: a leading
12325        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12326        // through `FonteCaminhoAbsolute` not
12327        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12328        // diagnostic is the load-bearing axis, the subshell-grouping
12329        // byte is the secondary observation. Same precedence logic as
12330        // every prior leading-byte arm.
12331        let d = dep_with_fonte(DepSource::Path {
12332            caminho: "/etc/(cd foo)".into(),
12333        });
12334        let err = d.validate().unwrap_err();
12335        assert!(
12336            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12337            "got {err:?}",
12338        );
12339    }
12340
12341    #[test]
12342    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12343        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12344        // value carrying both a leading `$` and a `(` (`"$(date)/\
12345        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12346        // command-substitution at the head of a sibling-workspace
12347        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12348        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12349        // shell-variable-expansion is the more self-locating diagnostic
12350        // on values that probe as both — same load-bearing-leading-
12351        // byte cascade discipline every prior `:caminho` arm
12352        // establishes. Closing both halves of `$(<cmd>)` structurally
12353        // (leading `$` here, trailing `)` on the new arm) excludes the
12354        // entire modern Bourne command-substitution surface from the
12355        // typed `:caminho` accepted set; the cascade preserves the
12356        // narrower leading-byte diagnostic on values that probe both
12357        // halves at the canonical leading position.
12358        let d = dep_with_fonte(DepSource::Path {
12359            caminho: "$(date)/caixa-teia".into(),
12360        });
12361        let err = d.validate().unwrap_err();
12362        assert!(
12363            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12364            "got {err:?}",
12365        );
12366    }
12367
12368    #[test]
12369    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12370        // Cascade pin on the immediate-successor arm: a value carrying
12371        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12372        // "I tab-completed a path that already had a subshell-grouping
12373        // expansion tail" footgun) routes through
12374        // `FonteCaminhoShellSubshellGrouping` not
12375        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12376        // the more semantic-locating axis (an author who removes the
12377        // `(` typically also drops the trailing separator since both
12378        // are paste-from-shell artifacts).
12379        let d = dep_with_fonte(DepSource::Path {
12380            caminho: "../(cd foo)/".into(),
12381        });
12382        let err = d.validate().unwrap_err();
12383        assert!(
12384            matches!(
12385                err,
12386                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12387            ),
12388            "got {err:?}",
12389        );
12390    }
12391
12392    #[test]
12393    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12394        // Diagnostic-shape pin (peer with
12395        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12396        // on the closest two-byte peer arm): the error's Display
12397        // surfaces the offending `:nome`, the offending `:caminho`
12398        // verbatim, the offending byte's hex / character form, and
12399        // names the shell-subshell-grouping footgun explicitly so a
12400        // `feira lint` run can render the diagnostic without re-
12401        // parsing.
12402        let d = dep_with_fonte(DepSource::Path {
12403            caminho: "../caixa-teia/$(date)/build".into(),
12404        });
12405        let rendered = d.validate().unwrap_err().to_string();
12406        assert!(
12407            rendered.contains("caixa-teia"),
12408            "diagnostic must name the offending dep: {rendered}",
12409        );
12410        assert!(
12411            rendered.contains("../caixa-teia/$(date)/build"),
12412            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12413        );
12414        assert!(
12415            rendered.contains("0x28"),
12416            "diagnostic must surface the offending byte hex: {rendered:?}",
12417        );
12418        assert!(
12419            rendered.contains("subshell-grouping"),
12420            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12421        );
12422        assert!(
12423            rendered.contains("command-substitution"),
12424            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12425             {rendered:?}",
12426        );
12427    }
12428
12429    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12430    //
12431    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12432    // `)`) byte-pair arm: the same per-byte cascade with the same
12433    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12434    // `}` brace-expansion / URI-Template placeholder axis. The peer
12435    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12436    // byte pair on the sibling `:fonte :repo` axis under the same
12437    // banner.
12438
12439    #[test]
12440    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12441        // The fail-before-pass-after pin for the canonical paste-from-
12442        // shell-history brace-expansion footgun: an author copies a
12443        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12444        // liner whose `{a,b}` brace expansion fans across two siblings
12445        // and silently passed every prior arm (`Path::is_absolute`
12446        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12447        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12448        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12449        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12450        // value starts with `..` not `$`). The lacre embedded the
12451        // value verbatim, the resolver folded it through `Path::join`
12452        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12453        // subdirectory, and the failure surfaced at resolve time with
12454        // a non-self-locating `No such file or directory` error. The
12455        // new arm moves the rejection to validate time and names the
12456        // offending dep + caminho + byte verbatim. The arm fires on
12457        // the first `{` encountered.
12458        let d = dep_with_fonte(DepSource::Path {
12459            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12460        });
12461        let err = d.validate().unwrap_err();
12462        let DepError::FonteCaminhoShellBraceExpansion {
12463            nome,
12464            caminho,
12465            byte,
12466        } = err
12467        else {
12468            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12469        };
12470        assert_eq!(nome, "caixa-teia");
12471        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12472        assert_eq!(byte, b'{');
12473    }
12474
12475    #[test]
12476    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12477        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12478        // the degenerate "I selected an unbalanced closing brace out
12479        // of a shell-history block" idiom that probes for the
12480        // cascade's last-byte handling on a value carrying only the
12481        // closing byte). Pinned separately from the open-brace shape
12482        // so the gate's contract is "any `{` or `}` anywhere", not
12483        // single-byte coverage. Mirrors the peer
12484        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12485        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12486        // arm.
12487        let d = dep_with_fonte(DepSource::Path {
12488            caminho: "../caixa-teia}".into(),
12489        });
12490        let err = d.validate().unwrap_err();
12491        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12492            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12493        };
12494        assert_eq!(byte, b'}');
12495    }
12496
12497    #[test]
12498    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12499        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12500        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12501        // out of a shell-history one-liner" idiom). Pinned separately
12502        // from the embedded-byte shape so the gate covers every
12503        // position, not only mid-path.
12504        let d = dep_with_fonte(DepSource::Path {
12505            caminho: "{caixa-teia,caixa-helm}/build".into(),
12506        });
12507        let err = d.validate().unwrap_err();
12508        assert!(
12509            matches!(
12510                err,
12511                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12512            ),
12513            "got {err:?}",
12514        );
12515    }
12516
12517    #[test]
12518    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12519        // The canonical URI-Template / Mustache / Helm doubled-brace
12520        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12521        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12522        // quick-start / OpenAPI spec / Helm chart `home:` template
12523        // and forgot to substitute the placeholder" footgun). The arm
12524        // fires on the first `{` encountered; pinned so the gate's
12525        // coverage extends from the bare-brace shell-history shape to
12526        // the doubled-brace URI-Template / templating-engine shape.
12527        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12528        // sibling `:fonte :repo` axis.
12529        let d = dep_with_fonte(DepSource::Path {
12530            caminho: "../{{org}}/caixa-teia".into(),
12531        });
12532        let err = d.validate().unwrap_err();
12533        assert!(
12534            matches!(
12535                err,
12536                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12537            ),
12538            "got {err:?}",
12539        );
12540    }
12541
12542    #[test]
12543    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12544        // The canonical bash brace-range-expansion shape (`"../caixa-
12545        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12546        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12547        // sequence-range form to the `{a,b,c}` comma-separated form).
12548        // The arm fires on the first `{` encountered; pinned so the
12549        // gate's coverage extends from the comma-separated form to
12550        // the integer-range form.
12551        let d = dep_with_fonte(DepSource::Path {
12552            caminho: "../caixa-v{1..10}".into(),
12553        });
12554        let err = d.validate().unwrap_err();
12555        assert!(
12556            matches!(
12557                err,
12558                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12559            ),
12560            "got {err:?}",
12561        );
12562    }
12563
12564    #[test]
12565    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12566        // The positive-control pin: the gate targets only `{` / `}`,
12567        // never adjacent printable ASCII or POSIX-valid bytes. The
12568        // canonical relative POSIX path (`"../caixa-teia"`) and a
12569        // nested deeply-pathed variant with adjacent printable
12570        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12571        // validate cleanly so the gate doesn't widen to a "no
12572        // printable punctuation anywhere" sweep that would defeat
12573        // the entire path-fonte author surface. Peer with
12574        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12575        // on the immediate-predecessor arm.
12576        let d = dep_with_fonte(DepSource::Path {
12577            caminho: "../caixa-teia/sub-dir.v2".into(),
12578        });
12579        d.validate().unwrap();
12580    }
12581
12582    #[test]
12583    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12584        // Cascade pin on the immediate-predecessor arm: a value
12585        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12586        // canonical "I pasted a subshell-grouping followed by a
12587        // brace-expansion tail" footgun) routes through
12588        // `FonteCaminhoShellSubshellGrouping` not
12589        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12590        // shape is the more semantic-locating axis on every probe-
12591        // as-both value because it closes both halves of the modern
12592        // Bourne `$(<cmd>)` command-substitution surface — same
12593        // cascade discipline every prior `:caminho` arm establishes.
12594        let d = dep_with_fonte(DepSource::Path {
12595            caminho: "../(cd foo)/{a,b}".into(),
12596        });
12597        let err = d.validate().unwrap_err();
12598        assert!(
12599            matches!(
12600                err,
12601                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12602            ),
12603            "got {err:?}",
12604        );
12605    }
12606
12607    #[test]
12608    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12609        // Cascade pin on the upstream shell-glob arm: a value carrying
12610        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12611        // "I pasted a glob expansion followed by a brace-expansion
12612        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12613        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12614        // shape is the load-bearing root-cause edit on every
12615        // probe-as-both value.
12616        let d = dep_with_fonte(DepSource::Path {
12617            caminho: "../caixa-teia/*{a,b}".into(),
12618        });
12619        let err = d.validate().unwrap_err();
12620        assert!(
12621            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12622            "got {err:?}",
12623        );
12624    }
12625
12626    #[test]
12627    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12628        // Cascade pin on the upstream shell-command-substitution arm:
12629        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12630        // — the canonical "I pasted a legacy-backtick command-
12631        // substitution followed by a brace-expansion fan-out" footgun)
12632        // routes through `FonteCaminhoShellCommandSubstitution` not
12633        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12634        // command-injection vector is the load-bearing root-cause
12635        // edit on every probe-as-both value.
12636        let d = dep_with_fonte(DepSource::Path {
12637            caminho: "../`whoami`/{a,b}".into(),
12638        });
12639        let err = d.validate().unwrap_err();
12640        assert!(
12641            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12642            "got {err:?}",
12643        );
12644    }
12645
12646    #[test]
12647    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12648        // Cascade pin on the upstream shell-background arm: a value
12649        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12650        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12651        // + brace-expansion chain" footgun) routes through
12652        // `FonteCaminhoShellBackground` not
12653        // `FonteCaminhoShellBraceExpansion`. The background-launch
12654        // tail is the load-bearing root-cause edit on every
12655        // probe-as-both value.
12656        let d = dep_with_fonte(DepSource::Path {
12657            caminho: "../caixa-teia & {a,b}".into(),
12658        });
12659        let err = d.validate().unwrap_err();
12660        assert!(
12661            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12662            "got {err:?}",
12663        );
12664    }
12665
12666    #[test]
12667    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12668        // Cascade pin on the upstream shell-semicolon arm: a value
12669        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12670        // canonical sequential-cleanup + brace-expansion paste
12671        // idiom) routes through `FonteCaminhoShellSemicolon` not
12672        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12673        // separator paste is the load-bearing root-cause edit on
12674        // every probe-as-both value.
12675        let d = dep_with_fonte(DepSource::Path {
12676            caminho: "../caixa-teia; {a,b}".into(),
12677        });
12678        let err = d.validate().unwrap_err();
12679        assert!(
12680            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12681            "got {err:?}",
12682        );
12683    }
12684
12685    #[test]
12686    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12687        // Cascade pin on the upstream shell-pipe arm: a value
12688        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12689        // — the canonical pipeline-to-brace-expansion paste idiom)
12690        // routes through `FonteCaminhoShellPipe` not
12691        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12692        // is the load-bearing root-cause edit on every probe-as-
12693        // both value.
12694        let d = dep_with_fonte(DepSource::Path {
12695            caminho: "../caixa-teia | {tee,cat}".into(),
12696        });
12697        let err = d.validate().unwrap_err();
12698        assert!(
12699            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12700            "got {err:?}",
12701        );
12702    }
12703
12704    #[test]
12705    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12706        // Cascade pin on the upstream shell-redirection arm: a value
12707        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12708        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12709        // plus-brace-expansion chain" footgun) routes through
12710        // `FonteCaminhoShellRedirection` not
12711        // `FonteCaminhoShellBraceExpansion`. The input/output
12712        // redirection metachar carries the more self-locating
12713        // `byte` payload, so the prior arm wins on every probe-
12714        // as-both value.
12715        let d = dep_with_fonte(DepSource::Path {
12716            caminho: "../caixa-teia>log {a,b}".into(),
12717        });
12718        let err = d.validate().unwrap_err();
12719        assert!(
12720            matches!(
12721                err,
12722                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12723            ),
12724            "got {err:?}",
12725        );
12726    }
12727
12728    #[test]
12729    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12730        // Cascade pin on the upstream backslash arm: a value
12731        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12732        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12733        // chain") routes through `FonteCaminhoBackslash` not
12734        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12735        // separator divergence is the load-bearing axis on every
12736        // probe-as-both value.
12737        let d = dep_with_fonte(DepSource::Path {
12738            caminho: "..\\caixa-teia\\{a,b}".into(),
12739        });
12740        let err = d.validate().unwrap_err();
12741        assert!(
12742            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12743            "got {err:?}",
12744        );
12745    }
12746
12747    #[test]
12748    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12749        // Cascade pin on the embedded-control-byte arm: a value
12750        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12751        // the canonical paste-from-multiline-doc footgun where a
12752        // newline landed mid-caminho between two paste fragments)
12753        // routes through `FonteCaminhoControlChar` not
12754        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12755        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12756        // load-bearing axis on every value that probes positive for
12757        // both — mirrors the cascade discipline on every prior arm.
12758        let d = dep_with_fonte(DepSource::Path {
12759            caminho: "../foo\n{a,b}".into(),
12760        });
12761        let err = d.validate().unwrap_err();
12762        assert!(
12763            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12764            "got {err:?}",
12765        );
12766    }
12767
12768    #[test]
12769    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12770        // Cascade pin on the load-bearing leading-byte arm: a
12771        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12772        // routes through `FonteCaminhoAbsolute` not
12773        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12774        // diagnostic is the load-bearing axis, the brace-expansion
12775        // byte is the secondary observation. Same precedence logic
12776        // as every prior leading-byte arm.
12777        let d = dep_with_fonte(DepSource::Path {
12778            caminho: "/etc/{a,b}".into(),
12779        });
12780        let err = d.validate().unwrap_err();
12781        assert!(
12782            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12783            "got {err:?}",
12784        );
12785    }
12786
12787    #[test]
12788    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12789        // Cascade pin on the upstream leading-`$` var-expansion
12790        // arm: a value carrying both a leading `$` and a `{`
12791        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12792        // `${ORG}` shell-variable + curly-brace expansion at the
12793        // head of a sibling-workspace path" footgun) routes through
12794        // `FonteCaminhoVarExpansion` not
12795        // `FonteCaminhoShellBraceExpansion`. The leading-byte
12796        // shell-variable-expansion is the more self-locating
12797        // diagnostic on values that probe as both — same
12798        // load-bearing-leading-byte cascade discipline every prior
12799        // `:caminho` arm establishes.
12800        let d = dep_with_fonte(DepSource::Path {
12801            caminho: "${ORG}/caixa-teia".into(),
12802        });
12803        let err = d.validate().unwrap_err();
12804        assert!(
12805            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12806            "got {err:?}",
12807        );
12808    }
12809
12810    #[test]
12811    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12812        // Cascade pin on the immediate-successor arm: a value
12813        // carrying both `{` and a trailing `/`
12814        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12815        // tab-completed a path that already had a brace-expansion
12816        // expansion tail" footgun) routes through
12817        // `FonteCaminhoShellBraceExpansion` not
12818        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12819        // is the more semantic-locating axis (an author who removes
12820        // the `{` typically also drops the trailing separator since
12821        // both are paste-from-shell artifacts).
12822        let d = dep_with_fonte(DepSource::Path {
12823            caminho: "../{caixa-teia,caixa-helm}/".into(),
12824        });
12825        let err = d.validate().unwrap_err();
12826        assert!(
12827            matches!(
12828                err,
12829                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12830            ),
12831            "got {err:?}",
12832        );
12833    }
12834
12835    #[test]
12836    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12837        // Diagnostic-shape pin (peer with
12838        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12839        // on the closest two-byte peer arm): the error's Display
12840        // surfaces the offending `:nome`, the offending `:caminho`
12841        // verbatim, the offending byte's hex / character form, and
12842        // names the shell-brace-expansion / URI-Template footgun
12843        // explicitly so a `feira lint` run can render the diagnostic
12844        // without re-parsing.
12845        let d = dep_with_fonte(DepSource::Path {
12846            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12847        });
12848        let rendered = d.validate().unwrap_err().to_string();
12849        assert!(
12850            rendered.contains("caixa-teia"),
12851            "diagnostic must name the offending dep: {rendered}",
12852        );
12853        assert!(
12854            rendered.contains("../{caixa-teia,caixa-helm}/build"),
12855            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12856        );
12857        assert!(
12858            rendered.contains("0x7b"),
12859            "diagnostic must surface the offending byte hex: {rendered:?}",
12860        );
12861        assert!(
12862            rendered.contains("brace-expansion"),
12863            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12864        );
12865        assert!(
12866            rendered.contains("URI Template"),
12867            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12868             {rendered:?}",
12869        );
12870    }
12871
12872    #[test]
12873    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12874        // The canonical paste-from-shell-history bracket-glob /
12875        // character-class footgun: an author copies a
12876        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12877        // `[a-z]` POSIX glob character-class matches every lowercase-
12878        // ASCII-suffix sibling caixa directory and silently passed
12879        // every prior arm (`Path::is_absolute` false on `..`, no
12880        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12881        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12882        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12883        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12884        // value starts with `..` not `$`). The lacre embedded the
12885        // value verbatim, the resolver folded it through
12886        // `Path::join` looking for a literal `./../caixa-[a-z]/
12887        // build` subdirectory, and the failure surfaced at resolve
12888        // time with a non-self-locating `No such file or directory`
12889        // error. The new arm moves the rejection to validate time
12890        // and names the offending dep + caminho + byte verbatim.
12891        // The arm fires on the first `[` encountered.
12892        let d = dep_with_fonte(DepSource::Path {
12893            caminho: "../caixa-[a-z]/build".into(),
12894        });
12895        let err = d.validate().unwrap_err();
12896        let DepError::FonteCaminhoShellBracketExpansion {
12897            nome,
12898            caminho,
12899            byte,
12900        } = err
12901        else {
12902            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12903        };
12904        assert_eq!(nome, "caixa-teia");
12905        assert_eq!(caminho, "../caixa-[a-z]/build");
12906        assert_eq!(byte, b'[');
12907    }
12908
12909    #[test]
12910    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12911        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12912        // — the degenerate "I selected an unbalanced closing bracket
12913        // out of a glob character-class block" idiom that probes for
12914        // the cascade's last-byte handling on a value carrying only
12915        // the closing byte). Pinned separately from the open-bracket
12916        // shape so the gate's contract is "any `[` or `]` anywhere",
12917        // not single-byte coverage. Mirrors the peer
12918        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12919        // shape on the immediate-predecessor
12920        // `FonteCaminhoShellBraceExpansion` arm.
12921        let d = dep_with_fonte(DepSource::Path {
12922            caminho: "../caixa-teia]".into(),
12923        });
12924        let err = d.validate().unwrap_err();
12925        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12926            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12927        };
12928        assert_eq!(byte, b']');
12929    }
12930
12931    #[test]
12932    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12933        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12934        // canonical "I selected a `[caixa-teia]` TOML-table-header /
12935        // glob-character-class prefix out of an aligned config /
12936        // shell-history one-liner" idiom). Pinned separately from
12937        // the embedded-byte shape so the gate covers every position,
12938        // not only mid-path.
12939        let d = dep_with_fonte(DepSource::Path {
12940            caminho: "[caixa-teia]/build".into(),
12941        });
12942        let err = d.validate().unwrap_err();
12943        assert!(
12944            matches!(
12945                err,
12946                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12947            ),
12948            "got {err:?}",
12949        );
12950    }
12951
12952    #[test]
12953    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12954        // The canonical TOML inline-array / YAML flow-sequence
12955        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12956        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12957        // inline-array out of a sibling-Cargo manifest" cross-idiom
12958        // leak; the symmetric YAML flow-sequence form `paths: [/a,
12959        // /b]` paste-from-values.yaml shape carries the same
12960        // bracket pair). The arm fires on the first `[` encountered;
12961        // pinned so the gate's coverage extends from the bare-
12962        // bracket glob-character-class shape to the TOML / YAML /
12963        // JSON array-literal shape.
12964        let d = dep_with_fonte(DepSource::Path {
12965            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12966        });
12967        let err = d.validate().unwrap_err();
12968        assert!(
12969            matches!(
12970                err,
12971                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12972            ),
12973            "got {err:?}",
12974        );
12975    }
12976
12977    #[test]
12978    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12979        // The canonical POSIX `test` / `[` builtin command paste
12980        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12981        // script conditional every paste-from-shell-script idiom
12982        // carries; bash's `[[ <expr> ]]` extended-test grammar
12983        // would surface the same byte pair). The arm fires on the
12984        // first `[` encountered; pinned so the gate's coverage
12985        // extends from the embedded-glob-character-class shape to
12986        // the leading-`test`-builtin / extended-test form.
12987        let d = dep_with_fonte(DepSource::Path {
12988            caminho: "../[ -d caixa-teia ]".into(),
12989        });
12990        let err = d.validate().unwrap_err();
12991        assert!(
12992            matches!(
12993                err,
12994                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12995            ),
12996            "got {err:?}",
12997        );
12998    }
12999
13000    #[test]
13001    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13002        // The positive-control pin: the gate targets only `[` /
13003        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13004        // The canonical relative POSIX path (`"../caixa-teia"`) and
13005        // a nested deeply-pathed variant with adjacent printable
13006        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13007        // to validate cleanly so the gate doesn't widen to a "no
13008        // printable punctuation anywhere" sweep that would defeat
13009        // the entire path-fonte author surface. Peer with
13010        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13011        // on the immediate-predecessor arm.
13012        let d = dep_with_fonte(DepSource::Path {
13013            caminho: "../caixa-teia/sub-dir.v2".into(),
13014        });
13015        d.validate().unwrap();
13016    }
13017
13018    #[test]
13019    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13020        // Cascade pin on the immediate-predecessor arm: a value
13021        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13022        // canonical "I pasted a brace-expansion fan followed by a
13023        // glob-character-class tail" footgun) routes through
13024        // `FonteCaminhoShellBraceExpansion` not
13025        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13026        // fan is the load-bearing root-cause edit on every
13027        // probe-as-both value because the bracket-class tail
13028        // typically rides on a prior brace-expansion expansion;
13029        // same cascade discipline every prior `:caminho` arm
13030        // establishes.
13031        let d = dep_with_fonte(DepSource::Path {
13032            caminho: "../{a,b}[ch]".into(),
13033        });
13034        let err = d.validate().unwrap_err();
13035        assert!(
13036            matches!(
13037                err,
13038                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13039            ),
13040            "got {err:?}",
13041        );
13042    }
13043
13044    #[test]
13045    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13046        // Cascade pin on the upstream shell-subshell-grouping arm:
13047        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13048        // the canonical "I pasted a subshell-grouping followed by
13049        // a glob-character-class tail" footgun) routes through
13050        // `FonteCaminhoShellSubshellGrouping` not
13051        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13052        // `$(<cmd>)` command-substitution boundary is the load-
13053        // bearing axis on every probe-as-both value.
13054        let d = dep_with_fonte(DepSource::Path {
13055            caminho: "../(cd foo)/[ch]".into(),
13056        });
13057        let err = d.validate().unwrap_err();
13058        assert!(
13059            matches!(
13060                err,
13061                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13062            ),
13063            "got {err:?}",
13064        );
13065    }
13066
13067    #[test]
13068    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13069        // Cascade pin on the upstream shell-glob arm: a value
13070        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13071        // canonical "I pasted a `*.[ch]` C-source-file glob whose
13072        // unbounded `*` precedes the bracket character-class"
13073        // footgun) routes through `FonteCaminhoShellGlob` not
13074        // `FonteCaminhoShellBracketExpansion`. The unbounded
13075        // pathname-expansion sentinel is the load-bearing root-
13076        // cause edit on every probe-as-both value — the unbounded
13077        // `*` carries the more aggressive expansion vector than
13078        // the bounded `[ch]` class, so the prior arm wins.
13079        let d = dep_with_fonte(DepSource::Path {
13080            caminho: "../caixa-teia/*[ch]".into(),
13081        });
13082        let err = d.validate().unwrap_err();
13083        assert!(
13084            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13085            "got {err:?}",
13086        );
13087    }
13088
13089    #[test]
13090    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13091        // Cascade pin on the upstream shell-command-substitution
13092        // arm: a value carrying both a backtick and `[`
13093        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13094        // legacy-backtick command-substitution followed by a
13095        // glob-character-class tail" footgun) routes through
13096        // `FonteCaminhoShellCommandSubstitution` not
13097        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13098        // command-injection vector is the load-bearing root-cause
13099        // edit on every probe-as-both value.
13100        let d = dep_with_fonte(DepSource::Path {
13101            caminho: "../`whoami`/[ch]".into(),
13102        });
13103        let err = d.validate().unwrap_err();
13104        assert!(
13105            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13106            "got {err:?}",
13107        );
13108    }
13109
13110    #[test]
13111    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13112        // Cascade pin on the upstream shell-background arm: a
13113        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13114        // — the canonical "I pasted a `cmd & [glob]` background-
13115        // launch + bracket-class chain" footgun) routes through
13116        // `FonteCaminhoShellBackground` not
13117        // `FonteCaminhoShellBracketExpansion`. The background-
13118        // launch tail is the load-bearing root-cause edit on
13119        // every probe-as-both value.
13120        let d = dep_with_fonte(DepSource::Path {
13121            caminho: "../caixa-teia & [ch]".into(),
13122        });
13123        let err = d.validate().unwrap_err();
13124        assert!(
13125            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13126            "got {err:?}",
13127        );
13128    }
13129
13130    #[test]
13131    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13132        // Cascade pin on the upstream shell-semicolon arm: a value
13133        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13134        // canonical sequential-cleanup + bracket-class paste
13135        // idiom) routes through `FonteCaminhoShellSemicolon` not
13136        // `FonteCaminhoShellBracketExpansion`. The sequential-
13137        // command-separator paste is the load-bearing root-cause
13138        // edit on every probe-as-both value.
13139        let d = dep_with_fonte(DepSource::Path {
13140            caminho: "../caixa-teia; [ch]".into(),
13141        });
13142        let err = d.validate().unwrap_err();
13143        assert!(
13144            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13145            "got {err:?}",
13146        );
13147    }
13148
13149    #[test]
13150    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13151        // Cascade pin on the upstream shell-pipe arm: a value
13152        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13153        // the canonical pipeline-to-bracket-class paste idiom)
13154        // routes through `FonteCaminhoShellPipe` not
13155        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13156        // paste is the load-bearing root-cause edit on every
13157        // probe-as-both value.
13158        let d = dep_with_fonte(DepSource::Path {
13159            caminho: "../caixa-teia | [tee]".into(),
13160        });
13161        let err = d.validate().unwrap_err();
13162        assert!(
13163            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13164            "got {err:?}",
13165        );
13166    }
13167
13168    #[test]
13169    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13170        // Cascade pin on the upstream shell-redirection arm: a
13171        // value carrying both `>` and `[` (`"../caixa-teia>log
13172        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13173        // redirect-plus-bracket chain" footgun) routes through
13174        // `FonteCaminhoShellRedirection` not
13175        // `FonteCaminhoShellBracketExpansion`. The input/output
13176        // redirection metachar carries the more self-locating
13177        // `byte` payload, so the prior arm wins on every
13178        // probe-as-both value.
13179        let d = dep_with_fonte(DepSource::Path {
13180            caminho: "../caixa-teia>log [ch]".into(),
13181        });
13182        let err = d.validate().unwrap_err();
13183        assert!(
13184            matches!(
13185                err,
13186                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13187            ),
13188            "got {err:?}",
13189        );
13190    }
13191
13192    #[test]
13193    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13194        // Cascade pin on the upstream backslash arm: a value
13195        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13196        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13197        // chain") routes through `FonteCaminhoBackslash` not
13198        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13199        // separator divergence is the load-bearing axis on every
13200        // probe-as-both value.
13201        let d = dep_with_fonte(DepSource::Path {
13202            caminho: "..\\caixa-teia\\[ch]".into(),
13203        });
13204        let err = d.validate().unwrap_err();
13205        assert!(
13206            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13207            "got {err:?}",
13208        );
13209    }
13210
13211    #[test]
13212    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13213        // Cascade pin on the embedded-control-byte arm: a value
13214        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13215        // the canonical paste-from-multiline-doc footgun where a
13216        // newline landed mid-caminho between two paste fragments)
13217        // routes through `FonteCaminhoControlChar` not
13218        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13219        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13220        // the load-bearing axis on every value that probes
13221        // positive for both — mirrors the cascade discipline on
13222        // every prior arm.
13223        let d = dep_with_fonte(DepSource::Path {
13224            caminho: "../foo\n[ch]".into(),
13225        });
13226        let err = d.validate().unwrap_err();
13227        assert!(
13228            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13229            "got {err:?}",
13230        );
13231    }
13232
13233    #[test]
13234    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13235        // Cascade pin on the load-bearing leading-byte arm: a
13236        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13237        // routes through `FonteCaminhoAbsolute` not
13238        // `FonteCaminhoShellBracketExpansion` — the host-layout-
13239        // leak diagnostic is the load-bearing axis, the bracket-
13240        // expansion byte is the secondary observation. Same
13241        // precedence logic as every prior leading-byte arm.
13242        let d = dep_with_fonte(DepSource::Path {
13243            caminho: "/etc/[ch]".into(),
13244        });
13245        let err = d.validate().unwrap_err();
13246        assert!(
13247            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13248            "got {err:?}",
13249        );
13250    }
13251
13252    #[test]
13253    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13254        // Cascade pin on the upstream leading-`$` var-expansion
13255        // arm: a value carrying both a leading `$` and a `[`
13256        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13257        // variable + bracket-class at the head of a sibling-
13258        // workspace path" footgun) routes through
13259        // `FonteCaminhoVarExpansion` not
13260        // `FonteCaminhoShellBracketExpansion`. The leading-byte
13261        // shell-variable-expansion is the more self-locating
13262        // diagnostic on values that probe as both — same
13263        // load-bearing-leading-byte cascade discipline every
13264        // prior `:caminho` arm establishes.
13265        let d = dep_with_fonte(DepSource::Path {
13266            caminho: "$DIR/[ch]".into(),
13267        });
13268        let err = d.validate().unwrap_err();
13269        assert!(
13270            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13271            "got {err:?}",
13272        );
13273    }
13274
13275    #[test]
13276    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13277        // Cascade pin on the immediate-successor arm: a value
13278        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13279        // the canonical "I tab-completed a path that already had
13280        // a bracket-glob-character-class expansion tail" footgun)
13281        // routes through `FonteCaminhoShellBracketExpansion` not
13282        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13283        // is the more semantic-locating axis (an author who
13284        // removes the `[` typically also drops the trailing
13285        // separator since both are paste-from-shell artifacts).
13286        let d = dep_with_fonte(DepSource::Path {
13287            caminho: "../[a-z]/".into(),
13288        });
13289        let err = d.validate().unwrap_err();
13290        assert!(
13291            matches!(
13292                err,
13293                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13294            ),
13295            "got {err:?}",
13296        );
13297    }
13298
13299    #[test]
13300    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13301        // Diagnostic-shape pin (peer with
13302        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13303        // on the closest two-byte peer arm): the error's Display
13304        // surfaces the offending `:nome`, the offending `:caminho`
13305        // verbatim, the offending byte's hex / character form, and
13306        // names the shell-bracket-expansion / glob-character-class
13307        // footgun explicitly so a `feira lint` run can render the
13308        // diagnostic without re-parsing.
13309        let d = dep_with_fonte(DepSource::Path {
13310            caminho: "../caixa-[a-z]/build".into(),
13311        });
13312        let rendered = d.validate().unwrap_err().to_string();
13313        assert!(
13314            rendered.contains("caixa-teia"),
13315            "diagnostic must name the offending dep: {rendered}",
13316        );
13317        assert!(
13318            rendered.contains("../caixa-[a-z]/build"),
13319            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13320        );
13321        assert!(
13322            rendered.contains("0x5b"),
13323            "diagnostic must surface the offending byte hex: {rendered:?}",
13324        );
13325        assert!(
13326            rendered.contains("bracket-expansion"),
13327            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13328        );
13329        assert!(
13330            rendered.contains("glob-character-class"),
13331            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13332             {rendered:?}",
13333        );
13334    }
13335
13336    #[test]
13337    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13338        // The canonical paste-from-shell-history strong-quoted
13339        // sibling-workspace-path footgun: an author copies a
13340        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13341        // quoting preserved the path across a whitespace paste
13342        // boundary and silently passed every prior arm
13343        // (`Path::is_absolute` false on `'..`, no control bytes, no
13344        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13345        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13346        // doesn't end in `/`; the leading-`$` f4efe9c
13347        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13348        // value starts with `'` not `$`). The lacre embedded the
13349        // value verbatim, the resolver folded it through
13350        // `Path::join` looking for a literal `./'../caixa-teia'`
13351        // subdirectory, and the failure surfaced at resolve time
13352        // with a non-self-locating `No such file or directory`
13353        // error. The new arm moves the rejection to validate time
13354        // and names the offending dep + caminho + byte verbatim.
13355        // The arm fires on the first `'` encountered.
13356        let d = dep_with_fonte(DepSource::Path {
13357            caminho: "'../caixa-teia'".into(),
13358        });
13359        let err = d.validate().unwrap_err();
13360        let DepError::FonteCaminhoShellQuoteGrouping {
13361            nome,
13362            caminho,
13363            byte,
13364        } = err
13365        else {
13366            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13367        };
13368        assert_eq!(nome, "caixa-teia");
13369        assert_eq!(caminho, "'../caixa-teia'");
13370        assert_eq!(byte, b'\'');
13371    }
13372
13373    #[test]
13374    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13375        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13376        // — the canonical paste-from-JSON-config / paste-from-YAML-
13377        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13378        // tatara-lisp-string-literal cross-idiom leak). Pinned
13379        // separately from the single-quote shape so the gate's
13380        // contract is "any `'` or `\"` anywhere", not single-byte
13381        // coverage. Mirrors the peer
13382        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13383        // shape on the immediate-predecessor
13384        // `FonteCaminhoShellBracketExpansion` arm.
13385        let d = dep_with_fonte(DepSource::Path {
13386            caminho: "\"../caixa-teia\"".into(),
13387        });
13388        let err = d.validate().unwrap_err();
13389        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13390            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13391        };
13392        assert_eq!(byte, b'"');
13393    }
13394
13395    #[test]
13396    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13397        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13398        // canonical "I pasted a JSON key-value pair fragment into
13399        // the middle of the path" idiom). Pinned separately from
13400        // the leading-byte shape so the gate covers every position,
13401        // not only leading.
13402        let d = dep_with_fonte(DepSource::Path {
13403            caminho: "../\"caixa-teia\"".into(),
13404        });
13405        let err = d.validate().unwrap_err();
13406        assert!(
13407            matches!(
13408                err,
13409                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13410            ),
13411            "got {err:?}",
13412        );
13413    }
13414
13415    #[test]
13416    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13417        // The canonical YAML double-quoted flow-scalar cross-idiom
13418        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13419        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13420        // values.yaml / K8s manifest and dropped it verbatim into
13421        // the `:caminho` slot including the `path: ` key prefix"
13422        // paste-idiom). The arm fires on the first `"` encountered;
13423        // pinned so the gate's coverage extends from the bare-quote
13424        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13425        // shape.
13426        let d = dep_with_fonte(DepSource::Path {
13427            caminho: "path: \"../caixa-teia\"".into(),
13428        });
13429        let err = d.validate().unwrap_err();
13430        assert!(
13431            matches!(
13432                err,
13433                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13434            ),
13435            "got {err:?}",
13436        );
13437    }
13438
13439    #[test]
13440    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13441        // The positive-control pin: the gate targets only `'` /
13442        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13443        // The canonical relative POSIX path (`"../caixa-teia"`) and
13444        // a nested deeply-pathed variant with adjacent printable
13445        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13446        // to validate cleanly so the gate doesn't widen to a "no
13447        // printable punctuation anywhere" sweep that would defeat
13448        // the entire path-fonte author surface. Peer with
13449        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13450        // on the immediate-predecessor arm.
13451        let d = dep_with_fonte(DepSource::Path {
13452            caminho: "../caixa-teia/sub-dir.v2".into(),
13453        });
13454        d.validate().unwrap();
13455    }
13456
13457    #[test]
13458    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13459        // Cascade pin on the immediate-predecessor arm: a value
13460        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13461        // "I pasted a glob-character-class followed by a strong-
13462        // quoted literal tail" footgun) routes through
13463        // `FonteCaminhoShellBracketExpansion` not
13464        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13465        // expansion is the load-bearing root-cause edit on every
13466        // probe-as-both value; same cascade discipline every prior
13467        // `:caminho` arm establishes.
13468        let d = dep_with_fonte(DepSource::Path {
13469            caminho: "../[a-z]'x'".into(),
13470        });
13471        let err = d.validate().unwrap_err();
13472        assert!(
13473            matches!(
13474                err,
13475                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13476            ),
13477            "got {err:?}",
13478        );
13479    }
13480
13481    #[test]
13482    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13483        // Cascade pin on the upstream shell-brace-expansion arm: a
13484        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13485        // canonical "I pasted a brace-expansion fan followed by a
13486        // strong-quoted literal tail" footgun) routes through
13487        // `FonteCaminhoShellBraceExpansion` not
13488        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13489        // is the load-bearing root-cause edit on every probe-as-
13490        // both value.
13491        let d = dep_with_fonte(DepSource::Path {
13492            caminho: "../{a,b}'x'".into(),
13493        });
13494        let err = d.validate().unwrap_err();
13495        assert!(
13496            matches!(
13497                err,
13498                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13499            ),
13500            "got {err:?}",
13501        );
13502    }
13503
13504    #[test]
13505    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13506        // Cascade pin on the upstream shell-subshell-grouping arm:
13507        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13508        // the canonical "I pasted a subshell-grouping followed by
13509        // a strong-quoted literal tail" footgun) routes through
13510        // `FonteCaminhoShellSubshellGrouping` not
13511        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13512        // `$(<cmd>)` command-substitution boundary is the load-
13513        // bearing axis on every probe-as-both value.
13514        let d = dep_with_fonte(DepSource::Path {
13515            caminho: "../(cd foo)/'x'".into(),
13516        });
13517        let err = d.validate().unwrap_err();
13518        assert!(
13519            matches!(
13520                err,
13521                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13522            ),
13523            "got {err:?}",
13524        );
13525    }
13526
13527    #[test]
13528    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13529        // Cascade pin on the upstream shell-glob arm: a value
13530        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13531        // canonical "I pasted a `*` unbounded pathname-expansion
13532        // followed by a strong-quoted literal tail" footgun) routes
13533        // through `FonteCaminhoShellGlob` not
13534        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13535        // expansion sentinel is the load-bearing root-cause edit
13536        // on every probe-as-both value.
13537        let d = dep_with_fonte(DepSource::Path {
13538            caminho: "../caixa-teia/*'x'".into(),
13539        });
13540        let err = d.validate().unwrap_err();
13541        assert!(
13542            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13543            "got {err:?}",
13544        );
13545    }
13546
13547    #[test]
13548    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13549        // Cascade pin on the upstream shell-command-substitution
13550        // arm: a value carrying both a backtick and `'`
13551        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13552        // legacy-backtick command-substitution followed by a
13553        // strong-quoted literal tail" footgun) routes through
13554        // `FonteCaminhoShellCommandSubstitution` not
13555        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13556        // command-injection vector is the load-bearing root-cause
13557        // edit on every probe-as-both value.
13558        let d = dep_with_fonte(DepSource::Path {
13559            caminho: "../`whoami`/'x'".into(),
13560        });
13561        let err = d.validate().unwrap_err();
13562        assert!(
13563            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13564            "got {err:?}",
13565        );
13566    }
13567
13568    #[test]
13569    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13570        // Cascade pin on the upstream shell-background arm: a value
13571        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13572        // canonical "I pasted a `cmd & 'literal'` background-launch
13573        // + quote chain" footgun) routes through
13574        // `FonteCaminhoShellBackground` not
13575        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13576        // tail is the load-bearing root-cause edit on every
13577        // probe-as-both value.
13578        let d = dep_with_fonte(DepSource::Path {
13579            caminho: "../caixa-teia & 'x'".into(),
13580        });
13581        let err = d.validate().unwrap_err();
13582        assert!(
13583            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13584            "got {err:?}",
13585        );
13586    }
13587
13588    #[test]
13589    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13590        // Cascade pin on the upstream shell-semicolon arm: a value
13591        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13592        // canonical sequential-cleanup + quote paste idiom) routes
13593        // through `FonteCaminhoShellSemicolon` not
13594        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13595        // separator paste is the load-bearing root-cause edit on
13596        // every probe-as-both value.
13597        let d = dep_with_fonte(DepSource::Path {
13598            caminho: "../caixa-teia; 'x'".into(),
13599        });
13600        let err = d.validate().unwrap_err();
13601        assert!(
13602            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13603            "got {err:?}",
13604        );
13605    }
13606
13607    #[test]
13608    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13609        // Cascade pin on the upstream shell-pipe arm: a value
13610        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13611        // canonical pipeline-to-quoted-literal paste idiom) routes
13612        // through `FonteCaminhoShellPipe` not
13613        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13614        // is the load-bearing root-cause edit on every probe-as-
13615        // both value.
13616        let d = dep_with_fonte(DepSource::Path {
13617            caminho: "../caixa-teia | 'x'".into(),
13618        });
13619        let err = d.validate().unwrap_err();
13620        assert!(
13621            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13622            "got {err:?}",
13623        );
13624    }
13625
13626    #[test]
13627    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13628        // Cascade pin on the upstream shell-redirection arm: a
13629        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13630        // — the canonical "I pasted a `cmd > log 'literal'`
13631        // redirect-plus-quote chain" footgun) routes through
13632        // `FonteCaminhoShellRedirection` not
13633        // `FonteCaminhoShellQuoteGrouping`. The input/output
13634        // redirection metachar carries the more self-locating
13635        // `byte` payload, so the prior arm wins on every probe-as-
13636        // both value.
13637        let d = dep_with_fonte(DepSource::Path {
13638            caminho: "../caixa-teia>log 'x'".into(),
13639        });
13640        let err = d.validate().unwrap_err();
13641        assert!(
13642            matches!(
13643                err,
13644                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13645            ),
13646            "got {err:?}",
13647        );
13648    }
13649
13650    #[test]
13651    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13652        // Cascade pin on the upstream backslash arm: a value
13653        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13654        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13655        // chain" footgun) routes through `FonteCaminhoBackslash`
13656        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13657        // separator divergence is the load-bearing axis on every
13658        // probe-as-both value.
13659        let d = dep_with_fonte(DepSource::Path {
13660            caminho: "..\\caixa-teia\\'x'".into(),
13661        });
13662        let err = d.validate().unwrap_err();
13663        assert!(
13664            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13665            "got {err:?}",
13666        );
13667    }
13668
13669    #[test]
13670    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13671        // Cascade pin on the embedded-control-byte arm: a value
13672        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13673        // the canonical paste-from-multiline-doc footgun where a
13674        // newline landed mid-caminho between two paste fragments)
13675        // routes through `FonteCaminhoControlChar` not
13676        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13677        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13678        // the load-bearing axis on every value that probes
13679        // positive for both — mirrors the cascade discipline on
13680        // every prior arm.
13681        let d = dep_with_fonte(DepSource::Path {
13682            caminho: "../foo\n'x'".into(),
13683        });
13684        let err = d.validate().unwrap_err();
13685        assert!(
13686            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13687            "got {err:?}",
13688        );
13689    }
13690
13691    #[test]
13692    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13693        // Cascade pin on the load-bearing leading-byte arm: a
13694        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13695        // through `FonteCaminhoAbsolute` not
13696        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13697        // diagnostic is the load-bearing axis, the quote byte is
13698        // the secondary observation. Same precedence logic as every
13699        // prior leading-byte arm.
13700        let d = dep_with_fonte(DepSource::Path {
13701            caminho: "/etc/'x'".into(),
13702        });
13703        let err = d.validate().unwrap_err();
13704        assert!(
13705            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13706            "got {err:?}",
13707        );
13708    }
13709
13710    #[test]
13711    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13712        // Cascade pin on the upstream leading-`$` var-expansion
13713        // arm: a value carrying both a leading `$` and a `'`
13714        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13715        // variable + quoted literal at the head of a sibling-
13716        // workspace path" footgun) routes through
13717        // `FonteCaminhoVarExpansion` not
13718        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13719        // shell-variable-expansion is the more self-locating
13720        // diagnostic on values that probe as both — same
13721        // load-bearing-leading-byte cascade discipline every
13722        // prior `:caminho` arm establishes.
13723        let d = dep_with_fonte(DepSource::Path {
13724            caminho: "$DIR/'x'".into(),
13725        });
13726        let err = d.validate().unwrap_err();
13727        assert!(
13728            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13729            "got {err:?}",
13730        );
13731    }
13732
13733    #[test]
13734    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13735        // Cascade pin on the immediate-successor arm: a value
13736        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13737        // — the canonical "I tab-completed a path whose strong-
13738        // quoted body already carried the quoting from a shell-
13739        // history paste" footgun) routes through
13740        // `FonteCaminhoShellQuoteGrouping` not
13741        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13742        // is the more semantic-locating axis (an author who removes
13743        // the `'` typically also drops the trailing separator since
13744        // both are paste-from-shell artifacts).
13745        let d = dep_with_fonte(DepSource::Path {
13746            caminho: "../'caixa-teia'/".into(),
13747        });
13748        let err = d.validate().unwrap_err();
13749        assert!(
13750            matches!(
13751                err,
13752                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13753            ),
13754            "got {err:?}",
13755        );
13756    }
13757
13758    #[test]
13759    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13760        // Diagnostic-shape pin (peer with
13761        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13762        // on the closest two-byte peer arm): the error's Display
13763        // surfaces the offending `:nome`, the offending `:caminho`
13764        // verbatim, the offending byte's hex / character form, and
13765        // names the shell-quote-grouping / cross-config-DSL-string-
13766        // literal-delimiter footgun explicitly so a `feira lint`
13767        // run can render the diagnostic without re-parsing.
13768        let d = dep_with_fonte(DepSource::Path {
13769            caminho: "'../caixa-teia'".into(),
13770        });
13771        let rendered = d.validate().unwrap_err().to_string();
13772        assert!(
13773            rendered.contains("caixa-teia"),
13774            "diagnostic must name the offending dep: {rendered}",
13775        );
13776        assert!(
13777            rendered.contains("'../caixa-teia'"),
13778            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13779        );
13780        assert!(
13781            rendered.contains("0x27"),
13782            "diagnostic must surface the offending byte hex: {rendered:?}",
13783        );
13784        assert!(
13785            rendered.contains("quote-grouping"),
13786            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13787        );
13788        assert!(
13789            rendered.contains("string-literal"),
13790            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13791             vocabulary: {rendered:?}",
13792        );
13793    }
13794
13795    #[test]
13796    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13797        // The canonical paste-from-shell-history-with-trailing-
13798        // annotation footgun: an author pastes a `cd ../caixa-teia
13799        // # legacy sibling` shell-history one-liner whose unquoted `#`
13800        // comment-lead separates the path from an inline annotation.
13801        // The POSIX shell trims the annotation to `../caixa-teia`
13802        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13803        // `Path::is_absolute` returns false on `..`, `#` is neither
13804        // a leading-byte sentinel nor a control byte nor `\` nor
13805        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13806        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13807        // `"`, and the value's last byte isn't `/` — so the value
13808        // silently passed every prior arm. The resolver folded the
13809        // value through `Path::join` looking for a literal
13810        // `./../caixa-teia # legacy sibling` subdirectory and the
13811        // failure surfaced at resolve time with a non-self-locating
13812        // `No such file or directory` error. The new arm moves the
13813        // rejection to validate time and names the offending dep +
13814        // caminho + byte verbatim.
13815        let d = dep_with_fonte(DepSource::Path {
13816            caminho: "../caixa-teia # legacy sibling".into(),
13817        });
13818        let err = d.validate().unwrap_err();
13819        let DepError::FonteCaminhoShellComment {
13820            nome,
13821            caminho,
13822            byte,
13823        } = err
13824        else {
13825            panic!("expected FonteCaminhoShellComment, got {err:?}");
13826        };
13827        assert_eq!(nome, "caixa-teia");
13828        assert_eq!(caminho, "../caixa-teia # legacy sibling");
13829        assert_eq!(byte, b'#');
13830    }
13831
13832    #[test]
13833    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13834        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13835        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
13836        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
13837        // scalar-plus-comment entry out of an aligned values.yaml and
13838        // dropped it verbatim into the `:caminho` slot" paste-idiom).
13839        // Pinned separately from the shell-history shape so the
13840        // gate's coverage extends from the single-space `#` shape to
13841        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
13842        // requires the `#` to be preceded by whitespace to lex as a
13843        // comment (bare `foo#bar` is a single scalar); the double-
13844        // space paste from an aligned manifest is the canonical
13845        // shape.
13846        let d = dep_with_fonte(DepSource::Path {
13847            caminho: "../caixa-teia  # pin".into(),
13848        });
13849        let err = d.validate().unwrap_err();
13850        assert!(
13851            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13852            "got {err:?}",
13853        );
13854    }
13855
13856    #[test]
13857    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13858        // The URL-fragment-identifier paste shape
13859        // (`"../caixa-teia#readme"` — the canonical
13860        // paste-from-browser-address-bar permalink shape where the
13861        // browser preserved the `#anchor` tail on the copy). Pinned
13862        // separately from the whitespace-separated shell / YAML
13863        // comment shapes so the gate covers the unpadded RFC 3986
13864        // §3.5 fragment-delimiter position too, not only positions
13865        // preceded by unquoted whitespace. Peer with the immediate-
13866        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13867        // (a68f818) which closes the same byte under the same URL-
13868        // fragment-identifier banner.
13869        let d = dep_with_fonte(DepSource::Path {
13870            caminho: "../caixa-teia#readme".into(),
13871        });
13872        let err = d.validate().unwrap_err();
13873        assert!(
13874            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13875            "got {err:?}",
13876        );
13877    }
13878
13879    #[test]
13880    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13881        // Leading-position `#` shape (`"#../caixa-teia"` — the
13882        // "I copied a shell-comment-out entry from a commented-out
13883        // dep row" footgun). Pinned separately from the embedded
13884        // shapes so the gate covers every position, not only
13885        // whitespace-preceded / mid-value.
13886        let d = dep_with_fonte(DepSource::Path {
13887            caminho: "#../caixa-teia".into(),
13888        });
13889        let err = d.validate().unwrap_err();
13890        assert!(
13891            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13892            "got {err:?}",
13893        );
13894    }
13895
13896    #[test]
13897    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13898        // The positive-control pin: the gate targets only `#`,
13899        // never adjacent printable ASCII or POSIX-valid bytes. The
13900        // canonical relative POSIX path (`"../caixa-teia"`) and a
13901        // nested deeply-pathed variant with adjacent printable
13902        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13903        // to validate cleanly so the gate doesn't widen to a "no
13904        // printable punctuation anywhere" sweep that would defeat
13905        // the entire path-fonte author surface. Peer with
13906        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13907        // on the immediate-predecessor arm.
13908        let d = dep_with_fonte(DepSource::Path {
13909            caminho: "../caixa-teia/sub-dir.v2".into(),
13910        });
13911        d.validate().unwrap();
13912    }
13913
13914    #[test]
13915    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13916        // Cascade pin on the immediate-predecessor arm: a value
13917        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13918        // "I pasted a strong-quoted literal followed by a URL-
13919        // fragment permalink tail" footgun) routes through
13920        // `FonteCaminhoShellQuoteGrouping` not
13921        // `FonteCaminhoShellComment`. The shell-string-literal-
13922        // delimiter is the load-bearing root-cause edit on every
13923        // probe-as-both value; same cascade discipline every prior
13924        // `:caminho` arm establishes.
13925        let d = dep_with_fonte(DepSource::Path {
13926            caminho: "../'x'#pin".into(),
13927        });
13928        let err = d.validate().unwrap_err();
13929        assert!(
13930            matches!(
13931                err,
13932                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13933            ),
13934            "got {err:?}",
13935        );
13936    }
13937
13938    #[test]
13939    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13940        // Cascade pin on the upstream shell-bracket-expansion arm:
13941        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13942        // canonical "I pasted a glob-character-class followed by a
13943        // URL-fragment tail" footgun) routes through
13944        // `FonteCaminhoShellBracketExpansion` not
13945        // `FonteCaminhoShellComment`. The glob-character-class
13946        // expansion is the load-bearing root-cause edit on every
13947        // probe-as-both value.
13948        let d = dep_with_fonte(DepSource::Path {
13949            caminho: "../[a-z]#pin".into(),
13950        });
13951        let err = d.validate().unwrap_err();
13952        assert!(
13953            matches!(
13954                err,
13955                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13956            ),
13957            "got {err:?}",
13958        );
13959    }
13960
13961    #[test]
13962    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13963        // Cascade pin on the upstream shell-brace-expansion arm: a
13964        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13965        // canonical "I pasted a brace-expansion fan followed by a
13966        // URL-fragment tail" footgun) routes through
13967        // `FonteCaminhoShellBraceExpansion` not
13968        // `FonteCaminhoShellComment`. The brace-expansion fan is the
13969        // load-bearing root-cause edit on every probe-as-both value.
13970        let d = dep_with_fonte(DepSource::Path {
13971            caminho: "../{a,b}#pin".into(),
13972        });
13973        let err = d.validate().unwrap_err();
13974        assert!(
13975            matches!(
13976                err,
13977                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13978            ),
13979            "got {err:?}",
13980        );
13981    }
13982
13983    #[test]
13984    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13985        // Cascade pin on the upstream shell-subshell-grouping arm:
13986        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13987        // the canonical "I pasted a subshell-grouping followed by a
13988        // URL-fragment tail" footgun) routes through
13989        // `FonteCaminhoShellSubshellGrouping` not
13990        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13991        // command-substitution boundary is the load-bearing axis on
13992        // every probe-as-both value.
13993        let d = dep_with_fonte(DepSource::Path {
13994            caminho: "../(cd foo)#pin".into(),
13995        });
13996        let err = d.validate().unwrap_err();
13997        assert!(
13998            matches!(
13999                err,
14000                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14001            ),
14002            "got {err:?}",
14003        );
14004    }
14005
14006    #[test]
14007    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14008        // Cascade pin on the upstream shell-glob arm: a value
14009        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14010        // canonical "I pasted a `*` unbounded pathname-expansion
14011        // followed by a URL-fragment tail" footgun) routes through
14012        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14013        // The unbounded pathname-expansion sentinel is the load-
14014        // bearing root-cause edit on every probe-as-both value.
14015        let d = dep_with_fonte(DepSource::Path {
14016            caminho: "../caixa-teia/*#pin".into(),
14017        });
14018        let err = d.validate().unwrap_err();
14019        assert!(
14020            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14021            "got {err:?}",
14022        );
14023    }
14024
14025    #[test]
14026    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14027        // Cascade pin on the upstream shell-command-substitution
14028        // arm: a value carrying both a backtick and `#`
14029        // (``"../`whoami`#pin"`` — the canonical "I pasted a
14030        // legacy-backtick command-substitution followed by a URL-
14031        // fragment tail" footgun) routes through
14032        // `FonteCaminhoShellCommandSubstitution` not
14033        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14034        // injection vector is the load-bearing root-cause edit on
14035        // every probe-as-both value.
14036        let d = dep_with_fonte(DepSource::Path {
14037            caminho: "../`whoami`#pin".into(),
14038        });
14039        let err = d.validate().unwrap_err();
14040        assert!(
14041            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14042            "got {err:?}",
14043        );
14044    }
14045
14046    #[test]
14047    fn fonte_caminho_shell_background_fires_before_shell_comment() {
14048        // Cascade pin on the upstream shell-background arm: a value
14049        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14050        // the canonical "I pasted a `cmd &` background-launch
14051        // followed by a URL-fragment tail" footgun) routes through
14052        // `FonteCaminhoShellBackground` not
14053        // `FonteCaminhoShellComment`. The background-launch tail is
14054        // the load-bearing root-cause edit on every probe-as-both
14055        // value.
14056        let d = dep_with_fonte(DepSource::Path {
14057            caminho: "../caixa-teia&pin#tail".into(),
14058        });
14059        let err = d.validate().unwrap_err();
14060        assert!(
14061            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14062            "got {err:?}",
14063        );
14064    }
14065
14066    #[test]
14067    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14068        // Cascade pin on the upstream shell-semicolon arm: a value
14069        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14070        // the canonical sequential-cleanup + URL-fragment paste
14071        // idiom) routes through `FonteCaminhoShellSemicolon` not
14072        // `FonteCaminhoShellComment`. The sequential-command-
14073        // separator paste is the load-bearing root-cause edit on
14074        // every probe-as-both value.
14075        let d = dep_with_fonte(DepSource::Path {
14076            caminho: "../caixa-teia;pin#tail".into(),
14077        });
14078        let err = d.validate().unwrap_err();
14079        assert!(
14080            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14081            "got {err:?}",
14082        );
14083    }
14084
14085    #[test]
14086    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14087        // Cascade pin on the upstream shell-pipe arm: a value
14088        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14089        // the canonical pipeline-to-URL-fragment paste idiom) routes
14090        // through `FonteCaminhoShellPipe` not
14091        // `FonteCaminhoShellComment`. The pipeline-tail paste is
14092        // the load-bearing root-cause edit on every probe-as-both
14093        // value.
14094        let d = dep_with_fonte(DepSource::Path {
14095            caminho: "../caixa-teia|pin#tail".into(),
14096        });
14097        let err = d.validate().unwrap_err();
14098        assert!(
14099            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14100            "got {err:?}",
14101        );
14102    }
14103
14104    #[test]
14105    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14106        // Cascade pin on the upstream shell-redirection arm: a
14107        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14108        // — the canonical "I pasted a `cmd > log` redirect followed
14109        // by a URL-fragment tail" footgun) routes through
14110        // `FonteCaminhoShellRedirection` not
14111        // `FonteCaminhoShellComment`. The input/output redirection
14112        // metachar carries the more self-locating `byte` payload,
14113        // so the prior arm wins on every probe-as-both value.
14114        let d = dep_with_fonte(DepSource::Path {
14115            caminho: "../caixa-teia>log#pin".into(),
14116        });
14117        let err = d.validate().unwrap_err();
14118        assert!(
14119            matches!(
14120                err,
14121                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14122            ),
14123            "got {err:?}",
14124        );
14125    }
14126
14127    #[test]
14128    fn fonte_caminho_backslash_fires_before_shell_comment() {
14129        // Cascade pin on the upstream backslash arm: a value
14130        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14131        // canonical "I pasted a Windows-shell path followed by a
14132        // URL-fragment tail" footgun) routes through
14133        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14134        // The cross-host-OS-separator divergence is the load-
14135        // bearing axis on every probe-as-both value.
14136        let d = dep_with_fonte(DepSource::Path {
14137            caminho: "..\\caixa-teia#pin".into(),
14138        });
14139        let err = d.validate().unwrap_err();
14140        assert!(
14141            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14142            "got {err:?}",
14143        );
14144    }
14145
14146    #[test]
14147    fn fonte_caminho_control_char_fires_before_shell_comment() {
14148        // Cascade pin on the embedded-control-byte arm: a value
14149        // carrying both a control byte and `#` (`"../foo\n#pin"` —
14150        // the canonical paste-from-multiline-doc footgun where a
14151        // newline landed mid-caminho between the path and an
14152        // annotation) routes through `FonteCaminhoControlChar` not
14153        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14154        // byte diagnostic is the load-bearing axis on every value
14155        // that probes positive for both — mirrors the cascade
14156        // discipline on every prior arm.
14157        let d = dep_with_fonte(DepSource::Path {
14158            caminho: "../foo\n#pin".into(),
14159        });
14160        let err = d.validate().unwrap_err();
14161        assert!(
14162            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14163            "got {err:?}",
14164        );
14165    }
14166
14167    #[test]
14168    fn fonte_caminho_absolute_fires_before_shell_comment() {
14169        // Cascade pin on the load-bearing leading-byte arm: a
14170        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14171        // routes through `FonteCaminhoAbsolute` not
14172        // `FonteCaminhoShellComment` — the host-layout-leak
14173        // diagnostic is the load-bearing axis, the fragment byte is
14174        // the secondary observation. Same precedence logic as every
14175        // prior leading-byte arm.
14176        let d = dep_with_fonte(DepSource::Path {
14177            caminho: "/etc/foo#pin".into(),
14178        });
14179        let err = d.validate().unwrap_err();
14180        assert!(
14181            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14182            "got {err:?}",
14183        );
14184    }
14185
14186    #[test]
14187    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14188        // Cascade pin on the upstream leading-`$` var-expansion
14189        // arm: a value carrying both a leading `$` and a `#`
14190        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14191        // shell-variable at the head of a sibling-workspace path
14192        // followed by a URL-fragment tail" footgun) routes through
14193        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14194        // The leading-byte shell-variable-expansion is the more
14195        // self-locating diagnostic on values that probe as both.
14196        let d = dep_with_fonte(DepSource::Path {
14197            caminho: "$DIR/foo#pin".into(),
14198        });
14199        let err = d.validate().unwrap_err();
14200        assert!(
14201            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14202            "got {err:?}",
14203        );
14204    }
14205
14206    #[test]
14207    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14208        // Cascade pin on the immediate-successor arm: a value
14209        // carrying both `#` and a trailing `/`
14210        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14211        // a URL-fragment-carrying path" footgun) routes through
14212        // `FonteCaminhoShellComment` not
14213        // `FonteCaminhoTrailingSlash`. The embedded fragment /
14214        // comment-lead byte is the more semantic-locating axis (an
14215        // author who removes the `#pin` fragment typically also
14216        // drops the trailing separator since both are paste-from-
14217        // URL / paste-from-shell-tab-completion artifacts).
14218        let d = dep_with_fonte(DepSource::Path {
14219            caminho: "../caixa-teia#pin/".into(),
14220        });
14221        let err = d.validate().unwrap_err();
14222        assert!(
14223            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14224            "got {err:?}",
14225        );
14226    }
14227
14228    #[test]
14229    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14230        // Diagnostic-shape pin (peer with
14231        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14232        // on the immediate-predecessor arm): the error's Display
14233        // surfaces the offending `:nome`, the offending `:caminho`
14234        // verbatim, the offending byte's hex / character form, and
14235        // names the shell-comment / URL-fragment-identifier /
14236        // YAML-comment cross-config-DSL footgun explicitly so a
14237        // `feira lint` run can render the diagnostic without
14238        // re-parsing.
14239        let d = dep_with_fonte(DepSource::Path {
14240            caminho: "../caixa-teia#readme".into(),
14241        });
14242        let rendered = d.validate().unwrap_err().to_string();
14243        assert!(
14244            rendered.contains("caixa-teia"),
14245            "diagnostic must name the offending dep: {rendered}",
14246        );
14247        assert!(
14248            rendered.contains("../caixa-teia#readme"),
14249            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14250        );
14251        assert!(
14252            rendered.contains("0x23"),
14253            "diagnostic must surface the offending byte hex: {rendered:?}",
14254        );
14255        assert!(
14256            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14257            "diagnostic must name the shell-comment footgun: {rendered:?}",
14258        );
14259        assert!(
14260            rendered.contains("fragment") || rendered.contains("URL-fragment"),
14261            "diagnostic must reference the URL-fragment-identifier vocabulary: \
14262             {rendered:?}",
14263        );
14264    }
14265
14266    #[test]
14267    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14268        // The canonical paste-from-browser-address-bar percent-
14269        // encoded-space footgun: an author copies `../caixa%20teia`
14270        // out of a URL-encoded README hyperlink / browser address
14271        // bar / percent-encoded permalink expecting `%20` to decode
14272        // to a literal space at the filesystem layer. POSIX
14273        // `std::path::Path` treats `%` as a literal path-component
14274        // byte, so `Path::join` looks for a literal
14275        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14276        // returns false on `..`, `%` is neither a leading-byte
14277        // sentinel nor a control byte nor `\` nor `<` / `>` nor
14278        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14279        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14280        // and the value's last byte isn't `/` — so the value
14281        // silently passed every prior arm. The new arm moves the
14282        // rejection to validate time and names the offending dep +
14283        // caminho + byte verbatim.
14284        let d = dep_with_fonte(DepSource::Path {
14285            caminho: "../caixa%20teia".into(),
14286        });
14287        let err = d.validate().unwrap_err();
14288        let DepError::FonteCaminhoUrlPercentEncoding {
14289            nome,
14290            caminho,
14291            byte,
14292        } = err
14293        else {
14294            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14295        };
14296        assert_eq!(nome, "caixa-teia");
14297        assert_eq!(caminho, "../caixa%20teia");
14298        assert_eq!(byte, b'%');
14299    }
14300
14301    #[test]
14302    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14303        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14304        // intending the `%2F` as the URL encoding of `/`) locks a
14305        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14306        // the byte-identical `path:../caixa/teia` form. Pinned
14307        // separately from the space-encoded shape so the gate's
14308        // coverage extends past the single canonical `%20` example
14309        // to any two-hex-digit percent-encoded sequence.
14310        let d = dep_with_fonte(DepSource::Path {
14311            caminho: "../caixa%2Fteia".into(),
14312        });
14313        let err = d.validate().unwrap_err();
14314        assert!(
14315            matches!(
14316                err,
14317                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14318            ),
14319            "got {err:?}",
14320        );
14321    }
14322
14323    #[test]
14324    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14325        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14326        // where `%` isn't followed by two hex digits) — every
14327        // WHATWG-conformant URL parser rejects the value at parse
14328        // time per RFC 3986 §2.1, but the byte would silently ride
14329        // into the lacre before the resolver subprocess crosses the
14330        // URL-parser boundary. Pinned separately from the well-
14331        // formed `%HH` shapes so the gate covers every percent-
14332        // occurrence, not only strictly-conformant escapes.
14333        let d = dep_with_fonte(DepSource::Path {
14334            caminho: "../caixa-teia%foo".into(),
14335        });
14336        let err = d.validate().unwrap_err();
14337        assert!(
14338            matches!(
14339                err,
14340                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14341            ),
14342            "got {err:?}",
14343        );
14344    }
14345
14346    #[test]
14347    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14348        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14349        // — the canonical paste-from-top-of-doc YAML directive
14350        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14351        // separately from embedded shapes so the gate covers the
14352        // leading-position `%` too, not only mid-value occurrences.
14353        let d = dep_with_fonte(DepSource::Path {
14354            caminho: "%YAML/../caixa-teia".into(),
14355        });
14356        let err = d.validate().unwrap_err();
14357        assert!(
14358            matches!(
14359                err,
14360                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14361            ),
14362            "got {err:?}",
14363        );
14364    }
14365
14366    #[test]
14367    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14368        // The printf-format-specifier paste shape
14369        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14370        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14371        // 134 format-string-injection vector). Pinned separately
14372        // from the URL-encoding shapes so the gate's rationale
14373        // extends past the RFC 3986 axis to the C / POSIX printf
14374        // format-directive-lead axis.
14375        let d = dep_with_fonte(DepSource::Path {
14376            caminho: "../caixa-%s-teia".into(),
14377        });
14378        let err = d.validate().unwrap_err();
14379        assert!(
14380            matches!(
14381                err,
14382                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14383            ),
14384            "got {err:?}",
14385        );
14386    }
14387
14388    #[test]
14389    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14390        // The positive-control pin: the gate targets only `%`,
14391        // never adjacent printable ASCII or POSIX-valid bytes. The
14392        // canonical relative POSIX path (`"../caixa-teia"`) and a
14393        // nested deeply-pathed variant with adjacent printable
14394        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14395        // to validate cleanly so the gate doesn't widen to a "no
14396        // printable punctuation anywhere" sweep that would defeat
14397        // the entire path-fonte author surface. Peer with
14398        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14399        // on the immediate-predecessor arm.
14400        let d = dep_with_fonte(DepSource::Path {
14401            caminho: "../caixa-teia/sub-dir.v2".into(),
14402        });
14403        d.validate().unwrap();
14404    }
14405
14406    #[test]
14407    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14408        // Cascade pin on the immediate-predecessor arm: a value
14409        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14410        // canonical "I pasted a URL-fragment permalink followed by a
14411        // percent-encoded space tail" footgun) routes through
14412        // `FonteCaminhoShellComment` not
14413        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14414        // identifier is the load-bearing downstream-truncation edit
14415        // on every probe-as-both value; same cascade discipline
14416        // every prior `:caminho` arm establishes.
14417        let d = dep_with_fonte(DepSource::Path {
14418            caminho: "../caixa-teia#pin%20".into(),
14419        });
14420        let err = d.validate().unwrap_err();
14421        assert!(
14422            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14423            "got {err:?}",
14424        );
14425    }
14426
14427    #[test]
14428    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14429        // Cascade pin on the upstream shell-quote-grouping arm: a
14430        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14431        // canonical "I pasted a strong-quoted literal followed by
14432        // a percent-encoded space" footgun) routes through
14433        // `FonteCaminhoShellQuoteGrouping` not
14434        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14435        // literal-delimiter is the load-bearing root-cause edit on
14436        // every probe-as-both value.
14437        let d = dep_with_fonte(DepSource::Path {
14438            caminho: "../'x'%20teia".into(),
14439        });
14440        let err = d.validate().unwrap_err();
14441        assert!(
14442            matches!(
14443                err,
14444                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14445            ),
14446            "got {err:?}",
14447        );
14448    }
14449
14450    #[test]
14451    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14452        // Cascade pin on the upstream backslash arm: a value
14453        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14454        // canonical "I pasted a Windows-shell path followed by a
14455        // percent-encoded space" footgun) routes through
14456        // `FonteCaminhoBackslash` not
14457        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14458        // separator divergence is the load-bearing root-cause edit
14459        // on every probe-as-both value.
14460        let d = dep_with_fonte(DepSource::Path {
14461            caminho: "..\\caixa%20teia".into(),
14462        });
14463        let err = d.validate().unwrap_err();
14464        assert!(
14465            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14466            "got {err:?}",
14467        );
14468    }
14469
14470    #[test]
14471    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14472        // Cascade pin on the upstream control-char arm: a value
14473        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14474        // the canonical "I pasted a paste-from-binary-blob path
14475        // followed by a percent-encoded space" footgun) routes
14476        // through `FonteCaminhoControlChar` not
14477        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14478        // rejected byte is the load-bearing root-cause edit on
14479        // every probe-as-both value.
14480        let d = dep_with_fonte(DepSource::Path {
14481            caminho: "../caixa\0%20teia".into(),
14482        });
14483        let err = d.validate().unwrap_err();
14484        assert!(
14485            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14486            "got {err:?}",
14487        );
14488    }
14489
14490    #[test]
14491    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14492        // Cascade pin on the upstream absolute-path arm: a value
14493        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14494        // — the canonical "I pasted an absolute path with a
14495        // percent-encoded space tail" footgun) routes through
14496        // `FonteCaminhoAbsolute` not
14497        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14498        // the load-bearing root-cause edit on every probe-as-both
14499        // value.
14500        let d = dep_with_fonte(DepSource::Path {
14501            caminho: "/etc/passwd%20".into(),
14502        });
14503        let err = d.validate().unwrap_err();
14504        assert!(
14505            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14506            "got {err:?}",
14507        );
14508    }
14509
14510    #[test]
14511    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14512        // Cascade pin on the upstream var-expansion arm: a value
14513        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14514        // — the canonical "I pasted a `$HOME`-rooted path with a
14515        // percent-encoded space" footgun) routes through
14516        // `FonteCaminhoVarExpansion` not
14517        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14518        // expansion is the load-bearing root-cause edit on every
14519        // probe-as-both value.
14520        let d = dep_with_fonte(DepSource::Path {
14521            caminho: "$HOME/caixa%20teia".into(),
14522        });
14523        let err = d.validate().unwrap_err();
14524        assert!(
14525            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14526            "got {err:?}",
14527        );
14528    }
14529
14530    #[test]
14531    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14532        // Cascade pin on the immediate-successor arm: a value
14533        // carrying both `%` and a trailing `/`
14534        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14535        // percent-encoded-space-carrying path" footgun) routes
14536        // through `FonteCaminhoUrlPercentEncoding` not
14537        // `FonteCaminhoTrailingSlash`. The embedded percent-
14538        // encoding-escape byte is the more semantic-locating axis
14539        // (an author who decodes the `%20` to a literal space is
14540        // likely to also tab-strip the trailing separator since
14541        // both are paste-from-URL / paste-from-shell-tab-completion
14542        // artifacts).
14543        let d = dep_with_fonte(DepSource::Path {
14544            caminho: "../caixa%20teia/".into(),
14545        });
14546        let err = d.validate().unwrap_err();
14547        assert!(
14548            matches!(
14549                err,
14550                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14551            ),
14552            "got {err:?}",
14553        );
14554    }
14555
14556    #[test]
14557    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14558        // Diagnostic-shape pin (peer with
14559        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14560        // on the immediate-predecessor arm): the error's Display
14561        // surfaces the offending `:nome`, the offending `:caminho`
14562        // verbatim, the offending byte's hex / character form, and
14563        // names the URL-percent-encoding-escape / printf-format-
14564        // specifier footgun explicitly so a `feira lint` run can
14565        // render the diagnostic without re-parsing.
14566        let d = dep_with_fonte(DepSource::Path {
14567            caminho: "../caixa%20teia".into(),
14568        });
14569        let rendered = d.validate().unwrap_err().to_string();
14570        assert!(
14571            rendered.contains("caixa-teia"),
14572            "diagnostic must name the offending dep: {rendered}",
14573        );
14574        assert!(
14575            rendered.contains("../caixa%20teia"),
14576            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14577        );
14578        assert!(
14579            rendered.contains("0x25"),
14580            "diagnostic must surface the offending byte hex: {rendered:?}",
14581        );
14582        assert!(
14583            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14584            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14585        );
14586        assert!(
14587            rendered.contains("printf") || rendered.contains("format-specifier"),
14588            "diagnostic must reference the printf-format-specifier vocabulary: \
14589             {rendered:?}",
14590        );
14591    }
14592
14593    #[test]
14594    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14595        // The canonical embedded-`$` shell-variable-expansion paste
14596        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14597        // substituted shell one-liner where the leading segment is a
14598        // literal `../foo` while the mid segment carries the un-
14599        // substituted `$HOME` template). The leading-`$` position is
14600        // already gated by the f4efe9c leading-byte arm which routes
14601        // through `FonteCaminhoVarExpansion`; this arm closes the
14602        // last positional gap on `$` — every position on the axis is
14603        // structurally rejected.
14604        let d = dep_with_fonte(DepSource::Path {
14605            caminho: "../foo$HOME/bar".into(),
14606        });
14607        let err = d.validate().unwrap_err();
14608        let DepError::FonteCaminhoShellVariableExpansion {
14609            nome,
14610            caminho,
14611            byte,
14612        } = err
14613        else {
14614            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14615        };
14616        assert_eq!(nome, "caixa-teia");
14617        assert_eq!(caminho, "../foo$HOME/bar");
14618        assert_eq!(byte, b'$');
14619    }
14620
14621    #[test]
14622    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14623        // The symmetric braced-CI-manifest paste shape
14624        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14625        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14626        // footgun). Pinned separately from the bare-`$VAR` shape so
14627        // the gate covers both POSIX shell §2.6 Parameter Expansion
14628        // syntactic forms, not only the unbraced variant. The
14629        // embedded `{` byte in `${...}` is also caught by the 598b770
14630        // shell-brace-expansion arm but that arm fires earlier in
14631        // the cascade — the `$` arm's coverage extends to `${...}`
14632        // structurally, so the diagnostic asserted here is the
14633        // brace-expansion one (which is a valid outcome; the point
14634        // of the pin is that the value never survives validation).
14635        let d = dep_with_fonte(DepSource::Path {
14636            caminho: "../foo${WORKSPACE}/bar".into(),
14637        });
14638        let err = d.validate().unwrap_err();
14639        assert!(
14640            matches!(
14641                err,
14642                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14643                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14644            ),
14645            "got {err:?}",
14646        );
14647    }
14648
14649    #[test]
14650    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14651        // The paste-from-shell-prompt command-substitution idiom
14652        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14653        // `$VAR` shape so the gate's rationale extends to POSIX shell
14654        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14655        // legacy `` `<cmd>` `` form is already closed by the c370458
14656        // backtick arm). The embedded `(` byte in `$(...)` is also
14657        // caught structurally by the 0633c91 shell-subshell-grouping
14658        // arm which fires earlier in the cascade — the diagnostic
14659        // asserted here is either outcome, since both structurally
14660        // reject the value; the point of the pin is that the value
14661        // never survives validation.
14662        let d = dep_with_fonte(DepSource::Path {
14663            caminho: "../foo$(whoami)/bar".into(),
14664        });
14665        let err = d.validate().unwrap_err();
14666        assert!(
14667            matches!(
14668                err,
14669                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14670                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14671            ),
14672            "got {err:?}",
14673        );
14674    }
14675
14676    #[test]
14677    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14678        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14679        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14680        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14681        // idiom copied into a caminho template). None of the prior
14682        // shell-metachar arms cover this shape (`1` is a bare digit;
14683        // no `(` / `{` / letter follows the `$`), so the arm is the
14684        // sole gate on the shape.
14685        let d = dep_with_fonte(DepSource::Path {
14686            caminho: "../foo$1/bar".into(),
14687        });
14688        let err = d.validate().unwrap_err();
14689        assert!(
14690            matches!(
14691                err,
14692                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14693            ),
14694            "got {err:?}",
14695        );
14696    }
14697
14698    #[test]
14699    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14700        // The positive-control pin (peer with
14701        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14702        // on the immediate-predecessor arm): the gate targets only
14703        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14704        // A relative POSIX path carrying dashes / dots / slashes /
14705        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14706        // validate cleanly so the gate doesn't widen to a "no
14707        // printable punctuation anywhere" sweep that would defeat
14708        // the entire path-fonte author surface.
14709        let d = dep_with_fonte(DepSource::Path {
14710            caminho: "../caixa-teia/sub-dir.v2".into(),
14711        });
14712        d.validate().unwrap();
14713    }
14714
14715    #[test]
14716    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14717        // Cascade pin on the leading-`$` sibling arm at line 540: a
14718        // value starting with `$` and carrying an embedded `$` too
14719        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14720        // fully-templated CI path with two un-substituted variables")
14721        // routes through `FonteCaminhoVarExpansion` not
14722        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14723        // host-layout-leak is the load-bearing self-locating axis
14724        // (the leading position dominates the semantic-locating
14725        // rationale on every probe-as-both value); the embedded
14726        // arm's positional-agnostic sweep catches only values whose
14727        // leading byte doesn't route through the earlier leading-
14728        // byte arms.
14729        let d = dep_with_fonte(DepSource::Path {
14730            caminho: "$HOME/foo$WORKSPACE/bar".into(),
14731        });
14732        let err = d.validate().unwrap_err();
14733        assert!(
14734            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14735            "got {err:?}",
14736        );
14737    }
14738
14739    #[test]
14740    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14741        // Cascade pin on the immediate-predecessor arm: a value
14742        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14743        // — the canonical "I pasted a percent-encoded space adjacent
14744        // to a `$HOME` template") routes through
14745        // `FonteCaminhoUrlPercentEncoding` not
14746        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14747        // encoding-escape byte is the more semantic-locating axis
14748        // (the paste-from-browser-address-bar shape is the load-
14749        // bearing self-locating edit); same cascade discipline every
14750        // prior `:caminho` arm establishes.
14751        let d = dep_with_fonte(DepSource::Path {
14752            caminho: "../foo%20$HOME/bar".into(),
14753        });
14754        let err = d.validate().unwrap_err();
14755        assert!(
14756            matches!(
14757                err,
14758                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14759            ),
14760            "got {err:?}",
14761        );
14762    }
14763
14764    #[test]
14765    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14766        // Cascade pin on the immediate-successor arm: a value
14767        // carrying both embedded `$` and a trailing `/`
14768        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14769        // `$HOME`-template-carrying path") routes through
14770        // `FonteCaminhoShellVariableExpansion` not
14771        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14772        // expansion byte is the more semantic-locating axis on
14773        // probe-as-both values (an author who substitutes the
14774        // `$HOME` template with a literal value is likely to also
14775        // tab-strip the trailing separator).
14776        let d = dep_with_fonte(DepSource::Path {
14777            caminho: "../foo$HOME/bar/".into(),
14778        });
14779        let err = d.validate().unwrap_err();
14780        assert!(
14781            matches!(
14782                err,
14783                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14784            ),
14785            "got {err:?}",
14786        );
14787    }
14788
14789    #[test]
14790    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14791        // Diagnostic-shape pin (peer with
14792        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14793        // on the immediate-predecessor arm): the error's Display
14794        // surfaces the offending `:nome`, the offending `:caminho`
14795        // verbatim, the offending byte's hex / character form, and
14796        // names the shell-variable-expansion / command-substitution
14797        // footgun explicitly so a `feira lint` run can render the
14798        // diagnostic without re-parsing.
14799        let d = dep_with_fonte(DepSource::Path {
14800            caminho: "../foo$HOME/bar".into(),
14801        });
14802        let rendered = d.validate().unwrap_err().to_string();
14803        assert!(
14804            rendered.contains("caixa-teia"),
14805            "diagnostic must name the offending dep: {rendered}",
14806        );
14807        assert!(
14808            rendered.contains("../foo$HOME/bar"),
14809            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14810        );
14811        assert!(
14812            rendered.contains("0x24"),
14813            "diagnostic must surface the offending byte hex: {rendered:?}",
14814        );
14815        assert!(
14816            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14817            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14818        );
14819        assert!(
14820            rendered.contains("command-substitution") || rendered.contains("command substitution"),
14821            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14822        );
14823    }
14824
14825    #[test]
14826    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14827        // The fail-before-pass-after pin for the canonical paste-from-
14828        // shell-history footgun on `:caminho`. An author copies a `cd
14829        // ../caixa-teia && !sudo make install` one-liner from a quick-
14830        // start README, intending the trailing `!sudo` as a shell-
14831        // history-expansion reference but the typed slot is itself a
14832        // byte-level string parser, not a shell context, so the byte
14833        // rides into the value verbatim. Until this arm landed the `!`
14834        // byte silently passed every prior `:caminho` cascade arm
14835        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14836        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14837        // `#` / `%` / `$`); bash with the default `histexpand` mode
14838        // rewrites `!command` to the most recent history entry
14839        // beginning with `command`, the canonical RCE-class injection
14840        // vector when the byte rides into a shell argument executed
14841        // under `bash -i` (the operator-notebook interactive shell).
14842        let d = dep_with_fonte(DepSource::Path {
14843            caminho: "../caixa-teia!sudo".into(),
14844        });
14845        let err = d.validate().unwrap_err();
14846        let DepError::FonteCaminhoShellHistoryExpansion {
14847            nome,
14848            caminho,
14849            byte,
14850        } = err
14851        else {
14852            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14853        };
14854        assert_eq!(nome, "caixa-teia");
14855        assert_eq!(caminho, "../caixa-teia!sudo");
14856        assert_eq!(byte, b'!');
14857    }
14858
14859    #[test]
14860    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14861        // The symmetric `!!` repeat-prior-command paste idiom (peer with
14862        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14863        // on `is_git_repo_url`). Pinned separately from the wrapped
14864        // `!command` shape so a future diagnostic-surface change that
14865        // only checked the leading or paired-bang position surfaces
14866        // here — the per-byte arm fires anywhere `!` appears in the
14867        // value, including at consecutive positions in the middle.
14868        let d = dep_with_fonte(DepSource::Path {
14869            caminho: "../foo!!/bar".into(),
14870        });
14871        let err = d.validate().unwrap_err();
14872        assert!(
14873            matches!(
14874                err,
14875                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14876            ),
14877            "got {err:?}",
14878        );
14879    }
14880
14881    #[test]
14882    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14883        // The English-typography enthusiasm-form paste-from-prose
14884        // idiom: an author writes `:caminho "../caixa-teia!"`
14885        // expecting the substrate to coerce it to a kebab-case slug.
14886        // Pinned separately from the `!<word>` shell-history shape so
14887        // the gate's rationale extends to the paste-from-prose surface
14888        // (the same rationale the peer `is_git_repo_url` bang arm at
14889        // 7d53c68 covers). None of the prior shell-metachar arms cover
14890        // this shape (no `!<word>` reference and no `!!` repeat), so
14891        // the arm is the sole gate on the shape.
14892        let d = dep_with_fonte(DepSource::Path {
14893            caminho: "../caixa-teia!".into(),
14894        });
14895        let err = d.validate().unwrap_err();
14896        assert!(
14897            matches!(
14898                err,
14899                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14900            ),
14901            "got {err:?}",
14902        );
14903    }
14904
14905    #[test]
14906    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14907        // The positive-control pin (peer with
14908        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14909        // on the immediate-predecessor arm): the gate targets only
14910        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14911        // A relative POSIX path carrying dashes / dots / slashes /
14912        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14913        // validate cleanly so the gate doesn't widen to a "no
14914        // printable punctuation anywhere" sweep that would defeat
14915        // the entire path-fonte author surface.
14916        let d = dep_with_fonte(DepSource::Path {
14917            caminho: "../caixa-teia/sub-dir.v2".into(),
14918        });
14919        d.validate().unwrap();
14920    }
14921
14922    #[test]
14923    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14924        // Cascade pin on the immediate-predecessor arm: a value
14925        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14926        // — the canonical "I pasted a `$HOME`-templated path adjacent
14927        // to a trailing `!sudo` history-expansion") routes through
14928        // `FonteCaminhoShellVariableExpansion` not
14929        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14930        // expansion byte is the more semantic-locating axis on
14931        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14932        // template shape is the load-bearing self-locating edit);
14933        // same cascade discipline every prior `:caminho` arm
14934        // establishes.
14935        let d = dep_with_fonte(DepSource::Path {
14936            caminho: "../foo$HOME/bar!sudo".into(),
14937        });
14938        let err = d.validate().unwrap_err();
14939        assert!(
14940            matches!(
14941                err,
14942                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14943            ),
14944            "got {err:?}",
14945        );
14946    }
14947
14948    #[test]
14949    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14950        // Cascade pin on the immediate-successor arm: a value carrying
14951        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14952        // — the canonical "I tab-completed a `!sudo`-carrying path")
14953        // routes through `FonteCaminhoShellHistoryExpansion` not
14954        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14955        // expansion byte is the more semantic-locating axis on probe-
14956        // as-both values (an author who removes the `!sudo` history
14957        // reference is likely to also tab-strip the trailing separator).
14958        let d = dep_with_fonte(DepSource::Path {
14959            caminho: "../caixa-teia!sudo/".into(),
14960        });
14961        let err = d.validate().unwrap_err();
14962        assert!(
14963            matches!(
14964                err,
14965                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14966            ),
14967            "got {err:?}",
14968        );
14969    }
14970
14971    #[test]
14972    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14973        // Diagnostic-shape pin (peer with
14974        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14975        // on the immediate-predecessor arm): the error's Display
14976        // surfaces the offending `:nome`, the offending `:caminho`
14977        // verbatim, the offending byte's hex / character form, and
14978        // names the shell-history-expansion / bang-operator footgun
14979        // explicitly so a `feira lint` run can render the diagnostic
14980        // without re-parsing.
14981        let d = dep_with_fonte(DepSource::Path {
14982            caminho: "../caixa-teia!sudo".into(),
14983        });
14984        let rendered = d.validate().unwrap_err().to_string();
14985        assert!(
14986            rendered.contains("caixa-teia"),
14987            "diagnostic must name the offending dep: {rendered}",
14988        );
14989        assert!(
14990            rendered.contains("../caixa-teia!sudo"),
14991            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14992        );
14993        assert!(
14994            rendered.contains("0x21"),
14995            "diagnostic must surface the offending byte hex: {rendered:?}",
14996        );
14997        assert!(
14998            rendered.contains("history-expansion") || rendered.contains("history expansion"),
14999            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15000        );
15001        assert!(
15002            rendered.contains("bang"),
15003            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15004        );
15005    }
15006
15007    #[test]
15008    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15009        // The fail-before-pass-after pin for the canonical paste-from-
15010        // shell-history-quick-substitution footgun on `:caminho`. An
15011        // author copies a `git clone <bad-url>` line from their terminal,
15012        // corrects it via bash's `^bad^good` quick-substitution history
15013        // operator (bash reference §9.3, `set -o histexpand` mode's
15014        // default for interactive sessions), and pastes the trailing
15015        // `^bad^good` substitution fragment into a `:caminho` value
15016        // without trimming the leading `git clone` prefix — the byte
15017        // rides into the manifest verbatim. Until this arm landed the
15018        // `^` byte silently passed every prior `:caminho` cascade arm
15019        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15020        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15021        // `%` / `$` / `!`); bash with the default `histexpand` mode
15022        // rewrites the prior command's `bad` string to `good` and re-
15023        // executes it, the paired-operator half of the `set -o
15024        // histexpand` feature the peer `!` arm already closes the prefix
15025        // half of. The peer `is_git_repo_url` axis rejects the byte at
15026        // 49e142f under the same shell-history-substitution / RFC-3986-
15027        // unwise banner.
15028        let d = dep_with_fonte(DepSource::Path {
15029            caminho: "../foo^bad^good".into(),
15030        });
15031        let err = d.validate().unwrap_err();
15032        let DepError::FonteCaminhoShellHistorySubstitution {
15033            nome,
15034            caminho,
15035            byte,
15036        } = err
15037        else {
15038            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15039        };
15040        assert_eq!(nome, "caixa-teia");
15041        assert_eq!(caminho, "../foo^bad^good");
15042        assert_eq!(byte, b'^');
15043    }
15044
15045    #[test]
15046    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15047        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15048        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15049        // on `is_git_repo_url`). An author copies a `grep '^archived'`
15050        // regex-anchor / negation idiom from a doc snippet and the byte
15051        // rides in verbatim. Pinned separately from the `^old^new^`
15052        // quick-substitution shape so a future diagnostic-surface change
15053        // that only checked the paired-caret history-substitution
15054        // position surfaces here — the per-byte arm fires anywhere `^`
15055        // appears in the value, including at a solitary leading-of-
15056        // segment position.
15057        let d = dep_with_fonte(DepSource::Path {
15058            caminho: "../foo/^archived".into(),
15059        });
15060        let err = d.validate().unwrap_err();
15061        assert!(
15062            matches!(
15063                err,
15064                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15065            ),
15066            "got {err:?}",
15067        );
15068    }
15069
15070    #[test]
15071    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15072        // The trailing-`^` history-substitution-open shape — an author
15073        // starts typing a `^bad^good` quick-substitution but pastes only
15074        // the leading `^` sentinel before context-switching (a bash-
15075        // reference §9.3 valid histexpand prefix on its own — even a
15076        // solitary `^` on the prior command's whole re-execution shape).
15077        // Pinned separately from the `^old^new^` full-form and the leading-
15078        // of-segment `^archived` regex-anchor shape so the gate's
15079        // rationale extends to the paste-from-shell-history-with-only-
15080        // the-first-byte-selected surface. None of the prior shell-
15081        // metachar arms cover this shape.
15082        let d = dep_with_fonte(DepSource::Path {
15083            caminho: "../caixa-teia^".into(),
15084        });
15085        let err = d.validate().unwrap_err();
15086        assert!(
15087            matches!(
15088                err,
15089                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15090            ),
15091            "got {err:?}",
15092        );
15093    }
15094
15095    #[test]
15096    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15097        // The positive-control pin (peer with
15098        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15099        // on the immediate-predecessor arm): the gate targets only
15100        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15101        // A relative POSIX path carrying dashes / dots / slashes /
15102        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15103        // continue to validate cleanly so the gate doesn't widen to
15104        // a "no printable punctuation anywhere" sweep that would
15105        // defeat the entire path-fonte author surface.
15106        let d = dep_with_fonte(DepSource::Path {
15107            caminho: "../caixa-teia/sub_v2.rc".into(),
15108        });
15109        d.validate().unwrap();
15110    }
15111
15112    #[test]
15113    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15114        // Cascade pin on the immediate-predecessor arm: a value carrying
15115        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15116        // canonical "I pasted a `!sudo` history-reference next to a
15117        // `^bad^good` quick-substitution") routes through
15118        // `FonteCaminhoShellHistoryExpansion` not
15119        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15120        // the more semantic-locating axis on probe-as-both values (an
15121        // author who removes the `!sudo` reference is likely to also
15122        // strip the paired `^` substitution fragment); same cascade
15123        // discipline every prior `:caminho` arm establishes.
15124        let d = dep_with_fonte(DepSource::Path {
15125            caminho: "../foo!sudo^bad^good".into(),
15126        });
15127        let err = d.validate().unwrap_err();
15128        assert!(
15129            matches!(
15130                err,
15131                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15132            ),
15133            "got {err:?}",
15134        );
15135    }
15136
15137    #[test]
15138    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15139        // Cascade pin on the immediate-successor arm: a value carrying
15140        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15141        // the canonical "I tab-completed a `^bad^good`-carrying path")
15142        // routes through `FonteCaminhoShellHistorySubstitution` not
15143        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15144        // substitution byte is the more semantic-locating axis on probe-
15145        // as-both values (an author who removes the `^bad^good`
15146        // substitution fragment is likely to also tab-strip the trailing
15147        // separator).
15148        let d = dep_with_fonte(DepSource::Path {
15149            caminho: "../foo^bad^good/".into(),
15150        });
15151        let err = d.validate().unwrap_err();
15152        assert!(
15153            matches!(
15154                err,
15155                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15156            ),
15157            "got {err:?}",
15158        );
15159    }
15160
15161    #[test]
15162    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15163    {
15164        // Diagnostic-shape pin (peer with
15165        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15166        // on the immediate-predecessor arm): the error's Display
15167        // surfaces the offending `:nome`, the offending `:caminho`
15168        // verbatim, the offending byte's hex form, and names the
15169        // shell-history-substitution / RFC-3986-'unwise' / regex-
15170        // negation footgun explicitly so a `feira lint` run can render
15171        // the diagnostic without re-parsing.
15172        let d = dep_with_fonte(DepSource::Path {
15173            caminho: "../foo^bad^good".into(),
15174        });
15175        let rendered = d.validate().unwrap_err().to_string();
15176        assert!(
15177            rendered.contains("caixa-teia"),
15178            "diagnostic must name the offending dep: {rendered}",
15179        );
15180        assert!(
15181            rendered.contains("../foo^bad^good"),
15182            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15183        );
15184        assert!(
15185            rendered.contains("0x5e") || rendered.contains("0x5E"),
15186            "diagnostic must surface the offending byte hex: {rendered:?}",
15187        );
15188        assert!(
15189            rendered.contains("history-substitution") || rendered.contains("history substitution"),
15190            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15191        );
15192        assert!(
15193            rendered.contains("unwise"),
15194            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15195        );
15196    }
15197
15198    #[test]
15199    fn fonte_repo_empty_fires_before_pin_missing() {
15200        // Order pin: empty `:repo` is the more self-locating diagnostic
15201        // (every git source needs a repo; the pin discussion is
15202        // secondary), so it fires before the pin-missing arm even when
15203        // both are violated. Mirrors the
15204        // `nome_empty_takes_precedence_over_versao_invalid` ordering
15205        // discipline on the per-entry layer.
15206        let d = dep_with_fonte(DepSource::Git {
15207            repo: String::new(),
15208            tag: None,
15209            rev: None,
15210            branch: None,
15211        });
15212        let err = d.validate().unwrap_err();
15213        assert!(
15214            matches!(err, DepError::FonteRepoEmpty { .. }),
15215            "got {err:?}"
15216        );
15217    }
15218
15219    #[test]
15220    fn fonte_pin_missing_fires_before_pin_empty() {
15221        // Order pin: a fully-None pin set is structurally distinct from
15222        // a Some(empty) pin — the first surfaces as FontePinMissing
15223        // (no axis chosen), the second as FontePinEmpty (axis chosen
15224        // but value blank). Pin the disjoint relationship so a future
15225        // unification collapses to one variant only as a structural
15226        // decision.
15227        let d = dep_with_fonte(DepSource::Git {
15228            repo: "github:pleme-io/caixa-teia".into(),
15229            tag: None,
15230            rev: None,
15231            branch: None,
15232        });
15233        assert!(matches!(
15234            d.validate().unwrap_err(),
15235            DepError::FontePinMissing { .. }
15236        ));
15237    }
15238
15239    #[test]
15240    fn nome_empty_takes_precedence_over_fonte_invalid() {
15241        // Order pin: a per-entry diagnostic without a non-empty :nome
15242        // can't be self-locating, so :nome "" fires first even when
15243        // :fonte is also malformed. Mirrors
15244        // `nome_empty_takes_precedence_over_versao_invalid` on the
15245        // adjacent axis.
15246        let mut d = dep_with_fonte(DepSource::Git {
15247            repo: String::new(),
15248            tag: None,
15249            rev: None,
15250            branch: None,
15251        });
15252        d.nome = String::new();
15253        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15254    }
15255
15256    #[test]
15257    fn versao_invalid_takes_precedence_over_fonte_invalid() {
15258        // Order pin: the :versao parse-side diagnostic is narrower than
15259        // the :fonte shape diagnostic — a malformed :versao always names
15260        // the parser's reason, which is more actionable than the
15261        // :fonte gate's "the pins are wrong" wording. Pin the ordering
15262        // so a re-ordering surfaces here.
15263        let mut d = dep_with_fonte(DepSource::Git {
15264            repo: String::new(),
15265            tag: None,
15266            rev: None,
15267            branch: None,
15268        });
15269        d.versao = "v0.1".into();
15270        let err = d.validate().unwrap_err();
15271        assert!(
15272            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15273            "got {err:?}"
15274        );
15275    }
15276
15277    #[test]
15278    fn fonte_invalid_diagnostic_carries_offending_nome() {
15279        // The diagnostic-shape pin: every :fonte error variant names
15280        // the offending dep's :nome verbatim, so the author can grep
15281        // caixa.lisp for the `:nome "<n>"` block and fix it in one
15282        // edit. Cover all seven variants so a future variant addition
15283        // forces a parallel diagnostic-shape decision.
15284        for (case, fonte) in [
15285            (
15286                "repo-empty",
15287                DepSource::Git {
15288                    repo: String::new(),
15289                    tag: Some("v1".into()),
15290                    rev: None,
15291                    branch: None,
15292                },
15293            ),
15294            (
15295                "repo-shape",
15296                DepSource::Git {
15297                    repo: "github:p/x ".into(),
15298                    tag: Some("v1".into()),
15299                    rev: None,
15300                    branch: None,
15301                },
15302            ),
15303            (
15304                "pin-missing",
15305                DepSource::Git {
15306                    repo: "github:p/x".into(),
15307                    tag: None,
15308                    rev: None,
15309                    branch: None,
15310                },
15311            ),
15312            (
15313                "pin-ambiguous",
15314                DepSource::Git {
15315                    repo: "github:p/x".into(),
15316                    tag: Some("v1".into()),
15317                    rev: None,
15318                    branch: Some("main".into()),
15319                },
15320            ),
15321            (
15322                "pin-empty",
15323                DepSource::Git {
15324                    repo: "github:p/x".into(),
15325                    tag: Some(String::new()),
15326                    rev: None,
15327                    branch: None,
15328                },
15329            ),
15330            (
15331                "caminho-empty",
15332                DepSource::Path {
15333                    caminho: String::new(),
15334                },
15335            ),
15336            (
15337                "caminho-absolute",
15338                DepSource::Path {
15339                    caminho: "/home/me/work/caixa-teia".into(),
15340                },
15341            ),
15342        ] {
15343            let d = dep_with_fonte(fonte);
15344            let msg = d
15345                .validate()
15346                .expect_err(&format!("{case}: expected fonte error"))
15347                .to_string();
15348            assert!(
15349                msg.contains("\"caixa-teia\""),
15350                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15351            );
15352        }
15353    }
15354
15355    // -- :tag / :branch value-shape gate ----------------------------------
15356
15357    #[test]
15358    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15359        // The canonical paste-from-doc footgun on `:tag` — author
15360        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15361        // paragraph. Until this gate landed the empty-pin arm passed
15362        // (the string isn't empty), the resolver issued
15363        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15364        // surfaced at clone time with a quoting-confused git error
15365        // far from the source caixa.lisp. The new gate moves the
15366        // check to caixa-build time and names the offending dep +
15367        // pin + value verbatim.
15368        let d = dep_with_fonte(DepSource::Git {
15369            repo: "github:pleme-io/caixa-teia".into(),
15370            tag: Some("v0.1.0 ".into()),
15371            rev: None,
15372            branch: None,
15373        });
15374        let err = d.validate().unwrap_err();
15375        let DepError::FontePinShape {
15376            nome,
15377            pin,
15378            value,
15379            reason,
15380        } = err
15381        else {
15382            panic!("expected FontePinShape, got other variant");
15383        };
15384        assert_eq!(nome, "caixa-teia");
15385        assert_eq!(pin, ":tag");
15386        assert_eq!(value, "v0.1.0 ");
15387        assert!(
15388            reason.contains("whitespace"),
15389            "reason must surface the whitespace arm, got {reason:?}"
15390        );
15391    }
15392
15393    #[test]
15394    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15395        // The `.lock` suffix is git's atomic-rename guard for
15396        // in-flight ref updates — a refname ending in `.lock` is
15397        // unwritable on disk. Pinned separately from the whitespace
15398        // arm so a future relaxation that admits one but not the
15399        // other surfaces here.
15400        let d = dep_with_fonte(DepSource::Git {
15401            repo: "github:pleme-io/caixa-teia".into(),
15402            tag: Some("v0.1.0.lock".into()),
15403            rev: None,
15404            branch: None,
15405        });
15406        let err = d.validate().unwrap_err();
15407        let DepError::FontePinShape {
15408            pin, value, reason, ..
15409        } = err
15410        else {
15411            panic!("expected FontePinShape, got other variant");
15412        };
15413        assert_eq!(pin, ":tag");
15414        assert_eq!(value, "v0.1.0.lock");
15415        assert!(
15416            reason.contains(".lock"),
15417            "reason must surface the .lock arm, got {reason:?}"
15418        );
15419    }
15420
15421    #[test]
15422    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15423        // The canonical "branch name with spaces" footgun (`feature
15424        // foo`, `release branch`) — git's refname parser rejects raw
15425        // whitespace, and the failure surfaces at `git checkout
15426        // 'feature foo'` time with a quoting-confused error far from
15427        // the source caixa.lisp. Pinned on the `:branch` axis so the
15428        // gate-applies-to-both-:tag-and-:branch contract is a build-
15429        // error to relax.
15430        let d = dep_with_fonte(DepSource::Git {
15431            repo: "github:pleme-io/caixa-teia".into(),
15432            tag: None,
15433            rev: None,
15434            branch: Some("feature/foo bar".into()),
15435        });
15436        let err = d.validate().unwrap_err();
15437        let DepError::FontePinShape {
15438            pin, value, reason, ..
15439        } = err
15440        else {
15441            panic!("expected FontePinShape, got other variant");
15442        };
15443        assert_eq!(pin, ":branch");
15444        assert_eq!(value, "feature/foo bar");
15445        assert!(
15446            reason.contains("whitespace"),
15447            "reason must surface the whitespace arm, got {reason:?}"
15448        );
15449    }
15450
15451    #[test]
15452    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15453        // The `refs/heads/main` shape — the canonical "I copied the
15454        // fully-qualified ref out of `git show-ref` instead of the
15455        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15456        // at clone time, so this resolves to a literal ref named
15457        // `refs/heads/refs/heads/main` on disk; the silent double-
15458        // prefix is the load-bearing reason to gate at validate.
15459        // The diagnostic must enumerate the leaf the author probably
15460        // meant (`"main"`) so the fix is one edit.
15461        let d = dep_with_fonte(DepSource::Git {
15462            repo: "github:pleme-io/caixa-teia".into(),
15463            tag: None,
15464            rev: None,
15465            branch: Some("refs/heads/main".into()),
15466        });
15467        let err = d.validate().unwrap_err();
15468        let DepError::FontePinShape {
15469            pin, value, reason, ..
15470        } = err
15471        else {
15472            panic!("expected FontePinShape, got other variant");
15473        };
15474        assert_eq!(pin, ":branch");
15475        assert_eq!(value, "refs/heads/main");
15476        assert!(
15477            reason.contains("fully-qualified"),
15478            "reason must surface the qualified-prefix arm, got {reason:?}"
15479        );
15480        assert!(
15481            reason.contains("\"main\""),
15482            "reason must quote the leaf the author probably meant, got {reason:?}"
15483        );
15484    }
15485
15486    #[test]
15487    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15488        // Sibling arm of the qualified-prefix gate on the `:tag`
15489        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15490        // footgun). Pinned separately so a future relaxation that
15491        // only catches the `:branch` arm surfaces here.
15492        let d = dep_with_fonte(DepSource::Git {
15493            repo: "github:pleme-io/caixa-teia".into(),
15494            tag: Some("refs/tags/v0.1.0".into()),
15495            rev: None,
15496            branch: None,
15497        });
15498        let err = d.validate().unwrap_err();
15499        let DepError::FontePinShape {
15500            pin, value, reason, ..
15501        } = err
15502        else {
15503            panic!("expected FontePinShape, got other variant");
15504        };
15505        assert_eq!(pin, ":tag");
15506        assert_eq!(value, "refs/tags/v0.1.0");
15507        assert!(
15508            reason.contains("fully-qualified"),
15509            "reason must surface the qualified-prefix arm, got {reason:?}"
15510        );
15511        assert!(
15512            reason.contains("\"v0.1.0\""),
15513            "reason must quote the leaf the author probably meant, got {reason:?}"
15514        );
15515    }
15516
15517    #[test]
15518    fn validate_rejects_git_fonte_with_branch_named_at() {
15519        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15520        // unsourceable. Pinned so a future relaxation that admits
15521        // any single-character refname surfaces here.
15522        let d = dep_with_fonte(DepSource::Git {
15523            repo: "github:pleme-io/caixa-teia".into(),
15524            tag: None,
15525            rev: None,
15526            branch: Some("@".into()),
15527        });
15528        let err = d.validate().unwrap_err();
15529        let DepError::FontePinShape { pin, value, .. } = err else {
15530            panic!("expected FontePinShape, got other variant");
15531        };
15532        assert_eq!(pin, ":branch");
15533        assert_eq!(value, "@");
15534    }
15535
15536    #[test]
15537    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15538        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15539        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15540        // passes parse and surfaces as a refname-parse error or, on
15541        // older git, a literal `../escape` checkout that escapes the
15542        // refs/ directory tree. Pinned separately from the
15543        // qualified-prefix arm so a future relaxation that catches
15544        // one but not the other surfaces here.
15545        let d = dep_with_fonte(DepSource::Git {
15546            repo: "github:pleme-io/caixa-teia".into(),
15547            tag: Some("../escape".into()),
15548            rev: None,
15549            branch: None,
15550        });
15551        let err = d.validate().unwrap_err();
15552        let DepError::FontePinShape { pin, value, .. } = err else {
15553            panic!("expected FontePinShape, got other variant");
15554        };
15555        assert_eq!(pin, ":tag");
15556        assert_eq!(value, "../escape");
15557    }
15558
15559    #[test]
15560    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15561        // The positive-control pin: hierarchical refnames with one or
15562        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15563        // canonical idiom) round-trip through the gate. Pinned
15564        // separately from the leaf-`"main"` positive control so a
15565        // future tightening that rejects all multi-component refnames
15566        // surfaces here.
15567        let d = dep_with_fonte(DepSource::Git {
15568            repo: "github:pleme-io/caixa-teia".into(),
15569            tag: None,
15570            rev: None,
15571            branch: Some("feature/checkout-rewrite".into()),
15572        });
15573        d.validate().unwrap();
15574    }
15575
15576    #[test]
15577    fn validate_accepts_git_fonte_with_prerelease_tag() {
15578        // The positive-control pin: semver pre-release shape
15579        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15580        // (only consecutive `..` and trailing `.` are rejected), the
15581        // mid-component hyphen is allowed. Pinned separately from
15582        // the bare-`"v0.1.0"` positive control so a future tightening
15583        // that rejects pre-release tags surfaces here.
15584        let d = dep_with_fonte(DepSource::Git {
15585            repo: "github:pleme-io/caixa-teia".into(),
15586            tag: Some("v0.1.0-alpha.1".into()),
15587            rev: None,
15588            branch: None,
15589        });
15590        d.validate().unwrap();
15591    }
15592
15593    #[test]
15594    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15595        // The `:rev` axis is routed through `crate::render::is_git_oid`
15596        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15597        // value with refname-shape punctuation (here, a `:` mid-string
15598        // — would be a refname violation under `is_git_ref_name` too)
15599        // is rejected at the OID-shape gate. The two predicates
15600        // partition the `:fonte` pin axes structurally: an `:rev` value
15601        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15602        // *still* rejected here because every refname character outside
15603        // `[0-9a-f]` fails the OID gate. Same shape as
15604        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15605        // on the refname-shaped axes — the diagnostic names the
15606        // offending dep + pin + value verbatim. The flip-from-accept
15607        // case the prior `:tag`/`:branch` gate left as a "future axis"
15608        // (e70d213) — now landed.
15609        let d = dep_with_fonte(DepSource::Git {
15610            repo: "github:pleme-io/caixa-teia".into(),
15611            tag: None,
15612            rev: Some("c0ffee:notarefname".into()),
15613            branch: None,
15614        });
15615        let err = d.validate().unwrap_err();
15616        let DepError::FontePinShape {
15617            nome,
15618            pin,
15619            value,
15620            reason,
15621        } = err
15622        else {
15623            panic!("expected FontePinShape, got other variant");
15624        };
15625        assert_eq!(nome, "caixa-teia");
15626        assert_eq!(pin, ":rev");
15627        assert_eq!(value, "c0ffee:notarefname");
15628        assert!(
15629            !reason.is_empty(),
15630            "FontePinShape `reason` must carry the predicate's wording verbatim"
15631        );
15632    }
15633
15634    #[test]
15635    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15636        // The positive-control pin on the SHA-1 OID width: exactly 40
15637        // lowercase hex characters — the canonical `git rev-parse HEAD`
15638        // emission on a SHA-1-hashed repository (the default on every
15639        // pre-2.42 git and the canonical pleme-io substrate hash).
15640        // Pinned separately from the SHA-256 positive control so a
15641        // future tightening that only admits one width surfaces here.
15642        let d = dep_with_fonte(DepSource::Git {
15643            repo: "github:pleme-io/caixa-teia".into(),
15644            tag: None,
15645            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15646            branch: None,
15647        });
15648        d.validate().unwrap();
15649    }
15650
15651    #[test]
15652    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15653        // The positive-control pin on the SHA-256 OID width: exactly
15654        // 64 lowercase hex characters — `git`'s
15655        // `extensions.objectFormat = sha256` emission (GA since Git
15656        // 2.42 / Oct 2023). The substrate admits either canonical
15657        // width so an `:rev` authored against a SHA-256-hashed
15658        // upstream round-trips through the gate without per-repo
15659        // configuration. Pinned separately from the SHA-1 positive
15660        // control so a future tightening that drops one width surfaces
15661        // here as a structural decision.
15662        let d = dep_with_fonte(DepSource::Git {
15663            repo: "github:pleme-io/caixa-teia".into(),
15664            tag: None,
15665            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15666            branch: None,
15667        });
15668        d.validate().unwrap();
15669    }
15670
15671    #[test]
15672    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15673        // The canonical `git log --short` / `git rev-parse --short HEAD`
15674        // paste-from-release-notes footgun: a 7-char prefix (git's
15675        // default `core.abbrev`) silently passes string emptiness
15676        // checks and resolves to one commit today, but becomes ambiguous
15677        // tomorrow as the repo grows. Until this gate landed the empty-
15678        // pin arm passed (the string isn't empty) and the resolver
15679        // accepted the prefix through git's separate prefix-lookup pass
15680        // — defeating the reproducibility contract `:rev` carries vs.
15681        // `:tag` / `:branch`. The new gate moves the check to caixa-
15682        // build time and names the offending dep + pin + value verbatim.
15683        let d = dep_with_fonte(DepSource::Git {
15684            repo: "github:pleme-io/caixa-teia".into(),
15685            tag: None,
15686            rev: Some("c0ffee0".into()),
15687            branch: None,
15688        });
15689        let err = d.validate().unwrap_err();
15690        let DepError::FontePinShape {
15691            pin, value, reason, ..
15692        } = err
15693        else {
15694            panic!("expected FontePinShape, got other variant");
15695        };
15696        assert_eq!(pin, ":rev");
15697        assert_eq!(value, "c0ffee0");
15698        assert!(
15699            reason.contains("abbreviated") || reason.contains("ambiguous"),
15700            "reason must surface the abbreviation arm, got {reason:?}"
15701        );
15702    }
15703
15704    #[test]
15705    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15706        // The canonical "I pasted the SHA in uppercase" footgun: `git
15707        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15708        // bearing `:rev` round-trips inconsistently across the
15709        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15710        // equality-check pipeline and fails the lacre's content-
15711        // addressing probe with a confusing case-only diff. Pinned
15712        // separately from the non-hex arm so a future relaxation that
15713        // admits one but not the other surfaces here.
15714        let d = dep_with_fonte(DepSource::Git {
15715            repo: "github:pleme-io/caixa-teia".into(),
15716            tag: None,
15717            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15718            branch: None,
15719        });
15720        let err = d.validate().unwrap_err();
15721        let DepError::FontePinShape {
15722            pin, value, reason, ..
15723        } = err
15724        else {
15725            panic!("expected FontePinShape, got other variant");
15726        };
15727        assert_eq!(pin, ":rev");
15728        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15729        assert!(
15730            reason.contains("uppercase"),
15731            "reason must surface the uppercase arm, got {reason:?}"
15732        );
15733    }
15734
15735    #[test]
15736    fn validate_rejects_git_fonte_with_rev_refname_value() {
15737        // The cross-axis mis-slot footgun: `:rev "main"` — the author
15738        // conflated `:rev` (hex commit ID, immutable) and `:branch`
15739        // (mutable ref pointing at whatever HEAD is today). Until this
15740        // gate landed the resolver silently dispatched on the value
15741        // shape ("`main` doesn't look like a SHA, fall back to
15742        // refname"), defeating the `:rev` reproducibility contract.
15743        // The new gate rejects every non-hex value on the `:rev` axis,
15744        // so the `:rev`/`:branch` boundary is structurally enforced —
15745        // a refname in the `:rev` slot is a build error, not a
15746        // resolver-time silent reinterpretation.
15747        let d = dep_with_fonte(DepSource::Git {
15748            repo: "github:pleme-io/caixa-teia".into(),
15749            tag: None,
15750            rev: Some("main".into()),
15751            branch: None,
15752        });
15753        let err = d.validate().unwrap_err();
15754        let DepError::FontePinShape {
15755            pin, value, reason, ..
15756        } = err
15757        else {
15758            panic!("expected FontePinShape, got other variant");
15759        };
15760        assert_eq!(pin, ":rev");
15761        assert_eq!(value, "main");
15762        // 4 chars `main` fails the length arm before the character arm,
15763        // so the diagnostic surfaces the abbreviation wording (same
15764        // path the `c0ffee0` 7-char fixture lands on); the structural
15765        // assertion is just that the `:rev "main"` value is rejected.
15766        assert!(
15767            !reason.is_empty(),
15768            "FontePinShape reason must be non-empty for refname-shaped :rev"
15769        );
15770    }
15771
15772    #[test]
15773    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15774        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15775        // conflated `:rev` and `:tag`. Pinned separately from the
15776        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15777        // that catches one but not the other surfaces here. The
15778        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15779        // assertion is just that the cross-axis mis-slot is a build
15780        // error, regardless of which sub-arm surfaces the diagnostic
15781        // (`is_git_oid` rejects at the first violation; longer
15782        // tag-shape values would hit the non-hex arm instead).
15783        let d = dep_with_fonte(DepSource::Git {
15784            repo: "github:pleme-io/caixa-teia".into(),
15785            tag: None,
15786            rev: Some("v0.1.0".into()),
15787            branch: None,
15788        });
15789        let err = d.validate().unwrap_err();
15790        let DepError::FontePinShape {
15791            pin, value, reason, ..
15792        } = err
15793        else {
15794            panic!("expected FontePinShape, got other variant");
15795        };
15796        assert_eq!(pin, ":rev");
15797        assert_eq!(value, "v0.1.0");
15798        assert!(
15799            !reason.is_empty(),
15800            "FontePinShape reason must be non-empty for tag-shaped :rev"
15801        );
15802    }
15803
15804    #[test]
15805    fn validate_rejects_git_fonte_with_rev_too_long() {
15806        // Boundary case on the upper end: 41 hex chars — one past the
15807        // SHA-1 width, well below the SHA-256 width. Pin so a future
15808        // relaxation that admits "long enough to be a SHA" without
15809        // matching either canonical width surfaces here. The diagnostic
15810        // names the offending length verbatim so the author's grep
15811        // target is unambiguous (either trim one char or paste the
15812        // full SHA-256).
15813        let too_long: String = "0".repeat(41);
15814        let d = dep_with_fonte(DepSource::Git {
15815            repo: "github:pleme-io/caixa-teia".into(),
15816            tag: None,
15817            rev: Some(too_long.clone()),
15818            branch: None,
15819        });
15820        let err = d.validate().unwrap_err();
15821        let DepError::FontePinShape {
15822            pin, value, reason, ..
15823        } = err
15824        else {
15825            panic!("expected FontePinShape, got other variant");
15826        };
15827        assert_eq!(pin, ":rev");
15828        assert_eq!(value, too_long);
15829        assert!(
15830            reason.contains("41"),
15831            "reason must surface the offending length verbatim, got {reason:?}"
15832        );
15833    }
15834
15835    #[test]
15836    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15837        // The canonical paste-from-doc footgun on `:rev` — author
15838        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15839        // commit-message paragraph. Until this gate landed the empty-
15840        // pin arm passed (the string isn't empty), the resolver issued
15841        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15842        // clone time with a quoting-confused git error far from the
15843        // source caixa.lisp. The new gate moves the check to caixa-
15844        // build time. Length is 41 (40 hex + space) so the length arm
15845        // fires first — pinned separately from the pure-length arm to
15846        // ensure the diagnostic surfaces *some* parser wording, not
15847        // silently pass through.
15848        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15849        let d = dep_with_fonte(DepSource::Git {
15850            repo: "github:pleme-io/caixa-teia".into(),
15851            tag: None,
15852            rev: Some(with_space.clone()),
15853            branch: None,
15854        });
15855        let err = d.validate().unwrap_err();
15856        let DepError::FontePinShape {
15857            pin, value, reason, ..
15858        } = err
15859        else {
15860            panic!("expected FontePinShape, got other variant");
15861        };
15862        assert_eq!(pin, ":rev");
15863        assert_eq!(value, with_space);
15864        assert!(
15865            !reason.is_empty(),
15866            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15867        );
15868    }
15869
15870    #[test]
15871    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15872        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15873        // variant on this axis names the offending dep's `:nome` + the
15874        // `:rev` axis + the offending value verbatim, so the author's
15875        // grep target is the literal `:rev "<value>"` block in
15876        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15877        // carries_offending_nome_pin_value` test on the refname-shaped
15878        // (`:tag` / `:branch`) axes.
15879        let d = dep_with_fonte(DepSource::Git {
15880            repo: "github:p/x".into(),
15881            tag: None,
15882            rev: Some("not-a-sha".into()),
15883            branch: None,
15884        });
15885        let msg = d
15886            .validate()
15887            .expect_err(":rev: expected FontePinShape")
15888            .to_string();
15889        assert!(
15890            msg.contains("\"caixa-teia\""),
15891            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15892        );
15893        assert!(
15894            msg.contains(":rev"),
15895            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15896        );
15897        assert!(
15898            msg.contains("not-a-sha"),
15899            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15900        );
15901    }
15902
15903    #[test]
15904    fn fonte_pin_empty_fires_before_pin_shape() {
15905        // Order pin: a `Some("")` `:tag` is the more self-locating
15906        // diagnostic (the author chose an axis but left it blank;
15907        // grep is unambiguous), so it fires before the shape gate
15908        // even when both arms would match. Pinned so a future
15909        // reordering surfaces here. Mirrors the
15910        // `fonte_repo_empty_fires_before_pin_missing` ordering
15911        // discipline on the peer per-axis arms.
15912        let d = dep_with_fonte(DepSource::Git {
15913            repo: "github:pleme-io/caixa-teia".into(),
15914            tag: Some(String::new()),
15915            rev: None,
15916            branch: None,
15917        });
15918        assert!(matches!(
15919            d.validate().unwrap_err(),
15920            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15921        ));
15922    }
15923
15924    #[test]
15925    fn fonte_pin_shape_fires_after_repo_empty() {
15926        // Order pin: `:repo ""` is the more self-locating axis
15927        // (every git source needs a repo; the per-pin shape gate is
15928        // secondary), so the repo-empty arm fires before the
15929        // per-pin shape arm even when both are violated. Pinned so
15930        // a future reordering surfaces here. Mirrors
15931        // `fonte_repo_empty_fires_before_pin_missing` on the
15932        // adjacent axis pair.
15933        let d = dep_with_fonte(DepSource::Git {
15934            repo: String::new(),
15935            tag: Some("v0.1.0 ".into()),
15936            rev: None,
15937            branch: None,
15938        });
15939        assert!(matches!(
15940            d.validate().unwrap_err(),
15941            DepError::FonteRepoEmpty { .. }
15942        ));
15943    }
15944
15945    #[test]
15946    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15947        // Diagnostic-shape pin across both refname-shaped axes
15948        // (`:tag` + `:branch`): every `FontePinShape` variant names
15949        // the offending dep's `:nome` + the offending pin axis + the
15950        // offending value verbatim, so the author's grep target is
15951        // unambiguous (the literal `:tag "<value>"` / `:branch
15952        // "<value>"` lands in caixa.lisp with quotes). Cover both
15953        // pin axes so a future variant addition forces a parallel
15954        // diagnostic-shape decision.
15955        for (pin_label, fonte) in [
15956            (
15957                ":tag",
15958                DepSource::Git {
15959                    repo: "github:p/x".into(),
15960                    tag: Some("v0.1.0~1".into()),
15961                    rev: None,
15962                    branch: None,
15963                },
15964            ),
15965            (
15966                ":branch",
15967                DepSource::Git {
15968                    repo: "github:p/x".into(),
15969                    tag: None,
15970                    rev: None,
15971                    branch: Some("feature/foo*".into()),
15972                },
15973            ),
15974        ] {
15975            let d = dep_with_fonte(fonte);
15976            let msg = d
15977                .validate()
15978                .expect_err(&format!("{pin_label}: expected FontePinShape"))
15979                .to_string();
15980            assert!(
15981                msg.contains("\"caixa-teia\""),
15982                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15983            );
15984            assert!(
15985                msg.contains(pin_label),
15986                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15987            );
15988        }
15989    }
15990
15991    #[test]
15992    fn git_source_json_round_trip() {
15993        let src = DepSource::Git {
15994            repo: "github:pleme-io/caixa-teia".into(),
15995            tag: Some("v0.1.0".into()),
15996            rev: None,
15997            branch: None,
15998        };
15999        let s = serde_json::to_string(&src).unwrap();
16000        assert!(s.contains(&format!(
16001            r#""{tipo}":"{git}""#,
16002            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16003            git = crate::render::DEP_SOURCE_TIPO_GIT,
16004        )));
16005        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16006        assert!(s.contains(r#""tag":"v0.1.0""#));
16007        assert!(!s.contains("rev"));
16008        assert!(!s.contains("branch"));
16009        let round: DepSource = serde_json::from_str(&s).unwrap();
16010        assert_eq!(round, src);
16011    }
16012
16013    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16014    //
16015    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16016    // attribute on [`DepSource`] pins three load-bearing byte-sequences
16017    // that flow into every serialized `Dep.fonte` block: the outer
16018    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16019    // the two admitted variant-tag values `"git"` / `"path"` the
16020    // `rename_all = "lowercase"` attribute pins as the discriminator's
16021    // closed-set arms. The three pin tests below round-trip a
16022    // fully-populated variant of each arm through
16023    // [`serde_json::to_value`] and assert each canonical byte-sequence
16024    // appears at its axis — pins a hypothetical future
16025    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16026    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16027    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16028    // at build time rather than at fetch time when the resolver's
16029    // `Dep.fonte` dispatch silently fails to match on the drifted
16030    // discriminator. Same "serialize-and-check" discipline the peer
16031    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16032    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16033    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16034    // family in caixa-core lacking a lifted peer.
16035
16036    #[test]
16037    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16038        // Fail-before-pass-after: a future `tag = "type"` at the derive
16039        // attribute would serialize under `"type":"git"`, and this test
16040        // would trip because `"tipo"` no longer appears at the emitted
16041        // discriminator key. A future `rename_all = "kebab-case"` /
16042        // `"snake_case"` (both no-ops on `Git` since it lacks internal
16043        // word boundaries) is caught by the sibling
16044        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16045        // pin below (Path has no internal boundary either but the pair
16046        // catches any per-arm inconsistency). A future variant rename
16047        // `Git` → `Repository` would emit `"tipo":"repository"` and
16048        // trip this pin.
16049        let src = DepSource::Git {
16050            repo: "github:pleme-io/caixa-teia".into(),
16051            tag: Some("v0.1.0".into()),
16052            rev: None,
16053            branch: None,
16054        };
16055        let json = serde_json::to_value(&src).unwrap();
16056        let obj = json.as_object().expect("Git serializes as a JSON object");
16057        assert_eq!(
16058            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16059                .and_then(serde_json::Value::as_str),
16060            Some(crate::render::DEP_SOURCE_TIPO_GIT),
16061            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16062             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16063             detected in {json}"
16064        );
16065    }
16066
16067    #[test]
16068    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16069        // Fail-before-pass-after: a future variant rename `Path` →
16070        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16071        // this pin. A per-consumer disambiguation as the `defcaixa`
16072        // macro stabilizes ("caminho" → "path" for English-uniformity)
16073        // is scoped to the inner field key, not the discriminator; this
16074        // pin is orthogonal to that and catches only the outer
16075        // discriminator drift.
16076        let src = DepSource::Path {
16077            caminho: "../caixa-teia".into(),
16078        };
16079        let json = serde_json::to_value(&src).unwrap();
16080        let obj = json.as_object().expect("Path serializes as a JSON object");
16081        assert_eq!(
16082            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16083                .and_then(serde_json::Value::as_str),
16084            Some(crate::render::DEP_SOURCE_TIPO_PATH),
16085            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16086             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16087             detected in {json}"
16088        );
16089    }
16090
16091    #[test]
16092    fn dep_source_key_consts_are_pairwise_distinct() {
16093        // Cross-axis collapse detector: a hypothetical future edit that
16094        // accidentally set two of the three consts to the same byte
16095        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16096        // pass every per-arm serialize pin above but silently collapse
16097        // the discriminator's closed-set arms onto one another; this pin
16098        // catches the collapse at build time.
16099        assert_ne!(
16100            crate::render::DEP_SOURCE_KEY_TIPO,
16101            crate::render::DEP_SOURCE_TIPO_GIT,
16102        );
16103        assert_ne!(
16104            crate::render::DEP_SOURCE_KEY_TIPO,
16105            crate::render::DEP_SOURCE_TIPO_PATH,
16106        );
16107        assert_ne!(
16108            crate::render::DEP_SOURCE_TIPO_GIT,
16109            crate::render::DEP_SOURCE_TIPO_PATH,
16110        );
16111    }
16112
16113    #[test]
16114    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16115        // Shape pin against `rename_all` drift: the two variant-tag
16116        // consts must be ASCII-lowercase-only to match the
16117        // `rename_all = "lowercase"` attribute the derive uses; a future
16118        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16119        // would emit `"GIT"` / `"Git"` instead and trip this pin.
16120        for (label, s) in [
16121            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16122            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16123        ] {
16124            assert!(!s.is_empty(), "{label} must not be empty");
16125            assert!(
16126                s.bytes().all(|b| b.is_ascii_lowercase()),
16127                "{label} must be ASCII-lowercase-only (matching \
16128                 rename_all = \"lowercase\"), got {s:?}",
16129            );
16130        }
16131    }
16132
16133    // ── per-entry :caracteristicas set-not-multiset gate ────────────
16134    //
16135    // Every Vec-keyed-by-name authoring surface on the typed Caixa
16136    // surface that identifies its entries by a name field now uniformly
16137    // closes the set-not-multiset discipline at build time (cite
16138    // `validate_caracteristicas`'s peer-axis enumeration). The
16139    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16140    // set-shaped (a feature is either enabled or not — there is no
16141    // `feature × 2` semantic), so two entries naming the same feature
16142    // are a redundant declaration the caixa-resolver's lacre pipeline
16143    // would silently dedup at resolve time. The empty-feature arm
16144    // closes the parallel "operationally-meaningless value" axis on
16145    // the same slot. Same linear-walk + `HashSet` + first-collision
16146    // shape every peer set gate uses; same empty-first cascade every
16147    // peer per-entry shape + duplicate gate uses (the empty-feature
16148    // axis is the more-actionable defect since two `""` entries would
16149    // both report `caracteristica: ""` under a duplicate-first
16150    // ordering, with no way to distinguish the offending site).
16151
16152    fn dep_with_features(features: &[&str]) -> Dep {
16153        Dep {
16154            nome: "caixa-teia".into(),
16155            versao: "^0.1".into(),
16156            fonte: None,
16157            opcional: false,
16158            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16159        }
16160    }
16161
16162    #[test]
16163    fn validate_rejects_empty_caracteristica() {
16164        // Fail-before-pass-after pin: every pre-gate codebase accepted
16165        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16166        // imposed no per-entry shape contract), the dep validated, and
16167        // the empty feature would have reached the future caixa-resolver
16168        // lacre pipeline as a no-op feature enable — silently dropping
16169        // the author's intent far from the source `caixa.lisp`. The new
16170        // gate surfaces the structural defect at the typed-validate
16171        // surface with a self-locating diagnostic naming the offending
16172        // dep's `:nome`.
16173        let d = dep_with_features(&[""]);
16174        assert!(
16175            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16176            "expected CaracteristicaEmpty, got {:?}",
16177            d.validate(),
16178        );
16179    }
16180
16181    #[test]
16182    fn validate_rejects_duplicate_caracteristica() {
16183        // Fail-before-pass-after pin on the set-not-multiset arm: the
16184        // feature-toggle slot is set-shaped, so `(:caracteristicas
16185        // ("http" "http"))` is a redundant declaration the lacre
16186        // pipeline dedupes silently at resolve time. The diagnostic
16187        // names the offending dep + the colliding feature verbatim so
16188        // the author can grep their caixa.lisp for `:caracteristicas`
16189        // and fix it in one edit. First-collision determinism is
16190        // pinned separately below.
16191        let d = dep_with_features(&["http", "http"]);
16192        assert!(
16193            matches!(
16194                d.validate().unwrap_err(),
16195                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16196                    if nome == "caixa-teia" && caracteristica == "http"
16197            ),
16198            "expected CaracteristicaDuplicate, got {:?}",
16199            d.validate(),
16200        );
16201    }
16202
16203    #[test]
16204    fn validate_accepts_distinct_caracteristicas() {
16205        // The canonical authoring shape — every feature distinct — must
16206        // remain a clean pass (positive control sweep). Covers the
16207        // canonical kebab-case feature names a target caixa typically
16208        // declares.
16209        dep_with_features(&["http", "json", "tls"])
16210            .validate()
16211            .unwrap();
16212    }
16213
16214    #[test]
16215    fn validate_accepts_single_caracteristica() {
16216        // Single-element list is the minimum non-empty shape; passes
16217        // the gate as the identity of the duplicate check (no second
16218        // entry to collide with).
16219        dep_with_features(&["http"]).validate().unwrap();
16220    }
16221
16222    #[test]
16223    fn validate_accepts_empty_caracteristicas_list() {
16224        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16225        // produces `caracteristicas: Vec::new()`; the empty list is
16226        // the gate's empty-set identity and passes vacuously. Pin
16227        // this so a future tightening that requires ≥1 feature
16228        // surfaces here as a test failure rather than a silent
16229        // contract narrowing.
16230        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16231        assert!(dep_with_features(&[]).validate().is_ok());
16232    }
16233
16234    #[test]
16235    fn validate_caracteristica_empty_fires_before_duplicate() {
16236        // Empty-first cascade: an entry with an empty feature *and*
16237        // duplicate entries surfaces the empty diagnostic first. The
16238        // empty-feature axis is the more-actionable defect since
16239        // `caracteristica: ""` is unambiguous; under duplicate-first
16240        // ordering the diagnostic could report the empty string from
16241        // either of two empty entries with no way to distinguish.
16242        // Mirrors the peer empty-before-duplicate ordering
16243        // discipline every per-entry shape + duplicate gate establishes
16244        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16245        // `DuplicateChildCaixa`, `validate_membros`'s
16246        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16247        let d = dep_with_features(&["", "http", "http"]);
16248        assert!(matches!(
16249            d.validate().unwrap_err(),
16250            DepError::CaracteristicaEmpty { .. }
16251        ));
16252    }
16253
16254    #[test]
16255    fn validate_caracteristica_duplicate_first_collision_determinism() {
16256        // Three matching entries: the second occurrence surfaces the
16257        // diagnostic (the second is the first *collision* — the first
16258        // entry is the establishing one, not a duplicate). Mirrors
16259        // every peer first-collision posture
16260        // (`SupervisorError::DuplicateChildCaixa` reports the second
16261        // collision, `AplicacaoError::MembroDuplicate` reports the
16262        // second, `DepError::DuplicateNome` reports the second).
16263        // Pinning this so a future shortcut that flips to last-
16264        // collision (or non-deterministic) surfaces here.
16265        let d = dep_with_features(&["http", "http", "http"]);
16266        assert!(matches!(
16267            d.validate().unwrap_err(),
16268            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16269        ));
16270    }
16271
16272    #[test]
16273    fn validate_per_entry_shape_fires_before_caracteristicas() {
16274        // Per-entry shape precedence: a dep with a malformed `:nome`
16275        // (uppercase) AND duplicate `:caracteristicas` surfaces the
16276        // narrower `NomeInvalid` diagnostic first, not the set-gate
16277        // diagnostic. The `:nome` is the self-locating axis (every
16278        // diagnostic from the caracteristicas gate quotes the
16279        // offending dep's `:nome` to anchor the grep target —
16280        // surfacing the malformed name first keeps that anchor
16281        // valid). Same precedence shape every peer per-entry-shape
16282        // arm establishes against its peer set-gate
16283        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16284        // on the cross-entry `:nome` axis).
16285        let d = Dep {
16286            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16287            versao: "^0.1".into(),
16288            fonte: None,
16289            opcional: false,
16290            caracteristicas: vec!["http".into(), "http".into()],
16291        };
16292        assert!(matches!(
16293            d.validate().unwrap_err(),
16294            DepError::NomeInvalid { .. }
16295        ));
16296    }
16297
16298    // ── per-entry :caracteristicas value-shape gate ──────────────────
16299    //
16300    // Until this gate landed `:caracteristicas` only refused the empty
16301    // string and cross-entry duplicates: a non-empty distinct but
16302    // structurally invalid feature name silently passed validate and the
16303    // failure surfaced at `cargo metadata` time as Cargo's
16304    // `restricted_names::validate_feature_name` parser rejection, far from
16305    // the source `caixa.lisp` with no field naming which `:deps` entry's
16306    // `:caracteristicas` carried the typo. The lifted predicate makes the
16307    // Cargo-feature-name-grammar intersection-floor a substrate-level
16308    // invariant at validate time. Same trajectory as the eight peer
16309    // value-shape predicates each typed surface downstream of a structured
16310    // grammar already follows.
16311
16312    #[test]
16313    fn validate_rejects_caracteristica_with_leading_plus() {
16314        // Fail-before-pass-after pin on the canonical Cargo
16315        // `+<feature>` activation-form-in-feature-name-slot footgun.
16316        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16317        // `+optional-feature` as an enablement of a previously-disabled
16318        // feature; pasting that activation form into `:caracteristicas`
16319        // (which names the feature itself) silently passed pre-gate and
16320        // failed at `cargo metadata` parse time.
16321        let d = dep_with_features(&["+http"]);
16322        let err = d.validate().unwrap_err();
16323        assert!(
16324            matches!(
16325                err,
16326                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16327                    if nome == "caixa-teia" && caracteristica == "+http"
16328            ),
16329            "expected CaracteristicaInvalid, got {err:?}"
16330        );
16331    }
16332
16333    #[test]
16334    fn validate_rejects_caracteristica_with_leading_hyphen() {
16335        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16336        // is a legitimate continuation character (kebab-case feature
16337        // names like `runtime-tokio` pass) but Cargo rejects it at the
16338        // start; the structural defect — and its CLI-argument-injection
16339        // adjacency at any downstream Cargo subprocess invocation — is
16340        // closed at validate time, not at `cargo metadata` time.
16341        let d = dep_with_features(&["-json"]);
16342        let err = d.validate().unwrap_err();
16343        assert!(
16344            matches!(
16345                err,
16346                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16347            ),
16348            "expected CaracteristicaInvalid, got {err:?}"
16349        );
16350    }
16351
16352    #[test]
16353    fn validate_rejects_caracteristica_with_leading_dot() {
16354        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16355        // a legitimate continuation character (version-suffix shapes
16356        // like `feat.v2` pass) but the leading-dot form is the
16357        // canonical dotted-version-suffix-as-feature-name confusion.
16358        let d = dep_with_features(&[".feat"]);
16359        let err = d.validate().unwrap_err();
16360        assert!(matches!(
16361            err,
16362            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16363        ));
16364    }
16365
16366    #[test]
16367    fn validate_rejects_caracteristica_with_whitespace() {
16368        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16369        // a feature name with a space inside is structurally a multi-
16370        // token blob (the canonical paste-from-doc footgun, or an
16371        // accidental `"http server"` where the author meant
16372        // `"http-server"`).
16373        let d = dep_with_features(&["http feature"]);
16374        let err = d.validate().unwrap_err();
16375        assert!(matches!(
16376            err,
16377            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16378        ));
16379    }
16380
16381    #[test]
16382    fn validate_rejects_caracteristica_with_comma() {
16383        // Fail-before-pass-after pin on the embedded-comma footgun:
16384        // the list-separator-belongs-to-the-list-grammar
16385        // miscomprehension where the author writes
16386        // `:caracteristicas ("http,json")` intending two features but
16387        // the `Vec<String>` field consumes the bare token as one entry.
16388        let d = dep_with_features(&["http,json"]);
16389        let err = d.validate().unwrap_err();
16390        assert!(matches!(
16391            err,
16392            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16393        ));
16394    }
16395
16396    #[test]
16397    fn validate_rejects_caracteristica_with_slash() {
16398        // Fail-before-pass-after pin on the embedded-slash footgun:
16399        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16400        // `[dependencies.<dep>.features]` list entries that already
16401        // name the parent dep (so the syntax says "enable feature
16402        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16403        // per-dep already (a sibling slot on the `Dep` itself), so the
16404        // segment separator within an entry must be `-`, `_`, `+`,
16405        // or `.`. The diagnostic remediation points at the canonical
16406        // Cargo namespaced-dep discipline.
16407        let d = dep_with_features(&["http/json"]);
16408        let err = d.validate().unwrap_err();
16409        assert!(matches!(
16410            err,
16411            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16412        ));
16413    }
16414
16415    #[test]
16416    fn validate_rejects_caracteristica_with_non_ascii() {
16417        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16418        // byte footgun: NFC-vs-NFD normalization across filesystems
16419        // silently rewrites the feature-key, breaking the lacre's
16420        // content-addressing invariant. Pinned at a canonical
16421        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16422        // documented APFS round-trip break.
16423        let d = dep_with_features(&["caf\u{e9}"]);
16424        let err = d.validate().unwrap_err();
16425        assert!(matches!(
16426            err,
16427            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16428        ));
16429    }
16430
16431    #[test]
16432    fn validate_rejects_caracteristica_with_control_character() {
16433        // Fail-before-pass-after pin on the embedded-control-character
16434        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16435        // feature name is the canonical paste-from-multiline-doc
16436        // footgun the predicate's reason wording specifically calls out.
16437        let d = dep_with_features(&["http\njson"]);
16438        let err = d.validate().unwrap_err();
16439        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16440    }
16441
16442    #[test]
16443    fn validate_accepts_canonical_caracteristicas_shapes() {
16444        // Positive control sweep: every canonical Cargo feature name
16445        // shape the pleme-io ecosystem uses must still pass. Mirrors
16446        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16447        // sweep — drift between either landing site and the predicate's
16448        // accepted set is a build error visible at this pair of tests,
16449        // not a per-renderer "this passed validate but failed at
16450        // cargo metadata time" surprise on the next acceptance.
16451        for s in [
16452            "http",
16453            "json",
16454            "derive",
16455            "serde_json",
16456            "runtime-tokio",
16457            "tokio.full",
16458            "v0.1",
16459            "http+json",
16460            "_internal",
16461            "__private",
16462            "default",
16463            "rt-multi-thread",
16464            "feat.v2",
16465        ] {
16466            let d = dep_with_features(&[s]);
16467            d.validate().unwrap_or_else(|e| {
16468                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16469            });
16470        }
16471    }
16472
16473    #[test]
16474    fn validate_caracteristica_empty_fires_before_invalid() {
16475        // Cascade precedence pin: an entry list with both an empty
16476        // feature AND an invalid-shape feature surfaces the
16477        // `CaracteristicaEmpty` arm first (the empty value carries no
16478        // self-locating data — `caracteristica: ""` is the diagnostic
16479        // with no way to anchor a grep target — so closing the empty
16480        // axis first preserves the per-entry-shape diagnostic's
16481        // self-locating discipline). Same empty-first cascade every
16482        // peer per-entry shape gate establishes
16483        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16484        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16485        // before `MembroCaixaInvalid`).
16486        let d = dep_with_features(&["", "+http"]);
16487        assert!(matches!(
16488            d.validate().unwrap_err(),
16489            DepError::CaracteristicaEmpty { .. }
16490        ));
16491    }
16492
16493    #[test]
16494    fn validate_caracteristica_invalid_fires_before_duplicate() {
16495        // Per-entry-shape precedence pin: an entry list with the same
16496        // invalid feature shape declared twice surfaces the
16497        // `CaracteristicaInvalid` diagnostic on the first entry, not
16498        // the `CaracteristicaDuplicate` on the second collision. The
16499        // per-entry shape gate fires before the cross-entry set gate
16500        // — same precedence shape every peer two-arm-plus-set gate
16501        // establishes (`SupervisorSpec::validate`'s
16502        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16503        // `validate_membros`'s `MembroCaixaInvalid` before
16504        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16505        // cross-list `DuplicateNome`).
16506        let d = dep_with_features(&["+http", "+http"]);
16507        assert!(matches!(
16508            d.validate().unwrap_err(),
16509            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16510        ));
16511    }
16512
16513    #[test]
16514    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16515        // Boundary pin on the 64-byte cap — both the boundary-accepting
16516        // case and the boundary-exceeding case in one place, so a
16517        // future cap shift surfaces both arms simultaneously, mirroring
16518        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16519        // predicate-level pin at the dep-axis landing site.
16520        let max_ok = "a".repeat(64);
16521        dep_with_features(&[&max_ok])
16522            .validate()
16523            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16524        let too_long = "a".repeat(65);
16525        let d = dep_with_features(&[&too_long]);
16526        assert!(matches!(
16527            d.validate().unwrap_err(),
16528            DepError::CaracteristicaInvalid { .. }
16529        ));
16530    }
16531
16532    // ── self-dep cross-slot gate ─────────────────────────────────────
16533
16534    #[test]
16535    fn validate_no_self_dep_rejects_self_in_deps() {
16536        // A caixa whose `:deps` lists its own `:nome` is a one-node
16537        // cycle in the lacre closure's dep-graph traversal — rejected,
16538        // naming the parent and the offending list tag.
16539        let deps = vec![
16540            Dep::simple("caixa-teia", "^0.1"),
16541            Dep::simple("orquestra", "^0.1"),
16542        ];
16543        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16544        assert!(
16545            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16546            "got {err:?}"
16547        );
16548    }
16549
16550    #[test]
16551    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16552        // Same gate on the `:deps-dev` axis — neither dep list is a
16553        // second-class citizen on the self-edge invariant.
16554        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16555        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16556        assert!(
16557            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16558            "got {err:?}"
16559        );
16560    }
16561
16562    #[test]
16563    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16564        // Walk order pin: a caixa that self-references on both lists
16565        // surfaces the `:deps` arm first — the load-bearing axis the
16566        // lacre closure resolves at every build. Mirrors the canonical
16567        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16568        let deps = vec![Dep::simple("orquestra", "^0.1")];
16569        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16570        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16571        assert!(
16572            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16573            "got {err:?}"
16574        );
16575    }
16576
16577    #[test]
16578    fn validate_no_self_dep_accepts_distinct_names() {
16579        // Positive control: every dep names a distinct caixa. The
16580        // canonical author surface — peer of
16581        // [`validate_no_self_supervision_accepts_distinct_children`].
16582        let deps = vec![
16583            Dep::simple("caixa-teia", "^0.1"),
16584            Dep::simple("caixa-arch", "^0.1"),
16585        ];
16586        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16587        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16588    }
16589
16590    #[test]
16591    fn validate_no_self_dep_empty_lists_pass() {
16592        // A caixa with no declared deps has nothing to self-reference —
16593        // the gate is vacuously satisfied. Peer of
16594        // [`validate_no_self_supervision_empty_children_is_ok`].
16595        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16596    }
16597
16598    #[test]
16599    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16600        // Diagnostic-shape pin (peer with
16601        // [`validate_no_self_supervision`]'s diagnostic): the error's
16602        // Display surfaces both the offending list tag and the
16603        // parent's `:nome` verbatim, so the author can grep their
16604        // caixa.lisp for the offending block in one edit. Names
16605        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16606        // surface — every legitimate "I want to use code from this
16607        // caixa" intent routes through one of those three slots.
16608        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16609        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16610            .unwrap_err()
16611            .to_string();
16612        assert!(
16613            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16614            "diagnostic must name the offending list tag: {rendered}",
16615        );
16616        assert!(
16617            rendered.contains("orquestra"),
16618            "diagnostic must quote the parent caixa name: {rendered}",
16619        );
16620        assert!(
16621            rendered.contains(":bibliotecas"),
16622            "diagnostic must point at the corrective code-surface slot: {rendered}",
16623        );
16624    }
16625
16626    #[test]
16627    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16628        // Identity is exact-string equality, not substring — a dep
16629        // named `"orquestra-helper"` is a distinct caixa even when the
16630        // parent is `"orquestra"`. Pin the exact-match discipline so a
16631        // future relaxation that uses `contains` surfaces here, peer
16632        // with the supervision-tree and Aplicacao-membership gates
16633        // which all use exact-string equality on the typed identity.
16634        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16635        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16636    }
16637
16638    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16639
16640    #[test]
16641    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16642        // Scalar-value pin: the two author-facing kebab-case labels the
16643        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16644        // the two-list dep-graph slot axis, one arm per typed slot.
16645        // Mirrors the peer scalar-value pin the sibling
16646        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16647        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16648        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16649        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16650        // (882f498) M3 top-level author-labels, and
16651        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16652        // Supervisor top-level author-labels carry, so every kind-scoped
16653        // typed-slot-family axis routes through one canonical per-arm
16654        // declaration.
16655        //
16656        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16657        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16658        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16659        // for symmetry) lands as an edit to exactly one const, and
16660        // every consumer that reaches for the label picks it up at
16661        // build time rather than at runtime as a downstream mismatch on
16662        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16663        // the rename's commit.
16664        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16665        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16666    }
16667
16668    #[test]
16669    fn dep_author_key_consts_are_pairwise_distinct() {
16670        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16671        // must not collapse onto one byte-string. A future copy-paste
16672        // slip that renamed both consts to the same value (or a rebrand
16673        // that dropped the `-dev` suffix from one but not the other)
16674        // would leave every `DepError::DuplicateNome { list: … }`
16675        // diagnostic naming an unattributable list — the linter would
16676        // route the author to the wrong caixa.lisp block, or the
16677        // cross-list precedence gate
16678        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16679        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16680        // duplicate. Peer of the sibling
16681        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16682        // other top-level kind-scoped slot-family axes carry
16683        // (implicitly held by their different byte-values today).
16684        assert_ne!(
16685            crate::render::DEP_AUTHOR_KEY_DEPS,
16686            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16687            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16688             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16689             self-locates the offending block in the author's caixa.lisp",
16690        );
16691    }
16692
16693    #[test]
16694    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16695        // Production-through-const pin: the two per-arm list tags
16696        // [`validate_no_self_dep`] threads onto the `list:` field of a
16697        // returned [`DepError::DepIsSelf`] route through the lifted
16698        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16699        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16700        // the walker (a rename that reaches one arm but not the const,
16701        // or vice versa) surfaces here at build time rather than at
16702        // runtime as a `feira lint` diagnostic naming the wrong list
16703        // tag. Mirror of the peer
16704        // [`crate::Caixa::declared_servico_slots`] production tagger
16705        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16706        // onto the two-list dep-graph gate.
16707        let deps = vec![Dep::simple("orquestra", "^0.1")];
16708        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16709        let DepError::DepIsSelf { list, .. } = err else {
16710            panic!("expected DepIsSelf from :deps walk");
16711        };
16712        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16713
16714        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16715        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16716        let DepError::DepIsSelf { list, .. } = err else {
16717            panic!("expected DepIsSelf from :deps-dev walk");
16718        };
16719        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16720    }
16721
16722    // ── Dep::nome accessor pins ───────────────────────────────────────
16723    //
16724    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16725    // projection over the plain-shorthand / explicit-git / explicit-path
16726    // fixture triad the [`Dep`] docstring lists (so the accessor's
16727    // accept-set is exercised across every author-surface `:fonte`
16728    // shape); by-borrow pointer identity so the projection stays
16729    // zero-copy at every consumer site; and validate-composition through
16730    // the [`validate_no_self_dep`] cross-slot gate reading its
16731    // parent-name equality check through the lifted accessor rather than
16732    // the raw field.
16733
16734    #[test]
16735    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16736        // Plain-shorthand form (`:fonte None`).
16737        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16738        // Explicit git-source form with a tag pin — same accessor path.
16739        assert_eq!(
16740            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16741            "caixa-teia",
16742        );
16743        // Explicit path-source form.
16744        assert_eq!(
16745            Dep {
16746                nome: "caixa-teia".to_string(),
16747                versao: "0.1.0".to_string(),
16748                fonte: Some(DepSource::Path {
16749                    caminho: "../caixa-teia".to_string(),
16750                }),
16751                opcional: false,
16752                caracteristicas: Vec::new(),
16753            }
16754            .nome(),
16755            "caixa-teia",
16756        );
16757        // The empty-string `:nome` sentinel (which [`Dep::validate`]
16758        // refuses through the [`DepError::NomeEmpty`] arm) still round-
16759        // trips as an empty `&str` through the accessor — the accessor is
16760        // a projection, not a gate; the gate is [`Dep::validate`].
16761        assert_eq!(Dep::simple("", "^0.1").nome(), "");
16762    }
16763
16764    #[test]
16765    fn dep_nome_is_by_borrow_pointer_identity() {
16766        // Zero-copy pin: the accessor must borrow into the field's own
16767        // storage, not clone. If a future rewrite regresses to
16768        // `self.nome.clone().leak()` or an owned-buffer shape, the two
16769        // pointers diverge and this pin fails at build time.
16770        let d = Dep::simple("caixa-teia", "^0.1");
16771        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16772    }
16773
16774    // ── Dep::versao_requirement accessor pins ─────────────────────────
16775    //
16776    // Three coherence pins on the lifted `Dep::versao_requirement`
16777    // accessor: byte-equal projection over the plain-shorthand /
16778    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16779    // lists plus the empty-sentinel that round-trips as `""` (the accessor
16780    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16781    // borrow pointer identity so the projection stays zero-copy at every
16782    // consumer site; and validate-composition through the
16783    // [`crate::render::require_valid_versao_requirement`] cascade reading
16784    // its requirement-shape check through the lifted accessor rather than
16785    // the raw field.
16786    #[test]
16787    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16788        // Plain-shorthand form (`:fonte None`).
16789        assert_eq!(
16790            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16791            "^0.1",
16792        );
16793        // Explicit git-source form with a tag pin — same accessor path.
16794        assert_eq!(
16795            Dep::git(
16796                "caixa-teia",
16797                "~0.1.2",
16798                "github:pleme-io/caixa-teia",
16799                "v0.1.0"
16800            )
16801            .versao_requirement(),
16802            "~0.1.2",
16803        );
16804        // Explicit path-source form.
16805        assert_eq!(
16806            Dep {
16807                nome: "caixa-teia".to_string(),
16808                versao: "0.1.0".to_string(),
16809                fonte: Some(DepSource::Path {
16810                    caminho: "../caixa-teia".to_string(),
16811                }),
16812                opcional: false,
16813                caracteristicas: Vec::new(),
16814            }
16815            .versao_requirement(),
16816            "0.1.0",
16817        );
16818        // The wildcard requirement (`"*"`) — the shorthand
16819        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16820        // verbatim through the accessor as `"*"`, same byte-shape the
16821        // author wrote.
16822        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16823        // The empty-string `:versao` sentinel (which [`Dep::validate`]
16824        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16825        // trips as an empty `&str` through the accessor — the accessor is
16826        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16827        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16828        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16829    }
16830
16831    #[test]
16832    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16833        // Zero-copy pin: the accessor must borrow into the field's own
16834        // storage, not clone. If a future rewrite regresses to
16835        // `self.versao.clone().leak()` or an owned-buffer shape, the two
16836        // pointers diverge and this pin fails at build time. Peer of the
16837        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16838        // discipline extended onto the requirement-carrying axis.
16839        let d = Dep::simple("caixa-teia", "^0.1");
16840        assert!(std::ptr::eq(
16841            d.versao_requirement().as_ptr(),
16842            d.versao.as_ptr(),
16843        ));
16844    }
16845
16846    #[test]
16847    fn dep_validate_reads_requirement_through_accessor() {
16848        // Composition pin: the [`Dep::validate`]
16849        // [`crate::render::require_valid_versao_requirement`] cascade
16850        // consumes the requirement string through the lifted accessor —
16851        // both the requirement-gate input and the
16852        // [`DepError::VersaoInvalid`] error-body carrier route through
16853        // `self.versao_requirement()`. A valid requirement passes
16854        // (positive control); a malformed-but-non-empty requirement fails
16855        // and the diagnostic quotes the offending byte-string verbatim
16856        // (same shape the accessor projects), so a future regression that
16857        // detoured the requirement carrier through a different byte-
16858        // string (say the parsed `VersionReq`'s `Display`, or a
16859        // normalized rewrite) would surface here at build time. The
16860        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16861        // ahead of the parse arm, pinning the empty-first cascade the
16862        // accessor's `""` sentinel round-trip acknowledges.
16863        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16864        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16865        assert!(
16866            matches!(
16867                &err,
16868                DepError::VersaoInvalid {
16869                    nome,
16870                    versao,
16871                    ..
16872                } if nome == "caixa-teia" && versao == "v0.1",
16873            ),
16874            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16875        );
16876        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16877        assert!(
16878            matches!(
16879                &err,
16880                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16881            ),
16882            "expected VersaoEmpty from the empty-first arm, got {err:?}",
16883        );
16884    }
16885
16886    // ── Dep::fonte accessor pins ──────────────────────────────────────
16887    //
16888    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16889    // equal projection over the plain-shorthand (`:fonte None`) /
16890    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16891    // docstring lists (so the accessor's accept-set is exercised across
16892    // every author-surface `:fonte` shape and both `DepSource` variants);
16893    // pointer identity so the borrowed reference points into the field's
16894    // own `Option<DepSource>` storage (not a cloned side-buffer); and
16895    // validate-composition through the [`Dep::validate`] gate reading
16896    // its per-`:fonte` [`DepSource::validate`] delegation through the
16897    // lifted accessor rather than the raw `if let Some(ref fonte) =
16898    // self.fonte` bracket.
16899
16900    #[test]
16901    fn dep_fonte_returns_declared_source_across_shapes() {
16902        // Plain-shorthand form — `:fonte` omitted, accessor projects
16903        // the `None` partition the resolver-side default-fill treats
16904        // as "resolve through `github:<default-org>/<nome>`".
16905        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16906        // Explicit git-source form with a tag pin — same accessor path.
16907        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16908        match git.fonte() {
16909            Some(DepSource::Git {
16910                repo,
16911                tag,
16912                rev,
16913                branch,
16914            }) => {
16915                assert_eq!(repo, "github:pleme-io/caixa-teia");
16916                assert_eq!(tag.as_deref(), Some("v0.1.0"));
16917                assert!(rev.is_none());
16918                assert!(branch.is_none());
16919            }
16920            other => panic!("expected explicit git :fonte, got {other:?}"),
16921        }
16922        // Explicit path-source form — the dev-only local-filesystem
16923        // arm the [`Dep`] docstring's third fixture carries.
16924        let path = Dep {
16925            nome: "caixa-teia".to_string(),
16926            versao: "0.1.0".to_string(),
16927            fonte: Some(DepSource::Path {
16928                caminho: "../caixa-teia".to_string(),
16929            }),
16930            opcional: false,
16931            caracteristicas: Vec::new(),
16932        };
16933        match path.fonte() {
16934            Some(DepSource::Path { caminho }) => {
16935                assert_eq!(caminho, "../caixa-teia");
16936            }
16937            other => panic!("expected explicit path :fonte, got {other:?}"),
16938        }
16939    }
16940
16941    #[test]
16942    fn dep_fonte_is_by_borrow_pointer_identity() {
16943        // Zero-copy pin: the accessor must borrow into the field's own
16944        // `Option<DepSource>` storage, not clone into a side buffer. If
16945        // a future rewrite regresses to `self.fonte.clone()` or an
16946        // owned-buffer shape, the two pointers diverge and this pin
16947        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16948        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16949        // identity pins — same by-borrow discipline extended onto the
16950        // outer-`Dep` `Option<&Composite>` composite-reference axis.
16951        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16952        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16953        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16954        assert!(std::ptr::eq(accessed, raw));
16955    }
16956
16957    #[test]
16958    fn dep_validate_reads_fonte_through_accessor() {
16959        // Composition pin: [`Dep::validate`]'s per-`:fonte`
16960        // [`DepSource::validate`] delegation consumes the typed slot
16961        // through the lifted accessor — an author-omitted `:fonte`
16962        // still passes the outer gate (positive control), an explicit
16963        // well-formed git source with exactly one pin passes, and a
16964        // malformed git source (empty `:repo`) surfaces the
16965        // [`DepError::FonteRepoEmpty`] variant quoting the offending
16966        // dep's `:nome` verbatim so a future regression that detoured
16967        // the `:fonte` delegation through a different path (say a
16968        // per-scope override projector) would surface here at build
16969        // time. Peer of the sibling
16970        // `dep_validate_reads_requirement_through_accessor` composition
16971        // pin on the `:versao` axis.
16972        // Positive control 1: no `:fonte` at all.
16973        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16974        // Positive control 2: well-formed git source.
16975        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16976            .validate()
16977            .unwrap();
16978        // Negative control: empty `:repo` — the accessor still returns
16979        // `Some(&DepSource::Git { repo: "", … })` and the delegated
16980        // `DepSource::validate` gate raises the typed carrier.
16981        let bad = Dep {
16982            nome: "caixa-teia".to_string(),
16983            versao: "^0.1".to_string(),
16984            fonte: Some(DepSource::Git {
16985                repo: String::new(),
16986                tag: Some("v0.1.0".to_string()),
16987                rev: None,
16988                branch: None,
16989            }),
16990            opcional: false,
16991            caracteristicas: Vec::new(),
16992        };
16993        let err = bad.validate().unwrap_err();
16994        assert!(
16995            matches!(
16996                &err,
16997                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16998            ),
16999            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17000        );
17001    }
17002
17003    #[test]
17004    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17005        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17006        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17007        // own `:nome` through the lifted accessor rather than the raw
17008        // field. Fails-before-passes-after: with the accessor lifted the
17009        // gate reads its equality check through `dep.nome() ==
17010        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17011        // the diagnostic still names the offending list tag as expected.
17012        let deps = vec![Dep::simple("orquestra", "^0.1")];
17013        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17014        assert!(matches!(
17015            err,
17016            DepError::DepIsSelf {
17017                ref nome,
17018                list,
17019            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17020        ));
17021        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17022        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17023        assert!(matches!(
17024            err,
17025            DepError::DepIsSelf {
17026                ref nome,
17027                list,
17028            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17029        ));
17030        // A non-matching `:nome` passes through the accessor gate.
17031        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17032        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17033    }
17034
17035    // ── Dep::caracteristicas accessor pins ────────────────────────────
17036    //
17037    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17038    // byte-equal projection over the default-empty / single-entry /
17039    // multi-entry fixture triad (so the accessor's accept-set is
17040    // exercised across every author-surface `:caracteristicas` shape,
17041    // matching the peer sibling family's fixture-triad discipline); by-
17042    // borrow pointer identity so the projection stays zero-copy at every
17043    // consumer site; and validate-composition through the
17044    // [`Dep::validate_caracteristicas`] gate reading its per-entry
17045    // linear walk through the lifted accessor rather than the raw
17046    // `for c in &self.caracteristicas` bracket.
17047
17048    #[test]
17049    fn dep_caracteristicas_returns_declared_features_across_shapes() {
17050        // Default-empty form — the [`Dep::simple`] constructor's
17051        // `Vec::new()` fill; the accessor projects the empty slice
17052        // verbatim (no `None` collapse).
17053        assert!(
17054            Dep::simple("caixa-teia", "^0.1")
17055                .caracteristicas()
17056                .is_empty(),
17057        );
17058        // Single-entry form — the canonical Cargo-shaped one-feature
17059        // enable ([`crate::render::is_cargo_feature_name`] accepts the
17060        // `"http"` byte-string as a valid feature name).
17061        let one = Dep {
17062            nome: "caixa-teia".to_string(),
17063            versao: "^0.1".to_string(),
17064            fonte: None,
17065            opcional: false,
17066            caracteristicas: vec!["http".to_string()],
17067        };
17068        assert_eq!(one.caracteristicas(), &["http".to_string()]);
17069        // Multi-entry form — the substrate's set-shaped multi-feature
17070        // enable, exercising the accessor over a length-two slice with
17071        // no duplicate collapse.
17072        let two = Dep {
17073            nome: "caixa-teia".to_string(),
17074            versao: "^0.1".to_string(),
17075            fonte: None,
17076            opcional: false,
17077            caracteristicas: vec!["http".to_string(), "json".to_string()],
17078        };
17079        assert_eq!(
17080            two.caracteristicas(),
17081            &["http".to_string(), "json".to_string()],
17082        );
17083    }
17084
17085    #[test]
17086    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17087        // Zero-copy pin: the accessor must borrow into the field's own
17088        // `Vec<String>` storage, not clone into a side buffer. If a
17089        // future rewrite regresses to `self.caracteristicas.clone()` or
17090        // an owned-buffer shape, the two pointers diverge and this pin
17091        // fails at build time. Peer of the sibling per-`Dep`
17092        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17093        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17094        // borrow discipline extended onto the outer-`Dep` `&[String]`
17095        // slice-projection axis.
17096        let d = Dep {
17097            nome: "caixa-teia".to_string(),
17098            versao: "^0.1".to_string(),
17099            fonte: None,
17100            opcional: false,
17101            caracteristicas: vec!["http".to_string(), "json".to_string()],
17102        };
17103        assert!(std::ptr::eq(
17104            d.caracteristicas().as_ptr(),
17105            d.caracteristicas.as_ptr(),
17106        ));
17107    }
17108
17109    #[test]
17110    fn dep_validate_reads_caracteristicas_through_accessor() {
17111        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17112        // linear walk consumes the feature-toggle list through the
17113        // lifted accessor — a well-formed `:caracteristicas` set passes
17114        // (positive control), an empty-string entry surfaces the
17115        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17116        // `Dep::nome`, and a within-list duplicate surfaces the
17117        // [`DepError::CaracteristicaDuplicate`] variant so a future
17118        // regression that detoured the walk through a different byte-
17119        // string list (say a per-scope override projector) would surface
17120        // here at build time. Peer of the sibling
17121        // `dep_validate_reads_fonte_through_accessor` /
17122        // `dep_validate_reads_requirement_through_accessor` composition
17123        // pins on the `:fonte` / `:versao` axes.
17124        // Positive control: two distinct well-formed feature names pass.
17125        Dep {
17126            nome: "caixa-teia".to_string(),
17127            versao: "^0.1".to_string(),
17128            fonte: None,
17129            opcional: false,
17130            caracteristicas: vec!["http".to_string(), "json".to_string()],
17131        }
17132        .validate()
17133        .unwrap();
17134        // Negative control 1: empty-string feature-name entry — the
17135        // accessor still returns `&[""]` and the walk raises the typed
17136        // empty-first carrier.
17137        let err = Dep {
17138            nome: "caixa-teia".to_string(),
17139            versao: "^0.1".to_string(),
17140            fonte: None,
17141            opcional: false,
17142            caracteristicas: vec![String::new()],
17143        }
17144        .validate()
17145        .unwrap_err();
17146        assert!(
17147            matches!(
17148                &err,
17149                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17150            ),
17151            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17152        );
17153        // Negative control 2: within-list duplicate — the accessor's
17154        // slice view carries both entries, and the walk's dedup arm
17155        // raises the typed duplicate carrier quoting the offending
17156        // feature name verbatim.
17157        let err = Dep {
17158            nome: "caixa-teia".to_string(),
17159            versao: "^0.1".to_string(),
17160            fonte: None,
17161            opcional: false,
17162            caracteristicas: vec!["http".to_string(), "http".to_string()],
17163        }
17164        .validate()
17165        .unwrap_err();
17166        assert!(
17167            matches!(
17168                &err,
17169                DepError::CaracteristicaDuplicate {
17170                    nome,
17171                    caracteristica,
17172                } if nome == "caixa-teia" && caracteristica == "http",
17173            ),
17174            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17175        );
17176    }
17177
17178    // ── Dep::opcional accessor pins ───────────────────────────────────
17179    //
17180    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17181    // equal projection over the default-`false` / explicit-`true`
17182    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17183    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17184    // exercising the accessor's accept-set over every author-surface
17185    // `:fonte` shape × every author-surface `:opcional` shape; and by-
17186    // `Copy` idempotency so the projection stays value-return (no
17187    // silent detour to a fresh `&bool` borrow that would introduce a
17188    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17189    // shape elides). No composition pin — `:opcional` does not
17190    // participate in [`Dep::validate`] (an opcional dep with any bool
17191    // value is validate-accepted; the missing-source arm is a resolver-
17192    // side runtime dispatch, not a build-time refusal), so the axis
17193    // reduces to the value-shape + `Copy` pin pair the peer
17194    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17195    // outer-`Option<Copy>` accessor pins already carry.
17196
17197    #[test]
17198    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17199        // Default-`false` form via the [`Dep::simple`] constructor —
17200        // the accessor projects the `false` bit the default-fill sets.
17201        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17202        // Default-`false` form via the [`Dep::git`] constructor — same
17203        // default fill; the accessor projects `false` regardless of the
17204        // `:fonte` arm.
17205        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17206        // Explicit-`true` form × plain-shorthand `:fonte` — the
17207        // canonical author-surface "this dep may be missing" shape.
17208        let plain_true = Dep {
17209            nome: "caixa-teia".to_string(),
17210            versao: "^0.1".to_string(),
17211            fonte: None,
17212            opcional: true,
17213            caracteristicas: Vec::new(),
17214        };
17215        assert!(plain_true.opcional());
17216        // Explicit-`true` form × explicit git-source — the accessor
17217        // projects the bit verbatim regardless of the `:fonte` arm.
17218        let git_true = Dep {
17219            nome: "caixa-teia".to_string(),
17220            versao: "^0.1".to_string(),
17221            fonte: Some(DepSource::Git {
17222                repo: "github:pleme-io/caixa-teia".to_string(),
17223                tag: Some("v0.1.0".to_string()),
17224                rev: None,
17225                branch: None,
17226            }),
17227            opcional: true,
17228            caracteristicas: Vec::new(),
17229        };
17230        assert!(git_true.opcional());
17231        // Explicit-`true` form × explicit path-source — the dev-only
17232        // local-filesystem arm the [`Dep`] docstring's third fixture
17233        // carries.
17234        let path_true = Dep {
17235            nome: "caixa-teia".to_string(),
17236            versao: "0.1.0".to_string(),
17237            fonte: Some(DepSource::Path {
17238                caminho: "../caixa-teia".to_string(),
17239            }),
17240            opcional: true,
17241            caracteristicas: Vec::new(),
17242        };
17243        assert!(path_true.opcional());
17244    }
17245
17246    #[test]
17247    fn dep_opcional_projects_bool_by_copy() {
17248        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17249        // (`bool: Copy`) — the accessor does not borrow `&self` past
17250        // the call (no lifetime on the return type), and calling the
17251        // accessor twice on the same [`Dep`] must yield discriminant-
17252        // equal values (idempotent, no side effects on `&self`). Peer
17253        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17254        // `max_restarts_projects_option_by_copy` (eba5211) /
17255        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17256        // outer-`Caixa` altitude — extended here to the outer-`Dep`
17257        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17258        // replaces the pointer-equality claim the sibling per-`Dep`
17259        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17260        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17261        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17262        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17263        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17264        // the same discriminant, so the axis reduces to discriminant
17265        // equality).
17266        //
17267        // Pins against a future silent detour that returned a fresh
17268        // `&bool` reference (which would type-check but silently
17269        // introduce a borrow of `&self` past the call, collapsing the
17270        // load-bearing "no lifetime on the return type" `Copy`
17271        // projection the plain-`Copy`-scalar axis's `bool` shape
17272        // carries) or a stale-read side effect that flipped the outer
17273        // discriminant on successive calls.
17274        for opcional in [false, true] {
17275            let d = Dep {
17276                nome: "caixa-teia".to_string(),
17277                versao: "^0.1".to_string(),
17278                fonte: None,
17279                opcional,
17280                caracteristicas: Vec::new(),
17281            };
17282            let first = d.opcional();
17283            let second = d.opcional();
17284            assert_eq!(
17285                first, second,
17286                "Dep::opcional must be idempotent — two successive calls \
17287                 on the same &self must return the same bool",
17288            );
17289            assert_eq!(
17290                first, opcional,
17291                "Dep::opcional must return :opcional verbatim by Copy — \
17292                 got {first}, expected {opcional}",
17293            );
17294            assert_eq!(
17295                d.opcional(),
17296                d.opcional,
17297                "Dep::opcional accessor and self.opcional field access \
17298                 must byte-equal — a bit-flip drift would silently split \
17299                 the paired resolver-side drop-vs-error dispatch from \
17300                 the storage-side default-fill the [`Dep::simple`] / \
17301                 [`Dep::git`] constructor pair carries",
17302            );
17303        }
17304    }
17305
17306    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17307
17308    #[test]
17309    fn sole_pin_returns_none_for_path_source() {
17310        // A path source carries no git-ref, so `sole_pin()` returns
17311        // `None` structurally — the sibling arm every git-fetching
17312        // consumer partitions off before reaching for a git-ref. Pins
17313        // the Path-arm branch of the accessor against a future silent
17314        // detour that treats a `Self::Path` as an unpinned-git source
17315        // and returns the wrong "no pin" signal (e.g. the empty string,
17316        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17317        // path-arm `git_ref` fill).
17318        let s = DepSource::Path {
17319            caminho: "../local-caixa".to_string(),
17320        };
17321        assert_eq!(s.sole_pin(), None);
17322    }
17323
17324    #[test]
17325    fn sole_pin_returns_none_for_unpinned_git_source() {
17326        // The [`DepSource::default_github`] shorthand shape carries no
17327        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17328        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17329        // materializes when the author omits `:fonte` entirely, then
17330        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17331        // on the `None` arm — the accessor's return matches the arm
17332        // the resolver's diagnostic keys off.
17333        let s = DepSource::default_github("pleme-io", "caixa-teia");
17334        assert_eq!(s.sole_pin(), None);
17335    }
17336
17337    #[test]
17338    fn sole_pin_returns_rev_when_only_rev_is_set() {
17339        let s = DepSource::Git {
17340            repo: "github:o/x".into(),
17341            tag: None,
17342            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17343            branch: None,
17344        };
17345        assert_eq!(
17346            s.sole_pin(),
17347            Some("deadbeefcafebabe1234567890abcdef12345678")
17348        );
17349    }
17350
17351    #[test]
17352    fn sole_pin_returns_tag_when_only_tag_is_set() {
17353        let s = DepSource::Git {
17354            repo: "github:o/x".into(),
17355            tag: Some("v0.1.0".into()),
17356            rev: None,
17357            branch: None,
17358        };
17359        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17360    }
17361
17362    #[test]
17363    fn sole_pin_returns_branch_when_only_branch_is_set() {
17364        let s = DepSource::Git {
17365            repo: "github:o/x".into(),
17366            tag: None,
17367            rev: None,
17368            branch: Some("main".into()),
17369        };
17370        assert_eq!(s.sole_pin(), Some("main"));
17371    }
17372
17373    #[test]
17374    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17375        // Precedence: rev > tag > branch. Validate() rejects
17376        // multiple-pin shapes, but the accessor's precedence is defined
17377        // for pre-validate consumers (the resolver's `MissingPin`
17378        // diagnostic path, the caixa-crd round-trip's default `"main"`
17379        // fallback) and as defense-in-depth if the gate is ever
17380        // bypassed. Pins the same precedence caixa-resolver's
17381        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17382        // inline.
17383        let s = DepSource::Git {
17384            repo: "github:o/x".into(),
17385            tag: Some("v1".into()),
17386            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17387            branch: Some("main".into()),
17388        };
17389        assert_eq!(
17390            s.sole_pin(),
17391            Some("deadbeefcafebabe1234567890abcdef12345678")
17392        );
17393    }
17394
17395    #[test]
17396    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17397        let s = DepSource::Git {
17398            repo: "github:o/x".into(),
17399            tag: Some("v1".into()),
17400            rev: None,
17401            branch: Some("main".into()),
17402        };
17403        assert_eq!(s.sole_pin(), Some("v1"));
17404    }
17405
17406    #[test]
17407    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17408        // Fail-before-pass-after byte-parity pin: the substrate accessor
17409        // must return byte-identical to the inline
17410        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17411        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17412        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17413        // time if the accessor's precedence silently drifts from the
17414        // consumer-side cascade — the exact drift this lift converges
17415        // to one substrate primitive to close structurally.
17416        //
17417        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17418        // branch) each-either-`None`-or-`Some`, so every arm of the
17419        // precedence cascade lands under the pin. `validate()` refuses
17420        // the 4 multi-pin combinations, but the accessor's return is
17421        // defined on all 8.
17422        let vals = [Some("R".to_string()), None];
17423        for tag in &vals {
17424            for rev in &vals {
17425                for branch in &vals {
17426                    let s = DepSource::Git {
17427                        repo: "github:o/x".into(),
17428                        tag: tag.clone(),
17429                        rev: rev.clone(),
17430                        branch: branch.clone(),
17431                    };
17432                    // The exact inline cascade the two pre-lift
17433                    // consumer sites hand-rolled, byte-for-byte.
17434                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17435                    assert_eq!(
17436                        s.sole_pin(),
17437                        expected,
17438                        "sole_pin() must byte-equal \
17439                         rev.or(tag).or(branch) for \
17440                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17441                         a drift would silently split caixa-resolver's \
17442                         fetch_git checkout target from caixa-crd's \
17443                         dep_into_ref git_ref fill",
17444                    );
17445                }
17446            }
17447        }
17448    }
17449
17450    // Fail-before-pass-after pins on the eleven
17451    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17452    // constructors folded from the [`DepSource::validate_caminho`]
17453    // wire-up sites. Each pins the generated ctor's output to the
17454    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17455    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17456    // regression on the two-field `{ nome: nome.to_string(), caminho:
17457    // caminho.to_string() }` construction surfaces here rather than at
17458    // a downstream diagnostic-shape mismatch. Peer of the sibling
17459    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17460    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17461    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17462    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17463    // pins on the peer `SupervisorError` / `AplicacaoError` /
17464    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17465
17466    #[test]
17467    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17468        assert_eq!(
17469            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17470            DepError::FonteCaminhoAbsolute {
17471                nome: "caixa-teia".to_string(),
17472                caminho: "/home/me/work/caixa-teia".to_string(),
17473            },
17474            "generated fonte_caminho_absolute ctor must produce byte-equal \
17475             DepError to the open-coded struct-literal wrap on the same \
17476             (&str, &str) fixture",
17477        );
17478    }
17479
17480    #[test]
17481    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17482        assert_eq!(
17483            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17484            DepError::FonteCaminhoTildeExpansion {
17485                nome: "caixa-teia".to_string(),
17486                caminho: "~/work/caixa-teia".to_string(),
17487            },
17488        );
17489    }
17490
17491    #[test]
17492    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17493        assert_eq!(
17494            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17495            DepError::FonteCaminhoVarExpansion {
17496                nome: "caixa-teia".to_string(),
17497                caminho: "$HOME/work/caixa-teia".to_string(),
17498            },
17499        );
17500    }
17501
17502    #[test]
17503    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17504        assert_eq!(
17505            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17506            DepError::FonteCaminhoLeadingWhitespace {
17507                nome: "caixa-teia".to_string(),
17508                caminho: " ../caixa-teia".to_string(),
17509            },
17510        );
17511    }
17512
17513    #[test]
17514    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17515        assert_eq!(
17516            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17517            DepError::FonteCaminhoLeadingHyphen {
17518                nome: "caixa-teia".to_string(),
17519                caminho: "-rf".to_string(),
17520            },
17521        );
17522    }
17523
17524    #[test]
17525    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17526        assert_eq!(
17527            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17528            DepError::FonteCaminhoBackslash {
17529                nome: "caixa-teia".to_string(),
17530                caminho: "..\\caixa-teia".to_string(),
17531            },
17532        );
17533    }
17534
17535    #[test]
17536    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17537        assert_eq!(
17538            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17539            DepError::FonteCaminhoShellPipe {
17540                nome: "caixa-teia".to_string(),
17541                caminho: "../caixa-teia|evil".to_string(),
17542            },
17543        );
17544    }
17545
17546    #[test]
17547    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17548        assert_eq!(
17549            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17550            DepError::FonteCaminhoShellSemicolon {
17551                nome: "caixa-teia".to_string(),
17552                caminho: "../caixa-teia;evil".to_string(),
17553            },
17554        );
17555    }
17556
17557    #[test]
17558    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17559        assert_eq!(
17560            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17561            DepError::FonteCaminhoShellBackground {
17562                nome: "caixa-teia".to_string(),
17563                caminho: "../caixa-teia&".to_string(),
17564            },
17565        );
17566    }
17567
17568    #[test]
17569    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17570        assert_eq!(
17571            DepError::fonte_caminho_shell_command_substitution(
17572                "caixa-teia",
17573                "../caixa-teia`whoami`",
17574            ),
17575            DepError::FonteCaminhoShellCommandSubstitution {
17576                nome: "caixa-teia".to_string(),
17577                caminho: "../caixa-teia`whoami`".to_string(),
17578            },
17579        );
17580    }
17581
17582    #[test]
17583    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17584        assert_eq!(
17585            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17586            DepError::FonteCaminhoTrailingSlash {
17587                nome: "caixa-teia".to_string(),
17588                caminho: "../caixa-teia/".to_string(),
17589            },
17590        );
17591    }
17592
17593    #[test]
17594    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17595        // Cross-axis pin: sweep the two constructor input axes
17596        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17597        // pair against every generated arm in the
17598        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17599        // / trim / truncate / re-order on the two-field
17600        // `{ nome, caminho }` construction — or a silent field swap
17601        // between the two axes at codegen time — surfaces here rather
17602        // than at a downstream diagnostic-shape mismatch. Peer of the
17603        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17604        // to_string` cross-axis routing pin on the peer
17605        // `SupervisorError` envelope, extended here onto the
17606        // `DepError` `{ nome: String, caminho: String }` envelope so
17607        // every substrate-primitive ctor family in caixa-core
17608        // guarantees each `&str`-field construction routes the
17609        // caller's `&str` verbatim through `.to_string()`.
17610        let nome = "sibling-teia";
17611        let caminho = "../workspace/sibling";
17612        let cases: [(DepError, DepError); 11] = [
17613            (
17614                DepError::fonte_caminho_absolute(nome, caminho),
17615                DepError::FonteCaminhoAbsolute {
17616                    nome: nome.to_string(),
17617                    caminho: caminho.to_string(),
17618                },
17619            ),
17620            (
17621                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17622                DepError::FonteCaminhoTildeExpansion {
17623                    nome: nome.to_string(),
17624                    caminho: caminho.to_string(),
17625                },
17626            ),
17627            (
17628                DepError::fonte_caminho_var_expansion(nome, caminho),
17629                DepError::FonteCaminhoVarExpansion {
17630                    nome: nome.to_string(),
17631                    caminho: caminho.to_string(),
17632                },
17633            ),
17634            (
17635                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17636                DepError::FonteCaminhoLeadingWhitespace {
17637                    nome: nome.to_string(),
17638                    caminho: caminho.to_string(),
17639                },
17640            ),
17641            (
17642                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17643                DepError::FonteCaminhoLeadingHyphen {
17644                    nome: nome.to_string(),
17645                    caminho: caminho.to_string(),
17646                },
17647            ),
17648            (
17649                DepError::fonte_caminho_backslash(nome, caminho),
17650                DepError::FonteCaminhoBackslash {
17651                    nome: nome.to_string(),
17652                    caminho: caminho.to_string(),
17653                },
17654            ),
17655            (
17656                DepError::fonte_caminho_shell_pipe(nome, caminho),
17657                DepError::FonteCaminhoShellPipe {
17658                    nome: nome.to_string(),
17659                    caminho: caminho.to_string(),
17660                },
17661            ),
17662            (
17663                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17664                DepError::FonteCaminhoShellSemicolon {
17665                    nome: nome.to_string(),
17666                    caminho: caminho.to_string(),
17667                },
17668            ),
17669            (
17670                DepError::fonte_caminho_shell_background(nome, caminho),
17671                DepError::FonteCaminhoShellBackground {
17672                    nome: nome.to_string(),
17673                    caminho: caminho.to_string(),
17674                },
17675            ),
17676            (
17677                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17678                DepError::FonteCaminhoShellCommandSubstitution {
17679                    nome: nome.to_string(),
17680                    caminho: caminho.to_string(),
17681                },
17682            ),
17683            (
17684                DepError::fonte_caminho_trailing_slash(nome, caminho),
17685                DepError::FonteCaminhoTrailingSlash {
17686                    nome: nome.to_string(),
17687                    caminho: caminho.to_string(),
17688                },
17689            ),
17690        ];
17691        for (via_ctor, via_struct_literal) in cases {
17692            assert_eq!(
17693                via_ctor, via_struct_literal,
17694                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17695                 through `.to_string()` in declared field order — a field-swap or \
17696                 silent-conversion regression surfaces here rather than at a \
17697                 downstream diagnostic-shape mismatch",
17698            );
17699        }
17700    }
17701
17702    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17703    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17704    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17705    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17706    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17707
17708    #[test]
17709    fn versao_empty_ctor_matches_struct_literal_wrap() {
17710        assert_eq!(
17711            DepError::versao_empty("caixa-teia"),
17712            DepError::VersaoEmpty {
17713                nome: "caixa-teia".to_string(),
17714            },
17715        );
17716    }
17717
17718    #[test]
17719    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17720        assert_eq!(
17721            DepError::fonte_repo_empty("caixa-teia"),
17722            DepError::FonteRepoEmpty {
17723                nome: "caixa-teia".to_string(),
17724            },
17725        );
17726    }
17727
17728    #[test]
17729    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17730        assert_eq!(
17731            DepError::fonte_pin_missing("caixa-teia"),
17732            DepError::FontePinMissing {
17733                nome: "caixa-teia".to_string(),
17734            },
17735        );
17736    }
17737
17738    #[test]
17739    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17740        assert_eq!(
17741            DepError::fonte_caminho_empty("caixa-teia"),
17742            DepError::FonteCaminhoEmpty {
17743                nome: "caixa-teia".to_string(),
17744            },
17745        );
17746    }
17747
17748    #[test]
17749    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17750        assert_eq!(
17751            DepError::caracteristica_empty("caixa-teia"),
17752            DepError::CaracteristicaEmpty {
17753                nome: "caixa-teia".to_string(),
17754            },
17755        );
17756    }
17757
17758    #[test]
17759    fn dep_nome_only_ctors_route_nome_through_to_string() {
17760        // Cross-axis routing pin: sweep the single constructor input
17761        // axis (`nome: &str`) through a non-default fixture against
17762        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17763        // any wrapper-side lowercase / trim / truncate at codegen time
17764        // — or a silent field re-name away from the canonical `nome`
17765        // axis on any one variant — surfaces here rather than at a
17766        // downstream diagnostic-shape mismatch. Peer of the sibling
17767        // `fonte_caminho_ctors_route_nome_and_caminho_through_
17768        // to_string` cross-axis routing pin on the same envelope's
17769        // two-slot family (f85f145) and of the peer
17770        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17771        // pin on the `SupervisorError` single-slot family (db09650).
17772        let nome = "sibling-teia";
17773        let cases: [(DepError, DepError); 5] = [
17774            (
17775                DepError::versao_empty(nome),
17776                DepError::VersaoEmpty {
17777                    nome: nome.to_string(),
17778                },
17779            ),
17780            (
17781                DepError::fonte_repo_empty(nome),
17782                DepError::FonteRepoEmpty {
17783                    nome: nome.to_string(),
17784                },
17785            ),
17786            (
17787                DepError::fonte_pin_missing(nome),
17788                DepError::FontePinMissing {
17789                    nome: nome.to_string(),
17790                },
17791            ),
17792            (
17793                DepError::fonte_caminho_empty(nome),
17794                DepError::FonteCaminhoEmpty {
17795                    nome: nome.to_string(),
17796                },
17797            ),
17798            (
17799                DepError::caracteristica_empty(nome),
17800                DepError::CaracteristicaEmpty {
17801                    nome: nome.to_string(),
17802                },
17803            ),
17804        ];
17805        for (via_ctor, via_struct_literal) in cases {
17806            assert_eq!(
17807                via_ctor, via_struct_literal,
17808                "dep_nome_only_ctors!-generated ctor must route `nome` \
17809                 through `.to_string()` onto the canonical `nome` field \
17810                 — a field-rename or silent-conversion regression surfaces \
17811                 here rather than at a downstream diagnostic-shape mismatch",
17812            );
17813        }
17814    }
17815
17816    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17817    //    &'static str }` two-slot envelope on `DepError`, strict
17818    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17819    //    same envelope's `{ nome: String }` one-slot shape and of the
17820    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
17821    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17822
17823    #[test]
17824    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17825        assert_eq!(
17826            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17827            DepError::DuplicateNome {
17828                nome: "caixa-teia".to_string(),
17829                list: crate::render::DEP_AUTHOR_KEY_DEPS,
17830            },
17831            "generated duplicate_nome ctor must produce byte-equal \
17832             `DepError::DuplicateNome` to the pre-lift struct-literal \
17833             wrap on the same scalar fixtures",
17834        );
17835    }
17836
17837    #[test]
17838    fn dep_is_self_ctor_matches_struct_literal_wrap() {
17839        assert_eq!(
17840            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17841            DepError::DepIsSelf {
17842                nome: "orquestra".to_string(),
17843                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17844            },
17845            "generated dep_is_self ctor must produce byte-equal \
17846             `DepError::DepIsSelf` to the pre-lift struct-literal \
17847             wrap on the same scalar fixtures",
17848        );
17849    }
17850
17851    #[test]
17852    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17853        // Cross-axis routing pin: sweep the two constructor input axes
17854        // (`nome: &str`, `list: &'static str`) through non-default
17855        // fixtures against every generated arm in the
17856        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17857        // lowercase / trim / truncate at codegen time — or a silent
17858        // field re-name away from the canonical `nome` / `list` axes
17859        // on any one variant, or a `list` axis silently rerouted
17860        // through `.to_string()` instead of passed as `&'static str`
17861        // verbatim — surfaces here rather than at a downstream
17862        // diagnostic-shape mismatch. Peer of the sibling
17863        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17864        // (792aa92) on the same envelope's one-slot family, and of the
17865        // peer
17866        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17867        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17868        // two-slot `{ caixa: String, reason: String }` shape.
17869        let nome = "sibling-teia";
17870        let cases: [(DepError, DepError); 4] = [
17871            (
17872                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17873                DepError::DuplicateNome {
17874                    nome: nome.to_string(),
17875                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17876                },
17877            ),
17878            (
17879                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17880                DepError::DuplicateNome {
17881                    nome: nome.to_string(),
17882                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17883                },
17884            ),
17885            (
17886                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17887                DepError::DepIsSelf {
17888                    nome: nome.to_string(),
17889                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
17890                },
17891            ),
17892            (
17893                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17894                DepError::DepIsSelf {
17895                    nome: nome.to_string(),
17896                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17897                },
17898            ),
17899        ];
17900        for (via_ctor, via_struct_literal) in cases {
17901            assert_eq!(
17902                via_ctor, via_struct_literal,
17903                "dep_nome_list_ctors!-generated ctor must route `nome` \
17904                 through `.to_string()` onto the canonical `nome` field \
17905                 and pass `list` verbatim onto the canonical `&'static str` \
17906                 `list` field — a field-rename, silent-conversion, or \
17907                 axis-swap regression surfaces here rather than at a \
17908                 downstream diagnostic-shape mismatch",
17909            );
17910        }
17911    }
17912
17913    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17914    //    value: String, reason: String }` four-slot envelope on
17915    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17916    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17917    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17918    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
17919    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
17920    //    envelope. Single-variant lift closing the last open-coded ctor
17921    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
17922
17923    #[test]
17924    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17925        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17926        // ctor: sweep both wire-up-shape arms (the refname-pin arm
17927        // routing `":tag"` / `":branch"` value through
17928        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17929        // routing `":rev"` through [`crate::render::is_git_oid`]) and
17930        // assert byte-equal `PartialEq` against the pre-lift
17931        // struct-literal, so any wrapper-side field-rename /
17932        // silent-conversion regression surfaces here rather than at a
17933        // downstream diagnostic-shape mismatch. Peer of the sibling
17934        // per-envelope byte-equal ctor pins
17935        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17936        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17937        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17938        assert_eq!(
17939            DepError::fonte_pin_shape(
17940                "caixa-teia",
17941                ":tag",
17942                "v0.1.0 ",
17943                "trailing whitespace".to_string(),
17944            ),
17945            DepError::FontePinShape {
17946                nome: "caixa-teia".to_string(),
17947                pin: ":tag".to_string(),
17948                value: "v0.1.0 ".to_string(),
17949                reason: "trailing whitespace".to_string(),
17950            },
17951            "fonte_pin_shape ctor must produce byte-equal \
17952             `DepError::FontePinShape` to the pre-lift struct-literal \
17953             wrap on a refname-pin (`:tag` / `:branch`) fixture",
17954        );
17955        assert_eq!(
17956            DepError::fonte_pin_shape(
17957                "caixa-teia",
17958                ":rev",
17959                "DEADBEEF",
17960                "abbreviated OID rejected".to_string(),
17961            ),
17962            DepError::FontePinShape {
17963                nome: "caixa-teia".to_string(),
17964                pin: ":rev".to_string(),
17965                value: "DEADBEEF".to_string(),
17966                reason: "abbreviated OID rejected".to_string(),
17967            },
17968            "fonte_pin_shape ctor must produce byte-equal \
17969             `DepError::FontePinShape` to the pre-lift struct-literal \
17970             wrap on a hex-OID-pin (`:rev`) fixture",
17971        );
17972    }
17973
17974    #[test]
17975    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17976        // Cross-axis routing pin: sweep every one of the four
17977        // constructor input axes (`nome: &str`, `pin: &str`,
17978        // `value: &str`, `reason: String`) through non-default
17979        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17980        // any wrapper-side lowercase / trim / truncate at codegen time
17981        // — or a silent field re-name / axis-swap on any one of the
17982        // four fields, or a `reason` axis silently routed through
17983        // `.to_string()` instead of forwarded owned — surfaces here
17984        // rather than at a downstream diagnostic-shape mismatch. Peer
17985        // of the sibling
17986        // `dep_nome_only_ctors_route_nome_through_to_string` pin
17987        // (792aa92) and
17988        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17989        // pin (6f5e0cd) on the same envelope's one- and two-slot
17990        // families. Distinct-per-axis fixtures rule out any two-axis
17991        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17992        // etc.) that would still pass a same-fixture-per-axis pin.
17993        let nome = "sibling-teia";
17994        let pin = ":branch";
17995        let value = "feature/bar";
17996        let reason = "embedded space".to_string();
17997        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17998        let via_struct_literal = DepError::FontePinShape {
17999            nome: nome.to_string(),
18000            pin: pin.to_string(),
18001            value: value.to_string(),
18002            reason: reason.clone(),
18003        };
18004        assert_eq!(
18005            via_ctor, via_struct_literal,
18006            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18007             through `.to_string()` onto their canonical fields and \
18008             forward `reason` owned onto the canonical `reason` field \
18009             — a field-rename, silent-conversion, or axis-swap \
18010             regression surfaces here rather than at a downstream \
18011             diagnostic-shape mismatch",
18012        );
18013        let DepError::FontePinShape {
18014            nome: n,
18015            pin: p,
18016            value: v,
18017            reason: r,
18018        } = via_ctor
18019        else {
18020            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18021        };
18022        assert_eq!(n, nome);
18023        assert_eq!(p, pin);
18024        assert_eq!(v, value);
18025        assert_eq!(r, reason);
18026    }
18027
18028    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18029    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18030    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18031    //    the same envelope's `{ nome: String, caminho: String }` two-slot
18032    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18033    //    same envelope's `{ nome: String }` one-slot shape.
18034
18035    #[test]
18036    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18037        assert_eq!(
18038            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18039            DepError::FonteCaminhoControlChar {
18040                nome: "caixa-teia".to_string(),
18041                caminho: "../caixa-teia\x00foo".to_string(),
18042                byte: 0x00,
18043            },
18044        );
18045    }
18046
18047    #[test]
18048    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18049        assert_eq!(
18050            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18051            DepError::FonteCaminhoShellRedirection {
18052                nome: "caixa-teia".to_string(),
18053                caminho: "../caixa-teia>log".to_string(),
18054                byte: b'>',
18055            },
18056        );
18057    }
18058
18059    #[test]
18060    #[allow(
18061        clippy::too_many_lines,
18062        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18063                  byte-classification arm on the {nome,caminho,byte} envelope; \
18064                  the linear per-variant repetition is exactly what the sweep \
18065                  is pinning — a helper macro would hide the shape the fold is \
18066                  keying on"
18067    )]
18068    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18069        // Cross-axis routing pin: sweep the three constructor input axes
18070        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18071        // non-default fixture triple against every generated arm in the
18072        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18073        // lowercase / trim / truncate on the two `&str` axes — a silent
18074        // field swap between `nome` and `caminho`, or a silent
18075        // re-classification of the offending byte — surfaces here rather
18076        // than at a downstream diagnostic-shape mismatch. Peer of the
18077        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18078        // to_string` cross-axis routing pin on the same envelope's
18079        // two-slot family (f85f145) and of the sibling
18080        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18081        // same envelope's one-slot family (792aa92), extended here onto
18082        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18083        // envelope so every substrate-primitive ctor family in
18084        // caixa-core's `DepError` envelope guarantees each field routes
18085        // the caller's value verbatim through `.to_string()` (or byte-
18086        // identity for `byte: u8`) in declared field order.
18087        let nome = "sibling-teia";
18088        let caminho = "../workspace/sibling";
18089        let byte = 0x2A_u8;
18090        let cases: [(DepError, DepError); 12] = [
18091            (
18092                DepError::fonte_caminho_control_char(nome, caminho, byte),
18093                DepError::FonteCaminhoControlChar {
18094                    nome: nome.to_string(),
18095                    caminho: caminho.to_string(),
18096                    byte,
18097                },
18098            ),
18099            (
18100                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18101                DepError::FonteCaminhoShellRedirection {
18102                    nome: nome.to_string(),
18103                    caminho: caminho.to_string(),
18104                    byte,
18105                },
18106            ),
18107            (
18108                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18109                DepError::FonteCaminhoShellGlob {
18110                    nome: nome.to_string(),
18111                    caminho: caminho.to_string(),
18112                    byte,
18113                },
18114            ),
18115            (
18116                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18117                DepError::FonteCaminhoShellSubshellGrouping {
18118                    nome: nome.to_string(),
18119                    caminho: caminho.to_string(),
18120                    byte,
18121                },
18122            ),
18123            (
18124                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18125                DepError::FonteCaminhoShellBraceExpansion {
18126                    nome: nome.to_string(),
18127                    caminho: caminho.to_string(),
18128                    byte,
18129                },
18130            ),
18131            (
18132                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18133                DepError::FonteCaminhoShellBracketExpansion {
18134                    nome: nome.to_string(),
18135                    caminho: caminho.to_string(),
18136                    byte,
18137                },
18138            ),
18139            (
18140                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18141                DepError::FonteCaminhoShellQuoteGrouping {
18142                    nome: nome.to_string(),
18143                    caminho: caminho.to_string(),
18144                    byte,
18145                },
18146            ),
18147            (
18148                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18149                DepError::FonteCaminhoShellComment {
18150                    nome: nome.to_string(),
18151                    caminho: caminho.to_string(),
18152                    byte,
18153                },
18154            ),
18155            (
18156                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18157                DepError::FonteCaminhoUrlPercentEncoding {
18158                    nome: nome.to_string(),
18159                    caminho: caminho.to_string(),
18160                    byte,
18161                },
18162            ),
18163            (
18164                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18165                DepError::FonteCaminhoShellVariableExpansion {
18166                    nome: nome.to_string(),
18167                    caminho: caminho.to_string(),
18168                    byte,
18169                },
18170            ),
18171            (
18172                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18173                DepError::FonteCaminhoShellHistoryExpansion {
18174                    nome: nome.to_string(),
18175                    caminho: caminho.to_string(),
18176                    byte,
18177                },
18178            ),
18179            (
18180                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18181                DepError::FonteCaminhoShellHistorySubstitution {
18182                    nome: nome.to_string(),
18183                    caminho: caminho.to_string(),
18184                    byte,
18185                },
18186            ),
18187        ];
18188        for (via_ctor, via_struct_literal) in cases {
18189            assert_eq!(
18190                via_ctor, via_struct_literal,
18191                "fonte_caminho_byte_ctors!-generated ctor must route \
18192                 (nome, caminho, byte) through `.to_string()` / byte-\
18193                 identity in declared field order — a field-swap or \
18194                 silent-conversion regression surfaces here rather than \
18195                 at a downstream diagnostic-shape mismatch",
18196            );
18197        }
18198    }
18199
18200    #[test]
18201    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18202        // Fail-before-pass-after byte-parity pin on the lifted
18203        // `impl AsRef<str> for DepList` — asserts the standard-
18204        // library trait impl and the substrate-primitive
18205        // [`super::DepList::as_str`] `pub const fn` accessor resolve
18206        // to the same `&str` per instance across the two-arm closed
18207        // set, so any future silent detour that routes the impl
18208        // through a divergent projection (a per-arm inline
18209        // `match self { DepList::Prod => ":deps", … }` re-inlining
18210        // that opens a compile-time link to the un-lifted arm-literal,
18211        // a swap onto a second projection axis) trips at caixa-core
18212        // test time under `PartialEq` rather than at a downstream
18213        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18214        // every one of the two arms [`super::DepList::ALL`] carries
18215        // so no arm's projection is covered only by the sibling
18216        // `Display` path. Peer of the sibling
18217        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18218        // (1723611) on the top-level dialect-classification closed-
18219        // set typed enum, and the peer
18220        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18221        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18222        // typed enum — the pins together close the substrate
18223        // primitive's `AsRef<str>` projection axis onto the seventh
18224        // (and last unlifted) closed-set typed enum on the caixa
18225        // surface.
18226        for &list in super::DepList::ALL {
18227            assert_eq!(
18228                <super::DepList as AsRef<str>>::as_ref(&list),
18229                list.as_str(),
18230                "AsRef<str> impl on DepList::{list:?} must byte-equal \
18231                 DepList::as_str on the same instance — divergence \
18232                 signals a silent detour off the substrate-primitive \
18233                 accessor"
18234            );
18235        }
18236    }
18237
18238    #[test]
18239    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18240        // Fail-before-pass-after byte-parity pin on the three-path
18241        // convergence discipline the [`super::DepList`] two-list
18242        // dep-graph closed-set typed enum now carries on the `&str`-
18243        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18244        // newly lifted impl), `format!("{v}")` (the pre-existing
18245        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18246        // primitive `pub const fn` accessor both trait impls delegate
18247        // through) must resolve to the same byte-string on every
18248        // instance across the two-arm closed set. Refuses any future
18249        // divergence between the two trait impls (a stray
18250        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18251        // rather than delegating through the shared accessor; a
18252        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18253        // literal cascade) that would silently split the two
18254        // projection paths of the same closed-set typed enum. Mirrors
18255        // the sibling three-path-convergence discipline the peer
18256        // [`crate::CaixaDialeto`] typed enum carries
18257        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18258        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18259        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18260        // d8136db), the peer [`crate::CaixaKind`] triple
18261        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18262        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18263        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18264        // 16d5c7e).
18265        for &list in super::DepList::ALL {
18266            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18267            let via_display: String = format!("{list}");
18268            let via_accessor: &str = list.as_str();
18269            assert_eq!(via_as_ref, via_accessor);
18270            assert_eq!(via_display, via_accessor);
18271            assert_eq!(via_as_ref, via_display.as_str());
18272        }
18273    }
18274
18275    #[test]
18276    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18277        // Fail-before-pass-after byte-parity pin on the newly lifted
18278        // `impl TryFrom<&str> for DepList` — asserts the standard-
18279        // library trait impl and the substrate-primitive
18280        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18281        // to the same two-arm accept-set across every arm the
18282        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18283        // the sibling
18284        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18285        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18286        // and the 12 other substrate-wide trait-idiomatic reverse-
18287        // projection routes-through pins — closes the campaign's
18288        // completeness gap on the two-list dep-graph closed-set enum.
18289        for &list in super::DepList::ALL {
18290            let wire = list.as_str();
18291            assert_eq!(
18292                <super::DepList as TryFrom<&str>>::try_from(wire),
18293                Ok(list),
18294                "TryFrom<&str> impl on DepList must round-trip \
18295                 DepList::{list:?}.as_str() = {wire:?} back to \
18296                 Ok(DepList::{list:?}) — divergence from \
18297                 DepList::from_wire signals a silent detour off the \
18298                 substrate-primitive accessor"
18299            );
18300            assert_eq!(
18301                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18302                super::DepList::from_wire(wire),
18303                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18304                 DepList::from_wire on the same input"
18305            );
18306        }
18307    }
18308
18309    #[test]
18310    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18311        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18312        // sweeps candidate byte-strings outside the two-arm accept-set
18313        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18314        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18315        // future accidental widening of the trait impl's accept-set (a
18316        // stray case-fold path, a silent inclusion of a rebrand alias
18317        // like `":packages"`, an English rebrand `":dev-deps"` in
18318        // reverse arm-order that would silently swap the two arms) trips
18319        // at caixa-core test time. Peer of the sibling
18320        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18321        // (5b828ed) rejection witness.
18322        let rejected: &[&str] = &[
18323            "",
18324            " ",
18325            "\t",
18326            "\n",
18327            ":deps ",
18328            " :deps",
18329            ":DEPS",
18330            ":Deps",
18331            ":Deps-Dev",
18332            ":deps_dev",
18333            ":deps-development",
18334            ":dev-deps",
18335            ":packages",
18336            ":packages-dev",
18337            "deps",
18338            "deps-dev",
18339            "Prod",
18340            "Dev",
18341            "prod",
18342            "dev",
18343            "\":deps\"",
18344            "\":deps-dev\"",
18345            ":deps\n",
18346            ":deps-dev\n",
18347        ];
18348        for &input in rejected {
18349            assert_eq!(
18350                <super::DepList as TryFrom<&str>>::try_from(input),
18351                Err(()),
18352                "TryFrom<&str> impl on DepList must reject unknown \
18353                 byte-string {input:?} — divergence from \
18354                 DepList::from_wire on the same input signals a silent \
18355                 accept-set widening past the two lifted \
18356                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18357            );
18358            assert_eq!(
18359                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18360                super::DepList::from_wire(input),
18361                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18362                 DepList::from_wire on the same input — divergence signals \
18363                 the two reverse-projection paths have drifted onto \
18364                 different accept-sets"
18365            );
18366        }
18367    }
18368
18369    #[test]
18370    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18371        // Fail-before-pass-after byte-parity pin on the newly lifted
18372        // `impl From<DepList> for &'static str` — asserts the standard-
18373        // library trait impl and the substrate-primitive
18374        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18375        // the same two-arm emit-set across every arm the exhaustive
18376        // [`super::DepList::ALL`] slice enumerates. Materializes the
18377        // `<&'static str as From<DepList>>::from` output in a
18378        // `const`-shape binding to make the `'static` lifetime promise
18379        // a build-time invariant — a future accidental downgrade of
18380        // either arm to a non-`&'static str` (a `String::leak()`-
18381        // produced return, a `Box::leak`-cast) trips at caixa-core
18382        // build time rather than at a downstream `'static`-bound
18383        // consumer. Peer of the sibling
18384        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18385        // (523157d) and the 13 other substrate-wide forward-projection
18386        // routes-through pins.
18387        const PROD: &str = super::DepList::Prod.as_str();
18388        const DEV: &str = super::DepList::Dev.as_str();
18389        for &list in super::DepList::ALL {
18390            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18391            let via_method: &'static str = list.as_str();
18392            assert_eq!(
18393                via_trait, via_method,
18394                "From<DepList> for &'static str impl must round-trip \
18395                 DepList::{list:?} to the same lifted \
18396                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18397                 DepList::as_str returns — divergence signals a silent \
18398                 detour off the substrate-primitive accessor"
18399            );
18400            let via_into: &'static str = list.into();
18401            assert_eq!(
18402                via_into, via_method,
18403                "Into<&'static str>::into on DepList::{list:?} must \
18404                 byte-equal DepList::as_str on the same input — the \
18405                 blanket-derived Into shape must resolve to the same \
18406                 as_str dispatch as the explicit From impl"
18407            );
18408        }
18409        assert_eq!(
18410            [PROD, DEV],
18411            [
18412                crate::render::DEP_AUTHOR_KEY_DEPS,
18413                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18414            ],
18415            "const-context DepList::as_str must resolve to the two lifted \
18416             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18417             of either arm to a non-const or non-static byte-string breaks \
18418             the `&'static str`-lifetime promise the paired \
18419             From<DepList> for &'static str impl carries by construction"
18420        );
18421    }
18422
18423    #[test]
18424    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18425        // Cross-axis partition pin: the paired trait-idiomatic
18426        // `From<DepList> for &'static str` forward projection and the
18427        // method-named [`super::DepList::as_str`] forward projection
18428        // must resolve identically on every arm, locking the two paths
18429        // together so any future detour trips at caixa-core test time.
18430        // Then a round-trip witness: every arm's forward `From` output
18431        // re-parses through the paired trait-idiomatic reverse
18432        // `TryFrom<&str>` back to the original variant, closing the
18433        // two-way `DepList ↔ &'static str` round-trip on the trait-
18434        // idiomatic axis pair, mirroring the pre-existing method-named
18435        // `as_str` + `from_wire` round-trip. Peer of the sibling
18436        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18437        // (523157d).
18438        for &list in super::DepList::ALL {
18439            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18440            let via_method: &'static str = list.as_str();
18441            assert_eq!(
18442                via_trait, via_method,
18443                "From<DepList> for &'static str and DepList::as_str must \
18444                 resolve identically on DepList::{list:?} — divergence \
18445                 signals the two forward-projection paths have drifted \
18446                 onto different emit-sets"
18447            );
18448        }
18449        for &list in super::DepList::ALL {
18450            let emitted: &'static str = list.into();
18451            let re_parsed: Result<super::DepList, ()> =
18452                <super::DepList as TryFrom<&str>>::try_from(emitted);
18453            assert_eq!(
18454                re_parsed,
18455                Ok(list),
18456                "trait-idiomatic axis pair must round-trip \
18457                 DepList::{list:?} through `.into::<&'static str>()` and \
18458                 back through `TryFrom<&str>` — a break signals the \
18459                 forward-emit and reverse-parse axes have drifted onto \
18460                 different vocabularies"
18461            );
18462        }
18463    }
18464
18465    #[test]
18466    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18467        // Fail-before-pass-after byte-parity pin on the newly lifted
18468        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18469        // input standard-library trait impl and the substrate-primitive
18470        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18471        // the same two-arm emit-set across every arm the exhaustive
18472        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18473        // does not auto-derive the borrowed-input sibling from a paired
18474        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18475        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18476        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18477        // shape over [`super::DepList::ALL`] (whose iterator yields
18478        // `&DepList`, not `DepList`) reaches through this impl and no
18479        // other — the paired owned-input [`From<DepList>`] impl requires
18480        // an explicit `.copied()` / dereference before the trait fires.
18481        // Materializes the `<&'static str as From<&DepList>>::from`
18482        // output in a `const`-shape binding to make the `'static`
18483        // lifetime promise a build-time invariant.
18484        const PROD: &str = super::DepList::Prod.as_str();
18485        const DEV: &str = super::DepList::Dev.as_str();
18486        for list in super::DepList::ALL {
18487            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18488            let via_method: &'static str = list.as_str();
18489            assert_eq!(
18490                via_trait, via_method,
18491                "From<&DepList> for &'static str impl must round-trip \
18492                 &DepList::{list:?} to the same lifted \
18493                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18494                 DepList::as_str returns — divergence signals a silent \
18495                 detour off the substrate-primitive accessor"
18496            );
18497            let via_into: &'static str = list.into();
18498            assert_eq!(
18499                via_into, via_method,
18500                "Into<&'static str>::into on &DepList::{list:?} must \
18501                 byte-equal DepList::as_str on the same input — the \
18502                 blanket-derived Into shape must resolve to the same \
18503                 as_str dispatch as the explicit From impl"
18504            );
18505        }
18506        assert_eq!(
18507            [PROD, DEV],
18508            [
18509                crate::render::DEP_AUTHOR_KEY_DEPS,
18510                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18511            ],
18512            "const-context DepList::as_str must resolve to the two lifted \
18513             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18514             From<&DepList> for &'static str impl inherits its `'static` \
18515             lifetime promise from the same accessor the owned-input \
18516             sibling routes through"
18517        );
18518    }
18519
18520    #[test]
18521    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18522        // Cross-axis partition pin: the paired trait-idiomatic
18523        // owned-input `From<DepList> for &'static str` (523157d
18524        // campaign-shape) and borrowed-input `From<&DepList> for
18525        // &'static str` (this lift) forward projections must resolve
18526        // identically on every arm, locking the two input-shape paths
18527        // together so any future detour trips at caixa-core test time.
18528        // Then a witness that a `.iter().map(Into::into)` pipe over
18529        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18530        // materializes the two-arm accept-set through the borrowed-
18531        // input axis alone — the exact shape a future M4 admission-
18532        // webhook rejection body composer, a future substrate-wide
18533        // per-arm diagnostic column, or a
18534        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18535        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18536        // through — closing the two-way owned/borrowed input-shape
18537        // symmetry on the forward-projection trait-idiomatic axis.
18538        for &list in super::DepList::ALL {
18539            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18540            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18541            assert_eq!(
18542                owned, borrowed,
18543                "From<DepList> and From<&DepList> for &'static str must \
18544                 resolve identically on DepList::{list:?} — divergence \
18545                 signals the owned-input and borrowed-input forward-\
18546                 projection paths have drifted onto different emit-sets"
18547            );
18548        }
18549        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18550        let via_method: Vec<&'static str> =
18551            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18552        assert_eq!(
18553            via_iter, via_method,
18554            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18555             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18556             input `From<&DepList> for &'static str` axis is what makes \
18557             the `.iter().map(Into::into)` shape route through the \
18558             substrate-primitive `DepList::as_str` accessor rather than \
18559             through a per-call-site `.copied()` / dereference detour"
18560        );
18561    }
18562
18563    #[test]
18564    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18565        // Fail-before-pass-after byte-parity pin on the newly lifted
18566        // `impl From<DepList> for String` — asserts the owned-`String`
18567        // -returning standard-library trait impl and the substrate-
18568        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18569        // resolve to the same two-arm emit-set across every arm the
18570        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18571        // standard library does not carry a blanket
18572        // `impl<T: AsRef<str>> From<T> for String` (nor an
18573        // `impl<T: fmt::Display> From<T> for String`), so the
18574        // owned-`String` forward-projection axis is a distinct trait-
18575        // idiomatic surface that a `let key: String = list.into();`-
18576        // shaped call site reaches through this impl and no other — the
18577        // paired sibling `From<DepList> for &'static str` impl forces
18578        // every owned-`String` call site through an explicit
18579        // `.to_owned()` / `String::from` restatement. Peer of the
18580        // first-mover
18581        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18582        // (7baa18a), the second-peer
18583        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18584        // (7851725), the third-peer
18585        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18586        // (231a18c), and the fourth-peer
18587        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18588        // (88942cd) — extends the trait-idiomatic owned-`String`
18589        // forward-projection axis onto the fifth closed-set fieldless
18590        // typed enum on the caixa surface (the two-list dep-graph axis).
18591        for &variant in super::DepList::ALL {
18592            let via_trait: String = <String as From<super::DepList>>::from(variant);
18593            let via_method: &'static str = variant.as_str();
18594            assert_eq!(
18595                via_trait.as_str(),
18596                via_method,
18597                "From<DepList> for String impl must round-trip \
18598                 DepList::{variant:?} to the same lifted \
18599                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18600                 DepList::as_str returns — divergence signals a silent \
18601                 detour off the substrate-primitive accessor"
18602            );
18603            let via_into: String = variant.into();
18604            assert_eq!(
18605                via_into.as_str(),
18606                via_method,
18607                "Into<String>::into on DepList::{variant:?} must \
18608                 byte-equal DepList::as_str on the same input — the \
18609                 blanket-derived Into shape must resolve to the same \
18610                 as_str dispatch as the explicit From impl"
18611            );
18612        }
18613    }
18614
18615    #[test]
18616    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18617        // Cross-axis partition pin: the paired trait-idiomatic
18618        // owned-`String` `From<DepList> for String` (this lift) and
18619        // owned-`&'static str` `From<DepList> for &'static str`
18620        // (523157d campaign-shape) forward projections must resolve
18621        // identically on every arm, locking the two return-type-shape
18622        // paths together so any future detour trips at caixa-core test
18623        // time. Also byte-parity witness against the sibling
18624        // [`ToString::to_string`] surface routed through
18625        // [`std::fmt::Display`] — the three owned-heap-string paths
18626        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18627        // resolve identically on every arm so a future consumer that
18628        // picks any of the three lands on the same two-arm lifted
18629        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18630        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18631        // Then a `.iter().copied().map(String::from)` pipe witness
18632        // over [`super::DepList::ALL`] that materializes the two-arm
18633        // accept-set through the owned-`String` axis alone — the exact
18634        // shape a future M4 admission-webhook rejection body composer
18635        // or a
18636        // `HashMap::<String, DepList>::from_iter(
18637        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18638        // style owned-key per-list lookup reaches through — closing the
18639        // owned-`String` forward-projection axis's iterator-pipe shape.
18640        // Then a direct round-trip witness through the paired
18641        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18642        // owned-`String`'s [`String::as_str`] borrow that closes the
18643        // two-way `Self → String → Self` round-trip on the trait-
18644        // idiomatic owned-`String` forward + reverse axis pair.
18645        //
18646        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18647        // `From` emit lands on the lowercase Portuguese `as_str`
18648        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18649        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18650        // forcing the round-trip through an intermediate
18651        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18652        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18653        // parse resolve through the same lifted
18654        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18655        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18656        // construction (there is no wire/diagnostic axis split on this
18657        // enum), so the owned-`String` forward axis and the reverse
18658        // axis compose directly — matching the peer
18659        // [`crate::supervisor::RestartStrategy`] /
18660        // [`crate::supervisor::RestartPolicy`] /
18661        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18662        for &list in super::DepList::ALL {
18663            let owned_string: String = <String as From<super::DepList>>::from(list);
18664            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18665            assert_eq!(
18666                owned_string.as_str(),
18667                owned_static,
18668                "From<DepList> for String and From<DepList> for \
18669                 &'static str must resolve identically on \
18670                 DepList::{list:?} — divergence signals the owned-\
18671                 `String` and owned-`&'static str` forward-projection \
18672                 return-type-shape paths have drifted onto different \
18673                 emit-sets"
18674            );
18675            let via_to_string: String = list.to_string();
18676            assert_eq!(
18677                owned_string, via_to_string,
18678                "From<DepList> for String must byte-equal \
18679                 DepList::to_string on DepList::{list:?} — divergence \
18680                 signals the trait-idiomatic owned-`String` forward-\
18681                 projection axis and the ToString-through-Display axis \
18682                 have drifted onto different emit-sets"
18683            );
18684        }
18685        let via_iter: Vec<String> = super::DepList::ALL
18686            .iter()
18687            .copied()
18688            .map(String::from)
18689            .collect();
18690        let via_method: Vec<String> = super::DepList::ALL
18691            .iter()
18692            .map(|l| l.as_str().to_owned())
18693            .collect();
18694        assert_eq!(
18695            via_iter, via_method,
18696            "`.iter().copied().map(String::from)` over DepList::ALL must \
18697             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18698             every arm — the owned-`String` `From<DepList> for String` \
18699             axis is what makes the `String::from` composition route \
18700             through the substrate-primitive `DepList::as_str` accessor \
18701             rather than through a per-call-site `.to_owned()` / \
18702             `String::from(list.as_str())` detour"
18703        );
18704        for &variant in super::DepList::ALL {
18705            let emitted: String = variant.into();
18706            let re_parsed: Result<super::DepList, ()> =
18707                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18708            assert_eq!(
18709                re_parsed,
18710                Ok(variant),
18711                "trait-idiomatic owned-`String` forward-projection + \
18712                 reverse-projection axis pair must round-trip \
18713                 DepList::{variant:?} through `.into::<String>()` and \
18714                 back through `TryFrom<&str>` on the owned-`String`'s \
18715                 String::as_str borrow — a break signals the owned-\
18716                 `String` forward-emit and reverse-parse axes have \
18717                 drifted onto different vocabularies (unlike the peer \
18718                 CaixaKind axis pair, DepList's forward emit and \
18719                 reverse parse share the same lifted \
18720                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18721                 round-trip composes directly)"
18722            );
18723        }
18724    }
18725
18726    #[test]
18727    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18728        // Fail-before-pass-after byte-parity pin on the newly lifted
18729        // `impl From<&DepList> for String` — asserts the borrowed-input
18730        // owned-`String`-returning standard-library trait impl and the
18731        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18732        // accessor resolve to the same two-arm emit-set across every
18733        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18734        // Rust's standard library does not carry a blanket
18735        // `impl<T: AsRef<str>> From<&T> for String` (nor an
18736        // `impl<T: fmt::Display> From<&T> for String`), so the
18737        // borrowed-input owned-`String` forward-projection axis is a
18738        // distinct trait-idiomatic surface that a
18739        // `let key: String = (&list).into();`-shaped call site reaches
18740        // through this impl and no other — the paired sibling
18741        // `From<DepList> for String` impl forces every borrowed-input
18742        // call site through an explicit `Copy` deref
18743        // (`String::from(*list)`) or an `.as_str().to_owned()` /
18744        // `.to_string()` detour. Peer of the first-mover
18745        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18746        // (579385f) and the second-peer
18747        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18748        // (8465740) — extends the trait-idiomatic borrowed-input owned-
18749        // `String` forward-projection axis off the M2 OTP-shape sibling
18750        // axis pair onto the first non-M2 closed-set fieldless typed
18751        // enum peer (the two-list dep-graph axis).
18752        for &variant in super::DepList::ALL {
18753            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18754            let via_method: &'static str = variant.as_str();
18755            assert_eq!(
18756                via_trait.as_str(),
18757                via_method,
18758                "From<&DepList> for String impl must round-trip \
18759                 &DepList::{variant:?} to the same lifted \
18760                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18761                 DepList::as_str returns — divergence signals a silent \
18762                 detour off the substrate-primitive accessor"
18763            );
18764            let via_into: String = (&variant).into();
18765            assert_eq!(
18766                via_into.as_str(),
18767                via_method,
18768                "Into<String>::into on &DepList::{variant:?} must \
18769                 byte-equal DepList::as_str on the same input — the \
18770                 blanket-derived Into shape must resolve to the same \
18771                 as_str dispatch as the explicit From impl"
18772            );
18773        }
18774    }
18775
18776    #[test]
18777    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18778        // Cross-axis partition pin: the newly lifted trait-idiomatic
18779        // borrowed-input owned-`String` `From<&DepList> for String`
18780        // (this lift), the paired owned-input owned-`String`
18781        // `From<DepList> for String` (32b0ee8), the paired borrowed-
18782        // input owned-`&'static str` `From<&DepList> for &'static str`
18783        // (64aa742), and the paired owned-input owned-`&'static str`
18784        // `From<DepList> for &'static str` (3455cbf) — every corner of
18785        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18786        // idiomatic projection family — must resolve identically on
18787        // every arm, locking the four return-shape × input-shape paths
18788        // together so any future detour trips at caixa-core test time.
18789        // Also byte-parity witness against the sibling
18790        // [`ToString::to_string`] surface routed through
18791        // [`std::fmt::Display`] and a direct round-trip witness through
18792        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18793        // the owned-`String`'s [`String::as_str`] borrow that closes
18794        // the two-way `&Self → String → Self` round-trip on the trait-
18795        // idiomatic borrowed-input owned-`String` forward + reverse
18796        // axis pair. Peer of the first-mover
18797        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18798        // (579385f) and the second-peer
18799        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18800        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18801        // String}` 2×2 projection corner on the third substrate-wide
18802        // closed-set fieldless typed enum peer (the two-list dep-graph
18803        // axis, first outside the M2 OTP-shape sibling pair).
18804        //
18805        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18806        // `From` emit lands on the lowercase Portuguese `as_str`
18807        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18808        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18809        // forcing the round-trip through an intermediate
18810        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18811        // [`super::DepList::as_str`] emit and
18812        // [`super::DepList::from_wire`] parse resolve through the same
18813        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18814        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18815        // construction (there is no wire/diagnostic axis split on this
18816        // enum), so the borrowed-input owned-`String` forward axis and
18817        // the reverse axis compose directly — matching the peer
18818        // [`crate::supervisor::RestartStrategy`] /
18819        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18820        // `String` axis pairs.
18821        for &list in super::DepList::ALL {
18822            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18823            let owned_string: String = <String as From<super::DepList>>::from(list);
18824            let borrowed_static: &'static str =
18825                <&'static str as From<&super::DepList>>::from(&list);
18826            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18827            assert_eq!(
18828                borrowed_string, owned_string,
18829                "From<&DepList> for String and From<DepList> for String \
18830                 must resolve identically on DepList::{list:?} — \
18831                 divergence signals the borrowed-input and owned-input \
18832                 owned-`String` forward-projection input-shape paths \
18833                 have drifted onto different emit-sets"
18834            );
18835            assert_eq!(
18836                borrowed_string.as_str(),
18837                borrowed_static,
18838                "From<&DepList> for String and From<&DepList> for \
18839                 &'static str must resolve identically on \
18840                 DepList::{list:?} — divergence signals the borrowed-\
18841                 input `&'static str` and owned-`String` return-shape \
18842                 paths have drifted onto different emit-sets"
18843            );
18844            assert_eq!(
18845                borrowed_string.as_str(),
18846                owned_static,
18847                "From<&DepList> for String and From<DepList> for \
18848                 &'static str must resolve identically on \
18849                 DepList::{list:?} — divergence signals a break in the \
18850                 diagonal corner of the {{Self, &Self}} × {{&'static \
18851                 str, String}} 2×2 trait-idiomatic projection family"
18852            );
18853            let via_to_string: String = list.to_string();
18854            assert_eq!(
18855                borrowed_string, via_to_string,
18856                "From<&DepList> for String must byte-equal \
18857                 DepList::to_string on DepList::{list:?} — divergence \
18858                 signals the trait-idiomatic borrowed-input owned-\
18859                 `String` forward-projection axis and the ToString-\
18860                 through-Display axis have drifted onto different \
18861                 emit-sets"
18862            );
18863        }
18864        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18865        let via_method: Vec<String> = super::DepList::ALL
18866            .iter()
18867            .map(|l| l.as_str().to_owned())
18868            .collect();
18869        assert_eq!(
18870            via_iter, via_method,
18871            "`.iter().map(String::from)` over DepList::ALL — a call \
18872             site whose iteration axis holds `&DepList` by construction \
18873             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18874             on every arm — the borrowed-input owned-`String` \
18875             `From<&DepList> for String` axis is what makes the \
18876             `String::from` composition route through the substrate-\
18877             primitive `DepList::as_str` accessor without a spurious \
18878             `Copy` deref (which would only be reachable through the \
18879             owned-input `From<DepList> for String` axis by first \
18880             calling `.copied()` on the iterator)"
18881        );
18882        for &variant in super::DepList::ALL {
18883            let emitted: String = (&variant).into();
18884            let re_parsed: Result<super::DepList, ()> =
18885                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18886            assert_eq!(
18887                re_parsed,
18888                Ok(variant),
18889                "trait-idiomatic borrowed-input owned-`String` \
18890                 forward-projection + reverse-projection axis pair must \
18891                 round-trip &DepList::{variant:?} through \
18892                 `.into::<String>()` on the borrowed-input surface and \
18893                 back through `TryFrom<&str>` on the owned-`String`'s \
18894                 String::as_str borrow — a break signals the \
18895                 borrowed-input owned-`String` forward-emit and \
18896                 reverse-parse axes have drifted onto different \
18897                 vocabularies (unlike the peer CaixaKind axis pair, \
18898                 DepList's forward emit and reverse parse share the \
18899                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18900                 construction, so the round-trip composes directly)"
18901            );
18902        }
18903    }
18904
18905    #[test]
18906    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
18907        // Fail-before-pass-after byte-parity pin on the newly lifted
18908        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
18909        // asserts the standard-library trait impl and the substrate-
18910        // primitive [`super::DepList::as_str`] `pub const fn`
18911        // accessor resolve to the same two-arm emit-set across every
18912        // arm the exhaustive [`super::DepList::ALL`] slice
18913        // enumerates. Rust's standard library does not carry a
18914        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
18915        // (nor an `impl<T: fmt::Display> From<T> for
18916        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
18917        // projection axis is a distinct trait-idiomatic surface that
18918        // a `let key: Cow<'static, str> = list.into();`-shaped call
18919        // site reaches through this impl and no other — the paired
18920        // sibling `From<DepList> for &'static str` and
18921        // `From<DepList> for String` impls force every
18922        // `Cow<'static, str>`-parameterized call site through a
18923        // `Cow::Borrowed(list.as_str())` /
18924        // `Cow::Owned(list.to_string())` composition whose type
18925        // bounds have no compile-time link back to the substrate
18926        // primitive.
18927        //
18928        // Also asserts the projection lands on the zero-alloc
18929        // [`std::borrow::Cow::Borrowed`] arm (not the
18930        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18931        // [`super::DepList::as_str`] accessor's `&'static str`
18932        // return lifetime by construction (each match arm resolves
18933        // to one of the two lifted
18934        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18935        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
18936        // &str` values) makes the borrowed arm the type-correct
18937        // projection with no runtime allocation. Any future silent
18938        // detour that routes the impl through the owned arm trips
18939        // at caixa-core test time under the
18940        // [`std::borrow::Cow::Borrowed`] discriminator witness
18941        // rather than at a downstream `Cow<'static, str>`-bound
18942        // consumer's silent allocation.
18943        //
18944        // First-mover on the outside-M3 substrate-wide tier of the
18945        // substrate-wide trait-idiomatic
18946        // [`std::borrow::Cow<'static, str>`] forward-projection
18947        // campaign — extends the axis off the paired
18948        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
18949        // the paired M2 OTP-shape
18950        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
18951        // and [`crate::supervisor::RestartPolicy`] (0612398 +
18952        // ee577fd), and the paired M3-mesh-shape
18953        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
18954        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
18955        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
18956        // peers onto the first outside-M3 caixa-core peer (the two-
18957        // list dep-graph axis), opening the outside-M3 caixa-core
18958        // tier of the substrate-wide Cow<'static, str> forward-
18959        // projection campaign's owned-input corner.
18960        for &variant in super::DepList::ALL {
18961            let via_trait: std::borrow::Cow<'static, str> =
18962                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18963            let via_method: &'static str = variant.as_str();
18964            assert_eq!(
18965                via_trait.as_ref(),
18966                via_method,
18967                "From<DepList> for Cow<'static, str> impl must \
18968                 round-trip DepList::{variant:?} to the same lifted \
18969                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18970                 DepList::as_str returns — divergence signals a \
18971                 silent detour off the substrate-primitive accessor"
18972            );
18973            assert!(
18974                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
18975                "From<DepList> for Cow<'static, str> impl must land \
18976                 on the zero-alloc Cow::Borrowed arm on \
18977                 DepList::{variant:?} — a Cow::Owned outcome signals \
18978                 the projection has silently allocated where the \
18979                 substrate-primitive DepList::as_str `&'static str` \
18980                 return makes the borrowed arm the type-correct \
18981                 projection"
18982            );
18983            let via_into: std::borrow::Cow<'static, str> = variant.into();
18984            assert_eq!(
18985                via_into.as_ref(),
18986                via_method,
18987                "Into<Cow<'static, str>>::into on DepList::\
18988                 {variant:?} must byte-equal DepList::as_str on the \
18989                 same input — the blanket-derived Into shape must \
18990                 resolve to the same as_str dispatch as the explicit \
18991                 From impl"
18992            );
18993            assert!(
18994                matches!(via_into, std::borrow::Cow::Borrowed(_)),
18995                "Into<Cow<'static, str>>::into on DepList::\
18996                 {variant:?} must land on the zero-alloc \
18997                 Cow::Borrowed arm — the blanket-derived Into shape \
18998                 must resolve to the same Cow::Borrowed dispatch as \
18999                 the explicit From impl"
19000            );
19001        }
19002    }
19003
19004    #[test]
19005    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19006        // Cross-axis partition pin: the newly lifted trait-idiomatic
19007        // `From<DepList> for std::borrow::Cow<'static, str>` (this
19008        // lift), the paired owned-input `From<DepList> for
19009        // &'static str` (3455cbf), and the paired owned-input
19010        // `From<DepList> for String` (32b0ee8) forward projections
19011        // must resolve identically on every arm, locking the three
19012        // return-shape paths together by construction so any future
19013        // detour trips at caixa-core test time. Also byte-parity
19014        // witness against the sibling [`ToString::to_string`]
19015        // surface routed through [`std::fmt::Display`] — every
19016        // owned-heap-string path (the `Cow::Owned` promotion of
19017        // this axis's `.into_owned()`, `From<DepList> for String`,
19018        // and `.to_string()`) resolves to the same two-arm lifted
19019        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19020        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19021        // arm.
19022        //
19023        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19024        // witness over [`super::DepList::ALL`] that materializes the
19025        // two-arm accept-set through the
19026        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19027        // shape a future M4 admission-webhook rejection body's
19028        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19029        // future substrate-wide per-arm diagnostic surface whose
19030        // typing rules out the sibling [`AsRef<str>`] borrowed
19031        // return, or a future per-arm dep-list emitter that binds
19032        // through a [`std::borrow::Cow<'static, str>`] boundary
19033        // reaches through — opening the composable-projection axis
19034        // on the first outside-M3 caixa-core closed-set fieldless
19035        // typed enum peer on the caixa surface. The pipe witness
19036        // also pins the zero-alloc discipline: every element in the
19037        // collected vector satisfies the
19038        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19039        // accidental silent-allocation regression on the pipe's
19040        // iteration axis is a caixa-core-test-time failure.
19041        for &variant in super::DepList::ALL {
19042            let via_cow: std::borrow::Cow<'static, str> =
19043                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19044            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19045            let via_string: String = <String as From<super::DepList>>::from(variant);
19046            assert_eq!(
19047                via_cow.as_ref(),
19048                via_static,
19049                "From<DepList> for Cow<'static, str> and \
19050                 From<DepList> for &'static str must resolve \
19051                 identically on DepList::{variant:?} — divergence \
19052                 signals the Cow<'static, str> and &'static str \
19053                 return-shape paths have drifted onto different \
19054                 emit-sets"
19055            );
19056            assert_eq!(
19057                via_cow.as_ref(),
19058                via_string.as_str(),
19059                "From<DepList> for Cow<'static, str> and \
19060                 From<DepList> for String must resolve identically \
19061                 on DepList::{variant:?} — divergence signals the \
19062                 Cow<'static, str> and String return-shape paths \
19063                 have drifted onto different emit-sets"
19064            );
19065            let via_to_string: String = variant.to_string();
19066            assert_eq!(
19067                via_cow.as_ref(),
19068                via_to_string.as_str(),
19069                "From<DepList> for Cow<'static, str> must byte-equal \
19070                 DepList::to_string on DepList::{variant:?} — \
19071                 divergence signals the trait-idiomatic \
19072                 Cow<'static, str> forward-projection axis and the \
19073                 ToString-through-Display axis have drifted onto \
19074                 different emit-sets"
19075            );
19076        }
19077        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19078            .iter()
19079            .copied()
19080            .map(std::borrow::Cow::from)
19081            .collect();
19082        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19083            .iter()
19084            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19085            .collect();
19086        assert_eq!(
19087            via_iter, via_method,
19088            "`.iter().copied().map(Cow::from)` over DepList::ALL \
19089             must byte-equal `.iter().map(|l| \
19090             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19091             idiomatic `From<DepList> for Cow<'static, str>` axis is \
19092             what makes the `Cow::from` composition route through \
19093             the substrate-primitive `DepList::as_str` accessor with \
19094             the zero-alloc Cow::Borrowed arm by construction, \
19095             rather than a per-call-site `Cow::Owned(list.to_string())` \
19096             allocation"
19097        );
19098        for cow in &via_iter {
19099            assert!(
19100                matches!(cow, std::borrow::Cow::Borrowed(_)),
19101                "every element of the .iter().copied().map(Cow::from) \
19102                 pipe over DepList::ALL must land on the zero-alloc \
19103                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19104                 signals the pipe's iteration axis has silently \
19105                 allocated where the substrate-primitive \
19106                 DepList::as_str `&'static str` return makes the \
19107                 borrowed arm the type-correct projection"
19108            );
19109        }
19110    }
19111
19112    #[test]
19113    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19114        // Fail-before-pass-after byte-parity pin on the newly lifted
19115        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19116        // asserts the borrowed-input standard-library trait impl and
19117        // the substrate-primitive [`super::DepList::as_str`] `pub const
19118        // fn` accessor resolve to the same two-arm emit-set across
19119        // every arm the exhaustive [`super::DepList::ALL`] slice
19120        // enumerates. Rust's standard library does not carry a blanket
19121        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19122        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19123        // the borrowed-input `Cow<'static, str>` forward-projection
19124        // axis is a distinct trait-idiomatic surface that a
19125        // `let key: Cow<'static, str> = (&list).into();`-shaped call
19126        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19127        // reaches through this impl and no other — the paired owned-
19128        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19129        // forces every borrowed-input call site through an explicit
19130        // `Copy` deref (`Cow::from(*list)`) or a
19131        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19132        // have no compile-time link back to the substrate primitive.
19133        //
19134        // Also asserts the projection lands on the zero-alloc
19135        // [`std::borrow::Cow::Borrowed`] arm (not the
19136        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19137        // [`super::DepList::as_str`] accessor's `&'static str` return
19138        // lifetime by construction (each match arm resolves to one of
19139        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19140        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19141        // values) makes the borrowed arm the type-correct projection
19142        // with no runtime allocation on the borrowed-input surface
19143        // just as on the paired owned-input surface.
19144        //
19145        // Closes the `{Self, &Self}` input-shape corner on the outside-
19146        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19147        // on the first outside-M3 caixa-core closed-set fieldless typed
19148        // enum peer on the caixa surface, exactly as afdf0f4 closed it
19149        // on the second M3-mesh-primitive peer
19150        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19151        // the owning half (eee504d) landed, as 25690ef closed it on
19152        // the first M3-mesh-primitive peer
19153        // ([`crate::aplicacao::WitShape`]) one commit after the owning
19154        // half (8634dec) landed, as d45c409 closed it on the top-level
19155        // [`crate::CaixaKind`] one commit after the owning half
19156        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19157        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19158        // [`crate::supervisor::RestartPolicy`] sibling peers one
19159        // commit after (7dd28b3 / 0612398) landed.
19160        for &variant in super::DepList::ALL {
19161            let via_trait: std::borrow::Cow<'static, str> =
19162                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19163            let via_method: &'static str = variant.as_str();
19164            assert_eq!(
19165                via_trait.as_ref(),
19166                via_method,
19167                "From<&DepList> for Cow<'static, str> impl must \
19168                 round-trip &DepList::{variant:?} to the same lifted \
19169                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19170                 DepList::as_str returns — divergence signals a silent \
19171                 detour off the substrate-primitive accessor"
19172            );
19173            assert!(
19174                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19175                "From<&DepList> for Cow<'static, str> impl must land \
19176                 on the zero-alloc Cow::Borrowed arm on \
19177                 &DepList::{variant:?} — a Cow::Owned outcome signals \
19178                 the projection has silently allocated where the \
19179                 substrate-primitive DepList::as_str `&'static str` \
19180                 return makes the borrowed arm the type-correct \
19181                 projection"
19182            );
19183            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19184            assert_eq!(
19185                via_into.as_ref(),
19186                via_method,
19187                "Into<Cow<'static, str>>::into on &DepList::\
19188                 {variant:?} must byte-equal DepList::as_str on the \
19189                 same input — the blanket-derived Into shape must \
19190                 resolve to the same as_str dispatch as the explicit \
19191                 From impl"
19192            );
19193            assert!(
19194                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19195                "Into<Cow<'static, str>>::into on &DepList::\
19196                 {variant:?} must land on the zero-alloc \
19197                 Cow::Borrowed arm — the blanket-derived Into shape \
19198                 must resolve to the same Cow::Borrowed dispatch as \
19199                 the explicit From impl"
19200            );
19201        }
19202    }
19203
19204    #[test]
19205    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19206        // Cross-axis partition pin: the newly lifted trait-idiomatic
19207        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19208        // str>` (this lift), the paired owned-input `From<DepList> for
19209        // std::borrow::Cow<'static, str>` (6858bac), the paired
19210        // borrowed-input owned-`&'static str` `From<&DepList> for
19211        // &'static str` (3455cbf), and the paired borrowed-input
19212        // owned-`String` `From<&DepList> for String` must resolve
19213        // identically on every arm, locking the four return-shape ×
19214        // input-shape paths together by construction so any future
19215        // detour trips at caixa-core test time. Also byte-parity
19216        // witness against the sibling [`ToString::to_string`] surface
19217        // routed through [`std::fmt::Display`] — every owned-heap-
19218        // string path (this axis's `.into_owned()` promotion, the
19219        // paired [`From<&DepList> for String`], and `.to_string()`)
19220        // resolves to the same two-arm lifted
19221        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19222        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19223        // arm.
19224        //
19225        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19226        // over [`super::DepList::ALL`] — whose iterator yields
19227        // `&DepList` by construction, so the borrowed-input
19228        // [`Cow<'static, str>`] axis is what routes the pipe through
19229        // the substrate-primitive [`super::DepList::as_str`] accessor
19230        // without a spurious [`Copy`] deref (which would only be
19231        // reachable through the owned-input [`From<DepList> for
19232        // Cow<'static, str>`] axis by first calling `.copied()` on the
19233        // iterator). The pipe witness also pins the zero-alloc
19234        // discipline: every element in the collected vector satisfies
19235        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19236        // future accidental silent-allocation regression on the pipe's
19237        // iteration axis is a caixa-core-test-time failure. Peer of
19238        // the sibling
19239        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19240        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19241        // axis — extends the whole borrowed-input `Cow<'static, str>`
19242        // + paired `{&'static str, String}` cross-axis-parity corner
19243        // onto the first outside-M3 caixa-core closed-set fieldless
19244        // typed enum peer on the caixa surface.
19245        for &variant in super::DepList::ALL {
19246            let borrowed_cow: std::borrow::Cow<'static, str> =
19247                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19248            let owned_cow: std::borrow::Cow<'static, str> =
19249                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19250            let borrowed_static: &'static str =
19251                <&'static str as From<&super::DepList>>::from(&variant);
19252            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19253            assert_eq!(
19254                borrowed_cow, owned_cow,
19255                "From<&DepList> for Cow<'static, str> and \
19256                 From<DepList> for Cow<'static, str> must resolve \
19257                 identically on DepList::{variant:?} — divergence \
19258                 signals the borrowed-input and owned-input \
19259                 Cow<'static, str> forward-projection input-shape \
19260                 paths have drifted onto different emit-sets"
19261            );
19262            assert_eq!(
19263                borrowed_cow.as_ref(),
19264                borrowed_static,
19265                "From<&DepList> for Cow<'static, str> and \
19266                 From<&DepList> for &'static str must resolve \
19267                 identically on DepList::{variant:?} — divergence \
19268                 signals the borrowed-input Cow<'static, str> and \
19269                 &'static str return-shape paths have drifted onto \
19270                 different emit-sets"
19271            );
19272            assert_eq!(
19273                borrowed_cow.as_ref(),
19274                borrowed_string.as_str(),
19275                "From<&DepList> for Cow<'static, str> and \
19276                 From<&DepList> for String must resolve identically \
19277                 on DepList::{variant:?} — divergence signals the \
19278                 borrowed-input Cow<'static, str> and owned-`String` \
19279                 return-shape paths have drifted onto different \
19280                 emit-sets"
19281            );
19282            let via_to_string: String = variant.to_string();
19283            assert_eq!(
19284                borrowed_cow.as_ref(),
19285                via_to_string.as_str(),
19286                "From<&DepList> for Cow<'static, str> must byte-equal \
19287                 DepList::to_string on DepList::{variant:?} — \
19288                 divergence signals the trait-idiomatic borrowed-input \
19289                 Cow<'static, str> forward-projection axis and the \
19290                 ToString-through-Display axis have drifted onto \
19291                 different emit-sets"
19292            );
19293        }
19294        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19295            .iter()
19296            .map(std::borrow::Cow::from)
19297            .collect();
19298        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19299            .iter()
19300            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19301            .collect();
19302        assert_eq!(
19303            via_iter, via_method,
19304            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19305             whose iteration axis holds &DepList by construction — \
19306             must byte-equal `.iter().map(|l| \
19307             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19308             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19309             str>` axis is what makes the `Cow::from` composition \
19310             route through the substrate-primitive `DepList::as_str` \
19311             accessor with the zero-alloc Cow::Borrowed arm by \
19312             construction and without a spurious `Copy` deref (which \
19313             would only be reachable through the owned-input \
19314             `From<DepList> for Cow<'static, str>` axis by first \
19315             calling `.copied()` on the iterator)"
19316        );
19317        for cow in &via_iter {
19318            assert!(
19319                matches!(cow, std::borrow::Cow::Borrowed(_)),
19320                "every element of the .iter().map(Cow::from) pipe \
19321                 over DepList::ALL must land on the zero-alloc \
19322                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19323                 signals the pipe's iteration axis has silently \
19324                 allocated where the substrate-primitive \
19325                 DepList::as_str `&'static str` return makes the \
19326                 borrowed arm the type-correct projection"
19327            );
19328        }
19329    }
19330
19331    #[test]
19332    fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19333        // Fail-before-pass-after byte-parity pin on the newly lifted
19334        // `impl From<DepList> for Box<str>` — asserts the owned-input
19335        // standard-library trait impl and the substrate-primitive
19336        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19337        // the same two-arm emit-set (the paired
19338        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19339        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19340        // byte-strings) across every arm the exhaustive
19341        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19342        // core-internal tier of the substrate-wide [`Box<str>`] forward-
19343        // projection campaign onto the second caixa-core-internal peer,
19344        // after the render-side path-shape-diagnostic
19345        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19346        // both corners in one axis) opened the tier. Rust's standard
19347        // library carries `impl From<&str> for Box<str>` and
19348        // `impl From<String> for Box<str>` but no blanket
19349        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19350        // distinct trait-idiomatic surface that a
19351        // `let key: Box<str> = list.into();`-shaped call site reaches
19352        // through this impl and no other — a paired
19353        // `Box::from(list.as_str())` open-code has no compile-time link
19354        // back to the substrate primitive.
19355        for &variant in super::DepList::ALL {
19356            let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19357            let via_method: &'static str = variant.as_str();
19358            assert_eq!(
19359                via_trait.as_ref(),
19360                via_method,
19361                "From<DepList> for Box<str> impl must round-trip \
19362                 DepList::{variant:?} to the same lifted \
19363                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19364                 DepList::as_str returns — divergence signals a silent \
19365                 detour off the substrate-primitive accessor"
19366            );
19367            let via_into: Box<str> = variant.into();
19368            assert_eq!(
19369                via_into.as_ref(),
19370                via_method,
19371                "Into<Box<str>>::into on DepList::{variant:?} must \
19372                 byte-equal DepList::as_str on the same input — the \
19373                 blanket-derived Into shape must resolve to the same \
19374                 as_str dispatch as the explicit From impl"
19375            );
19376        }
19377    }
19378
19379    #[test]
19380    fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19381        // Fail-before-pass-after byte-parity pin on the newly lifted
19382        // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19383        // standard-library trait impl and the substrate-primitive
19384        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19385        // the same two-arm emit-set (the paired
19386        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19387        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19388        // byte-strings) across every arm the exhaustive
19389        // [`super::DepList::ALL`] slice enumerates. Rust's standard
19390        // library carries `impl From<&str> for Box<str>` and
19391        // `impl From<String> for Box<str>` but no blanket
19392        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19393        // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19394        // input [`Box<str>`] forward-projection axis is a distinct
19395        // trait-idiomatic surface that a
19396        // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19397        // iterator over `&'static [DepList]` yields `&DepList` by
19398        // construction) or a `let key: Box<str> = (&list).into();`-shaped
19399        // call site reaches through this impl and no other — the paired
19400        // owned-input `From<DepList> for Box<str>` impl alone would force
19401        // every borrowed-input call site through an explicit `Copy` deref
19402        // (`Box::<str>::from(*list)`) or a
19403        // `Box::<str>::from(list.as_str())` open-code whose type bounds
19404        // have no compile-time link back to the substrate primitive.
19405        //
19406        // Closes the `{Self, &Self}` input-shape corner on the second
19407        // caixa-core-internal closed-set fieldless typed enum peer of
19408        // the substrate-wide [`Box<str>`] forward-projection campaign —
19409        // one commit after the paired render-side path-shape-diagnostic
19410        // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19411        // opened the caixa-core-internal tier — matching the trajectory
19412        // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19413        // in one axis), the caixa-provedor `FerriteRuntime` pair
19414        // (14886a8, both corners in one axis), and the render-side
19415        // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19416        // walked before it.
19417        for &variant in super::DepList::ALL {
19418            let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19419            let via_method: &'static str = variant.as_str();
19420            assert_eq!(
19421                via_trait.as_ref(),
19422                via_method,
19423                "From<&DepList> for Box<str> impl must round-trip \
19424                 &DepList::{variant:?} to the same lifted \
19425                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19426                 DepList::as_str returns — divergence signals a silent \
19427                 detour off the substrate-primitive accessor"
19428            );
19429            let via_into: Box<str> = (&variant).into();
19430            assert_eq!(
19431                via_into.as_ref(),
19432                via_method,
19433                "Into<Box<str>>::into on &DepList::{variant:?} must \
19434                 byte-equal DepList::as_str on the same input — the \
19435                 blanket-derived Into shape on the borrowed-input \
19436                 surface must resolve to the same as_str dispatch as \
19437                 the explicit From impl"
19438            );
19439        }
19440
19441        // Pipe witness — the distinguishing shape that forces the
19442        // borrowed-input axis to be independent of the owned-input
19443        // peer. `DepList::ALL.iter()` yields `&DepList` by
19444        // construction, so `.map(Box::<str>::from)` resolves through
19445        // the borrowed-input `From<&DepList> for Box<str>` impl and
19446        // no other — without this axis, the same pipe would force an
19447        // explicit `.copied()` restatement whose type bounds bypass
19448        // the substrate primitive.
19449        let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19450        let via_accessor: Vec<&'static str> =
19451            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19452        assert_eq!(
19453            via_pipe.len(),
19454            via_accessor.len(),
19455            "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19456             preserve arity against the paired DepList::as_str \
19457             accessor — a length divergence signals the borrowed-input \
19458             axis has silently rejected an arm"
19459        );
19460        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19461            assert_eq!(
19462                pipe_arm.as_ref(),
19463                *accessor_arm,
19464                "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19465                 byte-equal the paired \
19466                 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19467                 arm — divergence signals the borrowed-input \
19468                 `From<&DepList> for Box<str>` axis has silently \
19469                 detoured off the substrate-primitive accessor"
19470            );
19471        }
19472    }
19473
19474    #[test]
19475    fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
19476        // Fail-before-pass-after byte-parity pin on the newly lifted
19477        // `impl From<DepList> for std::sync::Arc<str>` — asserts the
19478        // owned-input standard-library trait impl and the substrate-
19479        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19480        // resolve to the same two-arm emit-set (the paired
19481        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19482        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19483        // byte-strings) across every arm the exhaustive
19484        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19485        // core-internal tier of the substrate-wide
19486        // [`std::sync::Arc<str>`] forward-projection campaign onto the
19487        // second caixa-core-internal peer, after the top-level
19488        // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
19489        // opened the tier. Rust's standard library carries
19490        // `impl From<&str> for std::sync::Arc<str>` and
19491        // `impl From<String> for std::sync::Arc<str>` but no blanket
19492        // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
19493        // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
19494        // this axis is a distinct trait-idiomatic surface that a
19495        // `let key: std::sync::Arc<str> = list.into();`-shaped call site
19496        // reaches through this impl and no other — a paired
19497        // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
19498        // compile-time link back to the substrate primitive, and a two-
19499        // step `std::sync::Arc::<str>::from(String::from(list))`
19500        // composition through the owned-`String` axis allocates twice
19501        // (once into the intermediate `String`, once into the
19502        // [`std::sync::Arc<str>`] on the `From<String>` conversion)
19503        // where the single-step trait impl allocates once.
19504        //
19505        // Cross-axis byte-parity witness against the sibling owned-input
19506        // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
19507        // shape axes — locking the five return-shape paths on the owned-
19508        // input surface together by construction so any future detour
19509        // off the substrate-primitive [`super::DepList::as_str`] accessor
19510        // trips at caixa-core test time.
19511        for &variant in super::DepList::ALL {
19512            let via_trait: std::sync::Arc<str> =
19513                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19514            let via_method: &'static str = variant.as_str();
19515            assert_eq!(
19516                via_trait.as_ref(),
19517                via_method,
19518                "From<DepList> for std::sync::Arc<str> impl must round-\
19519                 trip DepList::{variant:?} to the same lifted \
19520                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19521                 DepList::as_str returns — divergence signals a silent \
19522                 detour off the substrate-primitive accessor"
19523            );
19524            let via_into: std::sync::Arc<str> = variant.into();
19525            assert_eq!(
19526                via_into.as_ref(),
19527                via_method,
19528                "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
19529                 must byte-equal DepList::as_str on the same input — \
19530                 the blanket-derived Into shape must resolve to the same \
19531                 as_str dispatch as the explicit From impl"
19532            );
19533            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19534            assert_eq!(
19535                via_trait.as_ref(),
19536                owned_static,
19537                "From<DepList> for std::sync::Arc<str> and \
19538                 From<DepList> for &'static str must resolve identically \
19539                 on DepList::{variant:?} — divergence signals the owned-\
19540                 input std::sync::Arc<str> and &'static str return-shape \
19541                 paths have drifted onto different emit-sets"
19542            );
19543            let owned_string: String = <String as From<super::DepList>>::from(variant);
19544            assert_eq!(
19545                via_trait.as_ref(),
19546                owned_string.as_str(),
19547                "From<DepList> for std::sync::Arc<str> and \
19548                 From<DepList> for String must resolve identically on \
19549                 DepList::{variant:?} — divergence signals the owned-\
19550                 input std::sync::Arc<str> and owned-`String` return-shape \
19551                 paths have drifted onto different emit-sets"
19552            );
19553            let owned_cow: std::borrow::Cow<'static, str> =
19554                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19555            assert_eq!(
19556                via_trait.as_ref(),
19557                owned_cow.as_ref(),
19558                "From<DepList> for std::sync::Arc<str> and \
19559                 From<DepList> for Cow<'static, str> must resolve \
19560                 identically on DepList::{variant:?} — divergence signals \
19561                 the owned-input std::sync::Arc<str> and \
19562                 Cow<'static, str> return-shape paths have drifted onto \
19563                 different emit-sets"
19564            );
19565            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19566            assert_eq!(
19567                via_trait.as_ref(),
19568                owned_box.as_ref(),
19569                "From<DepList> for std::sync::Arc<str> and \
19570                 From<DepList> for Box<str> must resolve identically on \
19571                 DepList::{variant:?} — divergence signals the owned-\
19572                 input std::sync::Arc<str> and Box<str> return-shape \
19573                 paths have drifted onto different emit-sets"
19574            );
19575        }
19576    }
19577
19578    #[test]
19579    #[allow(
19580        clippy::too_many_lines,
19581        reason = "cross-axis partition pin folds four borrowed-input \
19582                  return-shape paths (&'static str, String, Cow<'static, \
19583                  str>, Box<str>) plus the paired owned-input Arc<str> \
19584                  witness and the .iter().map(std::sync::Arc::<str>::from) \
19585                  pipe witness into one exhaustive round-trip over \
19586                  DepList::ALL — the accepted line-count cost of keying \
19587                  the whole borrowed-input Arc<str> corner to the \
19588                  substrate-primitive as_str accessor at the same test-site"
19589    )]
19590    fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
19591        // Fail-before-pass-after byte-parity pin on the newly lifted
19592        // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
19593        // borrowed-input standard-library trait impl and the substrate-
19594        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19595        // resolve to the same two-arm emit-set across every arm the
19596        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19597        // standard library does not carry a blanket
19598        // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
19599        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19600        // the borrowed-input `std::sync::Arc<str>` forward-projection
19601        // axis is a distinct trait-idiomatic surface that a
19602        // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
19603        // site or a
19604        // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
19605        // pipe reaches through this impl and no other — the paired
19606        // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
19607        // forces every borrowed-input call site through a spurious
19608        // `Copy` deref
19609        // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
19610        // `.copied()` restatement whose type bounds have no compile-time
19611        // link back to the substrate primitive.
19612        //
19613        // Closes the `{Self, &Self}` input-shape corner on the second
19614        // caixa-core-internal closed-set fieldless typed enum peer of
19615        // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
19616        // forward-projection campaign — one commit after the paired
19617        // top-level [`crate::CaixaKind`] pair (c17be64) opened the
19618        // caixa-core-internal tier — matching the
19619        // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
19620        // Box<str>}` 2×4 forward-projection matrix the peer projection
19621        // surfaces already close on this same enum.
19622        //
19623        // Cross-axis partition pin against the paired owned-input
19624        // [`From<DepList> for std::sync::Arc<str>`] and the sibling
19625        // borrowed-input `{&'static str, String, Cow<'static, str>,
19626        // Box<str>}` return-shape axes — locking the five return-shape
19627        // × input-shape paths on the borrowed-input surface together by
19628        // construction so any future detour off the substrate-primitive
19629        // accessor trips at caixa-core test time. Then a
19630        // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
19631        // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
19632        // construction, so the borrowed-input
19633        // [`std::sync::Arc<str>`] axis is what routes the pipe through
19634        // the substrate-primitive [`super::DepList::as_str`] accessor
19635        // without a spurious [`Copy`] deref (which would only be
19636        // reachable through the owned-input
19637        // [`From<DepList> for std::sync::Arc<str>`] axis by first
19638        // calling `.copied()` on the iterator).
19639        for &variant in super::DepList::ALL {
19640            let via_trait: std::sync::Arc<str> =
19641                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
19642            let via_method: &'static str = variant.as_str();
19643            assert_eq!(
19644                via_trait.as_ref(),
19645                via_method,
19646                "From<&DepList> for std::sync::Arc<str> impl must round-\
19647                 trip &DepList::{variant:?} to the same lifted \
19648                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19649                 DepList::as_str returns — divergence signals a silent \
19650                 detour off the substrate-primitive accessor"
19651            );
19652            let via_into: std::sync::Arc<str> = (&variant).into();
19653            assert_eq!(
19654                via_into.as_ref(),
19655                via_method,
19656                "Into<std::sync::Arc<str>>::into on &DepList::\
19657                 {variant:?} must byte-equal DepList::as_str on the \
19658                 same input — the blanket-derived Into shape on the \
19659                 borrowed-input surface must resolve to the same as_str \
19660                 dispatch as the explicit From impl"
19661            );
19662            let owned_arc: std::sync::Arc<str> =
19663                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19664            assert_eq!(
19665                via_trait, owned_arc,
19666                "From<&DepList> for std::sync::Arc<str> and \
19667                 From<DepList> for std::sync::Arc<str> must resolve \
19668                 identically on DepList::{variant:?} — divergence \
19669                 signals the borrowed-input and owned-input \
19670                 std::sync::Arc<str> forward-projection input-shape \
19671                 paths have drifted onto different emit-sets"
19672            );
19673            let borrowed_static: &'static str =
19674                <&'static str as From<&super::DepList>>::from(&variant);
19675            assert_eq!(
19676                via_trait.as_ref(),
19677                borrowed_static,
19678                "From<&DepList> for std::sync::Arc<str> and \
19679                 From<&DepList> for &'static str must resolve \
19680                 identically on DepList::{variant:?} — divergence \
19681                 signals the borrowed-input std::sync::Arc<str> and \
19682                 &'static str return-shape paths have drifted onto \
19683                 different emit-sets"
19684            );
19685            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19686            assert_eq!(
19687                via_trait.as_ref(),
19688                borrowed_string.as_str(),
19689                "From<&DepList> for std::sync::Arc<str> and \
19690                 From<&DepList> for String must resolve identically on \
19691                 DepList::{variant:?} — divergence signals the \
19692                 borrowed-input std::sync::Arc<str> and owned-`String` \
19693                 return-shape paths have drifted onto different emit-\
19694                 sets"
19695            );
19696            let borrowed_cow: std::borrow::Cow<'static, str> =
19697                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19698            assert_eq!(
19699                via_trait.as_ref(),
19700                borrowed_cow.as_ref(),
19701                "From<&DepList> for std::sync::Arc<str> and \
19702                 From<&DepList> for Cow<'static, str> must resolve \
19703                 identically on DepList::{variant:?} — divergence \
19704                 signals the borrowed-input std::sync::Arc<str> and \
19705                 Cow<'static, str> return-shape paths have drifted onto \
19706                 different emit-sets"
19707            );
19708            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19709            assert_eq!(
19710                via_trait.as_ref(),
19711                borrowed_box.as_ref(),
19712                "From<&DepList> for std::sync::Arc<str> and \
19713                 From<&DepList> for Box<str> must resolve identically \
19714                 on DepList::{variant:?} — divergence signals the \
19715                 borrowed-input std::sync::Arc<str> and Box<str> \
19716                 return-shape paths have drifted onto different emit-sets"
19717            );
19718        }
19719        let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
19720            .iter()
19721            .map(std::sync::Arc::<str>::from)
19722            .collect();
19723        let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
19724            .iter()
19725            .map(|l| std::sync::Arc::<str>::from(l.as_str()))
19726            .collect();
19727        assert_eq!(
19728            via_iter, via_method,
19729            "`.iter().map(std::sync::Arc::<str>::from)` over \
19730             DepList::ALL — a call site whose iteration axis holds \
19731             `&DepList` by construction — must byte-equal \
19732             `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
19733             on every arm — the borrowed-input std::sync::Arc<str> \
19734             `From<&DepList> for std::sync::Arc<str>` axis is what \
19735             makes the `std::sync::Arc::<str>::from` composition route \
19736             through the substrate-primitive `DepList::as_str` \
19737             accessor without a spurious `Copy` deref (which would \
19738             only be reachable through the owned-input \
19739             `From<DepList> for std::sync::Arc<str>` axis by first \
19740             calling `.copied()` on the iterator)"
19741        );
19742    }
19743}
19744
19745#[cfg(test)]
19746mod dep_source_is_variant_tests {
19747    use super::*;
19748
19749    fn all_variants() -> Vec<(DepSource, &'static str)> {
19750        vec![
19751            (
19752                DepSource::Git {
19753                    repo: "github:pleme-io/caixa-teia".into(),
19754                    tag: Some("v0.1.0".into()),
19755                    rev: None,
19756                    branch: None,
19757                },
19758                "Git",
19759            ),
19760            (
19761                DepSource::Path {
19762                    caminho: "../caixa-teia".into(),
19763                },
19764                "Path",
19765            ),
19766        ]
19767    }
19768
19769    fn predicate_row(s: &DepSource) -> [bool; 2] {
19770        [s.is_git(), s.is_path()]
19771    }
19772
19773    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
19774    // derive-generated per-arm predicate partition — for every variant
19775    // in `all_variants()`, the observed 2-slot predicate row must equal
19776    // a one-hot row with the `true` at exactly the same index as the
19777    // variant's declaration order. Expected rows are generated live
19778    // from the enumeration rather than transcribed by hand, so a
19779    // copy-paste flip that reroutes one arm through the wrong predicate
19780    // lane trips at the identity-diagonal assertion the way every peer
19781    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
19782    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
19783    // / [`crate::upgrade::UpgradeInstruction`] /
19784    // [`crate::aplicacao::PlacementStrategy`] /
19785    // [`crate::aplicacao::RateLimitUnit`] /
19786    // [`crate::aplicacao::WitTarget`] /
19787    // [`crate::render::PathShapeViolation`] partition pin already does.
19788    #[test]
19789    fn dep_source_is_variant_predicates_partition_the_arm_set() {
19790        let variants = all_variants();
19791        for (idx, (variant, name)) in variants.iter().enumerate() {
19792            let observed = predicate_row(variant);
19793            let mut expected = [false; 2];
19794            expected[idx] = true;
19795            assert_eq!(
19796                observed, expected,
19797                "DepSource::{name} at declaration-order slot {idx} must \
19798                 satisfy exactly one is_* predicate (its own); observed \
19799                 row must equal the one-hot expected row — a drift \
19800                 would silently reroute one `:fonte`-arm consumer \
19801                 through the wrong predicate lane"
19802            );
19803        }
19804    }
19805
19806    // Byte-parity pin on the two field-agnostic `matches!` shapes the
19807    // per-arm arm-discriminator predicates replace at any future
19808    // consumer site (a `:fonte`-shape-only lint rule that flags path
19809    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
19810    // a future admission-webhook that rejects `:fonte` shapes outside
19811    // the `is_git()` accept-set, a caixa-lacre indexing pass that
19812    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
19813    // Refuses a future accidental split between the derived predicate
19814    // and its `matches!` shape — a hand-rolled shadow impl that
19815    // overrides one path, an accidental rebrand that leaves one
19816    // consumer on the raw `matches!` form — on the two load-bearing
19817    // `:fonte`-arm-discriminator axes every downstream substrate
19818    // consumer of the dep-source axis keys off.
19819    #[test]
19820    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
19821        for (variant, name) in all_variants() {
19822            let via_matches_git = matches!(variant, DepSource::Git { .. });
19823            let via_predicate_git = variant.is_git();
19824            assert_eq!(
19825                via_predicate_git, via_matches_git,
19826                "DepSource::{name}.is_git() must byte-equal \
19827                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
19828                 future converged consumer site would silently \
19829                 disagree with its pre-lift shape"
19830            );
19831            let via_matches_path = matches!(variant, DepSource::Path { .. });
19832            let via_predicate_path = variant.is_path();
19833            assert_eq!(
19834                via_predicate_path, via_matches_path,
19835                "DepSource::{name}.is_path() must byte-equal \
19836                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
19837                 future converged consumer site would silently \
19838                 disagree with its pre-lift shape"
19839            );
19840        }
19841    }
19842
19843    // Cross-pin against every constructor path that materializes a
19844    // [`DepSource`] shape today (the [`DepSource::default_github`]
19845    // resolver-side fallback that materializes an unpinned
19846    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
19847    // surface constructor that materializes a pinned `:tag`-carrying
19848    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
19849    // fixture family builds inline). Every constructor's return must
19850    // satisfy the arm-discriminator predicate the constructor's
19851    // variant name matches — a future constructor addition (an
19852    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
19853    // enclosing docstring already names as a trajectory item) surfaces
19854    // as a build-time failure that names the offending drift when its
19855    // return arm doesn't route through the paired predicate.
19856    #[test]
19857    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
19858        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
19859        assert!(
19860            via_default_github.is_git(),
19861            "DepSource::default_github must materialize a Git-arm shape — \
19862             a future constructor that routed through a non-Git arm \
19863             (a registry-fetch pin, a `DepSource::Feira` promotion) \
19864             would silently split the resolver's unpinned-shorthand \
19865             materializer from the sole_pin() precedence cascade"
19866        );
19867        assert!(
19868            !via_default_github.is_path(),
19869            "DepSource::default_github must NOT materialize a Path-arm \
19870             shape — the paired negation pin"
19871        );
19872
19873        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
19874            .fonte
19875            .expect("Dep::git materializes a Some(fonte)");
19876        assert!(
19877            via_dep_git.is_git(),
19878            "Dep::git's `:fonte` materialization must land on the Git \
19879             arm — the author-surface pinned-git constructor's return \
19880             must route through the paired predicate"
19881        );
19882        assert!(!via_dep_git.is_path(), "paired negation pin");
19883
19884        let via_path = DepSource::Path {
19885            caminho: "../caixa-teia".into(),
19886        };
19887        assert!(
19888            via_path.is_path(),
19889            "the dev-mode Path-arm materialization must satisfy is_path()"
19890        );
19891        assert!(!via_path.is_git(), "paired negation pin");
19892    }
19893
19894    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
19895    //    String, reason: String }` three-slot envelope on `DepError`,
19896    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
19897    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
19898    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
19899    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
19900    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
19901    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
19902
19903    #[test]
19904    fn versao_invalid_ctor_matches_struct_literal_wrap() {
19905        assert_eq!(
19906            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
19907            DepError::VersaoInvalid {
19908                nome: "caixa-teia".to_string(),
19909                versao: "^0..1".to_string(),
19910                reason: "invalid comparator".to_string(),
19911            },
19912            "versao_invalid ctor must produce byte-equal \
19913             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
19914        );
19915    }
19916
19917    #[test]
19918    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
19919        assert_eq!(
19920            DepError::fonte_repo_shape(
19921                "caixa-teia",
19922                "-upload-pack=evil",
19923                "leading dash rejected".to_string(),
19924            ),
19925            DepError::FonteRepoShape {
19926                nome: "caixa-teia".to_string(),
19927                repo: "-upload-pack=evil".to_string(),
19928                reason: "leading dash rejected".to_string(),
19929            },
19930            "fonte_repo_shape ctor must produce byte-equal \
19931             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
19932        );
19933    }
19934
19935    #[test]
19936    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
19937        assert_eq!(
19938            DepError::caracteristica_invalid(
19939                "caixa-teia",
19940                "bad feature!",
19941                "embedded space rejected".to_string(),
19942            ),
19943            DepError::CaracteristicaInvalid {
19944                nome: "caixa-teia".to_string(),
19945                caracteristica: "bad feature!".to_string(),
19946                reason: "embedded space rejected".to_string(),
19947            },
19948            "caracteristica_invalid ctor must produce byte-equal \
19949             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
19950        );
19951    }
19952
19953    #[test]
19954    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
19955        // Cross-axis routing pin: sweep the three constructor input axes
19956        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
19957        // distinct-per-axis fixtures against every generated arm in the
19958        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
19959        // lowercase / trim / truncate on the two `&str` axes — a silent
19960        // field swap between `nome`, the middle `<axis>` field, and
19961        // `reason`, or a `reason` axis silently rerouted through
19962        // `.to_string()` instead of forwarded owned — surfaces here rather
19963        // than at a downstream diagnostic-shape mismatch. Peer of the
19964        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
19965        // through_to_string` (0e35793) cross-axis routing pin on the same
19966        // envelope's `{ nome, caminho, byte }` three-slot family and of
19967        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
19968        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
19969        // — extended here onto the `{ nome, <axis>: String, reason:
19970        // String }` three-slot envelope so every substrate-primitive ctor
19971        // family in caixa-core's `DepError` envelope guarantees each field
19972        // routes the caller's value verbatim through `.to_string()` (or
19973        // owned-forward for `reason: String`) in declared field order.
19974        // Distinct-per-axis fixtures rule out any two-axis swap
19975        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
19976        // same-fixture-per-axis pin.
19977        let nome = "sibling-teia";
19978        let axis = "distinct-axis-value";
19979        let reason = "distinct rejection sentence".to_string();
19980        assert_eq!(
19981            DepError::versao_invalid(nome, axis, reason.clone()),
19982            DepError::VersaoInvalid {
19983                nome: nome.to_string(),
19984                versao: axis.to_string(),
19985                reason: reason.clone(),
19986            },
19987            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
19988             `reason` → `reason` in declared field order",
19989        );
19990        assert_eq!(
19991            DepError::fonte_repo_shape(nome, axis, reason.clone()),
19992            DepError::FonteRepoShape {
19993                nome: nome.to_string(),
19994                repo: axis.to_string(),
19995                reason: reason.clone(),
19996            },
19997            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
19998             `reason` → `reason` in declared field order",
19999        );
20000        assert_eq!(
20001            DepError::caracteristica_invalid(nome, axis, reason.clone()),
20002            DepError::CaracteristicaInvalid {
20003                nome: nome.to_string(),
20004                caracteristica: axis.to_string(),
20005                reason: reason.clone(),
20006            },
20007            "caracteristica_invalid must route `nome` → `nome`, \
20008             `axis` → `caracteristica`, `reason` → `reason` in declared \
20009             field order",
20010        );
20011    }
20012
20013    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
20014    //    two-slot envelope on `DepError`, missing rung between
20015    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
20016    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
20017    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
20018    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
20019    //    two-slot `{ nome, list: &'static str }` envelope (same slot
20020    //    count, `&'static str` axis instead of owned `String` axis).
20021
20022    #[test]
20023    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
20024        assert_eq!(
20025            DepError::fonte_pin_empty("caixa-teia", ":tag"),
20026            DepError::FontePinEmpty {
20027                nome: "caixa-teia".to_string(),
20028                pin: ":tag".to_string(),
20029            },
20030            "fonte_pin_empty ctor must produce byte-equal \
20031             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
20032             on the same `(&str, &str)` fixture",
20033        );
20034    }
20035
20036    #[test]
20037    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
20038        assert_eq!(
20039            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
20040            DepError::FontePinAmbiguous {
20041                nome: "caixa-teia".to_string(),
20042                pins: ":tag, :rev".to_string(),
20043            },
20044            "fonte_pin_ambiguous ctor must produce byte-equal \
20045             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
20046             wrap on the same `(&str, &str)` fixture",
20047        );
20048    }
20049
20050    #[test]
20051    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
20052        assert_eq!(
20053            DepError::caracteristica_duplicate("caixa-teia", "http"),
20054            DepError::CaracteristicaDuplicate {
20055                nome: "caixa-teia".to_string(),
20056                caracteristica: "http".to_string(),
20057            },
20058            "caracteristica_duplicate ctor must produce byte-equal \
20059             `DepError::CaracteristicaDuplicate` to the pre-lift \
20060             struct-literal wrap on the same `(&str, &str)` fixture",
20061        );
20062    }
20063
20064    #[test]
20065    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
20066        // Owned-`String` routing pin: thread the real
20067        // `set.join(", ")` `String` carrier through the ctor's
20068        // `&str`-parameter Deref coercion, so the ambiguity-arm
20069        // wire-up site's actual `&set.join(", ")` shape stays
20070        // byte-equal to a direct `":tag, :rev"` literal. A future
20071        // parameter-shape change silently dropping the Deref
20072        // coercion route (e.g., a switch to `impl Into<String>`)
20073        // surfaces here rather than at the wire-up's compile
20074        // error far from the ctor definition.
20075        let set: Vec<&'static str> = vec![":tag", ":rev"];
20076        let joined: String = set.join(", ");
20077        assert_eq!(
20078            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
20079            DepError::FontePinAmbiguous {
20080                nome: "caixa-teia".to_string(),
20081                pins: ":tag, :rev".to_string(),
20082            },
20083            "fonte_pin_ambiguous ctor must accept an owned-`String` \
20084             `&set.join(\", \")` carrier via Deref coercion — the exact \
20085             shape the ambiguity-arm wire-up site passes into it",
20086        );
20087    }
20088
20089    #[test]
20090    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
20091        // Cross-axis routing pin: sweep the two constructor input axes
20092        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
20093        // fixtures against every generated arm in the
20094        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
20095        // trim / truncate at codegen time — a silent field swap between
20096        // `nome` and the middle `<axis>` field, or a `<axis>` axis
20097        // silently rerouted through the wrong field on any one variant
20098        // — surfaces here rather than at a downstream diagnostic-shape
20099        // mismatch. Peer of the sibling
20100        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
20101        // (6f5e0cd) pin on the same envelope's peer two-slot family
20102        // (`{ nome, list: &'static str }`) and of the sibling
20103        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20104        // (5621f8a) pin on the same envelope's three-slot `{ nome,
20105        // <axis>: String, reason: String }` family — extended here onto
20106        // the `{ nome, <axis>: String }` two-slot envelope so the last
20107        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
20108        // ladder guarantees each field routes the caller's value
20109        // verbatim through `.to_string()` in declared field order.
20110        // Distinct-per-axis fixtures rule out any two-axis swap
20111        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
20112        // per-axis pin.
20113        let nome = "sibling-teia";
20114        let axis = "distinct-axis-value";
20115        assert_eq!(
20116            DepError::fonte_pin_empty(nome, axis),
20117            DepError::FontePinEmpty {
20118                nome: nome.to_string(),
20119                pin: axis.to_string(),
20120            },
20121            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
20122             in declared field order",
20123        );
20124        assert_eq!(
20125            DepError::fonte_pin_ambiguous(nome, axis),
20126            DepError::FontePinAmbiguous {
20127                nome: nome.to_string(),
20128                pins: axis.to_string(),
20129            },
20130            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
20131             in declared field order",
20132        );
20133        assert_eq!(
20134            DepError::caracteristica_duplicate(nome, axis),
20135            DepError::CaracteristicaDuplicate {
20136                nome: nome.to_string(),
20137                caracteristica: axis.to_string(),
20138            },
20139            "caracteristica_duplicate must route `nome` → `nome`, \
20140             `axis` → `caracteristica` in declared field order",
20141        );
20142    }
20143
20144    #[test]
20145    fn nome_invalid_ctor_matches_struct_literal_wrap() {
20146        // Equivalence pin: the ctor produces byte-equal
20147        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
20148        // literal that cloned the offending `:deps :nome` verbatim and
20149        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
20150        // owned `reason` payload at the caller site inside
20151        // [`Dep::validate`]. Guards any future field-addition /
20152        // reordering / accessor-return tweak on the variant. Sibling of
20153        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
20154        // (below) and the sibling three-slot
20155        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20156        // pin on the same envelope's three-slot `{ nome, <axis>: String,
20157        // reason: String }` family.
20158        let nome = "Caixa-Teia";
20159        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
20160        let via_ctor = DepError::nome_invalid(nome, reason.clone());
20161        let via_literal = DepError::NomeInvalid {
20162            nome: nome.to_string(),
20163            reason,
20164        };
20165        assert_eq!(
20166            via_ctor, via_literal,
20167            "nome_invalid(nome, reason) must byte-equal the open-coded \
20168             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
20169        );
20170        assert_eq!(
20171            via_ctor.to_string(),
20172            via_literal.to_string(),
20173            "Display byte-string must byte-equal the open-coded struct-literal"
20174        );
20175    }
20176
20177    #[test]
20178    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
20179        // Boundary-sweep pin on the ctor's two-slot projection: sweep
20180        // the two ctor input axes (`nome: &str`, `reason: String`)
20181        // through distinct-per-axis fixtures against a representative
20182        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
20183        // wrapper-side silent lowercase / trim / truncate at codegen
20184        // time — a silent field swap between `nome` and `reason`, an
20185        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
20186        // divergence on the `reason` axis — surfaces at caixa-core
20187        // build time rather than at a downstream diagnostic consumer
20188        // that reads `err.nome` / `err.reason` back and gets a different
20189        // value than the one it stored. Peer of the sibling
20190        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
20191        // (7f7c950) pin on the same envelope's peer two-slot family
20192        // (`{ nome, <axis>: String }`) — extended here onto the
20193        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
20194        // variant carries. Distinct-per-axis fixtures rule out any
20195        // two-axis swap (`nome` ↔ `reason`) that would still pass a
20196        // same-fixture-per-axis pin. The sweep list carries a mixed
20197        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
20198        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
20199        // over-63-byte) so a future silent per-input normalization
20200        // surfaces on the arm that diverges.
20201        for nome in [
20202            "Caixa-Teia",
20203            "caixa_teia",
20204            "caixa.teia",
20205            "-caixa-teia",
20206            "caixa-teia-",
20207            "caixa/teia",
20208            &"a".repeat(64),
20209        ] {
20210            let reason = crate::render::is_dns_1123_label(nome)
20211                .expect_err("fixture must be a DNS-1123-refused label");
20212            let via_ctor = DepError::nome_invalid(nome, reason.clone());
20213            let DepError::NomeInvalid {
20214                nome: stored_nome,
20215                reason: stored_reason,
20216            } = via_ctor
20217            else {
20218                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
20219            };
20220            assert_eq!(
20221                stored_nome, nome,
20222                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
20223            );
20224            assert_eq!(
20225                stored_reason, reason,
20226                "reason slot must forward the owned `String` verbatim for {nome:?}"
20227            );
20228        }
20229    }
20230
20231    #[test]
20232    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
20233        // End-to-end pin: the sole in-crate wire-up site
20234        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
20235        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
20236        // the ctor's output on the same DNS-1123-refused `:deps :nome`
20237        // fixture, with identical `Display` rendering. A future silent
20238        // de-lift of the wire-up back to the open-coded struct-literal
20239        // trips this test at caixa-core build time rather than at a
20240        // downstream diagnostic consumer far from the wire-up commit.
20241        // Sibling of the peer
20242        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
20243        // pin on the same wire-up — extended here from a `matches!`
20244        // shape check to a byte-identity + Display parity route through
20245        // the ctor.
20246        let d = Dep::simple("Caixa_Teia", "^0.1");
20247        let observed = d.validate().unwrap_err();
20248        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
20249            .expect_err("fixture must be DNS-1123-refused");
20250        let expected = DepError::nome_invalid("Caixa_Teia", reason);
20251        assert_eq!(
20252            observed, expected,
20253            "Dep::validate's DNS-1123 refusal arm must byte-equal \
20254             nome_invalid(nome, reason)"
20255        );
20256        assert_eq!(
20257            observed.to_string(),
20258            expected.to_string(),
20259            "Display byte-string parity"
20260        );
20261    }
20262}