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    /// Substrate-canonical exhaustive accept-set on the [`DepList`]
3223    /// `:`-prefixed kebab-case tatara-lisp author-surface key axis —
3224    /// the closed two-arm roster of every byte-string [`Self::as_str`]
3225    /// returns, routed byte-for-byte through the paired
3226    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3227    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] lifted `pub const`
3228    /// scalars the [`Self::as_str`] emitter (and the
3229    /// [`std::fmt::Display`] / [`AsRef<str>`] / `From<{Self,&Self}> for
3230    /// {&'static str, String, Cow<'static, str>, Box<str>, Arc<str>}`
3231    /// trait triple + quintuple routed through it) walks, and the same
3232    /// two strings the paired [`Self::from_wire`] reverse projection
3233    /// accepts.
3234    ///
3235    /// Peer of the sibling [`crate::CaixaKind::WIRE_NAMES`] (bd708bd) /
3236    /// [`crate::supervisor::RestartStrategy::WIRE_NAMES`] (3033f45) /
3237    /// [`crate::supervisor::RestartPolicy::WIRE_NAMES`] (ce9412b) /
3238    /// [`crate::aplicacao::PlacementStrategy::WIRE_NAMES`] (3e5b194)
3239    /// rosters on the `PascalCase` wire byte-string axis, the sibling
3240    /// [`crate::CaixaKind::LABELS`] (427fe75) /
3241    /// [`crate::aplicacao::WitShape::LABELS`] (9d9f585) rosters on the
3242    /// lowercase kebab census-label byte-string axis, the sibling
3243    /// [`crate::aplicacao::RateLimitUnit::SUFFIXES`] (b553ec9) roster
3244    /// on the single-char canonical-suffix axis, and the sibling
3245    /// [`crate::upgrade::UpgradeInstruction::LISP_FORMS`] (1898d77) /
3246    /// [`crate::upgrade::UpgradeInstruction::WIRE_FORMS`] (cc42c0e)
3247    /// rosters on the OTP-appup discriminator's two-axis roster split
3248    /// — the same closed-set exhaustive-accept-set roster discipline
3249    /// extended here onto the outer-`Caixa` two-list dep-graph
3250    /// closed-set typed enum, the ninth substrate-side closed-set
3251    /// typed enum on the roster-discipline axis and the last unlifted
3252    /// `&'static str`-carrying closed-set typed enum on the top-level
3253    /// manifest surface (the sibling `AsRef<str>` doc block at
3254    /// [`AsRef<str>`] already names the two-list dep-graph as "the
3255    /// seventh (and last unlifted) closed-set typed enum on the caixa
3256    /// surface" for the trait-idiomatic projection family — the same
3257    /// closure applies here on the exhaustive-roster family).
3258    ///
3259    /// Downstream consumers of the closed accepted-key set — a future
3260    /// `feira dep --list <deps|deps-dev>` CLI arg-parse's "did you
3261    /// mean" hint that scans this slice rather than open-coding a
3262    /// two-string array literal, a future M4
3263    /// `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
3264    /// body enumerating the accepted `:deps` / `:deps-dev` author-
3265    /// surface keys verbatim on an unknown-key miss, a future
3266    /// `feira dep census` per-Caixa `:deps` / `:deps-dev` histogram
3267    /// column that walks the roster to render every arm's tally
3268    /// (including zero-count arms — a hand-rolled projection off
3269    /// [`Self::ALL`] alone would need a companion per-variant-to-key
3270    /// map at every consumer; this roster closes the two-axis walk in
3271    /// one lifted const), any future K8s CRD generation tool that
3272    /// emits the accepted-key enum on the Caixa CR schema, a future
3273    /// [`DepError`] widening that promotes the two `list: &'static
3274    /// str` fields to a typed `list: DepList` carry so downstream
3275    /// consumers dispatch on the enum rather than string-comparing
3276    /// the wire scalar — every consumer that wants to enumerate the
3277    /// closed dep-list author-key set outside caixa-core now reaches
3278    /// for one lifted substrate-primitive roster rather than open-
3279    /// coding a `[":deps", ":deps-dev"]` array-literal whose arm-set
3280    /// has no compile-time link back to the typed [`DepList`] enum.
3281    /// A future arm addition (a `:build-dep` third list once the
3282    /// substrate grows Cargo-style split-graphs, a `:tool-dep` for
3283    /// build-time-only tooling per the peer Cargo
3284    /// `[build-dependencies]` / `[target.<cfg>.dev-dependencies]`
3285    /// future admission surface — both trajectory items the sibling
3286    /// [`Self::from_wire`] doc block already names) extends this
3287    /// roster as a single edit — paired with the [`Self::as_str`]
3288    /// match's compiler-checked exhaustiveness on the new arm — and
3289    /// every consumer picks up the new key by construction rather
3290    /// than a coordinated array-literal rewrite across every
3291    /// downstream site.
3292    ///
3293    /// Length is pinned load-bearing at `DepList::ALL.len()` (two) by
3294    /// [`tests::dep_list_author_keys_covers_every_arm`], every
3295    /// variant's [`Self::as_str`] projection is pinned to a member of
3296    /// the roster on every arm so a silent skew between the emitter's
3297    /// arm-set and this const's arm-set trips at caixa-core test time
3298    /// rather than at a downstream consumer's accepted-set enumeration
3299    /// miss, and every entry is further pinned to open with the ASCII
3300    /// `:` byte (the tatara-lisp author-surface keyword marker) so a
3301    /// silent collapse with any hypothetical peer un-prefixed wire-form
3302    /// axis (an entry byte-identical to a sibling `deps` / `deps-dev`
3303    /// bare-kebab byte-string that would let an author-key-axis
3304    /// consumer accept the un-prefixed vocabulary) trips here rather
3305    /// than at a downstream K8s-CR round-trip miss.
3306    pub const AUTHOR_KEYS: &'static [&'static str] = &[
3307        crate::render::DEP_AUTHOR_KEY_DEPS,
3308        crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3309    ];
3310
3311    /// Canonical author-surface tag every substrate consumer that
3312    /// names the offending dep-list in a diagnostic reaches for —
3313    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3314    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3315    /// the same `&'static str` payload the sibling
3316    /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3317    /// already carry. Routing every dep-list diagnostic through the
3318    /// closed-set enum's `as_str` closes the last `&'static str`-shape
3319    /// literal-carry axis on the two-list dep-graph surface — a
3320    /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3321    /// wire-format promotion (a distinct diagnostic form for the
3322    /// `Dev` arm) reaches every consumer through one edit on the
3323    /// canonical constant, not a coordinated rewrite across the
3324    /// substrate's dep-graph consumers.
3325    #[must_use]
3326    pub const fn as_str(self) -> &'static str {
3327        match self {
3328            Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3329            Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3330        }
3331    }
3332
3333    /// Substrate-canonical reverse projection on the two-list dep-graph
3334    /// axis — parses the author-surface wire tag back to the typed
3335    /// variant, or `None` when `s` is outside the closed-set arm-string
3336    /// set [`Self::as_str`] emits. Dispatches on the same lifted
3337    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3338    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3339    /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3340    /// the round-trip migrate through one caixa-core edit on any future
3341    /// list-axis addition.
3342    ///
3343    /// Prior to this lift the substrate carried only the forward
3344    /// `Self → &str` projection on the two-list dep-graph axis (the
3345    /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3346    /// through it, the two [`DepError::DuplicateNome`] /
3347    /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3348    /// as a `&'static str` `list:` field). Every future consumer that
3349    /// wanted to promote the wire tag back to the typed enum (a future
3350    /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3351    /// wire form into the typed enum before dispatching to
3352    /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3353    /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3354    /// wire re-parse of the per-list diagnostic body, a future
3355    /// [`DepError`] widening that promotes the two `list: &'static str`
3356    /// fields to a typed `list: DepList` carry so downstream consumers
3357    /// dispatch on the enum rather than string-comparing the wire
3358    /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3359    /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3360    /// compile-time link back to the typed [`DepList`] enum. A future
3361    /// variant addition (a `:build-dep` or `:test-dep` third list once
3362    /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3363    /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3364    /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3365    /// would silently split the wire byte-string the emitter walks from
3366    /// the parser's arm-set — the round-trip would carry the new list
3367    /// through the forward projection but land on the fallback silently
3368    /// at every non-updated reverse parser, far from the arm-addition
3369    /// commit that caused the drift. Lifting the resolver to a typed
3370    /// method on the substrate primitive closes the drift footgun by
3371    /// construction: the parser's accept-set is the same set the
3372    /// [`Self::as_str`] emitter walks (routed through the same lifted
3373    /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3374    /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3375    /// of the round-trip migrate through one caixa-core edit on any
3376    /// future list-axis addition.
3377    ///
3378    /// Same closed-set-reverse-projection discipline the sibling
3379    /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3380    /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3381    /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3382    /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3383    /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3384    /// carry on the peer wire-side `str → Self` axes — extended onto
3385    /// the two-list dep-graph closed-set axis, the sixth substrate-side
3386    /// closed-set typed enum on the caixa surface to converge on the
3387    /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3388    /// `from_str`) to match the peer shapes verbatim and side-step the
3389    /// derived [`std::str::FromStr`] impls the sibling
3390    /// [`gen_platform::FromStrKind`]-carrying axes install on their
3391    /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3392    /// (rather than `Result<Self, _>`) to match the peer shapes: the
3393    /// caller picks the diagnostic form appropriate for its use site —
3394    /// a future `feira dep --list …` arg-parse that surfaces
3395    /// `unknown list: <arg>` at the CLI builds one on top by iterating
3396    /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3397    /// path folds `None` onto its per-CR structured refusal body.
3398    #[must_use]
3399    pub fn from_wire(s: &str) -> Option<Self> {
3400        match s {
3401            crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3402            crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3403            _ => None,
3404        }
3405    }
3406}
3407
3408/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3409/// consumer that formats the axis as user-facing text (a future
3410/// `feira app graph` per-list summary, a future M4 admission-webhook
3411/// rejection body naming the offending list, this crate's own
3412/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3413/// typed [`DepList`]) lands on the same author-surface tag the
3414/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3415/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3416/// as-str-through-Display convergence discipline the sibling
3417/// [`crate::aplicacao::PlacementStrategy`],
3418/// [`crate::aplicacao::RateLimitUnit`],
3419/// [`crate::supervisor::RestartStrategy`],
3420/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3421/// closed-set typed enums carry.
3422impl std::fmt::Display for DepList {
3423    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3424        f.write_str(self.as_str())
3425    }
3426}
3427
3428/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3429/// dep-graph closed-set typed enum — routes through the same
3430/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3431/// [`std::fmt::Display`] impl already delegates through, so any future
3432/// consumer that binds a [`DepList`] through the standard-library
3433/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3434/// that composes the canonical author-surface tag into a
3435/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3436/// `tracing::field::Value::Str`-arm structured-log recorder on the
3437/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3438/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3439/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3440/// webhook's per-list rejection-body composition table) reaches the
3441/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3442/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3443/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3444/// re-inlining at every wire-up.
3445///
3446/// Same "route the trait impl through the substrate-primitive
3447/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3448/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3449/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3450/// [`AsRef<str>`] impl (cd2091f), the M3
3451/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3452/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3453/// [`AsRef<str>`] impl (419ea81), the M2
3454/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3455/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3456/// (16d5c7e) carry — closes the substrate primitive's
3457/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3458/// closed-set typed enum on the caixa surface: the two-list dep-graph
3459/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3460/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3461/// bound the enum through the standard-library `AsRef<str>` trait had
3462/// to reach the canonical byte-string through an open-coded
3463/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3464/// peer closed-set typed enums already admit.
3465///
3466/// Pinned load-bearing by
3467/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3468/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3469/// closed set) and
3470/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3471/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3472/// resolve to the same byte-string per arm) — any future silent detour
3473/// that routes the impl through a divergent projection (a per-arm
3474/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3475/// that opens a compile-time link to the un-lifted arm-literal, a
3476/// swap onto a second projection axis) trips at caixa-core test time
3477/// under `assert_eq!` rather than at a downstream
3478/// `impl AsRef<str>`-bound consumer's silent split.
3479impl AsRef<str> for DepList {
3480    fn as_ref(&self) -> &str {
3481        self.as_str()
3482    }
3483}
3484
3485/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3486/// [`DepList`] closed-set typed enum — routes through the paired
3487/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3488/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3489/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3490/// through, rather than an open-coded per-arm
3491/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3492/// has no compile-time link back to the substrate primitive.
3493///
3494/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3495/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3496/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3497/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3498/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3499/// which silently omitted [`DepList`] despite this enum being listed
3500/// as a sibling closed-set fieldless typed enum in every peer's
3501/// docstring). Every sibling closed-set fieldless typed enum on the
3502/// caixa surface now carries both trait-idiomatic axes
3503/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3504/// against the substrate-primitive canonical projection accessors
3505/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3506/// closed-set is the fifteenth and true-final peer.
3507///
3508/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3509/// `Option<Self>` return-shape's deliberate deferral of error typing:
3510/// the caller picks the diagnostic form appropriate for its use site
3511/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3512/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3513/// the M4 admission-webhook rejection body wraps `Err(())` with the
3514/// accepted-set enumeration).
3515///
3516/// Pinned load-bearing by
3517/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3518/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3519/// accept-set) and
3520/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3521/// (rejection witness against silent accept-set widening).
3522impl TryFrom<&str> for DepList {
3523    type Error = ();
3524
3525    fn try_from(s: &str) -> Result<Self, Self::Error> {
3526        Self::from_wire(s).ok_or(())
3527    }
3528}
3529
3530/// Trait-idiomatic *forward* projection on the two-list dep-graph
3531/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3532/// routes byte-for-byte through the paired substrate-primitive
3533/// [`DepList::as_str`] `pub const fn` accessor so
3534/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3535/// reaches the same two-arm lifted
3536/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3537/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3538/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3539/// surfaces already return.
3540///
3541/// Closes the substrate-wide trait-idiomatic forward-projection
3542/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3543/// via 523157d and traced through the 13 sibling closed-set typed
3544/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3545/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3546/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3547/// every peer's docstring naming it as a sibling. Paired with the
3548/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3549/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3550/// idiomatic axis pair, mirroring the pre-existing method-named
3551/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3552/// substrate-primitive axis pair.
3553///
3554/// The paired [`DepList::as_str`] returns `&'static str` by
3555/// construction — each arm resolves to a
3556/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3557/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3558/// static lifetime — so the trait's return-type promise is upheld
3559/// structurally.
3560///
3561/// Pinned load-bearing by
3562/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3563/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3564/// emit-set, plus a `const`-context materialization witness for the
3565/// `&'static str` lifetime promise) and
3566/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3567/// (partition pin + two-way round-trip through the paired
3568/// [`TryFrom<&str>`] axis).
3569impl From<DepList> for &'static str {
3570    fn from(list: DepList) -> &'static str {
3571        list.as_str()
3572    }
3573}
3574
3575/// Trait-idiomatic *forward* projection on the two-list dep-graph
3576/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3577/// `&'static str` axis — the borrowed-input companion to the paired
3578/// owned-input [`From<DepList> for &'static str`] impl immediately
3579/// above. Routes byte-for-byte through the same substrate-primitive
3580/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3581/// binds a `&DepList` through the standard-library `.into()` /
3582/// [`From<&Self> for &'static str`] axis (a
3583/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3584/// per-arm accept-set materializer that iterates the substrate-
3585/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3586/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3587/// forces every call site through an explicit `.copied()` /
3588/// dereference / [`Copy`]-bound restatement rather than the direct
3589/// trait-idiomatic projection; a future generic
3590/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3591/// that walks the `iter().map(Into::into)` shape verbatim; the future
3592/// M4 admission-webhook rejection body that composes the accepted-set
3593/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3594/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3595/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3596/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3597/// owned-input [`From<DepList> for &'static str`], the sibling
3598/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3599/// surfaces already return.
3600///
3601/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3602/// forward-projection family on the last-touched closed-set fieldless
3603/// typed enum — first-mover on the borrowed-input axis, mirroring the
3604/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3605/// input axis (523157d). Rust's `From` trait does not auto-derive the
3606/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3607/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3608/// in `core`), so every closed-set typed enum that carries the
3609/// owned-input axis but not the borrowed-input axis forces every
3610/// borrowed-input call site through a `.copied()` /
3611/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3612/// bounds have no compile-time link to the substrate primitive. The
3613/// remaining fourteen substrate-wide closed-set fieldless typed enum
3614/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3615/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3616/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3617/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3618/// of this campaign.
3619///
3620/// Pinned load-bearing by
3621/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3622/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3623/// emit-set via a borrowed input, plus a `const`-context materialization
3624/// witness) and
3625/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3626/// (cross-axis partition pin against the paired owned-input
3627/// [`From<DepList> for &'static str`] impl).
3628impl From<&DepList> for &'static str {
3629    fn from(list: &DepList) -> &'static str {
3630        list.as_str()
3631    }
3632}
3633
3634/// Trait-idiomatic *forward* projection on the two-list dep-graph
3635/// [`DepList`] closed-set typed enum from an *owned* input onto the
3636/// owned-[`String`] axis — routes byte-for-byte through the
3637/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3638/// every consumer that binds a [`DepList`] through the standard-library
3639/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3640/// axis reaches the same two-arm lifted
3641/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3642/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3643/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3644/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3645/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3646///
3647/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3648/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3649/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3650/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3651/// second-of-two-in-M2 per-child restart-decision axis, then onto
3652/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3653/// closed-set fieldless typed enum on the caixa surface, then onto
3654/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3655/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3656/// Rust's standard library does not carry a blanket
3657/// `impl<T: AsRef<str>> From<T> for String` (nor an
3658/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3659/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3660/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3661/// quadruple but not the owned-[`String`] axis forces every owned-string
3662/// call site through a `.to_string()` / `.as_str().to_owned()` /
3663/// `String::from(list.as_str())` detour whose type bounds have no
3664/// compile-time link to the substrate primitive.
3665///
3666/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3667/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3668/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3669/// share one vocabulary by construction — `PascalCase` on the three
3670/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3671/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3672/// emit and [`DepList::from_wire`] parse resolve through the same
3673/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3674/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3675/// (there is no wire/diagnostic axis split on this enum — both halves
3676/// of the round-trip route through the same two `pub const &str` values),
3677/// so the owned-[`String`] forward projection this impl exposes composes
3678/// directly with the paired trait-idiomatic reverse
3679/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3680/// borrow — no intermediate wire-vocab hop like the peer
3681/// [`crate::CaixaKind`] axis pair requires.
3682///
3683/// The remaining ten closed-set typed enums on the caixa substrate
3684/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3685/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3686/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3687/// this campaign — each carries the same paired [`AsRef<str>`] /
3688/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3689/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3690/// axis extends onto.
3691///
3692/// Pinned load-bearing by
3693/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3694/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3695/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3696/// witness) and
3697/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3698/// (cross-axis partition against the sibling owned-`&'static str` axis
3699/// and the [`ToString::to_string`] surface, a
3700/// `.iter().copied().map(String::from)` pipe witness over
3701/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3702/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3703/// borrow — composes directly without the wire-vocab intermediate hop
3704/// the peer [`crate::CaixaKind`] axis pair requires).
3705impl From<DepList> for String {
3706    fn from(list: DepList) -> String {
3707        list.as_str().to_owned()
3708    }
3709}
3710
3711/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3712/// projection on the two-list dep-graph [`DepList`] closed-set typed
3713/// enum — the fourth (and closing) corner of the
3714/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3715/// projection family on this enum, mirror of the peer M2 OTP-shape
3716/// [`From<&RestartStrategy> for String`] (579385f) and
3717/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3718/// closed the corner on the sibling supervisor-level restart-strategy
3719/// and per-child restart-decision enums. Routes byte-for-byte through
3720/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3721/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3722/// [`&DepList`] and needs an owned [`String`] — a future
3723/// `serde_json::Value::String(String::from(&list))` structured-payload
3724/// composer over a borrowed field, a future `Iterator::map` over
3725/// `&[DepList]` that projects to owned keys through
3726/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3727/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3728/// alone forces every call site through an explicit `.copied()` /
3729/// spurious [`Copy`] deref restatement rather than the direct trait-
3730/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3731/// that keys off a borrowed-iteration axis where dereferencing the list
3732/// would force an unnecessary `Copy` at every step, the future
3733/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3734/// per-list author-surface-tag diagnostic emit whose iteration axis is
3735/// borrowed by construction — reaches the same two-arm lifted
3736/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3737/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3738/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3739/// three other trait-idiomatic forward-projection impls
3740/// ([`From<DepList> for &'static str`],
3741/// [`From<&DepList> for &'static str`],
3742/// [`From<DepList> for String`]) already return.
3743///
3744/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3745/// owned-`String` output* forward-projection family opened on
3746/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3747/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3748/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3749/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3750/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3751/// standard library does not carry a blanket
3752/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3753/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3754/// typed enum that carries the paired `AsRef<str>` / `Display` /
3755/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3756/// `From<Self> for String` quintuple but not the borrowed-input owned-
3757/// [`String`] axis forces every borrowed-input owned-string call site
3758/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3759/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3760/// whose type bounds have no compile-time link to the substrate
3761/// primitive.
3762///
3763/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3764/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3765/// axis pairs (whose forward emit and reverse parse share one
3766/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3767/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3768/// [`DepList::from_wire`] parse resolve through the same lifted
3769/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3770/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3771/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3772/// tags — there is no wire/diagnostic axis split on this enum), so the
3773/// borrowed-input owned-[`String`] projection this impl exposes
3774/// composes directly with the paired trait-idiomatic reverse
3775/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3776/// borrow — no intermediate wire-vocab hop like the peer
3777/// [`crate::CaixaKind`] axis pair requires.
3778///
3779/// The remaining ten closed-set typed enums on the caixa substrate
3780/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3781/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3782/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3783/// are the future targets of this 2×2-completion campaign — each
3784/// carries the same paired quintuple that this borrowed-input owned-
3785/// [`String`] axis extends onto.
3786///
3787/// Pinned load-bearing by
3788/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3789/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3790/// emit-set through the borrowed-input surface) and
3791/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3792/// (cross-axis partition pin against the paired owned-input owned-
3793/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3794/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3795/// impl, and the sibling [`ToString::to_string`] surface routed through
3796/// [`std::fmt::Display`], plus a direct round-trip witness through
3797/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3798/// borrow that closes the two-way `&Self → String → Self` round-trip
3799/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3800/// reverse axis pair).
3801impl From<&DepList> for String {
3802    fn from(list: &DepList) -> String {
3803        list.as_str().to_owned()
3804    }
3805}
3806
3807/// Trait-idiomatic *forward* projection on the two-list dep-graph
3808/// [`DepList`] closed-set typed enum from an *owned* input onto the
3809/// borrowed-heap-string [`std::borrow::Cow<'static, str>`] axis —
3810/// routes byte-for-byte through the substrate-primitive
3811/// [`DepList::as_str`] `pub const fn` accessor (via
3812/// [`std::borrow::Cow::Borrowed`]) so every consumer that binds a
3813/// [`DepList`] through the standard-library `.into()` /
3814/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
3815/// [`Into<std::borrow::Cow<'static, str>>`]) axis reaches the same
3816/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3817/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] canonical `pub const
3818/// &str` values the paired [`From<DepList> for &'static str`],
3819/// [`From<&DepList> for &'static str`], [`From<DepList> for String`],
3820/// and [`From<&DepList> for String`] 2×2 trait-idiomatic forward-
3821/// projection corners, the sibling [`std::fmt::Display`],
3822/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return,
3823/// rather than an open-coded per-call-site
3824/// `std::borrow::Cow::Borrowed(list.as_str())` /
3825/// `std::borrow::Cow::Owned(list.to_string())` composition whose
3826/// type bounds have no compile-time link back to the substrate
3827/// primitive.
3828///
3829/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3830/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3831/// [`DepList::as_str`] accessor's return carries the `&'static str`
3832/// lifetime by construction (each `match` arm resolves to one of
3833/// the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3834/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3835/// values with static lifetime), so the zero-alloc borrowed arm is
3836/// the type-correct projection with no runtime allocation. The
3837/// paired [`std::borrow::Cow::Owned`] arm stays reachable at the
3838/// call site through the existing [`From<DepList> for String`] axis
3839/// composed with [`std::borrow::Cow::from`] on the resulting owned
3840/// [`String`] — a caller who chose to mutate the projection lands
3841/// on the owned arm by their own composition, not by the substrate-
3842/// primitive projection silently allocating on their behalf.
3843///
3844/// Rust's standard library carries no blanket `impl<T: AsRef<str>>
3845/// From<T> for Cow<'static, str>` (nor an `impl<T: fmt::Display>
3846/// From<T> for Cow<'static, str>`), so the paired sibling
3847/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3848/// [`AsRef<str>`], and [`std::fmt::Display`] surfaces do not
3849/// implicitly extend to a [`std::borrow::Cow<'static, str>`]-bound
3850/// call site — every such site is forced through a
3851/// `Cow::Borrowed(list.as_str())` / `Cow::Owned(list.to_string())`
3852/// open-code whose type bounds have no compile-time link back to
3853/// the substrate primitive until this lift.
3854///
3855/// First-mover on the outside-M3 substrate-wide tier of the
3856/// substrate-wide trait-idiomatic [`std::borrow::Cow<'static, str>`]
3857/// forward-projection campaign, opening the tier on the first
3858/// caixa-core-internal closed-set fieldless typed enum peer outside
3859/// the M2 OTP-shape and M3 mesh-shape tiers. The
3860/// [`crate::CaixaKind`] top-level first-mover
3861/// (99c1735 owned-input, d45c409 borrowed-input) opened the axis on
3862/// the structurally most fundamental closed-set fieldless typed
3863/// enum; the paired M2 OTP-shape
3864/// [`crate::supervisor::RestartStrategy`] (7dd28b3, 9b3e4b3) and
3865/// [`crate::supervisor::RestartPolicy`] (0612398, ee577fd) closed
3866/// the M2 OTP-shape tier; the paired M3-mesh-shape
3867/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3868/// (8634dec, 25690ef), [`crate::aplicacao::PlacementStrategy`]
3869/// `:placement :estrategia` distribution-strategy (eee504d,
3870/// afdf0f4), and [`crate::aplicacao::RateLimitUnit`] `:politicas
3871/// :rate-limit` canonical-suffix (1d59925, `From<&RateLimitUnit>`
3872/// Cow closer) closed the M3-mesh-shape tier. The remaining
3873/// outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3874/// [`crate::render::PathShapeViolation`]) and the outside-
3875/// `caixa-core` peers (`InvariantKind`, `ArchVerdict`, `Severity`,
3876/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the remaining
3877/// future targets of this campaign; the paired borrowed-input
3878/// [`From<&DepList> for std::borrow::Cow<'static, str>`]
3879/// `{Self, &Self}`-closer on this outside-M3-tier-opening peer is
3880/// the next commit's target.
3881///
3882/// Same three-path convergence discipline as the paired sibling
3883/// [`From<DepList> for &'static str`] / [`From<DepList> for String`]
3884/// / [`std::fmt::Display`] / [`AsRef<str>`] surfaces (this
3885/// [`std::borrow::Cow<'static, str>`] axis, the paired sibling
3886/// surfaces, and [`DepList::as_str`] all route through the same two
3887/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3888/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3889/// values by construction), so a future variant addition, rename,
3890/// or per-arm wire-tag drift reaches every forward-projection path
3891/// through exactly one caixa-core edit at the [`DepList::as_str`]
3892/// `match` head.
3893///
3894/// Pinned load-bearing by
3895/// [`tests::dep_list_from_into_static_cow_str_routes_through_as_str_accessor`]
3896/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3897/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`])
3898/// and
3899/// [`tests::dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3900/// (cross-axis partition pin against the paired
3901/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3902/// and [`ToString`]-through-[`std::fmt::Display`] axes, plus a
3903/// `.iter().copied().map(Cow::from)` pipe witness over
3904/// [`DepList::ALL`] that materializes the two-arm accept-set through
3905/// the [`std::borrow::Cow<'static, str>`] axis alone and pins the
3906/// zero-alloc discipline on every element).
3907impl From<DepList> for std::borrow::Cow<'static, str> {
3908    fn from(list: DepList) -> std::borrow::Cow<'static, str> {
3909        std::borrow::Cow::Borrowed(list.as_str())
3910    }
3911}
3912
3913/// Trait-idiomatic *borrowed-input, [`std::borrow::Cow<'static, str>`]
3914/// output* forward projection on the two-list dep-graph [`DepList`]
3915/// closed-set typed enum — the borrowed-input companion to the paired
3916/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] impl
3917/// immediately above (6858bac). Routes byte-for-byte through the same
3918/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor (via
3919/// [`std::borrow::Cow::Borrowed`]) so every consumer that holds a
3920/// `&DepList` and needs a [`std::borrow::Cow<'static, str>`] — a
3921/// `DepList::ALL.iter().map(std::borrow::Cow::from).collect::<Vec<_>>()`
3922/// per-arm accept-set materializer whose iterator over
3923/// `&'static [DepList]` yields `&DepList` (not `DepList`, so the paired
3924/// owned-input [`From<DepList> for std::borrow::Cow<'static, str>`] axis
3925/// alone forces every call site through an explicit `.copied()` /
3926/// dereference / [`Copy`]-bound restatement rather than the direct
3927/// trait-idiomatic projection), a future generic
3928/// `<T: for<'a> Into<std::borrow::Cow<'static, str>>>`-bound emitter on
3929/// a per-`:deps` / `:deps-dev` diagnostic column that walks the
3930/// `iter().map(Into::into)` shape verbatim, the future M4
3931/// `caixa.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection body
3932/// that composes the accepted-`:deps` / `:deps-dev` list-key enumeration
3933/// from an iterated `DepList::ALL.iter().map(|l| l.into())` pipe rather
3934/// than a per-arm `match l { … }` cascade — reaches the same two-arm
3935/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3936/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3937/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], the four
3938/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3939/// forward-projection corners, and the paired owned-input
3940/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl already
3941/// return.
3942///
3943/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3944/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3945/// [`DepList::as_str`] accessor's return carries the `&'static str`
3946/// lifetime by construction (each `match` arm resolves to one of the
3947/// two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3948/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3949/// byte-strings with static lifetime), so the zero-alloc borrowed arm
3950/// is the type-correct projection with no runtime allocation on the
3951/// borrowed-input surface just as on the paired owned-input surface.
3952///
3953/// Closes the `{Self, &Self}` input-shape corner on the outside-M3
3954/// caixa-core two-list dep-graph [`std::borrow::Cow<'static, str>`]
3955/// axis opened one commit prior (6858bac) on the paired owned-input
3956/// [`From<DepList> for std::borrow::Cow<'static, str>`] impl — first
3957/// outside-M3 caixa-core peer on the axis, one commit after the paired
3958/// M3-mesh-shape [`crate::aplicacao::RateLimitUnit`] `:politicas
3959/// :rate-limit` canonical-suffix (1d59925), the paired M3-mesh-shape
3960/// [`crate::aplicacao::PlacementStrategy`] `:placement :estrategia`
3961/// distribution-strategy (eee504d + afdf0f4), the paired M3-mesh-shape
3962/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3963/// (8634dec + 25690ef), the paired M2 OTP-shape
3964/// [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3) and
3965/// [`crate::supervisor::RestartPolicy`] (0612398 + ee577fd), and the
3966/// paired top-level [`crate::CaixaKind`] (99c1735 + d45c409) peers
3967/// closed the M3-mesh-shape, M2-OTP-shape, and top-level tiers.
3968/// Rust's standard library does not carry a blanket
3969/// `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor an
3970/// `impl<T: fmt::Display> From<&T> for Cow<'static, str>`), so every
3971/// closed-set fieldless typed enum peer on the substrate that carries
3972/// the paired owned-input [`Cow<'static, str>`] axis but not the
3973/// borrowed-input axis forces every borrowed-input
3974/// [`Cow<'static, str>`]-parameterized call site through a spurious
3975/// [`Copy`] deref (`std::borrow::Cow::from(*list)`) or a
3976/// `std::borrow::Cow::Borrowed(list.as_str())` open-code whose type
3977/// bounds have no compile-time link to the substrate primitive.
3978///
3979/// The remaining outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3980/// [`crate::render::PathShapeViolation`]) and the outside-`caixa-core`
3981/// peers (`InvariantKind`, `ArchVerdict`, `Severity`, `FixSafety`,
3982/// `Semantic`, `FerriteRuntime`) are the remaining future targets of
3983/// the campaign; closing this borrowed-input corner on [`DepList`]
3984/// leaves [`crate::CaixaDialeto`] as the next outside-M3 caixa-core
3985/// closed-set fieldless typed enum peer target on the
3986/// [`std::borrow::Cow<'static, str>`] axis.
3987///
3988/// Same three-path convergence discipline as the paired sibling
3989/// [`From<&DepList> for &'static str`], [`From<&DepList> for String`],
3990/// [`std::fmt::Display`], and [`AsRef<str>`] surfaces (this borrowed-
3991/// input [`std::borrow::Cow<'static, str>`] axis, the paired owned-
3992/// input [`From<DepList> for std::borrow::Cow<'static, str>`] axis, the
3993/// paired sibling `{Self, &Self} × {&'static str, String}` 2×2 corners,
3994/// and [`DepList::as_str`] all route through the same two lifted
3995/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3996/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` values
3997/// by construction), so a future variant addition, rename, or per-arm
3998/// wire-tag drift reaches every forward-projection path through
3999/// exactly one caixa-core edit at the [`DepList::as_str`] `match` head.
4000///
4001/// Pinned load-bearing by
4002/// [`tests::dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor`]
4003/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
4004/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`]
4005/// through the borrowed-input surface) and
4006/// [`tests::dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
4007/// (cross-axis partition pin against the paired owned-input
4008/// [`From<DepList> for std::borrow::Cow<'static, str>`], the paired
4009/// borrowed-input owned-`&'static str` [`From<&DepList> for &'static
4010/// str`], and the paired borrowed-input owned-`String` [`From<&DepList>
4011/// for String`] impls, plus a `.iter().map(std::borrow::Cow::from)`
4012/// pipe witness over [`DepList::ALL`] — whose iterator yields
4013/// `&DepList` by construction, so the borrowed-input
4014/// [`std::borrow::Cow<'static, str>`] axis is what routes the pipe
4015/// through the substrate-primitive [`DepList::as_str`] accessor with
4016/// the zero-alloc [`std::borrow::Cow::Borrowed`] arm by construction
4017/// and without a spurious [`Copy`] deref).
4018impl From<&DepList> for std::borrow::Cow<'static, str> {
4019    fn from(list: &DepList) -> std::borrow::Cow<'static, str> {
4020        std::borrow::Cow::Borrowed(list.as_str())
4021    }
4022}
4023
4024/// Trait-idiomatic *owned-input, [`Box<str>`] output* forward projection on
4025/// the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4026/// fieldless typed enum. Routes byte-for-byte through the substrate-
4027/// primitive [`DepList::as_str`] `pub const fn` accessor via
4028/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4029/// that binds a `let key: Box<str> = list.into();`-shaped call site — a
4030/// per-`:deps` / `:deps-dev` census-key materializer that stashes the
4031/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4032/// cheap clone off an owned handle, a future M4
4033/// [`caixa.pleme.io/v1alpha1/Caixa`] CR materializer's per-list admission-
4034/// webhook rejection body whose per-arm [`Box<str>`] field composes from
4035/// an owned [`DepList`] handle naming the accepted-list-tag list, a future
4036/// `feira lint --explain-dep-list=<axis>` per-arm listing that stashes
4037/// each arm as an owned [`Box<str>`] label — reaches the same two lifted
4038/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4039/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4040/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4041/// forward-projection corner already returns.
4042///
4043/// Rust's standard library carries `impl From<&str> for Box<str>` and
4044/// `impl From<String> for Box<str>` but no blanket
4045/// `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a distinct
4046/// trait-idiomatic surface that a downstream `DepList → Box<str>`
4047/// `.into()` reaches through this impl and no other — without a
4048/// `Box::from(list.as_str())` open-code whose type bounds have no
4049/// compile-time link back to the substrate primitive.
4050///
4051/// Extends the caixa-core-internal tier of the substrate-wide trait-
4052/// idiomatic [`Box<str>`] forward-projection campaign onto the second
4053/// caixa-core-internal peer, after the render-side path-shape-diagnostic
4054/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4055/// one axis) opened the tier. Follows the M2 OTP-shape
4056/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4057/// pair (59ae5dc + cb1d068), the M3 mesh-shape
4058/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4059/// [`crate::aplicacao::RateLimitUnit`] triple (6d73e84 → df7040c) that
4060/// closed the M3 mesh-shape tier, and the outside-`caixa-core` tier
4061/// (`InvariantKind` 10613a7 + 5901887, `ArchVerdict` 3e08f5a + c4319a8,
4062/// `Severity` 5116c95, `FixSafety` cf0174b, `Semantic` 0cd7dc3,
4063/// `FerriteRuntime` 14886a8) that closed one tier prior. Same discipline
4064/// as those peers: forward emit (this impl, the sibling `{&'static str,
4065/// String, Cow<'static, str>}` forward-projection corner, [`std::fmt::Display`],
4066/// [`AsRef<str>`], [`DepList::as_str`]) and reverse parse
4067/// ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the same two
4068/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4069/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4070/// by construction, so the round-trip composes directly without the
4071/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4072/// requires.
4073///
4074/// A future variant addition (a `Build` build-time-only dep-list axis the
4075/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4076/// `[build-dependencies]` table gains substrate visibility) reaches the
4077/// paired [`Box<str>`] output axis through one match-arm edit on the
4078/// [`DepList::as_str`] `pub const fn` accessor, not a coordinated rewrite
4079/// of every downstream `Box::from(list.as_str())` open-code.
4080///
4081/// Pinned load-bearing by
4082/// [`tests::dep_list_from_into_box_str_routes_through_as_str_accessor`]
4083/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4084/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4085/// derived [`Into`] shape witness).
4086impl From<DepList> for Box<str> {
4087    fn from(list: DepList) -> Box<str> {
4088        Box::<str>::from(list.as_str())
4089    }
4090}
4091
4092/// Trait-idiomatic *borrowed-input, [`Box<str>`] output* forward projection
4093/// on the outside-M3 caixa-core two-list dep-graph [`DepList`] closed-set
4094/// fieldless typed enum. Routes byte-for-byte through the substrate-
4095/// primitive [`DepList::as_str`] `pub const fn` accessor via
4096/// [`Box::<str>::from`] on the returned `&'static str`, so every consumer
4097/// that binds a `let key: Box<str> = (&list).into();`-shaped call site or
4098/// a `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
4099/// iterator over `&'static [DepList]` yields `&DepList` by construction)
4100/// — a per-`:deps` / `:deps-dev` census-key materializer that stashes the
4101/// dep-list discriminator in a [`Box<str>`]-typed heap-owned scalar for
4102/// cheap clone off a borrowed handle, a future M4 admission-webhook
4103/// rejection body whose per-arm [`Box<str>`] field composes from a
4104/// borrowed [`DepList`] handle off a `&DepList` borrow, a future
4105/// `feira lint --explain-dep-list` per-axis listing that iterates
4106/// [`DepList::ALL`] into per-arm owned [`Box<str>`] labels — reaches the
4107/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4108/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4109/// the sibling `{Self, &Self} × {&'static str, String, Cow<'static, str>}`
4110/// forward-projection corner and the paired owned-input
4111/// [`From<DepList> for Box<str>`] already return.
4112///
4113/// Rust's standard library carries `impl From<&str> for Box<str>` and
4114/// `impl From<String> for Box<str>` but no blanket
4115/// `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
4116/// `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-input
4117/// axis is a distinct trait-idiomatic surface that the pipe shape
4118/// [`DepList::ALL`]`.iter().map(Box::<str>::from)` reaches through this
4119/// impl and no other — without it, the same pipe would force an explicit
4120/// `.copied()` restatement (`.iter().copied().map(Box::<str>::from)`)
4121/// whose type bounds have no compile-time link back to the substrate
4122/// primitive, and a `let key: Box<str> = (&list).into();`-shaped call
4123/// site would force an explicit `Copy` deref (`Box::<str>::from(*list)`)
4124/// or a `Box::<str>::from(list.as_str())` open-code with the same defect.
4125///
4126/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4127/// core-internal closed-set fieldless typed enum peer of the substrate-
4128/// wide trait-idiomatic [`Box<str>`] forward-projection campaign — one
4129/// commit after the paired render-side path-shape-diagnostic
4130/// [`crate::render::PathShapeViolation`] pair (0d87a72) opened the caixa-
4131/// core-internal tier — matching the trajectory the paired caixa-theme
4132/// [`caixa_theme::style::Semantic`] pair (0cd7dc3, both corners in one
4133/// axis), the caixa-provedor [`caixa_provedor::FerriteRuntime`] pair
4134/// (14886a8, both corners in one axis), and the render-side
4135/// [`crate::render::PathShapeViolation`] pair (0d87a72, both corners in
4136/// one axis) walked before it.
4137///
4138/// Same discipline as the paired outside-`caixa-core`,
4139/// [`crate::supervisor`], [`crate::aplicacao`], and [`crate::render`]
4140/// [`Box<str>`] `{Self, &Self}`-closers: forward emit (this impl, the
4141/// paired owned-input [`From<DepList> for Box<str>`] impl, the sibling
4142/// `{&'static str, String, Cow<'static, str>}` forward-projection corner,
4143/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`]) and reverse
4144/// parse ([`DepList::from_wire`], [`TryFrom<&str>`]) route through the
4145/// same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4146/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4147/// by construction, so the round-trip composes directly without the
4148/// wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis pair
4149/// requires.
4150///
4151/// Pinned load-bearing by
4152/// [`tests::dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor`]
4153/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4154/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4155/// blanket-derived [`Into`] shape witness, plus a
4156/// `.iter().map(Box::<str>::from)` pipe witness over [`DepList::ALL`] —
4157/// whose iterator yields `&DepList` by construction, so the borrowed-
4158/// input [`Box<str>`] axis is what routes the pipe through the substrate-
4159/// primitive [`DepList::as_str`] accessor without a spurious [`Copy`]
4160/// deref).
4161impl From<&DepList> for Box<str> {
4162    fn from(list: &DepList) -> Box<str> {
4163        Box::<str>::from(list.as_str())
4164    }
4165}
4166
4167/// Trait-idiomatic *owned-input, [`std::sync::Arc<str>`] output* forward
4168/// projection on the outside-M3 caixa-core two-list dep-graph [`DepList`]
4169/// closed-set fieldless typed enum. Routes byte-for-byte through the
4170/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor via
4171/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4172/// every consumer that binds a
4173/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4174/// the same two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4175/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-strings
4176/// the sibling
4177/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4178/// forward-projection corner already returns.
4179///
4180/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4181/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4182/// `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
4183/// `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so this axis
4184/// is a distinct trait-idiomatic surface that a
4185/// `let key: std::sync::Arc<str> = list.into();`-shaped call site reaches
4186/// through this impl and no other — a paired
4187/// `std::sync::Arc::<str>::from(list.as_str())` open-code has no compile-
4188/// time link back to the substrate primitive, and a two-step
4189/// `std::sync::Arc::<str>::from(String::from(list))` composition through
4190/// the owned-`String` axis allocates twice (once into the intermediate
4191/// `String`, once into the [`std::sync::Arc<str>`] on the `From<String>`
4192/// conversion) where the single-step trait impl allocates once. The
4193/// shared-ownership + [`Sync`] + [`Send`] contract [`std::sync::Arc<str>`]
4194/// provides is the distinct value the sibling [`Box<str>`] axis's owned-
4195/// move return-shape cannot provide — a per-`:deps` / `:deps-dev` census
4196/// key reachable from multiple concurrent per-Caixa reconcile / per-lint
4197/// tasks through the same two lifted
4198/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4199/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-strings, without a
4200/// `.clone()`-per-task materialization the owned-move [`Box<str>`] axis
4201/// would force.
4202///
4203/// Extends the caixa-core-internal tier of the substrate-wide trait-
4204/// idiomatic [`std::sync::Arc<str>`] forward-projection campaign onto the
4205/// second caixa-core-internal peer, after the top-level
4206/// [`crate::CaixaKind`] pair (c17be64, both corners in one axis) opened
4207/// the tier. Follows the M2 OTP-shape
4208/// [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
4209/// pair (bca2ec8 + b3e72d7 / b05724e + ea91551), the M3 mesh-shape
4210/// [`crate::aplicacao::PlacementStrategy`] / [`crate::aplicacao::WitShape`] /
4211/// [`crate::aplicacao::RateLimitUnit`] triple (977d577 → dae722f), and
4212/// the outside-`caixa-core` tier (`InvariantKind` 4e923c1 + 03c043f,
4213/// `ArchVerdict` 1682f8b + 92ddfb2, `Severity` a7a9a6d + 4f041e1,
4214/// `FixSafety` fb73edb + 822138e, `Semantic` 65dbcff + f3a55c7,
4215/// `FerriteRuntime` 938d915 + 0afef4b) that closed prior tiers on this
4216/// same Arc<str> axis. Same discipline as those peers: forward emit
4217/// (this impl, the sibling
4218/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4219/// forward-projection corner, [`std::fmt::Display`], [`AsRef<str>`],
4220/// [`DepList::as_str`]) and reverse parse ([`DepList::from_wire`],
4221/// [`TryFrom<&str>`]) route through the same two lifted
4222/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4223/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4224/// strings by construction, so the round-trip composes directly without
4225/// the wire-vocab intermediate hop the peer [`crate::CaixaKind`] axis
4226/// pair requires.
4227///
4228/// A future variant addition (a `Build` build-time-only dep-list axis the
4229/// CAIXA-SDLC hints name as a trajectory item once the Cargo
4230/// `[build-dependencies]` table gains substrate visibility) reaches the
4231/// paired [`std::sync::Arc<str>`] output axis through one match-arm edit
4232/// on the [`DepList::as_str`] `pub const fn` accessor, not a coordinated
4233/// rewrite of every downstream
4234/// `std::sync::Arc::<str>::from(list.as_str())` open-code.
4235///
4236/// Pinned load-bearing by
4237/// [`tests::dep_list_from_into_arc_str_routes_through_as_str_accessor`]
4238/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4239/// [`DepList::ALL`] emit-set on the owned-input surface, plus a blanket-
4240/// derived [`Into`] shape witness and cross-axis byte-parity pins against
4241/// the sibling owned-input
4242/// `{&'static str, String, Cow<'static, str>, Box<str>}` return-shape
4243/// axes).
4244impl From<DepList> for std::sync::Arc<str> {
4245    fn from(list: DepList) -> std::sync::Arc<str> {
4246        std::sync::Arc::<str>::from(list.as_str())
4247    }
4248}
4249
4250/// Trait-idiomatic *borrowed-input, [`std::sync::Arc<str>`] output*
4251/// forward projection on the outside-M3 caixa-core two-list dep-graph
4252/// [`DepList`] closed-set fieldless typed enum — the borrowed-input
4253/// companion to the paired owned-input
4254/// [`From<DepList> for std::sync::Arc<str>`] impl immediately above.
4255/// Routes byte-for-byte through the substrate-primitive
4256/// [`DepList::as_str`] `pub const fn` accessor via
4257/// [`std::sync::Arc::<str>::from`] on the returned `&'static str`, so
4258/// every consumer that binds a
4259/// `let key: std::sync::Arc<str> = (&list).into();`-shaped call site or a
4260/// `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped pipe
4261/// (whose iterator over `&'static [DepList]` yields `&DepList` by
4262/// construction) reaches the same two lifted
4263/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4264/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` byte-
4265/// strings the paired owned-input
4266/// [`From<DepList> for std::sync::Arc<str>`] and the sibling
4267/// `{Self, &Self} × {&'static str, String, Cow<'static, str>, Box<str>}`
4268/// forward-projection corner already return.
4269///
4270/// Rust's standard library carries `impl From<&str> for std::sync::Arc<str>`
4271/// and `impl From<String> for std::sync::Arc<str>` but no blanket
4272/// `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a `Copy`-
4273/// based `impl<T: Copy, U: From<T>> From<&T> for U`), so this borrowed-
4274/// input axis is a distinct trait-idiomatic surface that the pipe shape
4275/// [`DepList::ALL`]`.iter().map(std::sync::Arc::<str>::from)` reaches
4276/// through this impl and no other — without it, the same pipe would
4277/// force a spurious [`Copy`] deref
4278/// (`std::sync::Arc::<str>::from((*list).as_str())`) or a `.copied()`
4279/// restatement whose type bounds have no compile-time link back to the
4280/// substrate primitive.
4281///
4282/// Closes the `{Self, &Self}` input-shape corner on the second caixa-
4283/// core-internal closed-set fieldless typed enum peer of the substrate-
4284/// wide trait-idiomatic [`std::sync::Arc<str>`] forward-projection
4285/// campaign — one commit after the paired top-level [`crate::CaixaKind`]
4286/// pair (c17be64) opened the caixa-core-internal Arc<str> tier — matching
4287/// the trajectory the paired top-level [`crate::CaixaKind`] pair
4288/// (c17be64, both corners in one axis) walked before it. Leaves the
4289/// remaining caixa-core-internal closed-set fieldless typed enum peers
4290/// ([`crate::dialeto::CaixaDialeto`],
4291/// [`crate::render::PathShapeViolation`]) as the campaign's next multi-
4292/// peer targets on the caixa-core-internal tier of the Arc<str> axis.
4293///
4294/// Pinned load-bearing by
4295/// [`tests::dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor`]
4296/// (byte-parity pin against [`DepList::as_str`] across the two-arm
4297/// [`DepList::ALL`] emit-set on the borrowed-input surface, plus a
4298/// blanket-derived [`Into`] shape witness, a cross-axis partition pin
4299/// against the paired owned-input
4300/// [`From<DepList> for std::sync::Arc<str>`] and the sibling borrowed-
4301/// input `{&'static str, String, Cow<'static, str>, Box<str>}` return-
4302/// shape axes, and a `.iter().map(std::sync::Arc::<str>::from)` pipe
4303/// witness over [`DepList::ALL`] that resolves through the borrowed-
4304/// input axis without a spurious [`Copy`] deref).
4305impl From<&DepList> for std::sync::Arc<str> {
4306    fn from(list: &DepList) -> std::sync::Arc<str> {
4307        std::sync::Arc::<str>::from(list.as_str())
4308    }
4309}
4310
4311/// Trait-idiomatic [`std::str::FromStr`] parse axis on the two-list
4312/// dep-graph [`DepList`] closed-set typed enum — routes byte-for-byte
4313/// through the paired [`TryFrom<&str> for DepList`] impl (which in
4314/// turn routes through the substrate-primitive [`DepList::from_wire`]
4315/// `Option<Self>` accessor), so `"...".parse::<DepList>()` /
4316/// `<DepList as FromStr>::from_str(…)` reaches the same two-arm
4317/// accept-set the sibling method-named [`DepList::from_wire`]
4318/// resolver and the paired [`TryFrom<&str>`] impl already resolve
4319/// against.
4320///
4321/// Opens the trait-idiomatic `str::parse`-axis campaign on the
4322/// substrate-wide closed-set fieldless typed-enum surface. The
4323/// substrate already carries three peers per enum on the projection
4324/// star: the method-named substrate-primitive pair
4325/// ([`DepList::as_str`] `pub const fn` accessor + [`DepList::from_wire`]
4326/// `Option<Self>` resolver), the emit-set trait pair
4327/// ([`std::fmt::Display`], [`AsRef<str>`], the owned-input +
4328/// borrowed-input `{&'static str, String, Cow<'static, str>, Box<str>,
4329/// std::sync::Arc<str>}` `From<{Self,&Self}>` return-shape matrix),
4330/// and the parse-set `TryFrom<&str>` reverse trait. [`FromStr`] is the
4331/// canonical Rust-idiomatic parse-set entry point every stdlib-shaped
4332/// consumer reaches for — [`str::parse::<T>()`] is a
4333/// `T: FromStr`-bounded generic, not a `T: for<'a> TryFrom<&'a str>`-
4334/// bounded one — so lifting [`FromStr`] onto the closed-set enum
4335/// unlocks the `.parse::<DepList>()` short-form on every consumer
4336/// (a future `feira dep --list <deps|deps-dev>` clap-style arg-parse
4337/// composes `arg.parse::<DepList>()`; a `serde` string-tagged
4338/// deserializer routes through the same `FromStr` bound; the future
4339/// M4 admission webhook's `Deserialize` derive reaches the enum
4340/// through its `FromStr` impl via `serde_with::DisplayFromStr`).
4341///
4342/// The impl trivially delegates to the paired [`TryFrom<&str>`] —
4343/// same `type Err = ()` deliberate-deferral shape the sibling
4344/// reverse-projection trait carries — so both trait-idiomatic
4345/// parse-axis paths (`TryFrom<&str>` and `FromStr::from_str`) resolve
4346/// to the same two-arm accept-set by construction. A future accept-set
4347/// widening (a `":packages"` rebrand, a `":dev-deps"` alias) reaches
4348/// every parse path through one edit on the substrate-primitive
4349/// [`DepList::from_wire`] accessor, not a coordinated rewrite across
4350/// the two reverse-projection trait impls.
4351///
4352/// Pinned load-bearing by
4353/// [`tests::dep_list_from_str_routes_through_try_from_str_impl`]
4354/// (byte-parity pin across the two-arm accept-set + delegated-
4355/// `.parse()`-projection witness) and
4356/// [`tests::dep_list_from_str_rejects_unknown_byte_strings`]
4357/// (rejection witness against silent accept-set widening).
4358impl std::str::FromStr for DepList {
4359    type Err = ();
4360
4361    fn from_str(s: &str) -> Result<Self, Self::Err> {
4362        <Self as TryFrom<&str>>::try_from(s)
4363    }
4364}
4365
4366/// Errors raised by [`Dep::validate`].
4367///
4368/// Mirrors the per-axis error families the other `:versao`-carrying
4369/// typed surfaces expose
4370/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
4371/// [`crate::AplicacaoError::MembroVersaoInvalid`],
4372/// [`crate::SupervisorError::EmptyChildVersion`] /
4373/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
4374/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
4375#[derive(Debug, Error, PartialEq, Eq)]
4376pub enum DepError {
4377    #[error(
4378        ":deps entry has empty :nome (every dep must name a target caixa; \
4379         omit the entry instead of carrying an empty name)"
4380    )]
4381    NomeEmpty,
4382    #[error(
4383        ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
4384         (the value flows verbatim as the target caixa's `:nome`, the rendered \
4385         `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
4386         value, and the resolver's checkout-directory leaf — each apiserver-side \
4387         schema rejects non-DNS-1123 names at admission time; use a lowercase \
4388         RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
4389         pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
4390    )]
4391    NomeInvalid { nome: String, reason: String },
4392    #[error(
4393        ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
4394         constraint that resolves through the lacre pipeline)"
4395    )]
4396    VersaoEmpty { nome: String },
4397    #[error(
4398        ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
4399         requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
4400         `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
4401         and `:children :versao` carry; the lacre pipeline resolves all three \
4402         through the same parser)"
4403    )]
4404    VersaoInvalid {
4405        nome: String,
4406        versao: String,
4407        reason: String,
4408    },
4409    #[error(
4410        ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
4411         (every git source must name a repo — use a `github:org/repo` \
4412         shorthand, an `https://…` URL, or an ssh-git URL; omit the \
4413         entire :fonte block to fall back to the default-host resolver \
4414         convention)"
4415    )]
4416    FonteRepoEmpty { nome: String },
4417    #[error(
4418        ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
4419         invalid value-shape: {reason} (the value flows verbatim into the \
4420         caixa-resolver's `git clone <repo>` subprocess invocation; every \
4421         documented form carries a `:` separator and no whitespace / \
4422         control / non-ASCII bytes — use a `github:org/repo` shorthand, \
4423         an `https://host/path` / `ssh://[user@]host/path` / \
4424         `git://host/path` / `file:///path` URL, or the `git@host:path` \
4425         scp-style SSH form)"
4426    )]
4427    FonteRepoShape {
4428        nome: String,
4429        repo: String,
4430        reason: String,
4431    },
4432    #[error(
4433        ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
4434         (set exactly one of :tag, :rev, or :branch so the resolver \
4435         can pick a reproducible commit; omit the entire :fonte block \
4436         to fall back to the default-host resolver convention, which \
4437         resolves the latest tag matching :versao)"
4438    )]
4439    FontePinMissing { nome: String },
4440    #[error(
4441        ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
4442         set ({pins}); exactly one of :tag, :rev, or :branch must be \
4443         set so the resolver's checkout target is unambiguous (the \
4444         resolver's silent precedence is :rev > :tag > :branch — if \
4445         you intended one specifically, drop the others)"
4446    )]
4447    FontePinAmbiguous { nome: String, pins: String },
4448    #[error(
4449        ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
4450         (a set pin must name a non-empty git ref; drop the {pin} key \
4451         entirely to fall through to another pin axis)"
4452    )]
4453    FontePinEmpty { nome: String, pin: String },
4454    #[error(
4455        ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
4456         value-shape: {reason} (the git porcelain enforces the same shape at \
4457         `git fetch` / `git checkout` time on every pin; use a leaf refname \
4458         like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
4459         `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
4460         drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
4461         prepends at clone time, and avoid abbreviated SHAs which are \
4462         ambiguous across repository history)"
4463    )]
4464    FontePinShape {
4465        nome: String,
4466        pin: String,
4467        value: String,
4468        reason: String,
4469    },
4470    #[error(
4471        ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
4472         (every path source must name a non-empty filesystem path; \
4473         omit the entire :fonte block to fall back to the default-host \
4474         resolver convention)"
4475    )]
4476    FonteCaminhoEmpty { nome: String },
4477    #[error(
4478        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
4479         absolute (the lacre pipeline embeds the value verbatim in its \
4480         per-dep content-address `path:{caminho}` at \
4481         caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
4482         BLAKE3 closure differ across machines — defeating the \
4483         reproducibility contract that's load-bearing for CSE; express \
4484         the path relative to the caixa.lisp location, e.g. \
4485         \"../caixa-teia\" for a sibling workspace dep)"
4486    )]
4487    FonteCaminhoAbsolute { nome: String, caminho: String },
4488    #[error(
4489        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4490         with `~` (the leading-tilde is a shell-expansion convention, not a \
4491         POSIX path component — `Path::is_absolute` returns false on it, so \
4492         the b94fd83 absolute-path gate doesn't catch it, but the lacre \
4493         pipeline embeds the value verbatim in its per-dep content-address \
4494         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4495         caixa-resolver folds it through `Path::join` without `~`-expansion, \
4496         so the build looks for a literal `./{caminho}` subdirectory and \
4497         fails at resolve time far from the source caixa.lisp; even worse, a \
4498         future caixa-resolver pass that *does* expand `~` would silently \
4499         re-open the host-layout-leak the b94fd83 absolute gate closes — \
4500         Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
4501         runners with different `$HOME` layouts resolve to two distinct paths \
4502         for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
4503         determinism contract; express the path relative to the caixa.lisp \
4504         location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
4505         spell out the full relative path explicitly if a workstation-rooted \
4506         dep is genuinely intended)"
4507    )]
4508    FonteCaminhoTildeExpansion { nome: String, caminho: String },
4509    #[error(
4510        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4511         with `$` (the leading-`$` is a shell-variable-expansion convention, \
4512         not a POSIX path component — `Path::is_absolute` returns false on it \
4513         and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
4514         embeds the value verbatim in its per-dep content-address \
4515         `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
4516         caixa-resolver folds it through `Path::join` without `$`-expansion, \
4517         so the build looks for a literal `./{caminho}` subdirectory and \
4518         fails at resolve time far from the source caixa.lisp; even worse, a \
4519         future caixa-resolver pass that *does* expand `$VAR` (the canonical \
4520         shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
4521         invites) would silently re-open the host-layout-leak the b94fd83 \
4522         absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
4523         Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
4524         layouts resolve to two distinct paths for the byte-identical caixa, \
4525         defeating the THEORY.md §V.2 render-determinism contract; express \
4526         the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
4527         for a sibling workspace dep, or spell out the full relative path \
4528         explicitly if a workstation-rooted dep is genuinely intended)"
4529    )]
4530    FonteCaminhoVarExpansion { nome: String, caminho: String },
4531    #[error(
4532        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4533         with a space (the leading ASCII space `0x20` is the orthogonal \
4534         paste-from-aligned-doc footgun that silently passes \
4535         `Path::is_absolute` and every prior leading-byte arm — \
4536         `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
4537         `./ ../caixa-teia` subdirectory the resolver fails to find at \
4538         resolve time with a non-self-locating `No such file or directory` \
4539         error far from the source caixa.lisp; the lacre pipeline embeds \
4540         the value verbatim in its per-dep content-address `path:{caminho}` \
4541         at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4542         semantic-identical caixa values (` ../caixa-teia` vs \
4543         `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4544         workstations whose authors differ only in paste-from-aligned- \
4545         caixa.lisp-doc whitespace habits — the most insidious failure \
4546         mode the typed slot can carry (no error surfaces; the divergence \
4547         is invisible until two machines compare lacres), defeating the \
4548         THEORY.md §V.2 render-determinism contract. The canonical \
4549         paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4550         a multi-entry `:deps` block sits at the same column — an author \
4551         selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4552         the rendered alignment into a fresh entry preserves the leading \
4553         whitespace verbatim); peer `:fonte :repo` axis already rejects \
4554         leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4555         `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4556         `is_chart_description_shape`, `:licenca` via \
4557         `is_spdx_expression_shape`. Drop the leading space; express the \
4558         path as a bare relative single-token like \"../caixa-teia\")"
4559    )]
4560    FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4561    #[error(
4562        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4563         with `-` (the canonical CLI-argument-injection footgun on the \
4564         `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4565         its per-dep content-address `path:{caminho}` at \
4566         caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4567         through `Path::join` looking for a literal `./{caminho}` \
4568         subdirectory. Every downstream subprocess that consumes the resolved \
4569         path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4570         `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4571         `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4572         value as a CLI flag rather than a positional path when the invocation \
4573         does not carry a `--` argument-list terminator between the flag block \
4574         and the path (the common case at every porcelain entry point). The \
4575         canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4576         `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4577         `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4578         CLI-arg-injection vector at every git porcelain entry point that \
4579         consumes a path or URL argument, peer with is_git_repo_url's \
4580         leading-`-` arm on the sibling `:fonte :repo` axis), \
4581         `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4582         POSIX `std::path::Path` treats a leading `-` as a literal filename \
4583         byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4584         for a literal `./-rf` subdirectory that fails at resolve time with a \
4585         non-self-locating `No such file or directory` error far from the \
4586         source caixa.lisp — but on any downstream shell-out without `--` the \
4587         reinterpretation is silent and the failure mode is arbitrary-\
4588         argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4589         rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4590         arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4591         leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4592         CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4593         DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4594         `:children :caixa`, `:deps :nome`, cluster names); \
4595         `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4596         the feira `init` / `add <nome>` positional gate (868c191) rejects \
4597         leading `-` on the CLI positional itself. Express the path as a bare \
4598         relative single-token like \"../caixa-teia\" — the sibling-workspace \
4599         directory name carries no leading-hyphen semantic, and `./` / `../` \
4600         prefixes structurally partition the leading-byte set to safe values.)"
4601    )]
4602    FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4603    #[error(
4604        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4605         ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4606         every `std::fs` syscall routes the path through `CString::new` which \
4607         fails with `NulError` at resolve time; the lacre pipeline embeds the \
4608         value verbatim in its per-dep content-address `path:{caminho}` at \
4609         caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4610         value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4611         determinism contract — the canonical paste-from-multiline-doc \
4612         (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4613         blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4614         (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4615         already gates against. Express the path as a relative single-line ASCII \
4616         string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4617    )]
4618    FonteCaminhoControlChar {
4619        nome: String,
4620        caminho: String,
4621        byte: u8,
4622    },
4623    #[error(
4624        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4625         (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4626         component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4627         not the parent's sibling — and the caixa-resolver folds the value through \
4628         `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4629         resolve time with a non-self-locating `No such file or directory` error far \
4630         from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4631         primary path separator equal to `/`, so byte-identical caixa.lisp values \
4632         resolve to two distinct directories across runner OSes — the lacre pipeline \
4633         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4634         caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4635         determinism contract via the cross-host-OS-separator divergence vector. The \
4636         canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4637         paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4638         rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4639         and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4640         byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4641         \"../caixa-teia\" for a sibling workspace dep)"
4642    )]
4643    FonteCaminhoBackslash { nome: String, caminho: String },
4644    #[error(
4645        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4646         redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4647         zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4648         operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4649         paste-from-shell-pipeline footgun where an author copies a `command > log` \
4650         tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4651         as literal path-component bytes, so the resolver folds the value through \
4652         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4653         subdirectory and fails at resolve time with a non-self-locating `No such \
4654         file or directory` error far from the source caixa.lisp. The lacre pipeline \
4655         embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4656         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4657         and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4658         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4659         canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4660         peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4661         `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4662         `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4663         RFC-3986-reserved set. Express the path as a bare relative single-token like \
4664         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4665         redirection semantic.",
4666        ch = *byte as char
4667    )]
4668    FonteCaminhoShellRedirection {
4669        nome: String,
4670        caminho: String,
4671        byte: u8,
4672    },
4673    #[error(
4674        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4675         metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4676         `|` as the pipe operator that wires one command's stdout to the next command's \
4677         stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4678         shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4679         without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4680         symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4681         treats `|` as a literal path-component byte, so the resolver folds the value \
4682         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4683         subdirectory and fails at resolve time with a non-self-locating `No such file or \
4684         directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4685         value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4686         src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4687         shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4688         shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4689         subprocess-argument / shell-metachar injection surface every peer single-token-\
4690         shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4691         via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4692         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4693         workspace directory name carries no shell-pipe semantic."
4694    )]
4695    FonteCaminhoShellPipe { nome: String, caminho: String },
4696    #[error(
4697        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4698         command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4699         / nushell — lexes `;` as the sequential-command terminator that fires the next \
4700         command regardless of the prior command's exit status, so `:caminho \
4701         \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4702         footgun where an author copies a `cd path; do-thing` chain without trimming \
4703         the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4704         arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4705         literal path-component byte, so the resolver folds the value through \
4706         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4707         subdirectory and fails at resolve time with a non-self-locating `No such file \
4708         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4709         the value verbatim in its per-dep content-address `path:{caminho}` at \
4710         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4711         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4712         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4713         canonical shell-metachar injection surface every peer single-token-shaped \
4714         typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4715         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4716         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4717         workspace directory name carries no shell-command-separator semantic."
4718    )]
4719    FonteCaminhoShellSemicolon { nome: String, caminho: String },
4720    #[error(
4721        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4722         background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4723         / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4724         terminator detaching the prior command and returning control immediately to \
4725         the prompt, double `&&` as the logical-AND list operator firing the next \
4726         command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4727         literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4728         sleep 1` background-launch one-liner or a `cd path && make install` build-\
4729         chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4730         05c358e closed the sequential-command-separator vector, this arm closes the \
4731         orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4732         prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4733         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4734         byte lands in the BLAKE3 closure and rides into every shell-spawned \
4735         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4736         future operator-side `nix` spawn) as the canonical shell-metachar injection \
4737         surface every peer single-token-shaped typed slot already closes. The peer \
4738         `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4739         byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4740         like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4741         shell-background / logical-AND semantic."
4742    )]
4743    FonteCaminhoShellBackground { nome: String, caminho: String },
4744    #[error(
4745        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4746         command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4747         dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4748         wrapper that runs the enclosed command and substitutes its standard-output \
4749         verbatim into the surrounding word, so a backticked `whoami` expands to the \
4750         current user's name and a backticked `cat /etc/passwd` expands to the file's \
4751         contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4752         `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4753         paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4754         one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4755         into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4756         background / logical-AND vector, this arm closes the orthogonal command-\
4757         substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4758         form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4759         the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4760         value verbatim in its per-dep content-address `path:{caminho}` at \
4761         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4762         rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4763         `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4764         shell-metachar injection surface every peer single-token-shaped typed slot \
4765         already closes. The peer `:entrada :paths` axis rejects the byte via \
4766         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4767         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4768         directory name carries no shell-command-substitution semantic."
4769    )]
4770    FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4771    #[error(
4772        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4773         glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4774         sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4775         expansion wildcards: `*` matches any sequence of characters in a path component \
4776         and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4777         canonical paste-from-shell-listing footgun where an author copies a \
4778         `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4779         \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4780         `std::path::Path` treats both bytes as literal path-component bytes, so the \
4781         resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4782         a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4783         locating `No such file or directory` error far from the source caixa.lisp. The \
4784         lacre pipeline embeds the value verbatim in its per-dep content-address \
4785         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4786         BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4787         `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4788         spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4789         single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4790         rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4791         reserved set. Express the path as a bare relative single-token like \
4792         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4793         / pathname-expansion semantic.",
4794        ch = *byte as char
4795    )]
4796    FonteCaminhoShellGlob {
4797        nome: String,
4798        caminho: String,
4799        byte: u8,
4800    },
4801    #[error(
4802        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4803         subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4804         zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4805         operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4806         (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4807         subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4808         modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4809         arm closes the leading byte of — together the two arms now structurally exclude the \
4810         entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4811         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4812         `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4813         modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4814         (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4815         every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4816         <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4817         self-locating `No such file or directory` error far from the source caixa.lisp. The \
4818         lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4819         {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4820         closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4821         future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4822         shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4823         already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4824         same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4825         together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4826         of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4827         like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4828         subshell-grouping semantic.",
4829        ch = *byte as char
4830    )]
4831    FonteCaminhoShellSubshellGrouping {
4832        nome: String,
4833        caminho: String,
4834        byte: u8,
4835    },
4836    #[error(
4837        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4838         brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4839         (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4840         `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4841         comma-separated members and `{{1..10}}` expands to the integer range — the \
4842         canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4843         idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4844         URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4845         substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4846         library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4847         Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4848         templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4849         `std::path::Path` treats the byte as a literal path-component byte, so a \
4850         `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4851         shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4852         caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4853         idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4854         silently passes every prior arm and the resolver folds the value through \
4855         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4856         resolve time with a non-self-locating `No such file or directory` error far from \
4857         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4858         per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4859         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4860         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4861         future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4862         expansion / URI-Template-placeholder surface every peer single-token-shaped \
4863         typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4864         same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4865         RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4866         bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4867         directory name carries no shell-brace-expansion / URI-Template-placeholder \
4868         semantic; if two siblings actually need pinning, author two separate `:deps` \
4869         entries rather than one brace-expanded `:caminho` value.",
4870        ch = *byte as char
4871    )]
4872    FonteCaminhoShellBraceExpansion {
4873        nome: String,
4874        caminho: String,
4875        byte: u8,
4876    },
4877    #[error(
4878        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4879         bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4880         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4881         — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4882         `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4883         canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4884         glob every shell-history block carries; the bracket pair additionally carries the \
4885         POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4886         script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4887         the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4888         canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4889         delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4890         leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4891         POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4892         `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4893         character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4894         (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4895         leak) silently passes every prior arm and the resolver folds the value through \
4896         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4897         resolve time with a non-self-locating `No such file or directory` error far from \
4898         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4899         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4900         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4901         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4902         `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4903         surface every peer single-token-shaped typed slot already closes. Express the path \
4904         as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4905         directory name carries no shell-bracket-expansion / glob-character-class / array-\
4906         literal semantic; if a family of sibling caixas actually needs pinning, author \
4907         separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4908        ch = *byte as char
4909    )]
4910    FonteCaminhoShellBracketExpansion {
4911        nome: String,
4912        caminho: String,
4913        byte: u8,
4914    },
4915    #[error(
4916        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4917         quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4918         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4919         nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4920         and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4921         substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4922         every path-with-embedded-whitespace paste block carries and the symmetric \
4923         `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4924         Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4925         the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4926         and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4927         paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4928         basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4929         paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4930         delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4931         entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4932         footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4933         both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4934         production. POSIX `std::path::Path` treats the byte as a literal path-component \
4935         byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4936         strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4937         (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4938         from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4939         shape) silently passes every prior arm and the resolver folds the value through \
4940         `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4941         resolve time with a non-self-locating `No such file or directory` error far from \
4942         the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4943         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4944         lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4945         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4946         `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4947         every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4948         axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4949         banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4950         `is_git_repo_url`). Express the path as a bare relative single-token like \
4951         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4952         grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4953         paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4954         quoting on the outer syntactic layer, so an inner quote pair would nest and \
4955         desugar to a broken layer).",
4956        ch = *byte as char
4957    )]
4958    FonteCaminhoShellQuoteGrouping {
4959        nome: String,
4960        caminho: String,
4961        byte: u8,
4962    },
4963    #[error(
4964        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4965         comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4966         0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4967         nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4968         whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4969         discarding the byte and everything after it to the end of the physical line \
4970         before command parsing (`cd ../caixa-teia  # legacy sibling` — the canonical \
4971         paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4972         and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4973         position preceded by whitespace or at line-start (`path: ../caixa-teia  # pin` \
4974         — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4975         leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4976         canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4977         `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4978         cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4979         output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4980         flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4981         `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4982         literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4983         (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4984         `:caminho \"../caixa-teia  # pin\"` (the symmetric YAML flow-scalar paste-with-\
4985         trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4986         fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4987         and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4988         looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4989         fails at resolve time with a non-self-locating `No such file or directory` \
4990         error far from the source caixa.lisp — while every downstream shell / YAML / \
4991         URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4992         a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4993         scalar disagree with the resolver on which directory the value names. The \
4994         lacre pipeline embeds the value verbatim in its per-dep content-address \
4995         `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4996         the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4997         resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4998         side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4999         fragment-delimiter surface every peer single-token-shaped typed slot already \
5000         closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
5001         fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
5002         path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
5003         workspace directory name carries no shell-comment / URL-fragment / YAML-\
5004         comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
5005         on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
5006         and drop any `#fragment` tail entirely (fragment identifiers select \
5007         renderings, not directories, and `:caminho` names a directory).",
5008        ch = *byte as char
5009    )]
5010    FonteCaminhoShellComment {
5011        nome: String,
5012        caminho: String,
5013        byte: u8,
5014    },
5015    #[error(
5016        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
5017         percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
5018         / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
5019         `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
5020         mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
5021         `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
5022         literally inside a URL value. The canonical paste-from-browser-address-bar \
5023         percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
5024         encoded README hyperlink / browser address bar / percent-encoded permalink \
5025         expecting `%20` to decode to a literal space at the filesystem layer) locks two \
5026         distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
5027         what the author intended as the byte-identical sibling-workspace dep. POSIX \
5028         `std::path::Path` treats the byte as a literal path-component byte, so \
5029         `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
5030         resolve time with a non-self-locating `No such file or directory` error far \
5031         from the source caixa.lisp — while every downstream URL parser / shell printf \
5032         builtin / YAML directive parser silently reinterprets the byte to a different \
5033         value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
5034         `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
5035         wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
5036         string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
5037         (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
5038         recent job whose command started with `foo`\" — a future `kill %1` invocation \
5039         silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
5040         directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
5041         directive block cross-idiom leak); and the Windows-shell env-var-reference \
5042         lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
5043         cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
5044         content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
5045         byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
5046         (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5047         operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
5048         printf-format-specifier / job-control-specifier surface every peer single-\
5049         token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
5050         the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
5051         `is_git_repo_url`). Express the path as a bare relative single-token like \
5052         \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
5053         percent-encoding-escape / format-specifier / job-control semantic; substitute \
5054         any `%20` percent-encoded-space with a literal space then reject the whole \
5055         value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
5056         directory name never carries an embedded space in practice); drop any \
5057         `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
5058         `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
5059        ch = *byte as char
5060    )]
5061    FonteCaminhoUrlPercentEncoding {
5062        nome: String,
5063        caminho: String,
5064        byte: u8,
5065    },
5066    #[error(
5067        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5068         variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
5069         DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
5070         bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
5071         POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
5072         / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
5073         Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
5074         / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
5075         literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
5076         templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
5077         superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
5078         for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
5079         the byte is a first-class parser byte in nearly every config / templating / \
5080         build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
5081         `std::path::Path` treats the byte as a literal path-component byte, so the \
5082         canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
5083         from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
5084         prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
5085         cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
5086         `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
5087         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5088         subdirectory that fails at resolve time with a non-self-locating `No such file \
5089         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5090         the value verbatim in its per-dep content-address `path:{caminho}` at \
5091         caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
5092         only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
5093         time lock to two distinct BLAKE3 closures across two workstations whose \
5094         downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
5095         recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
5096         same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
5097         `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
5098         is the canonical CWE-78 shell-command-injection surface every peer single-\
5099         token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
5100         under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
5101         (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
5102         `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
5103         rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
5104         `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
5105         position on the same axis routes through `FonteCaminhoVarExpansion` at the \
5106         f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
5107         so every position — leading and embedded — is structurally rejected. Substitute \
5108         the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
5109         time, or express the path as a bare relative single-token like \
5110         \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
5111         variable-expansion / command-substitution / arithmetic-expansion semantic.",
5112        ch = *byte as char
5113    )]
5114    FonteCaminhoShellVariableExpansion {
5115        nome: String,
5116        caminho: String,
5117        byte: u8,
5118    },
5119    #[error(
5120        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5121         history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
5122         `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
5123         `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
5124         reference §9.3: `!command` re-runs the most recent history entry beginning with \
5125         `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
5126         word of the prior command, `!:N` substitutes the Nth word of the prior command, \
5127         and the substitution fires at every history-expansion-enabled shell context — \
5128         `set -o histexpand` is bash's default for interactive sessions and the layer \
5129         every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
5130         invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
5131         §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
5132         a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
5133         encodes it inside a query component via the 'special-query percent-encode set' \
5134         the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
5135         also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
5136         prefix — the paste-from-source-code idiom where an author copies \
5137         `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
5138         the string-literal boundary); the canonical English-typography emphasis / \
5139         exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
5140         writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
5141         kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
5142         POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
5143         canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
5144         (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
5145         quick-start README and the trailing `!sudo` rides in verbatim as a history-\
5146         expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
5147         repeat-prior-command paste idiom), the English-typography `:caminho \
5148         \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
5149         substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
5150         arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
5151         / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
5152         through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
5153         subdirectory that fails at resolve time with a non-self-locating `No such file \
5154         or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
5155         the value verbatim in its per-dep content-address `path:{caminho}` at \
5156         caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
5157         rides into every shell-spawned subprocess (the resolver's `git clone`, a \
5158         future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
5159         as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
5160         peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
5161         axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
5162         delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
5163         relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
5164         name carries no shell-history-expansion / bang-operator semantic; drop any \
5165         `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
5166         idiom; and drop any trailing English-typography exclamation mark that pasted \
5167         from prose.",
5168        ch = *byte as char
5169    )]
5170    FonteCaminhoShellHistoryExpansion {
5171        nome: String,
5172        caminho: String,
5173        byte: u8,
5174    },
5175    #[error(
5176        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
5177         history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
5178         `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
5179         session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
5180         `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
5181         substitution' history operator that rewrites the prior command's `old` string to \
5182         `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
5183         (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
5184         history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
5185         `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
5186         the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
5187         `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
5188         literal value diverges from every downstream `feira tofu` curl-invocation / \
5189         artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
5190         the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
5191         C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
5192         metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
5193         `std::path::Path` treats `^` as a literal path-component byte, so \
5194         `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
5195         \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
5196         (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
5197         isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
5198         / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
5199         `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
5200         that fails at resolve time with a non-self-locating `No such file or directory` \
5201         error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
5202         in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
5203         so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
5204         subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
5205         operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
5206         / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
5207         The peer `:fonte :repo` axis closes the byte under the same shell-history-\
5208         substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
5209         with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
5210         histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
5211         prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
5212         path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
5213         directory name carries no shell-history-substitution / regex-negation / XOR-operator \
5214         semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
5215         drop any trailing `^` history-substitution-open fragment.",
5216        ch = *byte as char
5217    )]
5218    FonteCaminhoShellHistorySubstitution {
5219        nome: String,
5220        caminho: String,
5221        byte: u8,
5222    },
5223    #[error(
5224        ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
5225         `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
5226         `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
5227         value verbatim in its per-dep content-address `path:{caminho}` at \
5228         caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
5229         shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
5230         defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
5231         separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
5232         `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
5233         \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
5234         trailing `/`; every `:caminho` value names a sibling-workspace directory \
5235         already, so the trailing separator carries no information. Use \
5236         `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
5237    )]
5238    FonteCaminhoTrailingSlash { nome: String, caminho: String },
5239    #[error(
5240        "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
5241         entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
5242         apply the same set-not-multiset discipline; one package per table), and \
5243         two entries naming the same caixa carry two version constraints / source \
5244         pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
5245         consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
5246         silently overwrites the first at the resolver-side `concrete_versao` step, \
5247         and the dropped entry's pin / features never reach the closure — far from \
5248         the source caixa.lisp, with no field naming which `:deps` entry was the \
5249         silent loser. If two version constraints are genuinely needed (the rare \
5250         multi-version closure case the lacre pipeline doesn't yet support), the \
5251         author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
5252         `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
5253    )]
5254    DuplicateNome { nome: String, list: &'static str },
5255    #[error(
5256        ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
5257         name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
5258         applies the same per-entry non-empty discipline). An empty feature flag reaches the \
5259         caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
5260         author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
5261         with the canonical kebab-case feature name the target caixa declares."
5262    )]
5263    CaracteristicaEmpty { nome: String },
5264    #[error(
5265        ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
5266         feature name: {reason} (the value flows verbatim into Cargo's \
5267         [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
5268         parser enforces the same shape at `cargo metadata` time; use a single-token \
5269         identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
5270         alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
5271         an ASCII alphanumeric or `_`)"
5272    )]
5273    CaracteristicaInvalid {
5274        nome: String,
5275        caracteristica: String,
5276        reason: String,
5277    },
5278    #[error(
5279        ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
5280         every feature-flag list keys its entries by name (Cargo's \
5281         [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
5282         per feature per dep), and two entries naming the same feature are a redundant \
5283         set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
5284         enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
5285         pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
5286         feature once regardless of declaration count, so the duplicate's pin / position never \
5287         reaches the closure with no field naming the silent loser. One entry per feature per \
5288         dep; if two distinct features are intended, name each verbatim."
5289    )]
5290    CaracteristicaDuplicate {
5291        nome: String,
5292        caracteristica: String,
5293    },
5294    #[error(
5295        "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
5296         on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
5297         :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
5298         rejects mid-traversal far from the source caixa.lisp or recurses on until \
5299         it exhausts its stack). Every :nome is globally-unique substrate identity, \
5300         so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
5301         *is* the parent itself, not a coincidentally-named peer. Drop the \
5302         self-referential dep entry — to reference code from this caixa, use \
5303         :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
5304         referencing the caixa's own code surface) instead."
5305    )]
5306    DepIsSelf { nome: String, list: &'static str },
5307}
5308
5309// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5310// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
5311// [`DepSource::validate_caminho`] onto one substrate primitive per typed
5312// variant — the paired `{ nome: String, caminho: String }` two-slot family
5313// on [`DepError`], sibling of the peer
5314// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5315// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
5316// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
5317// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
5318// (981060b, 7 variants on `{ <field>: String, reason: String }`),
5319// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
5320// `{ de, para, wit, expected }`), and
5321// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
5322// variants on `{ de, para, <field>: String, reason: String }`) on the
5323// `AplicacaoError` envelopes, the peer
5324// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
5325// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
5326// (0419438, 4 variants on `{ caixa, kind, slots }`),
5327// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
5328// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
5329// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
5330// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
5331// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
5332// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
5333// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
5334// `UpgradeError` envelope. First fold family on this `DepError` envelope.
5335//
5336// Each of the eleven wire-up sites on this shape (the leading-byte cascade
5337// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
5338// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
5339// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
5340// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
5341// CommandSubstitution}` on the four single-byte shell operators; and the
5342// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
5343// opened the identical `DepError::FonteCaminho<Variant> { nome:
5344// nome.to_string(), caminho: caminho.to_string() }` four-line
5345// struct-literal against the same `(nome: &str, caminho: &str)` local pair
5346// — the exact "same block re-inlined at every consumer" shape the PRIME
5347// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
5348// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
5349// families each closed on their sibling envelopes. The eleven variants
5350// share one `{ nome: String, caminho: String }` shape, so the fold routes
5351// each wire-up site through one dispatch per typed variant.
5352//
5353// The macro below generates one `#[must_use]` inherent constructor per
5354// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
5355// wire-up site collapses onto one dispatch:
5356// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
5357// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
5358// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
5359// once — inside the macro — rather than at every wire-up site.
5360//
5361// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
5362// shapes at the per-byte-classification arms — the
5363// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
5364// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
5365// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
5366// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
5367// cluster — carry an additional `byte: u8` naming the offending byte and
5368// so would break the uniform-two-field routing this macro promises. They
5369// instead fold onto the sibling three-field envelope through
5370// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
5371// `{ nome, caminho, byte }` shape), whose sole additional axis over this
5372// two-slot family is the `byte: u8` classification the arms carry. The
5373// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
5374// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
5375// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
5376// envelope.
5377//
5378// Every future consumer that wants to construct one of these eleven
5379// variants outside the current in-crate [`DepSource::validate_caminho`]
5380// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5381// at lacre-resolve time re-checking the same value-shape axes the resolver
5382// consumes, a future `feira validate --deps` per-caixa admission verb
5383// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
5384// rejecting a `:caminho` value against a cluster-local snapshot) now
5385// reaches each variant through one call rather than re-inlining the
5386// four-line struct-literal in lockstep with the eleven in-crate wire-up
5387// sites.
5388macro_rules! fonte_caminho_ctors {
5389    ($($ctor:ident => $variant:ident),* $(,)?) => {
5390        impl DepError {
5391            $(
5392                #[doc = concat!(
5393                    "Construct a [`DepError::",
5394                    stringify!($variant),
5395                    "`] naming the offending `:deps :nome` + `:fonte ",
5396                    "(:tipo path …) :caminho` pair. Folds the uniform ",
5397                    "`Self::",
5398                    stringify!($variant),
5399                    " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
5400                    "two-slot struct-literal onto one substrate primitive so ",
5401                    "every [`DepSource::validate_caminho`] wire-up on this ",
5402                    "variant reads through one dispatch rather than the ",
5403                    "pre-lift four-line open-coded block."
5404                )]
5405                #[must_use]
5406                pub fn $ctor(nome: &str, caminho: &str) -> Self {
5407                    Self::$variant {
5408                        nome: nome.to_string(),
5409                        caminho: caminho.to_string(),
5410                    }
5411                }
5412            )*
5413        }
5414    };
5415}
5416
5417fonte_caminho_ctors! {
5418    fonte_caminho_absolute => FonteCaminhoAbsolute,
5419    fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
5420    fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
5421    fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
5422    fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
5423    fonte_caminho_backslash => FonteCaminhoBackslash,
5424    fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
5425    fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
5426    fonte_caminho_shell_background => FonteCaminhoShellBackground,
5427    fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
5428    fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
5429}
5430
5431// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5432// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
5433// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
5434// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
5435// three-slot family on [`DepError`], strict sibling of the peer
5436// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
5437// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
5438// that fold onto the `byte`-classifying arms whose additional `byte: u8`
5439// axis broke its uniform-two-field routing — the exact "future compounding
5440// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
5441// here. Third fold family on this `DepError` envelope, sibling of the peer
5442// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
5443// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
5444// same enum.
5445//
5446// Each of the twelve wire-up sites on this shape (the control-byte arm
5447// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
5448// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
5449// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
5450// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
5451// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
5452// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
5453// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
5454// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
5455// `FonteCaminhoShellHistoryExpansion` on `!`, and
5456// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
5457// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
5458// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
5459// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
5460// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
5461// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
5462// closed on the sibling two-field envelope of this same enum. The twelve
5463// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
5464// the fold routes each wire-up site through one dispatch per typed variant.
5465//
5466// The macro below generates one `#[must_use]` inherent constructor per
5467// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
5468// so every wire-up site collapses onto one dispatch:
5469// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
5470// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
5471// three-field construction (`nome.to_string()` / `caminho.to_string()` /
5472// `byte`) is spelled once — inside the macro — rather than at every wire-up
5473// site.
5474//
5475// Every future consumer that wants to construct one of these twelve
5476// variants outside the current in-crate [`DepSource::validate_caminho`]
5477// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
5478// at lacre-resolve time re-checking the same value-shape axes the resolver
5479// consumes, a future `feira validate --deps` per-caixa admission verb
5480// re-checking the `:fonte :caminho` axis against the shell-metachar
5481// classification bytes this cluster catches, a per-lacre overlay resolver
5482// rejecting a `:caminho` value against a cluster-local snapshot) now
5483// reaches each variant through one call rather than re-inlining the
5484// five-line struct-literal in lockstep with the twelve in-crate wire-up
5485// sites.
5486macro_rules! fonte_caminho_byte_ctors {
5487    ($($ctor:ident => $variant:ident),* $(,)?) => {
5488        impl DepError {
5489            $(
5490                #[doc = concat!(
5491                    "Construct a [`DepError::",
5492                    stringify!($variant),
5493                    "`] naming the offending `:deps :nome` + `:fonte ",
5494                    "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
5495                    "classification. Folds the uniform `Self::",
5496                    stringify!($variant),
5497                    " { nome: nome.to_string(), caminho: caminho.to_string(), ",
5498                    "byte }` three-slot struct-literal onto one substrate ",
5499                    "primitive so every [`DepSource::validate_caminho`] wire-up ",
5500                    "on this variant reads through one dispatch rather than ",
5501                    "the pre-lift five-line open-coded block."
5502                )]
5503                #[must_use]
5504                pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
5505                    Self::$variant {
5506                        nome: nome.to_string(),
5507                        caminho: caminho.to_string(),
5508                        byte,
5509                    }
5510                }
5511            )*
5512        }
5513    };
5514}
5515
5516fonte_caminho_byte_ctors! {
5517    fonte_caminho_control_char => FonteCaminhoControlChar,
5518    fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
5519    fonte_caminho_shell_glob => FonteCaminhoShellGlob,
5520    fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
5521    fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
5522    fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
5523    fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
5524    fonte_caminho_shell_comment => FonteCaminhoShellComment,
5525    fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
5526    fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
5527    fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
5528    fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
5529}
5530
5531// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
5532// single-slot struct-variant wire-up sites scattered across
5533// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
5534// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
5535// substrate primitive per typed variant — the paired `{ nome: String }`
5536// single-slot family on [`DepError`], sibling of the peer
5537// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
5538// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
5539// the same enum, and of the peer
5540// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
5541// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5542// axis. Second fold family on this `DepError` envelope, and the first on
5543// the single-`{ nome }` shape.
5544//
5545// The five wire-up sites this fold closes each opened the identical
5546// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5547// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5548// local — the exact "same block re-inlined at every consumer" shape the
5549// PRIME DIRECTIVE names as a bug. The five variants share one
5550// `{ nome: String }` shape, so the fold routes each wire-up site through
5551// one dispatch per typed variant.
5552//
5553// The macro below generates one `#[must_use]` inherent constructor per
5554// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5555// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5556// pre-lift struct-literal on the same `&str` fixture. The uniform
5557// one-field construction (`nome.to_string()`) is spelled once — inside
5558// the macro — rather than at every wire-up site. Callers that hold a
5559// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5560// and lets the macro-owned `.to_string()` produce the fresh owning copy
5561// the enum variant needs; the semantics collapse onto the same
5562// `.clone()`-equivalent one this fold replaces at every site.
5563//
5564// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5565// on the same envelope stays on its pre-lift open-coded wire-up shape —
5566// it carries no `nome` field (the offending `:nome` value *is* the empty
5567// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5568// signature this macro promises does not apply. Every future consumer
5569// that wants to construct one of these five variants outside the current
5570// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5571// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5572// re-validator at lacre-resolve time, a future `feira validate --deps`
5573// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5574// these empty-value shapes against a cluster-local snapshot) now reaches
5575// each variant through one call rather than re-inlining the three-line
5576// struct-literal in lockstep with the five in-crate wire-up sites.
5577macro_rules! dep_nome_only_ctors {
5578    ($($ctor:ident => $variant:ident),* $(,)?) => {
5579        impl DepError {
5580            $(
5581                #[doc = concat!(
5582                    "Construct a [`DepError::",
5583                    stringify!($variant),
5584                    "`] naming the offending `:deps :nome`. Folds the ",
5585                    "uniform `Self::",
5586                    stringify!($variant),
5587                    " { nome: nome.to_string() }` one-field ",
5588                    "struct-literal onto one substrate primitive so every ",
5589                    "in-crate wire-up on this variant reads through one ",
5590                    "dispatch rather than the pre-lift three-line ",
5591                    "open-coded block."
5592                )]
5593                #[must_use]
5594                pub fn $ctor(nome: &str) -> Self {
5595                    Self::$variant { nome: nome.to_string() }
5596                }
5597            )*
5598        }
5599    };
5600}
5601
5602dep_nome_only_ctors! {
5603    versao_empty => VersaoEmpty,
5604    fonte_repo_empty => FonteRepoEmpty,
5605    fonte_pin_missing => FontePinMissing,
5606    fonte_caminho_empty => FonteCaminhoEmpty,
5607    caracteristica_empty => CaracteristicaEmpty,
5608}
5609
5610// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5611// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5612// [`crate::manifest::Caixa::validate_deps`] +
5613// [`validate_no_self_dep`] onto one substrate-primitive family per
5614// typed variant — the `DepError`-side siblings of the peer
5615// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5616// on the `SupervisorError { caixa: String }` one-slot envelope and of
5617// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5618// `DepError { nome: String }` one-slot envelope. The two variants
5619// carry the same `{ nome: String, list: &'static str }` two-slot
5620// shape: the `nome` field names the offending dep the diagnostic
5621// points the author back at, and the `list` field carries the
5622// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5623// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5624// [`validate_deps`] arms, and via the paired
5625// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5626// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5627// canonicals on the [`validate_no_self_dep`] arm) so the author can
5628// grep their caixa.lisp for the offending list block in one edit.
5629//
5630// Each of the four wire-up sites opened the same struct-literal
5631// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5632// two-line block — the exact "same block re-inlined at every
5633// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5634// altitude the peer `DepError` / `SupervisorError` /
5635// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5636// already closed on their sibling envelopes. The two `#[must_use]`
5637// inherent constructors below fold each wire-up onto one dispatch:
5638// `DepError::duplicate_nome(<nome>, <list>)` and
5639// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5640// pre-lift struct-literal on the same scalar fixtures. The `list:
5641// &'static str` parameter (not `impl Into<String>`) preserves the
5642// exact wire tag every consumer already passes verbatim — no
5643// downstream diagnostic reshaping at the lift, matching the peer
5644// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5645// contract each wire-up site already keys off.
5646macro_rules! dep_nome_list_ctors {
5647    ($($ctor:ident => $variant:ident),* $(,)?) => {
5648        impl DepError {
5649            $(
5650                #[doc = concat!(
5651                    "Construct a [`DepError::",
5652                    stringify!($variant),
5653                    "`] naming the offending `:deps :nome` and the ",
5654                    "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5655                    "the diagnostic points the author back at. Folds ",
5656                    "the uniform `Self::",
5657                    stringify!($variant),
5658                    " { nome: nome.to_string(), list }` two-field ",
5659                    "struct-literal onto one substrate primitive so ",
5660                    "every in-crate wire-up on this variant reads ",
5661                    "through one dispatch rather than the pre-lift ",
5662                    "open-coded struct-literal block."
5663                )]
5664                #[must_use]
5665                pub fn $ctor(nome: &str, list: &'static str) -> Self {
5666                    Self::$variant { nome: nome.to_string(), list }
5667                }
5668            )*
5669        }
5670    };
5671}
5672
5673dep_nome_list_ctors! {
5674    duplicate_nome => DuplicateNome,
5675    dep_is_self => DepIsSelf,
5676}
5677
5678// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5679// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5680// <value>.to_string(), reason }` struct-variant wire-up sites at
5681// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5682// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5683// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5684// primitive family per typed variant — the `DepError`-side siblings of the
5685// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5686// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5687// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5688// the two-slot `{ nome, caminho }` envelope, and
5689// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5690// caminho, byte }` envelope. The three variants share the same
5691// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5692// the `nome` field names the offending dep the diagnostic points the
5693// author back at, the middle `<axis>: String` field carries the offending
5694// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5695// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5696// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5697// field carries the parser-shaped rejection sentence the paired
5698// [`crate::render::require_valid_versao_requirement`] /
5699// [`crate::render::is_git_repo_url`] /
5700// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5701// axis-field name differs across variants (`versao` / `repo` /
5702// `caracteristica`) so the ctor family below takes the axis field name as
5703// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5704// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5705// -> Self` inherent constructor per typed variant that spells the uniform
5706// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5707// `reason` forwarded owned) exactly once. Peer of the sibling
5708// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5709// family on the `AplicacaoError` envelope's mirror-symmetric
5710// `{ <field>: String, reason: String }` two-slot shape — same
5711// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5712// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5713// envelope keys off (every `DepError` variant carries the offending
5714// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5715// offending block in one edit).
5716//
5717// The three wire-up sites this fold closes are:
5718// - [`DepSource::validate`]'s `:repo` value-shape arm
5719//   (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5720//   repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5721//   rejects the offending URL);
5722// - [`Dep::validate`]'s `:versao` requirement-shape arm
5723//   (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5724//   self.versao_requirement().to_string(), reason }` inside the
5725//   [`crate::render::require_valid_versao_requirement`] callback pair);
5726// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5727//   (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5728//   caracteristica: c.clone(), reason })` after
5729//   [`crate::render::is_cargo_feature_name`] rejects the offending
5730//   feature-name).
5731//
5732// Each opened the identical five-line struct-literal against the same
5733// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5734// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5735// same altitude the peer four already-lifted `DepError` ctor families
5736// closed on their sibling shape-envelopes. The three variant / axis-field
5737// discriminators are the only things that vary between them; the rest of
5738// the struct-literal is a byte-for-byte re-inline.
5739//
5740// Every future consumer wanting to raise one of these three diagnostics
5741// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5742// time re-checking each declared dep against the same requirement +
5743// git-URL + feature-name value-shape cascade, a future `feira validate
5744// --deps` per-caixa admission verb re-running the shape gates on demand,
5745// a per-lacre overlay resolver rejecting an author-supplied dep against a
5746// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5747// the five-line struct-literal in lockstep with the three in-crate
5748// wire-up sites.
5749macro_rules! dep_nome_axis_reason_ctors {
5750    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5751        impl DepError {
5752            $(
5753                #[doc = concat!(
5754                    "Construct a [`DepError::",
5755                    stringify!($variant),
5756                    "`] naming the offending `:deps :nome`, the offending ",
5757                    "`:", stringify!($axis), "` axis value, and the ",
5758                    "parser-shaped rejection `reason`. Folds the uniform ",
5759                    "`Self::",
5760                    stringify!($variant),
5761                    " { nome: nome.to_string(), ",
5762                    stringify!($axis),
5763                    ": ",
5764                    stringify!($axis),
5765                    ".to_string(), reason }` three-field struct-literal ",
5766                    "onto one substrate primitive so every in-crate ",
5767                    "wire-up on this variant reads through one dispatch ",
5768                    "rather than the pre-lift five-line open-coded block. ",
5769                    "The `nome: &str` and `",
5770                    stringify!($axis),
5771                    ": &str` parameters accept `&str` literals and ",
5772                    "`&String` (via Deref coercion) so every existing ",
5773                    "wire-up threads through the ctor without a ",
5774                    "pre-conversion; the `reason: String` parameter takes ",
5775                    "an owned `String` (not `impl Into<String>`) matching ",
5776                    "the paired `crate::render::*` predicate's ",
5777                    "`Result<(), String>` return shape every wire-up ",
5778                    "already holds owned at the call site."
5779                )]
5780                #[must_use]
5781                pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5782                    Self::$variant {
5783                        nome: nome.to_string(),
5784                        $axis: $axis.to_string(),
5785                        reason,
5786                    }
5787                }
5788            )*
5789        }
5790    };
5791}
5792
5793dep_nome_axis_reason_ctors! {
5794    versao_invalid => VersaoInvalid { versao },
5795    fonte_repo_shape => FonteRepoShape { repo },
5796    caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5797}
5798
5799// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5800// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5801// <value>.to_string() }` struct-variant wire-up sites at
5802// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5803// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5804// per-entry set-not-multiset dedup closure onto one substrate-primitive
5805// family per typed variant — the missing two-slot rung on the
5806// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5807// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5808// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5809// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5810// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5811// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5812// symmetric sibling of the peer
5813// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5814// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5815// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5816// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5817// owned altitude the `DepError` envelope keys off (every `DepError`
5818// variant carries the offending `:deps :nome` verbatim so the author
5819// can grep their caixa.lisp for the offending block in one edit). The
5820// three variants share the same `{ nome: String, <axis>: String }`
5821// two-slot shape: the `nome` field names the offending dep the
5822// diagnostic points the author back at, and the middle `<axis>:
5823// String` field carries the offending per-envelope axis value verbatim
5824// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5825// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5826// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5827// The middle axis-field name differs across variants (`pin` / `pins` /
5828// `caracteristica`) so the ctor family below takes the axis field name
5829// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5830// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5831// Self` inherent constructor per typed variant that spells the
5832// uniform two-field construction (`nome.to_string()` /
5833// `<axis>.to_string()`) exactly once.
5834//
5835// The three wire-up sites this fold closes are:
5836// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5837//   (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5838//   pin.to_string() });` inside the `set.len() == 1` branch after the
5839//   `is_some_and(String::is_empty)` iterator);
5840// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5841//   ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5842//   nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5843// - [`Dep::validate_caracteristicas`]'s per-entry
5844//   set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5845//   { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5846//   [`crate::render::insert_first_seen`]).
5847//
5848// Each opened the identical four-line struct-literal against the same
5849// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5850// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5851// same altitude the peer four already-lifted `DepError` ctor families
5852// closed on their sibling shape-envelopes. The three variant / axis-
5853// field discriminators are the only things that vary between them;
5854// the rest of the struct-literal is a byte-for-byte re-inline.
5855//
5856// Every future consumer wanting to raise one of these three
5857// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5858// at lacre-resolve time re-checking each declared dep against the
5859// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5860// set-not-multiset cascade, a future `feira validate --deps` per-
5861// caixa admission verb re-running the shape gates on demand, a
5862// per-lacre overlay resolver rejecting an author-supplied dep against
5863// a cluster-local snapshot the M4 CR materializer projects) now
5864// reaches one dispatch rather than re-inlining the four-line struct-
5865// literal in lockstep with the three in-crate wire-up sites.
5866macro_rules! dep_nome_axis_ctors {
5867    ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5868        impl DepError {
5869            $(
5870                #[doc = concat!(
5871                    "Construct a [`DepError::",
5872                    stringify!($variant),
5873                    "`] naming the offending `:deps :nome` and the ",
5874                    "offending `:", stringify!($axis), "` axis value. ",
5875                    "Folds the uniform `Self::",
5876                    stringify!($variant),
5877                    " { nome: nome.to_string(), ",
5878                    stringify!($axis),
5879                    ": ",
5880                    stringify!($axis),
5881                    ".to_string() }` two-field struct-literal onto one ",
5882                    "substrate primitive so every in-crate wire-up on ",
5883                    "this variant reads through one dispatch rather than ",
5884                    "the pre-lift four-line open-coded block. Both `nome: ",
5885                    "&str` and `",
5886                    stringify!($axis),
5887                    ": &str` parameters accept `&str` literals and ",
5888                    "`&String` (via Deref coercion) so every existing ",
5889                    "wire-up threads through the ctor without a pre-",
5890                    "conversion."
5891                )]
5892                #[must_use]
5893                pub fn $ctor(nome: &str, $axis: &str) -> Self {
5894                    Self::$variant {
5895                        nome: nome.to_string(),
5896                        $axis: $axis.to_string(),
5897                    }
5898                }
5899            )*
5900        }
5901    };
5902}
5903
5904dep_nome_axis_ctors! {
5905    fonte_pin_empty => FontePinEmpty { pin },
5906    fonte_pin_ambiguous => FontePinAmbiguous { pins },
5907    caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5908}
5909
5910// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5911// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5912// struct-variant wire-up sites at [`DepSource::validate`]'s
5913// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5914// the `DepError` envelope — the last open-coded ctor site remaining on
5915// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5916// carries, and the single-variant sibling of the peer four already-
5917// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5918// on the two-slot `{ nome, caminho }` envelope,
5919// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5920// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5921// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5922// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5923// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5924// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5925// `{ …, value: String, reason: String }` payload shape, one axis
5926// removed at the `nome`-only-owner altitude the `DepError` envelope
5927// keys off (no `edge_pair()` de/para pair).
5928//
5929// The two wire-up sites this fold closes are the paired refname-pin
5930// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5931// pin: pin.to_string(), value: v.clone(), reason }` inside the
5932// `[(":tag", tag), (":branch", branch)]` iterator against
5933// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5934// (`|| DepError::FontePinShape { nome: nome.to_string(),
5935// pin: ":rev".to_string(), value: v.clone(), reason }` against
5936// [`crate::render::is_git_oid`]) — each opened the identical
5937// `DepError::FontePinShape { … }` six-line struct-literal against the
5938// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5939// tuple, the exact "same block re-inlined at every consumer" shape
5940// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5941// the only thing that varies between them (`":tag"`/`":branch"` on
5942// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5943// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5944// route through the same ctor because their `pin` field carries the
5945// author-surface tag verbatim (matching the `FontePinEmpty` /
5946// `FontePinAmbiguous` sibling variants' `pin: String` axis
5947// convention), so the offending author can grep their caixa.lisp for
5948// the offending `:tag "<value>"` / `:branch "<value>"` /
5949// `:rev "<value>"` literal in one edit.
5950//
5951// The single ctor below folds each wire-up onto one dispatch:
5952// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5953// the pre-lift struct-literal on the same `(&str, &str, &str,
5954// String)` fixture. The uniform four-field construction
5955// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5956// `reason` forwarded owned) is spelled once here rather than at every
5957// wire-up site. The `reason: String` field takes an owned `String`
5958// (not `impl Into<String>`) matching the two call sites' pre-existing
5959// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5960// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5961// predicates return `Result<(), String>`, so the caller always holds
5962// an owned `String` at the wire-up site and threading it through the
5963// ctor without a `.into()` shim keeps the routing shape byte-equal to
5964// the pre-lift block. The `value: &str` parameter accepts both `&str`
5965// literals (unused today) and `&String` (from the caller-held
5966// `v: &String` on each arm, via Deref coercion), so every existing
5967// wire-up threads through the ctor without a pre-conversion.
5968//
5969// Every future consumer that wants to construct this variant outside
5970// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5971// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5972// re-checking the same value-shape axes the resolver consumes, a
5973// future `feira validate --deps` per-caixa admission verb re-checking
5974// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5975// resolver rejecting a git-pin value against a cluster-local
5976// snapshot) now reaches this variant through one call rather than
5977// re-inlining the six-line struct-literal in lockstep with the two
5978// in-crate wire-up sites.
5979impl DepError {
5980    /// Construct a [`DepError::FontePinShape`] naming the offending
5981    /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5982    /// axis tag, the offending value, and the parser-shaped `reason`.
5983    /// Folds the uniform
5984    /// `Self::FontePinShape { nome: nome.to_string(),
5985    /// pin: pin.to_string(), value: value.to_string(), reason }`
5986    /// four-field struct-literal onto one substrate primitive so
5987    /// every [`DepSource::validate`] wire-up on this variant reads
5988    /// through one dispatch rather than the pre-lift six-line
5989    /// open-coded block. The `nome` string threads verbatim from
5990    /// [`Dep::nome`] at the call site; the `pin` string carries the
5991    /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5992    /// `value` string carries the offending refname / hex-OID
5993    /// verbatim; and `reason` forwards the owned `String` returned
5994    /// by [`crate::render::is_git_ref_name`] /
5995    /// [`crate::render::is_git_oid`] without a `.into()` shim.
5996    #[must_use]
5997    pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5998        Self::FontePinShape {
5999            nome: nome.to_string(),
6000            pin: pin.to_string(),
6001            value: value.to_string(),
6002            reason,
6003        }
6004    }
6005
6006    /// Construct a [`DepError::NomeInvalid`] naming the offending
6007    /// `:deps :nome` byte-string and the parser-shaped rejection
6008    /// `reason` returned by [`crate::render::is_dns_1123_label`].
6009    ///
6010    /// Folds the uniform
6011    /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
6012    /// struct-literal onto one substrate primitive so every wire-up on
6013    /// this variant reads through one dispatch rather than the pre-lift
6014    /// four-line open-coded `DepError::NomeInvalid { nome:
6015    /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
6016    /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
6017    /// ctor-family ladder (`{ nome }` one-slot →
6018    /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
6019    /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
6020    /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
6021    /// `{ nome, <axis>: String, reason: String }` three-slot →
6022    /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
6023    /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
6024    /// — the sole variant on the envelope carrying the
6025    /// `{ nome: String, reason: String }` two-slot shape without a
6026    /// middle axis, matching the peer
6027    /// [`crate::manifest::ManifestError::NomeInvalid`] +
6028    /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
6029    /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
6030    /// four-axis DNS-1123 caixa-identifier diagnostic family the
6031    /// existing `nome_invalid_diagnostic_carries_offending_name` test
6032    /// pins on this envelope.
6033    ///
6034    /// The `nome: &str` parameter accepts `&str` literals and `&String`
6035    /// (via Deref coercion) so the sole in-crate wire-up threads through
6036    /// the ctor without a pre-conversion; the `reason: String`
6037    /// parameter takes an owned `String` (not `impl Into<String>`)
6038    /// matching the [`crate::render::is_dns_1123_label`] predicate's
6039    /// `Result<(), String>` return shape the sole wire-up site already
6040    /// holds owned at the call site, keeping the routing byte-equal to
6041    /// the pre-lift block. Same owned-`String`-forward `reason` payload
6042    /// discipline as the sibling three-slot family
6043    /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
6044    /// and the four-slot [`DepError::fonte_pin_shape`] on
6045    /// `{ nome, pin, value, reason }`.
6046    ///
6047    /// Every future consumer that raises the same diagnostic outside
6048    /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
6049    /// re-validator at lacre-resolve time re-checking each declared
6050    /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
6051    /// side schema uses (the `:nome` value flows verbatim as the target
6052    /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
6053    /// segment, the `LABEL_PROGRAM` label value, and the resolver's
6054    /// checkout-directory leaf), a future `feira validate --deps`
6055    /// per-caixa admission verb re-running the shape gate on demand, a
6056    /// per-lacre overlay resolver rejecting an author-supplied dep's
6057    /// `:nome` against a cluster-local snapshot the M4 CR materializer
6058    /// projects, a future authoring-surface widening the field into a
6059    /// `(String, Vec<Suggestion>)` pair carrying a
6060    /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
6061    /// variant through one call rather than re-inlining the four-line
6062    /// struct-literal in lockstep with the one in-crate wire-up site.
6063    #[must_use]
6064    pub fn nome_invalid(nome: &str, reason: String) -> Self {
6065        Self::NomeInvalid {
6066            nome: nome.to_string(),
6067            reason,
6068        }
6069    }
6070}
6071
6072#[allow(clippy::trivially_copy_pass_by_ref)]
6073fn is_false(b: &bool) -> bool {
6074    !*b
6075}
6076
6077#[cfg(test)]
6078mod tests {
6079    use super::*;
6080
6081    #[test]
6082    fn registry_dep_is_minimal() {
6083        let d = Dep::simple("caixa-teia", "^0.1");
6084        assert_eq!(d.nome, "caixa-teia");
6085        assert_eq!(d.versao, "^0.1");
6086        assert!(d.fonte.is_none());
6087        assert!(!d.opcional());
6088        assert!(d.caracteristicas().is_empty());
6089    }
6090
6091    #[test]
6092    fn dep_string_scalar_accessor_pair_is_const_fn() {
6093        // Fail-before-pass-after pin on [`Dep::nome`] +
6094        // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
6095        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6096        // entry's [`String`] storage through the `pub const fn`
6097        // [`String::as_str`] (const-stable since Rust 1.87, well
6098        // within the workspace MSRV) — any future accidental
6099        // downgrade to non-`const` fails the corresponding
6100        // `<name>_via_const_fn` wrapper at caixa-core build time with
6101        // E0015 (`cannot call non-const method`), strictly stronger
6102        // than a runtime `assert!`. Sibling of the peer
6103        // per-M2/M3/universal-axis `String → &str` scalar-accessor
6104        // family pins on the sibling `const`-eval-surface passes
6105        // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
6106        // top-level manifest, [`crate::CaixaVersion::as_str`] at the
6107        // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
6108        // [`crate::aplicacao::Membro::versao_requirement`] at the M3
6109        // membership axis, [`crate::aplicacao::Entrada::hostname`] /
6110        // [`crate::aplicacao::Entrada::destination`] at the M3
6111        // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
6112        // [`crate::supervisor::ChildSpec::versao_requirement`] at the
6113        // M2 supervisor-tree axis,
6114        // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
6115        // M2 upgrade axis, and the per-`:contratos`
6116        // [`crate::aplicacao::WitContract::source`] /
6117        // [`crate::aplicacao::WitContract::destination`] /
6118        // [`crate::aplicacao::WitContract::world_ref`] trio the
6119        // sibling pin at 279823b already anchors).
6120        const fn nome_via_const_fn(d: &Dep) -> &str {
6121            d.nome()
6122        }
6123        const fn versao_via_const_fn(d: &Dep) -> &str {
6124            d.versao_requirement()
6125        }
6126        for (nome, versao) in [
6127            ("caixa-teia", "^0.1"),
6128            ("caixa-mesh", "~0.2.3"),
6129            ("caixa-helm", "*"),
6130        ] {
6131            let d = Dep::simple(nome, versao);
6132            assert_eq!(nome_via_const_fn(&d), d.nome());
6133            assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
6134            assert_eq!(d.nome(), nome);
6135            assert_eq!(d.versao_requirement(), versao);
6136        }
6137    }
6138
6139    #[test]
6140    fn dep_outer_accessor_family_is_const_fn() {
6141        // Fail-before-pass-after pin on [`Dep::fonte`] +
6142        // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
6143        // Each accessor projects the per-`:deps` / per-`:deps-dev`
6144        // entry's composite / list storage through a `pub const fn`
6145        // stdlib method (`Option::<DepSource>::as_ref` /
6146        // `Vec::<String>::as_slice`, both const-stable since Rust
6147        // 1.83, well within the workspace MSRV). Any future
6148        // accidental downgrade to non-`const` fails the corresponding
6149        // `<name>_via_const_fn` wrapper at caixa-core build time with
6150        // E0015 (`cannot call non-const method`), strictly stronger
6151        // than a runtime `assert!` and side-stepping the destructor-
6152        // in-const restriction the `Dep` fixture's `String` /
6153        // `Option<DepSource>` / `Vec<String>` carriers rule out on the
6154        // direct-`const _: () = assert!(...)` residence.
6155        //
6156        // Peer of the sibling per-`Dep` scalar-accessor pair pin
6157        // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
6158        // outer per-dep-list-entry [`Dep`] altitude — this pin extends
6159        // the `const`-eval-surface discipline onto the composite-
6160        // reference and slice-return arms of the outer-`Dep` accessor
6161        // family, closing the four-slot outer surface (`:nome` +
6162        // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
6163        // posture. The `:opcional` `bool` arm already carries the
6164        // posture through [`Dep::opcional`]'s prior `pub const fn`
6165        // declaration, so this pin lands the last two unlifted
6166        // outer-`Dep` accessors and closes the family.
6167        const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
6168            d.fonte()
6169        }
6170        const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
6171            d.caracteristicas()
6172        }
6173        // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
6174        let empty = Dep::simple("caixa-teia", "^0.1");
6175        assert!(fonte_via_const_fn(&empty).is_none());
6176        assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
6177        assert!(caracteristicas_via_const_fn(&empty).is_empty());
6178        assert_eq!(
6179            caracteristicas_via_const_fn(&empty),
6180            empty.caracteristicas()
6181        );
6182        // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
6183        // still empty.
6184        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
6185        assert!(fonte_via_const_fn(&git).is_some());
6186        assert_eq!(fonte_via_const_fn(&git), git.fonte());
6187        assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
6188        // Populated `:caracteristicas` — exercise the non-empty
6189        // slice-view arm to pin the accessor's borrow shape against
6190        // both a `Vec::new()` empty backing buffer and a populated one.
6191        let mut with_features = Dep::simple("caixa-teia", "^0.1");
6192        with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
6193        assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
6194        assert_eq!(
6195            caracteristicas_via_const_fn(&with_features),
6196            with_features.caracteristicas()
6197        );
6198    }
6199
6200    #[test]
6201    fn git_dep_carries_tag() {
6202        let d = Dep::git("t", "*", "github:o/r", "v1");
6203        match d.fonte {
6204            Some(DepSource::Git {
6205                ref repo, ref tag, ..
6206            }) => {
6207                assert_eq!(repo, "github:o/r");
6208                assert_eq!(tag.as_deref(), Some("v1"));
6209            }
6210            _ => panic!("expected Git source"),
6211        }
6212    }
6213
6214    #[test]
6215    fn validate_accepts_simple_dep() {
6216        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
6217    }
6218
6219    #[test]
6220    fn validate_rejects_empty_nome() {
6221        // The fail-before-pass-after pin for `:nome ""`: the empty-name
6222        // arm fires first so the per-entry parse-side diagnostic doesn't
6223        // emit a useless `nome: ""` reference.
6224        let mut d = Dep::simple("placeholder", "^0.1");
6225        d.nome = String::new();
6226        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6227    }
6228
6229    #[test]
6230    fn validate_rejects_empty_versao() {
6231        // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
6232        // semver crate accepts the empty string as a wildcard match),
6233        // so the empty-`:versao` arm is structurally necessary even
6234        // with the parse arm in place — mirrors `MembroVersaoEmpty` /
6235        // `EmptyChildVersion` ordering on the other two `:versao` axes.
6236        let mut d = Dep::simple("caixa-teia", "ignored");
6237        d.versao = String::new();
6238        let err = d.validate().unwrap_err();
6239        assert!(
6240            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6241            "got {err:?}"
6242        );
6243    }
6244
6245    // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
6246
6247    #[test]
6248    fn validate_rejects_nome_with_uppercase() {
6249        // The fail-before-pass-after pin: a non-empty but uppercase
6250        // `:nome` silently passed `validate()` on every pre-gate
6251        // codebase because the prior shape only refused the empty
6252        // string. The DNS-1123 violation surfaced far downstream at
6253        // lacre-resolve time when the *target* caixa's `:nome` failed
6254        // its own gate — far from the `:deps` entry, with a diagnostic
6255        // naming the target rather than the dep entry that referenced
6256        // it. Same fail-before-pass-after fixture pinned for
6257        // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
6258        // and Caixa `:nome` (6c992f8).
6259        let d = Dep::simple("Caixa-Teia", "^0.1");
6260        let err = d.validate().unwrap_err();
6261        assert!(
6262            matches!(
6263                err,
6264                DepError::NomeInvalid { ref nome, ref reason }
6265                    if nome == "Caixa-Teia" && reason.contains("uppercase")
6266            ),
6267            "got {err:?}"
6268        );
6269    }
6270
6271    #[test]
6272    fn validate_rejects_nome_with_underscore() {
6273        // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
6274        // "I'm thinking of Go module names / Python identifiers" leak.
6275        // Same fixture pinned for the peer caixa-identifier axes.
6276        let d = Dep::simple("caixa_teia", "^0.1");
6277        let err = d.validate().unwrap_err();
6278        assert!(
6279            matches!(
6280                err,
6281                DepError::NomeInvalid { ref nome, ref reason }
6282                    if nome == "caixa_teia" && reason.contains('_')
6283            ),
6284            "got {err:?}"
6285        );
6286    }
6287
6288    #[test]
6289    fn validate_rejects_nome_with_dot() {
6290        // A `:deps :nome` is a single DNS-1123 *label*, not a
6291        // subdomain — dots are rejected. The `"caixa.teia"` shape is
6292        // the canonical "I confused the dep name with the FQDN /
6293        // namespace" footgun, distinct from the legitimate
6294        // `:fonte :repo "github:org/caixa-teia"` axis.
6295        let d = Dep::simple("caixa.teia", "^0.1");
6296        let err = d.validate().unwrap_err();
6297        assert!(
6298            matches!(
6299                err,
6300                DepError::NomeInvalid { ref nome, ref reason }
6301                    if nome == "caixa.teia" && reason.contains('.')
6302            ),
6303            "got {err:?}"
6304        );
6305    }
6306
6307    #[test]
6308    fn validate_rejects_nome_with_leading_hyphen() {
6309        // RFC 1123 requires alphanumeric at both label boundaries.
6310        // Pinned in parity with the peer DNS-1123 fixtures.
6311        let d = Dep::simple("-caixa-teia", "^0.1");
6312        let err = d.validate().unwrap_err();
6313        assert!(
6314            matches!(
6315                err,
6316                DepError::NomeInvalid { ref nome, ref reason }
6317                    if nome == "-caixa-teia" && reason.contains("alphanumeric")
6318            ),
6319            "got {err:?}"
6320        );
6321    }
6322
6323    #[test]
6324    fn validate_rejects_nome_with_trailing_hyphen() {
6325        let d = Dep::simple("caixa-teia-", "^0.1");
6326        let err = d.validate().unwrap_err();
6327        assert!(
6328            matches!(
6329                err,
6330                DepError::NomeInvalid { ref nome, ref reason }
6331                    if nome == "caixa-teia-" && reason.contains("alphanumeric")
6332            ),
6333            "got {err:?}"
6334        );
6335    }
6336
6337    #[test]
6338    fn validate_rejects_nome_with_slash() {
6339        // The canonical "I copied the GitHub repo path into `:nome`
6340        // instead of `:fonte :repo`" typo. A `/` in the name leaks the
6341        // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
6342        // the local-name slot. Same fixture pinned for `:membros
6343        // :caixa` (3f9d7a0).
6344        let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
6345        let err = d.validate().unwrap_err();
6346        assert!(
6347            matches!(
6348                err,
6349                DepError::NomeInvalid { ref nome, ref reason }
6350                    if nome == "pleme-io/caixa-teia" && reason.contains('/')
6351            ),
6352            "got {err:?}"
6353        );
6354    }
6355
6356    #[test]
6357    fn validate_rejects_nome_too_long() {
6358        // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
6359        // Built from a valid character set so the length-bound
6360        // diagnostic surfaces before any per-character check (the
6361        // order pin parallel to the per-character predicates inside
6362        // [`crate::render::is_dns_1123_label`]).
6363        let long = "a".repeat(64);
6364        let d = Dep::simple(&long, "^0.1");
6365        let err = d.validate().unwrap_err();
6366        assert!(
6367            matches!(
6368                err,
6369                DepError::NomeInvalid { ref nome, ref reason }
6370                    if nome.len() == 64 && reason.contains("max length of 63")
6371            ),
6372            "got {err:?}"
6373        );
6374    }
6375
6376    #[test]
6377    fn validate_accepts_canonical_nome_labels() {
6378        // Positive-control sweep — every form the K8s apiserver
6379        // accepts as a DNS-1123 label must round-trip through
6380        // validate. Covers a hyphen-bearing label, a numeric-suffix
6381        // label, a leading-digit label, a single-character label, and
6382        // a 63-byte (exactly the cap) label — the same fixture set
6383        // the peer `:membros :caixa` / `:children :caixa` positive
6384        // controls pin.
6385        for nome in [
6386            "caixa-teia",
6387            "caixa-resolver2",
6388            "2nd-tier-cache",
6389            "x",
6390            "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
6391        ] {
6392            Dep::simple(nome, "^0.1")
6393                .validate()
6394                .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
6395        }
6396    }
6397
6398    #[test]
6399    fn nome_empty_takes_precedence_over_nome_invalid() {
6400        // Ordering pin: `NomeEmpty` is the more self-locating
6401        // diagnostic on `""` and must lead — `is_dns_1123_label` is
6402        // only reached after the empty-check fires at the call site.
6403        // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
6404        // (3f9d7a0) on the peer caixa-identifier axis.
6405        let mut d = Dep::simple("placeholder", "^0.1");
6406        d.nome = String::new();
6407        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
6408    }
6409
6410    #[test]
6411    fn nome_invalid_fires_before_versao_empty() {
6412        // Ordering pin: a malformed `:nome` fires before any `:versao`
6413        // axis check on the *same* entry — the per-entry shape gates
6414        // run top-to-bottom (nome empty → nome shape → versao empty →
6415        // versao parse → fonte shape), so a one-entry caixa.lisp with
6416        // both wrong sees the name-side diagnostic first (the name is
6417        // the self-locating axis — without a valid name, the parse
6418        // diagnostic can't quote `:nome "<bad>"`). Same ordering
6419        // discipline as `membro_caixa_invalid_fires_before_versao_check`
6420        // (3f9d7a0).
6421        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6422        d.versao = String::new();
6423        let err = d.validate().unwrap_err();
6424        assert!(
6425            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6426            "got {err:?}"
6427        );
6428    }
6429
6430    #[test]
6431    fn nome_invalid_fires_before_versao_invalid() {
6432        // Ordering pin: a malformed `:nome` fires before the `:versao`
6433        // parse-side check on the *same* entry. Pin separately from
6434        // the empty-versao ordering so a future re-ordering surfaces
6435        // here, parallel to the b0c8389 / c4213a4 trajectory.
6436        let d = Dep::simple("Caixa-Teia", "^^0.1");
6437        let err = d.validate().unwrap_err();
6438        assert!(
6439            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6440            "got {err:?}"
6441        );
6442    }
6443
6444    #[test]
6445    fn nome_invalid_fires_before_fonte_invalid() {
6446        // Ordering pin: a malformed `:nome` fires before the `:fonte`
6447        // shape check on the *same* entry. The `:fonte` diagnostic
6448        // names the offending dep's `:nome` verbatim (via
6449        // `DepSource::validate(&self.nome)`), so a non-self-locating
6450        // name would taint the downstream diagnostic too — the gate
6451        // ordering keeps both diagnostics individually self-locating.
6452        let mut d = Dep::simple("Caixa-Teia", "^0.1");
6453        d.fonte = Some(DepSource::Git {
6454            repo: String::new(),
6455            tag: None,
6456            rev: None,
6457            branch: None,
6458        });
6459        let err = d.validate().unwrap_err();
6460        assert!(
6461            matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
6462            "got {err:?}"
6463        );
6464    }
6465
6466    #[test]
6467    fn nome_invalid_diagnostic_carries_offending_name() {
6468        // The diagnostic-shape pin: the error names the offending
6469        // `:nome` value verbatim so the author can grep their
6470        // caixa.lisp without re-running the build, and carries a
6471        // non-empty `reason` from `is_dns_1123_label` so the
6472        // predicate's own wording flows through to the diagnostic.
6473        // Same shape as `MembroCaixaInvalid` (3f9d7a0),
6474        // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
6475        // (6c992f8) — the four DNS-1123 caixa-identifier axes now
6476        // share a structurally-equivalent diagnostic family.
6477        let d = Dep::simple("Caixa_Teia", "^0.1");
6478        let err = d.validate().unwrap_err();
6479        let DepError::NomeInvalid { nome, reason } = err else {
6480            panic!("expected NomeInvalid, got other variant");
6481        };
6482        assert_eq!(nome, "Caixa_Teia");
6483        assert!(
6484            !reason.is_empty(),
6485            "NomeInvalid `reason` must carry the predicate's wording verbatim"
6486        );
6487    }
6488
6489    #[test]
6490    fn validate_rejects_invalid_versao_requirement() {
6491        // The fail-before-pass-after pin: a non-empty but malformed
6492        // requirement (`"^bad-version"`) silently passed every pre-gate
6493        // codebase because `:deps :versao` wasn't validated. The parse
6494        // failure surfaced far downstream at lacre-resolve time with a
6495        // `semver::Error` that didn't name which `:deps` entry carried
6496        // the typo. The new gate moves the check to caixa-build time
6497        // at the source caixa.lisp.
6498        let d = Dep::simple("caixa-teia", "^bad-version");
6499        let err = d.validate().unwrap_err();
6500        assert!(
6501            matches!(
6502                err,
6503                DepError::VersaoInvalid { ref nome, ref versao, .. }
6504                    if nome == "caixa-teia" && versao == "^bad-version"
6505            ),
6506            "got {err:?}"
6507        );
6508    }
6509
6510    #[test]
6511    fn validate_rejects_versao_with_double_caret_typo() {
6512        // `"^^0.1"` is the canonical doubled-caret typo — looks like a
6513        // Cargo-shaped requirement on first glance but fails the parser
6514        // because semver doesn't accept stacked operators. Pin this
6515        // adjacent-shape footgun explicitly so a future relaxation that
6516        // accepts "looks-canonical-but-isn't" forms surfaces here, in
6517        // parity with the `:membros` / `:children` fixtures.
6518        let d = Dep::simple("caixa-teia", "^^0.1");
6519        let err = d.validate().unwrap_err();
6520        assert!(
6521            matches!(
6522                err,
6523                DepError::VersaoInvalid { ref nome, ref versao, .. }
6524                    if nome == "caixa-teia" && versao == "^^0.1"
6525            ),
6526            "got {err:?}"
6527        );
6528    }
6529
6530    #[test]
6531    fn validate_rejects_versao_with_v_prefixed_tag() {
6532        // `"v0.1"` is the canonical "git-tag-shape leaking into the
6533        // semver requirement slot" typo — an author copies the
6534        // publish-side git-tag string verbatim into `:versao`, but
6535        // Cargo's semver parser rejects the leading `v`. Same fixture
6536        // pinned for `:membros :versao` (9888b13) and `:children
6537        // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
6538        // are *accepted* by the semver crate as an `*` wildcard on the
6539        // patch axis — they're a Cargo-side valid shape, not a typo.)
6540        let d = Dep::simple("caixa-teia", "v0.1");
6541        let err = d.validate().unwrap_err();
6542        assert!(
6543            matches!(
6544                err,
6545                DepError::VersaoInvalid { ref nome, ref versao, .. }
6546                    if nome == "caixa-teia" && versao == "v0.1"
6547            ),
6548            "got {err:?}"
6549        );
6550    }
6551
6552    #[test]
6553    fn validate_accepts_canonical_versao_forms() {
6554        // The five Cargo-shaped requirement forms `:membros :versao`
6555        // and `:children :versao` already accept via
6556        // `crate::parse_requirement` must pass the deps gate without
6557        // re-validating at the resolver layer. Pin every leg so a
6558        // future tightening of the canonical set surfaces here as a
6559        // test failure.
6560        for form in [
6561            "^0.1",      // caret — minor-range pin (the most common shape)
6562            "~0.1.2",    // tilde — patch-range pin
6563            "0.1.0",     // exact — single-version pin
6564            "*",         // wildcard — explicitly any-version
6565            ">=0.1, <2", // multi-range — comma-separated comparators
6566        ] {
6567            Dep::simple("caixa-teia", form)
6568                .validate()
6569                .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6570        }
6571    }
6572
6573    #[test]
6574    fn versao_empty_takes_precedence_over_invalid() {
6575        // Order pin: the existing `VersaoEmpty` diagnostic (which
6576        // doesn't try to parse) fires before the new `VersaoInvalid`
6577        // parse-side diagnostic, so an empty `:versao` keeps its
6578        // narrower error message — `parse_requirement("")` would
6579        // otherwise return `Ok(STAR)` and silently pass, but the empty
6580        // arm catches it first.
6581        let mut d = Dep::simple("caixa-teia", "ignored");
6582        d.versao = String::new();
6583        let err = d.validate().unwrap_err();
6584        assert!(
6585            matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6586            "got {err:?}"
6587        );
6588    }
6589
6590    #[test]
6591    fn nome_empty_takes_precedence_over_versao_invalid() {
6592        // Order pin: even when `:versao` is malformed and would raise
6593        // its own diagnostic, `:nome ""` fires first because the
6594        // per-entry parse diagnostic needs a non-empty name to be
6595        // self-locating. Mirrors the
6596        // `membros_validation_runs_before_contratos_membership_check`
6597        // ordering on the typed-graph layer.
6598        let mut d = Dep::simple("placeholder", "^bad");
6599        d.nome = String::new();
6600        let err = d.validate().unwrap_err();
6601        assert_eq!(err, DepError::NomeEmpty);
6602    }
6603
6604    #[test]
6605    fn versao_invalid_diagnostic_carries_offending_versao() {
6606        // The diagnostic-shape pin: the error names the offending
6607        // `:versao` value verbatim so the author can grep their
6608        // caixa.lisp without re-running the build, and carries a
6609        // non-empty `reason` from `semver::VersionReq::parse` so the
6610        // parser's own wording flows through to the diagnostic.
6611        let d = Dep::simple("caixa-teia", "not-a-req");
6612        let err = d.validate().unwrap_err();
6613        let DepError::VersaoInvalid {
6614            nome,
6615            versao,
6616            reason,
6617        } = err
6618        else {
6619            panic!("expected VersaoInvalid, got other variant");
6620        };
6621        assert_eq!(nome, "caixa-teia");
6622        assert_eq!(versao, "not-a-req");
6623        assert!(
6624            !reason.is_empty(),
6625            "VersaoInvalid `reason` must carry the parser's wording verbatim"
6626        );
6627    }
6628
6629    // -- :fonte value-shape gate ------------------------------------------
6630
6631    fn dep_with_fonte(fonte: DepSource) -> Dep {
6632        let mut d = Dep::simple("caixa-teia", "^0.1");
6633        d.fonte = Some(fonte);
6634        d
6635    }
6636
6637    #[test]
6638    fn validate_accepts_git_fonte_with_tag() {
6639        // The positive-control pin on the canonical git source — exactly
6640        // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6641        // shape every existing caixa-resolver integration test uses.
6642        let d = dep_with_fonte(DepSource::Git {
6643            repo: "github:pleme-io/caixa-teia".into(),
6644            tag: Some("v0.1.0".into()),
6645            rev: None,
6646            branch: None,
6647        });
6648        d.validate().unwrap();
6649    }
6650
6651    #[test]
6652    fn validate_accepts_git_fonte_with_rev() {
6653        // Each of the three pin axes is independently a valid single-pin
6654        // shape; pin the :rev arm so a future relaxation that only
6655        // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6656        // OID — the canonical `git rev-parse HEAD` emission shape the
6657        // `crate::render::is_git_oid` value-shape gate now requires;
6658        // abbreviated OIDs are ambiguous across repo history and
6659        // rejected at this gate (pinned separately by
6660        // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6661        let d = dep_with_fonte(DepSource::Git {
6662            repo: "github:pleme-io/caixa-teia".into(),
6663            tag: None,
6664            rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6665            branch: None,
6666        });
6667        d.validate().unwrap();
6668    }
6669
6670    #[test]
6671    fn validate_accepts_git_fonte_with_branch() {
6672        // The :branch arm is the third valid single-pin shape — pinned
6673        // separately so the gate-accepts-all-three-pin-axes contract is
6674        // a build-error to relax.
6675        let d = dep_with_fonte(DepSource::Git {
6676            repo: "github:pleme-io/caixa-teia".into(),
6677            tag: None,
6678            rev: None,
6679            branch: Some("main".into()),
6680        });
6681        d.validate().unwrap();
6682    }
6683
6684    #[test]
6685    fn validate_accepts_path_fonte() {
6686        // The positive-control pin on the path source — non-empty
6687        // :caminho, no pin axes (paths have no commit identity). Pinned
6688        // so a future "paths must also pin a rev" tightening surfaces
6689        // here as a structural decision, not a silent break.
6690        let d = dep_with_fonte(DepSource::Path {
6691            caminho: "../caixa-teia".into(),
6692        });
6693        d.validate().unwrap();
6694    }
6695
6696    #[test]
6697    fn validate_rejects_git_fonte_with_empty_repo() {
6698        // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6699        // "v1")`: the empty-repo shape silently passed every pre-gate
6700        // codebase because `:fonte` wasn't validated. The git-clone
6701        // failure surfaced far downstream at lacre-resolve time with no
6702        // field naming which `:deps` entry carried the typo. The new
6703        // gate moves the check to caixa-build time at the source
6704        // caixa.lisp.
6705        let d = dep_with_fonte(DepSource::Git {
6706            repo: String::new(),
6707            tag: Some("v0.1.0".into()),
6708            rev: None,
6709            branch: None,
6710        });
6711        let err = d.validate().unwrap_err();
6712        assert!(
6713            matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6714            "got {err:?}"
6715        );
6716    }
6717
6718    // -- :repo value-shape gate -------------------------------------------
6719    //
6720    // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6721    // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6722    // codebase admitted any non-empty string; the new
6723    // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6724    // URL intersection-floor at validate time, peer with the three pin
6725    // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6726    // `is_git_oid`). Every test in this section is a fail-before /
6727    // pass-after pin on a specific authoring footgun.
6728
6729    #[test]
6730    fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6731        // The canonical paste-from-doc footgun on `:repo` — an author
6732        // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6733        // a doc paragraph. Until this gate landed the empty-repo arm
6734        // passed (the string isn't empty), the resolver issued
6735        // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6736        // surfaced at clone time with a quoting-confused error far from
6737        // the source caixa.lisp. Same paste-from-doc footgun the
6738        // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6739        // axis — now closed on the `:repo` URL axis too.
6740        let d = dep_with_fonte(DepSource::Git {
6741            repo: "github:pleme-io/caixa-teia ".into(),
6742            tag: Some("v0.1.0".into()),
6743            rev: None,
6744            branch: None,
6745        });
6746        let err = d.validate().unwrap_err();
6747        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6748            panic!("expected FonteRepoShape, got other variant");
6749        };
6750        assert_eq!(nome, "caixa-teia");
6751        assert_eq!(repo, "github:pleme-io/caixa-teia ");
6752        assert!(
6753            reason.contains("whitespace"),
6754            "reason must surface the whitespace arm, got {reason:?}"
6755        );
6756    }
6757
6758    #[test]
6759    fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6760        // The canonical CLI-argument-injection footgun at the `git clone`
6761        // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6762        // argv parser read the value as a CLI flag, escaping the
6763        // subprocess argument boundary. The `--` separator workaround
6764        // does not fix the typed slot's accepted set; the gate rejects
6765        // the shape upstream at validate time so the resolver never
6766        // invokes a `git clone -…` subprocess.
6767        let d = dep_with_fonte(DepSource::Git {
6768            repo: "-upload-pack=evil".into(),
6769            tag: Some("v0.1.0".into()),
6770            rev: None,
6771            branch: None,
6772        });
6773        let err = d.validate().unwrap_err();
6774        let DepError::FonteRepoShape { repo, reason, .. } = err else {
6775            panic!("expected FonteRepoShape, got other variant");
6776        };
6777        assert_eq!(repo, "-upload-pack=evil");
6778        assert!(
6779            reason.contains("must not start with `-`"),
6780            "reason must surface the leading-`-` arm, got {reason:?}"
6781        );
6782    }
6783
6784    #[test]
6785    fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6786        // The canonical paste-from-multiline-doc footgun — a `:repo`
6787        // string with an embedded `\n` silently breaks git's URL parser
6788        // and is a class of CRLF-injection at the subprocess-argument
6789        // boundary. Caught by the control-char arm (0x0A < 0x20).
6790        let d = dep_with_fonte(DepSource::Git {
6791            repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6792            tag: Some("v0.1.0".into()),
6793            rev: None,
6794            branch: None,
6795        });
6796        let err = d.validate().unwrap_err();
6797        let DepError::FonteRepoShape { reason, .. } = err else {
6798            panic!("expected FonteRepoShape, got other variant");
6799        };
6800        assert!(
6801            reason.contains("control character"),
6802            "reason must surface the control-char arm, got {reason:?}"
6803        );
6804    }
6805
6806    #[test]
6807    fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6808        // Tab is the sibling whitespace footgun (the canonical
6809        // copy-from-aligned-table paste); pinned separately from the
6810        // space arm so a future relaxation that only catches one
6811        // surfaces here.
6812        let d = dep_with_fonte(DepSource::Git {
6813            repo: "github:pleme-io/caixa-teia\t".into(),
6814            tag: Some("v0.1.0".into()),
6815            rev: None,
6816            branch: None,
6817        });
6818        let err = d.validate().unwrap_err();
6819        assert!(
6820            matches!(
6821                err,
6822                DepError::FonteRepoShape { ref reason, .. }
6823                    if reason.contains("whitespace")
6824            ),
6825            "got {err:?}"
6826        );
6827    }
6828
6829    #[test]
6830    fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6831        // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6832        // non-ASCII silently breaks at git's URL parser and round-trips
6833        // inconsistently across NFC/NFD normalization on APFS /
6834        // case-folding filesystems. Same intersection-floor
6835        // [`is_git_ref_name`] enforces on the refname axes.
6836        let d = dep_with_fonte(DepSource::Git {
6837            repo: "https://github.com/pleme-io/café".into(),
6838            tag: Some("v0.1.0".into()),
6839            rev: None,
6840            branch: None,
6841        });
6842        let err = d.validate().unwrap_err();
6843        assert!(
6844            matches!(
6845                err,
6846                DepError::FonteRepoShape { ref reason, .. }
6847                    if reason.contains("non-ASCII")
6848            ),
6849            "got {err:?}"
6850        );
6851    }
6852
6853    #[test]
6854    fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6855        // The fail-before-pass-after pin for the canonical paste-from-
6856        // browser-address-bar footgun on `:repo`: an author copies a
6857        // GitHub permalink to a README anchor / line-permalink and
6858        // forgets to trim the `#fragment` tail. Until this arm landed
6859        // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6860        // silently passed every prior arm (no whitespace, no control
6861        // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6862        // or `:`), libcurl's URL parser stripped the `#readme` tail
6863        // before opening the HTTPS transport, and the lacre embedded
6864        // the value verbatim in its per-dep BLAKE3 closure — two
6865        // authors whose values differ only in their fragment anchor
6866        // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6867        // `git clone` but lock to two distinct lacres, defeating the
6868        // THEORY.md §V.2 render-determinism contract. Same value-shape
6869        // axis-floor every peer typed surface enforces; peer `:fonte
6870        // :tag` / `:fonte :branch` already reject the byte-class through
6871        // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6872        // URL grammar admitted) and `:entrada :paths` rejects `#` as
6873        // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6874        let d = dep_with_fonte(DepSource::Git {
6875            repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6876            tag: Some("v0.1.0".into()),
6877            rev: None,
6878            branch: None,
6879        });
6880        let err = d.validate().unwrap_err();
6881        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6882            panic!("expected FonteRepoShape, got other variant");
6883        };
6884        assert_eq!(nome, "caixa-teia");
6885        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6886        assert!(
6887            reason.contains("must not contain `#`"),
6888            "reason must surface the fragment-`#` arm, got {reason:?}"
6889        );
6890        assert!(
6891            reason.contains("fragment"),
6892            "reason must name the URL fragment grammar, got {reason:?}"
6893        );
6894    }
6895
6896    #[test]
6897    fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6898        // The symmetric paste-from-Nix-flake-ref footgun — an author
6899        // confuses the Nix flake-reference idiom (`github:foo/
6900        // bar#packageName`, where `#packageName` selects a flake
6901        // output) with the bare git `:repo` shape. The pleme-io
6902        // substrate authors compose flakes downstream of caixa
6903        // (caixa-flake renders a flake.nix), so the cross-idiom leak
6904        // is the canonical near-miss: the author writes the
6905        // flake-ref shape into a git `:repo` slot. Pinned separately
6906        // from the HTTPS-anchor arm so a future relaxation that
6907        // narrows to one URL scheme surfaces here.
6908        let d = dep_with_fonte(DepSource::Git {
6909            repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6910            tag: Some("v0.1.0".into()),
6911            rev: None,
6912            branch: None,
6913        });
6914        let err = d.validate().unwrap_err();
6915        let DepError::FonteRepoShape { reason, .. } = err else {
6916            panic!("expected FonteRepoShape, got other variant");
6917        };
6918        assert!(
6919            reason.contains("must not contain `#`"),
6920            "reason must surface the fragment-`#` arm, got {reason:?}"
6921        );
6922        assert!(
6923            reason.contains("Nix flake"),
6924            "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6925        );
6926    }
6927
6928    #[test]
6929    fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6930        // The fail-before-pass-after pin for the canonical paste-from-
6931        // browser-address-bar footgun on `:repo` (peer with the
6932        // a68f818 fragment-`#` arm on the same axis). An author
6933        // copies a GitHub tab deep-link out of the address bar and
6934        // forgets to trim the `?tab=…` query tail. Until this arm
6935        // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6936        // silently passed every prior arm (no whitespace, no control
6937        // chars, no non-ASCII, no `#` fragment, contains a `:`,
6938        // doesn't start with `-` or `:`); GitHub silently ignored
6939        // the `?query` tail and served the same repo regardless;
6940        // the lacre embedded the value verbatim in its per-dep
6941        // BLAKE3 closure — two authors whose values differ only in
6942        // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6943        // `?utm_source=twitter`) resolve to the byte-identical
6944        // upstream `git clone` but lock to two distinct lacres,
6945        // defeating the THEORY.md §V.2 render-determinism contract
6946        // on the same axis the `#` fragment arm closes. Same value-
6947        // shape axis-floor every peer typed surface enforces; peer
6948        // `:fonte :tag` / `:fonte :branch` already reject the byte-
6949        // class through `is_git_ref_name`'s alphabet (refspec glob
6950        // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6951        // :paths` rejects `?` as the query separator in
6952        // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6953        let d = dep_with_fonte(DepSource::Git {
6954            repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6955            tag: Some("v0.1.0".into()),
6956            rev: None,
6957            branch: None,
6958        });
6959        let err = d.validate().unwrap_err();
6960        let DepError::FonteRepoShape { nome, repo, reason } = err else {
6961            panic!("expected FonteRepoShape, got other variant");
6962        };
6963        assert_eq!(nome, "caixa-teia");
6964        assert_eq!(
6965            repo,
6966            "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6967        );
6968        assert!(
6969            reason.contains("must not contain `?`"),
6970            "reason must surface the query-`?` arm, got {reason:?}"
6971        );
6972        assert!(
6973            reason.contains("query"),
6974            "reason must name the URL query grammar, got {reason:?}"
6975        );
6976    }
6977
6978    #[test]
6979    fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6980        // The symmetric paste-from-social-share footgun — an author
6981        // copies a repo URL out of a Slack unfurl / Twitter share /
6982        // newsletter link / Discord embed and forgets to trim the
6983        // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6984        // campaign-tracker tail. Every major social-share / unfurl /
6985        // newsletter platform appends these UTM parameters; the
6986        // canonical near-miss on the `:repo` axis. Pinned separately
6987        // from the GitHub-tab-deep-link arm so a future relaxation
6988        // that narrows to one query-parameter class surfaces here.
6989        let d = dep_with_fonte(DepSource::Git {
6990            repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6991                .into(),
6992            tag: Some("v0.1.0".into()),
6993            rev: None,
6994            branch: None,
6995        });
6996        let err = d.validate().unwrap_err();
6997        let DepError::FonteRepoShape { reason, .. } = err else {
6998            panic!("expected FonteRepoShape, got other variant");
6999        };
7000        assert!(
7001            reason.contains("must not contain `?`"),
7002            "reason must surface the query-`?` arm, got {reason:?}"
7003        );
7004        assert!(
7005            reason.contains("campaign-tracker"),
7006            "reason must name the campaign-tracker paste footgun, got {reason:?}"
7007        );
7008    }
7009
7010    #[test]
7011    fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
7012        // Cascade pin: the fragment-`#` arm and the query-`?` arm are
7013        // both per-byte arms inside the same `for &b in s.as_bytes()`
7014        // loop, so the byte that appears first in the value's byte
7015        // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
7016        // (fragment before query — unusual URL-grammar but value-
7017        // disjoint at byte level) carries both `#` and `?`; the `#`
7018        // byte appears first, so the fragment-`#` arm fires, surfacing
7019        // the more self-locating diagnostic on the byte the author
7020        // pasted earliest in the URL. Mirrors the peer cascade
7021        // discipline `fonte_repo_control_char_fires_before_fragment`
7022        // pins on the prior `:repo` byte-class arm.
7023        let d = dep_with_fonte(DepSource::Git {
7024            repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
7025            tag: Some("v0.1.0".into()),
7026            rev: None,
7027            branch: None,
7028        });
7029        let err = d.validate().unwrap_err();
7030        let DepError::FonteRepoShape { reason, .. } = err else {
7031            panic!("expected FonteRepoShape, got other variant");
7032        };
7033        assert!(
7034            reason.contains("must not contain `#`"),
7035            "reason must surface the fragment-`#` arm (fires before query-`?` when \
7036             `#` byte appears first in value), got {reason:?}"
7037        );
7038    }
7039
7040    #[test]
7041    fn fonte_repo_control_char_fires_before_fragment() {
7042        // Cascade pin: the control-char arm structurally precedes the
7043        // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
7044        // positive on both arms (contains LF and `#`), but the narrower
7045        // POSIX-syscall-rejected / CRLF-injection-class diagnostic
7046        // (`control character`) wins so the author sees the more
7047        // self-locating arm first. Mirrors the peer cascade discipline
7048        // every prior `:repo` byte-class arm establishes.
7049        let d = dep_with_fonte(DepSource::Git {
7050            repo: "github:pleme-io/caixa-teia\n#readme".into(),
7051            tag: Some("v0.1.0".into()),
7052            rev: None,
7053            branch: None,
7054        });
7055        let err = d.validate().unwrap_err();
7056        let DepError::FonteRepoShape { reason, .. } = err else {
7057            panic!("expected FonteRepoShape, got other variant");
7058        };
7059        assert!(
7060            reason.contains("control character"),
7061            "reason must surface the control-char arm, got {reason:?}"
7062        );
7063    }
7064
7065    #[test]
7066    fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
7067        // The fail-before-pass-after pin for the canonical Windows-
7068        // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
7069        // backslash arm on the sibling `:caminho` path-fonte axis).
7070        // An author pastes a Windows Explorer address-bar / PowerShell
7071        // `Get-Location` output into a `file://` URL slot, producing
7072        // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
7073        // value silently passed every prior arm (no whitespace, no
7074        // control chars, no non-ASCII, no `#`, no `?`, doesn't start
7075        // with `-` or `:`); libcurl's URL parser silently translates
7076        // `\` → `/` on some platforms and refuses it on others, so
7077        // the byte rides verbatim into the lacre's per-dep content-
7078        // address but is silently rewritten / rejected at the wire —
7079        // two authors whose `:repo` values differ only in backslash-
7080        // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
7081        // resolve to the byte-identical local clone but lock to two
7082        // distinct BLAKE3 closures, defeating the THEORY.md §V.2
7083        // render-determinism contract on the same axis the `#`
7084        // fragment and `?` query arms close. Same value-shape axis-
7085        // floor every peer typed surface enforces; the `:caminho`
7086        // 3a4e1d7 arm closes the same byte on the path-fonte axis.
7087        let d = dep_with_fonte(DepSource::Git {
7088            repo: "file:///C:\\Users\\me\\caixa-teia".into(),
7089            tag: Some("v0.1.0".into()),
7090            rev: None,
7091            branch: None,
7092        });
7093        let err = d.validate().unwrap_err();
7094        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7095            panic!("expected FonteRepoShape, got other variant");
7096        };
7097        assert_eq!(nome, "caixa-teia");
7098        assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
7099        assert!(
7100            reason.contains("must not contain `\\`"),
7101            "reason must surface the backslash-`\\` arm, got {reason:?}"
7102        );
7103        assert!(
7104            reason.contains("Windows"),
7105            "reason must name the Windows-path-confusion footgun, got {reason:?}"
7106        );
7107    }
7108
7109    #[test]
7110    fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
7111        // The symmetric Win32-shell-mangled-slashes footgun — an author
7112        // copies `https://github.com/foo/bar` into a Win32 shell that
7113        // rewrites every `/` to `\` (the canonical `cmd.exe` path-
7114        // separator-coercion bug), pastes the result into a `:repo`
7115        // slot, and produces `https:\\github.com\foo\bar`. Pinned
7116        // separately from the `file://` Explorer-paste arm so a future
7117        // relaxation that narrows to one URL scheme surfaces here.
7118        let d = dep_with_fonte(DepSource::Git {
7119            repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
7120            tag: Some("v0.1.0".into()),
7121            rev: None,
7122            branch: None,
7123        });
7124        let err = d.validate().unwrap_err();
7125        let DepError::FonteRepoShape { reason, .. } = err else {
7126            panic!("expected FonteRepoShape, got other variant");
7127        };
7128        assert!(
7129            reason.contains("must not contain `\\`"),
7130            "reason must surface the backslash-`\\` arm, got {reason:?}"
7131        );
7132        assert!(
7133            reason.contains("path separator") || reason.contains("path-segment separator"),
7134            "reason must name the URL path-segment separator grammar, got {reason:?}"
7135        );
7136    }
7137
7138    #[test]
7139    fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
7140        // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
7141        // are both per-byte arms inside the same `for &b in s.as_bytes()`
7142        // loop, so the byte that appears first in the value's byte order
7143        // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
7144        // both `#` and `\`; the `#` byte appears first, so the fragment-
7145        // `#` arm fires, surfacing the more self-locating diagnostic on
7146        // the byte the author pasted earliest in the URL. Mirrors the
7147        // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
7148        // pins on the prior `:repo` byte-class arm.
7149        let d = dep_with_fonte(DepSource::Git {
7150            repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
7151            tag: Some("v0.1.0".into()),
7152            rev: None,
7153            branch: None,
7154        });
7155        let err = d.validate().unwrap_err();
7156        let DepError::FonteRepoShape { reason, .. } = err else {
7157            panic!("expected FonteRepoShape, got other variant");
7158        };
7159        assert!(
7160            reason.contains("must not contain `#`"),
7161            "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
7162             `#` byte appears first in value), got {reason:?}"
7163        );
7164    }
7165
7166    #[test]
7167    fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
7168        // The fail-before-pass-after pin for the canonical URI Template
7169        // (RFC 6570) placeholder footgun on `:repo`. An author copies a
7170        // README quick-start snippet / OpenAPI `servers:` URL / Helm
7171        // chart `home:` template that carries unresolved
7172        // `{org}` / `{repo}` placeholders and pastes the raw template
7173        // into the `:repo` slot, expecting the substrate to resolve the
7174        // placeholder downstream. Until this arm landed the value
7175        // silently passed every prior arm (no whitespace, no control
7176        // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
7177        // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
7178        // / `%7D` on the wire, so the byte rides verbatim into the
7179        // lacre's per-dep content-address but round-trips inconsistently
7180        // between the lacre's per-dep content-address and the
7181        // resolver's `git clone <repo>` invocation, defeating the
7182        // THEORY.md §V.2 render-determinism contract on the same axis
7183        // the `#` fragment, `?` query, and `\` backslash arms close;
7184        // every git porcelain entry-point additionally fetches a
7185        // nonexistent literal-`{placeholder}`-named path far from the
7186        // source caixa.lisp.
7187        let d = dep_with_fonte(DepSource::Git {
7188            repo: "https://github.com/{org}/caixa-teia".into(),
7189            tag: Some("v0.1.0".into()),
7190            rev: None,
7191            branch: None,
7192        });
7193        let err = d.validate().unwrap_err();
7194        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7195            panic!("expected FonteRepoShape, got other variant");
7196        };
7197        assert_eq!(nome, "caixa-teia");
7198        assert_eq!(repo, "https://github.com/{org}/caixa-teia");
7199        assert!(
7200            reason.contains("must not contain `{`"),
7201            "reason must surface the open-brace `{{` arm, got {reason:?}"
7202        );
7203        assert!(
7204            reason.contains("URI Template") || reason.contains("RFC 6570"),
7205            "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
7206        );
7207    }
7208
7209    #[test]
7210    fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
7211        // The symmetric Mustache / Handlebars doubled-brace
7212        // substitution-form footgun every CI / IaC templating engine
7213        // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
7214        // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
7215        // chart README quick-start snippet emits. Pinned separately
7216        // from the single-`{` `{org}` arm so a future relaxation that
7217        // narrows to one substitution-form surfaces here.
7218        let d = dep_with_fonte(DepSource::Git {
7219            repo: "https://github.com/{{org}}/caixa-teia".into(),
7220            tag: Some("v0.1.0".into()),
7221            rev: None,
7222            branch: None,
7223        });
7224        let err = d.validate().unwrap_err();
7225        let DepError::FonteRepoShape { reason, .. } = err else {
7226            panic!("expected FonteRepoShape, got other variant");
7227        };
7228        assert!(
7229            reason.contains("must not contain `{`"),
7230            "reason must surface the open-brace `{{` arm, got {reason:?}"
7231        );
7232    }
7233
7234    #[test]
7235    fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
7236        // Asymmetric `}`-only shape — covers the closing-brace-by-
7237        // itself footgun (an author truncated `{org}/{repo}` mid-edit
7238        // and left a trailing `}` from the prior template fragment,
7239        // or pasted a value that included a closing brace from a
7240        // surrounding shell context). Pinned to ensure the predicate
7241        // refuses each brace independently rather than only when both
7242        // appear — a future regression that ANDs the two byte tests
7243        // surfaces here.
7244        let d = dep_with_fonte(DepSource::Git {
7245            repo: "https://github.com/pleme-io/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 { reason, .. } = err else {
7252            panic!("expected FonteRepoShape, got other variant");
7253        };
7254        assert!(
7255            reason.contains("must not contain `}`"),
7256            "reason must surface the close-brace `}}` arm, got {reason:?}"
7257        );
7258    }
7259
7260    #[test]
7261    fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
7262        // Cascade pin: the fragment-`#` arm and the template-`{` /
7263        // `}` arm are both per-byte arms inside the same
7264        // `for &b in s.as_bytes()` loop, so the byte that appears
7265        // first in the value's byte order wins. A `:repo
7266        // "https://github.com/p/x#readme{org}"` carries both `#` and
7267        // `{`; the `#` byte appears first, so the fragment-`#` arm
7268        // fires, surfacing the more self-locating diagnostic on the
7269        // byte the author pasted earliest in the URL. Mirrors the
7270        // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
7271        // pins on the prior `:repo` byte-class arm.
7272        let d = dep_with_fonte(DepSource::Git {
7273            repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
7274            tag: Some("v0.1.0".into()),
7275            rev: None,
7276            branch: None,
7277        });
7278        let err = d.validate().unwrap_err();
7279        let DepError::FonteRepoShape { reason, .. } = err else {
7280            panic!("expected FonteRepoShape, got other variant");
7281        };
7282        assert!(
7283            reason.contains("must not contain `#`"),
7284            "reason must surface the fragment-`#` arm (fires before template-`{{` when \
7285             `#` byte appears first in value), got {reason:?}"
7286        );
7287    }
7288
7289    #[test]
7290    fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
7291        // The fail-before-pass-after pin for the canonical
7292        // shell-output-redirection footgun on `:repo`: an author
7293        // pastes a shell-pipeline tail (`git clone <repo> > build.log`
7294        // / `… >output.txt`) into the `:repo` slot without trimming
7295        // the redirect. Until this arm landed the value silently
7296        // passed every prior arm (no whitespace, no control chars,
7297        // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
7298        // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
7299        // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
7300        // percent-encode set maps `>` → `%3E` on the wire, so the
7301        // byte rides verbatim into the lacre's per-dep BLAKE3 closure
7302        // but is silently rewritten or rejected at libcurl's URL-
7303        // parser layer — two authors whose values differ only in
7304        // their redirect tail (`>build.log` vs nothing) resolve to
7305        // the byte-identical upstream `git clone` but lock to two
7306        // distinct lacres, defeating the THEORY.md §V.2 render-
7307        // determinism contract. Peer with the `:caminho` axis's
7308        // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
7309        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7310        // byte RFC-3986-reserved set on `:entrada :paths`.
7311        let d = dep_with_fonte(DepSource::Git {
7312            repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
7313            tag: Some("v0.1.0".into()),
7314            rev: None,
7315            branch: None,
7316        });
7317        let err = d.validate().unwrap_err();
7318        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7319            panic!("expected FonteRepoShape, got other variant");
7320        };
7321        assert_eq!(nome, "caixa-teia");
7322        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
7323        assert!(
7324            reason.contains("must not contain `>`"),
7325            "reason must surface the output-redirection `>` arm, got {reason:?}"
7326        );
7327        assert!(
7328            reason.contains("redirection") || reason.contains("'delims'"),
7329            "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
7330        );
7331    }
7332
7333    #[test]
7334    fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
7335        // The symmetric shell-input-redirection footgun — an author
7336        // pastes a shell-pipeline head (`git clone <input.url` /
7337        // `cat <README.md`) into the `:repo` slot. Pinned separately
7338        // from the `>`-output arm so a future relaxation that only
7339        // catches one of the two redirect bytes surfaces here. Peer
7340        // with the `:caminho` axis's `FonteCaminhoShellRedirection`
7341        // arm which closes both `<` and `>` under the same banner.
7342        let d = dep_with_fonte(DepSource::Git {
7343            repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
7344            tag: Some("v0.1.0".into()),
7345            rev: None,
7346            branch: None,
7347        });
7348        let err = d.validate().unwrap_err();
7349        let DepError::FonteRepoShape { reason, .. } = err else {
7350            panic!("expected FonteRepoShape, got other variant");
7351        };
7352        assert!(
7353            reason.contains("must not contain `<`"),
7354            "reason must surface the input-redirection `<` arm, got {reason:?}"
7355        );
7356        assert!(
7357            reason.contains("RFC 3986") || reason.contains("'unwise'"),
7358            "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
7359        );
7360    }
7361
7362    #[test]
7363    fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
7364        // The fail-before-pass-after pin for the canonical
7365        // paste-from-shell-prompt-with-backticked-substitution footgun
7366        // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
7367        // `:caminho` path-fonte axis). An author pastes a URL whose
7368        // segment carries a backticked command-substitution wrapper
7369        // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
7370        // from a doc / README quick-start snippet that expected the
7371        // substrate to substitute the value downstream. Until this arm
7372        // landed the value silently passed every prior arm (no
7373        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7374        // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
7375        // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
7376        // 'unwise' set and the WHATWG URL spec's fragment percent-
7377        // encode set maps `` ` `` → `%60` on the wire, so the byte
7378        // rides verbatim into the lacre's per-dep BLAKE3 closure but
7379        // is silently rewritten or rejected at libcurl's URL-parser
7380        // layer — two authors whose values differ only in their
7381        // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
7382        // byte-identical upstream `git clone` but lock to two distinct
7383        // lacres, defeating the THEORY.md §V.2 render-determinism
7384        // contract. Peer with the `:caminho` axis's
7385        // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
7386        // sibling path-fonte axis, and `is_gateway_api_http_path`'s
7387        // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
7388        let d = dep_with_fonte(DepSource::Git {
7389            repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
7390            tag: Some("v0.1.0".into()),
7391            rev: None,
7392            branch: None,
7393        });
7394        let err = d.validate().unwrap_err();
7395        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7396            panic!("expected FonteRepoShape, got other variant");
7397        };
7398        assert_eq!(nome, "caixa-teia");
7399        assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
7400        assert!(
7401            reason.contains("must not contain `` ` ``"),
7402            "reason must surface the backtick command-substitution arm, got {reason:?}"
7403        );
7404        assert!(
7405            reason.contains("command-substitution") || reason.contains("'unwise'"),
7406            "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
7407             got {reason:?}"
7408        );
7409    }
7410
7411    #[test]
7412    fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
7413        // Cascade pin: the fragment-`#` arm and the backtick command-
7414        // substitution arm are both per-byte arms inside the same
7415        // `for &b in s.as_bytes()` loop, so the byte that appears first
7416        // in the value's byte order wins. A `:repo
7417        // "https://github.com/p/x#readme/`whoami`"` carries both `#`
7418        // and backtick; the `#` byte appears first, so the fragment-
7419        // `#` arm fires, surfacing the more self-locating diagnostic
7420        // on the byte the author pasted earliest in the URL. Mirrors
7421        // the peer cascade discipline
7422        // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
7423        // pins on the prior `:repo` byte-class arm.
7424        let d = dep_with_fonte(DepSource::Git {
7425            repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
7426            tag: Some("v0.1.0".into()),
7427            rev: None,
7428            branch: None,
7429        });
7430        let err = d.validate().unwrap_err();
7431        let DepError::FonteRepoShape { reason, .. } = err else {
7432            panic!("expected FonteRepoShape, got other variant");
7433        };
7434        assert!(
7435            reason.contains("must not contain `#`"),
7436            "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
7437             appears first in value), got {reason:?}"
7438        );
7439    }
7440
7441    #[test]
7442    fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
7443        // Cascade pin: the shell-redirection `<` / `>` arm and the
7444        // backtick command-substitution arm are both per-byte arms
7445        // inside the same `for &b in s.as_bytes()` loop, so the byte
7446        // that appears first in the value's byte order wins. A `:repo
7447        // "https://github.com/p/x>build.log/`whoami`"` carries both
7448        // `>` and backtick; the `>` byte appears first, so the
7449        // shell-redirection arm fires, surfacing the more self-
7450        // locating diagnostic on the byte the author pasted earliest
7451        // in the URL. Pins the natural-order cascade so a future
7452        // reorder of the per-byte arms surfaces here.
7453        let d = dep_with_fonte(DepSource::Git {
7454            repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
7455            tag: Some("v0.1.0".into()),
7456            rev: None,
7457            branch: None,
7458        });
7459        let err = d.validate().unwrap_err();
7460        let DepError::FonteRepoShape { reason, .. } = err else {
7461            panic!("expected FonteRepoShape, got other variant");
7462        };
7463        assert!(
7464            reason.contains("must not contain `>`"),
7465            "reason must surface the shell-redirection `>` arm (fires before backtick when \
7466             `>` byte appears first in value), got {reason:?}"
7467        );
7468    }
7469
7470    #[test]
7471    fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
7472        // Cascade pin: the fragment-`#` arm and the shell-redirection
7473        // `<` / `>` arm are both per-byte arms inside the same
7474        // `for &b in s.as_bytes()` loop, so the byte that appears
7475        // first in the value's byte order wins. A `:repo
7476        // "https://github.com/p/x#readme>build.log"` carries both
7477        // `#` and `>`; the `#` byte appears first, so the fragment-
7478        // `#` arm fires, surfacing the more self-locating diagnostic
7479        // on the byte the author pasted earliest in the URL. Mirrors
7480        // the peer cascade discipline
7481        // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
7482        // pins on the prior `:repo` byte-class arm.
7483        let d = dep_with_fonte(DepSource::Git {
7484            repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
7485            tag: Some("v0.1.0".into()),
7486            rev: None,
7487            branch: None,
7488        });
7489        let err = d.validate().unwrap_err();
7490        let DepError::FonteRepoShape { reason, .. } = err else {
7491            panic!("expected FonteRepoShape, got other variant");
7492        };
7493        assert!(
7494            reason.contains("must not contain `#`"),
7495            "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
7496             `#` byte appears first in value), got {reason:?}"
7497        );
7498    }
7499
7500    #[test]
7501    fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
7502        // The fail-before-pass-after pin for the canonical
7503        // paste-from-shell-prompt-with-piped-pipeline footgun on
7504        // `:repo` (peer with the 124106f pipe arm on the sibling
7505        // `:caminho` path-fonte axis). An author pastes a shell
7506        // pipeline (`git clone <url> | tee build.log`,
7507        // `git ls-remote <url> | head`) into the `:repo` slot,
7508        // forgetting to trim the `| <consumer>` tail. Until this arm
7509        // landed the value silently passed every prior arm (no
7510        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7511        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
7512        // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
7513        // 'unwise' set and the WHATWG URL spec's fragment percent-
7514        // encode set maps `|` → `%7C` on the wire, so the byte rides
7515        // verbatim into the lacre's per-dep BLAKE3 closure but is
7516        // silently rewritten or rejected at libcurl's URL-parser
7517        // layer — two authors whose values differ only in their pipe
7518        // tail (`|tee build.log` vs nothing) resolve to the byte-
7519        // identical upstream `git clone` but lock to two distinct
7520        // lacres, defeating the THEORY.md §V.2 render-determinism
7521        // contract. Peer with the `:caminho` axis's
7522        // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
7523        // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
7524        // RFC-3986-reserved set on `:entrada :paths`.
7525        let d = dep_with_fonte(DepSource::Git {
7526            repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
7527            tag: Some("v0.1.0".into()),
7528            rev: None,
7529            branch: None,
7530        });
7531        let err = d.validate().unwrap_err();
7532        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7533            panic!("expected FonteRepoShape, got other variant");
7534        };
7535        assert_eq!(nome, "caixa-teia");
7536        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
7537        assert!(
7538            reason.contains("must not contain `|`"),
7539            "reason must surface the shell-pipe arm, got {reason:?}"
7540        );
7541        assert!(
7542            reason.contains("pipe") || reason.contains("'unwise'"),
7543            "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7544        );
7545    }
7546
7547    #[test]
7548    fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7549        // Cascade pin: the fragment-`#` arm and the pipe arm are both
7550        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7551        // so the byte that appears first in the value's byte order
7552        // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7553        // both `#` and `|`; the `#` byte appears first, so the
7554        // fragment-`#` arm fires, surfacing the more self-locating
7555        // diagnostic on the byte the author pasted earliest in the
7556        // URL. Mirrors the peer cascade discipline
7557        // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7558        // pins on the prior `:repo` byte-class arm.
7559        let d = dep_with_fonte(DepSource::Git {
7560            repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7561            tag: Some("v0.1.0".into()),
7562            rev: None,
7563            branch: None,
7564        });
7565        let err = d.validate().unwrap_err();
7566        let DepError::FonteRepoShape { reason, .. } = err else {
7567            panic!("expected FonteRepoShape, got other variant");
7568        };
7569        assert!(
7570            reason.contains("must not contain `#`"),
7571            "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7572             appears first in value), got {reason:?}"
7573        );
7574    }
7575
7576    #[test]
7577    fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7578        // Cascade pin: the backtick arm and the pipe arm are both per-
7579        // byte arms inside the same `for &b in s.as_bytes()` loop, so
7580        // the byte that appears first in the value's byte order wins.
7581        // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7582        // `` ` `` and `|`; the backtick byte appears first, so the
7583        // backtick arm fires, surfacing the more self-locating
7584        // diagnostic on the byte the author pasted earliest in the
7585        // URL. Pins the natural-order cascade so a future reorder of
7586        // the per-byte arms surfaces here.
7587        let d = dep_with_fonte(DepSource::Git {
7588            repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7589            tag: Some("v0.1.0".into()),
7590            rev: None,
7591            branch: None,
7592        });
7593        let err = d.validate().unwrap_err();
7594        let DepError::FonteRepoShape { reason, .. } = err else {
7595            panic!("expected FonteRepoShape, got other variant");
7596        };
7597        assert!(
7598            reason.contains("must not contain `` ` ``"),
7599            "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7600             appears first in value), got {reason:?}"
7601        );
7602    }
7603
7604    #[test]
7605    fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7606        // The fail-before-pass-after pin for the canonical
7607        // paste-from-shell-prompt-with-sequential-command-tail footgun
7608        // on `:repo` (peer with the 05c358e `;` arm on the sibling
7609        // `:caminho` path-fonte axis). An author pastes a shell
7610        // one-liner that chained a cleanup tail after the URL
7611        // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7612        // echo done`) into the `:repo` slot, forgetting to trim the
7613        // `; <cmd>` tail. Until this arm landed the value silently
7614        // passed every prior `is_git_repo_url` arm (no whitespace, no
7615        // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7616        // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7617        // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7618        // reserved set and the WHATWG URL spec's fragment percent-
7619        // encode set maps `;` → `%3B` on the wire, so the byte rides
7620        // verbatim into the lacre's per-dep BLAKE3 closure but is
7621        // silently rewritten at libcurl's URL-parser layer — two
7622        // authors whose values differ only in their sequential-command
7623        // tail (`; rm -rf build` vs nothing) resolve to the byte-
7624        // identical upstream `git clone` but lock to two distinct
7625        // lacres, defeating the THEORY.md §V.2 render-determinism
7626        // contract. Peer with the `:caminho` axis's
7627        // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7628        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7629        // byte RFC-3986-reserved set on `:entrada :paths`.
7630        let d = dep_with_fonte(DepSource::Git {
7631            repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7632            tag: Some("v0.1.0".into()),
7633            rev: None,
7634            branch: None,
7635        });
7636        let err = d.validate().unwrap_err();
7637        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7638            panic!("expected FonteRepoShape, got other variant");
7639        };
7640        assert_eq!(nome, "caixa-teia");
7641        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7642        assert!(
7643            reason.contains("must not contain `;`"),
7644            "reason must surface the shell-command-separator arm, got {reason:?}"
7645        );
7646        assert!(
7647            reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7648            "reason must name the shell-command-separator / RFC-3986-sub-delims \
7649             rationale, got {reason:?}"
7650        );
7651    }
7652
7653    #[test]
7654    fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7655        // Cascade pin: the fragment-`#` arm and the semicolon arm are
7656        // both per-byte arms inside the same `for &b in s.as_bytes()`
7657        // loop, so the byte that appears first in the value's byte
7658        // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7659        // carries both `#` and `;`; the `#` byte appears first, so the
7660        // fragment-`#` arm fires, surfacing the more self-locating
7661        // diagnostic on the byte the author pasted earliest in the URL.
7662        // Mirrors the peer cascade discipline
7663        // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7664        // pins on the prior `:repo` byte-class arm.
7665        let d = dep_with_fonte(DepSource::Git {
7666            repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7667            tag: Some("v0.1.0".into()),
7668            rev: None,
7669            branch: None,
7670        });
7671        let err = d.validate().unwrap_err();
7672        let DepError::FonteRepoShape { reason, .. } = err else {
7673            panic!("expected FonteRepoShape, got other variant");
7674        };
7675        assert!(
7676            reason.contains("must not contain `#`"),
7677            "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7678             byte appears first in value), got {reason:?}"
7679        );
7680    }
7681
7682    #[test]
7683    fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7684        // Cascade pin: the pipe arm and the semicolon arm are both
7685        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7686        // so the byte that appears first in the value's byte order
7687        // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7688        // both `|` and `;`; the `|` byte appears first, so the
7689        // pipe arm fires, surfacing the more self-locating diagnostic
7690        // on the byte the author pasted earliest in the URL. Pins the
7691        // natural-order cascade so a future reorder of the per-byte
7692        // arms surfaces here.
7693        let d = dep_with_fonte(DepSource::Git {
7694            repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7695            tag: Some("v0.1.0".into()),
7696            rev: None,
7697            branch: None,
7698        });
7699        let err = d.validate().unwrap_err();
7700        let DepError::FonteRepoShape { reason, .. } = err else {
7701            panic!("expected FonteRepoShape, got other variant");
7702        };
7703        assert!(
7704            reason.contains("must not contain `|`"),
7705            "reason must surface the pipe arm (fires before semicolon when `|` byte \
7706             appears first in value), got {reason:?}"
7707        );
7708    }
7709
7710    #[test]
7711    fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7712        // The fail-before-pass-after pin for the canonical
7713        // paste-from-shell-prompt-with-background-launch-tail footgun
7714        // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7715        // `:caminho` path-fonte axis). An author pastes a shell one-
7716        // liner that detached the clone into the background
7717        // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7718        // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7719        // `&& <cmd>` tail. Until this arm landed the value silently
7720        // passed every prior `is_git_repo_url` arm (no whitespace,
7721        // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7722        // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7723        // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7724        // the 'sub-delims' / reserved set and the WHATWG URL spec's
7725        // fragment percent-encode set maps `&` → `%26` on the wire,
7726        // so the byte rides verbatim into the lacre's per-dep
7727        // BLAKE3 closure but is silently rewritten at libcurl's
7728        // URL-parser layer — two authors whose values differ only
7729        // in their background-launch tail (`& sleep 1` vs nothing)
7730        // resolve to the byte-identical upstream `git clone` but
7731        // lock to two distinct lacres, defeating the THEORY.md
7732        // §V.2 render-determinism contract. Peer with the
7733        // `:caminho` axis's `FonteCaminhoShellBackground` arm
7734        // (e12e4f3) on the sibling path-fonte axis, and
7735        // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7736        // reserved set on `:entrada :paths`.
7737        let d = dep_with_fonte(DepSource::Git {
7738            repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7739            tag: Some("v0.1.0".into()),
7740            rev: None,
7741            branch: None,
7742        });
7743        let err = d.validate().unwrap_err();
7744        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7745            panic!("expected FonteRepoShape, got other variant");
7746        };
7747        assert_eq!(nome, "caixa-teia");
7748        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7749        assert!(
7750            reason.contains("must not contain `&`"),
7751            "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7752        );
7753        assert!(
7754            reason.contains("background-task") || reason.contains("'sub-delims'"),
7755            "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7756             got {reason:?}"
7757        );
7758    }
7759
7760    #[test]
7761    fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7762        // The fail-before-pass-after pin for the symmetric `&&`
7763        // logical-AND build-chain paste footgun: an author pastes
7764        // a `git clone <url> && cd <repo>` build-chain one-liner
7765        // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7766        // is the same `&` byte twice in a row; the per-byte arm
7767        // fires on the first `&` it sees. Pinned separately from
7768        // the single-`&` background-launch shape so a future
7769        // diagnostic-surface change that special-cased the
7770        // doubled-byte form surfaces here.
7771        let d = dep_with_fonte(DepSource::Git {
7772            repo: "github:pleme-io/caixa-teia&&echo".into(),
7773            tag: Some("v0.1.0".into()),
7774            rev: None,
7775            branch: None,
7776        });
7777        let err = d.validate().unwrap_err();
7778        let DepError::FonteRepoShape { reason, .. } = err else {
7779            panic!("expected FonteRepoShape, got other variant");
7780        };
7781        assert!(
7782            reason.contains("must not contain `&`"),
7783            "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7784             shape too, got {reason:?}"
7785        );
7786    }
7787
7788    #[test]
7789    fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7790        // Cascade pin: the fragment-`#` arm and the background-`&`
7791        // arm are both per-byte arms inside the same `for &b in
7792        // s.as_bytes()` loop, so the byte that appears first in the
7793        // value's byte order wins. A `:repo
7794        // "https://github.com/p/x#readme & sleep"` carries both `#`
7795        // and `&`; the `#` byte appears first, so the fragment-`#`
7796        // arm fires, surfacing the more self-locating diagnostic on
7797        // the byte the author pasted earliest in the URL. Mirrors
7798        // the peer cascade discipline
7799        // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7800        // on the prior `:repo` byte-class arm.
7801        let d = dep_with_fonte(DepSource::Git {
7802            repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7803            tag: Some("v0.1.0".into()),
7804            rev: None,
7805            branch: None,
7806        });
7807        let err = d.validate().unwrap_err();
7808        let DepError::FonteRepoShape { reason, .. } = err else {
7809            panic!("expected FonteRepoShape, got other variant");
7810        };
7811        assert!(
7812            reason.contains("must not contain `#`"),
7813            "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7814             byte appears first in value), got {reason:?}"
7815        );
7816    }
7817
7818    #[test]
7819    fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7820        // Cascade pin: the semicolon arm and the background-`&` arm
7821        // are both per-byte arms inside the same `for &b in
7822        // s.as_bytes()` loop, so the byte that appears first in the
7823        // value's byte order wins. A `:repo
7824        // "https://github.com/p/x; rm & sleep"` carries both `;` and
7825        // `&`; the `;` byte appears first, so the semicolon arm
7826        // fires, surfacing the more self-locating diagnostic on the
7827        // byte the author pasted earliest in the URL. Pins the
7828        // natural-order cascade so a future reorder of the per-byte
7829        // arms surfaces here.
7830        let d = dep_with_fonte(DepSource::Git {
7831            repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".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 semicolon arm (fires before background-`&` when `;` \
7843             byte appears first in value), got {reason:?}"
7844        );
7845    }
7846
7847    #[test]
7848    fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7849        // The fail-before-pass-after pin for the canonical
7850        // paste-from-shell-prompt-with-unsubstituted-variable footgun
7851        // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7852        // `:caminho` path-fonte axis). An author pastes a shell one-
7853        // liner that referenced an environment variable
7854        // (`git clone https://github.com/$ORG/x`, `git clone
7855        // github:$USER/repo`) into the `:repo` slot, forgetting to
7856        // substitute the literal value at author time. Until this arm
7857        // landed the value silently passed every prior
7858        // `is_git_repo_url` arm (no whitespace, no control chars, no
7859        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7860        // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7861        // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7862        // reserved set and the WHATWG URL spec's fragment percent-
7863        // encode set maps `$` → `%24` on the wire, so the byte rides
7864        // verbatim into the lacre's per-dep BLAKE3 closure but is
7865        // silently rewritten at libcurl's URL-parser layer — two
7866        // authors whose values differ only in their `$VAR` /
7867        // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7868        // identical upstream `git clone` but lock to two distinct
7869        // lacres, defeating the THEORY.md §V.2 render-determinism
7870        // contract. Beyond determinism, the value is a structural
7871        // host-layout leak: two authors with the same `:repo` slot
7872        // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7873        // different upstreams. Peer with the `:caminho` axis's
7874        // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7875        // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7876        // byte RFC-3986-reserved set on `:entrada :paths`.
7877        let d = dep_with_fonte(DepSource::Git {
7878            repo: "https://github.com/$ORG/caixa-teia".into(),
7879            tag: Some("v0.1.0".into()),
7880            rev: None,
7881            branch: None,
7882        });
7883        let err = d.validate().unwrap_err();
7884        let DepError::FonteRepoShape { nome, repo, reason } = err else {
7885            panic!("expected FonteRepoShape, got other variant");
7886        };
7887        assert_eq!(nome, "caixa-teia");
7888        assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7889        assert!(
7890            reason.contains("must not contain `$`"),
7891            "reason must surface the shell-variable-expansion arm, got {reason:?}"
7892        );
7893        assert!(
7894            reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7895            "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7896             rationale, got {reason:?}"
7897        );
7898    }
7899
7900    #[test]
7901    fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7902        // The fail-before-pass-after pin for the symmetric POSIX-
7903        // shell braced `${VAR}` expansion paste footgun: an author
7904        // pastes a CI-manifest line `git clone
7905        // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7906        // Actions / GitLab CI / Drone shape) and forgets to
7907        // substitute the literal value. The `${...}` shape is the
7908        // same `$` byte at the leading position of the expansion;
7909        // the per-byte arm fires on the `$`. Pinned separately from
7910        // the bare-`$VAR` shape so a future diagnostic-surface
7911        // change that special-cased the braced form surfaces here.
7912        let d = dep_with_fonte(DepSource::Git {
7913            repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7914            tag: Some("v0.1.0".into()),
7915            rev: None,
7916            branch: None,
7917        });
7918        let err = d.validate().unwrap_err();
7919        let DepError::FonteRepoShape { reason, .. } = err else {
7920            panic!("expected FonteRepoShape, got other variant");
7921        };
7922        assert!(
7923            reason.contains("must not contain `$`"),
7924            "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7925             shape too, got {reason:?}"
7926        );
7927    }
7928
7929    #[test]
7930    fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7931        // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7932        // arm are both per-byte arms inside the same `for &b in
7933        // s.as_bytes()` loop, so the byte that appears first in the
7934        // value's byte order wins. A `:repo
7935        // "https://github.com/p/x#readme$HOME"` carries both `#` and
7936        // `$`; the `#` byte appears first, so the fragment-`#` arm
7937        // fires, surfacing the more self-locating diagnostic on the
7938        // byte the author pasted earliest in the URL. Mirrors the
7939        // peer cascade discipline
7940        // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7941        // on the prior `:repo` byte-class arm.
7942        let d = dep_with_fonte(DepSource::Git {
7943            repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7944            tag: Some("v0.1.0".into()),
7945            rev: None,
7946            branch: None,
7947        });
7948        let err = d.validate().unwrap_err();
7949        let DepError::FonteRepoShape { reason, .. } = err else {
7950            panic!("expected FonteRepoShape, got other variant");
7951        };
7952        assert!(
7953            reason.contains("must not contain `#`"),
7954            "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7955             `#` byte appears first in value), got {reason:?}"
7956        );
7957    }
7958
7959    #[test]
7960    fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7961        // Cascade pin: the background-`&` arm and the
7962        // var-expansion-`$` arm are both per-byte arms inside the
7963        // same `for &b in s.as_bytes()` loop, so the byte that
7964        // appears first in the value's byte order wins. A `:repo
7965        // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7966        // `$`; the `&` byte appears first, so the background arm
7967        // fires, surfacing the more self-locating diagnostic on the
7968        // byte the author pasted earliest in the URL. Pins the
7969        // natural-order cascade so a future reorder of the per-byte
7970        // arms surfaces here — `$` is the most recent byte-class arm,
7971        // so the cascade-pin sweep extends to cover every immediately
7972        // prior byte arm (`#`, `&`) firing first when ordered ahead
7973        // of `$` in the value.
7974        let d = dep_with_fonte(DepSource::Git {
7975            repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7976            tag: Some("v0.1.0".into()),
7977            rev: None,
7978            branch: None,
7979        });
7980        let err = d.validate().unwrap_err();
7981        let DepError::FonteRepoShape { reason, .. } = err else {
7982            panic!("expected FonteRepoShape, got other variant");
7983        };
7984        assert!(
7985            reason.contains("must not contain `&`"),
7986            "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7987             `&` byte appears first in value), got {reason:?}"
7988        );
7989    }
7990
7991    #[test]
7992    fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7993        // The fail-before-pass-after pin for the canonical
7994        // paste-from-shell-prompt glob footgun on `:repo` (peer with
7995        // the cf9034b `*` / `?` arm on the sibling `:caminho`
7996        // path-fonte axis). An author pastes a shell one-liner that
7997        // referenced a glob expansion (`ls
7998        // github.com/pleme-io/caixa-*`, `git clone
7999        // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
8000        // to substitute the literal repo name. Until this arm landed
8001        // the `*` byte silently passed every prior `is_git_repo_url`
8002        // arm (no whitespace, no control chars, no non-ASCII, no `#`,
8003        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
8004        // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
8005        // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
8006        // the WHATWG URL spec's special-query percent-encode set maps
8007        // `*` → `%2A` on the wire, so the byte rides verbatim into
8008        // the lacre's per-dep BLAKE3 closure but is silently
8009        // rewritten at libcurl's URL-parser layer — two authors
8010        // whose values differ only in their asterisk presence
8011        // resolve to the byte-identical upstream `git clone` but
8012        // lock to two distinct lacres, defeating the THEORY.md §V.2
8013        // render-determinism contract. Peer with the `:caminho`
8014        // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
8015        // sibling path-fonte axis, and the `is_git_ref_name`
8016        // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
8017        // axes.
8018        let d = dep_with_fonte(DepSource::Git {
8019            repo: "https://github.com/pleme-io/caixa-*".into(),
8020            tag: Some("v0.1.0".into()),
8021            rev: None,
8022            branch: None,
8023        });
8024        let err = d.validate().unwrap_err();
8025        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8026            panic!("expected FonteRepoShape, got other variant");
8027        };
8028        assert_eq!(nome, "caixa-teia");
8029        assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
8030        assert!(
8031            reason.contains("must not contain `*`"),
8032            "reason must surface the shell-glob arm, got {reason:?}"
8033        );
8034        assert!(
8035            reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
8036            "reason must name the shell-glob / pathname-expansion / \
8037             RFC-3986-sub-delims rationale, got {reason:?}"
8038        );
8039    }
8040
8041    #[test]
8042    fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
8043        // The fail-before-pass-after pin for the symmetric bash
8044        // `globstar` recursive-glob paste footgun: an author pastes
8045        // a `ls github.com/pleme-io/**/x` (the canonical
8046        // `globstar`-shopt-enabled recursive-listing tail) into the
8047        // `:repo` slot. The `**` shape is two `*` bytes adjacent;
8048        // the per-byte arm fires on the first `*`. Pinned
8049        // separately from the single-`*` shape so a future
8050        // diagnostic-surface change that special-cased the
8051        // double-`*` form surfaces here.
8052        let d = dep_with_fonte(DepSource::Git {
8053            repo: "https://github.com/pleme-io/**/caixa-teia".into(),
8054            tag: Some("v0.1.0".into()),
8055            rev: None,
8056            branch: None,
8057        });
8058        let err = d.validate().unwrap_err();
8059        let DepError::FonteRepoShape { reason, .. } = err else {
8060            panic!("expected FonteRepoShape, got other variant");
8061        };
8062        assert!(
8063            reason.contains("must not contain `*`"),
8064            "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
8065             got {reason:?}"
8066        );
8067    }
8068
8069    #[test]
8070    fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
8071        // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
8072        // both per-byte arms inside the same `for &b in s.as_bytes()`
8073        // loop, so the byte that appears first in the value's byte
8074        // order wins. A `:repo
8075        // "https://github.com/p/x#readme*tail"` carries both `#` and
8076        // `*`; the `#` byte appears first, so the fragment-`#` arm
8077        // fires, surfacing the more self-locating diagnostic on the
8078        // byte the author pasted earliest in the URL. Mirrors the
8079        // peer cascade discipline
8080        // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
8081        // on the prior `:repo` byte-class arm.
8082        let d = dep_with_fonte(DepSource::Git {
8083            repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
8084            tag: Some("v0.1.0".into()),
8085            rev: None,
8086            branch: None,
8087        });
8088        let err = d.validate().unwrap_err();
8089        let DepError::FonteRepoShape { reason, .. } = err else {
8090            panic!("expected FonteRepoShape, got other variant");
8091        };
8092        assert!(
8093            reason.contains("must not contain `#`"),
8094            "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
8095             appears first in value), got {reason:?}"
8096        );
8097    }
8098
8099    #[test]
8100    fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
8101        // Cascade pin: the var-expansion-`$` arm and the glob-`*`
8102        // arm are both per-byte arms inside the same `for &b in
8103        // s.as_bytes()` loop, so the byte that appears first in the
8104        // value's byte order wins. A `:repo
8105        // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
8106        // the `$` byte appears first, so the var-expansion arm
8107        // fires, surfacing the more self-locating diagnostic on the
8108        // byte the author pasted earliest in the URL. Pins the
8109        // natural-order cascade so a future reorder of the per-byte
8110        // arms surfaces here — `*` is the most recent byte-class
8111        // arm, so the cascade-pin sweep extends to cover the
8112        // immediately prior `$` byte arm firing first when ordered
8113        // ahead of `*` in the value.
8114        let d = dep_with_fonte(DepSource::Git {
8115            repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
8116            tag: Some("v0.1.0".into()),
8117            rev: None,
8118            branch: None,
8119        });
8120        let err = d.validate().unwrap_err();
8121        let DepError::FonteRepoShape { reason, .. } = err else {
8122            panic!("expected FonteRepoShape, got other variant");
8123        };
8124        assert!(
8125            reason.contains("must not contain `$`"),
8126            "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
8127             byte appears first in value), got {reason:?}"
8128        );
8129    }
8130
8131    #[test]
8132    fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
8133        // The fail-before-pass-after pin for the canonical paste-from-
8134        // shell-prompt subshell-grouping footgun on `:repo`. An author
8135        // pastes a doc / README snippet carrying a regex-alternation
8136        // grouping shape (`https://github.com/(foo|bar)/repo`) or a
8137        // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
8138        // `:repo` slot, forgetting to substitute one literal org name.
8139        // Until this arm landed the `(` byte silently passed every
8140        // prior `is_git_repo_url` arm (no whitespace, no control
8141        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8142        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
8143        // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
8144        // / `)` in the 'sub-delims' / reserved set, and the WHATWG
8145        // URL spec's special-query percent-encode set maps `(` →
8146        // `%28` and `)` → `%29` on the wire, so the byte rides
8147        // verbatim into the lacre's per-dep BLAKE3 closure but is
8148        // silently rewritten at libcurl's URL-parser layer —
8149        // defeating the THEORY.md §V.2 render-determinism contract on
8150        // the same axis the prior twelve byte-class arms close.
8151        let d = dep_with_fonte(DepSource::Git {
8152            repo: "https://github.com/(foo|bar)/caixa-teia".into(),
8153            tag: Some("v0.1.0".into()),
8154            rev: None,
8155            branch: None,
8156        });
8157        let err = d.validate().unwrap_err();
8158        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8159            panic!("expected FonteRepoShape, got other variant");
8160        };
8161        assert_eq!(nome, "caixa-teia");
8162        assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
8163        assert!(
8164            reason.contains("must not contain `(`"),
8165            "reason must surface the subshell-open-paren arm, got {reason:?}"
8166        );
8167        assert!(
8168            reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
8169            "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
8170             got {reason:?}"
8171        );
8172    }
8173
8174    #[test]
8175    fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
8176        // The symmetric arm pin on the closing `)` byte: an author
8177        // pastes a `$(date)` command-substitution wrapper or a
8178        // regex-alternation `(foo|bar)` tail into the `:repo` slot.
8179        // Pinned separately from the opening `(` shape so a future
8180        // diagnostic-surface change that only checked one boundary
8181        // surfaces here. The `(` byte appears earlier in the
8182        // canonical regex / subshell wrapper so the per-byte loop
8183        // fires on `(` first; this test exercises a `:repo` value
8184        // carrying only the closing `)` byte (no opening paren) so
8185        // the `)` arm fires directly — pinning the byte-class arm
8186        // independent of order.
8187        let d = dep_with_fonte(DepSource::Git {
8188            repo: "github:pleme-io/caixa-teia)tail".into(),
8189            tag: Some("v0.1.0".into()),
8190            rev: None,
8191            branch: None,
8192        });
8193        let err = d.validate().unwrap_err();
8194        let DepError::FonteRepoShape { reason, .. } = err else {
8195            panic!("expected FonteRepoShape, got other variant");
8196        };
8197        assert!(
8198            reason.contains("must not contain `)`"),
8199            "reason must surface the subshell-close-paren arm on the bare `)` shape, \
8200             got {reason:?}"
8201        );
8202    }
8203
8204    #[test]
8205    fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
8206        // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
8207        // are both per-byte arms inside the same `for &b in
8208        // s.as_bytes()` loop, so the byte that appears first in the
8209        // value's byte order wins. A `:repo
8210        // "https://github.com/p/x#readme(tail)"` carries both `#` and
8211        // `(`; the `#` byte appears first, so the fragment-`#` arm
8212        // fires, surfacing the more self-locating diagnostic on the
8213        // byte the author pasted earliest in the URL. Mirrors the
8214        // peer cascade discipline
8215        // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
8216        // on the prior `:repo` byte-class arm.
8217        let d = dep_with_fonte(DepSource::Git {
8218            repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
8219            tag: Some("v0.1.0".into()),
8220            rev: None,
8221            branch: None,
8222        });
8223        let err = d.validate().unwrap_err();
8224        let DepError::FonteRepoShape { reason, .. } = err else {
8225            panic!("expected FonteRepoShape, got other variant");
8226        };
8227        assert!(
8228            reason.contains("must not contain `#`"),
8229            "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
8230             byte appears first in value), got {reason:?}"
8231        );
8232    }
8233
8234    #[test]
8235    fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
8236        // Cascade pin: the glob-`*` arm (the immediate-predecessor
8237        // byte-class arm, 3902a9a) and the subshell-`(` arm are both
8238        // per-byte arms inside the same `for &b in s.as_bytes()`
8239        // loop, so the byte that appears first in the value's byte
8240        // order wins. A `:repo
8241        // "https://github.com/p/x-*-(date)"` carries both `*` and
8242        // `(`; the `*` byte appears first, so the glob arm fires,
8243        // surfacing the more self-locating diagnostic on the byte
8244        // the author pasted earliest in the URL. Pins the natural-
8245        // order cascade so a future reorder of the per-byte arms
8246        // surfaces here — `(` is the most recent byte-class arm,
8247        // so the cascade-pin sweep extends to cover the immediately
8248        // prior `*` byte arm firing first when ordered ahead of `(`
8249        // in the value.
8250        let d = dep_with_fonte(DepSource::Git {
8251            repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
8252            tag: Some("v0.1.0".into()),
8253            rev: None,
8254            branch: None,
8255        });
8256        let err = d.validate().unwrap_err();
8257        let DepError::FonteRepoShape { reason, .. } = err else {
8258            panic!("expected FonteRepoShape, got other variant");
8259        };
8260        assert!(
8261            reason.contains("must not contain `*`"),
8262            "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
8263             appears first in value), got {reason:?}"
8264        );
8265    }
8266
8267    #[test]
8268    fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
8269        // The fail-before-pass-after pin for the canonical paste-from-
8270        // doc-shell-quoting footgun on `:repo`. An author copies a
8271        // README quick-start snippet (`$ git clone "https://github.com/
8272        // foo/bar"`) and keeps the surrounding double-quote bytes when
8273        // pasting into the `:repo` slot — the doc wraps the URL in
8274        // double quotes so the shell doesn't re-lex metachars inside,
8275        // but the typed slot is itself a byte-level string parser, not
8276        // a shell context, so the quote bytes ride into the value
8277        // verbatim. Until this arm landed the `"` byte silently passed
8278        // every prior `is_git_repo_url` arm (no whitespace, no control
8279        // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
8280        // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
8281        // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
8282        // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
8283        // `` ` ``) every URL parser is required to refuse or percent-
8284        // encode, and the WHATWG URL spec's 'C0 control percent-encode
8285        // set' maps `"` → `%22` on the wire, so the byte rides verbatim
8286        // into the lacre's per-dep BLAKE3 closure but is silently
8287        // rewritten at libcurl's URL-parser layer, defeating the
8288        // THEORY.md §V.2 render-determinism contract.
8289        let d = dep_with_fonte(DepSource::Git {
8290            repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
8291            tag: Some("v0.1.0".into()),
8292            rev: None,
8293            branch: None,
8294        });
8295        let err = d.validate().unwrap_err();
8296        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8297            panic!("expected FonteRepoShape, got other variant");
8298        };
8299        assert_eq!(nome, "caixa-teia");
8300        assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
8301        assert!(
8302            reason.contains("must not contain `\"`"),
8303            "reason must surface the shell-double-quote arm, got {reason:?}"
8304        );
8305        assert!(
8306            reason.contains("double-quote") || reason.contains("'delims'"),
8307            "reason must name the shell-double-quote / RFC-3986-delims rationale, \
8308             got {reason:?}"
8309        );
8310    }
8311
8312    #[test]
8313    fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
8314        // The symmetric stray-quote tail pin: an author pastes only a
8315        // closing `"` from a shell-history line like `git clone
8316        // "https://github.com/foo/bar" && cd …` (the trim went too
8317        // far in one direction but not the other) into the `:repo`
8318        // slot. Pinned separately from the wrapped-quote shape so a
8319        // future diagnostic-surface change that only checked one
8320        // boundary (only leading, only trailing, only paired) surfaces
8321        // here — the per-byte arm fires anywhere `"` appears.
8322        let d = dep_with_fonte(DepSource::Git {
8323            repo: "github:pleme-io/caixa-teia\"".into(),
8324            tag: Some("v0.1.0".into()),
8325            rev: None,
8326            branch: None,
8327        });
8328        let err = d.validate().unwrap_err();
8329        let DepError::FonteRepoShape { reason, .. } = err else {
8330            panic!("expected FonteRepoShape, got other variant");
8331        };
8332        assert!(
8333            reason.contains("must not contain `\"`"),
8334            "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
8335             got {reason:?}"
8336        );
8337    }
8338
8339    #[test]
8340    fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
8341        // Cascade pin: the fragment-`#` arm and the double-quote arm
8342        // are both per-byte arms inside the same `for &b in
8343        // s.as_bytes()` loop, so the byte that appears first in the
8344        // value's byte order wins. A `:repo
8345        // "https://github.com/p/x#readme\"tail"` carries both `#` and
8346        // `"`; the `#` byte appears first, so the fragment-`#` arm
8347        // fires, surfacing the more self-locating diagnostic on the
8348        // byte the author pasted earliest in the URL.
8349        let d = dep_with_fonte(DepSource::Git {
8350            repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
8351            tag: Some("v0.1.0".into()),
8352            rev: None,
8353            branch: None,
8354        });
8355        let err = d.validate().unwrap_err();
8356        let DepError::FonteRepoShape { reason, .. } = err else {
8357            panic!("expected FonteRepoShape, got other variant");
8358        };
8359        assert!(
8360            reason.contains("must not contain `#`"),
8361            "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
8362             byte appears first in value), got {reason:?}"
8363        );
8364    }
8365
8366    #[test]
8367    fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
8368        // Cascade pin: the subshell-`(` arm (the immediate-predecessor
8369        // byte-class arm, 3b99147) and the double-quote arm are both
8370        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8371        // so the byte that appears first in the value's byte order
8372        // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
8373        // and `"`; the `(` byte appears first, so the subshell arm
8374        // fires, surfacing the more self-locating diagnostic on the
8375        // byte the author pasted earliest in the URL. Pins the natural-
8376        // order cascade so a future reorder of the per-byte arms
8377        // surfaces here — `"` is the most recent byte-class arm, so
8378        // the cascade-pin sweep extends to cover the immediately prior
8379        // `(` byte arm firing first when ordered ahead of `"` in the
8380        // value.
8381        let d = dep_with_fonte(DepSource::Git {
8382            repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
8383            tag: Some("v0.1.0".into()),
8384            rev: None,
8385            branch: None,
8386        });
8387        let err = d.validate().unwrap_err();
8388        let DepError::FonteRepoShape { reason, .. } = err else {
8389            panic!("expected FonteRepoShape, got other variant");
8390        };
8391        assert!(
8392            reason.contains("must not contain `(`"),
8393            "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
8394             byte appears first in value), got {reason:?}"
8395        );
8396    }
8397
8398    #[test]
8399    fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
8400        // The fail-before-pass-after pin for the canonical paste-from-
8401        // doc-strong-quoting footgun on `:repo`. An author copies a
8402        // security-conscious README quick-start snippet (`$ git clone
8403        // 'https://github.com/foo/bar'`) and keeps the surrounding
8404        // single-quote bytes when pasting into the `:repo` slot — the
8405        // doc strong-quotes the URL so the shell suppresses every form
8406        // of expansion on the bytes inside (no `$`, no backtick, no
8407        // glob, no word-splitting), but the typed slot is itself a
8408        // byte-level string parser, not a shell context, so the quote
8409        // bytes ride into the value verbatim. Until this arm landed the
8410        // `'` byte silently passed every prior `is_git_repo_url` arm
8411        // (no whitespace, no control chars, no non-ASCII, no `#`, no
8412        // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
8413        // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
8414        // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
8415        // set, peer with the `\"` 'delims' double-quote arm and the
8416        // partner ASCII shell-string-delimiter byte every byte-level
8417        // string parser sharing a value-shape with a shell argument
8418        // must refuse on a URL-shaped slot.
8419        let d = dep_with_fonte(DepSource::Git {
8420            repo: "'https://github.com/pleme-io/caixa-teia'".into(),
8421            tag: Some("v0.1.0".into()),
8422            rev: None,
8423            branch: None,
8424        });
8425        let err = d.validate().unwrap_err();
8426        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8427            panic!("expected FonteRepoShape, got other variant");
8428        };
8429        assert_eq!(nome, "caixa-teia");
8430        assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
8431        assert!(
8432            reason.contains("must not contain `'`"),
8433            "reason must surface the shell-single-quote arm, got {reason:?}"
8434        );
8435        assert!(
8436            reason.contains("single-quote") || reason.contains("strong-quote"),
8437            "reason must name the shell-single-quote / strong-quote rationale, \
8438             got {reason:?}"
8439        );
8440    }
8441
8442    #[test]
8443    fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
8444        // The symmetric English-typography pin: an author writes
8445        // `:repo "github:p/repo's-fork"` (the possessive-form paste-
8446        // from-prose idiom every README / commit-message / chat-thread
8447        // reference to a repo carries) expecting the substrate to
8448        // coerce it to a kebab-case slug — but the byte rides into the
8449        // lacre verbatim. Pinned separately from the wrapped-quote
8450        // shape so a future diagnostic-surface change that only checked
8451        // the boundary positions (only leading, only trailing, only
8452        // paired) surfaces here — the per-byte arm fires anywhere `'`
8453        // appears in the value.
8454        let d = dep_with_fonte(DepSource::Git {
8455            repo: "github:pleme-io/repo's-fork".into(),
8456            tag: Some("v0.1.0".into()),
8457            rev: None,
8458            branch: None,
8459        });
8460        let err = d.validate().unwrap_err();
8461        let DepError::FonteRepoShape { reason, .. } = err else {
8462            panic!("expected FonteRepoShape, got other variant");
8463        };
8464        assert!(
8465            reason.contains("must not contain `'`"),
8466            "reason must surface the shell-single-quote arm on the mid-string \
8467             apostrophe shape, got {reason:?}"
8468        );
8469    }
8470
8471    #[test]
8472    fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
8473        // Cascade pin: the fragment-`#` arm and the single-quote arm
8474        // are both per-byte arms inside the same `for &b in
8475        // s.as_bytes()` loop, so the byte that appears first in the
8476        // value's byte order wins. A `:repo
8477        // "https://github.com/p/x#readme'tail"` carries both `#` and
8478        // `'`; the `#` byte appears first, so the fragment-`#` arm
8479        // fires, surfacing the more self-locating diagnostic on the
8480        // byte the author pasted earliest in the URL.
8481        let d = dep_with_fonte(DepSource::Git {
8482            repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
8483            tag: Some("v0.1.0".into()),
8484            rev: None,
8485            branch: None,
8486        });
8487        let err = d.validate().unwrap_err();
8488        let DepError::FonteRepoShape { reason, .. } = err else {
8489            panic!("expected FonteRepoShape, got other variant");
8490        };
8491        assert!(
8492            reason.contains("must not contain `#`"),
8493            "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
8494             byte appears first in value), got {reason:?}"
8495        );
8496    }
8497
8498    #[test]
8499    fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
8500        // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
8501        // byte-class arm, 4267d8b) and the single-quote arm are both
8502        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8503        // so the byte that appears first in the value's byte order
8504        // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
8505        // `'`; the `"` byte appears first, so the double-quote arm
8506        // fires, surfacing the more self-locating diagnostic on the
8507        // byte the author pasted earliest in the URL. Pins the natural-
8508        // order cascade so a future reorder of the per-byte arms
8509        // surfaces here — `'` is the most recent byte-class arm, so
8510        // the cascade-pin sweep extends to cover the immediately prior
8511        // `"` byte arm firing first when ordered ahead of `'` in the
8512        // value.
8513        let d = dep_with_fonte(DepSource::Git {
8514            repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
8515            tag: Some("v0.1.0".into()),
8516            rev: None,
8517            branch: None,
8518        });
8519        let err = d.validate().unwrap_err();
8520        let DepError::FonteRepoShape { reason, .. } = err else {
8521            panic!("expected FonteRepoShape, got other variant");
8522        };
8523        assert!(
8524            reason.contains("must not contain `\"`"),
8525            "reason must surface the double-quote arm (fires before single-quote when `\"` \
8526             byte appears first in value), got {reason:?}"
8527        );
8528    }
8529
8530    #[test]
8531    fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
8532        // The fail-before-pass-after pin for the canonical paste-from-
8533        // shell-history footgun on `:repo`. An author copies a `git
8534        // clone <url>!sudo make install` one-liner from a README's
8535        // quick-start snippet, intending the trailing `!sudo` as a
8536        // shell-history-expansion reference but the typed slot is itself
8537        // a byte-level string parser, not a shell context, so the byte
8538        // rides into the value verbatim. Until this arm landed the `!`
8539        // byte silently passed every prior `is_git_repo_url` arm (no
8540        // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
8541        // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8542        // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8543        // start with `-` or `:`); bash with the default `histexpand`
8544        // mode rewrites `!command` to the most recent history entry
8545        // beginning with `command`, the canonical RCE-class injection
8546        // vector when the byte rides into a shell argument.
8547        let d = dep_with_fonte(DepSource::Git {
8548            repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8549            tag: Some("v0.1.0".into()),
8550            rev: None,
8551            branch: None,
8552        });
8553        let err = d.validate().unwrap_err();
8554        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8555            panic!("expected FonteRepoShape, got other variant");
8556        };
8557        assert_eq!(nome, "caixa-teia");
8558        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8559        assert!(
8560            reason.contains("must not contain `!`"),
8561            "reason must surface the shell-history-expansion arm, got {reason:?}"
8562        );
8563        assert!(
8564            reason.contains("history-expansion") || reason.contains("bang"),
8565            "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8566        );
8567    }
8568
8569    #[test]
8570    fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8571        // The symmetric `!!` repeat-prior-command pin: an author paste-
8572        // trims a `git clone <url>` retry idiom from shell history that
8573        // expands to the previous command via `!!`. Pinned separately
8574        // from the wrapped `!command` shape so a future diagnostic-
8575        // surface change that only checked the leading or paired-bang
8576        // position surfaces here — the per-byte arm fires anywhere `!`
8577        // appears in the value.
8578        let d = dep_with_fonte(DepSource::Git {
8579            repo: "github:pleme-io/caixa-teia!!".into(),
8580            tag: Some("v0.1.0".into()),
8581            rev: None,
8582            branch: None,
8583        });
8584        let err = d.validate().unwrap_err();
8585        let DepError::FonteRepoShape { reason, .. } = err else {
8586            panic!("expected FonteRepoShape, got other variant");
8587        };
8588        assert!(
8589            reason.contains("must not contain `!`"),
8590            "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8591             got {reason:?}"
8592        );
8593    }
8594
8595    #[test]
8596    fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8597        // Cascade pin: the fragment-`#` arm and the bang arm are both
8598        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8599        // so the byte that appears first in the value's byte order
8600        // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8601        // both `#` and `!`; the `#` byte appears first, so the
8602        // fragment-`#` arm fires, surfacing the more self-locating
8603        // diagnostic on the byte the author pasted earliest in the URL.
8604        let d = dep_with_fonte(DepSource::Git {
8605            repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8606            tag: Some("v0.1.0".into()),
8607            rev: None,
8608            branch: None,
8609        });
8610        let err = d.validate().unwrap_err();
8611        let DepError::FonteRepoShape { reason, .. } = err else {
8612            panic!("expected FonteRepoShape, got other variant");
8613        };
8614        assert!(
8615            reason.contains("must not contain `#`"),
8616            "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8617             appears first in value), got {reason:?}"
8618        );
8619    }
8620
8621    #[test]
8622    fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8623        // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8624        // byte-class arm, e7a109f) and the bang arm are both per-byte
8625        // arms inside the same `for &b in s.as_bytes()` loop, so the
8626        // byte that appears first in the value's byte order wins. A
8627        // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8628        // `'` byte appears first, so the single-quote arm fires,
8629        // surfacing the more self-locating diagnostic on the byte the
8630        // author pasted earliest in the URL. Pins the natural-order
8631        // cascade so a future reorder of the per-byte arms surfaces
8632        // here — `!` is the most recent byte-class arm, so the
8633        // cascade-pin sweep extends to cover the immediately prior `'`
8634        // byte arm firing first when ordered ahead of `!` in the value.
8635        let d = dep_with_fonte(DepSource::Git {
8636            repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8637            tag: Some("v0.1.0".into()),
8638            rev: None,
8639            branch: None,
8640        });
8641        let err = d.validate().unwrap_err();
8642        let DepError::FonteRepoShape { reason, .. } = err else {
8643            panic!("expected FonteRepoShape, got other variant");
8644        };
8645        assert!(
8646            reason.contains("must not contain `'`"),
8647            "reason must surface the single-quote arm (fires before bang when `'` byte \
8648             appears first in value), got {reason:?}"
8649        );
8650    }
8651
8652    #[test]
8653    fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8654        // The fail-before-pass-after pin for the canonical
8655        // list-separator-belongs-to-list-grammar footgun on `:repo`.
8656        // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8657        // one-liner from a multi-repo bootstrap doc, intending the
8658        // comma to separate multiple repo entries but the typed
8659        // `:repo` slot names *one* repo (the list-separator belongs
8660        // to the `:deps` list grammar, not to the value). Until this
8661        // arm landed the `,` byte silently passed every prior
8662        // `is_git_repo_url` arm (no whitespace, no control chars, no
8663        // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8664        // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8665        // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8666        // `:`); the byte rode into the lacre's per-dep content-
8667        // address and the resolver's `git clone <repo>` subprocess
8668        // invocation, where no host's repo registry resolved the
8669        // comma-bearing slug.
8670        let d = dep_with_fonte(DepSource::Git {
8671            repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8672            tag: Some("v0.1.0".into()),
8673            rev: None,
8674            branch: None,
8675        });
8676        let err = d.validate().unwrap_err();
8677        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8678            panic!("expected FonteRepoShape, got other variant");
8679        };
8680        assert_eq!(nome, "caixa-teia");
8681        assert_eq!(
8682            repo,
8683            "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8684        );
8685        assert!(
8686            reason.contains("must not contain `,`"),
8687            "reason must surface the list-separator-comma arm, got {reason:?}"
8688        );
8689        assert!(
8690            reason.contains("list-separator") || reason.contains("sub-delims"),
8691            "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8692             got {reason:?}"
8693        );
8694    }
8695
8696    #[test]
8697    fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8698        // The symmetric trailing-`,` paste-from-prose pin: an author
8699        // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8700        // comma every README-prose list-of-projects sentence carries,
8701        // mistakenly retained when the slug is pasted mid-sentence)
8702        // expecting the substrate to coerce it to a kebab-case slug.
8703        // Pinned separately from the wrapped mid-token shape so a
8704        // future diagnostic-surface change that only checked the
8705        // leading or paired-comma position surfaces here — the
8706        // per-byte arm fires anywhere `,` appears in the value.
8707        let d = dep_with_fonte(DepSource::Git {
8708            repo: "github:pleme-io/caixa-feira,".into(),
8709            tag: Some("v0.1.0".into()),
8710            rev: None,
8711            branch: None,
8712        });
8713        let err = d.validate().unwrap_err();
8714        let DepError::FonteRepoShape { reason, .. } = err else {
8715            panic!("expected FonteRepoShape, got other variant");
8716        };
8717        assert!(
8718            reason.contains("must not contain `,`"),
8719            "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8720             got {reason:?}"
8721        );
8722    }
8723
8724    #[test]
8725    fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8726        // Cascade pin: the fragment-`#` arm and the comma arm are
8727        // both per-byte arms inside the same `for &b in s.as_bytes()`
8728        // loop, so the byte that appears first in the value's byte
8729        // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8730        // carries both `#` and `,`; the `#` byte appears first, so
8731        // the fragment-`#` arm fires, surfacing the more self-
8732        // locating diagnostic on the byte the author pasted earliest
8733        // in the URL.
8734        let d = dep_with_fonte(DepSource::Git {
8735            repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8736            tag: Some("v0.1.0".into()),
8737            rev: None,
8738            branch: None,
8739        });
8740        let err = d.validate().unwrap_err();
8741        let DepError::FonteRepoShape { reason, .. } = err else {
8742            panic!("expected FonteRepoShape, got other variant");
8743        };
8744        assert!(
8745            reason.contains("must not contain `#`"),
8746            "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8747             appears first in value), got {reason:?}"
8748        );
8749    }
8750
8751    #[test]
8752    fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8753        // Cascade pin: the bang-`!` arm (the immediate-predecessor
8754        // byte-class arm, 7d53c68) and the comma arm are both
8755        // per-byte arms inside the same `for &b in s.as_bytes()`
8756        // loop, so the byte that appears first in the value's byte
8757        // order wins. A `:repo "github:p/x!mid,tail"` carries both
8758        // `!` and `,`; the `!` byte appears first, so the bang arm
8759        // fires, surfacing the more self-locating diagnostic on the
8760        // byte the author pasted earliest in the URL. Pins the
8761        // natural-order cascade so a future reorder of the per-byte
8762        // arms surfaces here — `,` is the most recent byte-class
8763        // arm, so the cascade-pin sweep extends to cover the
8764        // immediately prior `!` byte arm firing first when ordered
8765        // ahead of `,` in the value.
8766        let d = dep_with_fonte(DepSource::Git {
8767            repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8768            tag: Some("v0.1.0".into()),
8769            rev: None,
8770            branch: None,
8771        });
8772        let err = d.validate().unwrap_err();
8773        let DepError::FonteRepoShape { reason, .. } = err else {
8774            panic!("expected FonteRepoShape, got other variant");
8775        };
8776        assert!(
8777            reason.contains("must not contain `!`"),
8778            "reason must surface the bang arm (fires before comma when `!` byte \
8779             appears first in value), got {reason:?}"
8780        );
8781    }
8782
8783    #[test]
8784    fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8785        // The fail-before-pass-after pin for the canonical
8786        // shell-env-var-assignment-belongs-to-shell-grammar footgun
8787        // on `:repo`. An author copies
8788        // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8789        // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8790        // git clone <url>`, etc. — the canonical
8791        // git-troubleshooting README idiom for a one-shot env-var
8792        // scoped to the `git clone` invocation) from a shell-prompt
8793        // one-liner, intending the `KEY=VALUE` prefix as a shell-
8794        // grammar env-var assignment but the typed `:repo` slot is
8795        // a value parser, not a shell context, so the bytes ride
8796        // into the value verbatim. Until this arm landed the `=`
8797        // byte silently passed every prior `is_git_repo_url` arm
8798        // (no whitespace, no control chars, no non-ASCII, no `#`,
8799        // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8800        // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8801        // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8802        // the byte rode into the lacre's per-dep content-address
8803        // and the resolver's `git clone <repo>` subprocess
8804        // invocation, where the upstream host's git porcelain
8805        // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8806        // path that no host's repo registry resolves.
8807        let d = dep_with_fonte(DepSource::Git {
8808            repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8809            tag: Some("v0.1.0".into()),
8810            rev: None,
8811            branch: None,
8812        });
8813        let err = d.validate().unwrap_err();
8814        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8815            panic!("expected FonteRepoShape, got other variant");
8816        };
8817        assert_eq!(nome, "caixa-teia");
8818        assert_eq!(
8819            repo,
8820            "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8821        );
8822        // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8823        // appears before the ` ` byte at position 21, so the `=`
8824        // arm fires (not the whitespace arm) — both arms guard
8825        // the slot, but the per-byte for-loop scans left-to-right
8826        // and the first matching byte wins.
8827        assert!(
8828            reason.contains("must not contain `=`"),
8829            "reason must surface the equals-`=` arm on the env-var-assignment \
8830             paste shape, got {reason:?}"
8831        );
8832        assert!(
8833            reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8834            "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8835        );
8836    }
8837
8838    #[test]
8839    fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8840        // The symmetric paste-from-gitconfig pin: an author copies
8841        // `url=https://github.com/p/x` from `git config --get-all
8842        // remote.origin.url` output, a `.gitconfig` `[remote
8843        // "origin"] url = https://…` ini-stanza paste, or a
8844        // `git config remote.origin.url <value>` doc snippet,
8845        // intending the `url=` prefix as the ini-key but the typed
8846        // `:repo` slot is a URL value parser, not a gitconfig
8847        // grammar. With no leading whitespace and no earlier-arm
8848        // bytes in the value, the `=` arm itself fires (rather
8849        // than cascading to the whitespace arm as in the env-var
8850        // paste shape). Pinned separately so a future diagnostic-
8851        // surface change that only checked the whitespace-leading
8852        // shape surfaces here — the per-byte arm fires anywhere
8853        // `=` appears in the value.
8854        let d = dep_with_fonte(DepSource::Git {
8855            repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8856            tag: Some("v0.1.0".into()),
8857            rev: None,
8858            branch: None,
8859        });
8860        let err = d.validate().unwrap_err();
8861        let DepError::FonteRepoShape { reason, .. } = err else {
8862            panic!("expected FonteRepoShape, got other variant");
8863        };
8864        assert!(
8865            reason.contains("must not contain `=`"),
8866            "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8867             paste shape, got {reason:?}"
8868        );
8869        assert!(
8870            reason.contains("key-value-separator") || reason.contains("sub-delims"),
8871            "reason must name the key-value-separator / RFC-3986-sub-delims \
8872             rationale, got {reason:?}"
8873        );
8874    }
8875
8876    #[test]
8877    fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8878        // Cascade pin: the fragment-`#` arm and the `=` arm are
8879        // both per-byte arms inside the same `for &b in s.as_bytes()`
8880        // loop, so the byte that appears first in the value's byte
8881        // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8882        // carries both `#` and `=`; the `#` byte appears first, so
8883        // the fragment-`#` arm fires, surfacing the more self-
8884        // locating diagnostic on the byte the author pasted earliest
8885        // in the URL.
8886        let d = dep_with_fonte(DepSource::Git {
8887            repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8888            tag: Some("v0.1.0".into()),
8889            rev: None,
8890            branch: None,
8891        });
8892        let err = d.validate().unwrap_err();
8893        let DepError::FonteRepoShape { reason, .. } = err else {
8894            panic!("expected FonteRepoShape, got other variant");
8895        };
8896        assert!(
8897            reason.contains("must not contain `#`"),
8898            "reason must surface the fragment-`#` arm (fires before equals when \
8899             `#` byte appears first in value), got {reason:?}"
8900        );
8901    }
8902
8903    #[test]
8904    fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8905        // Cascade pin: the comma-`,` arm (the immediate-predecessor
8906        // byte-class arm, 775b80e) and the `=` arm are both per-byte
8907        // arms inside the same `for &b in s.as_bytes()` loop, so
8908        // the byte that appears first in the value's byte order
8909        // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8910        // and `=`; the `,` byte appears first, so the comma arm
8911        // fires, surfacing the more self-locating diagnostic on
8912        // the byte the author pasted earliest in the URL. Pins the
8913        // natural-order cascade so a future reorder of the per-byte
8914        // arms surfaces here — `=` is the most recent byte-class
8915        // arm, so the cascade-pin sweep extends to cover the
8916        // immediately prior `,` byte arm firing first when ordered
8917        // ahead of `=` in the value.
8918        let d = dep_with_fonte(DepSource::Git {
8919            repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8920            tag: Some("v0.1.0".into()),
8921            rev: None,
8922            branch: None,
8923        });
8924        let err = d.validate().unwrap_err();
8925        let DepError::FonteRepoShape { reason, .. } = err else {
8926            panic!("expected FonteRepoShape, got other variant");
8927        };
8928        assert!(
8929            reason.contains("must not contain `,`"),
8930            "reason must surface the comma arm (fires before equals when `,` byte \
8931             appears first in value), got {reason:?}"
8932        );
8933    }
8934
8935    #[test]
8936    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8937        // The fail-before-pass-after pin for the canonical paste-from-
8938        // browser-address-bar percent-encoded-space footgun on `:repo`.
8939        // An author copies `https://github.com/p/x%20test` from a
8940        // browser address bar (or a percent-encoded README hyperlink,
8941        // or a `curl --data-urlencode` shell-pipeline output)
8942        // intending `%20` as the URL encoding of a literal space; the
8943        // typed `:repo` slot already rejects the literal space byte
8944        // (the whitespace arm at the top of `is_git_repo_url`), so an
8945        // author trying to express "I really meant a space" reaches
8946        // for percent-encoding. Until this arm landed the `%` byte
8947        // silently passed every prior `is_git_repo_url` arm and rode
8948        // verbatim into the lacre's per-dep content-address — but
8949        // libcurl re-percent-encodes `%` to `%25` on the wire (since
8950        // `%` is reserved as the escape-sequence lead-in), so the
8951        // wire request becomes `https://github.com/p/x%2520test`, a
8952        // path the lacre's content-address never names. The classic
8953        // render-determinism violation on the encoding-mechanism axis
8954        // itself.
8955        let d = dep_with_fonte(DepSource::Git {
8956            repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8957            tag: Some("v0.1.0".into()),
8958            rev: None,
8959            branch: None,
8960        });
8961        let err = d.validate().unwrap_err();
8962        let DepError::FonteRepoShape { nome, repo, reason } = err else {
8963            panic!("expected FonteRepoShape, got other variant");
8964        };
8965        assert_eq!(nome, "caixa-teia");
8966        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8967        assert!(
8968            reason.contains("must not contain `%`"),
8969            "reason must surface the percent-`%` arm on the percent-encoded-space \
8970             paste shape, got {reason:?}"
8971        );
8972        assert!(
8973            reason.contains("percent-encoding") || reason.contains("%25"),
8974            "reason must name the percent-encoding / `%25` re-encoding rationale, \
8975             got {reason:?}"
8976        );
8977    }
8978
8979    #[test]
8980    fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8981        // The symmetric over-encoded-path-separator pin: an author
8982        // writes `:repo "https://github.com/p%2Fx"` intending the
8983        // `%2F` as the URL encoding of `/` (the canonical
8984        // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8985        // footgun every API client library and OAuth redirect-URI
8986        // documentation surfaces — the `/` is the URL-path-separator
8987        // and some templates percent-encode it to escape interpretation
8988        // as a path separator). The GitHub Smart-HTTP transport
8989        // resolves the URL's path-segment grammar before the
8990        // percent-decoding pass, so the value identifies a different
8991        // resource on the wire than the literal-`/` form the lacre's
8992        // content-address must agree with — two authors whose `:repo`
8993        // values differ only in their `/` vs `%2F` presence lock to
8994        // two distinct BLAKE3 closures for the byte-identical upstream
8995        // `git clone`. Pinned separately so a future diagnostic
8996        // surface that only catches the `%20` shape surfaces here too.
8997        let d = dep_with_fonte(DepSource::Git {
8998            repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8999            tag: Some("v0.1.0".into()),
9000            rev: None,
9001            branch: None,
9002        });
9003        let err = d.validate().unwrap_err();
9004        let DepError::FonteRepoShape { reason, .. } = err else {
9005            panic!("expected FonteRepoShape, got other variant");
9006        };
9007        assert!(
9008            reason.contains("must not contain `%`"),
9009            "reason must surface the percent-`%` arm on the over-encoded-path \
9010             shape, got {reason:?}"
9011        );
9012        assert!(
9013            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9014            "reason must name the render-determinism / BLAKE3-closure rationale, \
9015             got {reason:?}"
9016        );
9017    }
9018
9019    #[test]
9020    fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
9021        // Cascade pin: the fragment-`#` arm and the `%` arm are both
9022        // per-byte arms inside the same `for &b in s.as_bytes()` loop,
9023        // so the byte that appears first in the value's byte order
9024        // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
9025        // both `#` and `%`; the `#` byte appears first, so the
9026        // fragment-`#` arm fires, surfacing the more self-locating
9027        // diagnostic on the byte the author pasted earliest in the URL.
9028        let d = dep_with_fonte(DepSource::Git {
9029            repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
9030            tag: Some("v0.1.0".into()),
9031            rev: None,
9032            branch: None,
9033        });
9034        let err = d.validate().unwrap_err();
9035        let DepError::FonteRepoShape { reason, .. } = err else {
9036            panic!("expected FonteRepoShape, got other variant");
9037        };
9038        assert!(
9039            reason.contains("must not contain `#`"),
9040            "reason must surface the fragment-`#` arm (fires before percent when \
9041             `#` byte appears first in value), got {reason:?}"
9042        );
9043    }
9044
9045    #[test]
9046    fn fonte_repo_equals_fires_before_percent_when_equals_first() {
9047        // Cascade pin: the equals-`=` arm (the immediate-predecessor
9048        // byte-class arm, acf99af) and the `%` arm are both per-byte
9049        // arms inside the same `for &b in s.as_bytes()` loop, so the
9050        // byte that appears first in the value's byte order wins.
9051        // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
9052        // the `=` byte appears first, so the equals arm fires,
9053        // surfacing the more self-locating diagnostic on the byte the
9054        // author pasted earliest in the URL. Pins the natural-order
9055        // cascade so a future reorder of the per-byte arms surfaces
9056        // here — `%` is the most recent byte-class arm, so the
9057        // cascade-pin sweep extends to cover the immediately prior
9058        // `=` byte arm firing first when ordered ahead of `%` in the
9059        // value.
9060        let d = dep_with_fonte(DepSource::Git {
9061            repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
9062            tag: Some("v0.1.0".into()),
9063            rev: None,
9064            branch: None,
9065        });
9066        let err = d.validate().unwrap_err();
9067        let DepError::FonteRepoShape { reason, .. } = err else {
9068            panic!("expected FonteRepoShape, got other variant");
9069        };
9070        assert!(
9071            reason.contains("must not contain `=`"),
9072            "reason must surface the equals arm (fires before percent when `=` byte \
9073             appears first in value), got {reason:?}"
9074        );
9075    }
9076
9077    #[test]
9078    fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
9079        // The fail-before-pass-after pin for the canonical paste-from-
9080        // shell-history footgun on `:repo`. An author copies a
9081        // `git clone <url>` line from their terminal followed by a
9082        // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
9083        // history shorthand (the `^old^new^` form re-runs the prior
9084        // history entry with the first `old` substituted by `new`,
9085        // bash's default behavior on interactive sessions with
9086        // `set -o histexpand`), forgetting to trim the trailing
9087        // `^...^...` shell-history fragment from the URL value. The
9088        // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
9089        // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
9090        // classes), the WHATWG URL spec's 'fragment percent-encode
9091        // set' maps `^` → `%5E` on the wire, so the byte rides
9092        // verbatim into the lacre's per-dep content-address but
9093        // libcurl re-encodes it to `%5E` at `git clone` time — the
9094        // classic render-determinism violation on the same axis the
9095        // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
9096        // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
9097        // `#` arms close.
9098        let d = dep_with_fonte(DepSource::Git {
9099            repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
9100            tag: Some("v0.1.0".into()),
9101            rev: None,
9102            branch: None,
9103        });
9104        let err = d.validate().unwrap_err();
9105        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9106            panic!("expected FonteRepoShape, got other variant");
9107        };
9108        assert_eq!(nome, "caixa-teia");
9109        assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
9110        assert!(
9111            reason.contains("must not contain `^`"),
9112            "reason must surface the caret-`^` arm on the paste-from-shell-history \
9113             shape, got {reason:?}"
9114        );
9115        assert!(
9116            reason.contains("history-substitution") || reason.contains("%5E"),
9117            "reason must name the shell-history-substitution / `%5E` wire-encoding \
9118             rationale, got {reason:?}"
9119        );
9120    }
9121
9122    #[test]
9123    fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
9124        // The symmetric paste-from-doc-grep-pipeline footgun: an
9125        // author writes `:repo "github:p/^archived"` after copying a
9126        // `grep '^archived'` regex-anchor / negation idiom from a
9127        // doc / README quick-listing snippet, expecting the substrate
9128        // to coerce it to a literal repo name. The byte rides
9129        // verbatim into the lacre's per-dep content-address and
9130        // diverges from the byte-identical literal `archived` form
9131        // every other author authored — the canonical render-
9132        // determinism violation pin on the second footgun shape the
9133        // caret-`^` arm closes.
9134        let d = dep_with_fonte(DepSource::Git {
9135            repo: "github:pleme-io/^archived".into(),
9136            tag: Some("v0.1.0".into()),
9137            rev: None,
9138            branch: None,
9139        });
9140        let err = d.validate().unwrap_err();
9141        let DepError::FonteRepoShape { reason, .. } = err else {
9142            panic!("expected FonteRepoShape, got other variant");
9143        };
9144        assert!(
9145            reason.contains("must not contain `^`"),
9146            "reason must surface the caret-`^` arm on the regex-anchor shape, \
9147             got {reason:?}"
9148        );
9149        assert!(
9150            reason.contains("render-determinism") || reason.contains("BLAKE3"),
9151            "reason must name the render-determinism / BLAKE3-closure rationale, \
9152             got {reason:?}"
9153        );
9154    }
9155
9156    #[test]
9157    fn fonte_repo_percent_fires_before_caret_when_percent_first() {
9158        // Cascade pin: the `%` arm (the immediate-predecessor byte-
9159        // class arm, a323db8) and the `^` arm are both per-byte arms
9160        // inside the same `for &b in s.as_bytes()` loop, so the byte
9161        // that appears first in the value's byte order wins. A
9162        // `:repo "https://github.com/p/x%20mid^tail"` carries both
9163        // `%` and `^`; the `%` byte appears first, so the percent
9164        // arm fires, surfacing the more self-locating diagnostic on
9165        // the byte the author pasted earliest in the URL. Pins the
9166        // natural-order cascade so a future reorder of the per-byte
9167        // arms surfaces here — `^` is the most recent byte-class arm,
9168        // so the cascade-pin sweep extends to cover the immediately
9169        // prior `%` byte arm firing first when ordered ahead of `^`
9170        // in the value.
9171        let d = dep_with_fonte(DepSource::Git {
9172            repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
9173            tag: Some("v0.1.0".into()),
9174            rev: None,
9175            branch: None,
9176        });
9177        let err = d.validate().unwrap_err();
9178        let DepError::FonteRepoShape { reason, .. } = err else {
9179            panic!("expected FonteRepoShape, got other variant");
9180        };
9181        assert!(
9182            reason.contains("must not contain `%`"),
9183            "reason must surface the percent arm (fires before caret when `%` byte \
9184             appears first in value), got {reason:?}"
9185        );
9186    }
9187
9188    #[test]
9189    fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
9190        // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
9191        // (no `github:` prefix, no scheme). Every documented form
9192        // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
9193        // `file://`, or `git@host:path`); a bare `org/repo` is
9194        // ambiguous (`git clone` reads as a relative filesystem path
9195        // rather than the GitHub-shorthand expansion the author
9196        // probably intended) and the gate rejects the shape upstream.
9197        let d = dep_with_fonte(DepSource::Git {
9198            repo: "pleme-io/caixa-teia".into(),
9199            tag: Some("v0.1.0".into()),
9200            rev: None,
9201            branch: None,
9202        });
9203        let err = d.validate().unwrap_err();
9204        let DepError::FonteRepoShape { reason, .. } = err else {
9205            panic!("expected FonteRepoShape, got other variant");
9206        };
9207        assert!(
9208            reason.contains("must contain a `:`"),
9209            "reason must surface the missing-`:` arm, got {reason:?}"
9210        );
9211        assert!(
9212            reason.contains("github:"),
9213            "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
9214        );
9215    }
9216
9217    #[test]
9218    fn validate_rejects_git_fonte_with_repo_leading_colon() {
9219        // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
9220        // scheme that no git porcelain entry-point accepts. Pinned
9221        // separately from the missing-`:` arm because a value with a
9222        // leading `:` does technically contain a `:` separator; the
9223        // shape gate rejects on a dedicated arm so the diagnostic
9224        // names the specific footgun.
9225        let d = dep_with_fonte(DepSource::Git {
9226            repo: ":pleme-io/caixa-teia".into(),
9227            tag: Some("v0.1.0".into()),
9228            rev: None,
9229            branch: None,
9230        });
9231        let err = d.validate().unwrap_err();
9232        let DepError::FonteRepoShape { reason, .. } = err else {
9233            panic!("expected FonteRepoShape, got other variant");
9234        };
9235        assert!(
9236            reason.contains("must not start with `:`"),
9237            "reason must surface the leading-`:` arm, got {reason:?}"
9238        );
9239    }
9240
9241    #[test]
9242    fn validate_rejects_git_fonte_with_repo_too_long() {
9243        // The cap arm — a `:repo` value longer than
9244        // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
9245        // structurally untenable on every realistic landing site (the
9246        // resolver's `git clone` invocation, the future M4 CR
9247        // materializer's per-dep `repo:` axis); a value of that length
9248        // is almost certainly a paste-from-binary slug.
9249        let too_long = format!(
9250            "github:pleme-io/{}",
9251            "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
9252        );
9253        let d = dep_with_fonte(DepSource::Git {
9254            repo: too_long.clone(),
9255            tag: Some("v0.1.0".into()),
9256            rev: None,
9257            branch: None,
9258        });
9259        let err = d.validate().unwrap_err();
9260        let DepError::FonteRepoShape { reason, .. } = err else {
9261            panic!("expected FonteRepoShape, got other variant");
9262        };
9263        assert!(
9264            reason.contains("2048"),
9265            "reason must name the cap, got {reason:?}"
9266        );
9267    }
9268
9269    #[test]
9270    fn validate_accepts_canonical_git_fonte_repo_shapes() {
9271        // The positive-control sweep: every documented author shape on
9272        // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
9273        // must pass the value-shape gate. Pinned so a future tightening
9274        // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
9275        // here as a structural decision. Each form is exercised with the
9276        // same canonical `:tag` pin so only the `:repo` axis varies.
9277        for repo in [
9278            // The pleme-io registry-shorthand convention — `github:org/repo`.
9279            "github:pleme-io/caixa-teia",
9280            // Other host-aliased shorthands (the resolver's pluggable
9281            // host-prefix table).
9282            "gitlab:pleme-io/caixa-teia",
9283            "codeberg:pleme-io/caixa-teia",
9284            "sourcehut:~pleme-io/caixa-teia",
9285            // Full HTTPS URL with and without `.git` suffix.
9286            "https://github.com/pleme-io/caixa-teia",
9287            "https://github.com/pleme-io/caixa-teia.git",
9288            // HTTP (rare; dev / mirror).
9289            "http://example.com/pleme-io/caixa-teia.git",
9290            // SSH URL.
9291            "ssh://git@github.com/pleme-io/caixa-teia.git",
9292            "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
9293            // Scp-style SSH — the canonical `git@host:path` short form.
9294            "git@github.com:pleme-io/caixa-teia.git",
9295            "git@git.example.com:team/private.git",
9296            // Anonymous git protocol.
9297            "git://git.example.com/pleme-io/caixa-teia.git",
9298            // Local file URL (dev path).
9299            "file:///tmp/caixa-teia",
9300        ] {
9301            let d = dep_with_fonte(DepSource::Git {
9302                repo: repo.into(),
9303                tag: Some("v0.1.0".into()),
9304                rev: None,
9305                branch: None,
9306            });
9307            d.validate()
9308                .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
9309        }
9310    }
9311
9312    #[test]
9313    fn fonte_repo_empty_takes_precedence_over_shape() {
9314        // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
9315        // diagnostic; doesn't try to parse the URL shape) fires before
9316        // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
9317        // keeps its narrower error message. Mirrors
9318        // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
9319        // on the ordering layer.
9320        let d = dep_with_fonte(DepSource::Git {
9321            repo: String::new(),
9322            tag: Some("v0.1.0".into()),
9323            rev: None,
9324            branch: None,
9325        });
9326        let err = d.validate().unwrap_err();
9327        assert!(
9328            matches!(err, DepError::FonteRepoEmpty { .. }),
9329            "got {err:?}"
9330        );
9331    }
9332
9333    #[test]
9334    fn fonte_repo_shape_fires_before_pin_missing() {
9335        // Order pin: a malformed `:repo` value on a dep with no pin set
9336        // surfaces the `:repo` shape diagnostic (the more self-locating
9337        // axis — the `:repo` is the load-bearing identity of the source;
9338        // a missing pin is downstream from "do we even know the repo")
9339        // rather than collapsing onto the pin-missing diagnostic. The
9340        // shape gate runs inline before the pin enumeration in
9341        // `DepSource::validate`.
9342        let d = dep_with_fonte(DepSource::Git {
9343            repo: "pleme-io/caixa-teia".into(), // missing `:` separator
9344            tag: None,
9345            rev: None,
9346            branch: None,
9347        });
9348        let err = d.validate().unwrap_err();
9349        assert!(
9350            matches!(err, DepError::FonteRepoShape { .. }),
9351            "got {err:?}"
9352        );
9353    }
9354
9355    #[test]
9356    fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
9357        // The diagnostic-shape pin: the error names the offending
9358        // `:repo` value verbatim plus a non-empty parser-shaped `reason`
9359        // so the author can grep their caixa.lisp without re-running
9360        // the build. Mirrors the diagnostic-shape sweep on every prior
9361        // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
9362        let d = dep_with_fonte(DepSource::Git {
9363            repo: "pleme-io/caixa-teia".into(),
9364            tag: Some("v0.1.0".into()),
9365            rev: None,
9366            branch: None,
9367        });
9368        let err = d.validate().unwrap_err();
9369        let DepError::FonteRepoShape { nome, repo, reason } = err else {
9370            panic!("expected FonteRepoShape, got other variant");
9371        };
9372        assert_eq!(nome, "caixa-teia");
9373        assert_eq!(repo, "pleme-io/caixa-teia");
9374        assert!(
9375            !reason.is_empty(),
9376            "FonteRepoShape `reason` must carry the predicate's wording verbatim"
9377        );
9378    }
9379
9380    #[test]
9381    fn validate_rejects_git_fonte_with_no_pin() {
9382        // The fail-before-pass-after pin for the canonical
9383        // `(:tipo git :repo "github:pleme-io/x")` shape with no
9384        // :tag/:rev/:branch — until this gate landed the resolver's
9385        // ResolveError::MissingPin surfaced at fetch time, far from the
9386        // source caixa.lisp. The new gate moves the check to validate
9387        // time and names the offending dep.
9388        let d = dep_with_fonte(DepSource::Git {
9389            repo: "github:pleme-io/caixa-teia".into(),
9390            tag: None,
9391            rev: None,
9392            branch: None,
9393        });
9394        let err = d.validate().unwrap_err();
9395        assert!(
9396            matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
9397            "got {err:?}"
9398        );
9399    }
9400
9401    #[test]
9402    fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
9403        // The canonical "pin drift" footgun: an author writes
9404        // `:tag "v1"` and later adds `:branch "main"` without removing
9405        // the :tag, and the resolver silently picks :tag (precedence
9406        // :rev > :tag > :branch). The :branch was dropped with no
9407        // diagnostic. The gate now rejects multi-pin shapes so the
9408        // author makes the precedence explicit at the source.
9409        let d = dep_with_fonte(DepSource::Git {
9410            repo: "github:pleme-io/caixa-teia".into(),
9411            tag: Some("v0.1.0".into()),
9412            rev: None,
9413            branch: Some("main".into()),
9414        });
9415        let err = d.validate().unwrap_err();
9416        let DepError::FontePinAmbiguous { nome, pins } = err else {
9417            panic!("expected FontePinAmbiguous");
9418        };
9419        assert_eq!(nome, "caixa-teia");
9420        assert!(pins.contains(":tag"));
9421        assert!(pins.contains(":branch"));
9422        assert!(!pins.contains(":rev"));
9423    }
9424
9425    #[test]
9426    fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
9427        // Sibling arm of the pin-drift footgun: :tag + :rev set
9428        // simultaneously. Pinned separately so a future relaxation
9429        // that only catches the (:tag, :branch) pair surfaces here.
9430        let d = dep_with_fonte(DepSource::Git {
9431            repo: "github:pleme-io/caixa-teia".into(),
9432            tag: Some("v0.1.0".into()),
9433            rev: Some("c0ffee".into()),
9434            branch: None,
9435        });
9436        let err = d.validate().unwrap_err();
9437        let DepError::FontePinAmbiguous { nome, pins } = err else {
9438            panic!("expected FontePinAmbiguous");
9439        };
9440        assert_eq!(nome, "caixa-teia");
9441        assert!(pins.contains(":tag"));
9442        assert!(pins.contains(":rev"));
9443    }
9444
9445    #[test]
9446    fn validate_rejects_git_fonte_with_all_three_pins() {
9447        // The maximal ambiguity case — every pin axis set. Pinned so a
9448        // future relaxation that only catches pairs surfaces here. The
9449        // diagnostic must enumerate every offending axis so the author
9450        // sees the full set, not just the first match.
9451        let d = dep_with_fonte(DepSource::Git {
9452            repo: "github:pleme-io/caixa-teia".into(),
9453            tag: Some("v0.1.0".into()),
9454            rev: Some("c0ffee".into()),
9455            branch: Some("main".into()),
9456        });
9457        let err = d.validate().unwrap_err();
9458        let DepError::FontePinAmbiguous { nome, pins } = err else {
9459            panic!("expected FontePinAmbiguous");
9460        };
9461        assert_eq!(nome, "caixa-teia");
9462        assert!(pins.contains(":tag"));
9463        assert!(pins.contains(":rev"));
9464        assert!(pins.contains(":branch"));
9465    }
9466
9467    #[test]
9468    fn validate_rejects_git_fonte_with_empty_tag_pin() {
9469        // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
9470        // inner string is empty. Distinct from FontePinMissing (where
9471        // every axis is None) — pinned separately so a future
9472        // tightening collapsing them surfaces here as a structural
9473        // decision.
9474        let d = dep_with_fonte(DepSource::Git {
9475            repo: "github:pleme-io/caixa-teia".into(),
9476            tag: Some(String::new()),
9477            rev: None,
9478            branch: None,
9479        });
9480        let err = d.validate().unwrap_err();
9481        let DepError::FontePinEmpty { nome, pin } = err else {
9482            panic!("expected FontePinEmpty");
9483        };
9484        assert_eq!(nome, "caixa-teia");
9485        assert_eq!(pin, ":tag");
9486    }
9487
9488    #[test]
9489    fn validate_rejects_git_fonte_with_empty_rev_pin() {
9490        // Sibling arm — the empty-pin diagnostic names which axis
9491        // carries the empty value, so the author's grep target is
9492        // unambiguous.
9493        let d = dep_with_fonte(DepSource::Git {
9494            repo: "github:pleme-io/caixa-teia".into(),
9495            tag: None,
9496            rev: Some(String::new()),
9497            branch: None,
9498        });
9499        let err = d.validate().unwrap_err();
9500        let DepError::FontePinEmpty { nome, pin } = err else {
9501            panic!("expected FontePinEmpty");
9502        };
9503        assert_eq!(nome, "caixa-teia");
9504        assert_eq!(pin, ":rev");
9505    }
9506
9507    #[test]
9508    fn validate_rejects_path_fonte_with_empty_caminho() {
9509        // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
9510        // until this gate landed the resolver's
9511        // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
9512        // fetch time — not actionable. The new gate moves the check to
9513        // validate time and names the offending dep.
9514        let d = dep_with_fonte(DepSource::Path {
9515            caminho: String::new(),
9516        });
9517        let err = d.validate().unwrap_err();
9518        assert!(
9519            matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
9520            "got {err:?}"
9521        );
9522    }
9523
9524    #[test]
9525    fn validate_rejects_path_fonte_with_absolute_caminho() {
9526        // The fail-before-pass-after pin for the absolute-`:caminho`
9527        // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
9528        // Until this gate landed an absolute `:caminho` silently
9529        // passed validate; the lacre pipeline embedded the
9530        // host-specific filesystem path verbatim in its
9531        // content-address (`conteudo: format!("path:{caminho}")`,
9532        // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
9533        // differed per machine — the build succeeded but two CI
9534        // runners with different `${HOME}` layouts emitted two
9535        // distinct lacres for the byte-identical caixa, silently
9536        // breaking the THEORY.md §V.2 render-determinism contract
9537        // far from the source caixa.lisp. The new gate moves the
9538        // check to validate time and names the offending dep +
9539        // caminho verbatim.
9540        let d = dep_with_fonte(DepSource::Path {
9541            caminho: "/home/me/work/caixa-teia".into(),
9542        });
9543        let err = d.validate().unwrap_err();
9544        let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9545            panic!("expected FonteCaminhoAbsolute, got other variant");
9546        };
9547        assert_eq!(nome, "caixa-teia");
9548        assert_eq!(caminho, "/home/me/work/caixa-teia");
9549    }
9550
9551    #[test]
9552    fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9553        // The canonical sibling-workspace dep form
9554        // (`:caminho "../caixa-teia"`) remains accepted. The
9555        // absolute-path gate above is specifically narrower than the
9556        // shared [`crate::render::is_sandboxed_relative_path`]
9557        // predicate (which additionally forbids `..` traversal): a
9558        // local-path dep's canonical author surface is the in-tree
9559        // sibling-workspace path, so a full sandboxed-relative-path
9560        // lift would structurally reject every legitimate path-fonte
9561        // dep. Pinned so a future tightening to the full predicate
9562        // surfaces here as a structural decision, not a silent break.
9563        let d = dep_with_fonte(DepSource::Path {
9564            caminho: "../caixa-teia".into(),
9565        });
9566        d.validate().unwrap();
9567    }
9568
9569    #[test]
9570    fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9571        // A multi-segment relative `:caminho`
9572        // (`"vendor/forks/caixa-teia"`) remains accepted — the
9573        // absolute-path gate brackets the host-layout-leaking shape
9574        // at the leading-`/` boundary only; every relative shape past
9575        // the empty arm continues to pass. Pinned alongside the
9576        // `..`-traversal positive control so a future tightening
9577        // surfaces the full set of legitimate relative forms here
9578        // rather than at a downstream consumer.
9579        let d = dep_with_fonte(DepSource::Path {
9580            caminho: "vendor/forks/caixa-teia".into(),
9581        });
9582        d.validate().unwrap();
9583    }
9584
9585    #[test]
9586    fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9587        // The fail-before-pass-after pin for the tilde-expansion
9588        // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9589        // Until this gate landed the b94fd83 absolute arm let `~/foo`
9590        // through (`Path::is_absolute` returns false on a leading `~`
9591        // — the tilde is a shell-expansion convention, not a POSIX
9592        // path component), so the lacre embedded the value verbatim
9593        // and the resolver folded it through `Path::join` without
9594        // expansion, looking for a literal `./~/work/caixa-teia`
9595        // subdirectory and failing at resolve time with a
9596        // `No such file or directory` error far from the source
9597        // caixa.lisp. The new gate moves the check to validate time
9598        // and names the offending dep + caminho verbatim.
9599        let d = dep_with_fonte(DepSource::Path {
9600            caminho: "~/work/caixa-teia".into(),
9601        });
9602        let err = d.validate().unwrap_err();
9603        let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9604            panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9605        };
9606        assert_eq!(nome, "caixa-teia");
9607        assert_eq!(caminho, "~/work/caixa-teia");
9608    }
9609
9610    #[test]
9611    fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9612        // The bare `~` form (canonical "I meant `$HOME` and forgot
9613        // the rest"): both the leading-tilde arm catches it and the
9614        // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9615        // sweeps through the same arm. Pinned both to ensure the
9616        // gate doesn't narrow to `~/` only.
9617        for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9618            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9619            let err = d.validate().unwrap_err();
9620            assert!(
9621                matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9622                "{s:?} → {err:?}",
9623            );
9624        }
9625    }
9626
9627    #[test]
9628    fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9629        // The leading-`~` is the canonical shell-expansion footgun —
9630        // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9631        // backup-file-suffix idiom) is a legitimate POSIX path byte
9632        // with no shell-expansion semantic at the leading position.
9633        // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9634        // sweep that would break every legitimate-shape backup-file
9635        // path.
9636        let d = dep_with_fonte(DepSource::Path {
9637            caminho: "../foo~bar/caixa-teia".into(),
9638        });
9639        d.validate().unwrap();
9640    }
9641
9642    #[test]
9643    fn fonte_caminho_empty_fires_before_tilde_expansion() {
9644        // Cascade pin: the empty arm structurally precedes the
9645        // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9646        // pin establishes the precedence at the diagnostic-shape
9647        // level should a future codec round-trip ever produce a
9648        // probe-as-both value. Mirrors the peer
9649        // `fonte_repo_empty_fires_before_pin_missing` cascade
9650        // discipline.
9651        let d = dep_with_fonte(DepSource::Path {
9652            caminho: String::new(),
9653        });
9654        let err = d.validate().unwrap_err();
9655        assert!(
9656            matches!(err, DepError::FonteCaminhoEmpty { .. }),
9657            "got {err:?}",
9658        );
9659    }
9660
9661    #[test]
9662    fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9663        // Diagnostic-shape pin (peer with
9664        // `validate_rejects_path_fonte_with_absolute_caminho`'s
9665        // payload assertion): the error's Display surfaces both the
9666        // offending `:nome` and the offending `:caminho` verbatim
9667        // so a `feira lint` run can render the diagnostic without
9668        // re-parsing.
9669        let d = dep_with_fonte(DepSource::Path {
9670            caminho: "~alice/dev/caixa-teia".into(),
9671        });
9672        let rendered = d.validate().unwrap_err().to_string();
9673        assert!(
9674            rendered.contains("caixa-teia"),
9675            "diagnostic must name the offending dep: {rendered}",
9676        );
9677        assert!(
9678            rendered.contains("~alice/dev/caixa-teia"),
9679            "diagnostic must quote the offending caminho: {rendered}",
9680        );
9681        assert!(
9682            rendered.contains('~'),
9683            "diagnostic must reference the tilde footgun: {rendered}",
9684        );
9685    }
9686
9687    #[test]
9688    fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9689        // The fail-before-pass-after pin for the shell-variable-
9690        // expansion `:caminho` shape: `(:tipo path :caminho
9691        // "$HOME/work/caixa-teia")`. Until this gate landed the
9692        // b94fd83 absolute arm + the a5c248e tilde arm both let
9693        // `$HOME/foo` through (`Path::is_absolute` returns false on
9694        // a leading `$` — the `$` is a shell convention, not a POSIX
9695        // path component; `starts_with('~')` returns false too), so
9696        // the lacre embedded the value verbatim and the resolver
9697        // folded it through `Path::join` without `$`-expansion,
9698        // looking for a literal `./$HOME/work/caixa-teia`
9699        // subdirectory and failing at resolve time with a
9700        // `No such file or directory` error far from the source
9701        // caixa.lisp. The new gate moves the check to validate time
9702        // and names the offending dep + caminho verbatim.
9703        let d = dep_with_fonte(DepSource::Path {
9704            caminho: "$HOME/work/caixa-teia".into(),
9705        });
9706        let err = d.validate().unwrap_err();
9707        let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9708            panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9709        };
9710        assert_eq!(nome, "caixa-teia");
9711        assert_eq!(caminho, "$HOME/work/caixa-teia");
9712    }
9713
9714    #[test]
9715    fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9716        // Sweep over every leading-`$` shape: the `${VAR}`-braced
9717        // form (canonical "paste-from-CI-manifest" footgun every
9718        // GitHub Actions / GitLab CI / Drone manifest carries on
9719        // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9720        // canonical "I'm referencing a per-user config dir"),
9721        // and the bare `$` (canonical "I meant `$HOME` and forgot
9722        // the rest"). All shapes route through the same gate's
9723        // byte check. Pinned so the gate doesn't narrow to a
9724        // single shape (e.g. `$HOME/` only).
9725        for s in [
9726            "${HOME}/work/caixa-teia",
9727            "${WORKSPACE}/caixa-teia",
9728            "$XDG_CONFIG_HOME/caixa",
9729            "$",
9730        ] {
9731            let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9732            let err = d.validate().unwrap_err();
9733            assert!(
9734                matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9735                "{s:?} → {err:?}",
9736            );
9737        }
9738    }
9739
9740    #[test]
9741    fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9742        // The `$` byte is the canonical shell-variable-expansion /
9743        // command-substitution / arithmetic-expansion sentinel and
9744        // is rejected at *every* position on the `:caminho` axis: the
9745        // leading arm surfaces `FonteCaminhoVarExpansion`, the
9746        // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9747        // (6620f39). Pinned so a future arm doesn't narrow the gate
9748        // back to the leading position and re-open the paste-from-
9749        // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9750        // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9751        // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9752        // the lacre content-address (`path:{caminho}`,
9753        // caixa-resolver/src/resolve.rs:189).
9754        let d = dep_with_fonte(DepSource::Path {
9755            caminho: "../foo$bar/caixa-teia".into(),
9756        });
9757        let err = d.validate().unwrap_err();
9758        assert!(
9759            matches!(
9760                err,
9761                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9762            ),
9763            "got {err:?}",
9764        );
9765    }
9766
9767    #[test]
9768    fn fonte_caminho_tilde_fires_before_var_expansion() {
9769        // Cascade pin: the tilde arm structurally precedes the var
9770        // arm (the bytes `~` and `$` don't overlap at the leading
9771        // position), but the pin establishes the precedence at the
9772        // diagnostic-shape level should a future codec round-trip
9773        // ever produce a probe-as-both value. Mirrors the peer
9774        // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9775        // discipline on the immediate-predecessor arm.
9776        let d = dep_with_fonte(DepSource::Path {
9777            caminho: "~/work/caixa-teia".into(),
9778        });
9779        let err = d.validate().unwrap_err();
9780        assert!(
9781            matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9782            "got {err:?}",
9783        );
9784    }
9785
9786    #[test]
9787    fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9788        // Diagnostic-shape pin (peer with
9789        // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9790        // payload assertion on the immediate-predecessor arm): the
9791        // error's Display surfaces both the offending `:nome` and
9792        // the offending `:caminho` verbatim plus the `$` footgun
9793        // character itself so a `feira lint` run can render the
9794        // diagnostic without re-parsing.
9795        let d = dep_with_fonte(DepSource::Path {
9796            caminho: "${WORKSPACE}/caixa-teia".into(),
9797        });
9798        let rendered = d.validate().unwrap_err().to_string();
9799        assert!(
9800            rendered.contains("caixa-teia"),
9801            "diagnostic must name the offending dep: {rendered}",
9802        );
9803        assert!(
9804            rendered.contains("${WORKSPACE}/caixa-teia"),
9805            "diagnostic must quote the offending caminho: {rendered}",
9806        );
9807        assert!(
9808            rendered.contains('$'),
9809            "diagnostic must reference the dollar footgun: {rendered}",
9810        );
9811    }
9812
9813    #[test]
9814    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9815        // The fail-before-pass-after pin for the load-bearing NUL byte:
9816        // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9817        // routes the path through `CString::new` which fails with
9818        // `NulError`); until this gate landed a `:caminho
9819        // "../caixa\0teia"` silently passed validate, the lacre
9820        // pipeline embedded the value verbatim, and the failure
9821        // surfaced at the resolver's `Path::join` → `CString::new`
9822        // boundary with a non-self-locating `NulError` far from the
9823        // source caixa.lisp. The new gate moves the check to validate
9824        // time and names the offending dep + caminho + offending byte
9825        // verbatim.
9826        let d = dep_with_fonte(DepSource::Path {
9827            caminho: "../caixa\0teia".into(),
9828        });
9829        let err = d.validate().unwrap_err();
9830        let DepError::FonteCaminhoControlChar {
9831            nome,
9832            caminho,
9833            byte,
9834        } = err
9835        else {
9836            panic!("expected FonteCaminhoControlChar, got {err:?}");
9837        };
9838        assert_eq!(nome, "caixa-teia");
9839        assert_eq!(caminho, "../caixa\0teia");
9840        assert_eq!(byte, 0x00);
9841    }
9842
9843    #[test]
9844    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9845        // The canonical paste-from-multiline-doc footgun on `:caminho`
9846        // — author copies `"../caixa-teia\n"` (trailing newline) out
9847        // of a multi-line code-fence or, worse, a `:caminho
9848        // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9849        // injection sibling on the path axis the `is_git_repo_url`
9850        // control-char arm already closes on `:repo`). Pinned
9851        // separately from the NUL arm so a future relaxation that
9852        // catches one but not the other surfaces here.
9853        let d = dep_with_fonte(DepSource::Path {
9854            caminho: "../caixa-teia\n".into(),
9855        });
9856        let err = d.validate().unwrap_err();
9857        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9858            panic!("expected FonteCaminhoControlChar, got {err:?}");
9859        };
9860        assert_eq!(byte, 0x0A);
9861    }
9862
9863    #[test]
9864    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9865        // The CRLF sibling of the LF arm — Windows-line-ending
9866        // paste-from-multiline-doc on a `\r\n`-terminated buffer
9867        // leaves a stray `\r` mid-string after the LF strip. Pinned
9868        // separately from the LF arm so a future relaxation that
9869        // only catches LF surfaces here.
9870        let d = dep_with_fonte(DepSource::Path {
9871            caminho: "../caixa-teia\r".into(),
9872        });
9873        let err = d.validate().unwrap_err();
9874        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9875            panic!("expected FonteCaminhoControlChar, got {err:?}");
9876        };
9877        assert_eq!(byte, 0x0D);
9878    }
9879
9880    #[test]
9881    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9882        // The canonical paste-from-aligned-table footgun — a `\t`
9883        // mid-`:caminho` is invisible in most editors but rides
9884        // through the lacre's content-address verbatim, so two
9885        // paste-from-distinct-tables (one editor strips tabs, one
9886        // preserves them) yield divergent lacres for the byte-
9887        // identical-looking caixa. Pinned separately from the
9888        // whitespace-shaped LF/CR arms so a future relaxation that
9889        // narrows to line-terminator-only surfaces here.
9890        let d = dep_with_fonte(DepSource::Path {
9891            caminho: "../caixa\tteia".into(),
9892        });
9893        let err = d.validate().unwrap_err();
9894        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9895            panic!("expected FonteCaminhoControlChar, got {err:?}");
9896        };
9897        assert_eq!(byte, 0x09);
9898    }
9899
9900    #[test]
9901    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9902        // The DEL byte (`0x7F`) closes the upper-end paste-from-
9903        // binary-blob footgun — the gate's contract is `b < 0x20 ||
9904        // b == 0x7F`, matching the `is_git_repo_url` /
9905        // `is_git_ref_name` predicates' control-char arms. Pinned
9906        // separately from the lower-range arms so a future narrowing
9907        // to `< 0x20` only surfaces here.
9908        let d = dep_with_fonte(DepSource::Path {
9909            caminho: "../caixa\x7fteia".into(),
9910        });
9911        let err = d.validate().unwrap_err();
9912        let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9913            panic!("expected FonteCaminhoControlChar, got {err:?}");
9914        };
9915        assert_eq!(byte, 0x7F);
9916    }
9917
9918    #[test]
9919    fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9920        // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9921        // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9922        // are opaque byte sequences and UTF-8 multi-byte sequences
9923        // are a legitimate filename shape (the `café-teia/foo` idiom).
9924        // Pinned so the gate doesn't widen to a full ASCII-only sweep
9925        // that would break every legitimate-shape UTF-8 path.
9926        let d = dep_with_fonte(DepSource::Path {
9927            caminho: "../café-teia/foo".into(),
9928        });
9929        d.validate().unwrap();
9930    }
9931
9932    #[test]
9933    fn fonte_caminho_var_fires_before_control_char() {
9934        // Cascade pin: the var-expansion arm structurally precedes the
9935        // control-char arm. A value like `"$\n"` probes positive on
9936        // both arms (`starts_with('$')` and contains LF), but the
9937        // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9938        // wins so the author sees the more self-locating shell-
9939        // expansion arm first. Mirrors the
9940        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9941        // discipline on the immediate-predecessor arm.
9942        let d = dep_with_fonte(DepSource::Path {
9943            caminho: "$HOME\n".into(),
9944        });
9945        let err = d.validate().unwrap_err();
9946        assert!(
9947            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9948            "got {err:?}",
9949        );
9950    }
9951
9952    #[test]
9953    fn validate_rejects_path_fonte_with_leading_space_caminho() {
9954        // The fail-before-pass-after pin for the leading ASCII space
9955        // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9956        // Until this gate landed the b94fd83 absolute arm + the a5c248e
9957        // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9958        // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9959        // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9960        // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9961        // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9962        // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9963        // are caught, but the most common whitespace `0x20` space is
9964        // not). The lacre embedded the value verbatim and the resolver
9965        // folded it through `Path::join` looking for a literal `./ ../
9966        // caixa-teia` subdirectory and failing at resolve time with a
9967        // non-self-locating `No such file or directory` error far from
9968        // the source caixa.lisp. The new gate moves the check to
9969        // validate time and names the offending dep + caminho verbatim.
9970        let d = dep_with_fonte(DepSource::Path {
9971            caminho: " ../caixa-teia".into(),
9972        });
9973        let err = d.validate().unwrap_err();
9974        let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9975            panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9976        };
9977        assert_eq!(nome, "caixa-teia");
9978        assert_eq!(caminho, " ../caixa-teia");
9979    }
9980
9981    #[test]
9982    fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9983        // The aligned-doc paste footgun sweep: more than one leading
9984        // space (`"   ../caixa-teia"` — the canonical "I selected the
9985        // aligned column from a four-`:fonte`-entry `:deps` block"
9986        // paste) routes through the same gate's `starts_with(' ')`
9987        // byte check. Pinned so the gate doesn't narrow to a
9988        // single-space prefix.
9989        let d = dep_with_fonte(DepSource::Path {
9990            caminho: "   ../caixa-teia".into(),
9991        });
9992        let err = d.validate().unwrap_err();
9993        assert!(
9994            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9995            "got {err:?}",
9996        );
9997    }
9998
9999    #[test]
10000    fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
10001        // The leading-space is the canonical paste-from-aligned-doc
10002        // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
10003        // canonical "I have a directory with a space in its name"
10004        // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
10005        // legitimate path with no whitespace-leak semantic at the
10006        // non-leading position. Pinned so the gate doesn't widen to a
10007        // full no-space-anywhere sweep that would break every
10008        // legitimate-shape space-in-filename path.
10009        let d = dep_with_fonte(DepSource::Path {
10010            caminho: "../my dir/caixa-teia".into(),
10011        });
10012        d.validate().unwrap();
10013    }
10014
10015    #[test]
10016    fn fonte_caminho_var_fires_before_leading_whitespace() {
10017        // Cascade pin: the var-expansion arm structurally precedes the
10018        // leading-whitespace arm. A value like `"$ "` would probe positive
10019        // on var (`starts_with('$')`) but the leading-byte arms walk
10020        // left-to-right so the var arm fires on the leading `$` before
10021        // the leading-whitespace arm probes. Mirrors the
10022        // `fonte_caminho_tilde_fires_before_var_expansion` cascade
10023        // discipline on the immediate-predecessor arms.
10024        let d = dep_with_fonte(DepSource::Path {
10025            caminho: "$VAR".into(),
10026        });
10027        let err = d.validate().unwrap_err();
10028        assert!(
10029            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10030            "got {err:?}",
10031        );
10032    }
10033
10034    #[test]
10035    fn fonte_caminho_leading_whitespace_fires_before_control_char() {
10036        // Cascade pin: the leading-whitespace arm structurally precedes
10037        // the control-char arm. A value like `" ../foo\n"` probes
10038        // positive on both (starts with space AND contains LF), but
10039        // the narrower leading-byte diagnostic
10040        // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
10041        // more self-locating paste-from-aligned-doc arm first. Mirrors
10042        // the `fonte_caminho_var_fires_before_control_char` cascade
10043        // discipline on the immediate-predecessor arm.
10044        let d = dep_with_fonte(DepSource::Path {
10045            caminho: " ../foo\n".into(),
10046        });
10047        let err = d.validate().unwrap_err();
10048        assert!(
10049            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10050            "got {err:?}",
10051        );
10052    }
10053
10054    #[test]
10055    fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
10056        // Diagnostic-shape pin (peer with
10057        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10058        // payload assertion on the immediate-predecessor arm): the
10059        // error's Display surfaces both the offending `:nome` and the
10060        // offending `:caminho` verbatim, so a `feira lint` run can
10061        // render the diagnostic without re-parsing and the author can
10062        // grep their caixa.lisp for `:caminho "<value>"` and fix it in
10063        // one edit.
10064        let d = dep_with_fonte(DepSource::Path {
10065            caminho: " ../caixa-teia".into(),
10066        });
10067        let rendered = d.validate().unwrap_err().to_string();
10068        assert!(
10069            rendered.contains("caixa-teia"),
10070            "diagnostic must name the offending dep: {rendered}",
10071        );
10072        assert!(
10073            rendered.contains(" ../caixa-teia"),
10074            "diagnostic must quote the offending caminho: {rendered}",
10075        );
10076        assert!(
10077            rendered.contains("space"),
10078            "diagnostic must name the space footgun: {rendered}",
10079        );
10080    }
10081
10082    #[test]
10083    fn fonte_caminho_absolute_fires_before_control_char() {
10084        // Cascade pin on the sibling leading-byte arm: a leading `/`
10085        // value with embedded control byte (`"/etc/passwd\n"`) routes
10086        // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
10087        // — the host-layout-leak diagnostic is the load-bearing axis,
10088        // the control byte is the secondary observation. Same precedence
10089        // logic on every prior leading-byte arm.
10090        let d = dep_with_fonte(DepSource::Path {
10091            caminho: "/etc/passwd\n".into(),
10092        });
10093        let err = d.validate().unwrap_err();
10094        assert!(
10095            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10096            "got {err:?}",
10097        );
10098    }
10099
10100    #[test]
10101    fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
10102        // The fail-before-pass-after pin for the leading-`-` CLI-arg-
10103        // injection `:caminho` shape sweep. Until this gate landed
10104        // every prior leading-byte arm passed a leading-`-` value
10105        // through: `Path::is_absolute` returns false on `-` (the
10106        // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
10107        // `starts_with('$')` / `starts_with(' ')` all return false,
10108        // and `0x2D` sits outside the control-byte set. The lacre
10109        // embedded the value verbatim and the resolver folded it
10110        // through `Path::join` looking for a literal `./-rf` /
10111        // `./-C` / `./--upload-pack=…` subdirectory; the failure at
10112        // `Path::join` time is non-self-locating but harmless, while
10113        // the failure at every downstream `git -C {caminho}` /
10114        // `terraform -chdir={caminho}` / `find {caminho}` shell-out
10115        // is arbitrary-CLI-arg-injection because none of those
10116        // porcelains carry a `--` argument-list terminator between
10117        // the flag block and the path argument. The new arm moves the
10118        // rejection to `Caixa::from_lisp` boundary time and names
10119        // the offending dep + caminho verbatim.
10120        //
10121        // Sweep spans the canonical CLI-arg-injection shapes matching
10122        // the peer sweep on the sibling `is_git_ref_name` /
10123        // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
10124        // `find -rf` reinterpretation vector), `-C` (the `git -C`
10125        // change-directory-config-injection paste), long-flag
10126        // `--upload-pack=cat /etc/passwd` (the canonical
10127        // arbitrary-command-execution vector on every git porcelain
10128        // entry point), git-config-injection `--config=core.merge=ours`,
10129        // and the degenerate single-byte `-` value.
10130        for caminho in [
10131            "-rf",
10132            "-C",
10133            "--upload-pack=cat /etc/passwd",
10134            "--config=core.merge=ours",
10135            "-",
10136        ] {
10137            let d = dep_with_fonte(DepSource::Path {
10138                caminho: caminho.into(),
10139            });
10140            let err = d.validate().unwrap_err();
10141            let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
10142                panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
10143            };
10144            assert_eq!(nome, "caixa-teia");
10145            assert_eq!(got, caminho);
10146        }
10147    }
10148
10149    #[test]
10150    fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
10151        // The leading-`-` is the canonical CLI-arg-injection footgun
10152        // — a `-` anywhere else in the path (`"../caixa-teia"` — the
10153        // canonical kebab-separator-between-alphanumeric-segments
10154        // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
10155        // — a mid-path segment starting with `-`, still a legitimate
10156        // POSIX filename byte at that non-leading position because the
10157        // subprocess reads the whole `{caminho}` value as one positional
10158        // argument, so only the very first byte of the composite path
10159        // string is at the CLI-arg-injection boundary) is a legitimate
10160        // path with no CLI-flag-reinterpretation semantic at the non-
10161        // leading position of the top-level value. Pinned so the gate
10162        // doesn't widen to a full no-`-`-anywhere sweep that would
10163        // break every legitimate-shape kebab-in-filename path (i.e.
10164        // essentially every sibling-workspace caixa dep).
10165        for caminho in [
10166            "../caixa-teia",
10167            "../caixa-teia/-hidden",
10168            "./my-lib",
10169            "../foo-bar/baz",
10170        ] {
10171            let d = dep_with_fonte(DepSource::Path {
10172                caminho: caminho.into(),
10173            });
10174            d.validate()
10175                .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
10176        }
10177    }
10178
10179    #[test]
10180    fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
10181        // Cascade pin: the leading-whitespace arm structurally precedes
10182        // the leading-hyphen arm. A value like `" -rf"` probes positive
10183        // on both (leading space AND, one byte in, a `-` — though the
10184        // leading-hyphen arm probes only the very first byte so it
10185        // wouldn't fire on this value; the pin instead documents the
10186        // arm order on the more common "leading space then a hyphen"
10187        // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
10188        // The narrower leading-space diagnostic (the paste-from-aligned-
10189        // doc footgun) wins so the author sees the more self-locating
10190        // whitespace arm first. Mirrors the
10191        // `fonte_caminho_var_fires_before_leading_whitespace` cascade
10192        // discipline on the immediate-predecessor arm.
10193        let d = dep_with_fonte(DepSource::Path {
10194            caminho: " -rf".into(),
10195        });
10196        let err = d.validate().unwrap_err();
10197        assert!(
10198            matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
10199            "got {err:?}",
10200        );
10201    }
10202
10203    #[test]
10204    fn fonte_caminho_leading_hyphen_fires_before_control_char() {
10205        // Cascade pin: the leading-hyphen arm structurally precedes
10206        // the control-char arm. A value like `"-rf\n"` probes positive
10207        // on both (starts with `-` AND contains LF), but the narrower
10208        // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
10209        // the author sees the more self-locating CLI-arg-injection arm
10210        // first. Mirrors the
10211        // `fonte_caminho_leading_whitespace_fires_before_control_char`
10212        // cascade discipline on the immediate-predecessor arm.
10213        let d = dep_with_fonte(DepSource::Path {
10214            caminho: "-rf\n".into(),
10215        });
10216        let err = d.validate().unwrap_err();
10217        assert!(
10218            matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
10219            "got {err:?}",
10220        );
10221    }
10222
10223    #[test]
10224    fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
10225        // Diagnostic-shape pin (peer with
10226        // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
10227        // payload assertion on the immediate-predecessor arm): the
10228        // error's Display surfaces both the offending `:nome` and the
10229        // offending `:caminho` verbatim plus the CLI-argument-injection
10230        // vocabulary, so a `feira lint` run can render the diagnostic
10231        // without re-parsing and the author can grep their caixa.lisp
10232        // for `:caminho "<value>"` and fix it in one edit.
10233        let d = dep_with_fonte(DepSource::Path {
10234            caminho: "--upload-pack=cat /etc/passwd".into(),
10235        });
10236        let rendered = d.validate().unwrap_err().to_string();
10237        assert!(
10238            rendered.contains("caixa-teia"),
10239            "diagnostic must name the offending dep: {rendered}",
10240        );
10241        assert!(
10242            rendered.contains("--upload-pack=cat /etc/passwd"),
10243            "diagnostic must quote the offending caminho: {rendered}",
10244        );
10245        assert!(
10246            rendered.contains("CLI-argument-injection"),
10247            "diagnostic must name the CLI-argument-injection vector: {rendered}",
10248        );
10249        assert!(
10250            rendered.contains("`-`"),
10251            "diagnostic must name the offending byte: {rendered}",
10252        );
10253    }
10254
10255    #[test]
10256    fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
10257        // Diagnostic-shape pin (peer with
10258        // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
10259        // payload assertion on the immediate-predecessor arm): the
10260        // error's Display surfaces the offending `:nome`, the
10261        // offending `:caminho` verbatim, and the offending byte in
10262        // hex form (`0x09` for tab) so a `feira lint` run can render
10263        // the diagnostic without re-parsing.
10264        let d = dep_with_fonte(DepSource::Path {
10265            caminho: "../caixa\tteia".into(),
10266        });
10267        let rendered = d.validate().unwrap_err().to_string();
10268        assert!(
10269            rendered.contains("caixa-teia"),
10270            "diagnostic must name the offending dep: {rendered}",
10271        );
10272        assert!(
10273            rendered.contains("../caixa\tteia"),
10274            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10275        );
10276        assert!(
10277            rendered.contains("0x09"),
10278            "diagnostic must name the offending byte in hex: {rendered:?}",
10279        );
10280    }
10281
10282    #[test]
10283    fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
10284        // The fail-before-pass-after pin for the canonical Windows-
10285        // path-separator paste footgun: an author who pastes a path
10286        // from Windows-Explorer's `Copy as path`, PowerShell's
10287        // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
10288        // produces `..\caixa-teia`-shape values that silently passed
10289        // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
10290        // false; `\` is neither a leading-byte sentinel nor a
10291        // control byte). On POSIX resolvers the value rides through
10292        // `Path::join` as a literal directory name and fails at
10293        // resolve time with `No such file or directory`; on Windows
10294        // resolvers the value resolves to the parent's sibling — two
10295        // distinct directories for the byte-identical caixa.lisp.
10296        // The new arm moves the rejection to validate time and names
10297        // the offending dep + caminho verbatim.
10298        let d = dep_with_fonte(DepSource::Path {
10299            caminho: "..\\caixa-teia".into(),
10300        });
10301        let err = d.validate().unwrap_err();
10302        let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
10303            panic!("expected FonteCaminhoBackslash, got {err:?}");
10304        };
10305        assert_eq!(nome, "caixa-teia");
10306        assert_eq!(caminho, "..\\caixa-teia");
10307    }
10308
10309    #[test]
10310    fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
10311        // The Windows drive-letter paste shape (`C:\work\caixa-teia`
10312        // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
10313        // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
10314        // false (POSIX absolute paths start with `/`, drive letters
10315        // are not a POSIX concept), so the b94fd83 absolute arm
10316        // doesn't fire; the value contains `\` bytes that this arm
10317        // now catches with the more self-locating Windows-path-
10318        // separator diagnostic. Pinned separately from the bare
10319        // `..\caixa-teia` shape so a future arm that targets only
10320        // leading-`..\` doesn't regress the drive-letter coverage.
10321        let d = dep_with_fonte(DepSource::Path {
10322            caminho: "C:\\work\\caixa-teia".into(),
10323        });
10324        let err = d.validate().unwrap_err();
10325        assert!(
10326            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10327            "got {err:?}",
10328        );
10329    }
10330
10331    #[test]
10332    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
10333        // The trailing-`\` shape (`..\caixa-teia\` — the canonical
10334        // PowerShell tab-completion-on-a-directory append). Pinned
10335        // separately from the embedded-`\` shape so the gate's
10336        // contract is "any `\` anywhere", not "any `\` not at end".
10337        let d = dep_with_fonte(DepSource::Path {
10338            caminho: "..\\caixa-teia\\".into(),
10339        });
10340        let err = d.validate().unwrap_err();
10341        assert!(
10342            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10343            "got {err:?}",
10344        );
10345    }
10346
10347    #[test]
10348    fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
10349        // The positive-control pin: the gate targets `\` only,
10350        // never `/`. The canonical relative POSIX path
10351        // (`../caixa-teia/foo/bar`) must continue to validate cleanly
10352        // so legitimate nested-directory deps aren't broken. Pinned
10353        // so the gate doesn't accidentally widen to a "no path
10354        // separators at all" sweep.
10355        let d = dep_with_fonte(DepSource::Path {
10356            caminho: "../caixa-teia/foo/bar".into(),
10357        });
10358        d.validate().unwrap();
10359    }
10360
10361    #[test]
10362    fn fonte_caminho_control_char_fires_before_backslash() {
10363        // Cascade pin: the control-char arm structurally precedes the
10364        // backslash arm. A value like `"..\caixa\0teia"` probes
10365        // positive on both (`\` byte + NUL byte), but the control-
10366        // char diagnostic wins so the author sees the more self-
10367        // locating POSIX-syscall-rejected-byte diagnostic first
10368        // (NUL outright breaks `CString::new` at every `std::fs`
10369        // syscall boundary; the `\` divergence is the cross-OS-
10370        // separator axis). Mirrors the
10371        // `fonte_caminho_var_fires_before_control_char` cascade
10372        // discipline on the immediate-predecessor arm.
10373        let d = dep_with_fonte(DepSource::Path {
10374            caminho: "..\\caixa\0teia".into(),
10375        });
10376        let err = d.validate().unwrap_err();
10377        assert!(
10378            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10379            "got {err:?}",
10380        );
10381    }
10382
10383    #[test]
10384    fn fonte_caminho_absolute_fires_before_backslash() {
10385        // Cascade pin on the load-bearing leading-byte arm: a leading
10386        // `/` value with embedded `\` (`/etc/passwd\foo`) routes
10387        // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
10388        // — the host-layout-leak diagnostic is the load-bearing
10389        // axis, the `\` byte is the secondary observation. Same
10390        // precedence logic as every prior leading-byte arm.
10391        let d = dep_with_fonte(DepSource::Path {
10392            caminho: "/etc/passwd\\foo".into(),
10393        });
10394        let err = d.validate().unwrap_err();
10395        assert!(
10396            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10397            "got {err:?}",
10398        );
10399    }
10400
10401    #[test]
10402    fn fonte_caminho_var_fires_before_backslash() {
10403        // Cascade pin on the var-expansion arm: a leading-`$` value
10404        // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
10405        // PowerShell-env-var paste-from-CI-manifest footgun) routes
10406        // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
10407        // The shell-expansion diagnostic is the more self-locating
10408        // axis since both the leading `$` and the embedded `\`
10409        // are Windows-shell artifacts but the `$` is the root-cause
10410        // surface (an author who removes the `$` is likely to leave
10411        // the `\` too).
10412        let d = dep_with_fonte(DepSource::Path {
10413            caminho: "$WORKSPACE\\caixa-teia".into(),
10414        });
10415        let err = d.validate().unwrap_err();
10416        assert!(
10417            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
10418            "got {err:?}",
10419        );
10420    }
10421
10422    #[test]
10423    fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
10424        // Diagnostic-shape pin (peer with the prior
10425        // `fonte_caminho_*_diagnostic_carries_*` payload assertions
10426        // on every preceding arm): the error's Display surfaces the
10427        // offending `:nome` and the offending `:caminho` verbatim
10428        // so a `feira lint` run can render the diagnostic without
10429        // re-parsing.
10430        let d = dep_with_fonte(DepSource::Path {
10431            caminho: "..\\caixa-teia".into(),
10432        });
10433        let rendered = d.validate().unwrap_err().to_string();
10434        assert!(
10435            rendered.contains("caixa-teia"),
10436            "diagnostic must name the offending dep: {rendered}",
10437        );
10438        assert!(
10439            rendered.contains("..\\caixa-teia"),
10440            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10441        );
10442        assert!(
10443            rendered.contains('\\'),
10444            "diagnostic must reference the backslash footgun: {rendered:?}",
10445        );
10446    }
10447
10448    #[test]
10449    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
10450        // The fail-before-pass-after pin for the canonical trailing-`/`
10451        // paste footgun: an author who shell-tab-completes a sibling
10452        // directory (every interactive shell — bash/zsh/fish/nushell —
10453        // appends `/` on tab-completing a directory) produces
10454        // `"../caixa-teia/"`-shape values that silently passed every
10455        // prior arm (the leading byte is `.`, no control bytes, no
10456        // backslash). `Path::join` resolves both shapes to the same
10457        // directory at the resolver, but the lacre embeds the value
10458        // verbatim and the BLAKE3 closures diverge across two
10459        // workstations whose authors differ only in tab-completion
10460        // habits.
10461        let d = dep_with_fonte(DepSource::Path {
10462            caminho: "../caixa-teia/".into(),
10463        });
10464        let err = d.validate().unwrap_err();
10465        let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
10466            panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
10467        };
10468        assert_eq!(nome, "caixa-teia");
10469        assert_eq!(caminho, "../caixa-teia/");
10470    }
10471
10472    #[test]
10473    fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
10474        // The `"./"` shape (the canonical "I meant the caixa.lisp's own
10475        // directory and tab-completed it" footgun). Pinned separately
10476        // from the canonical `"../caixa-teia/"` shape so the gate's
10477        // contract is "any trailing `/`", not "trailing `/` after a leaf
10478        // name".
10479        let d = dep_with_fonte(DepSource::Path {
10480            caminho: "./".into(),
10481        });
10482        let err = d.validate().unwrap_err();
10483        assert!(
10484            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10485            "got {err:?}",
10486        );
10487    }
10488
10489    #[test]
10490    fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
10491        // The `"foo//"` shape (the canonical "I pasted from a CI manifest
10492        // that double-templated `${VAR}/` over an already-`/`-suffixed
10493        // path" footgun). The gate fires on the last byte being `/`
10494        // regardless of how many `/` precede it; the arm contract is
10495        // "the value ends with `/`", structurally.
10496        let d = dep_with_fonte(DepSource::Path {
10497            caminho: "../caixa-teia//".into(),
10498        });
10499        let err = d.validate().unwrap_err();
10500        assert!(
10501            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10502            "got {err:?}",
10503        );
10504    }
10505
10506    #[test]
10507    fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
10508        // The `"../"` shape (the canonical "I want the parent" tab-
10509        // completion footgun on a bare `..` path). Pinned separately so
10510        // the gate doesn't accidentally narrow to "trailing `/` only on
10511        // multi-segment paths".
10512        let d = dep_with_fonte(DepSource::Path {
10513            caminho: "../".into(),
10514        });
10515        let err = d.validate().unwrap_err();
10516        assert!(
10517            matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
10518            "got {err:?}",
10519        );
10520    }
10521
10522    #[test]
10523    fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
10524        // The positive-control pin: the gate targets the trailing byte
10525        // only, never internal `/` separators. The canonical nested
10526        // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
10527        // to validate cleanly so legitimate deeply-nested deps aren't
10528        // broken. Pinned so the gate doesn't accidentally widen to a
10529        // "no `/` separators anywhere" sweep that would defeat the
10530        // entire path-fonte author surface.
10531        let d = dep_with_fonte(DepSource::Path {
10532            caminho: "../caixa-teia/foo/bar".into(),
10533        });
10534        d.validate().unwrap();
10535    }
10536
10537    #[test]
10538    fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
10539        // The positive-control pin on the degenerate single-`.` shape
10540        // (the canonical "the caixa.lisp's own directory" idiom). The
10541        // gate fires on the trailing byte being `/`, not on the path
10542        // being short, so `"."` (one byte, not `/`) must continue to
10543        // validate cleanly.
10544        let d = dep_with_fonte(DepSource::Path {
10545            caminho: ".".into(),
10546        });
10547        d.validate().unwrap();
10548    }
10549
10550    #[test]
10551    fn fonte_caminho_control_char_fires_before_trailing_slash() {
10552        // Cascade pin: the control-char arm structurally precedes the
10553        // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10554        // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10555        // (control bytes are the paste-from-multiline-doc footgun the
10556        // d624c8d arm already closes). Mirrors the
10557        // `fonte_caminho_control_char_fires_before_backslash` cascade
10558        // discipline on the immediate-predecessor arm.
10559        let d = dep_with_fonte(DepSource::Path {
10560            caminho: "../foo\n/".into(),
10561        });
10562        let err = d.validate().unwrap_err();
10563        assert!(
10564            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10565            "got {err:?}",
10566        );
10567    }
10568
10569    #[test]
10570    fn fonte_caminho_backslash_fires_before_trailing_slash() {
10571        // Cascade pin on the backslash arm: a value like `"..\foo/"`
10572        // ends in `/` but the embedded `\` is the load-bearing
10573        // diagnostic (the cross-host-OS-separator divergence vector
10574        // the 3a4e1d7 arm closes). Same precedence logic as the prior
10575        // narrower-diagnostic-first cascade.
10576        let d = dep_with_fonte(DepSource::Path {
10577            caminho: "..\\caixa-teia/".into(),
10578        });
10579        let err = d.validate().unwrap_err();
10580        assert!(
10581            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10582            "got {err:?}",
10583        );
10584    }
10585
10586    #[test]
10587    fn fonte_caminho_absolute_fires_before_trailing_slash() {
10588        // Cascade pin on the load-bearing leading-byte arm: a leading
10589        // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10590        // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10591        // — the host-layout-leak diagnostic is the load-bearing axis,
10592        // the trailing `/` is the secondary observation. Same
10593        // precedence logic as every prior leading-byte arm.
10594        let d = dep_with_fonte(DepSource::Path {
10595            caminho: "/etc/passwd/".into(),
10596        });
10597        let err = d.validate().unwrap_err();
10598        assert!(
10599            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10600            "got {err:?}",
10601        );
10602    }
10603
10604    #[test]
10605    fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10606        // Diagnostic-shape pin (peer with the prior
10607        // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10608        // every preceding arm): the error's Display surfaces the
10609        // offending `:nome` and the offending `:caminho` verbatim so a
10610        // `feira lint` run can render the diagnostic without re-parsing.
10611        let d = dep_with_fonte(DepSource::Path {
10612            caminho: "../caixa-teia/".into(),
10613        });
10614        let rendered = d.validate().unwrap_err().to_string();
10615        assert!(
10616            rendered.contains("caixa-teia"),
10617            "diagnostic must name the offending dep: {rendered}",
10618        );
10619        assert!(
10620            rendered.contains("../caixa-teia/"),
10621            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10622        );
10623        assert!(
10624            rendered.contains("trailing"),
10625            "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10626        );
10627    }
10628
10629    // -- :caminho shell-redirection metacharacter arm -----------------------
10630
10631    #[test]
10632    fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10633        // The fail-before-pass-after pin for the canonical output-redirection
10634        // paste footgun: an author copies a shell pipeline tail
10635        // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10636        // line including the `> build.log` redirect" idiom) and silently
10637        // passed every prior arm (`Path::is_absolute` false on `..`, no
10638        // control bytes, no backslash, doesn't end in `/`). The lacre
10639        // embedded the value verbatim, the resolver folded it through
10640        // `Path::join` looking for a literal `./../caixa-teia>build.log`
10641        // subdirectory, and the failure surfaced at resolve time with a
10642        // non-self-locating `No such file or directory` error. The new arm
10643        // moves the rejection to validate time and names the offending dep
10644        // + caminho + byte verbatim.
10645        let d = dep_with_fonte(DepSource::Path {
10646            caminho: "../caixa-teia>build.log".into(),
10647        });
10648        let err = d.validate().unwrap_err();
10649        let DepError::FonteCaminhoShellRedirection {
10650            nome,
10651            caminho,
10652            byte,
10653        } = err
10654        else {
10655            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10656        };
10657        assert_eq!(nome, "caixa-teia");
10658        assert_eq!(caminho, "../caixa-teia>build.log");
10659        assert_eq!(byte, b'>');
10660    }
10661
10662    #[test]
10663    fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10664        // The symmetric input-redirection paste shape
10665        // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10666        // `command < input.lisp` line from a tatara-lisp REPL log"
10667        // idiom). Pinned separately from the `>` shape so the gate's
10668        // contract is "any `<` or `>` anywhere", not single-byte coverage.
10669        let d = dep_with_fonte(DepSource::Path {
10670            caminho: "../caixa-teia<input.lisp".into(),
10671        });
10672        let err = d.validate().unwrap_err();
10673        let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10674            panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10675        };
10676        assert_eq!(byte, b'<');
10677    }
10678
10679    #[test]
10680    fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10681        // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10682        // "I forgot the source side of the redirect" idiom). Pinned
10683        // separately from the embedded-byte shapes so the gate covers
10684        // every position, not only mid-path.
10685        let d = dep_with_fonte(DepSource::Path {
10686            caminho: ">../caixa-teia".into(),
10687        });
10688        let err = d.validate().unwrap_err();
10689        assert!(
10690            matches!(
10691                err,
10692                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10693            ),
10694            "got {err:?}",
10695        );
10696    }
10697
10698    #[test]
10699    fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10700        // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10701        // the canonical "I copied a `>>` append redirect" idiom). The arm
10702        // fires on the first `>` encountered; pinned so a future arm that
10703        // tries to distinguish `>` from `>>` doesn't break the broader
10704        // contract.
10705        let d = dep_with_fonte(DepSource::Path {
10706            caminho: "../caixa-teia>>build.log".into(),
10707        });
10708        let err = d.validate().unwrap_err();
10709        assert!(
10710            matches!(
10711                err,
10712                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10713            ),
10714            "got {err:?}",
10715        );
10716    }
10717
10718    #[test]
10719    fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10720        // The positive-control pin: the gate targets only `<` / `>`,
10721        // never adjacent printable ASCII or POSIX-valid bytes. The
10722        // canonical relative POSIX path (`"../caixa-teia"`) and a
10723        // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10724        // continue to validate cleanly so the gate doesn't widen to a
10725        // "no printable punctuation anywhere" sweep that would defeat
10726        // the entire path-fonte author surface.
10727        let d = dep_with_fonte(DepSource::Path {
10728            caminho: "../caixa-teia/foo/bar".into(),
10729        });
10730        d.validate().unwrap();
10731    }
10732
10733    #[test]
10734    fn fonte_caminho_backslash_fires_before_shell_redirection() {
10735        // Cascade pin on the immediate-predecessor arm: a value carrying
10736        // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10737        // canonical "I pasted a Windows-shell command with output
10738        // redirect" footgun) routes through `FonteCaminhoBackslash` not
10739        // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10740        // divergence is the load-bearing axis (an author who removes
10741        // the `\` is the root-cause edit; the `>` falls away in the
10742        // same edit since it's downstream of the Windows-shell
10743        // convention).
10744        let d = dep_with_fonte(DepSource::Path {
10745            caminho: "..\\caixa-teia>build.log".into(),
10746        });
10747        let err = d.validate().unwrap_err();
10748        assert!(
10749            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10750            "got {err:?}",
10751        );
10752    }
10753
10754    #[test]
10755    fn fonte_caminho_control_char_fires_before_shell_redirection() {
10756        // Cascade pin on the embedded-control-byte arm: a value carrying
10757        // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10758        // canonical paste-from-multiline-doc footgun where a newline
10759        // landed mid-caminho) routes through `FonteCaminhoControlChar`
10760        // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10761        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10762        // load-bearing axis on every value that probes positive for
10763        // both — mirrors the cascade discipline on every prior arm.
10764        let d = dep_with_fonte(DepSource::Path {
10765            caminho: "../foo\n>bar".into(),
10766        });
10767        let err = d.validate().unwrap_err();
10768        assert!(
10769            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10770            "got {err:?}",
10771        );
10772    }
10773
10774    #[test]
10775    fn fonte_caminho_absolute_fires_before_shell_redirection() {
10776        // Cascade pin on the load-bearing leading-byte arm: a leading
10777        // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10778        // routes through `FonteCaminhoAbsolute` not
10779        // `FonteCaminhoShellRedirection` — the host-layout-leak
10780        // diagnostic is the load-bearing axis, the `>` byte is the
10781        // secondary observation. Same precedence logic as every prior
10782        // leading-byte arm.
10783        let d = dep_with_fonte(DepSource::Path {
10784            caminho: "/etc/passwd>out".into(),
10785        });
10786        let err = d.validate().unwrap_err();
10787        assert!(
10788            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10789            "got {err:?}",
10790        );
10791    }
10792
10793    #[test]
10794    fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10795        // Cascade pin on the immediate-successor arm: a value carrying
10796        // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10797        // canonical "I tab-completed a path that already had a
10798        // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10799        // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10800        // the more semantic-locating axis (an author who removes the
10801        // `<` / `>` typically also drops the trailing separator since
10802        // both are paste-from-shell artifacts).
10803        let d = dep_with_fonte(DepSource::Path {
10804            caminho: "../foo></".into(),
10805        });
10806        let err = d.validate().unwrap_err();
10807        assert!(
10808            matches!(
10809                err,
10810                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10811            ),
10812            "got {err:?}",
10813        );
10814    }
10815
10816    #[test]
10817    fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10818        // Diagnostic-shape pin (peer with
10819        // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10820        // payload assertion on the closest peer arm that also carries a
10821        // `byte` field): the error's Display surfaces the offending
10822        // `:nome`, the offending `:caminho` verbatim, and the offending
10823        // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10824        // run can render the diagnostic without re-parsing.
10825        let d = dep_with_fonte(DepSource::Path {
10826            caminho: "../caixa-teia>build.log".into(),
10827        });
10828        let rendered = d.validate().unwrap_err().to_string();
10829        assert!(
10830            rendered.contains("caixa-teia"),
10831            "diagnostic must name the offending dep: {rendered}",
10832        );
10833        assert!(
10834            rendered.contains("../caixa-teia>build.log"),
10835            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10836        );
10837        assert!(
10838            rendered.contains("0x3e"),
10839            "diagnostic must name the offending byte in hex: {rendered:?}",
10840        );
10841        assert!(
10842            rendered.contains("redirection"),
10843            "diagnostic must name the shell-redirection footgun: {rendered:?}",
10844        );
10845    }
10846
10847    // -- :caminho shell-pipe metacharacter arm ----------------------------
10848
10849    #[test]
10850    fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10851        // The fail-before-pass-after pin for the canonical shell-pipe
10852        // paste footgun: an author copies a shell-history line
10853        // (`"../caixa-teia | grep foo"` — the canonical "I selected
10854        // the whole `ls dir | grep` line out of zsh history") and
10855        // silently passed every prior arm (`Path::is_absolute` false
10856        // on `..`, no control bytes, no backslash, no `<` / `>`,
10857        // doesn't end in `/`). The lacre embedded the value verbatim,
10858        // the resolver folded it through `Path::join` looking for a
10859        // literal `./../caixa-teia | grep foo` subdirectory, and the
10860        // failure surfaced at resolve time with a non-self-locating
10861        // `No such file or directory` error. The new arm moves the
10862        // rejection to validate time and names the offending dep +
10863        // caminho verbatim.
10864        let d = dep_with_fonte(DepSource::Path {
10865            caminho: "../caixa-teia | grep foo".into(),
10866        });
10867        let err = d.validate().unwrap_err();
10868        let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10869            panic!("expected FonteCaminhoShellPipe, got {err:?}");
10870        };
10871        assert_eq!(nome, "caixa-teia");
10872        assert_eq!(caminho, "../caixa-teia | grep foo");
10873    }
10874
10875    #[test]
10876    fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10877        // Leading-position `|` shape (`"|../caixa-teia"` — the
10878        // degenerate "I forgot the source side of the pipe" idiom).
10879        // Pinned separately from the embedded-byte shape so the gate
10880        // covers every position, not only mid-path.
10881        let d = dep_with_fonte(DepSource::Path {
10882            caminho: "|../caixa-teia".into(),
10883        });
10884        let err = d.validate().unwrap_err();
10885        assert!(
10886            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10887            "got {err:?}",
10888        );
10889    }
10890
10891    #[test]
10892    fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10893        // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10894        // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10895        // idiom). The arm fires on the first `|` encountered; pinned
10896        // so a future arm that tries to distinguish `|` from `||`
10897        // doesn't break the broader contract.
10898        let d = dep_with_fonte(DepSource::Path {
10899            caminho: "../caixa-teia||fallback".into(),
10900        });
10901        let err = d.validate().unwrap_err();
10902        assert!(
10903            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10904            "got {err:?}",
10905        );
10906    }
10907
10908    #[test]
10909    fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10910        // The positive-control pin: the gate targets only `|`, never
10911        // adjacent printable ASCII or POSIX-valid bytes. The canonical
10912        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10913        // pathed variant with adjacent printable punctuation
10914        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10915        // cleanly so the gate doesn't widen to a "no printable
10916        // punctuation anywhere" sweep that would defeat the entire
10917        // path-fonte author surface.
10918        let d = dep_with_fonte(DepSource::Path {
10919            caminho: "../caixa-teia/sub-dir.v2".into(),
10920        });
10921        d.validate().unwrap();
10922    }
10923
10924    #[test]
10925    fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10926        // Cascade pin on the immediate-predecessor arm: a value carrying
10927        // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10928        // canonical "I pasted a `cmd < input | tee` pipeline tail"
10929        // footgun) routes through `FonteCaminhoShellRedirection` not
10930        // `FonteCaminhoShellPipe`. The input/output redirection
10931        // metachar carries the more self-locating `byte: u8` payload
10932        // (it names which of `<` or `>` triggered), so the prior arm
10933        // wins on every probe-as-both value — same cascade discipline
10934        // every prior `:caminho` arm establishes.
10935        let d = dep_with_fonte(DepSource::Path {
10936            caminho: "../caixa-teia<input|tee".into(),
10937        });
10938        let err = d.validate().unwrap_err();
10939        assert!(
10940            matches!(
10941                err,
10942                DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10943            ),
10944            "got {err:?}",
10945        );
10946    }
10947
10948    #[test]
10949    fn fonte_caminho_backslash_fires_before_shell_pipe() {
10950        // Cascade pin on the upstream backslash arm: a value carrying
10951        // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10952        // "I pasted a Windows-shell command with pipe to tee"
10953        // footgun) routes through `FonteCaminhoBackslash` not
10954        // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10955        // divergence is the load-bearing axis on every probe-as-both
10956        // value (an author who removes the `\` is the root-cause edit;
10957        // the `|` falls away in the same edit since it's downstream of
10958        // the Windows-shell convention).
10959        let d = dep_with_fonte(DepSource::Path {
10960            caminho: "..\\caixa-teia|tee".into(),
10961        });
10962        let err = d.validate().unwrap_err();
10963        assert!(
10964            matches!(err, DepError::FonteCaminhoBackslash { .. }),
10965            "got {err:?}",
10966        );
10967    }
10968
10969    #[test]
10970    fn fonte_caminho_control_char_fires_before_shell_pipe() {
10971        // Cascade pin on the embedded-control-byte arm: a value
10972        // carrying both a control byte and `|` (`"../foo\n|bar"` —
10973        // the canonical paste-from-multiline-doc footgun where a
10974        // newline landed mid-caminho) routes through
10975        // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10976        // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10977        // diagnostic is the load-bearing axis on every value that
10978        // probes positive for both — mirrors the cascade discipline
10979        // on every prior arm.
10980        let d = dep_with_fonte(DepSource::Path {
10981            caminho: "../foo\n|bar".into(),
10982        });
10983        let err = d.validate().unwrap_err();
10984        assert!(
10985            matches!(err, DepError::FonteCaminhoControlChar { .. }),
10986            "got {err:?}",
10987        );
10988    }
10989
10990    #[test]
10991    fn fonte_caminho_absolute_fires_before_shell_pipe() {
10992        // Cascade pin on the load-bearing leading-byte arm: a leading
10993        // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10994        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10995        // — the host-layout-leak diagnostic is the load-bearing axis,
10996        // the `|` byte is the secondary observation. Same precedence
10997        // logic as every prior leading-byte arm.
10998        let d = dep_with_fonte(DepSource::Path {
10999            caminho: "/etc/passwd|tee".into(),
11000        });
11001        let err = d.validate().unwrap_err();
11002        assert!(
11003            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11004            "got {err:?}",
11005        );
11006    }
11007
11008    #[test]
11009    fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
11010        // Cascade pin on the immediate-successor arm: a value carrying
11011        // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
11012        // "I tab-completed a path that already had a pipeline tail"
11013        // footgun) routes through `FonteCaminhoShellPipe` not
11014        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11015        // the more semantic-locating axis (an author who removes the
11016        // `|` typically also drops the trailing separator since both
11017        // are paste-from-shell artifacts).
11018        let d = dep_with_fonte(DepSource::Path {
11019            caminho: "../foo|tee/".into(),
11020        });
11021        let err = d.validate().unwrap_err();
11022        assert!(
11023            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11024            "got {err:?}",
11025        );
11026    }
11027
11028    #[test]
11029    fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
11030        // Diagnostic-shape pin (peer with
11031        // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
11032        // on the closest single-byte peer arm): the error's Display
11033        // surfaces the offending `:nome` and the offending `:caminho`
11034        // verbatim, and names the shell-pipe footgun explicitly so a
11035        // `feira lint` run can render the diagnostic without
11036        // re-parsing.
11037        let d = dep_with_fonte(DepSource::Path {
11038            caminho: "../caixa-teia | grep foo".into(),
11039        });
11040        let rendered = d.validate().unwrap_err().to_string();
11041        assert!(
11042            rendered.contains("caixa-teia"),
11043            "diagnostic must name the offending dep: {rendered}",
11044        );
11045        assert!(
11046            rendered.contains("../caixa-teia | grep foo"),
11047            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11048        );
11049        assert!(
11050            rendered.contains('|'),
11051            "diagnostic must reference the pipe footgun: {rendered:?}",
11052        );
11053        assert!(
11054            rendered.contains("pipe"),
11055            "diagnostic must name the shell-pipe footgun: {rendered:?}",
11056        );
11057    }
11058
11059    // -- :caminho shell-command-separator metacharacter arm ---------------
11060
11061    #[test]
11062    fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
11063        // The fail-before-pass-after pin for the canonical shell-command-
11064        // separator paste footgun: an author copies a shell one-liner
11065        // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
11066        // whole `cd path; do-thing` chain out of a shell-history block")
11067        // and silently passed every prior arm (`Path::is_absolute` false
11068        // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
11069        // doesn't end in `/`). The lacre embedded the value verbatim, the
11070        // resolver folded it through `Path::join` looking for a literal
11071        // `./../caixa-teia; rm -rf build` subdirectory, and the failure
11072        // surfaced at resolve time with a non-self-locating `No such file
11073        // or directory` error. The new arm moves the rejection to validate
11074        // time and names the offending dep + caminho verbatim.
11075        let d = dep_with_fonte(DepSource::Path {
11076            caminho: "../caixa-teia; rm -rf build".into(),
11077        });
11078        let err = d.validate().unwrap_err();
11079        let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
11080            panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
11081        };
11082        assert_eq!(nome, "caixa-teia");
11083        assert_eq!(caminho, "../caixa-teia; rm -rf build");
11084    }
11085
11086    #[test]
11087    fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
11088        // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
11089        // "I forgot the prior command side of the separator" idiom).
11090        // Pinned separately from the embedded-byte shape so the gate
11091        // covers every position, not only mid-path.
11092        let d = dep_with_fonte(DepSource::Path {
11093            caminho: ";../caixa-teia".into(),
11094        });
11095        let err = d.validate().unwrap_err();
11096        assert!(
11097            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11098            "got {err:?}",
11099        );
11100    }
11101
11102    #[test]
11103    fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
11104        // The POSIX `case` arm `;;` terminator shape
11105        // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
11106        // arm tail" idiom). The arm fires on the first `;` encountered;
11107        // pinned so a future arm that tries to distinguish `;` from `;;`
11108        // doesn't break the broader contract.
11109        let d = dep_with_fonte(DepSource::Path {
11110            caminho: "../caixa-teia;;next".into(),
11111        });
11112        let err = d.validate().unwrap_err();
11113        assert!(
11114            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11115            "got {err:?}",
11116        );
11117    }
11118
11119    #[test]
11120    fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
11121        // The positive-control pin: the gate targets only `;`, never
11122        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11123        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11124        // pathed variant with adjacent printable punctuation
11125        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11126        // cleanly so the gate doesn't widen to a "no printable
11127        // punctuation anywhere" sweep that would defeat the entire
11128        // path-fonte author surface.
11129        let d = dep_with_fonte(DepSource::Path {
11130            caminho: "../caixa-teia/sub-dir.v2".into(),
11131        });
11132        d.validate().unwrap();
11133    }
11134
11135    #[test]
11136    fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
11137        // Cascade pin on the immediate-predecessor arm: a value carrying
11138        // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
11139        // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
11140        // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
11141        // pipeline-tail paste is the load-bearing root-cause edit on
11142        // every probe-as-both value (an author who removes the `|`
11143        // typically also drops the trailing `; cleanup` since both are
11144        // the same paste-from-shell-history artifact) — same cascade
11145        // discipline every prior `:caminho` arm establishes.
11146        let d = dep_with_fonte(DepSource::Path {
11147            caminho: "../caixa-teia | tee; rm".into(),
11148        });
11149        let err = d.validate().unwrap_err();
11150        assert!(
11151            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11152            "got {err:?}",
11153        );
11154    }
11155
11156    #[test]
11157    fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
11158        // Cascade pin on the upstream shell-redirection arm: a value
11159        // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
11160        // the canonical "I pasted a `cmd > log; cleanup` chain"
11161        // footgun) routes through `FonteCaminhoShellRedirection` not
11162        // `FonteCaminhoShellSemicolon`. The input/output redirection
11163        // metachar carries the more self-locating `byte: u8` payload
11164        // (it names which of `<` or `>` triggered), so the prior arm
11165        // wins on every probe-as-both value.
11166        let d = dep_with_fonte(DepSource::Path {
11167            caminho: "../caixa-teia>log; rm".into(),
11168        });
11169        let err = d.validate().unwrap_err();
11170        assert!(
11171            matches!(
11172                err,
11173                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11174            ),
11175            "got {err:?}",
11176        );
11177    }
11178
11179    #[test]
11180    fn fonte_caminho_backslash_fires_before_shell_semicolon() {
11181        // Cascade pin on the upstream backslash arm: a value carrying
11182        // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
11183        // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
11184        // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
11185        // The cross-host-OS-separator divergence is the load-bearing axis
11186        // on every probe-as-both value (an author who removes the `\` is
11187        // the root-cause edit; the `;` falls away in the same edit since
11188        // it's downstream of the Windows-shell convention).
11189        let d = dep_with_fonte(DepSource::Path {
11190            caminho: "..\\caixa-teia;rm".into(),
11191        });
11192        let err = d.validate().unwrap_err();
11193        assert!(
11194            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11195            "got {err:?}",
11196        );
11197    }
11198
11199    #[test]
11200    fn fonte_caminho_control_char_fires_before_shell_semicolon() {
11201        // Cascade pin on the embedded-control-byte arm: a value carrying
11202        // both a control byte and `;` (`"../foo\n;bar"` — the canonical
11203        // paste-from-multiline-doc footgun where a newline landed mid-
11204        // caminho) routes through `FonteCaminhoControlChar` not
11205        // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
11206        // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
11207        // on every value that probes positive for both — mirrors the
11208        // cascade discipline on every prior arm.
11209        let d = dep_with_fonte(DepSource::Path {
11210            caminho: "../foo\n;bar".into(),
11211        });
11212        let err = d.validate().unwrap_err();
11213        assert!(
11214            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11215            "got {err:?}",
11216        );
11217    }
11218
11219    #[test]
11220    fn fonte_caminho_absolute_fires_before_shell_semicolon() {
11221        // Cascade pin on the load-bearing leading-byte arm: a leading
11222        // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
11223        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
11224        // — the host-layout-leak diagnostic is the load-bearing axis,
11225        // the `;` byte is the secondary observation. Same precedence
11226        // logic as every prior leading-byte arm.
11227        let d = dep_with_fonte(DepSource::Path {
11228            caminho: "/etc/passwd;rm".into(),
11229        });
11230        let err = d.validate().unwrap_err();
11231        assert!(
11232            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11233            "got {err:?}",
11234        );
11235    }
11236
11237    #[test]
11238    fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
11239        // Cascade pin on the immediate-successor arm: a value carrying
11240        // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
11241        // "I tab-completed a path that already had a `; cleanup` tail"
11242        // footgun) routes through `FonteCaminhoShellSemicolon` not
11243        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11244        // the more semantic-locating axis (an author who removes the
11245        // `;` typically also drops the trailing separator since both
11246        // are paste-from-shell artifacts).
11247        let d = dep_with_fonte(DepSource::Path {
11248            caminho: "../foo;rm/".into(),
11249        });
11250        let err = d.validate().unwrap_err();
11251        assert!(
11252            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11253            "got {err:?}",
11254        );
11255    }
11256
11257    #[test]
11258    fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
11259        // Diagnostic-shape pin (peer with
11260        // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
11261        // on the closest single-byte peer arm): the error's Display
11262        // surfaces the offending `:nome` and the offending `:caminho`
11263        // verbatim, and names the shell-command-separator footgun
11264        // explicitly so a `feira lint` run can render the diagnostic
11265        // without re-parsing.
11266        let d = dep_with_fonte(DepSource::Path {
11267            caminho: "../caixa-teia; rm -rf build".into(),
11268        });
11269        let rendered = d.validate().unwrap_err().to_string();
11270        assert!(
11271            rendered.contains("caixa-teia"),
11272            "diagnostic must name the offending dep: {rendered}",
11273        );
11274        assert!(
11275            rendered.contains("../caixa-teia; rm -rf build"),
11276            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11277        );
11278        assert!(
11279            rendered.contains(';'),
11280            "diagnostic must reference the semicolon footgun: {rendered:?}",
11281        );
11282        assert!(
11283            rendered.contains("command-separator"),
11284            "diagnostic must name the shell-command-separator footgun: {rendered:?}",
11285        );
11286    }
11287
11288    #[test]
11289    fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
11290        // The fail-before-pass-after pin for the canonical shell-
11291        // background-task paste footgun: an author copies a shell one-
11292        // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
11293        // the whole `cd path & sleep 1` background-launch out of a
11294        // shell-history block") and silently passed every prior arm
11295        // (`Path::is_absolute` false on `..`, no control bytes, no
11296        // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
11297        // The lacre embedded the value verbatim, the resolver folded it
11298        // through `Path::join` looking for a literal `./../caixa-teia &
11299        // sleep 1` subdirectory, and the failure surfaced at resolve
11300        // time with a non-self-locating `No such file or directory`
11301        // error. The new arm moves the rejection to validate time and
11302        // names the offending dep + caminho verbatim.
11303        let d = dep_with_fonte(DepSource::Path {
11304            caminho: "../caixa-teia & sleep 1".into(),
11305        });
11306        let err = d.validate().unwrap_err();
11307        let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
11308            panic!("expected FonteCaminhoShellBackground, got {err:?}");
11309        };
11310        assert_eq!(nome, "caixa-teia");
11311        assert_eq!(caminho, "../caixa-teia & sleep 1");
11312    }
11313
11314    #[test]
11315    fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
11316        // Leading-position `&` shape (`"&../caixa-teia"` — the
11317        // degenerate "I forgot the prior command side of the
11318        // background terminator" idiom). Pinned separately from the
11319        // embedded-byte shape so the gate covers every position, not
11320        // only mid-path.
11321        let d = dep_with_fonte(DepSource::Path {
11322            caminho: "&../caixa-teia".into(),
11323        });
11324        let err = d.validate().unwrap_err();
11325        assert!(
11326            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11327            "got {err:?}",
11328        );
11329    }
11330
11331    #[test]
11332    fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
11333        // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
11334        // canonical "I copied a `cd path && make` build chain" idiom
11335        // every Makefile / shell-script wraps). The arm fires on the
11336        // first `&` encountered; pinned so a future arm that tries to
11337        // distinguish `&` from `&&` doesn't break the broader contract.
11338        let d = dep_with_fonte(DepSource::Path {
11339            caminho: "../caixa-teia && make".into(),
11340        });
11341        let err = d.validate().unwrap_err();
11342        assert!(
11343            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11344            "got {err:?}",
11345        );
11346    }
11347
11348    #[test]
11349    fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
11350        // The positive-control pin: the gate targets only `&`, never
11351        // adjacent printable ASCII or POSIX-valid bytes. The canonical
11352        // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
11353        // pathed variant with adjacent printable punctuation
11354        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11355        // cleanly so the gate doesn't widen to a "no printable
11356        // punctuation anywhere" sweep that would defeat the entire
11357        // path-fonte author surface.
11358        let d = dep_with_fonte(DepSource::Path {
11359            caminho: "../caixa-teia/sub-dir.v2".into(),
11360        });
11361        d.validate().unwrap();
11362    }
11363
11364    #[test]
11365    fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
11366        // Cascade pin on the immediate-predecessor arm: a value carrying
11367        // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
11368        // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
11369        // routes through `FonteCaminhoShellSemicolon` not
11370        // `FonteCaminhoShellBackground`. The sequential-command-
11371        // separator paste is the more common shell-history paste idiom
11372        // on every probe-as-both value (an author who removes the `;`
11373        // typically also drops the trailing `& sleep` since both are
11374        // paste-from-shell-history artifacts) — same cascade discipline
11375        // every prior `:caminho` arm establishes.
11376        let d = dep_with_fonte(DepSource::Path {
11377            caminho: "../caixa-teia; rm & sleep".into(),
11378        });
11379        let err = d.validate().unwrap_err();
11380        assert!(
11381            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11382            "got {err:?}",
11383        );
11384    }
11385
11386    #[test]
11387    fn fonte_caminho_shell_pipe_fires_before_shell_background() {
11388        // Cascade pin on the upstream shell-pipe arm: a value carrying
11389        // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
11390        // canonical "I pasted a `cmd | tee & sleep` background-pipeline
11391        // chain" footgun) routes through `FonteCaminhoShellPipe` not
11392        // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
11393        // load-bearing root-cause edit on every probe-as-both value.
11394        let d = dep_with_fonte(DepSource::Path {
11395            caminho: "../caixa-teia | tee & sleep".into(),
11396        });
11397        let err = d.validate().unwrap_err();
11398        assert!(
11399            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11400            "got {err:?}",
11401        );
11402    }
11403
11404    #[test]
11405    fn fonte_caminho_shell_redirection_fires_before_shell_background() {
11406        // Cascade pin on the upstream shell-redirection arm: a value
11407        // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
11408        // the canonical "I pasted a `cmd > log & sleep` background-
11409        // redirect chain" footgun) routes through
11410        // `FonteCaminhoShellRedirection` not
11411        // `FonteCaminhoShellBackground`. The input/output redirection
11412        // metachar carries the more self-locating `byte: u8` payload
11413        // (it names which of `<` or `>` triggered), so the prior arm
11414        // wins on every probe-as-both value.
11415        let d = dep_with_fonte(DepSource::Path {
11416            caminho: "../caixa-teia>log & sleep".into(),
11417        });
11418        let err = d.validate().unwrap_err();
11419        assert!(
11420            matches!(
11421                err,
11422                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11423            ),
11424            "got {err:?}",
11425        );
11426    }
11427
11428    #[test]
11429    fn fonte_caminho_backslash_fires_before_shell_background() {
11430        // Cascade pin on the upstream backslash arm: a value carrying
11431        // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
11432        // "I pasted a Windows-shell `cd ..\path & sleep` background-
11433        // launch chain") routes through `FonteCaminhoBackslash` not
11434        // `FonteCaminhoShellBackground`. The cross-host-OS-separator
11435        // divergence is the load-bearing axis on every probe-as-both
11436        // value (an author who removes the `\` is the root-cause edit;
11437        // the `&` falls away in the same edit since it's downstream of
11438        // the Windows-shell convention).
11439        let d = dep_with_fonte(DepSource::Path {
11440            caminho: "..\\caixa-teia & sleep".into(),
11441        });
11442        let err = d.validate().unwrap_err();
11443        assert!(
11444            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11445            "got {err:?}",
11446        );
11447    }
11448
11449    #[test]
11450    fn fonte_caminho_control_char_fires_before_shell_background() {
11451        // Cascade pin on the embedded-control-byte arm: a value
11452        // carrying both a control byte and `&` (`"../foo\n&sleep"` —
11453        // the canonical paste-from-multiline-doc footgun where a
11454        // newline landed mid-caminho) routes through
11455        // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
11456        // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
11457        // diagnostic is the load-bearing axis on every value that
11458        // probes positive for both — mirrors the cascade discipline on
11459        // every prior arm.
11460        let d = dep_with_fonte(DepSource::Path {
11461            caminho: "../foo\n&sleep".into(),
11462        });
11463        let err = d.validate().unwrap_err();
11464        assert!(
11465            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11466            "got {err:?}",
11467        );
11468    }
11469
11470    #[test]
11471    fn fonte_caminho_absolute_fires_before_shell_background() {
11472        // Cascade pin on the load-bearing leading-byte arm: a leading
11473        // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
11474        // through `FonteCaminhoAbsolute` not
11475        // `FonteCaminhoShellBackground` — the host-layout-leak
11476        // diagnostic is the load-bearing axis, the `&` byte is the
11477        // secondary observation. Same precedence logic as every prior
11478        // leading-byte arm.
11479        let d = dep_with_fonte(DepSource::Path {
11480            caminho: "/etc/passwd & sleep".into(),
11481        });
11482        let err = d.validate().unwrap_err();
11483        assert!(
11484            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11485            "got {err:?}",
11486        );
11487    }
11488
11489    #[test]
11490    fn fonte_caminho_shell_background_fires_before_trailing_slash() {
11491        // Cascade pin on the immediate-successor arm: a value carrying
11492        // both `&` and a trailing `/` (`"../foo&sleep/"` — the
11493        // canonical "I tab-completed a path that already had a `&
11494        // sleep` background-launch tail" footgun) routes through
11495        // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
11496        // The embedded shell-metachar is the more semantic-locating
11497        // axis (an author who removes the `&` typically also drops
11498        // the trailing separator since both are paste-from-shell
11499        // artifacts).
11500        let d = dep_with_fonte(DepSource::Path {
11501            caminho: "../foo&sleep/".into(),
11502        });
11503        let err = d.validate().unwrap_err();
11504        assert!(
11505            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11506            "got {err:?}",
11507        );
11508    }
11509
11510    #[test]
11511    fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
11512        // Diagnostic-shape pin (peer with
11513        // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
11514        // on the closest single-byte peer arm): the error's Display
11515        // surfaces the offending `:nome` and the offending `:caminho`
11516        // verbatim, and names the shell-background / logical-AND
11517        // footgun explicitly so a `feira lint` run can render the
11518        // diagnostic without re-parsing.
11519        let d = dep_with_fonte(DepSource::Path {
11520            caminho: "../caixa-teia & sleep 1".into(),
11521        });
11522        let rendered = d.validate().unwrap_err().to_string();
11523        assert!(
11524            rendered.contains("caixa-teia"),
11525            "diagnostic must name the offending dep: {rendered}",
11526        );
11527        assert!(
11528            rendered.contains("../caixa-teia & sleep 1"),
11529            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11530        );
11531        assert!(
11532            rendered.contains('&'),
11533            "diagnostic must reference the ampersand footgun: {rendered:?}",
11534        );
11535        assert!(
11536            rendered.contains("background") || rendered.contains("list-AND"),
11537            "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
11538        );
11539    }
11540
11541    #[test]
11542    fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11543        // The fail-before-pass-after pin for the canonical shell-
11544        // command-substitution paste footgun: an author copies a
11545        // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11546        // — the canonical "I pasted a path that included a `pwd`
11547        // / `whoami` / `date` legacy command-substitution expansion
11548        // out of a shell-history block") and silently passed every
11549        // prior arm (`Path::is_absolute` false on `..`, no control
11550        // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11551        // end in `/`). The lacre embedded the value verbatim, the
11552        // resolver folded it through `Path::join` looking for a
11553        // literal `./../caixa-teia/`whoami`` subdirectory, and the
11554        // failure surfaced at resolve time with a non-self-locating
11555        // `No such file or directory` error. The new arm moves the
11556        // rejection to validate time and names the offending dep +
11557        // caminho verbatim.
11558        let d = dep_with_fonte(DepSource::Path {
11559            caminho: "../caixa-teia/`whoami`".into(),
11560        });
11561        let err = d.validate().unwrap_err();
11562        let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11563            panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11564        };
11565        assert_eq!(nome, "caixa-teia");
11566        assert_eq!(caminho, "../caixa-teia/`whoami`");
11567    }
11568
11569    #[test]
11570    fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11571        // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11572        // the canonical `<backtick>pwd<backtick>/path` working-
11573        // directory expansion shape every shell-side path-composition
11574        // idiom carries). Pinned separately from the embedded-byte
11575        // shape so the gate covers every position, not only mid-path.
11576        let d = dep_with_fonte(DepSource::Path {
11577            caminho: "`pwd`/caixa-teia".into(),
11578        });
11579        let err = d.validate().unwrap_err();
11580        assert!(
11581            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11582            "got {err:?}",
11583        );
11584    }
11585
11586    #[test]
11587    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11588        // Trailing-position backtick shape (`"../caixa-teia`"` — the
11589        // degenerate "I selected an unbalanced backtick out of a
11590        // shell-history block" idiom that probes for the cascade's
11591        // last-byte handling). The trailing-`/` arm fires only on
11592        // last-byte `/`; an unbalanced trailing backtick must route
11593        // through this arm regardless of position.
11594        let d = dep_with_fonte(DepSource::Path {
11595            caminho: "../caixa-teia`".into(),
11596        });
11597        let err = d.validate().unwrap_err();
11598        assert!(
11599            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11600            "got {err:?}",
11601        );
11602    }
11603
11604    #[test]
11605    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11606        // The canonical balanced-pair shape (``"../<backtick>cat
11607        // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11608        // command-injection paste idiom every shell-side hardening
11609        // guide enumerates first). The arm fires on the first
11610        // backtick encountered; pinned so a future arm that tries to
11611        // distinguish the opening from the closing byte doesn't break
11612        // the broader contract.
11613        let d = dep_with_fonte(DepSource::Path {
11614            caminho: "../`cat /etc/passwd`".into(),
11615        });
11616        let err = d.validate().unwrap_err();
11617        assert!(
11618            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11619            "got {err:?}",
11620        );
11621    }
11622
11623    #[test]
11624    fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11625        // The positive-control pin: the gate targets only the
11626        // backtick byte, never adjacent printable ASCII or POSIX-
11627        // valid bytes. The canonical relative POSIX path
11628        // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11629        // adjacent printable punctuation
11630        // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11631        // cleanly so the gate doesn't widen to a "no printable
11632        // punctuation anywhere" sweep that would defeat the entire
11633        // path-fonte author surface.
11634        let d = dep_with_fonte(DepSource::Path {
11635            caminho: "../caixa-teia/sub-dir.v2".into(),
11636        });
11637        d.validate().unwrap();
11638    }
11639
11640    #[test]
11641    fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11642        // Cascade pin on the immediate-predecessor arm: a value
11643        // carrying both `&` and a backtick (``"../caixa-teia &
11644        // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11645        // `cmd & <backtick>sleep N<backtick>` background-launch +
11646        // command-substitution chain" footgun) routes through
11647        // `FonteCaminhoShellBackground` not
11648        // `FonteCaminhoShellCommandSubstitution`. The background-
11649        // launch tail is the more common shell-history paste idiom
11650        // on every probe-as-both value — same cascade discipline
11651        // every prior `:caminho` arm establishes.
11652        let d = dep_with_fonte(DepSource::Path {
11653            caminho: "../caixa-teia & `sleep 1`".into(),
11654        });
11655        let err = d.validate().unwrap_err();
11656        assert!(
11657            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11658            "got {err:?}",
11659        );
11660    }
11661
11662    #[test]
11663    fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11664        // Cascade pin on the upstream shell-semicolon arm: a value
11665        // carrying both `;` and a backtick (``"../caixa-teia;
11666        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11667        // `cmd; <backtick>follow-up<backtick>` sequential-chain
11668        // footgun) routes through `FonteCaminhoShellSemicolon` not
11669        // `FonteCaminhoShellCommandSubstitution`. The sequential-
11670        // command-separator paste is the load-bearing root-cause
11671        // edit on every probe-as-both value.
11672        let d = dep_with_fonte(DepSource::Path {
11673            caminho: "../caixa-teia; `whoami`".into(),
11674        });
11675        let err = d.validate().unwrap_err();
11676        assert!(
11677            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11678            "got {err:?}",
11679        );
11680    }
11681
11682    #[test]
11683    fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11684        // Cascade pin on the upstream shell-pipe arm: a value
11685        // carrying both `|` and a backtick (``"../caixa-teia |
11686        // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11687        // command-substitution paste idiom) routes through
11688        // `FonteCaminhoShellPipe` not
11689        // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11690        // paste is the load-bearing root-cause edit on every
11691        // probe-as-both value.
11692        let d = dep_with_fonte(DepSource::Path {
11693            caminho: "../caixa-teia | `tee log`".into(),
11694        });
11695        let err = d.validate().unwrap_err();
11696        assert!(
11697            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11698            "got {err:?}",
11699        );
11700    }
11701
11702    #[test]
11703    fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11704        // Cascade pin on the upstream shell-redirection arm: a value
11705        // carrying both `>` and a backtick (``"../caixa-teia>log
11706        // <backtick>date<backtick>"`` — the canonical "I pasted a
11707        // `cmd > log <backtick>date<backtick>` redirect-plus-
11708        // substitution chain" footgun) routes through
11709        // `FonteCaminhoShellRedirection` not
11710        // `FonteCaminhoShellCommandSubstitution`. The input/output
11711        // redirection metachar carries the more self-locating `byte`
11712        // payload (it names which of `<` or `>` triggered), so the
11713        // prior arm wins on every probe-as-both value.
11714        let d = dep_with_fonte(DepSource::Path {
11715            caminho: "../caixa-teia>log `date`".into(),
11716        });
11717        let err = d.validate().unwrap_err();
11718        assert!(
11719            matches!(
11720                err,
11721                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11722            ),
11723            "got {err:?}",
11724        );
11725    }
11726
11727    #[test]
11728    fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11729        // Cascade pin on the upstream backslash arm: a value
11730        // carrying both `\` and a backtick (``"..\caixa-teia
11731        // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11732        // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11733        // chain") routes through `FonteCaminhoBackslash` not
11734        // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11735        // separator divergence is the load-bearing axis on every
11736        // probe-as-both value (an author who removes the `\` is the
11737        // root-cause edit; the backtick falls away in the same edit
11738        // since it's downstream of the Windows-shell convention).
11739        let d = dep_with_fonte(DepSource::Path {
11740            caminho: "..\\caixa-teia `whoami`".into(),
11741        });
11742        let err = d.validate().unwrap_err();
11743        assert!(
11744            matches!(err, DepError::FonteCaminhoBackslash { .. }),
11745            "got {err:?}",
11746        );
11747    }
11748
11749    #[test]
11750    fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11751        // Cascade pin on the embedded-control-byte arm: a value
11752        // carrying both a control byte and a backtick (`"../foo\n
11753        // `whoami`"` — the canonical paste-from-multiline-doc
11754        // footgun where a newline landed mid-caminho between two
11755        // paste fragments) routes through `FonteCaminhoControlChar`
11756        // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11757        // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11758        // is the load-bearing axis on every value that probes
11759        // positive for both — mirrors the cascade discipline on
11760        // every prior arm.
11761        let d = dep_with_fonte(DepSource::Path {
11762            caminho: "../foo\n`whoami`".into(),
11763        });
11764        let err = d.validate().unwrap_err();
11765        assert!(
11766            matches!(err, DepError::FonteCaminhoControlChar { .. }),
11767            "got {err:?}",
11768        );
11769    }
11770
11771    #[test]
11772    fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11773        // Cascade pin on the load-bearing leading-byte arm: a
11774        // leading `/` value with embedded backtick (``"/etc/passwd
11775        // <backtick>whoami<backtick>"``) routes through
11776        // `FonteCaminhoAbsolute` not
11777        // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11778        // leak diagnostic is the load-bearing axis, the backtick
11779        // byte is the secondary observation. Same precedence logic
11780        // as every prior leading-byte arm.
11781        let d = dep_with_fonte(DepSource::Path {
11782            caminho: "/etc/passwd `whoami`".into(),
11783        });
11784        let err = d.validate().unwrap_err();
11785        assert!(
11786            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11787            "got {err:?}",
11788        );
11789    }
11790
11791    #[test]
11792    fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11793        // Cascade pin on the immediate-successor arm: a value
11794        // carrying both a backtick and a trailing `/`
11795        // (``"../`whoami`/"`` — the canonical "I tab-completed a
11796        // path that already had a backticked `whoami` substitution
11797        // tail" footgun) routes through
11798        // `FonteCaminhoShellCommandSubstitution` not
11799        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11800        // is the more semantic-locating axis (an author who removes
11801        // the backtick typically also drops the trailing separator
11802        // since both are paste-from-shell artifacts).
11803        let d = dep_with_fonte(DepSource::Path {
11804            caminho: "../`whoami`/".into(),
11805        });
11806        let err = d.validate().unwrap_err();
11807        assert!(
11808            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11809            "got {err:?}",
11810        );
11811    }
11812
11813    #[test]
11814    fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11815        // Diagnostic-shape pin (peer with
11816        // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11817        // on the closest single-byte peer arm): the error's Display
11818        // surfaces the offending `:nome` and the offending `:caminho`
11819        // verbatim, and names the shell-command-substitution footgun
11820        // explicitly so a `feira lint` run can render the diagnostic
11821        // without re-parsing.
11822        let d = dep_with_fonte(DepSource::Path {
11823            caminho: "../caixa-teia/`whoami`".into(),
11824        });
11825        let rendered = d.validate().unwrap_err().to_string();
11826        assert!(
11827            rendered.contains("caixa-teia"),
11828            "diagnostic must name the offending dep: {rendered}",
11829        );
11830        assert!(
11831            rendered.contains("../caixa-teia/`whoami`"),
11832            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11833        );
11834        assert!(
11835            rendered.contains('`'),
11836            "diagnostic must reference the backtick footgun: {rendered:?}",
11837        );
11838        assert!(
11839            rendered.contains("command-substitution"),
11840            "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11841        );
11842    }
11843
11844    #[test]
11845    fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11846        // The fail-before-pass-after pin for the canonical pathname-
11847        // expansion paste footgun: an author copies an `ls
11848        // ../caixa-teia/*` shell-listing tail into the `:caminho`
11849        // slot and silently passes every prior arm
11850        // (`Path::is_absolute` false on `..`, no control bytes, no
11851        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11852        // doesn't end in `/`). The lacre embedded the value
11853        // verbatim, the resolver folded it through `Path::join`
11854        // looking for a literal `./../caixa-teia/*` subdirectory,
11855        // and the failure surfaced at resolve time with a non-self-
11856        // locating `No such file or directory` error. The new arm
11857        // moves the rejection to validate time and names the
11858        // offending dep + caminho + byte verbatim.
11859        let d = dep_with_fonte(DepSource::Path {
11860            caminho: "../caixa-teia/*".into(),
11861        });
11862        let err = d.validate().unwrap_err();
11863        let DepError::FonteCaminhoShellGlob {
11864            nome,
11865            caminho,
11866            byte,
11867        } = err
11868        else {
11869            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11870        };
11871        assert_eq!(nome, "caixa-teia");
11872        assert_eq!(caminho, "../caixa-teia/*");
11873        assert_eq!(byte, b'*');
11874    }
11875
11876    #[test]
11877    fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11878        // The symmetric single-char-wildcard paste shape
11879        // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11880        // out of shell history" idiom). Pinned separately from the
11881        // `*` shape so the gate's contract is "any `*` or `?`
11882        // anywhere", not single-byte coverage.
11883        let d = dep_with_fonte(DepSource::Path {
11884            caminho: "../foo?".into(),
11885        });
11886        let err = d.validate().unwrap_err();
11887        let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11888            panic!("expected FonteCaminhoShellGlob, got {err:?}");
11889        };
11890        assert_eq!(byte, b'?');
11891    }
11892
11893    #[test]
11894    fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11895        // Leading-position `*` shape (`"*/caixa-teia"` — the
11896        // degenerate "I selected only the wildcard prefix out of a
11897        // shell-glob expression" idiom). Pinned separately from the
11898        // embedded-byte shapes so the gate covers every position,
11899        // not only mid-path.
11900        let d = dep_with_fonte(DepSource::Path {
11901            caminho: "*/caixa-teia".into(),
11902        });
11903        let err = d.validate().unwrap_err();
11904        assert!(
11905            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11906            "got {err:?}",
11907        );
11908    }
11909
11910    #[test]
11911    fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11912        // The bash/zsh `globstar` recursive-glob shape
11913        // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11914        // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11915        // The arm fires on the first `*` encountered; pinned so a
11916        // future arm that tries to distinguish single `*` from
11917        // double `**` doesn't break the broader contract.
11918        let d = dep_with_fonte(DepSource::Path {
11919            caminho: "../caixa-teia/**/foo".into(),
11920        });
11921        let err = d.validate().unwrap_err();
11922        assert!(
11923            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11924            "got {err:?}",
11925        );
11926    }
11927
11928    #[test]
11929    fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11930        // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11931        // — the "I selected `*.lisp` to mean every Lisp source file
11932        // in the dep root" footgun the prior arms structurally
11933        // cannot catch since `.` is a POSIX-valid path-component
11934        // byte). Pinned so the gate's contract covers the most
11935        // idiomatic glob-paste shape every author meets first.
11936        let d = dep_with_fonte(DepSource::Path {
11937            caminho: "../caixa-teia/*.lisp".into(),
11938        });
11939        let err = d.validate().unwrap_err();
11940        assert!(
11941            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11942            "got {err:?}",
11943        );
11944    }
11945
11946    #[test]
11947    fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11948        // The positive-control pin: the gate targets only `*` /
11949        // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11950        // The canonical relative POSIX path (`"../caixa-teia"`) and
11951        // a nested deeply-pathed variant with adjacent printable
11952        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11953        // to validate cleanly so the gate doesn't widen to a "no
11954        // printable punctuation anywhere" sweep that would defeat
11955        // the entire path-fonte author surface.
11956        let d = dep_with_fonte(DepSource::Path {
11957            caminho: "../caixa-teia/sub-dir.v2".into(),
11958        });
11959        d.validate().unwrap();
11960    }
11961
11962    #[test]
11963    fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11964        // Cascade pin on the immediate-predecessor arm: a value
11965        // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11966        // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11967        // command-substitution + glob chain") routes through
11968        // `FonteCaminhoShellCommandSubstitution` not
11969        // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11970        // injection vector is the load-bearing root-cause edit on
11971        // every probe-as-both value — same cascade discipline every
11972        // prior `:caminho` arm establishes.
11973        let d = dep_with_fonte(DepSource::Path {
11974            caminho: "../`whoami`/*".into(),
11975        });
11976        let err = d.validate().unwrap_err();
11977        assert!(
11978            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11979            "got {err:?}",
11980        );
11981    }
11982
11983    #[test]
11984    fn fonte_caminho_shell_background_fires_before_shell_glob() {
11985        // Cascade pin on the upstream shell-background arm: a value
11986        // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11987        // canonical "I pasted a `cmd & ls /*` background + glob
11988        // chain" footgun) routes through `FonteCaminhoShellBackground`
11989        // not `FonteCaminhoShellGlob`. The background-launch tail is
11990        // the load-bearing root-cause edit on every probe-as-both
11991        // value.
11992        let d = dep_with_fonte(DepSource::Path {
11993            caminho: "../caixa-teia & ls /*".into(),
11994        });
11995        let err = d.validate().unwrap_err();
11996        assert!(
11997            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11998            "got {err:?}",
11999        );
12000    }
12001
12002    #[test]
12003    fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
12004        // Cascade pin on the upstream shell-semicolon arm: a value
12005        // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
12006        // canonical sequential-cleanup + glob paste idiom) routes
12007        // through `FonteCaminhoShellSemicolon` not
12008        // `FonteCaminhoShellGlob`. The sequential-command-separator
12009        // paste is the load-bearing root-cause edit on every
12010        // probe-as-both value.
12011        let d = dep_with_fonte(DepSource::Path {
12012            caminho: "../caixa-teia; rm *".into(),
12013        });
12014        let err = d.validate().unwrap_err();
12015        assert!(
12016            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12017            "got {err:?}",
12018        );
12019    }
12020
12021    #[test]
12022    fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
12023        // Cascade pin on the upstream shell-pipe arm: a value
12024        // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
12025        // canonical pipeline-to-glob paste idiom) routes through
12026        // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
12027        // pipeline-tail paste is the load-bearing root-cause edit
12028        // on every probe-as-both value.
12029        let d = dep_with_fonte(DepSource::Path {
12030            caminho: "../caixa-teia | ls *".into(),
12031        });
12032        let err = d.validate().unwrap_err();
12033        assert!(
12034            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12035            "got {err:?}",
12036        );
12037    }
12038
12039    #[test]
12040    fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
12041        // Cascade pin on the upstream shell-redirection arm: a value
12042        // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
12043        // canonical "I pasted a `cmd > log *` redirect-plus-glob
12044        // chain" footgun) routes through
12045        // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
12046        // The input/output redirection metachar carries the more
12047        // self-locating `byte` payload (it names which of `<` or `>`
12048        // triggered), so the prior arm wins on every probe-as-both
12049        // value.
12050        let d = dep_with_fonte(DepSource::Path {
12051            caminho: "../caixa-teia>log *".into(),
12052        });
12053        let err = d.validate().unwrap_err();
12054        assert!(
12055            matches!(
12056                err,
12057                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12058            ),
12059            "got {err:?}",
12060        );
12061    }
12062
12063    #[test]
12064    fn fonte_caminho_backslash_fires_before_shell_glob() {
12065        // Cascade pin on the upstream backslash arm: a value
12066        // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
12067        // canonical "I pasted a Windows-shell `cd ..\path\*` glob
12068        // expression" footgun) routes through
12069        // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
12070        // cross-host-OS-separator divergence is the load-bearing
12071        // axis on every probe-as-both value (an author who removes
12072        // the `\` is the root-cause edit; the `*` falls away in the
12073        // same edit since it's downstream of the Windows-shell
12074        // convention).
12075        let d = dep_with_fonte(DepSource::Path {
12076            caminho: "..\\caixa-teia\\*".into(),
12077        });
12078        let err = d.validate().unwrap_err();
12079        assert!(
12080            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12081            "got {err:?}",
12082        );
12083    }
12084
12085    #[test]
12086    fn fonte_caminho_control_char_fires_before_shell_glob() {
12087        // Cascade pin on the embedded-control-byte arm: a value
12088        // carrying both a control byte and `*` (`"../foo\n*"` — the
12089        // canonical paste-from-multiline-doc footgun where a
12090        // newline landed mid-caminho between two paste fragments)
12091        // routes through `FonteCaminhoControlChar` not
12092        // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
12093        // NUL-`CString::new`-fail diagnostic is the load-bearing
12094        // axis on every value that probes positive for both —
12095        // mirrors the cascade discipline on every prior arm.
12096        let d = dep_with_fonte(DepSource::Path {
12097            caminho: "../foo\n*".into(),
12098        });
12099        let err = d.validate().unwrap_err();
12100        assert!(
12101            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12102            "got {err:?}",
12103        );
12104    }
12105
12106    #[test]
12107    fn fonte_caminho_absolute_fires_before_shell_glob() {
12108        // Cascade pin on the load-bearing leading-byte arm: a
12109        // leading `/` value with embedded `*` (`"/etc/*"`) routes
12110        // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
12111        // — the host-layout-leak diagnostic is the load-bearing
12112        // axis, the glob byte is the secondary observation. Same
12113        // precedence logic as every prior leading-byte arm.
12114        let d = dep_with_fonte(DepSource::Path {
12115            caminho: "/etc/*".into(),
12116        });
12117        let err = d.validate().unwrap_err();
12118        assert!(
12119            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12120            "got {err:?}",
12121        );
12122    }
12123
12124    #[test]
12125    fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
12126        // Cascade pin on the immediate-successor arm: a value
12127        // carrying both `*` and a trailing `/` (`"../foo*/"` — the
12128        // canonical "I tab-completed a path that already had a
12129        // glob-expansion tail" footgun) routes through
12130        // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
12131        // The embedded shell-metachar is the more semantic-locating
12132        // axis (an author who removes the `*` typically also drops
12133        // the trailing separator since both are paste-from-shell
12134        // artifacts).
12135        let d = dep_with_fonte(DepSource::Path {
12136            caminho: "../foo*/".into(),
12137        });
12138        let err = d.validate().unwrap_err();
12139        assert!(
12140            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12141            "got {err:?}",
12142        );
12143    }
12144
12145    #[test]
12146    fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
12147        // Diagnostic-shape pin (peer with
12148        // `fonte_caminho_shell_redirection_diagnostic_*` on the
12149        // closest two-byte peer arm): the error's Display surfaces
12150        // the offending `:nome`, the offending `:caminho` verbatim,
12151        // the offending byte's hex / character form, and names the
12152        // shell-glob / pathname-expansion footgun explicitly so a
12153        // `feira lint` run can render the diagnostic without
12154        // re-parsing.
12155        let d = dep_with_fonte(DepSource::Path {
12156            caminho: "../caixa-teia/*.lisp".into(),
12157        });
12158        let rendered = d.validate().unwrap_err().to_string();
12159        assert!(
12160            rendered.contains("caixa-teia"),
12161            "diagnostic must name the offending dep: {rendered}",
12162        );
12163        assert!(
12164            rendered.contains("../caixa-teia/*.lisp"),
12165            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12166        );
12167        assert!(
12168            rendered.contains("0x2a"),
12169            "diagnostic must surface the offending byte hex: {rendered:?}",
12170        );
12171        assert!(
12172            rendered.contains("glob"),
12173            "diagnostic must name the shell-glob footgun: {rendered:?}",
12174        );
12175        assert!(
12176            rendered.contains("pathname-expansion"),
12177            "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
12178        );
12179    }
12180
12181    #[test]
12182    fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
12183        // The fail-before-pass-after pin for the canonical modern-Bourne
12184        // command-substitution paste footgun: an author copies a
12185        // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
12186        // `$(<cmd>)` expansion would land the current date as a
12187        // subdirectory name and silently passed every prior arm
12188        // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
12189        // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
12190        // `?`, doesn't end in `/`; the leading-`$` f4efe9c
12191        // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
12192        // sits mid-path). The lacre embedded the value verbatim, the
12193        // resolver folded it through `Path::join` looking for a literal
12194        // `./../caixa-teia/$(date)/build` subdirectory, and the failure
12195        // surfaced at resolve time with a non-self-locating `No such
12196        // file or directory` error. The new arm moves the rejection to
12197        // validate time and names the offending dep + caminho + byte
12198        // verbatim. The arm fires on the first `(` encountered (the
12199        // opening byte of `$(date)`).
12200        let d = dep_with_fonte(DepSource::Path {
12201            caminho: "../caixa-teia/$(date)/build".into(),
12202        });
12203        let err = d.validate().unwrap_err();
12204        let DepError::FonteCaminhoShellSubshellGrouping {
12205            nome,
12206            caminho,
12207            byte,
12208        } = err
12209        else {
12210            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12211        };
12212        assert_eq!(nome, "caixa-teia");
12213        assert_eq!(caminho, "../caixa-teia/$(date)/build");
12214        assert_eq!(byte, b'(');
12215    }
12216
12217    #[test]
12218    fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
12219        // The symmetric close-paren paste shape (`"../caixa-teia)"` —
12220        // the degenerate "I selected an unbalanced closing paren out of
12221        // a shell-history block" idiom that probes for the cascade's
12222        // last-byte handling on a value carrying only the closing byte).
12223        // Pinned separately from the open-paren shape so the gate's
12224        // contract is "any `(` or `)` anywhere", not single-byte
12225        // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
12226        // caminho_carrying_question_glob` shape on the immediate-
12227        // predecessor `FonteCaminhoShellGlob` arm.
12228        let d = dep_with_fonte(DepSource::Path {
12229            caminho: "../caixa-teia)".into(),
12230        });
12231        let err = d.validate().unwrap_err();
12232        let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
12233            panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
12234        };
12235        assert_eq!(byte, b')');
12236    }
12237
12238    #[test]
12239    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
12240        // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
12241        // canonical "I selected a `(cd foo)` subshell-grouping prefix
12242        // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
12243        // Pinned separately from the embedded-byte shape so the gate
12244        // covers every position, not only mid-path.
12245        let d = dep_with_fonte(DepSource::Path {
12246            caminho: "(cd foo)/caixa-teia".into(),
12247        });
12248        let err = d.validate().unwrap_err();
12249        assert!(
12250            matches!(
12251                err,
12252                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12253            ),
12254            "got {err:?}",
12255        );
12256    }
12257
12258    #[test]
12259    fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
12260        // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
12261        // — the canonical "I copied a `(pwd)` working-directory-probe
12262        // subshell-grouping idiom every shell-history block carries"
12263        // footgun). The value carries no other cascade-preceding
12264        // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
12265        // `*` / `?`) so the arm fires on the first `(` encountered;
12266        // pinned so a future arm that tries to distinguish the
12267        // opening from the closing byte doesn't break the broader
12268        // contract. Mirrors the peer
12269        // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
12270        // backtick_pair` shape on the upstream `FonteCaminhoShell\
12271        // CommandSubstitution` arm.
12272        let d = dep_with_fonte(DepSource::Path {
12273            caminho: "../(pwd)/caixa-teia".into(),
12274        });
12275        let err = d.validate().unwrap_err();
12276        assert!(
12277            matches!(
12278                err,
12279                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12280            ),
12281            "got {err:?}",
12282        );
12283    }
12284
12285    #[test]
12286    fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
12287        // The positive-control pin: the gate targets only `(` / `)`,
12288        // never adjacent printable ASCII or POSIX-valid bytes. The
12289        // canonical relative POSIX path (`"../caixa-teia"`) and a
12290        // nested deeply-pathed variant with adjacent printable
12291        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12292        // validate cleanly so the gate doesn't widen to a "no printable
12293        // punctuation anywhere" sweep that would defeat the entire
12294        // path-fonte author surface.
12295        let d = dep_with_fonte(DepSource::Path {
12296            caminho: "../caixa-teia/sub-dir.v2".into(),
12297        });
12298        d.validate().unwrap();
12299    }
12300
12301    #[test]
12302    fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
12303        // Cascade pin on the immediate-predecessor arm: a value
12304        // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
12305        // canonical "I pasted a glob expansion followed by a
12306        // subshell-grouping tail" footgun) routes through
12307        // `FonteCaminhoShellGlob` not
12308        // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
12309        // shape is the more common shell-history paste idiom on every
12310        // probe-as-both value — same cascade discipline every prior
12311        // `:caminho` arm establishes.
12312        let d = dep_with_fonte(DepSource::Path {
12313            caminho: "../caixa-teia/*(date)".into(),
12314        });
12315        let err = d.validate().unwrap_err();
12316        assert!(
12317            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12318            "got {err:?}",
12319        );
12320    }
12321
12322    #[test]
12323    fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
12324        // Cascade pin on the upstream shell-command-substitution arm: a
12325        // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
12326        // — the canonical "I pasted a legacy-backtick + modern-paren
12327        // command-substitution chain" footgun) routes through
12328        // `FonteCaminhoShellCommandSubstitution` not
12329        // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
12330        // command-injection vector is the load-bearing root-cause edit
12331        // on every probe-as-both value.
12332        let d = dep_with_fonte(DepSource::Path {
12333            caminho: "../`whoami`/$(date)".into(),
12334        });
12335        let err = d.validate().unwrap_err();
12336        assert!(
12337            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12338            "got {err:?}",
12339        );
12340    }
12341
12342    #[test]
12343    fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
12344        // Cascade pin on the upstream shell-background arm: a value
12345        // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
12346        // the canonical "I pasted a `cmd & (cd foo)` background-launch
12347        // + subshell-grouping chain" footgun) routes through
12348        // `FonteCaminhoShellBackground` not
12349        // `FonteCaminhoShellSubshellGrouping`. The background-launch
12350        // tail is the load-bearing root-cause edit on every probe-as-
12351        // both value.
12352        let d = dep_with_fonte(DepSource::Path {
12353            caminho: "../caixa-teia & (cd foo)".into(),
12354        });
12355        let err = d.validate().unwrap_err();
12356        assert!(
12357            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12358            "got {err:?}",
12359        );
12360    }
12361
12362    #[test]
12363    fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
12364        // Cascade pin on the upstream shell-semicolon arm: a value
12365        // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
12366        // the canonical sequential-cleanup + subshell-grouping paste
12367        // idiom) routes through `FonteCaminhoShellSemicolon` not
12368        // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
12369        // separator paste is the load-bearing root-cause edit on
12370        // every probe-as-both value.
12371        let d = dep_with_fonte(DepSource::Path {
12372            caminho: "../caixa-teia; (cd foo)".into(),
12373        });
12374        let err = d.validate().unwrap_err();
12375        assert!(
12376            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12377            "got {err:?}",
12378        );
12379    }
12380
12381    #[test]
12382    fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
12383        // Cascade pin on the upstream shell-pipe arm: a value carrying
12384        // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
12385        // canonical pipeline-to-subshell-grouping paste idiom) routes
12386        // through `FonteCaminhoShellPipe` not
12387        // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
12388        // is the load-bearing root-cause edit on every probe-as-both
12389        // value.
12390        let d = dep_with_fonte(DepSource::Path {
12391            caminho: "../caixa-teia | (tee log)".into(),
12392        });
12393        let err = d.validate().unwrap_err();
12394        assert!(
12395            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12396            "got {err:?}",
12397        );
12398    }
12399
12400    #[test]
12401    fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
12402        // Cascade pin on the upstream shell-redirection arm: a value
12403        // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
12404        // the canonical "I pasted a `cmd > log (cd foo)` redirect-
12405        // plus-subshell-grouping chain" footgun) routes through
12406        // `FonteCaminhoShellRedirection` not
12407        // `FonteCaminhoShellSubshellGrouping`. The input/output
12408        // redirection metachar carries the more self-locating `byte`
12409        // payload (it names which of `<` or `>` triggered), so the
12410        // prior arm wins on every probe-as-both value.
12411        let d = dep_with_fonte(DepSource::Path {
12412            caminho: "../caixa-teia>log (cd foo)".into(),
12413        });
12414        let err = d.validate().unwrap_err();
12415        assert!(
12416            matches!(
12417                err,
12418                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12419            ),
12420            "got {err:?}",
12421        );
12422    }
12423
12424    #[test]
12425    fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
12426        // Cascade pin on the upstream backslash arm: a value carrying
12427        // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
12428        // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
12429        // through `FonteCaminhoBackslash` not
12430        // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
12431        // separator divergence is the load-bearing axis on every
12432        // probe-as-both value (an author who removes the `\` is the
12433        // root-cause edit; the `(` falls away in the same edit since
12434        // it's downstream of the Windows-shell convention).
12435        let d = dep_with_fonte(DepSource::Path {
12436            caminho: "..\\caixa-teia\\(cd foo)".into(),
12437        });
12438        let err = d.validate().unwrap_err();
12439        assert!(
12440            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12441            "got {err:?}",
12442        );
12443    }
12444
12445    #[test]
12446    fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
12447        // Cascade pin on the embedded-control-byte arm: a value
12448        // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
12449        // the canonical paste-from-multiline-doc footgun where a
12450        // newline landed mid-caminho between two paste fragments)
12451        // routes through `FonteCaminhoControlChar` not
12452        // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
12453        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12454        // load-bearing axis on every value that probes positive for
12455        // both — mirrors the cascade discipline on every prior arm.
12456        let d = dep_with_fonte(DepSource::Path {
12457            caminho: "../foo\n(cd bar)".into(),
12458        });
12459        let err = d.validate().unwrap_err();
12460        assert!(
12461            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12462            "got {err:?}",
12463        );
12464    }
12465
12466    #[test]
12467    fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
12468        // Cascade pin on the load-bearing leading-byte arm: a leading
12469        // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
12470        // through `FonteCaminhoAbsolute` not
12471        // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
12472        // diagnostic is the load-bearing axis, the subshell-grouping
12473        // byte is the secondary observation. Same precedence logic as
12474        // every prior leading-byte arm.
12475        let d = dep_with_fonte(DepSource::Path {
12476            caminho: "/etc/(cd foo)".into(),
12477        });
12478        let err = d.validate().unwrap_err();
12479        assert!(
12480            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12481            "got {err:?}",
12482        );
12483    }
12484
12485    #[test]
12486    fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
12487        // Cascade pin on the upstream leading-`$` var-expansion arm: a
12488        // value carrying both a leading `$` and a `(` (`"$(date)/\
12489        // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
12490        // command-substitution at the head of a sibling-workspace
12491        // path" footgun) routes through `FonteCaminhoVarExpansion` not
12492        // `FonteCaminhoShellSubshellGrouping`. The leading-byte
12493        // shell-variable-expansion is the more self-locating diagnostic
12494        // on values that probe as both — same load-bearing-leading-
12495        // byte cascade discipline every prior `:caminho` arm
12496        // establishes. Closing both halves of `$(<cmd>)` structurally
12497        // (leading `$` here, trailing `)` on the new arm) excludes the
12498        // entire modern Bourne command-substitution surface from the
12499        // typed `:caminho` accepted set; the cascade preserves the
12500        // narrower leading-byte diagnostic on values that probe both
12501        // halves at the canonical leading position.
12502        let d = dep_with_fonte(DepSource::Path {
12503            caminho: "$(date)/caixa-teia".into(),
12504        });
12505        let err = d.validate().unwrap_err();
12506        assert!(
12507            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12508            "got {err:?}",
12509        );
12510    }
12511
12512    #[test]
12513    fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
12514        // Cascade pin on the immediate-successor arm: a value carrying
12515        // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
12516        // "I tab-completed a path that already had a subshell-grouping
12517        // expansion tail" footgun) routes through
12518        // `FonteCaminhoShellSubshellGrouping` not
12519        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
12520        // the more semantic-locating axis (an author who removes the
12521        // `(` typically also drops the trailing separator since both
12522        // are paste-from-shell artifacts).
12523        let d = dep_with_fonte(DepSource::Path {
12524            caminho: "../(cd foo)/".into(),
12525        });
12526        let err = d.validate().unwrap_err();
12527        assert!(
12528            matches!(
12529                err,
12530                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12531            ),
12532            "got {err:?}",
12533        );
12534    }
12535
12536    #[test]
12537    fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12538        // Diagnostic-shape pin (peer with
12539        // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
12540        // on the closest two-byte peer arm): the error's Display
12541        // surfaces the offending `:nome`, the offending `:caminho`
12542        // verbatim, the offending byte's hex / character form, and
12543        // names the shell-subshell-grouping footgun explicitly so a
12544        // `feira lint` run can render the diagnostic without re-
12545        // parsing.
12546        let d = dep_with_fonte(DepSource::Path {
12547            caminho: "../caixa-teia/$(date)/build".into(),
12548        });
12549        let rendered = d.validate().unwrap_err().to_string();
12550        assert!(
12551            rendered.contains("caixa-teia"),
12552            "diagnostic must name the offending dep: {rendered}",
12553        );
12554        assert!(
12555            rendered.contains("../caixa-teia/$(date)/build"),
12556            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12557        );
12558        assert!(
12559            rendered.contains("0x28"),
12560            "diagnostic must surface the offending byte hex: {rendered:?}",
12561        );
12562        assert!(
12563            rendered.contains("subshell-grouping"),
12564            "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12565        );
12566        assert!(
12567            rendered.contains("command-substitution"),
12568            "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12569             {rendered:?}",
12570        );
12571    }
12572
12573    // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12574    //
12575    // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12576    // `)`) byte-pair arm: the same per-byte cascade with the same
12577    // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12578    // `}` brace-expansion / URI-Template placeholder axis. The peer
12579    // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12580    // byte pair on the sibling `:fonte :repo` axis under the same
12581    // banner.
12582
12583    #[test]
12584    fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12585        // The fail-before-pass-after pin for the canonical paste-from-
12586        // shell-history brace-expansion footgun: an author copies a
12587        // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12588        // liner whose `{a,b}` brace expansion fans across two siblings
12589        // and silently passed every prior arm (`Path::is_absolute`
12590        // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12591        // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12592        // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12593        // `FonteCaminhoVarExpansion` arm doesn't fire because the
12594        // value starts with `..` not `$`). The lacre embedded the
12595        // value verbatim, the resolver folded it through `Path::join`
12596        // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12597        // subdirectory, and the failure surfaced at resolve time with
12598        // a non-self-locating `No such file or directory` error. The
12599        // new arm moves the rejection to validate time and names the
12600        // offending dep + caminho + byte verbatim. The arm fires on
12601        // the first `{` encountered.
12602        let d = dep_with_fonte(DepSource::Path {
12603            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12604        });
12605        let err = d.validate().unwrap_err();
12606        let DepError::FonteCaminhoShellBraceExpansion {
12607            nome,
12608            caminho,
12609            byte,
12610        } = err
12611        else {
12612            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12613        };
12614        assert_eq!(nome, "caixa-teia");
12615        assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12616        assert_eq!(byte, b'{');
12617    }
12618
12619    #[test]
12620    fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12621        // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12622        // the degenerate "I selected an unbalanced closing brace out
12623        // of a shell-history block" idiom that probes for the
12624        // cascade's last-byte handling on a value carrying only the
12625        // closing byte). Pinned separately from the open-brace shape
12626        // so the gate's contract is "any `{` or `}` anywhere", not
12627        // single-byte coverage. Mirrors the peer
12628        // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12629        // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12630        // arm.
12631        let d = dep_with_fonte(DepSource::Path {
12632            caminho: "../caixa-teia}".into(),
12633        });
12634        let err = d.validate().unwrap_err();
12635        let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12636            panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12637        };
12638        assert_eq!(byte, b'}');
12639    }
12640
12641    #[test]
12642    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12643        // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12644        // — the canonical "I selected a `{a,b}` brace-expansion prefix
12645        // out of a shell-history one-liner" idiom). Pinned separately
12646        // from the embedded-byte shape so the gate covers every
12647        // position, not only mid-path.
12648        let d = dep_with_fonte(DepSource::Path {
12649            caminho: "{caixa-teia,caixa-helm}/build".into(),
12650        });
12651        let err = d.validate().unwrap_err();
12652        assert!(
12653            matches!(
12654                err,
12655                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12656            ),
12657            "got {err:?}",
12658        );
12659    }
12660
12661    #[test]
12662    fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12663        // The canonical URI-Template / Mustache / Helm doubled-brace
12664        // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12665        // "I copied a `https://github.com/{{org}}/caixa-teia` README
12666        // quick-start / OpenAPI spec / Helm chart `home:` template
12667        // and forgot to substitute the placeholder" footgun). The arm
12668        // fires on the first `{` encountered; pinned so the gate's
12669        // coverage extends from the bare-brace shell-history shape to
12670        // the doubled-brace URI-Template / templating-engine shape.
12671        // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12672        // sibling `:fonte :repo` axis.
12673        let d = dep_with_fonte(DepSource::Path {
12674            caminho: "../{{org}}/caixa-teia".into(),
12675        });
12676        let err = d.validate().unwrap_err();
12677        assert!(
12678            matches!(
12679                err,
12680                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12681            ),
12682            "got {err:?}",
12683        );
12684    }
12685
12686    #[test]
12687    fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12688        // The canonical bash brace-range-expansion shape (`"../caixa-
12689        // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12690        // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12691        // sequence-range form to the `{a,b,c}` comma-separated form).
12692        // The arm fires on the first `{` encountered; pinned so the
12693        // gate's coverage extends from the comma-separated form to
12694        // the integer-range form.
12695        let d = dep_with_fonte(DepSource::Path {
12696            caminho: "../caixa-v{1..10}".into(),
12697        });
12698        let err = d.validate().unwrap_err();
12699        assert!(
12700            matches!(
12701                err,
12702                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12703            ),
12704            "got {err:?}",
12705        );
12706    }
12707
12708    #[test]
12709    fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12710        // The positive-control pin: the gate targets only `{` / `}`,
12711        // never adjacent printable ASCII or POSIX-valid bytes. The
12712        // canonical relative POSIX path (`"../caixa-teia"`) and a
12713        // nested deeply-pathed variant with adjacent printable
12714        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12715        // validate cleanly so the gate doesn't widen to a "no
12716        // printable punctuation anywhere" sweep that would defeat
12717        // the entire path-fonte author surface. Peer with
12718        // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12719        // on the immediate-predecessor arm.
12720        let d = dep_with_fonte(DepSource::Path {
12721            caminho: "../caixa-teia/sub-dir.v2".into(),
12722        });
12723        d.validate().unwrap();
12724    }
12725
12726    #[test]
12727    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12728        // Cascade pin on the immediate-predecessor arm: a value
12729        // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12730        // canonical "I pasted a subshell-grouping followed by a
12731        // brace-expansion tail" footgun) routes through
12732        // `FonteCaminhoShellSubshellGrouping` not
12733        // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12734        // shape is the more semantic-locating axis on every probe-
12735        // as-both value because it closes both halves of the modern
12736        // Bourne `$(<cmd>)` command-substitution surface — same
12737        // cascade discipline every prior `:caminho` arm establishes.
12738        let d = dep_with_fonte(DepSource::Path {
12739            caminho: "../(cd foo)/{a,b}".into(),
12740        });
12741        let err = d.validate().unwrap_err();
12742        assert!(
12743            matches!(
12744                err,
12745                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12746            ),
12747            "got {err:?}",
12748        );
12749    }
12750
12751    #[test]
12752    fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12753        // Cascade pin on the upstream shell-glob arm: a value carrying
12754        // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12755        // "I pasted a glob expansion followed by a brace-expansion
12756        // tail" footgun) routes through `FonteCaminhoShellGlob` not
12757        // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12758        // shape is the load-bearing root-cause edit on every
12759        // probe-as-both value.
12760        let d = dep_with_fonte(DepSource::Path {
12761            caminho: "../caixa-teia/*{a,b}".into(),
12762        });
12763        let err = d.validate().unwrap_err();
12764        assert!(
12765            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12766            "got {err:?}",
12767        );
12768    }
12769
12770    #[test]
12771    fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12772        // Cascade pin on the upstream shell-command-substitution arm:
12773        // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12774        // — the canonical "I pasted a legacy-backtick command-
12775        // substitution followed by a brace-expansion fan-out" footgun)
12776        // routes through `FonteCaminhoShellCommandSubstitution` not
12777        // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12778        // command-injection vector is the load-bearing root-cause
12779        // edit on every probe-as-both value.
12780        let d = dep_with_fonte(DepSource::Path {
12781            caminho: "../`whoami`/{a,b}".into(),
12782        });
12783        let err = d.validate().unwrap_err();
12784        assert!(
12785            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12786            "got {err:?}",
12787        );
12788    }
12789
12790    #[test]
12791    fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12792        // Cascade pin on the upstream shell-background arm: a value
12793        // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12794        // canonical "I pasted a `cmd & {fork-fan}` background-launch
12795        // + brace-expansion chain" footgun) routes through
12796        // `FonteCaminhoShellBackground` not
12797        // `FonteCaminhoShellBraceExpansion`. The background-launch
12798        // tail is the load-bearing root-cause edit on every
12799        // probe-as-both value.
12800        let d = dep_with_fonte(DepSource::Path {
12801            caminho: "../caixa-teia & {a,b}".into(),
12802        });
12803        let err = d.validate().unwrap_err();
12804        assert!(
12805            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12806            "got {err:?}",
12807        );
12808    }
12809
12810    #[test]
12811    fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12812        // Cascade pin on the upstream shell-semicolon arm: a value
12813        // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12814        // canonical sequential-cleanup + brace-expansion paste
12815        // idiom) routes through `FonteCaminhoShellSemicolon` not
12816        // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12817        // separator paste is the load-bearing root-cause edit on
12818        // every probe-as-both value.
12819        let d = dep_with_fonte(DepSource::Path {
12820            caminho: "../caixa-teia; {a,b}".into(),
12821        });
12822        let err = d.validate().unwrap_err();
12823        assert!(
12824            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12825            "got {err:?}",
12826        );
12827    }
12828
12829    #[test]
12830    fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12831        // Cascade pin on the upstream shell-pipe arm: a value
12832        // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12833        // — the canonical pipeline-to-brace-expansion paste idiom)
12834        // routes through `FonteCaminhoShellPipe` not
12835        // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12836        // is the load-bearing root-cause edit on every probe-as-
12837        // both value.
12838        let d = dep_with_fonte(DepSource::Path {
12839            caminho: "../caixa-teia | {tee,cat}".into(),
12840        });
12841        let err = d.validate().unwrap_err();
12842        assert!(
12843            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12844            "got {err:?}",
12845        );
12846    }
12847
12848    #[test]
12849    fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12850        // Cascade pin on the upstream shell-redirection arm: a value
12851        // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12852        // the canonical "I pasted a `cmd > log {a,b}` redirect-
12853        // plus-brace-expansion chain" footgun) routes through
12854        // `FonteCaminhoShellRedirection` not
12855        // `FonteCaminhoShellBraceExpansion`. The input/output
12856        // redirection metachar carries the more self-locating
12857        // `byte` payload, so the prior arm wins on every probe-
12858        // as-both value.
12859        let d = dep_with_fonte(DepSource::Path {
12860            caminho: "../caixa-teia>log {a,b}".into(),
12861        });
12862        let err = d.validate().unwrap_err();
12863        assert!(
12864            matches!(
12865                err,
12866                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12867            ),
12868            "got {err:?}",
12869        );
12870    }
12871
12872    #[test]
12873    fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12874        // Cascade pin on the upstream backslash arm: a value
12875        // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12876        // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12877        // chain") routes through `FonteCaminhoBackslash` not
12878        // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12879        // separator divergence is the load-bearing axis on every
12880        // probe-as-both value.
12881        let d = dep_with_fonte(DepSource::Path {
12882            caminho: "..\\caixa-teia\\{a,b}".into(),
12883        });
12884        let err = d.validate().unwrap_err();
12885        assert!(
12886            matches!(err, DepError::FonteCaminhoBackslash { .. }),
12887            "got {err:?}",
12888        );
12889    }
12890
12891    #[test]
12892    fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12893        // Cascade pin on the embedded-control-byte arm: a value
12894        // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12895        // the canonical paste-from-multiline-doc footgun where a
12896        // newline landed mid-caminho between two paste fragments)
12897        // routes through `FonteCaminhoControlChar` not
12898        // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12899        // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12900        // load-bearing axis on every value that probes positive for
12901        // both — mirrors the cascade discipline on every prior arm.
12902        let d = dep_with_fonte(DepSource::Path {
12903            caminho: "../foo\n{a,b}".into(),
12904        });
12905        let err = d.validate().unwrap_err();
12906        assert!(
12907            matches!(err, DepError::FonteCaminhoControlChar { .. }),
12908            "got {err:?}",
12909        );
12910    }
12911
12912    #[test]
12913    fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12914        // Cascade pin on the load-bearing leading-byte arm: a
12915        // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12916        // routes through `FonteCaminhoAbsolute` not
12917        // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12918        // diagnostic is the load-bearing axis, the brace-expansion
12919        // byte is the secondary observation. Same precedence logic
12920        // as every prior leading-byte arm.
12921        let d = dep_with_fonte(DepSource::Path {
12922            caminho: "/etc/{a,b}".into(),
12923        });
12924        let err = d.validate().unwrap_err();
12925        assert!(
12926            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12927            "got {err:?}",
12928        );
12929    }
12930
12931    #[test]
12932    fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12933        // Cascade pin on the upstream leading-`$` var-expansion
12934        // arm: a value carrying both a leading `$` and a `{`
12935        // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12936        // `${ORG}` shell-variable + curly-brace expansion at the
12937        // head of a sibling-workspace path" footgun) routes through
12938        // `FonteCaminhoVarExpansion` not
12939        // `FonteCaminhoShellBraceExpansion`. The leading-byte
12940        // shell-variable-expansion is the more self-locating
12941        // diagnostic on values that probe as both — same
12942        // load-bearing-leading-byte cascade discipline every prior
12943        // `:caminho` arm establishes.
12944        let d = dep_with_fonte(DepSource::Path {
12945            caminho: "${ORG}/caixa-teia".into(),
12946        });
12947        let err = d.validate().unwrap_err();
12948        assert!(
12949            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12950            "got {err:?}",
12951        );
12952    }
12953
12954    #[test]
12955    fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12956        // Cascade pin on the immediate-successor arm: a value
12957        // carrying both `{` and a trailing `/`
12958        // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12959        // tab-completed a path that already had a brace-expansion
12960        // expansion tail" footgun) routes through
12961        // `FonteCaminhoShellBraceExpansion` not
12962        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12963        // is the more semantic-locating axis (an author who removes
12964        // the `{` typically also drops the trailing separator since
12965        // both are paste-from-shell artifacts).
12966        let d = dep_with_fonte(DepSource::Path {
12967            caminho: "../{caixa-teia,caixa-helm}/".into(),
12968        });
12969        let err = d.validate().unwrap_err();
12970        assert!(
12971            matches!(
12972                err,
12973                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12974            ),
12975            "got {err:?}",
12976        );
12977    }
12978
12979    #[test]
12980    fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12981        // Diagnostic-shape pin (peer with
12982        // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12983        // on the closest two-byte peer arm): the error's Display
12984        // surfaces the offending `:nome`, the offending `:caminho`
12985        // verbatim, the offending byte's hex / character form, and
12986        // names the shell-brace-expansion / URI-Template footgun
12987        // explicitly so a `feira lint` run can render the diagnostic
12988        // without re-parsing.
12989        let d = dep_with_fonte(DepSource::Path {
12990            caminho: "../{caixa-teia,caixa-helm}/build".into(),
12991        });
12992        let rendered = d.validate().unwrap_err().to_string();
12993        assert!(
12994            rendered.contains("caixa-teia"),
12995            "diagnostic must name the offending dep: {rendered}",
12996        );
12997        assert!(
12998            rendered.contains("../{caixa-teia,caixa-helm}/build"),
12999            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13000        );
13001        assert!(
13002            rendered.contains("0x7b"),
13003            "diagnostic must surface the offending byte hex: {rendered:?}",
13004        );
13005        assert!(
13006            rendered.contains("brace-expansion"),
13007            "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
13008        );
13009        assert!(
13010            rendered.contains("URI Template"),
13011            "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
13012             {rendered:?}",
13013        );
13014    }
13015
13016    #[test]
13017    fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
13018        // The canonical paste-from-shell-history bracket-glob /
13019        // character-class footgun: an author copies a
13020        // `cd ../caixa-[a-z]/build` shell-history one-liner whose
13021        // `[a-z]` POSIX glob character-class matches every lowercase-
13022        // ASCII-suffix sibling caixa directory and silently passed
13023        // every prior arm (`Path::is_absolute` false on `..`, no
13024        // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
13025        // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
13026        // `}`, doesn't end in `/`; the leading-`$` f4efe9c
13027        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13028        // value starts with `..` not `$`). The lacre embedded the
13029        // value verbatim, the resolver folded it through
13030        // `Path::join` looking for a literal `./../caixa-[a-z]/
13031        // build` subdirectory, and the failure surfaced at resolve
13032        // time with a non-self-locating `No such file or directory`
13033        // error. The new arm moves the rejection to validate time
13034        // and names the offending dep + caminho + byte verbatim.
13035        // The arm fires on the first `[` encountered.
13036        let d = dep_with_fonte(DepSource::Path {
13037            caminho: "../caixa-[a-z]/build".into(),
13038        });
13039        let err = d.validate().unwrap_err();
13040        let DepError::FonteCaminhoShellBracketExpansion {
13041            nome,
13042            caminho,
13043            byte,
13044        } = err
13045        else {
13046            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13047        };
13048        assert_eq!(nome, "caixa-teia");
13049        assert_eq!(caminho, "../caixa-[a-z]/build");
13050        assert_eq!(byte, b'[');
13051    }
13052
13053    #[test]
13054    fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
13055        // The symmetric close-bracket paste shape (`"../caixa-teia]"`
13056        // — the degenerate "I selected an unbalanced closing bracket
13057        // out of a glob character-class block" idiom that probes for
13058        // the cascade's last-byte handling on a value carrying only
13059        // the closing byte). Pinned separately from the open-bracket
13060        // shape so the gate's contract is "any `[` or `]` anywhere",
13061        // not single-byte coverage. Mirrors the peer
13062        // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
13063        // shape on the immediate-predecessor
13064        // `FonteCaminhoShellBraceExpansion` arm.
13065        let d = dep_with_fonte(DepSource::Path {
13066            caminho: "../caixa-teia]".into(),
13067        });
13068        let err = d.validate().unwrap_err();
13069        let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
13070            panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
13071        };
13072        assert_eq!(byte, b']');
13073    }
13074
13075    #[test]
13076    fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
13077        // Leading-position `[` shape (`"[caixa-teia]/build"` — the
13078        // canonical "I selected a `[caixa-teia]` TOML-table-header /
13079        // glob-character-class prefix out of an aligned config /
13080        // shell-history one-liner" idiom). Pinned separately from
13081        // the embedded-byte shape so the gate covers every position,
13082        // not only mid-path.
13083        let d = dep_with_fonte(DepSource::Path {
13084            caminho: "[caixa-teia]/build".into(),
13085        });
13086        let err = d.validate().unwrap_err();
13087        assert!(
13088            matches!(
13089                err,
13090                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13091            ),
13092            "got {err:?}",
13093        );
13094    }
13095
13096    #[test]
13097    fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
13098        // The canonical TOML inline-array / YAML flow-sequence
13099        // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
13100        // canonical "I copied a `features = [\"a\", \"b\"]` TOML
13101        // inline-array out of a sibling-Cargo manifest" cross-idiom
13102        // leak; the symmetric YAML flow-sequence form `paths: [/a,
13103        // /b]` paste-from-values.yaml shape carries the same
13104        // bracket pair). The arm fires on the first `[` encountered;
13105        // pinned so the gate's coverage extends from the bare-
13106        // bracket glob-character-class shape to the TOML / YAML /
13107        // JSON array-literal shape.
13108        let d = dep_with_fonte(DepSource::Path {
13109            caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
13110        });
13111        let err = d.validate().unwrap_err();
13112        assert!(
13113            matches!(
13114                err,
13115                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13116            ),
13117            "got {err:?}",
13118        );
13119    }
13120
13121    #[test]
13122    fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
13123        // The canonical POSIX `test` / `[` builtin command paste
13124        // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
13125        // script conditional every paste-from-shell-script idiom
13126        // carries; bash's `[[ <expr> ]]` extended-test grammar
13127        // would surface the same byte pair). The arm fires on the
13128        // first `[` encountered; pinned so the gate's coverage
13129        // extends from the embedded-glob-character-class shape to
13130        // the leading-`test`-builtin / extended-test form.
13131        let d = dep_with_fonte(DepSource::Path {
13132            caminho: "../[ -d caixa-teia ]".into(),
13133        });
13134        let err = d.validate().unwrap_err();
13135        assert!(
13136            matches!(
13137                err,
13138                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13139            ),
13140            "got {err:?}",
13141        );
13142    }
13143
13144    #[test]
13145    fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
13146        // The positive-control pin: the gate targets only `[` /
13147        // `]`, never adjacent printable ASCII or POSIX-valid bytes.
13148        // The canonical relative POSIX path (`"../caixa-teia"`) and
13149        // a nested deeply-pathed variant with adjacent printable
13150        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13151        // to validate cleanly so the gate doesn't widen to a "no
13152        // printable punctuation anywhere" sweep that would defeat
13153        // the entire path-fonte author surface. Peer with
13154        // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
13155        // on the immediate-predecessor arm.
13156        let d = dep_with_fonte(DepSource::Path {
13157            caminho: "../caixa-teia/sub-dir.v2".into(),
13158        });
13159        d.validate().unwrap();
13160    }
13161
13162    #[test]
13163    fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
13164        // Cascade pin on the immediate-predecessor arm: a value
13165        // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
13166        // canonical "I pasted a brace-expansion fan followed by a
13167        // glob-character-class tail" footgun) routes through
13168        // `FonteCaminhoShellBraceExpansion` not
13169        // `FonteCaminhoShellBracketExpansion`. The brace-expansion
13170        // fan is the load-bearing root-cause edit on every
13171        // probe-as-both value because the bracket-class tail
13172        // typically rides on a prior brace-expansion expansion;
13173        // same cascade discipline every prior `:caminho` arm
13174        // establishes.
13175        let d = dep_with_fonte(DepSource::Path {
13176            caminho: "../{a,b}[ch]".into(),
13177        });
13178        let err = d.validate().unwrap_err();
13179        assert!(
13180            matches!(
13181                err,
13182                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13183            ),
13184            "got {err:?}",
13185        );
13186    }
13187
13188    #[test]
13189    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
13190        // Cascade pin on the upstream shell-subshell-grouping arm:
13191        // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
13192        // the canonical "I pasted a subshell-grouping followed by
13193        // a glob-character-class tail" footgun) routes through
13194        // `FonteCaminhoShellSubshellGrouping` not
13195        // `FonteCaminhoShellBracketExpansion`. The modern Bourne
13196        // `$(<cmd>)` command-substitution boundary is the load-
13197        // bearing axis on every probe-as-both value.
13198        let d = dep_with_fonte(DepSource::Path {
13199            caminho: "../(cd foo)/[ch]".into(),
13200        });
13201        let err = d.validate().unwrap_err();
13202        assert!(
13203            matches!(
13204                err,
13205                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13206            ),
13207            "got {err:?}",
13208        );
13209    }
13210
13211    #[test]
13212    fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
13213        // Cascade pin on the upstream shell-glob arm: a value
13214        // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
13215        // canonical "I pasted a `*.[ch]` C-source-file glob whose
13216        // unbounded `*` precedes the bracket character-class"
13217        // footgun) routes through `FonteCaminhoShellGlob` not
13218        // `FonteCaminhoShellBracketExpansion`. The unbounded
13219        // pathname-expansion sentinel is the load-bearing root-
13220        // cause edit on every probe-as-both value — the unbounded
13221        // `*` carries the more aggressive expansion vector than
13222        // the bounded `[ch]` class, so the prior arm wins.
13223        let d = dep_with_fonte(DepSource::Path {
13224            caminho: "../caixa-teia/*[ch]".into(),
13225        });
13226        let err = d.validate().unwrap_err();
13227        assert!(
13228            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13229            "got {err:?}",
13230        );
13231    }
13232
13233    #[test]
13234    fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
13235        // Cascade pin on the upstream shell-command-substitution
13236        // arm: a value carrying both a backtick and `[`
13237        // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
13238        // legacy-backtick command-substitution followed by a
13239        // glob-character-class tail" footgun) routes through
13240        // `FonteCaminhoShellCommandSubstitution` not
13241        // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
13242        // command-injection vector is the load-bearing root-cause
13243        // edit on every probe-as-both value.
13244        let d = dep_with_fonte(DepSource::Path {
13245            caminho: "../`whoami`/[ch]".into(),
13246        });
13247        let err = d.validate().unwrap_err();
13248        assert!(
13249            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13250            "got {err:?}",
13251        );
13252    }
13253
13254    #[test]
13255    fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
13256        // Cascade pin on the upstream shell-background arm: a
13257        // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
13258        // — the canonical "I pasted a `cmd & [glob]` background-
13259        // launch + bracket-class chain" footgun) routes through
13260        // `FonteCaminhoShellBackground` not
13261        // `FonteCaminhoShellBracketExpansion`. The background-
13262        // launch tail is the load-bearing root-cause edit on
13263        // every probe-as-both value.
13264        let d = dep_with_fonte(DepSource::Path {
13265            caminho: "../caixa-teia & [ch]".into(),
13266        });
13267        let err = d.validate().unwrap_err();
13268        assert!(
13269            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13270            "got {err:?}",
13271        );
13272    }
13273
13274    #[test]
13275    fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
13276        // Cascade pin on the upstream shell-semicolon arm: a value
13277        // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
13278        // canonical sequential-cleanup + bracket-class paste
13279        // idiom) routes through `FonteCaminhoShellSemicolon` not
13280        // `FonteCaminhoShellBracketExpansion`. The sequential-
13281        // command-separator paste is the load-bearing root-cause
13282        // edit on every probe-as-both value.
13283        let d = dep_with_fonte(DepSource::Path {
13284            caminho: "../caixa-teia; [ch]".into(),
13285        });
13286        let err = d.validate().unwrap_err();
13287        assert!(
13288            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13289            "got {err:?}",
13290        );
13291    }
13292
13293    #[test]
13294    fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
13295        // Cascade pin on the upstream shell-pipe arm: a value
13296        // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
13297        // the canonical pipeline-to-bracket-class paste idiom)
13298        // routes through `FonteCaminhoShellPipe` not
13299        // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
13300        // paste is the load-bearing root-cause edit on every
13301        // probe-as-both value.
13302        let d = dep_with_fonte(DepSource::Path {
13303            caminho: "../caixa-teia | [tee]".into(),
13304        });
13305        let err = d.validate().unwrap_err();
13306        assert!(
13307            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13308            "got {err:?}",
13309        );
13310    }
13311
13312    #[test]
13313    fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
13314        // Cascade pin on the upstream shell-redirection arm: a
13315        // value carrying both `>` and `[` (`"../caixa-teia>log
13316        // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
13317        // redirect-plus-bracket chain" footgun) routes through
13318        // `FonteCaminhoShellRedirection` not
13319        // `FonteCaminhoShellBracketExpansion`. The input/output
13320        // redirection metachar carries the more self-locating
13321        // `byte` payload, so the prior arm wins on every
13322        // probe-as-both value.
13323        let d = dep_with_fonte(DepSource::Path {
13324            caminho: "../caixa-teia>log [ch]".into(),
13325        });
13326        let err = d.validate().unwrap_err();
13327        assert!(
13328            matches!(
13329                err,
13330                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13331            ),
13332            "got {err:?}",
13333        );
13334    }
13335
13336    #[test]
13337    fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
13338        // Cascade pin on the upstream backslash arm: a value
13339        // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
13340        // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
13341        // chain") routes through `FonteCaminhoBackslash` not
13342        // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
13343        // separator divergence is the load-bearing axis on every
13344        // probe-as-both value.
13345        let d = dep_with_fonte(DepSource::Path {
13346            caminho: "..\\caixa-teia\\[ch]".into(),
13347        });
13348        let err = d.validate().unwrap_err();
13349        assert!(
13350            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13351            "got {err:?}",
13352        );
13353    }
13354
13355    #[test]
13356    fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
13357        // Cascade pin on the embedded-control-byte arm: a value
13358        // carrying both a control byte and `[` (`"../foo\n[ch]"` —
13359        // the canonical paste-from-multiline-doc footgun where a
13360        // newline landed mid-caminho between two paste fragments)
13361        // routes through `FonteCaminhoControlChar` not
13362        // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
13363        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13364        // the load-bearing axis on every value that probes
13365        // positive for both — mirrors the cascade discipline on
13366        // every prior arm.
13367        let d = dep_with_fonte(DepSource::Path {
13368            caminho: "../foo\n[ch]".into(),
13369        });
13370        let err = d.validate().unwrap_err();
13371        assert!(
13372            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13373            "got {err:?}",
13374        );
13375    }
13376
13377    #[test]
13378    fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
13379        // Cascade pin on the load-bearing leading-byte arm: a
13380        // leading `/` value with embedded `[` (`"/etc/[ch]"`)
13381        // routes through `FonteCaminhoAbsolute` not
13382        // `FonteCaminhoShellBracketExpansion` — the host-layout-
13383        // leak diagnostic is the load-bearing axis, the bracket-
13384        // expansion byte is the secondary observation. Same
13385        // precedence logic as every prior leading-byte arm.
13386        let d = dep_with_fonte(DepSource::Path {
13387            caminho: "/etc/[ch]".into(),
13388        });
13389        let err = d.validate().unwrap_err();
13390        assert!(
13391            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13392            "got {err:?}",
13393        );
13394    }
13395
13396    #[test]
13397    fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
13398        // Cascade pin on the upstream leading-`$` var-expansion
13399        // arm: a value carrying both a leading `$` and a `[`
13400        // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
13401        // variable + bracket-class at the head of a sibling-
13402        // workspace path" footgun) routes through
13403        // `FonteCaminhoVarExpansion` not
13404        // `FonteCaminhoShellBracketExpansion`. The leading-byte
13405        // shell-variable-expansion is the more self-locating
13406        // diagnostic on values that probe as both — same
13407        // load-bearing-leading-byte cascade discipline every
13408        // prior `:caminho` arm establishes.
13409        let d = dep_with_fonte(DepSource::Path {
13410            caminho: "$DIR/[ch]".into(),
13411        });
13412        let err = d.validate().unwrap_err();
13413        assert!(
13414            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13415            "got {err:?}",
13416        );
13417    }
13418
13419    #[test]
13420    fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
13421        // Cascade pin on the immediate-successor arm: a value
13422        // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
13423        // the canonical "I tab-completed a path that already had
13424        // a bracket-glob-character-class expansion tail" footgun)
13425        // routes through `FonteCaminhoShellBracketExpansion` not
13426        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13427        // is the more semantic-locating axis (an author who
13428        // removes the `[` typically also drops the trailing
13429        // separator since both are paste-from-shell artifacts).
13430        let d = dep_with_fonte(DepSource::Path {
13431            caminho: "../[a-z]/".into(),
13432        });
13433        let err = d.validate().unwrap_err();
13434        assert!(
13435            matches!(
13436                err,
13437                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13438            ),
13439            "got {err:?}",
13440        );
13441    }
13442
13443    #[test]
13444    fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13445        // Diagnostic-shape pin (peer with
13446        // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13447        // on the closest two-byte peer arm): the error's Display
13448        // surfaces the offending `:nome`, the offending `:caminho`
13449        // verbatim, the offending byte's hex / character form, and
13450        // names the shell-bracket-expansion / glob-character-class
13451        // footgun explicitly so a `feira lint` run can render the
13452        // diagnostic without re-parsing.
13453        let d = dep_with_fonte(DepSource::Path {
13454            caminho: "../caixa-[a-z]/build".into(),
13455        });
13456        let rendered = d.validate().unwrap_err().to_string();
13457        assert!(
13458            rendered.contains("caixa-teia"),
13459            "diagnostic must name the offending dep: {rendered}",
13460        );
13461        assert!(
13462            rendered.contains("../caixa-[a-z]/build"),
13463            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13464        );
13465        assert!(
13466            rendered.contains("0x5b"),
13467            "diagnostic must surface the offending byte hex: {rendered:?}",
13468        );
13469        assert!(
13470            rendered.contains("bracket-expansion"),
13471            "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
13472        );
13473        assert!(
13474            rendered.contains("glob-character-class"),
13475            "diagnostic must reference the POSIX glob-character-class vocabulary: \
13476             {rendered:?}",
13477        );
13478    }
13479
13480    #[test]
13481    fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
13482        // The canonical paste-from-shell-history strong-quoted
13483        // sibling-workspace-path footgun: an author copies a
13484        // `cd '../caixa-teia'` shell-history one-liner whose strong-
13485        // quoting preserved the path across a whitespace paste
13486        // boundary and silently passed every prior arm
13487        // (`Path::is_absolute` false on `'..`, no control bytes, no
13488        // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
13489        // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
13490        // doesn't end in `/`; the leading-`$` f4efe9c
13491        // `FonteCaminhoVarExpansion` arm doesn't fire because the
13492        // value starts with `'` not `$`). The lacre embedded the
13493        // value verbatim, the resolver folded it through
13494        // `Path::join` looking for a literal `./'../caixa-teia'`
13495        // subdirectory, and the failure surfaced at resolve time
13496        // with a non-self-locating `No such file or directory`
13497        // error. The new arm moves the rejection to validate time
13498        // and names the offending dep + caminho + byte verbatim.
13499        // The arm fires on the first `'` encountered.
13500        let d = dep_with_fonte(DepSource::Path {
13501            caminho: "'../caixa-teia'".into(),
13502        });
13503        let err = d.validate().unwrap_err();
13504        let DepError::FonteCaminhoShellQuoteGrouping {
13505            nome,
13506            caminho,
13507            byte,
13508        } = err
13509        else {
13510            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13511        };
13512        assert_eq!(nome, "caixa-teia");
13513        assert_eq!(caminho, "'../caixa-teia'");
13514        assert_eq!(byte, b'\'');
13515    }
13516
13517    #[test]
13518    fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
13519        // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
13520        // — the canonical paste-from-JSON-config / paste-from-YAML-
13521        // flow-scalar / paste-from-TOML-basic-string / paste-from-
13522        // tatara-lisp-string-literal cross-idiom leak). Pinned
13523        // separately from the single-quote shape so the gate's
13524        // contract is "any `'` or `\"` anywhere", not single-byte
13525        // coverage. Mirrors the peer
13526        // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
13527        // shape on the immediate-predecessor
13528        // `FonteCaminhoShellBracketExpansion` arm.
13529        let d = dep_with_fonte(DepSource::Path {
13530            caminho: "\"../caixa-teia\"".into(),
13531        });
13532        let err = d.validate().unwrap_err();
13533        let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
13534            panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
13535        };
13536        assert_eq!(byte, b'"');
13537    }
13538
13539    #[test]
13540    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
13541        // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13542        // canonical "I pasted a JSON key-value pair fragment into
13543        // the middle of the path" idiom). Pinned separately from
13544        // the leading-byte shape so the gate covers every position,
13545        // not only leading.
13546        let d = dep_with_fonte(DepSource::Path {
13547            caminho: "../\"caixa-teia\"".into(),
13548        });
13549        let err = d.validate().unwrap_err();
13550        assert!(
13551            matches!(
13552                err,
13553                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13554            ),
13555            "got {err:?}",
13556        );
13557    }
13558
13559    #[test]
13560    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13561        // The canonical YAML double-quoted flow-scalar cross-idiom
13562        // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13563        // `path: \"...\"` YAML flow-scalar entry out of an aligned
13564        // values.yaml / K8s manifest and dropped it verbatim into
13565        // the `:caminho` slot including the `path: ` key prefix"
13566        // paste-idiom). The arm fires on the first `"` encountered;
13567        // pinned so the gate's coverage extends from the bare-quote
13568        // paste shape to the aligned-YAML-manifest cross-idiom-leak
13569        // shape.
13570        let d = dep_with_fonte(DepSource::Path {
13571            caminho: "path: \"../caixa-teia\"".into(),
13572        });
13573        let err = d.validate().unwrap_err();
13574        assert!(
13575            matches!(
13576                err,
13577                DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13578            ),
13579            "got {err:?}",
13580        );
13581    }
13582
13583    #[test]
13584    fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13585        // The positive-control pin: the gate targets only `'` /
13586        // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13587        // The canonical relative POSIX path (`"../caixa-teia"`) and
13588        // a nested deeply-pathed variant with adjacent printable
13589        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13590        // to validate cleanly so the gate doesn't widen to a "no
13591        // printable punctuation anywhere" sweep that would defeat
13592        // the entire path-fonte author surface. Peer with
13593        // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13594        // on the immediate-predecessor arm.
13595        let d = dep_with_fonte(DepSource::Path {
13596            caminho: "../caixa-teia/sub-dir.v2".into(),
13597        });
13598        d.validate().unwrap();
13599    }
13600
13601    #[test]
13602    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13603        // Cascade pin on the immediate-predecessor arm: a value
13604        // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13605        // "I pasted a glob-character-class followed by a strong-
13606        // quoted literal tail" footgun) routes through
13607        // `FonteCaminhoShellBracketExpansion` not
13608        // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13609        // expansion is the load-bearing root-cause edit on every
13610        // probe-as-both value; same cascade discipline every prior
13611        // `:caminho` arm establishes.
13612        let d = dep_with_fonte(DepSource::Path {
13613            caminho: "../[a-z]'x'".into(),
13614        });
13615        let err = d.validate().unwrap_err();
13616        assert!(
13617            matches!(
13618                err,
13619                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13620            ),
13621            "got {err:?}",
13622        );
13623    }
13624
13625    #[test]
13626    fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13627        // Cascade pin on the upstream shell-brace-expansion arm: a
13628        // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13629        // canonical "I pasted a brace-expansion fan followed by a
13630        // strong-quoted literal tail" footgun) routes through
13631        // `FonteCaminhoShellBraceExpansion` not
13632        // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13633        // is the load-bearing root-cause edit on every probe-as-
13634        // both value.
13635        let d = dep_with_fonte(DepSource::Path {
13636            caminho: "../{a,b}'x'".into(),
13637        });
13638        let err = d.validate().unwrap_err();
13639        assert!(
13640            matches!(
13641                err,
13642                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13643            ),
13644            "got {err:?}",
13645        );
13646    }
13647
13648    #[test]
13649    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13650        // Cascade pin on the upstream shell-subshell-grouping arm:
13651        // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13652        // the canonical "I pasted a subshell-grouping followed by
13653        // a strong-quoted literal tail" footgun) routes through
13654        // `FonteCaminhoShellSubshellGrouping` not
13655        // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13656        // `$(<cmd>)` command-substitution boundary is the load-
13657        // bearing axis on every probe-as-both value.
13658        let d = dep_with_fonte(DepSource::Path {
13659            caminho: "../(cd foo)/'x'".into(),
13660        });
13661        let err = d.validate().unwrap_err();
13662        assert!(
13663            matches!(
13664                err,
13665                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13666            ),
13667            "got {err:?}",
13668        );
13669    }
13670
13671    #[test]
13672    fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13673        // Cascade pin on the upstream shell-glob arm: a value
13674        // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13675        // canonical "I pasted a `*` unbounded pathname-expansion
13676        // followed by a strong-quoted literal tail" footgun) routes
13677        // through `FonteCaminhoShellGlob` not
13678        // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13679        // expansion sentinel is the load-bearing root-cause edit
13680        // on every probe-as-both value.
13681        let d = dep_with_fonte(DepSource::Path {
13682            caminho: "../caixa-teia/*'x'".into(),
13683        });
13684        let err = d.validate().unwrap_err();
13685        assert!(
13686            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13687            "got {err:?}",
13688        );
13689    }
13690
13691    #[test]
13692    fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13693        // Cascade pin on the upstream shell-command-substitution
13694        // arm: a value carrying both a backtick and `'`
13695        // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13696        // legacy-backtick command-substitution followed by a
13697        // strong-quoted literal tail" footgun) routes through
13698        // `FonteCaminhoShellCommandSubstitution` not
13699        // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13700        // command-injection vector is the load-bearing root-cause
13701        // edit on every probe-as-both value.
13702        let d = dep_with_fonte(DepSource::Path {
13703            caminho: "../`whoami`/'x'".into(),
13704        });
13705        let err = d.validate().unwrap_err();
13706        assert!(
13707            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13708            "got {err:?}",
13709        );
13710    }
13711
13712    #[test]
13713    fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13714        // Cascade pin on the upstream shell-background arm: a value
13715        // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13716        // canonical "I pasted a `cmd & 'literal'` background-launch
13717        // + quote chain" footgun) routes through
13718        // `FonteCaminhoShellBackground` not
13719        // `FonteCaminhoShellQuoteGrouping`. The background-launch
13720        // tail is the load-bearing root-cause edit on every
13721        // probe-as-both value.
13722        let d = dep_with_fonte(DepSource::Path {
13723            caminho: "../caixa-teia & 'x'".into(),
13724        });
13725        let err = d.validate().unwrap_err();
13726        assert!(
13727            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13728            "got {err:?}",
13729        );
13730    }
13731
13732    #[test]
13733    fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13734        // Cascade pin on the upstream shell-semicolon arm: a value
13735        // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13736        // canonical sequential-cleanup + quote paste idiom) routes
13737        // through `FonteCaminhoShellSemicolon` not
13738        // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13739        // separator paste is the load-bearing root-cause edit on
13740        // every probe-as-both value.
13741        let d = dep_with_fonte(DepSource::Path {
13742            caminho: "../caixa-teia; 'x'".into(),
13743        });
13744        let err = d.validate().unwrap_err();
13745        assert!(
13746            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13747            "got {err:?}",
13748        );
13749    }
13750
13751    #[test]
13752    fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13753        // Cascade pin on the upstream shell-pipe arm: a value
13754        // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13755        // canonical pipeline-to-quoted-literal paste idiom) routes
13756        // through `FonteCaminhoShellPipe` not
13757        // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13758        // is the load-bearing root-cause edit on every probe-as-
13759        // both value.
13760        let d = dep_with_fonte(DepSource::Path {
13761            caminho: "../caixa-teia | 'x'".into(),
13762        });
13763        let err = d.validate().unwrap_err();
13764        assert!(
13765            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13766            "got {err:?}",
13767        );
13768    }
13769
13770    #[test]
13771    fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13772        // Cascade pin on the upstream shell-redirection arm: a
13773        // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13774        // — the canonical "I pasted a `cmd > log 'literal'`
13775        // redirect-plus-quote chain" footgun) routes through
13776        // `FonteCaminhoShellRedirection` not
13777        // `FonteCaminhoShellQuoteGrouping`. The input/output
13778        // redirection metachar carries the more self-locating
13779        // `byte` payload, so the prior arm wins on every probe-as-
13780        // both value.
13781        let d = dep_with_fonte(DepSource::Path {
13782            caminho: "../caixa-teia>log 'x'".into(),
13783        });
13784        let err = d.validate().unwrap_err();
13785        assert!(
13786            matches!(
13787                err,
13788                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13789            ),
13790            "got {err:?}",
13791        );
13792    }
13793
13794    #[test]
13795    fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13796        // Cascade pin on the upstream backslash arm: a value
13797        // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13798        // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13799        // chain" footgun) routes through `FonteCaminhoBackslash`
13800        // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13801        // separator divergence is the load-bearing axis on every
13802        // probe-as-both value.
13803        let d = dep_with_fonte(DepSource::Path {
13804            caminho: "..\\caixa-teia\\'x'".into(),
13805        });
13806        let err = d.validate().unwrap_err();
13807        assert!(
13808            matches!(err, DepError::FonteCaminhoBackslash { .. }),
13809            "got {err:?}",
13810        );
13811    }
13812
13813    #[test]
13814    fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13815        // Cascade pin on the embedded-control-byte arm: a value
13816        // carrying both a control byte and `'` (`"../foo\n'x'"` —
13817        // the canonical paste-from-multiline-doc footgun where a
13818        // newline landed mid-caminho between two paste fragments)
13819        // routes through `FonteCaminhoControlChar` not
13820        // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13821        // rejected-byte / NUL-`CString::new`-fail diagnostic is
13822        // the load-bearing axis on every value that probes
13823        // positive for both — mirrors the cascade discipline on
13824        // every prior arm.
13825        let d = dep_with_fonte(DepSource::Path {
13826            caminho: "../foo\n'x'".into(),
13827        });
13828        let err = d.validate().unwrap_err();
13829        assert!(
13830            matches!(err, DepError::FonteCaminhoControlChar { .. }),
13831            "got {err:?}",
13832        );
13833    }
13834
13835    #[test]
13836    fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13837        // Cascade pin on the load-bearing leading-byte arm: a
13838        // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13839        // through `FonteCaminhoAbsolute` not
13840        // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13841        // diagnostic is the load-bearing axis, the quote byte is
13842        // the secondary observation. Same precedence logic as every
13843        // prior leading-byte arm.
13844        let d = dep_with_fonte(DepSource::Path {
13845            caminho: "/etc/'x'".into(),
13846        });
13847        let err = d.validate().unwrap_err();
13848        assert!(
13849            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13850            "got {err:?}",
13851        );
13852    }
13853
13854    #[test]
13855    fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13856        // Cascade pin on the upstream leading-`$` var-expansion
13857        // arm: a value carrying both a leading `$` and a `'`
13858        // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13859        // variable + quoted literal at the head of a sibling-
13860        // workspace path" footgun) routes through
13861        // `FonteCaminhoVarExpansion` not
13862        // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13863        // shell-variable-expansion is the more self-locating
13864        // diagnostic on values that probe as both — same
13865        // load-bearing-leading-byte cascade discipline every
13866        // prior `:caminho` arm establishes.
13867        let d = dep_with_fonte(DepSource::Path {
13868            caminho: "$DIR/'x'".into(),
13869        });
13870        let err = d.validate().unwrap_err();
13871        assert!(
13872            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13873            "got {err:?}",
13874        );
13875    }
13876
13877    #[test]
13878    fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13879        // Cascade pin on the immediate-successor arm: a value
13880        // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13881        // — the canonical "I tab-completed a path whose strong-
13882        // quoted body already carried the quoting from a shell-
13883        // history paste" footgun) routes through
13884        // `FonteCaminhoShellQuoteGrouping` not
13885        // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13886        // is the more semantic-locating axis (an author who removes
13887        // the `'` typically also drops the trailing separator since
13888        // both are paste-from-shell artifacts).
13889        let d = dep_with_fonte(DepSource::Path {
13890            caminho: "../'caixa-teia'/".into(),
13891        });
13892        let err = d.validate().unwrap_err();
13893        assert!(
13894            matches!(
13895                err,
13896                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13897            ),
13898            "got {err:?}",
13899        );
13900    }
13901
13902    #[test]
13903    fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13904        // Diagnostic-shape pin (peer with
13905        // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13906        // on the closest two-byte peer arm): the error's Display
13907        // surfaces the offending `:nome`, the offending `:caminho`
13908        // verbatim, the offending byte's hex / character form, and
13909        // names the shell-quote-grouping / cross-config-DSL-string-
13910        // literal-delimiter footgun explicitly so a `feira lint`
13911        // run can render the diagnostic without re-parsing.
13912        let d = dep_with_fonte(DepSource::Path {
13913            caminho: "'../caixa-teia'".into(),
13914        });
13915        let rendered = d.validate().unwrap_err().to_string();
13916        assert!(
13917            rendered.contains("caixa-teia"),
13918            "diagnostic must name the offending dep: {rendered}",
13919        );
13920        assert!(
13921            rendered.contains("'../caixa-teia'"),
13922            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13923        );
13924        assert!(
13925            rendered.contains("0x27"),
13926            "diagnostic must surface the offending byte hex: {rendered:?}",
13927        );
13928        assert!(
13929            rendered.contains("quote-grouping"),
13930            "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13931        );
13932        assert!(
13933            rendered.contains("string-literal"),
13934            "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13935             vocabulary: {rendered:?}",
13936        );
13937    }
13938
13939    #[test]
13940    fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13941        // The canonical paste-from-shell-history-with-trailing-
13942        // annotation footgun: an author pastes a `cd ../caixa-teia
13943        // # legacy sibling` shell-history one-liner whose unquoted `#`
13944        // comment-lead separates the path from an inline annotation.
13945        // The POSIX shell trims the annotation to `../caixa-teia`
13946        // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13947        // `Path::is_absolute` returns false on `..`, `#` is neither
13948        // a leading-byte sentinel nor a control byte nor `\` nor
13949        // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13950        // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13951        // `"`, and the value's last byte isn't `/` — so the value
13952        // silently passed every prior arm. The resolver folded the
13953        // value through `Path::join` looking for a literal
13954        // `./../caixa-teia # legacy sibling` subdirectory and the
13955        // failure surfaced at resolve time with a non-self-locating
13956        // `No such file or directory` error. The new arm moves the
13957        // rejection to validate time and names the offending dep +
13958        // caminho + byte verbatim.
13959        let d = dep_with_fonte(DepSource::Path {
13960            caminho: "../caixa-teia # legacy sibling".into(),
13961        });
13962        let err = d.validate().unwrap_err();
13963        let DepError::FonteCaminhoShellComment {
13964            nome,
13965            caminho,
13966            byte,
13967        } = err
13968        else {
13969            panic!("expected FonteCaminhoShellComment, got {err:?}");
13970        };
13971        assert_eq!(nome, "caixa-teia");
13972        assert_eq!(caminho, "../caixa-teia # legacy sibling");
13973        assert_eq!(byte, b'#');
13974    }
13975
13976    #[test]
13977    fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13978        // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13979        // cross-idiom-leak shape (`"../caixa-teia  # pin"` — the
13980        // canonical "I copied a `path: ../caixa-teia  # pin` YAML
13981        // scalar-plus-comment entry out of an aligned values.yaml and
13982        // dropped it verbatim into the `:caminho` slot" paste-idiom).
13983        // Pinned separately from the shell-history shape so the
13984        // gate's coverage extends from the single-space `#` shape to
13985        // the YAML-canonical double-space `  #` shape. YAML 1.2 §6.6
13986        // requires the `#` to be preceded by whitespace to lex as a
13987        // comment (bare `foo#bar` is a single scalar); the double-
13988        // space paste from an aligned manifest is the canonical
13989        // shape.
13990        let d = dep_with_fonte(DepSource::Path {
13991            caminho: "../caixa-teia  # pin".into(),
13992        });
13993        let err = d.validate().unwrap_err();
13994        assert!(
13995            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13996            "got {err:?}",
13997        );
13998    }
13999
14000    #[test]
14001    fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
14002        // The URL-fragment-identifier paste shape
14003        // (`"../caixa-teia#readme"` — the canonical
14004        // paste-from-browser-address-bar permalink shape where the
14005        // browser preserved the `#anchor` tail on the copy). Pinned
14006        // separately from the whitespace-separated shell / YAML
14007        // comment shapes so the gate covers the unpadded RFC 3986
14008        // §3.5 fragment-delimiter position too, not only positions
14009        // preceded by unquoted whitespace. Peer with the immediate-
14010        // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
14011        // (a68f818) which closes the same byte under the same URL-
14012        // fragment-identifier banner.
14013        let d = dep_with_fonte(DepSource::Path {
14014            caminho: "../caixa-teia#readme".into(),
14015        });
14016        let err = d.validate().unwrap_err();
14017        assert!(
14018            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14019            "got {err:?}",
14020        );
14021    }
14022
14023    #[test]
14024    fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
14025        // Leading-position `#` shape (`"#../caixa-teia"` — the
14026        // "I copied a shell-comment-out entry from a commented-out
14027        // dep row" footgun). Pinned separately from the embedded
14028        // shapes so the gate covers every position, not only
14029        // whitespace-preceded / mid-value.
14030        let d = dep_with_fonte(DepSource::Path {
14031            caminho: "#../caixa-teia".into(),
14032        });
14033        let err = d.validate().unwrap_err();
14034        assert!(
14035            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14036            "got {err:?}",
14037        );
14038    }
14039
14040    #[test]
14041    fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
14042        // The positive-control pin: the gate targets only `#`,
14043        // never adjacent printable ASCII or POSIX-valid bytes. The
14044        // canonical relative POSIX path (`"../caixa-teia"`) and a
14045        // nested deeply-pathed variant with adjacent printable
14046        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14047        // to validate cleanly so the gate doesn't widen to a "no
14048        // printable punctuation anywhere" sweep that would defeat
14049        // the entire path-fonte author surface. Peer with
14050        // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
14051        // on the immediate-predecessor arm.
14052        let d = dep_with_fonte(DepSource::Path {
14053            caminho: "../caixa-teia/sub-dir.v2".into(),
14054        });
14055        d.validate().unwrap();
14056    }
14057
14058    #[test]
14059    fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
14060        // Cascade pin on the immediate-predecessor arm: a value
14061        // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
14062        // "I pasted a strong-quoted literal followed by a URL-
14063        // fragment permalink tail" footgun) routes through
14064        // `FonteCaminhoShellQuoteGrouping` not
14065        // `FonteCaminhoShellComment`. The shell-string-literal-
14066        // delimiter is the load-bearing root-cause edit on every
14067        // probe-as-both value; same cascade discipline every prior
14068        // `:caminho` arm establishes.
14069        let d = dep_with_fonte(DepSource::Path {
14070            caminho: "../'x'#pin".into(),
14071        });
14072        let err = d.validate().unwrap_err();
14073        assert!(
14074            matches!(
14075                err,
14076                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14077            ),
14078            "got {err:?}",
14079        );
14080    }
14081
14082    #[test]
14083    fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
14084        // Cascade pin on the upstream shell-bracket-expansion arm:
14085        // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
14086        // canonical "I pasted a glob-character-class followed by a
14087        // URL-fragment tail" footgun) routes through
14088        // `FonteCaminhoShellBracketExpansion` not
14089        // `FonteCaminhoShellComment`. The glob-character-class
14090        // expansion is the load-bearing root-cause edit on every
14091        // probe-as-both value.
14092        let d = dep_with_fonte(DepSource::Path {
14093            caminho: "../[a-z]#pin".into(),
14094        });
14095        let err = d.validate().unwrap_err();
14096        assert!(
14097            matches!(
14098                err,
14099                DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
14100            ),
14101            "got {err:?}",
14102        );
14103    }
14104
14105    #[test]
14106    fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
14107        // Cascade pin on the upstream shell-brace-expansion arm: a
14108        // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
14109        // canonical "I pasted a brace-expansion fan followed by a
14110        // URL-fragment tail" footgun) routes through
14111        // `FonteCaminhoShellBraceExpansion` not
14112        // `FonteCaminhoShellComment`. The brace-expansion fan is the
14113        // load-bearing root-cause edit on every probe-as-both value.
14114        let d = dep_with_fonte(DepSource::Path {
14115            caminho: "../{a,b}#pin".into(),
14116        });
14117        let err = d.validate().unwrap_err();
14118        assert!(
14119            matches!(
14120                err,
14121                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
14122            ),
14123            "got {err:?}",
14124        );
14125    }
14126
14127    #[test]
14128    fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
14129        // Cascade pin on the upstream shell-subshell-grouping arm:
14130        // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
14131        // the canonical "I pasted a subshell-grouping followed by a
14132        // URL-fragment tail" footgun) routes through
14133        // `FonteCaminhoShellSubshellGrouping` not
14134        // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
14135        // command-substitution boundary is the load-bearing axis on
14136        // every probe-as-both value.
14137        let d = dep_with_fonte(DepSource::Path {
14138            caminho: "../(cd foo)#pin".into(),
14139        });
14140        let err = d.validate().unwrap_err();
14141        assert!(
14142            matches!(
14143                err,
14144                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
14145            ),
14146            "got {err:?}",
14147        );
14148    }
14149
14150    #[test]
14151    fn fonte_caminho_shell_glob_fires_before_shell_comment() {
14152        // Cascade pin on the upstream shell-glob arm: a value
14153        // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
14154        // canonical "I pasted a `*` unbounded pathname-expansion
14155        // followed by a URL-fragment tail" footgun) routes through
14156        // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
14157        // The unbounded pathname-expansion sentinel is the load-
14158        // bearing root-cause edit on every probe-as-both value.
14159        let d = dep_with_fonte(DepSource::Path {
14160            caminho: "../caixa-teia/*#pin".into(),
14161        });
14162        let err = d.validate().unwrap_err();
14163        assert!(
14164            matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
14165            "got {err:?}",
14166        );
14167    }
14168
14169    #[test]
14170    fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
14171        // Cascade pin on the upstream shell-command-substitution
14172        // arm: a value carrying both a backtick and `#`
14173        // (``"../`whoami`#pin"`` — the canonical "I pasted a
14174        // legacy-backtick command-substitution followed by a URL-
14175        // fragment tail" footgun) routes through
14176        // `FonteCaminhoShellCommandSubstitution` not
14177        // `FonteCaminhoShellComment`. The CWE-78 shell-command-
14178        // injection vector is the load-bearing root-cause edit on
14179        // every probe-as-both value.
14180        let d = dep_with_fonte(DepSource::Path {
14181            caminho: "../`whoami`#pin".into(),
14182        });
14183        let err = d.validate().unwrap_err();
14184        assert!(
14185            matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
14186            "got {err:?}",
14187        );
14188    }
14189
14190    #[test]
14191    fn fonte_caminho_shell_background_fires_before_shell_comment() {
14192        // Cascade pin on the upstream shell-background arm: a value
14193        // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
14194        // the canonical "I pasted a `cmd &` background-launch
14195        // followed by a URL-fragment tail" footgun) routes through
14196        // `FonteCaminhoShellBackground` not
14197        // `FonteCaminhoShellComment`. The background-launch tail is
14198        // the load-bearing root-cause edit on every probe-as-both
14199        // value.
14200        let d = dep_with_fonte(DepSource::Path {
14201            caminho: "../caixa-teia&pin#tail".into(),
14202        });
14203        let err = d.validate().unwrap_err();
14204        assert!(
14205            matches!(err, DepError::FonteCaminhoShellBackground { .. }),
14206            "got {err:?}",
14207        );
14208    }
14209
14210    #[test]
14211    fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
14212        // Cascade pin on the upstream shell-semicolon arm: a value
14213        // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
14214        // the canonical sequential-cleanup + URL-fragment paste
14215        // idiom) routes through `FonteCaminhoShellSemicolon` not
14216        // `FonteCaminhoShellComment`. The sequential-command-
14217        // separator paste is the load-bearing root-cause edit on
14218        // every probe-as-both value.
14219        let d = dep_with_fonte(DepSource::Path {
14220            caminho: "../caixa-teia;pin#tail".into(),
14221        });
14222        let err = d.validate().unwrap_err();
14223        assert!(
14224            matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
14225            "got {err:?}",
14226        );
14227    }
14228
14229    #[test]
14230    fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
14231        // Cascade pin on the upstream shell-pipe arm: a value
14232        // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
14233        // the canonical pipeline-to-URL-fragment paste idiom) routes
14234        // through `FonteCaminhoShellPipe` not
14235        // `FonteCaminhoShellComment`. The pipeline-tail paste is
14236        // the load-bearing root-cause edit on every probe-as-both
14237        // value.
14238        let d = dep_with_fonte(DepSource::Path {
14239            caminho: "../caixa-teia|pin#tail".into(),
14240        });
14241        let err = d.validate().unwrap_err();
14242        assert!(
14243            matches!(err, DepError::FonteCaminhoShellPipe { .. }),
14244            "got {err:?}",
14245        );
14246    }
14247
14248    #[test]
14249    fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
14250        // Cascade pin on the upstream shell-redirection arm: a
14251        // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
14252        // — the canonical "I pasted a `cmd > log` redirect followed
14253        // by a URL-fragment tail" footgun) routes through
14254        // `FonteCaminhoShellRedirection` not
14255        // `FonteCaminhoShellComment`. The input/output redirection
14256        // metachar carries the more self-locating `byte` payload,
14257        // so the prior arm wins on every probe-as-both value.
14258        let d = dep_with_fonte(DepSource::Path {
14259            caminho: "../caixa-teia>log#pin".into(),
14260        });
14261        let err = d.validate().unwrap_err();
14262        assert!(
14263            matches!(
14264                err,
14265                DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
14266            ),
14267            "got {err:?}",
14268        );
14269    }
14270
14271    #[test]
14272    fn fonte_caminho_backslash_fires_before_shell_comment() {
14273        // Cascade pin on the upstream backslash arm: a value
14274        // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
14275        // canonical "I pasted a Windows-shell path followed by a
14276        // URL-fragment tail" footgun) routes through
14277        // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
14278        // The cross-host-OS-separator divergence is the load-
14279        // bearing axis on every probe-as-both value.
14280        let d = dep_with_fonte(DepSource::Path {
14281            caminho: "..\\caixa-teia#pin".into(),
14282        });
14283        let err = d.validate().unwrap_err();
14284        assert!(
14285            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14286            "got {err:?}",
14287        );
14288    }
14289
14290    #[test]
14291    fn fonte_caminho_control_char_fires_before_shell_comment() {
14292        // Cascade pin on the embedded-control-byte arm: a value
14293        // carrying both a control byte and `#` (`"../foo\n#pin"` —
14294        // the canonical paste-from-multiline-doc footgun where a
14295        // newline landed mid-caminho between the path and an
14296        // annotation) routes through `FonteCaminhoControlChar` not
14297        // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
14298        // byte diagnostic is the load-bearing axis on every value
14299        // that probes positive for both — mirrors the cascade
14300        // discipline on every prior arm.
14301        let d = dep_with_fonte(DepSource::Path {
14302            caminho: "../foo\n#pin".into(),
14303        });
14304        let err = d.validate().unwrap_err();
14305        assert!(
14306            matches!(err, DepError::FonteCaminhoControlChar { .. }),
14307            "got {err:?}",
14308        );
14309    }
14310
14311    #[test]
14312    fn fonte_caminho_absolute_fires_before_shell_comment() {
14313        // Cascade pin on the load-bearing leading-byte arm: a
14314        // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
14315        // routes through `FonteCaminhoAbsolute` not
14316        // `FonteCaminhoShellComment` — the host-layout-leak
14317        // diagnostic is the load-bearing axis, the fragment byte is
14318        // the secondary observation. Same precedence logic as every
14319        // prior leading-byte arm.
14320        let d = dep_with_fonte(DepSource::Path {
14321            caminho: "/etc/foo#pin".into(),
14322        });
14323        let err = d.validate().unwrap_err();
14324        assert!(
14325            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14326            "got {err:?}",
14327        );
14328    }
14329
14330    #[test]
14331    fn fonte_caminho_var_expansion_fires_before_shell_comment() {
14332        // Cascade pin on the upstream leading-`$` var-expansion
14333        // arm: a value carrying both a leading `$` and a `#`
14334        // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
14335        // shell-variable at the head of a sibling-workspace path
14336        // followed by a URL-fragment tail" footgun) routes through
14337        // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
14338        // The leading-byte shell-variable-expansion is the more
14339        // self-locating diagnostic on values that probe as both.
14340        let d = dep_with_fonte(DepSource::Path {
14341            caminho: "$DIR/foo#pin".into(),
14342        });
14343        let err = d.validate().unwrap_err();
14344        assert!(
14345            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14346            "got {err:?}",
14347        );
14348    }
14349
14350    #[test]
14351    fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
14352        // Cascade pin on the immediate-successor arm: a value
14353        // carrying both `#` and a trailing `/`
14354        // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
14355        // a URL-fragment-carrying path" footgun) routes through
14356        // `FonteCaminhoShellComment` not
14357        // `FonteCaminhoTrailingSlash`. The embedded fragment /
14358        // comment-lead byte is the more semantic-locating axis (an
14359        // author who removes the `#pin` fragment typically also
14360        // drops the trailing separator since both are paste-from-
14361        // URL / paste-from-shell-tab-completion artifacts).
14362        let d = dep_with_fonte(DepSource::Path {
14363            caminho: "../caixa-teia#pin/".into(),
14364        });
14365        let err = d.validate().unwrap_err();
14366        assert!(
14367            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
14368            "got {err:?}",
14369        );
14370    }
14371
14372    #[test]
14373    fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
14374        // Diagnostic-shape pin (peer with
14375        // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
14376        // on the immediate-predecessor arm): the error's Display
14377        // surfaces the offending `:nome`, the offending `:caminho`
14378        // verbatim, the offending byte's hex / character form, and
14379        // names the shell-comment / URL-fragment-identifier /
14380        // YAML-comment cross-config-DSL footgun explicitly so a
14381        // `feira lint` run can render the diagnostic without
14382        // re-parsing.
14383        let d = dep_with_fonte(DepSource::Path {
14384            caminho: "../caixa-teia#readme".into(),
14385        });
14386        let rendered = d.validate().unwrap_err().to_string();
14387        assert!(
14388            rendered.contains("caixa-teia"),
14389            "diagnostic must name the offending dep: {rendered}",
14390        );
14391        assert!(
14392            rendered.contains("../caixa-teia#readme"),
14393            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14394        );
14395        assert!(
14396            rendered.contains("0x23"),
14397            "diagnostic must surface the offending byte hex: {rendered:?}",
14398        );
14399        assert!(
14400            rendered.contains("shell-comment") || rendered.contains("comment-lead"),
14401            "diagnostic must name the shell-comment footgun: {rendered:?}",
14402        );
14403        assert!(
14404            rendered.contains("fragment") || rendered.contains("URL-fragment"),
14405            "diagnostic must reference the URL-fragment-identifier vocabulary: \
14406             {rendered:?}",
14407        );
14408    }
14409
14410    #[test]
14411    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
14412        // The canonical paste-from-browser-address-bar percent-
14413        // encoded-space footgun: an author copies `../caixa%20teia`
14414        // out of a URL-encoded README hyperlink / browser address
14415        // bar / percent-encoded permalink expecting `%20` to decode
14416        // to a literal space at the filesystem layer. POSIX
14417        // `std::path::Path` treats `%` as a literal path-component
14418        // byte, so `Path::join` looks for a literal
14419        // `./../caixa%20teia` subdirectory. `Path::is_absolute`
14420        // returns false on `..`, `%` is neither a leading-byte
14421        // sentinel nor a control byte nor `\` nor `<` / `>` nor
14422        // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
14423        // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
14424        // and the value's last byte isn't `/` — so the value
14425        // silently passed every prior arm. The new arm moves the
14426        // rejection to validate time and names the offending dep +
14427        // caminho + byte verbatim.
14428        let d = dep_with_fonte(DepSource::Path {
14429            caminho: "../caixa%20teia".into(),
14430        });
14431        let err = d.validate().unwrap_err();
14432        let DepError::FonteCaminhoUrlPercentEncoding {
14433            nome,
14434            caminho,
14435            byte,
14436        } = err
14437        else {
14438            panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
14439        };
14440        assert_eq!(nome, "caixa-teia");
14441        assert_eq!(caminho, "../caixa%20teia");
14442        assert_eq!(byte, b'%');
14443    }
14444
14445    #[test]
14446    fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
14447        // The over-encoded path-separator shape (`"../caixa%2Fteia"`
14448        // intending the `%2F` as the URL encoding of `/`) locks a
14449        // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
14450        // the byte-identical `path:../caixa/teia` form. Pinned
14451        // separately from the space-encoded shape so the gate's
14452        // coverage extends past the single canonical `%20` example
14453        // to any two-hex-digit percent-encoded sequence.
14454        let d = dep_with_fonte(DepSource::Path {
14455            caminho: "../caixa%2Fteia".into(),
14456        });
14457        let err = d.validate().unwrap_err();
14458        assert!(
14459            matches!(
14460                err,
14461                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14462            ),
14463            "got {err:?}",
14464        );
14465    }
14466
14467    #[test]
14468    fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
14469        // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
14470        // where `%` isn't followed by two hex digits) — every
14471        // WHATWG-conformant URL parser rejects the value at parse
14472        // time per RFC 3986 §2.1, but the byte would silently ride
14473        // into the lacre before the resolver subprocess crosses the
14474        // URL-parser boundary. Pinned separately from the well-
14475        // formed `%HH` shapes so the gate covers every percent-
14476        // occurrence, not only strictly-conformant escapes.
14477        let d = dep_with_fonte(DepSource::Path {
14478            caminho: "../caixa-teia%foo".into(),
14479        });
14480        let err = d.validate().unwrap_err();
14481        assert!(
14482            matches!(
14483                err,
14484                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14485            ),
14486            "got {err:?}",
14487        );
14488    }
14489
14490    #[test]
14491    fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
14492        // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
14493        // — the canonical paste-from-top-of-doc YAML directive
14494        // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
14495        // separately from embedded shapes so the gate covers the
14496        // leading-position `%` too, not only mid-value occurrences.
14497        let d = dep_with_fonte(DepSource::Path {
14498            caminho: "%YAML/../caixa-teia".into(),
14499        });
14500        let err = d.validate().unwrap_err();
14501        assert!(
14502            matches!(
14503                err,
14504                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14505            ),
14506            "got {err:?}",
14507        );
14508    }
14509
14510    #[test]
14511    fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
14512        // The printf-format-specifier paste shape
14513        // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
14514        // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
14515        // 134 format-string-injection vector). Pinned separately
14516        // from the URL-encoding shapes so the gate's rationale
14517        // extends past the RFC 3986 axis to the C / POSIX printf
14518        // format-directive-lead axis.
14519        let d = dep_with_fonte(DepSource::Path {
14520            caminho: "../caixa-%s-teia".into(),
14521        });
14522        let err = d.validate().unwrap_err();
14523        assert!(
14524            matches!(
14525                err,
14526                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14527            ),
14528            "got {err:?}",
14529        );
14530    }
14531
14532    #[test]
14533    fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
14534        // The positive-control pin: the gate targets only `%`,
14535        // never adjacent printable ASCII or POSIX-valid bytes. The
14536        // canonical relative POSIX path (`"../caixa-teia"`) and a
14537        // nested deeply-pathed variant with adjacent printable
14538        // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
14539        // to validate cleanly so the gate doesn't widen to a "no
14540        // printable punctuation anywhere" sweep that would defeat
14541        // the entire path-fonte author surface. Peer with
14542        // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14543        // on the immediate-predecessor arm.
14544        let d = dep_with_fonte(DepSource::Path {
14545            caminho: "../caixa-teia/sub-dir.v2".into(),
14546        });
14547        d.validate().unwrap();
14548    }
14549
14550    #[test]
14551    fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14552        // Cascade pin on the immediate-predecessor arm: a value
14553        // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14554        // canonical "I pasted a URL-fragment permalink followed by a
14555        // percent-encoded space tail" footgun) routes through
14556        // `FonteCaminhoShellComment` not
14557        // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14558        // identifier is the load-bearing downstream-truncation edit
14559        // on every probe-as-both value; same cascade discipline
14560        // every prior `:caminho` arm establishes.
14561        let d = dep_with_fonte(DepSource::Path {
14562            caminho: "../caixa-teia#pin%20".into(),
14563        });
14564        let err = d.validate().unwrap_err();
14565        assert!(
14566            matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14567            "got {err:?}",
14568        );
14569    }
14570
14571    #[test]
14572    fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14573        // Cascade pin on the upstream shell-quote-grouping arm: a
14574        // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14575        // canonical "I pasted a strong-quoted literal followed by
14576        // a percent-encoded space" footgun) routes through
14577        // `FonteCaminhoShellQuoteGrouping` not
14578        // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14579        // literal-delimiter is the load-bearing root-cause edit on
14580        // every probe-as-both value.
14581        let d = dep_with_fonte(DepSource::Path {
14582            caminho: "../'x'%20teia".into(),
14583        });
14584        let err = d.validate().unwrap_err();
14585        assert!(
14586            matches!(
14587                err,
14588                DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14589            ),
14590            "got {err:?}",
14591        );
14592    }
14593
14594    #[test]
14595    fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14596        // Cascade pin on the upstream backslash arm: a value
14597        // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14598        // canonical "I pasted a Windows-shell path followed by a
14599        // percent-encoded space" footgun) routes through
14600        // `FonteCaminhoBackslash` not
14601        // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14602        // separator divergence is the load-bearing root-cause edit
14603        // on every probe-as-both value.
14604        let d = dep_with_fonte(DepSource::Path {
14605            caminho: "..\\caixa%20teia".into(),
14606        });
14607        let err = d.validate().unwrap_err();
14608        assert!(
14609            matches!(err, DepError::FonteCaminhoBackslash { .. }),
14610            "got {err:?}",
14611        );
14612    }
14613
14614    #[test]
14615    fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14616        // Cascade pin on the upstream control-char arm: a value
14617        // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14618        // the canonical "I pasted a paste-from-binary-blob path
14619        // followed by a percent-encoded space" footgun) routes
14620        // through `FonteCaminhoControlChar` not
14621        // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14622        // rejected byte is the load-bearing root-cause edit on
14623        // every probe-as-both value.
14624        let d = dep_with_fonte(DepSource::Path {
14625            caminho: "../caixa\0%20teia".into(),
14626        });
14627        let err = d.validate().unwrap_err();
14628        assert!(
14629            matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14630            "got {err:?}",
14631        );
14632    }
14633
14634    #[test]
14635    fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14636        // Cascade pin on the upstream absolute-path arm: a value
14637        // that's both absolute and carries `%` (`"/etc/passwd%20"`
14638        // — the canonical "I pasted an absolute path with a
14639        // percent-encoded space tail" footgun) routes through
14640        // `FonteCaminhoAbsolute` not
14641        // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14642        // the load-bearing root-cause edit on every probe-as-both
14643        // value.
14644        let d = dep_with_fonte(DepSource::Path {
14645            caminho: "/etc/passwd%20".into(),
14646        });
14647        let err = d.validate().unwrap_err();
14648        assert!(
14649            matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14650            "got {err:?}",
14651        );
14652    }
14653
14654    #[test]
14655    fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14656        // Cascade pin on the upstream var-expansion arm: a value
14657        // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14658        // — the canonical "I pasted a `$HOME`-rooted path with a
14659        // percent-encoded space" footgun) routes through
14660        // `FonteCaminhoVarExpansion` not
14661        // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14662        // expansion is the load-bearing root-cause edit on every
14663        // probe-as-both value.
14664        let d = dep_with_fonte(DepSource::Path {
14665            caminho: "$HOME/caixa%20teia".into(),
14666        });
14667        let err = d.validate().unwrap_err();
14668        assert!(
14669            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14670            "got {err:?}",
14671        );
14672    }
14673
14674    #[test]
14675    fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14676        // Cascade pin on the immediate-successor arm: a value
14677        // carrying both `%` and a trailing `/`
14678        // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14679        // percent-encoded-space-carrying path" footgun) routes
14680        // through `FonteCaminhoUrlPercentEncoding` not
14681        // `FonteCaminhoTrailingSlash`. The embedded percent-
14682        // encoding-escape byte is the more semantic-locating axis
14683        // (an author who decodes the `%20` to a literal space is
14684        // likely to also tab-strip the trailing separator since
14685        // both are paste-from-URL / paste-from-shell-tab-completion
14686        // artifacts).
14687        let d = dep_with_fonte(DepSource::Path {
14688            caminho: "../caixa%20teia/".into(),
14689        });
14690        let err = d.validate().unwrap_err();
14691        assert!(
14692            matches!(
14693                err,
14694                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14695            ),
14696            "got {err:?}",
14697        );
14698    }
14699
14700    #[test]
14701    fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14702        // Diagnostic-shape pin (peer with
14703        // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14704        // on the immediate-predecessor arm): the error's Display
14705        // surfaces the offending `:nome`, the offending `:caminho`
14706        // verbatim, the offending byte's hex / character form, and
14707        // names the URL-percent-encoding-escape / printf-format-
14708        // specifier footgun explicitly so a `feira lint` run can
14709        // render the diagnostic without re-parsing.
14710        let d = dep_with_fonte(DepSource::Path {
14711            caminho: "../caixa%20teia".into(),
14712        });
14713        let rendered = d.validate().unwrap_err().to_string();
14714        assert!(
14715            rendered.contains("caixa-teia"),
14716            "diagnostic must name the offending dep: {rendered}",
14717        );
14718        assert!(
14719            rendered.contains("../caixa%20teia"),
14720            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14721        );
14722        assert!(
14723            rendered.contains("0x25"),
14724            "diagnostic must surface the offending byte hex: {rendered:?}",
14725        );
14726        assert!(
14727            rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14728            "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14729        );
14730        assert!(
14731            rendered.contains("printf") || rendered.contains("format-specifier"),
14732            "diagnostic must reference the printf-format-specifier vocabulary: \
14733             {rendered:?}",
14734        );
14735    }
14736
14737    #[test]
14738    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14739        // The canonical embedded-`$` shell-variable-expansion paste
14740        // shape (`"../foo$HOME/bar"` — an author copies a partially-
14741        // substituted shell one-liner where the leading segment is a
14742        // literal `../foo` while the mid segment carries the un-
14743        // substituted `$HOME` template). The leading-`$` position is
14744        // already gated by the f4efe9c leading-byte arm which routes
14745        // through `FonteCaminhoVarExpansion`; this arm closes the
14746        // last positional gap on `$` — every position on the axis is
14747        // structurally rejected.
14748        let d = dep_with_fonte(DepSource::Path {
14749            caminho: "../foo$HOME/bar".into(),
14750        });
14751        let err = d.validate().unwrap_err();
14752        let DepError::FonteCaminhoShellVariableExpansion {
14753            nome,
14754            caminho,
14755            byte,
14756        } = err
14757        else {
14758            panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14759        };
14760        assert_eq!(nome, "caixa-teia");
14761        assert_eq!(caminho, "../foo$HOME/bar");
14762        assert_eq!(byte, b'$');
14763    }
14764
14765    #[test]
14766    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14767        // The symmetric braced-CI-manifest paste shape
14768        // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14769        // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14770        // footgun). Pinned separately from the bare-`$VAR` shape so
14771        // the gate covers both POSIX shell §2.6 Parameter Expansion
14772        // syntactic forms, not only the unbraced variant. The
14773        // embedded `{` byte in `${...}` is also caught by the 598b770
14774        // shell-brace-expansion arm but that arm fires earlier in
14775        // the cascade — the `$` arm's coverage extends to `${...}`
14776        // structurally, so the diagnostic asserted here is the
14777        // brace-expansion one (which is a valid outcome; the point
14778        // of the pin is that the value never survives validation).
14779        let d = dep_with_fonte(DepSource::Path {
14780            caminho: "../foo${WORKSPACE}/bar".into(),
14781        });
14782        let err = d.validate().unwrap_err();
14783        assert!(
14784            matches!(
14785                err,
14786                DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14787                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14788            ),
14789            "got {err:?}",
14790        );
14791    }
14792
14793    #[test]
14794    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14795        // The paste-from-shell-prompt command-substitution idiom
14796        // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14797        // `$VAR` shape so the gate's rationale extends to POSIX shell
14798        // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14799        // legacy `` `<cmd>` `` form is already closed by the c370458
14800        // backtick arm). The embedded `(` byte in `$(...)` is also
14801        // caught structurally by the 0633c91 shell-subshell-grouping
14802        // arm which fires earlier in the cascade — the diagnostic
14803        // asserted here is either outcome, since both structurally
14804        // reject the value; the point of the pin is that the value
14805        // never survives validation.
14806        let d = dep_with_fonte(DepSource::Path {
14807            caminho: "../foo$(whoami)/bar".into(),
14808        });
14809        let err = d.validate().unwrap_err();
14810        assert!(
14811            matches!(
14812                err,
14813                DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14814                    | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14815            ),
14816            "got {err:?}",
14817        );
14818    }
14819
14820    #[test]
14821    fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14822        // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14823        // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14824        // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14825        // idiom copied into a caminho template). None of the prior
14826        // shell-metachar arms cover this shape (`1` is a bare digit;
14827        // no `(` / `{` / letter follows the `$`), so the arm is the
14828        // sole gate on the shape.
14829        let d = dep_with_fonte(DepSource::Path {
14830            caminho: "../foo$1/bar".into(),
14831        });
14832        let err = d.validate().unwrap_err();
14833        assert!(
14834            matches!(
14835                err,
14836                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14837            ),
14838            "got {err:?}",
14839        );
14840    }
14841
14842    #[test]
14843    fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14844        // The positive-control pin (peer with
14845        // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14846        // on the immediate-predecessor arm): the gate targets only
14847        // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14848        // A relative POSIX path carrying dashes / dots / slashes /
14849        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14850        // validate cleanly so the gate doesn't widen to a "no
14851        // printable punctuation anywhere" sweep that would defeat
14852        // the entire path-fonte author surface.
14853        let d = dep_with_fonte(DepSource::Path {
14854            caminho: "../caixa-teia/sub-dir.v2".into(),
14855        });
14856        d.validate().unwrap();
14857    }
14858
14859    #[test]
14860    fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14861        // Cascade pin on the leading-`$` sibling arm at line 540: a
14862        // value starting with `$` and carrying an embedded `$` too
14863        // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14864        // fully-templated CI path with two un-substituted variables")
14865        // routes through `FonteCaminhoVarExpansion` not
14866        // `FonteCaminhoShellVariableExpansion`. The leading-byte
14867        // host-layout-leak is the load-bearing self-locating axis
14868        // (the leading position dominates the semantic-locating
14869        // rationale on every probe-as-both value); the embedded
14870        // arm's positional-agnostic sweep catches only values whose
14871        // leading byte doesn't route through the earlier leading-
14872        // byte arms.
14873        let d = dep_with_fonte(DepSource::Path {
14874            caminho: "$HOME/foo$WORKSPACE/bar".into(),
14875        });
14876        let err = d.validate().unwrap_err();
14877        assert!(
14878            matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14879            "got {err:?}",
14880        );
14881    }
14882
14883    #[test]
14884    fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14885        // Cascade pin on the immediate-predecessor arm: a value
14886        // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14887        // — the canonical "I pasted a percent-encoded space adjacent
14888        // to a `$HOME` template") routes through
14889        // `FonteCaminhoUrlPercentEncoding` not
14890        // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14891        // encoding-escape byte is the more semantic-locating axis
14892        // (the paste-from-browser-address-bar shape is the load-
14893        // bearing self-locating edit); same cascade discipline every
14894        // prior `:caminho` arm establishes.
14895        let d = dep_with_fonte(DepSource::Path {
14896            caminho: "../foo%20$HOME/bar".into(),
14897        });
14898        let err = d.validate().unwrap_err();
14899        assert!(
14900            matches!(
14901                err,
14902                DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14903            ),
14904            "got {err:?}",
14905        );
14906    }
14907
14908    #[test]
14909    fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14910        // Cascade pin on the immediate-successor arm: a value
14911        // carrying both embedded `$` and a trailing `/`
14912        // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14913        // `$HOME`-template-carrying path") routes through
14914        // `FonteCaminhoShellVariableExpansion` not
14915        // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14916        // expansion byte is the more semantic-locating axis on
14917        // probe-as-both values (an author who substitutes the
14918        // `$HOME` template with a literal value is likely to also
14919        // tab-strip the trailing separator).
14920        let d = dep_with_fonte(DepSource::Path {
14921            caminho: "../foo$HOME/bar/".into(),
14922        });
14923        let err = d.validate().unwrap_err();
14924        assert!(
14925            matches!(
14926                err,
14927                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14928            ),
14929            "got {err:?}",
14930        );
14931    }
14932
14933    #[test]
14934    fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14935        // Diagnostic-shape pin (peer with
14936        // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14937        // on the immediate-predecessor arm): the error's Display
14938        // surfaces the offending `:nome`, the offending `:caminho`
14939        // verbatim, the offending byte's hex / character form, and
14940        // names the shell-variable-expansion / command-substitution
14941        // footgun explicitly so a `feira lint` run can render the
14942        // diagnostic without re-parsing.
14943        let d = dep_with_fonte(DepSource::Path {
14944            caminho: "../foo$HOME/bar".into(),
14945        });
14946        let rendered = d.validate().unwrap_err().to_string();
14947        assert!(
14948            rendered.contains("caixa-teia"),
14949            "diagnostic must name the offending dep: {rendered}",
14950        );
14951        assert!(
14952            rendered.contains("../foo$HOME/bar"),
14953            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14954        );
14955        assert!(
14956            rendered.contains("0x24"),
14957            "diagnostic must surface the offending byte hex: {rendered:?}",
14958        );
14959        assert!(
14960            rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14961            "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14962        );
14963        assert!(
14964            rendered.contains("command-substitution") || rendered.contains("command substitution"),
14965            "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14966        );
14967    }
14968
14969    #[test]
14970    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14971        // The fail-before-pass-after pin for the canonical paste-from-
14972        // shell-history footgun on `:caminho`. An author copies a `cd
14973        // ../caixa-teia && !sudo make install` one-liner from a quick-
14974        // start README, intending the trailing `!sudo` as a shell-
14975        // history-expansion reference but the typed slot is itself a
14976        // byte-level string parser, not a shell context, so the byte
14977        // rides into the value verbatim. Until this arm landed the `!`
14978        // byte silently passed every prior `:caminho` cascade arm
14979        // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14980        // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14981        // `#` / `%` / `$`); bash with the default `histexpand` mode
14982        // rewrites `!command` to the most recent history entry
14983        // beginning with `command`, the canonical RCE-class injection
14984        // vector when the byte rides into a shell argument executed
14985        // under `bash -i` (the operator-notebook interactive shell).
14986        let d = dep_with_fonte(DepSource::Path {
14987            caminho: "../caixa-teia!sudo".into(),
14988        });
14989        let err = d.validate().unwrap_err();
14990        let DepError::FonteCaminhoShellHistoryExpansion {
14991            nome,
14992            caminho,
14993            byte,
14994        } = err
14995        else {
14996            panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14997        };
14998        assert_eq!(nome, "caixa-teia");
14999        assert_eq!(caminho, "../caixa-teia!sudo");
15000        assert_eq!(byte, b'!');
15001    }
15002
15003    #[test]
15004    fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
15005        // The symmetric `!!` repeat-prior-command paste idiom (peer with
15006        // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
15007        // on `is_git_repo_url`). Pinned separately from the wrapped
15008        // `!command` shape so a future diagnostic-surface change that
15009        // only checked the leading or paired-bang position surfaces
15010        // here — the per-byte arm fires anywhere `!` appears in the
15011        // value, including at consecutive positions in the middle.
15012        let d = dep_with_fonte(DepSource::Path {
15013            caminho: "../foo!!/bar".into(),
15014        });
15015        let err = d.validate().unwrap_err();
15016        assert!(
15017            matches!(
15018                err,
15019                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15020            ),
15021            "got {err:?}",
15022        );
15023    }
15024
15025    #[test]
15026    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
15027        // The English-typography enthusiasm-form paste-from-prose
15028        // idiom: an author writes `:caminho "../caixa-teia!"`
15029        // expecting the substrate to coerce it to a kebab-case slug.
15030        // Pinned separately from the `!<word>` shell-history shape so
15031        // the gate's rationale extends to the paste-from-prose surface
15032        // (the same rationale the peer `is_git_repo_url` bang arm at
15033        // 7d53c68 covers). None of the prior shell-metachar arms cover
15034        // this shape (no `!<word>` reference and no `!!` repeat), so
15035        // the arm is the sole gate on the shape.
15036        let d = dep_with_fonte(DepSource::Path {
15037            caminho: "../caixa-teia!".into(),
15038        });
15039        let err = d.validate().unwrap_err();
15040        assert!(
15041            matches!(
15042                err,
15043                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15044            ),
15045            "got {err:?}",
15046        );
15047    }
15048
15049    #[test]
15050    fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
15051        // The positive-control pin (peer with
15052        // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
15053        // on the immediate-predecessor arm): the gate targets only
15054        // `!`, never adjacent printable ASCII or POSIX-valid bytes.
15055        // A relative POSIX path carrying dashes / dots / slashes /
15056        // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
15057        // validate cleanly so the gate doesn't widen to a "no
15058        // printable punctuation anywhere" sweep that would defeat
15059        // the entire path-fonte author surface.
15060        let d = dep_with_fonte(DepSource::Path {
15061            caminho: "../caixa-teia/sub-dir.v2".into(),
15062        });
15063        d.validate().unwrap();
15064    }
15065
15066    #[test]
15067    fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
15068        // Cascade pin on the immediate-predecessor arm: a value
15069        // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
15070        // — the canonical "I pasted a `$HOME`-templated path adjacent
15071        // to a trailing `!sudo` history-expansion") routes through
15072        // `FonteCaminhoShellVariableExpansion` not
15073        // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
15074        // expansion byte is the more semantic-locating axis on
15075        // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
15076        // template shape is the load-bearing self-locating edit);
15077        // same cascade discipline every prior `:caminho` arm
15078        // establishes.
15079        let d = dep_with_fonte(DepSource::Path {
15080            caminho: "../foo$HOME/bar!sudo".into(),
15081        });
15082        let err = d.validate().unwrap_err();
15083        assert!(
15084            matches!(
15085                err,
15086                DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
15087            ),
15088            "got {err:?}",
15089        );
15090    }
15091
15092    #[test]
15093    fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
15094        // Cascade pin on the immediate-successor arm: a value carrying
15095        // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
15096        // — the canonical "I tab-completed a `!sudo`-carrying path")
15097        // routes through `FonteCaminhoShellHistoryExpansion` not
15098        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15099        // expansion byte is the more semantic-locating axis on probe-
15100        // as-both values (an author who removes the `!sudo` history
15101        // reference is likely to also tab-strip the trailing separator).
15102        let d = dep_with_fonte(DepSource::Path {
15103            caminho: "../caixa-teia!sudo/".into(),
15104        });
15105        let err = d.validate().unwrap_err();
15106        assert!(
15107            matches!(
15108                err,
15109                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15110            ),
15111            "got {err:?}",
15112        );
15113    }
15114
15115    #[test]
15116    fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
15117        // Diagnostic-shape pin (peer with
15118        // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15119        // on the immediate-predecessor arm): the error's Display
15120        // surfaces the offending `:nome`, the offending `:caminho`
15121        // verbatim, the offending byte's hex / character form, and
15122        // names the shell-history-expansion / bang-operator footgun
15123        // explicitly so a `feira lint` run can render the diagnostic
15124        // without re-parsing.
15125        let d = dep_with_fonte(DepSource::Path {
15126            caminho: "../caixa-teia!sudo".into(),
15127        });
15128        let rendered = d.validate().unwrap_err().to_string();
15129        assert!(
15130            rendered.contains("caixa-teia"),
15131            "diagnostic must name the offending dep: {rendered}",
15132        );
15133        assert!(
15134            rendered.contains("../caixa-teia!sudo"),
15135            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15136        );
15137        assert!(
15138            rendered.contains("0x21"),
15139            "diagnostic must surface the offending byte hex: {rendered:?}",
15140        );
15141        assert!(
15142            rendered.contains("history-expansion") || rendered.contains("history expansion"),
15143            "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
15144        );
15145        assert!(
15146            rendered.contains("bang"),
15147            "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
15148        );
15149    }
15150
15151    #[test]
15152    fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
15153        // The fail-before-pass-after pin for the canonical paste-from-
15154        // shell-history-quick-substitution footgun on `:caminho`. An
15155        // author copies a `git clone <bad-url>` line from their terminal,
15156        // corrects it via bash's `^bad^good` quick-substitution history
15157        // operator (bash reference §9.3, `set -o histexpand` mode's
15158        // default for interactive sessions), and pastes the trailing
15159        // `^bad^good` substitution fragment into a `:caminho` value
15160        // without trimming the leading `git clone` prefix — the byte
15161        // rides into the manifest verbatim. Until this arm landed the
15162        // `^` byte silently passed every prior `:caminho` cascade arm
15163        // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
15164        // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
15165        // `%` / `$` / `!`); bash with the default `histexpand` mode
15166        // rewrites the prior command's `bad` string to `good` and re-
15167        // executes it, the paired-operator half of the `set -o
15168        // histexpand` feature the peer `!` arm already closes the prefix
15169        // half of. The peer `is_git_repo_url` axis rejects the byte at
15170        // 49e142f under the same shell-history-substitution / RFC-3986-
15171        // unwise banner.
15172        let d = dep_with_fonte(DepSource::Path {
15173            caminho: "../foo^bad^good".into(),
15174        });
15175        let err = d.validate().unwrap_err();
15176        let DepError::FonteCaminhoShellHistorySubstitution {
15177            nome,
15178            caminho,
15179            byte,
15180        } = err
15181        else {
15182            panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
15183        };
15184        assert_eq!(nome, "caixa-teia");
15185        assert_eq!(caminho, "../foo^bad^good");
15186        assert_eq!(byte, b'^');
15187    }
15188
15189    #[test]
15190    fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
15191        // The symmetric paste-from-doc-grep-pipeline footgun (peer with
15192        // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
15193        // on `is_git_repo_url`). An author copies a `grep '^archived'`
15194        // regex-anchor / negation idiom from a doc snippet and the byte
15195        // rides in verbatim. Pinned separately from the `^old^new^`
15196        // quick-substitution shape so a future diagnostic-surface change
15197        // that only checked the paired-caret history-substitution
15198        // position surfaces here — the per-byte arm fires anywhere `^`
15199        // appears in the value, including at a solitary leading-of-
15200        // segment position.
15201        let d = dep_with_fonte(DepSource::Path {
15202            caminho: "../foo/^archived".into(),
15203        });
15204        let err = d.validate().unwrap_err();
15205        assert!(
15206            matches!(
15207                err,
15208                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15209            ),
15210            "got {err:?}",
15211        );
15212    }
15213
15214    #[test]
15215    fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
15216        // The trailing-`^` history-substitution-open shape — an author
15217        // starts typing a `^bad^good` quick-substitution but pastes only
15218        // the leading `^` sentinel before context-switching (a bash-
15219        // reference §9.3 valid histexpand prefix on its own — even a
15220        // solitary `^` on the prior command's whole re-execution shape).
15221        // Pinned separately from the `^old^new^` full-form and the leading-
15222        // of-segment `^archived` regex-anchor shape so the gate's
15223        // rationale extends to the paste-from-shell-history-with-only-
15224        // the-first-byte-selected surface. None of the prior shell-
15225        // metachar arms cover this shape.
15226        let d = dep_with_fonte(DepSource::Path {
15227            caminho: "../caixa-teia^".into(),
15228        });
15229        let err = d.validate().unwrap_err();
15230        assert!(
15231            matches!(
15232                err,
15233                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15234            ),
15235            "got {err:?}",
15236        );
15237    }
15238
15239    #[test]
15240    fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
15241        // The positive-control pin (peer with
15242        // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
15243        // on the immediate-predecessor arm): the gate targets only
15244        // `^`, never adjacent printable ASCII or POSIX-valid bytes.
15245        // A relative POSIX path carrying dashes / dots / slashes /
15246        // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
15247        // continue to validate cleanly so the gate doesn't widen to
15248        // a "no printable punctuation anywhere" sweep that would
15249        // defeat the entire path-fonte author surface.
15250        let d = dep_with_fonte(DepSource::Path {
15251            caminho: "../caixa-teia/sub_v2.rc".into(),
15252        });
15253        d.validate().unwrap();
15254    }
15255
15256    #[test]
15257    fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
15258        // Cascade pin on the immediate-predecessor arm: a value carrying
15259        // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
15260        // canonical "I pasted a `!sudo` history-reference next to a
15261        // `^bad^good` quick-substitution") routes through
15262        // `FonteCaminhoShellHistoryExpansion` not
15263        // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
15264        // the more semantic-locating axis on probe-as-both values (an
15265        // author who removes the `!sudo` reference is likely to also
15266        // strip the paired `^` substitution fragment); same cascade
15267        // discipline every prior `:caminho` arm establishes.
15268        let d = dep_with_fonte(DepSource::Path {
15269            caminho: "../foo!sudo^bad^good".into(),
15270        });
15271        let err = d.validate().unwrap_err();
15272        assert!(
15273            matches!(
15274                err,
15275                DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
15276            ),
15277            "got {err:?}",
15278        );
15279    }
15280
15281    #[test]
15282    fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
15283        // Cascade pin on the immediate-successor arm: a value carrying
15284        // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
15285        // the canonical "I tab-completed a `^bad^good`-carrying path")
15286        // routes through `FonteCaminhoShellHistorySubstitution` not
15287        // `FonteCaminhoTrailingSlash`. The embedded shell-history-
15288        // substitution byte is the more semantic-locating axis on probe-
15289        // as-both values (an author who removes the `^bad^good`
15290        // substitution fragment is likely to also tab-strip the trailing
15291        // separator).
15292        let d = dep_with_fonte(DepSource::Path {
15293            caminho: "../foo^bad^good/".into(),
15294        });
15295        let err = d.validate().unwrap_err();
15296        assert!(
15297            matches!(
15298                err,
15299                DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
15300            ),
15301            "got {err:?}",
15302        );
15303    }
15304
15305    #[test]
15306    fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
15307    {
15308        // Diagnostic-shape pin (peer with
15309        // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
15310        // on the immediate-predecessor arm): the error's Display
15311        // surfaces the offending `:nome`, the offending `:caminho`
15312        // verbatim, the offending byte's hex form, and names the
15313        // shell-history-substitution / RFC-3986-'unwise' / regex-
15314        // negation footgun explicitly so a `feira lint` run can render
15315        // the diagnostic without re-parsing.
15316        let d = dep_with_fonte(DepSource::Path {
15317            caminho: "../foo^bad^good".into(),
15318        });
15319        let rendered = d.validate().unwrap_err().to_string();
15320        assert!(
15321            rendered.contains("caixa-teia"),
15322            "diagnostic must name the offending dep: {rendered}",
15323        );
15324        assert!(
15325            rendered.contains("../foo^bad^good"),
15326            "diagnostic must quote the offending caminho verbatim: {rendered:?}",
15327        );
15328        assert!(
15329            rendered.contains("0x5e") || rendered.contains("0x5E"),
15330            "diagnostic must surface the offending byte hex: {rendered:?}",
15331        );
15332        assert!(
15333            rendered.contains("history-substitution") || rendered.contains("history substitution"),
15334            "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
15335        );
15336        assert!(
15337            rendered.contains("unwise"),
15338            "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
15339        );
15340    }
15341
15342    #[test]
15343    fn fonte_repo_empty_fires_before_pin_missing() {
15344        // Order pin: empty `:repo` is the more self-locating diagnostic
15345        // (every git source needs a repo; the pin discussion is
15346        // secondary), so it fires before the pin-missing arm even when
15347        // both are violated. Mirrors the
15348        // `nome_empty_takes_precedence_over_versao_invalid` ordering
15349        // discipline on the per-entry layer.
15350        let d = dep_with_fonte(DepSource::Git {
15351            repo: String::new(),
15352            tag: None,
15353            rev: None,
15354            branch: None,
15355        });
15356        let err = d.validate().unwrap_err();
15357        assert!(
15358            matches!(err, DepError::FonteRepoEmpty { .. }),
15359            "got {err:?}"
15360        );
15361    }
15362
15363    #[test]
15364    fn fonte_pin_missing_fires_before_pin_empty() {
15365        // Order pin: a fully-None pin set is structurally distinct from
15366        // a Some(empty) pin — the first surfaces as FontePinMissing
15367        // (no axis chosen), the second as FontePinEmpty (axis chosen
15368        // but value blank). Pin the disjoint relationship so a future
15369        // unification collapses to one variant only as a structural
15370        // decision.
15371        let d = dep_with_fonte(DepSource::Git {
15372            repo: "github:pleme-io/caixa-teia".into(),
15373            tag: None,
15374            rev: None,
15375            branch: None,
15376        });
15377        assert!(matches!(
15378            d.validate().unwrap_err(),
15379            DepError::FontePinMissing { .. }
15380        ));
15381    }
15382
15383    #[test]
15384    fn nome_empty_takes_precedence_over_fonte_invalid() {
15385        // Order pin: a per-entry diagnostic without a non-empty :nome
15386        // can't be self-locating, so :nome "" fires first even when
15387        // :fonte is also malformed. Mirrors
15388        // `nome_empty_takes_precedence_over_versao_invalid` on the
15389        // adjacent axis.
15390        let mut d = dep_with_fonte(DepSource::Git {
15391            repo: String::new(),
15392            tag: None,
15393            rev: None,
15394            branch: None,
15395        });
15396        d.nome = String::new();
15397        assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
15398    }
15399
15400    #[test]
15401    fn versao_invalid_takes_precedence_over_fonte_invalid() {
15402        // Order pin: the :versao parse-side diagnostic is narrower than
15403        // the :fonte shape diagnostic — a malformed :versao always names
15404        // the parser's reason, which is more actionable than the
15405        // :fonte gate's "the pins are wrong" wording. Pin the ordering
15406        // so a re-ordering surfaces here.
15407        let mut d = dep_with_fonte(DepSource::Git {
15408            repo: String::new(),
15409            tag: None,
15410            rev: None,
15411            branch: None,
15412        });
15413        d.versao = "v0.1".into();
15414        let err = d.validate().unwrap_err();
15415        assert!(
15416            matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
15417            "got {err:?}"
15418        );
15419    }
15420
15421    #[test]
15422    fn fonte_invalid_diagnostic_carries_offending_nome() {
15423        // The diagnostic-shape pin: every :fonte error variant names
15424        // the offending dep's :nome verbatim, so the author can grep
15425        // caixa.lisp for the `:nome "<n>"` block and fix it in one
15426        // edit. Cover all seven variants so a future variant addition
15427        // forces a parallel diagnostic-shape decision.
15428        for (case, fonte) in [
15429            (
15430                "repo-empty",
15431                DepSource::Git {
15432                    repo: String::new(),
15433                    tag: Some("v1".into()),
15434                    rev: None,
15435                    branch: None,
15436                },
15437            ),
15438            (
15439                "repo-shape",
15440                DepSource::Git {
15441                    repo: "github:p/x ".into(),
15442                    tag: Some("v1".into()),
15443                    rev: None,
15444                    branch: None,
15445                },
15446            ),
15447            (
15448                "pin-missing",
15449                DepSource::Git {
15450                    repo: "github:p/x".into(),
15451                    tag: None,
15452                    rev: None,
15453                    branch: None,
15454                },
15455            ),
15456            (
15457                "pin-ambiguous",
15458                DepSource::Git {
15459                    repo: "github:p/x".into(),
15460                    tag: Some("v1".into()),
15461                    rev: None,
15462                    branch: Some("main".into()),
15463                },
15464            ),
15465            (
15466                "pin-empty",
15467                DepSource::Git {
15468                    repo: "github:p/x".into(),
15469                    tag: Some(String::new()),
15470                    rev: None,
15471                    branch: None,
15472                },
15473            ),
15474            (
15475                "caminho-empty",
15476                DepSource::Path {
15477                    caminho: String::new(),
15478                },
15479            ),
15480            (
15481                "caminho-absolute",
15482                DepSource::Path {
15483                    caminho: "/home/me/work/caixa-teia".into(),
15484                },
15485            ),
15486        ] {
15487            let d = dep_with_fonte(fonte);
15488            let msg = d
15489                .validate()
15490                .expect_err(&format!("{case}: expected fonte error"))
15491                .to_string();
15492            assert!(
15493                msg.contains("\"caixa-teia\""),
15494                "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15495            );
15496        }
15497    }
15498
15499    // -- :tag / :branch value-shape gate ----------------------------------
15500
15501    #[test]
15502    fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
15503        // The canonical paste-from-doc footgun on `:tag` — author
15504        // copies `"v0.1.0 "` (trailing space) out of a release-notes
15505        // paragraph. Until this gate landed the empty-pin arm passed
15506        // (the string isn't empty), the resolver issued
15507        // `git fetch <remote> tag 'v0.1.0 '`, and the failure
15508        // surfaced at clone time with a quoting-confused git error
15509        // far from the source caixa.lisp. The new gate moves the
15510        // check to caixa-build time and names the offending dep +
15511        // pin + value verbatim.
15512        let d = dep_with_fonte(DepSource::Git {
15513            repo: "github:pleme-io/caixa-teia".into(),
15514            tag: Some("v0.1.0 ".into()),
15515            rev: None,
15516            branch: None,
15517        });
15518        let err = d.validate().unwrap_err();
15519        let DepError::FontePinShape {
15520            nome,
15521            pin,
15522            value,
15523            reason,
15524        } = err
15525        else {
15526            panic!("expected FontePinShape, got other variant");
15527        };
15528        assert_eq!(nome, "caixa-teia");
15529        assert_eq!(pin, ":tag");
15530        assert_eq!(value, "v0.1.0 ");
15531        assert!(
15532            reason.contains("whitespace"),
15533            "reason must surface the whitespace arm, got {reason:?}"
15534        );
15535    }
15536
15537    #[test]
15538    fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
15539        // The `.lock` suffix is git's atomic-rename guard for
15540        // in-flight ref updates — a refname ending in `.lock` is
15541        // unwritable on disk. Pinned separately from the whitespace
15542        // arm so a future relaxation that admits one but not the
15543        // other surfaces here.
15544        let d = dep_with_fonte(DepSource::Git {
15545            repo: "github:pleme-io/caixa-teia".into(),
15546            tag: Some("v0.1.0.lock".into()),
15547            rev: None,
15548            branch: None,
15549        });
15550        let err = d.validate().unwrap_err();
15551        let DepError::FontePinShape {
15552            pin, value, reason, ..
15553        } = err
15554        else {
15555            panic!("expected FontePinShape, got other variant");
15556        };
15557        assert_eq!(pin, ":tag");
15558        assert_eq!(value, "v0.1.0.lock");
15559        assert!(
15560            reason.contains(".lock"),
15561            "reason must surface the .lock arm, got {reason:?}"
15562        );
15563    }
15564
15565    #[test]
15566    fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15567        // The canonical "branch name with spaces" footgun (`feature
15568        // foo`, `release branch`) — git's refname parser rejects raw
15569        // whitespace, and the failure surfaces at `git checkout
15570        // 'feature foo'` time with a quoting-confused error far from
15571        // the source caixa.lisp. Pinned on the `:branch` axis so the
15572        // gate-applies-to-both-:tag-and-:branch contract is a build-
15573        // error to relax.
15574        let d = dep_with_fonte(DepSource::Git {
15575            repo: "github:pleme-io/caixa-teia".into(),
15576            tag: None,
15577            rev: None,
15578            branch: Some("feature/foo bar".into()),
15579        });
15580        let err = d.validate().unwrap_err();
15581        let DepError::FontePinShape {
15582            pin, value, reason, ..
15583        } = err
15584        else {
15585            panic!("expected FontePinShape, got other variant");
15586        };
15587        assert_eq!(pin, ":branch");
15588        assert_eq!(value, "feature/foo bar");
15589        assert!(
15590            reason.contains("whitespace"),
15591            "reason must surface the whitespace arm, got {reason:?}"
15592        );
15593    }
15594
15595    #[test]
15596    fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15597        // The `refs/heads/main` shape — the canonical "I copied the
15598        // fully-qualified ref out of `git show-ref` instead of the
15599        // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15600        // at clone time, so this resolves to a literal ref named
15601        // `refs/heads/refs/heads/main` on disk; the silent double-
15602        // prefix is the load-bearing reason to gate at validate.
15603        // The diagnostic must enumerate the leaf the author probably
15604        // meant (`"main"`) so the fix is one edit.
15605        let d = dep_with_fonte(DepSource::Git {
15606            repo: "github:pleme-io/caixa-teia".into(),
15607            tag: None,
15608            rev: None,
15609            branch: Some("refs/heads/main".into()),
15610        });
15611        let err = d.validate().unwrap_err();
15612        let DepError::FontePinShape {
15613            pin, value, reason, ..
15614        } = err
15615        else {
15616            panic!("expected FontePinShape, got other variant");
15617        };
15618        assert_eq!(pin, ":branch");
15619        assert_eq!(value, "refs/heads/main");
15620        assert!(
15621            reason.contains("fully-qualified"),
15622            "reason must surface the qualified-prefix arm, got {reason:?}"
15623        );
15624        assert!(
15625            reason.contains("\"main\""),
15626            "reason must quote the leaf the author probably meant, got {reason:?}"
15627        );
15628    }
15629
15630    #[test]
15631    fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15632        // Sibling arm of the qualified-prefix gate on the `:tag`
15633        // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15634        // footgun). Pinned separately so a future relaxation that
15635        // only catches the `:branch` arm surfaces here.
15636        let d = dep_with_fonte(DepSource::Git {
15637            repo: "github:pleme-io/caixa-teia".into(),
15638            tag: Some("refs/tags/v0.1.0".into()),
15639            rev: None,
15640            branch: None,
15641        });
15642        let err = d.validate().unwrap_err();
15643        let DepError::FontePinShape {
15644            pin, value, reason, ..
15645        } = err
15646        else {
15647            panic!("expected FontePinShape, got other variant");
15648        };
15649        assert_eq!(pin, ":tag");
15650        assert_eq!(value, "refs/tags/v0.1.0");
15651        assert!(
15652            reason.contains("fully-qualified"),
15653            "reason must surface the qualified-prefix arm, got {reason:?}"
15654        );
15655        assert!(
15656            reason.contains("\"v0.1.0\""),
15657            "reason must quote the leaf the author probably meant, got {reason:?}"
15658        );
15659    }
15660
15661    #[test]
15662    fn validate_rejects_git_fonte_with_branch_named_at() {
15663        // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15664        // unsourceable. Pinned so a future relaxation that admits
15665        // any single-character refname surfaces here.
15666        let d = dep_with_fonte(DepSource::Git {
15667            repo: "github:pleme-io/caixa-teia".into(),
15668            tag: None,
15669            rev: None,
15670            branch: Some("@".into()),
15671        });
15672        let err = d.validate().unwrap_err();
15673        let DepError::FontePinShape { pin, value, .. } = err else {
15674            panic!("expected FontePinShape, got other variant");
15675        };
15676        assert_eq!(pin, ":branch");
15677        assert_eq!(value, "@");
15678    }
15679
15680    #[test]
15681    fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15682        // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15683        // a `:tag "../escape"` (path-traversal-shaped slug) silently
15684        // passes parse and surfaces as a refname-parse error or, on
15685        // older git, a literal `../escape` checkout that escapes the
15686        // refs/ directory tree. Pinned separately from the
15687        // qualified-prefix arm so a future relaxation that catches
15688        // one but not the other surfaces here.
15689        let d = dep_with_fonte(DepSource::Git {
15690            repo: "github:pleme-io/caixa-teia".into(),
15691            tag: Some("../escape".into()),
15692            rev: None,
15693            branch: None,
15694        });
15695        let err = d.validate().unwrap_err();
15696        let DepError::FontePinShape { pin, value, .. } = err else {
15697            panic!("expected FontePinShape, got other variant");
15698        };
15699        assert_eq!(pin, ":tag");
15700        assert_eq!(value, "../escape");
15701    }
15702
15703    #[test]
15704    fn validate_accepts_git_fonte_with_hierarchical_branch() {
15705        // The positive-control pin: hierarchical refnames with one or
15706        // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15707        // canonical idiom) round-trip through the gate. Pinned
15708        // separately from the leaf-`"main"` positive control so a
15709        // future tightening that rejects all multi-component refnames
15710        // surfaces here.
15711        let d = dep_with_fonte(DepSource::Git {
15712            repo: "github:pleme-io/caixa-teia".into(),
15713            tag: None,
15714            rev: None,
15715            branch: Some("feature/checkout-rewrite".into()),
15716        });
15717        d.validate().unwrap();
15718    }
15719
15720    #[test]
15721    fn validate_accepts_git_fonte_with_prerelease_tag() {
15722        // The positive-control pin: semver pre-release shape
15723        // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15724        // (only consecutive `..` and trailing `.` are rejected), the
15725        // mid-component hyphen is allowed. Pinned separately from
15726        // the bare-`"v0.1.0"` positive control so a future tightening
15727        // that rejects pre-release tags surfaces here.
15728        let d = dep_with_fonte(DepSource::Git {
15729            repo: "github:pleme-io/caixa-teia".into(),
15730            tag: Some("v0.1.0-alpha.1".into()),
15731            rev: None,
15732            branch: None,
15733        });
15734        d.validate().unwrap();
15735    }
15736
15737    #[test]
15738    fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15739        // The `:rev` axis is routed through `crate::render::is_git_oid`
15740        // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15741        // value with refname-shape punctuation (here, a `:` mid-string
15742        // — would be a refname violation under `is_git_ref_name` too)
15743        // is rejected at the OID-shape gate. The two predicates
15744        // partition the `:fonte` pin axes structurally: an `:rev` value
15745        // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15746        // *still* rejected here because every refname character outside
15747        // `[0-9a-f]` fails the OID gate. Same shape as
15748        // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15749        // on the refname-shaped axes — the diagnostic names the
15750        // offending dep + pin + value verbatim. The flip-from-accept
15751        // case the prior `:tag`/`:branch` gate left as a "future axis"
15752        // (e70d213) — now landed.
15753        let d = dep_with_fonte(DepSource::Git {
15754            repo: "github:pleme-io/caixa-teia".into(),
15755            tag: None,
15756            rev: Some("c0ffee:notarefname".into()),
15757            branch: None,
15758        });
15759        let err = d.validate().unwrap_err();
15760        let DepError::FontePinShape {
15761            nome,
15762            pin,
15763            value,
15764            reason,
15765        } = err
15766        else {
15767            panic!("expected FontePinShape, got other variant");
15768        };
15769        assert_eq!(nome, "caixa-teia");
15770        assert_eq!(pin, ":rev");
15771        assert_eq!(value, "c0ffee:notarefname");
15772        assert!(
15773            !reason.is_empty(),
15774            "FontePinShape `reason` must carry the predicate's wording verbatim"
15775        );
15776    }
15777
15778    #[test]
15779    fn validate_accepts_git_fonte_with_rev_full_sha1() {
15780        // The positive-control pin on the SHA-1 OID width: exactly 40
15781        // lowercase hex characters — the canonical `git rev-parse HEAD`
15782        // emission on a SHA-1-hashed repository (the default on every
15783        // pre-2.42 git and the canonical pleme-io substrate hash).
15784        // Pinned separately from the SHA-256 positive control so a
15785        // future tightening that only admits one width surfaces here.
15786        let d = dep_with_fonte(DepSource::Git {
15787            repo: "github:pleme-io/caixa-teia".into(),
15788            tag: None,
15789            rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15790            branch: None,
15791        });
15792        d.validate().unwrap();
15793    }
15794
15795    #[test]
15796    fn validate_accepts_git_fonte_with_rev_full_sha256() {
15797        // The positive-control pin on the SHA-256 OID width: exactly
15798        // 64 lowercase hex characters — `git`'s
15799        // `extensions.objectFormat = sha256` emission (GA since Git
15800        // 2.42 / Oct 2023). The substrate admits either canonical
15801        // width so an `:rev` authored against a SHA-256-hashed
15802        // upstream round-trips through the gate without per-repo
15803        // configuration. Pinned separately from the SHA-1 positive
15804        // control so a future tightening that drops one width surfaces
15805        // here as a structural decision.
15806        let d = dep_with_fonte(DepSource::Git {
15807            repo: "github:pleme-io/caixa-teia".into(),
15808            tag: None,
15809            rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15810            branch: None,
15811        });
15812        d.validate().unwrap();
15813    }
15814
15815    #[test]
15816    fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15817        // The canonical `git log --short` / `git rev-parse --short HEAD`
15818        // paste-from-release-notes footgun: a 7-char prefix (git's
15819        // default `core.abbrev`) silently passes string emptiness
15820        // checks and resolves to one commit today, but becomes ambiguous
15821        // tomorrow as the repo grows. Until this gate landed the empty-
15822        // pin arm passed (the string isn't empty) and the resolver
15823        // accepted the prefix through git's separate prefix-lookup pass
15824        // — defeating the reproducibility contract `:rev` carries vs.
15825        // `:tag` / `:branch`. The new gate moves the check to caixa-
15826        // build time and names the offending dep + pin + value verbatim.
15827        let d = dep_with_fonte(DepSource::Git {
15828            repo: "github:pleme-io/caixa-teia".into(),
15829            tag: None,
15830            rev: Some("c0ffee0".into()),
15831            branch: None,
15832        });
15833        let err = d.validate().unwrap_err();
15834        let DepError::FontePinShape {
15835            pin, value, reason, ..
15836        } = err
15837        else {
15838            panic!("expected FontePinShape, got other variant");
15839        };
15840        assert_eq!(pin, ":rev");
15841        assert_eq!(value, "c0ffee0");
15842        assert!(
15843            reason.contains("abbreviated") || reason.contains("ambiguous"),
15844            "reason must surface the abbreviation arm, got {reason:?}"
15845        );
15846    }
15847
15848    #[test]
15849    fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15850        // The canonical "I pasted the SHA in uppercase" footgun: `git
15851        // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15852        // bearing `:rev` round-trips inconsistently across the
15853        // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15854        // equality-check pipeline and fails the lacre's content-
15855        // addressing probe with a confusing case-only diff. Pinned
15856        // separately from the non-hex arm so a future relaxation that
15857        // admits one but not the other surfaces here.
15858        let d = dep_with_fonte(DepSource::Git {
15859            repo: "github:pleme-io/caixa-teia".into(),
15860            tag: None,
15861            rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15862            branch: None,
15863        });
15864        let err = d.validate().unwrap_err();
15865        let DepError::FontePinShape {
15866            pin, value, reason, ..
15867        } = err
15868        else {
15869            panic!("expected FontePinShape, got other variant");
15870        };
15871        assert_eq!(pin, ":rev");
15872        assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15873        assert!(
15874            reason.contains("uppercase"),
15875            "reason must surface the uppercase arm, got {reason:?}"
15876        );
15877    }
15878
15879    #[test]
15880    fn validate_rejects_git_fonte_with_rev_refname_value() {
15881        // The cross-axis mis-slot footgun: `:rev "main"` — the author
15882        // conflated `:rev` (hex commit ID, immutable) and `:branch`
15883        // (mutable ref pointing at whatever HEAD is today). Until this
15884        // gate landed the resolver silently dispatched on the value
15885        // shape ("`main` doesn't look like a SHA, fall back to
15886        // refname"), defeating the `:rev` reproducibility contract.
15887        // The new gate rejects every non-hex value on the `:rev` axis,
15888        // so the `:rev`/`:branch` boundary is structurally enforced —
15889        // a refname in the `:rev` slot is a build error, not a
15890        // resolver-time silent reinterpretation.
15891        let d = dep_with_fonte(DepSource::Git {
15892            repo: "github:pleme-io/caixa-teia".into(),
15893            tag: None,
15894            rev: Some("main".into()),
15895            branch: None,
15896        });
15897        let err = d.validate().unwrap_err();
15898        let DepError::FontePinShape {
15899            pin, value, reason, ..
15900        } = err
15901        else {
15902            panic!("expected FontePinShape, got other variant");
15903        };
15904        assert_eq!(pin, ":rev");
15905        assert_eq!(value, "main");
15906        // 4 chars `main` fails the length arm before the character arm,
15907        // so the diagnostic surfaces the abbreviation wording (same
15908        // path the `c0ffee0` 7-char fixture lands on); the structural
15909        // assertion is just that the `:rev "main"` value is rejected.
15910        assert!(
15911            !reason.is_empty(),
15912            "FontePinShape reason must be non-empty for refname-shaped :rev"
15913        );
15914    }
15915
15916    #[test]
15917    fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15918        // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15919        // conflated `:rev` and `:tag`. Pinned separately from the
15920        // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15921        // that catches one but not the other surfaces here. The
15922        // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15923        // assertion is just that the cross-axis mis-slot is a build
15924        // error, regardless of which sub-arm surfaces the diagnostic
15925        // (`is_git_oid` rejects at the first violation; longer
15926        // tag-shape values would hit the non-hex arm instead).
15927        let d = dep_with_fonte(DepSource::Git {
15928            repo: "github:pleme-io/caixa-teia".into(),
15929            tag: None,
15930            rev: Some("v0.1.0".into()),
15931            branch: None,
15932        });
15933        let err = d.validate().unwrap_err();
15934        let DepError::FontePinShape {
15935            pin, value, reason, ..
15936        } = err
15937        else {
15938            panic!("expected FontePinShape, got other variant");
15939        };
15940        assert_eq!(pin, ":rev");
15941        assert_eq!(value, "v0.1.0");
15942        assert!(
15943            !reason.is_empty(),
15944            "FontePinShape reason must be non-empty for tag-shaped :rev"
15945        );
15946    }
15947
15948    #[test]
15949    fn validate_rejects_git_fonte_with_rev_too_long() {
15950        // Boundary case on the upper end: 41 hex chars — one past the
15951        // SHA-1 width, well below the SHA-256 width. Pin so a future
15952        // relaxation that admits "long enough to be a SHA" without
15953        // matching either canonical width surfaces here. The diagnostic
15954        // names the offending length verbatim so the author's grep
15955        // target is unambiguous (either trim one char or paste the
15956        // full SHA-256).
15957        let too_long: String = "0".repeat(41);
15958        let d = dep_with_fonte(DepSource::Git {
15959            repo: "github:pleme-io/caixa-teia".into(),
15960            tag: None,
15961            rev: Some(too_long.clone()),
15962            branch: None,
15963        });
15964        let err = d.validate().unwrap_err();
15965        let DepError::FontePinShape {
15966            pin, value, reason, ..
15967        } = err
15968        else {
15969            panic!("expected FontePinShape, got other variant");
15970        };
15971        assert_eq!(pin, ":rev");
15972        assert_eq!(value, too_long);
15973        assert!(
15974            reason.contains("41"),
15975            "reason must surface the offending length verbatim, got {reason:?}"
15976        );
15977    }
15978
15979    #[test]
15980    fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15981        // The canonical paste-from-doc footgun on `:rev` — author
15982        // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15983        // commit-message paragraph. Until this gate landed the empty-
15984        // pin arm passed (the string isn't empty), the resolver issued
15985        // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15986        // clone time with a quoting-confused git error far from the
15987        // source caixa.lisp. The new gate moves the check to caixa-
15988        // build time. Length is 41 (40 hex + space) so the length arm
15989        // fires first — pinned separately from the pure-length arm to
15990        // ensure the diagnostic surfaces *some* parser wording, not
15991        // silently pass through.
15992        let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15993        let d = dep_with_fonte(DepSource::Git {
15994            repo: "github:pleme-io/caixa-teia".into(),
15995            tag: None,
15996            rev: Some(with_space.clone()),
15997            branch: None,
15998        });
15999        let err = d.validate().unwrap_err();
16000        let DepError::FontePinShape {
16001            pin, value, reason, ..
16002        } = err
16003        else {
16004            panic!("expected FontePinShape, got other variant");
16005        };
16006        assert_eq!(pin, ":rev");
16007        assert_eq!(value, with_space);
16008        assert!(
16009            !reason.is_empty(),
16010            "FontePinShape reason must be non-empty for whitespace-bearing :rev"
16011        );
16012    }
16013
16014    #[test]
16015    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
16016        // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
16017        // variant on this axis names the offending dep's `:nome` + the
16018        // `:rev` axis + the offending value verbatim, so the author's
16019        // grep target is the literal `:rev "<value>"` block in
16020        // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
16021        // carries_offending_nome_pin_value` test on the refname-shaped
16022        // (`:tag` / `:branch`) axes.
16023        let d = dep_with_fonte(DepSource::Git {
16024            repo: "github:p/x".into(),
16025            tag: None,
16026            rev: Some("not-a-sha".into()),
16027            branch: None,
16028        });
16029        let msg = d
16030            .validate()
16031            .expect_err(":rev: expected FontePinShape")
16032            .to_string();
16033        assert!(
16034            msg.contains("\"caixa-teia\""),
16035            ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16036        );
16037        assert!(
16038            msg.contains(":rev"),
16039            ":rev: diagnostic must name the offending pin axis, got {msg:?}"
16040        );
16041        assert!(
16042            msg.contains("not-a-sha"),
16043            ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
16044        );
16045    }
16046
16047    #[test]
16048    fn fonte_pin_empty_fires_before_pin_shape() {
16049        // Order pin: a `Some("")` `:tag` is the more self-locating
16050        // diagnostic (the author chose an axis but left it blank;
16051        // grep is unambiguous), so it fires before the shape gate
16052        // even when both arms would match. Pinned so a future
16053        // reordering surfaces here. Mirrors the
16054        // `fonte_repo_empty_fires_before_pin_missing` ordering
16055        // discipline on the peer per-axis arms.
16056        let d = dep_with_fonte(DepSource::Git {
16057            repo: "github:pleme-io/caixa-teia".into(),
16058            tag: Some(String::new()),
16059            rev: None,
16060            branch: None,
16061        });
16062        assert!(matches!(
16063            d.validate().unwrap_err(),
16064            DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
16065        ));
16066    }
16067
16068    #[test]
16069    fn fonte_pin_shape_fires_after_repo_empty() {
16070        // Order pin: `:repo ""` is the more self-locating axis
16071        // (every git source needs a repo; the per-pin shape gate is
16072        // secondary), so the repo-empty arm fires before the
16073        // per-pin shape arm even when both are violated. Pinned so
16074        // a future reordering surfaces here. Mirrors
16075        // `fonte_repo_empty_fires_before_pin_missing` on the
16076        // adjacent axis pair.
16077        let d = dep_with_fonte(DepSource::Git {
16078            repo: String::new(),
16079            tag: Some("v0.1.0 ".into()),
16080            rev: None,
16081            branch: None,
16082        });
16083        assert!(matches!(
16084            d.validate().unwrap_err(),
16085            DepError::FonteRepoEmpty { .. }
16086        ));
16087    }
16088
16089    #[test]
16090    fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
16091        // Diagnostic-shape pin across both refname-shaped axes
16092        // (`:tag` + `:branch`): every `FontePinShape` variant names
16093        // the offending dep's `:nome` + the offending pin axis + the
16094        // offending value verbatim, so the author's grep target is
16095        // unambiguous (the literal `:tag "<value>"` / `:branch
16096        // "<value>"` lands in caixa.lisp with quotes). Cover both
16097        // pin axes so a future variant addition forces a parallel
16098        // diagnostic-shape decision.
16099        for (pin_label, fonte) in [
16100            (
16101                ":tag",
16102                DepSource::Git {
16103                    repo: "github:p/x".into(),
16104                    tag: Some("v0.1.0~1".into()),
16105                    rev: None,
16106                    branch: None,
16107                },
16108            ),
16109            (
16110                ":branch",
16111                DepSource::Git {
16112                    repo: "github:p/x".into(),
16113                    tag: None,
16114                    rev: None,
16115                    branch: Some("feature/foo*".into()),
16116                },
16117            ),
16118        ] {
16119            let d = dep_with_fonte(fonte);
16120            let msg = d
16121                .validate()
16122                .expect_err(&format!("{pin_label}: expected FontePinShape"))
16123                .to_string();
16124            assert!(
16125                msg.contains("\"caixa-teia\""),
16126                "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
16127            );
16128            assert!(
16129                msg.contains(pin_label),
16130                "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
16131            );
16132        }
16133    }
16134
16135    #[test]
16136    fn git_source_json_round_trip() {
16137        let src = DepSource::Git {
16138            repo: "github:pleme-io/caixa-teia".into(),
16139            tag: Some("v0.1.0".into()),
16140            rev: None,
16141            branch: None,
16142        };
16143        let s = serde_json::to_string(&src).unwrap();
16144        assert!(s.contains(&format!(
16145            r#""{tipo}":"{git}""#,
16146            tipo = crate::render::DEP_SOURCE_KEY_TIPO,
16147            git = crate::render::DEP_SOURCE_TIPO_GIT,
16148        )));
16149        assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
16150        assert!(s.contains(r#""tag":"v0.1.0""#));
16151        assert!(!s.contains("rev"));
16152        assert!(!s.contains("branch"));
16153        let round: DepSource = serde_json::from_str(&s).unwrap();
16154        assert_eq!(round, src);
16155    }
16156
16157    // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
16158    //
16159    // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
16160    // attribute on [`DepSource`] pins three load-bearing byte-sequences
16161    // that flow into every serialized `Dep.fonte` block: the outer
16162    // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
16163    // the two admitted variant-tag values `"git"` / `"path"` the
16164    // `rename_all = "lowercase"` attribute pins as the discriminator's
16165    // closed-set arms. The three pin tests below round-trip a
16166    // fully-populated variant of each arm through
16167    // [`serde_json::to_value`] and assert each canonical byte-sequence
16168    // appears at its axis — pins a hypothetical future
16169    // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
16170    // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
16171    // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
16172    // at build time rather than at fetch time when the resolver's
16173    // `Dep.fonte` dispatch silently fails to match on the drifted
16174    // discriminator. Same "serialize-and-check" discipline the peer
16175    // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
16176    // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
16177    // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
16178    // family in caixa-core lacking a lifted peer.
16179
16180    #[test]
16181    fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
16182        // Fail-before-pass-after: a future `tag = "type"` at the derive
16183        // attribute would serialize under `"type":"git"`, and this test
16184        // would trip because `"tipo"` no longer appears at the emitted
16185        // discriminator key. A future `rename_all = "kebab-case"` /
16186        // `"snake_case"` (both no-ops on `Git` since it lacks internal
16187        // word boundaries) is caught by the sibling
16188        // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
16189        // pin below (Path has no internal boundary either but the pair
16190        // catches any per-arm inconsistency). A future variant rename
16191        // `Git` → `Repository` would emit `"tipo":"repository"` and
16192        // trip this pin.
16193        let src = DepSource::Git {
16194            repo: "github:pleme-io/caixa-teia".into(),
16195            tag: Some("v0.1.0".into()),
16196            rev: None,
16197            branch: None,
16198        };
16199        let json = serde_json::to_value(&src).unwrap();
16200        let obj = json.as_object().expect("Git serializes as a JSON object");
16201        assert_eq!(
16202            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16203                .and_then(serde_json::Value::as_str),
16204            Some(crate::render::DEP_SOURCE_TIPO_GIT),
16205            "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16206             with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
16207             detected in {json}"
16208        );
16209    }
16210
16211    #[test]
16212    fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
16213        // Fail-before-pass-after: a future variant rename `Path` →
16214        // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
16215        // this pin. A per-consumer disambiguation as the `defcaixa`
16216        // macro stabilizes ("caminho" → "path" for English-uniformity)
16217        // is scoped to the inner field key, not the discriminator; this
16218        // pin is orthogonal to that and catches only the outer
16219        // discriminator drift.
16220        let src = DepSource::Path {
16221            caminho: "../caixa-teia".into(),
16222        };
16223        let json = serde_json::to_value(&src).unwrap();
16224        let obj = json.as_object().expect("Path serializes as a JSON object");
16225        assert_eq!(
16226            obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
16227                .and_then(serde_json::Value::as_str),
16228            Some(crate::render::DEP_SOURCE_TIPO_PATH),
16229            "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
16230             with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
16231             detected in {json}"
16232        );
16233    }
16234
16235    #[test]
16236    fn dep_source_key_consts_are_pairwise_distinct() {
16237        // Cross-axis collapse detector: a hypothetical future edit that
16238        // accidentally set two of the three consts to the same byte
16239        // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
16240        // pass every per-arm serialize pin above but silently collapse
16241        // the discriminator's closed-set arms onto one another; this pin
16242        // catches the collapse at build time.
16243        assert_ne!(
16244            crate::render::DEP_SOURCE_KEY_TIPO,
16245            crate::render::DEP_SOURCE_TIPO_GIT,
16246        );
16247        assert_ne!(
16248            crate::render::DEP_SOURCE_KEY_TIPO,
16249            crate::render::DEP_SOURCE_TIPO_PATH,
16250        );
16251        assert_ne!(
16252            crate::render::DEP_SOURCE_TIPO_GIT,
16253            crate::render::DEP_SOURCE_TIPO_PATH,
16254        );
16255    }
16256
16257    #[test]
16258    fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
16259        // Shape pin against `rename_all` drift: the two variant-tag
16260        // consts must be ASCII-lowercase-only to match the
16261        // `rename_all = "lowercase"` attribute the derive uses; a future
16262        // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
16263        // would emit `"GIT"` / `"Git"` instead and trip this pin.
16264        for (label, s) in [
16265            ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
16266            ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
16267        ] {
16268            assert!(!s.is_empty(), "{label} must not be empty");
16269            assert!(
16270                s.bytes().all(|b| b.is_ascii_lowercase()),
16271                "{label} must be ASCII-lowercase-only (matching \
16272                 rename_all = \"lowercase\"), got {s:?}",
16273            );
16274        }
16275    }
16276
16277    // ── per-entry :caracteristicas set-not-multiset gate ────────────
16278    //
16279    // Every Vec-keyed-by-name authoring surface on the typed Caixa
16280    // surface that identifies its entries by a name field now uniformly
16281    // closes the set-not-multiset discipline at build time (cite
16282    // `validate_caracteristicas`'s peer-axis enumeration). The
16283    // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
16284    // set-shaped (a feature is either enabled or not — there is no
16285    // `feature × 2` semantic), so two entries naming the same feature
16286    // are a redundant declaration the caixa-resolver's lacre pipeline
16287    // would silently dedup at resolve time. The empty-feature arm
16288    // closes the parallel "operationally-meaningless value" axis on
16289    // the same slot. Same linear-walk + `HashSet` + first-collision
16290    // shape every peer set gate uses; same empty-first cascade every
16291    // peer per-entry shape + duplicate gate uses (the empty-feature
16292    // axis is the more-actionable defect since two `""` entries would
16293    // both report `caracteristica: ""` under a duplicate-first
16294    // ordering, with no way to distinguish the offending site).
16295
16296    fn dep_with_features(features: &[&str]) -> Dep {
16297        Dep {
16298            nome: "caixa-teia".into(),
16299            versao: "^0.1".into(),
16300            fonte: None,
16301            opcional: false,
16302            caracteristicas: features.iter().map(|s| (*s).into()).collect(),
16303        }
16304    }
16305
16306    #[test]
16307    fn validate_rejects_empty_caracteristica() {
16308        // Fail-before-pass-after pin: every pre-gate codebase accepted
16309        // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
16310        // imposed no per-entry shape contract), the dep validated, and
16311        // the empty feature would have reached the future caixa-resolver
16312        // lacre pipeline as a no-op feature enable — silently dropping
16313        // the author's intent far from the source `caixa.lisp`. The new
16314        // gate surfaces the structural defect at the typed-validate
16315        // surface with a self-locating diagnostic naming the offending
16316        // dep's `:nome`.
16317        let d = dep_with_features(&[""]);
16318        assert!(
16319            matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
16320            "expected CaracteristicaEmpty, got {:?}",
16321            d.validate(),
16322        );
16323    }
16324
16325    #[test]
16326    fn validate_rejects_duplicate_caracteristica() {
16327        // Fail-before-pass-after pin on the set-not-multiset arm: the
16328        // feature-toggle slot is set-shaped, so `(:caracteristicas
16329        // ("http" "http"))` is a redundant declaration the lacre
16330        // pipeline dedupes silently at resolve time. The diagnostic
16331        // names the offending dep + the colliding feature verbatim so
16332        // the author can grep their caixa.lisp for `:caracteristicas`
16333        // and fix it in one edit. First-collision determinism is
16334        // pinned separately below.
16335        let d = dep_with_features(&["http", "http"]);
16336        assert!(
16337            matches!(
16338                d.validate().unwrap_err(),
16339                DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
16340                    if nome == "caixa-teia" && caracteristica == "http"
16341            ),
16342            "expected CaracteristicaDuplicate, got {:?}",
16343            d.validate(),
16344        );
16345    }
16346
16347    #[test]
16348    fn validate_accepts_distinct_caracteristicas() {
16349        // The canonical authoring shape — every feature distinct — must
16350        // remain a clean pass (positive control sweep). Covers the
16351        // canonical kebab-case feature names a target caixa typically
16352        // declares.
16353        dep_with_features(&["http", "json", "tls"])
16354            .validate()
16355            .unwrap();
16356    }
16357
16358    #[test]
16359    fn validate_accepts_single_caracteristica() {
16360        // Single-element list is the minimum non-empty shape; passes
16361        // the gate as the identity of the duplicate check (no second
16362        // entry to collide with).
16363        dep_with_features(&["http"]).validate().unwrap();
16364    }
16365
16366    #[test]
16367    fn validate_accepts_empty_caracteristicas_list() {
16368        // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
16369        // produces `caracteristicas: Vec::new()`; the empty list is
16370        // the gate's empty-set identity and passes vacuously. Pin
16371        // this so a future tightening that requires ≥1 feature
16372        // surfaces here as a test failure rather than a silent
16373        // contract narrowing.
16374        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16375        assert!(dep_with_features(&[]).validate().is_ok());
16376    }
16377
16378    #[test]
16379    fn validate_caracteristica_empty_fires_before_duplicate() {
16380        // Empty-first cascade: an entry with an empty feature *and*
16381        // duplicate entries surfaces the empty diagnostic first. The
16382        // empty-feature axis is the more-actionable defect since
16383        // `caracteristica: ""` is unambiguous; under duplicate-first
16384        // ordering the diagnostic could report the empty string from
16385        // either of two empty entries with no way to distinguish.
16386        // Mirrors the peer empty-before-duplicate ordering
16387        // discipline every per-entry shape + duplicate gate establishes
16388        // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
16389        // `DuplicateChildCaixa`, `validate_membros`'s
16390        // `MembroCaixaEmpty` arm before `MembroDuplicate`).
16391        let d = dep_with_features(&["", "http", "http"]);
16392        assert!(matches!(
16393            d.validate().unwrap_err(),
16394            DepError::CaracteristicaEmpty { .. }
16395        ));
16396    }
16397
16398    #[test]
16399    fn validate_caracteristica_duplicate_first_collision_determinism() {
16400        // Three matching entries: the second occurrence surfaces the
16401        // diagnostic (the second is the first *collision* — the first
16402        // entry is the establishing one, not a duplicate). Mirrors
16403        // every peer first-collision posture
16404        // (`SupervisorError::DuplicateChildCaixa` reports the second
16405        // collision, `AplicacaoError::MembroDuplicate` reports the
16406        // second, `DepError::DuplicateNome` reports the second).
16407        // Pinning this so a future shortcut that flips to last-
16408        // collision (or non-deterministic) surfaces here.
16409        let d = dep_with_features(&["http", "http", "http"]);
16410        assert!(matches!(
16411            d.validate().unwrap_err(),
16412            DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
16413        ));
16414    }
16415
16416    #[test]
16417    fn validate_per_entry_shape_fires_before_caracteristicas() {
16418        // Per-entry shape precedence: a dep with a malformed `:nome`
16419        // (uppercase) AND duplicate `:caracteristicas` surfaces the
16420        // narrower `NomeInvalid` diagnostic first, not the set-gate
16421        // diagnostic. The `:nome` is the self-locating axis (every
16422        // diagnostic from the caracteristicas gate quotes the
16423        // offending dep's `:nome` to anchor the grep target —
16424        // surfacing the malformed name first keeps that anchor
16425        // valid). Same precedence shape every peer per-entry-shape
16426        // arm establishes against its peer set-gate
16427        // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
16428        // on the cross-entry `:nome` axis).
16429        let d = Dep {
16430            nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
16431            versao: "^0.1".into(),
16432            fonte: None,
16433            opcional: false,
16434            caracteristicas: vec!["http".into(), "http".into()],
16435        };
16436        assert!(matches!(
16437            d.validate().unwrap_err(),
16438            DepError::NomeInvalid { .. }
16439        ));
16440    }
16441
16442    // ── per-entry :caracteristicas value-shape gate ──────────────────
16443    //
16444    // Until this gate landed `:caracteristicas` only refused the empty
16445    // string and cross-entry duplicates: a non-empty distinct but
16446    // structurally invalid feature name silently passed validate and the
16447    // failure surfaced at `cargo metadata` time as Cargo's
16448    // `restricted_names::validate_feature_name` parser rejection, far from
16449    // the source `caixa.lisp` with no field naming which `:deps` entry's
16450    // `:caracteristicas` carried the typo. The lifted predicate makes the
16451    // Cargo-feature-name-grammar intersection-floor a substrate-level
16452    // invariant at validate time. Same trajectory as the eight peer
16453    // value-shape predicates each typed surface downstream of a structured
16454    // grammar already follows.
16455
16456    #[test]
16457    fn validate_rejects_caracteristica_with_leading_plus() {
16458        // Fail-before-pass-after pin on the canonical Cargo
16459        // `+<feature>` activation-form-in-feature-name-slot footgun.
16460        // Cargo's `[dependencies.<dep>.features]` list grammar accepts
16461        // `+optional-feature` as an enablement of a previously-disabled
16462        // feature; pasting that activation form into `:caracteristicas`
16463        // (which names the feature itself) silently passed pre-gate and
16464        // failed at `cargo metadata` parse time.
16465        let d = dep_with_features(&["+http"]);
16466        let err = d.validate().unwrap_err();
16467        assert!(
16468            matches!(
16469                err,
16470                DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
16471                    if nome == "caixa-teia" && caracteristica == "+http"
16472            ),
16473            "expected CaracteristicaInvalid, got {err:?}"
16474        );
16475    }
16476
16477    #[test]
16478    fn validate_rejects_caracteristica_with_leading_hyphen() {
16479        // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
16480        // is a legitimate continuation character (kebab-case feature
16481        // names like `runtime-tokio` pass) but Cargo rejects it at the
16482        // start; the structural defect — and its CLI-argument-injection
16483        // adjacency at any downstream Cargo subprocess invocation — is
16484        // closed at validate time, not at `cargo metadata` time.
16485        let d = dep_with_features(&["-json"]);
16486        let err = d.validate().unwrap_err();
16487        assert!(
16488            matches!(
16489                err,
16490                DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
16491            ),
16492            "expected CaracteristicaInvalid, got {err:?}"
16493        );
16494    }
16495
16496    #[test]
16497    fn validate_rejects_caracteristica_with_leading_dot() {
16498        // Fail-before-pass-after pin on the leading-dot footgun. `.` is
16499        // a legitimate continuation character (version-suffix shapes
16500        // like `feat.v2` pass) but the leading-dot form is the
16501        // canonical dotted-version-suffix-as-feature-name confusion.
16502        let d = dep_with_features(&[".feat"]);
16503        let err = d.validate().unwrap_err();
16504        assert!(matches!(
16505            err,
16506            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
16507        ));
16508    }
16509
16510    #[test]
16511    fn validate_rejects_caracteristica_with_whitespace() {
16512        // Fail-before-pass-after pin on the embedded-whitespace footgun:
16513        // a feature name with a space inside is structurally a multi-
16514        // token blob (the canonical paste-from-doc footgun, or an
16515        // accidental `"http server"` where the author meant
16516        // `"http-server"`).
16517        let d = dep_with_features(&["http feature"]);
16518        let err = d.validate().unwrap_err();
16519        assert!(matches!(
16520            err,
16521            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
16522        ));
16523    }
16524
16525    #[test]
16526    fn validate_rejects_caracteristica_with_comma() {
16527        // Fail-before-pass-after pin on the embedded-comma footgun:
16528        // the list-separator-belongs-to-the-list-grammar
16529        // miscomprehension where the author writes
16530        // `:caracteristicas ("http,json")` intending two features but
16531        // the `Vec<String>` field consumes the bare token as one entry.
16532        let d = dep_with_features(&["http,json"]);
16533        let err = d.validate().unwrap_err();
16534        assert!(matches!(
16535            err,
16536            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
16537        ));
16538    }
16539
16540    #[test]
16541    fn validate_rejects_caracteristica_with_slash() {
16542        // Fail-before-pass-after pin on the embedded-slash footgun:
16543        // Cargo's `dep/feat` namespaced-dep syntax applies inside
16544        // `[dependencies.<dep>.features]` list entries that already
16545        // name the parent dep (so the syntax says "enable feature
16546        // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16547        // per-dep already (a sibling slot on the `Dep` itself), so the
16548        // segment separator within an entry must be `-`, `_`, `+`,
16549        // or `.`. The diagnostic remediation points at the canonical
16550        // Cargo namespaced-dep discipline.
16551        let d = dep_with_features(&["http/json"]);
16552        let err = d.validate().unwrap_err();
16553        assert!(matches!(
16554            err,
16555            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16556        ));
16557    }
16558
16559    #[test]
16560    fn validate_rejects_caracteristica_with_non_ascii() {
16561        // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16562        // byte footgun: NFC-vs-NFD normalization across filesystems
16563        // silently rewrites the feature-key, breaking the lacre's
16564        // content-addressing invariant. Pinned at a canonical
16565        // smart-quote-paste shape (`café`) where the raw `é` byte is the
16566        // documented APFS round-trip break.
16567        let d = dep_with_features(&["caf\u{e9}"]);
16568        let err = d.validate().unwrap_err();
16569        assert!(matches!(
16570            err,
16571            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16572        ));
16573    }
16574
16575    #[test]
16576    fn validate_rejects_caracteristica_with_control_character() {
16577        // Fail-before-pass-after pin on the embedded-control-character
16578        // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16579        // feature name is the canonical paste-from-multiline-doc
16580        // footgun the predicate's reason wording specifically calls out.
16581        let d = dep_with_features(&["http\njson"]);
16582        let err = d.validate().unwrap_err();
16583        assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16584    }
16585
16586    #[test]
16587    fn validate_accepts_canonical_caracteristicas_shapes() {
16588        // Positive control sweep: every canonical Cargo feature name
16589        // shape the pleme-io ecosystem uses must still pass. Mirrors
16590        // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16591        // sweep — drift between either landing site and the predicate's
16592        // accepted set is a build error visible at this pair of tests,
16593        // not a per-renderer "this passed validate but failed at
16594        // cargo metadata time" surprise on the next acceptance.
16595        for s in [
16596            "http",
16597            "json",
16598            "derive",
16599            "serde_json",
16600            "runtime-tokio",
16601            "tokio.full",
16602            "v0.1",
16603            "http+json",
16604            "_internal",
16605            "__private",
16606            "default",
16607            "rt-multi-thread",
16608            "feat.v2",
16609        ] {
16610            let d = dep_with_features(&[s]);
16611            d.validate().unwrap_or_else(|e| {
16612                panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16613            });
16614        }
16615    }
16616
16617    #[test]
16618    fn validate_caracteristica_empty_fires_before_invalid() {
16619        // Cascade precedence pin: an entry list with both an empty
16620        // feature AND an invalid-shape feature surfaces the
16621        // `CaracteristicaEmpty` arm first (the empty value carries no
16622        // self-locating data — `caracteristica: ""` is the diagnostic
16623        // with no way to anchor a grep target — so closing the empty
16624        // axis first preserves the per-entry-shape diagnostic's
16625        // self-locating discipline). Same empty-first cascade every
16626        // peer per-entry shape gate establishes
16627        // (`SupervisorSpec::validate`'s `EmptyChildName` before
16628        // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16629        // before `MembroCaixaInvalid`).
16630        let d = dep_with_features(&["", "+http"]);
16631        assert!(matches!(
16632            d.validate().unwrap_err(),
16633            DepError::CaracteristicaEmpty { .. }
16634        ));
16635    }
16636
16637    #[test]
16638    fn validate_caracteristica_invalid_fires_before_duplicate() {
16639        // Per-entry-shape precedence pin: an entry list with the same
16640        // invalid feature shape declared twice surfaces the
16641        // `CaracteristicaInvalid` diagnostic on the first entry, not
16642        // the `CaracteristicaDuplicate` on the second collision. The
16643        // per-entry shape gate fires before the cross-entry set gate
16644        // — same precedence shape every peer two-arm-plus-set gate
16645        // establishes (`SupervisorSpec::validate`'s
16646        // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16647        // `validate_membros`'s `MembroCaixaInvalid` before
16648        // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16649        // cross-list `DuplicateNome`).
16650        let d = dep_with_features(&["+http", "+http"]);
16651        assert!(matches!(
16652            d.validate().unwrap_err(),
16653            DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16654        ));
16655    }
16656
16657    #[test]
16658    fn validate_rejects_caracteristica_at_65_byte_boundary() {
16659        // Boundary pin on the 64-byte cap — both the boundary-accepting
16660        // case and the boundary-exceeding case in one place, so a
16661        // future cap shift surfaces both arms simultaneously, mirroring
16662        // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16663        // predicate-level pin at the dep-axis landing site.
16664        let max_ok = "a".repeat(64);
16665        dep_with_features(&[&max_ok])
16666            .validate()
16667            .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16668        let too_long = "a".repeat(65);
16669        let d = dep_with_features(&[&too_long]);
16670        assert!(matches!(
16671            d.validate().unwrap_err(),
16672            DepError::CaracteristicaInvalid { .. }
16673        ));
16674    }
16675
16676    // ── self-dep cross-slot gate ─────────────────────────────────────
16677
16678    #[test]
16679    fn validate_no_self_dep_rejects_self_in_deps() {
16680        // A caixa whose `:deps` lists its own `:nome` is a one-node
16681        // cycle in the lacre closure's dep-graph traversal — rejected,
16682        // naming the parent and the offending list tag.
16683        let deps = vec![
16684            Dep::simple("caixa-teia", "^0.1"),
16685            Dep::simple("orquestra", "^0.1"),
16686        ];
16687        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16688        assert!(
16689            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16690            "got {err:?}"
16691        );
16692    }
16693
16694    #[test]
16695    fn validate_no_self_dep_rejects_self_in_deps_dev() {
16696        // Same gate on the `:deps-dev` axis — neither dep list is a
16697        // second-class citizen on the self-edge invariant.
16698        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16699        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16700        assert!(
16701            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16702            "got {err:?}"
16703        );
16704    }
16705
16706    #[test]
16707    fn validate_no_self_dep_deps_fires_before_deps_dev() {
16708        // Walk order pin: a caixa that self-references on both lists
16709        // surfaces the `:deps` arm first — the load-bearing axis the
16710        // lacre closure resolves at every build. Mirrors the canonical
16711        // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16712        let deps = vec![Dep::simple("orquestra", "^0.1")];
16713        let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16714        let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16715        assert!(
16716            matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16717            "got {err:?}"
16718        );
16719    }
16720
16721    #[test]
16722    fn validate_no_self_dep_accepts_distinct_names() {
16723        // Positive control: every dep names a distinct caixa. The
16724        // canonical author surface — peer of
16725        // [`validate_no_self_supervision_accepts_distinct_children`].
16726        let deps = vec![
16727            Dep::simple("caixa-teia", "^0.1"),
16728            Dep::simple("caixa-arch", "^0.1"),
16729        ];
16730        let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16731        validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16732    }
16733
16734    #[test]
16735    fn validate_no_self_dep_empty_lists_pass() {
16736        // A caixa with no declared deps has nothing to self-reference —
16737        // the gate is vacuously satisfied. Peer of
16738        // [`validate_no_self_supervision_empty_children_is_ok`].
16739        validate_no_self_dep(&[], &[], "orquestra").unwrap();
16740    }
16741
16742    #[test]
16743    fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16744        // Diagnostic-shape pin (peer with
16745        // [`validate_no_self_supervision`]'s diagnostic): the error's
16746        // Display surfaces both the offending list tag and the
16747        // parent's `:nome` verbatim, so the author can grep their
16748        // caixa.lisp for the offending block in one edit. Names
16749        // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16750        // surface — every legitimate "I want to use code from this
16751        // caixa" intent routes through one of those three slots.
16752        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16753        let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16754            .unwrap_err()
16755            .to_string();
16756        assert!(
16757            rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16758            "diagnostic must name the offending list tag: {rendered}",
16759        );
16760        assert!(
16761            rendered.contains("orquestra"),
16762            "diagnostic must quote the parent caixa name: {rendered}",
16763        );
16764        assert!(
16765            rendered.contains(":bibliotecas"),
16766            "diagnostic must point at the corrective code-surface slot: {rendered}",
16767        );
16768    }
16769
16770    #[test]
16771    fn validate_no_self_dep_accepts_coincidental_substring_match() {
16772        // Identity is exact-string equality, not substring — a dep
16773        // named `"orquestra-helper"` is a distinct caixa even when the
16774        // parent is `"orquestra"`. Pin the exact-match discipline so a
16775        // future relaxation that uses `contains` surfaces here, peer
16776        // with the supervision-tree and Aplicacao-membership gates
16777        // which all use exact-string equality on the typed identity.
16778        let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16779        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16780    }
16781
16782    // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16783
16784    #[test]
16785    fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16786        // Scalar-value pin: the two author-facing kebab-case labels the
16787        // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16788        // the two-list dep-graph slot axis, one arm per typed slot.
16789        // Mirrors the peer scalar-value pin the sibling
16790        // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16791        // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16792        // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16793        // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16794        // (882f498) M3 top-level author-labels, and
16795        // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16796        // Supervisor top-level author-labels carry, so every kind-scoped
16797        // typed-slot-family axis routes through one canonical per-arm
16798        // declaration.
16799        //
16800        // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16801        // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16802        // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16803        // for symmetry) lands as an edit to exactly one const, and
16804        // every consumer that reaches for the label picks it up at
16805        // build time rather than at runtime as a downstream mismatch on
16806        // a `DepError::DuplicateNome { list: … }` diagnostic far from
16807        // the rename's commit.
16808        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16809        assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16810    }
16811
16812    #[test]
16813    fn dep_author_key_consts_are_pairwise_distinct() {
16814        // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16815        // must not collapse onto one byte-string. A future copy-paste
16816        // slip that renamed both consts to the same value (or a rebrand
16817        // that dropped the `-dev` suffix from one but not the other)
16818        // would leave every `DepError::DuplicateNome { list: … }`
16819        // diagnostic naming an unattributable list — the linter would
16820        // route the author to the wrong caixa.lisp block, or the
16821        // cross-list precedence gate
16822        // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16823        // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16824        // duplicate. Peer of the sibling
16825        // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16826        // other top-level kind-scoped slot-family axes carry
16827        // (implicitly held by their different byte-values today).
16828        assert_ne!(
16829            crate::render::DEP_AUTHOR_KEY_DEPS,
16830            crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16831            "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16832             so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16833             self-locates the offending block in the author's caixa.lisp",
16834        );
16835    }
16836
16837    #[test]
16838    fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16839        // Production-through-const pin: the two per-arm list tags
16840        // [`validate_no_self_dep`] threads onto the `list:` field of a
16841        // returned [`DepError::DepIsSelf`] route through the lifted
16842        // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16843        // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16844        // the walker (a rename that reaches one arm but not the const,
16845        // or vice versa) surfaces here at build time rather than at
16846        // runtime as a `feira lint` diagnostic naming the wrong list
16847        // tag. Mirror of the peer
16848        // [`crate::Caixa::declared_servico_slots`] production tagger
16849        // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16850        // onto the two-list dep-graph gate.
16851        let deps = vec![Dep::simple("orquestra", "^0.1")];
16852        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16853        let DepError::DepIsSelf { list, .. } = err else {
16854            panic!("expected DepIsSelf from :deps walk");
16855        };
16856        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16857
16858        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16859        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16860        let DepError::DepIsSelf { list, .. } = err else {
16861            panic!("expected DepIsSelf from :deps-dev walk");
16862        };
16863        assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16864    }
16865
16866    // ── Dep::nome accessor pins ───────────────────────────────────────
16867    //
16868    // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16869    // projection over the plain-shorthand / explicit-git / explicit-path
16870    // fixture triad the [`Dep`] docstring lists (so the accessor's
16871    // accept-set is exercised across every author-surface `:fonte`
16872    // shape); by-borrow pointer identity so the projection stays
16873    // zero-copy at every consumer site; and validate-composition through
16874    // the [`validate_no_self_dep`] cross-slot gate reading its
16875    // parent-name equality check through the lifted accessor rather than
16876    // the raw field.
16877
16878    #[test]
16879    fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16880        // Plain-shorthand form (`:fonte None`).
16881        assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16882        // Explicit git-source form with a tag pin — same accessor path.
16883        assert_eq!(
16884            Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16885            "caixa-teia",
16886        );
16887        // Explicit path-source form.
16888        assert_eq!(
16889            Dep {
16890                nome: "caixa-teia".to_string(),
16891                versao: "0.1.0".to_string(),
16892                fonte: Some(DepSource::Path {
16893                    caminho: "../caixa-teia".to_string(),
16894                }),
16895                opcional: false,
16896                caracteristicas: Vec::new(),
16897            }
16898            .nome(),
16899            "caixa-teia",
16900        );
16901        // The empty-string `:nome` sentinel (which [`Dep::validate`]
16902        // refuses through the [`DepError::NomeEmpty`] arm) still round-
16903        // trips as an empty `&str` through the accessor — the accessor is
16904        // a projection, not a gate; the gate is [`Dep::validate`].
16905        assert_eq!(Dep::simple("", "^0.1").nome(), "");
16906    }
16907
16908    #[test]
16909    fn dep_nome_is_by_borrow_pointer_identity() {
16910        // Zero-copy pin: the accessor must borrow into the field's own
16911        // storage, not clone. If a future rewrite regresses to
16912        // `self.nome.clone().leak()` or an owned-buffer shape, the two
16913        // pointers diverge and this pin fails at build time.
16914        let d = Dep::simple("caixa-teia", "^0.1");
16915        assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16916    }
16917
16918    // ── Dep::versao_requirement accessor pins ─────────────────────────
16919    //
16920    // Three coherence pins on the lifted `Dep::versao_requirement`
16921    // accessor: byte-equal projection over the plain-shorthand /
16922    // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16923    // lists plus the empty-sentinel that round-trips as `""` (the accessor
16924    // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16925    // borrow pointer identity so the projection stays zero-copy at every
16926    // consumer site; and validate-composition through the
16927    // [`crate::render::require_valid_versao_requirement`] cascade reading
16928    // its requirement-shape check through the lifted accessor rather than
16929    // the raw field.
16930    #[test]
16931    fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16932        // Plain-shorthand form (`:fonte None`).
16933        assert_eq!(
16934            Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16935            "^0.1",
16936        );
16937        // Explicit git-source form with a tag pin — same accessor path.
16938        assert_eq!(
16939            Dep::git(
16940                "caixa-teia",
16941                "~0.1.2",
16942                "github:pleme-io/caixa-teia",
16943                "v0.1.0"
16944            )
16945            .versao_requirement(),
16946            "~0.1.2",
16947        );
16948        // Explicit path-source form.
16949        assert_eq!(
16950            Dep {
16951                nome: "caixa-teia".to_string(),
16952                versao: "0.1.0".to_string(),
16953                fonte: Some(DepSource::Path {
16954                    caminho: "../caixa-teia".to_string(),
16955                }),
16956                opcional: false,
16957                caracteristicas: Vec::new(),
16958            }
16959            .versao_requirement(),
16960            "0.1.0",
16961        );
16962        // The wildcard requirement (`"*"`) — the shorthand
16963        // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16964        // verbatim through the accessor as `"*"`, same byte-shape the
16965        // author wrote.
16966        assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16967        // The empty-string `:versao` sentinel (which [`Dep::validate`]
16968        // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16969        // trips as an empty `&str` through the accessor — the accessor is
16970        // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16971        // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16972        assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16973    }
16974
16975    #[test]
16976    fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16977        // Zero-copy pin: the accessor must borrow into the field's own
16978        // storage, not clone. If a future rewrite regresses to
16979        // `self.versao.clone().leak()` or an owned-buffer shape, the two
16980        // pointers diverge and this pin fails at build time. Peer of the
16981        // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16982        // discipline extended onto the requirement-carrying axis.
16983        let d = Dep::simple("caixa-teia", "^0.1");
16984        assert!(std::ptr::eq(
16985            d.versao_requirement().as_ptr(),
16986            d.versao.as_ptr(),
16987        ));
16988    }
16989
16990    #[test]
16991    fn dep_validate_reads_requirement_through_accessor() {
16992        // Composition pin: the [`Dep::validate`]
16993        // [`crate::render::require_valid_versao_requirement`] cascade
16994        // consumes the requirement string through the lifted accessor —
16995        // both the requirement-gate input and the
16996        // [`DepError::VersaoInvalid`] error-body carrier route through
16997        // `self.versao_requirement()`. A valid requirement passes
16998        // (positive control); a malformed-but-non-empty requirement fails
16999        // and the diagnostic quotes the offending byte-string verbatim
17000        // (same shape the accessor projects), so a future regression that
17001        // detoured the requirement carrier through a different byte-
17002        // string (say the parsed `VersionReq`'s `Display`, or a
17003        // normalized rewrite) would surface here at build time. The
17004        // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
17005        // ahead of the parse arm, pinning the empty-first cascade the
17006        // accessor's `""` sentinel round-trip acknowledges.
17007        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17008        let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
17009        assert!(
17010            matches!(
17011                &err,
17012                DepError::VersaoInvalid {
17013                    nome,
17014                    versao,
17015                    ..
17016                } if nome == "caixa-teia" && versao == "v0.1",
17017            ),
17018            "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
17019        );
17020        let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
17021        assert!(
17022            matches!(
17023                &err,
17024                DepError::VersaoEmpty { nome } if nome == "caixa-teia",
17025            ),
17026            "expected VersaoEmpty from the empty-first arm, got {err:?}",
17027        );
17028    }
17029
17030    // ── Dep::fonte accessor pins ──────────────────────────────────────
17031    //
17032    // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
17033    // equal projection over the plain-shorthand (`:fonte None`) /
17034    // explicit-git-tag / explicit-path fixture triad the [`Dep`]
17035    // docstring lists (so the accessor's accept-set is exercised across
17036    // every author-surface `:fonte` shape and both `DepSource` variants);
17037    // pointer identity so the borrowed reference points into the field's
17038    // own `Option<DepSource>` storage (not a cloned side-buffer); and
17039    // validate-composition through the [`Dep::validate`] gate reading
17040    // its per-`:fonte` [`DepSource::validate`] delegation through the
17041    // lifted accessor rather than the raw `if let Some(ref fonte) =
17042    // self.fonte` bracket.
17043
17044    #[test]
17045    fn dep_fonte_returns_declared_source_across_shapes() {
17046        // Plain-shorthand form — `:fonte` omitted, accessor projects
17047        // the `None` partition the resolver-side default-fill treats
17048        // as "resolve through `github:<default-org>/<nome>`".
17049        assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
17050        // Explicit git-source form with a tag pin — same accessor path.
17051        let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17052        match git.fonte() {
17053            Some(DepSource::Git {
17054                repo,
17055                tag,
17056                rev,
17057                branch,
17058            }) => {
17059                assert_eq!(repo, "github:pleme-io/caixa-teia");
17060                assert_eq!(tag.as_deref(), Some("v0.1.0"));
17061                assert!(rev.is_none());
17062                assert!(branch.is_none());
17063            }
17064            other => panic!("expected explicit git :fonte, got {other:?}"),
17065        }
17066        // Explicit path-source form — the dev-only local-filesystem
17067        // arm the [`Dep`] docstring's third fixture carries.
17068        let path = Dep {
17069            nome: "caixa-teia".to_string(),
17070            versao: "0.1.0".to_string(),
17071            fonte: Some(DepSource::Path {
17072                caminho: "../caixa-teia".to_string(),
17073            }),
17074            opcional: false,
17075            caracteristicas: Vec::new(),
17076        };
17077        match path.fonte() {
17078            Some(DepSource::Path { caminho }) => {
17079                assert_eq!(caminho, "../caixa-teia");
17080            }
17081            other => panic!("expected explicit path :fonte, got {other:?}"),
17082        }
17083    }
17084
17085    #[test]
17086    fn dep_fonte_is_by_borrow_pointer_identity() {
17087        // Zero-copy pin: the accessor must borrow into the field's own
17088        // `Option<DepSource>` storage, not clone into a side buffer. If
17089        // a future rewrite regresses to `self.fonte.clone()` or an
17090        // owned-buffer shape, the two pointers diverge and this pin
17091        // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
17092        // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
17093        // identity pins — same by-borrow discipline extended onto the
17094        // outer-`Dep` `Option<&Composite>` composite-reference axis.
17095        let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
17096        let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
17097        let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
17098        assert!(std::ptr::eq(accessed, raw));
17099    }
17100
17101    #[test]
17102    fn dep_validate_reads_fonte_through_accessor() {
17103        // Composition pin: [`Dep::validate`]'s per-`:fonte`
17104        // [`DepSource::validate`] delegation consumes the typed slot
17105        // through the lifted accessor — an author-omitted `:fonte`
17106        // still passes the outer gate (positive control), an explicit
17107        // well-formed git source with exactly one pin passes, and a
17108        // malformed git source (empty `:repo`) surfaces the
17109        // [`DepError::FonteRepoEmpty`] variant quoting the offending
17110        // dep's `:nome` verbatim so a future regression that detoured
17111        // the `:fonte` delegation through a different path (say a
17112        // per-scope override projector) would surface here at build
17113        // time. Peer of the sibling
17114        // `dep_validate_reads_requirement_through_accessor` composition
17115        // pin on the `:versao` axis.
17116        // Positive control 1: no `:fonte` at all.
17117        Dep::simple("caixa-teia", "^0.1").validate().unwrap();
17118        // Positive control 2: well-formed git source.
17119        Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17120            .validate()
17121            .unwrap();
17122        // Negative control: empty `:repo` — the accessor still returns
17123        // `Some(&DepSource::Git { repo: "", … })` and the delegated
17124        // `DepSource::validate` gate raises the typed carrier.
17125        let bad = Dep {
17126            nome: "caixa-teia".to_string(),
17127            versao: "^0.1".to_string(),
17128            fonte: Some(DepSource::Git {
17129                repo: String::new(),
17130                tag: Some("v0.1.0".to_string()),
17131                rev: None,
17132                branch: None,
17133            }),
17134            opcional: false,
17135            caracteristicas: Vec::new(),
17136        };
17137        let err = bad.validate().unwrap_err();
17138        assert!(
17139            matches!(
17140                &err,
17141                DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
17142            ),
17143            "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
17144        );
17145    }
17146
17147    #[test]
17148    fn validate_no_self_dep_reads_parent_equality_through_accessor() {
17149        // Composition pin: the cross-slot [`validate_no_self_dep`] gate
17150        // rejects a `:deps` entry whose `:nome` equals the parent caixa's
17151        // own `:nome` through the lifted accessor rather than the raw
17152        // field. Fails-before-passes-after: with the accessor lifted the
17153        // gate reads its equality check through `dep.nome() ==
17154        // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
17155        // the diagnostic still names the offending list tag as expected.
17156        let deps = vec![Dep::simple("orquestra", "^0.1")];
17157        let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
17158        assert!(matches!(
17159            err,
17160            DepError::DepIsSelf {
17161                ref nome,
17162                list,
17163            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
17164        ));
17165        let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
17166        let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
17167        assert!(matches!(
17168            err,
17169            DepError::DepIsSelf {
17170                ref nome,
17171                list,
17172            } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17173        ));
17174        // A non-matching `:nome` passes through the accessor gate.
17175        let deps = vec![Dep::simple("caixa-teia", "^0.1")];
17176        validate_no_self_dep(&deps, &[], "orquestra").unwrap();
17177    }
17178
17179    // ── Dep::caracteristicas accessor pins ────────────────────────────
17180    //
17181    // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
17182    // byte-equal projection over the default-empty / single-entry /
17183    // multi-entry fixture triad (so the accessor's accept-set is
17184    // exercised across every author-surface `:caracteristicas` shape,
17185    // matching the peer sibling family's fixture-triad discipline); by-
17186    // borrow pointer identity so the projection stays zero-copy at every
17187    // consumer site; and validate-composition through the
17188    // [`Dep::validate_caracteristicas`] gate reading its per-entry
17189    // linear walk through the lifted accessor rather than the raw
17190    // `for c in &self.caracteristicas` bracket.
17191
17192    #[test]
17193    fn dep_caracteristicas_returns_declared_features_across_shapes() {
17194        // Default-empty form — the [`Dep::simple`] constructor's
17195        // `Vec::new()` fill; the accessor projects the empty slice
17196        // verbatim (no `None` collapse).
17197        assert!(
17198            Dep::simple("caixa-teia", "^0.1")
17199                .caracteristicas()
17200                .is_empty(),
17201        );
17202        // Single-entry form — the canonical Cargo-shaped one-feature
17203        // enable ([`crate::render::is_cargo_feature_name`] accepts the
17204        // `"http"` byte-string as a valid feature name).
17205        let one = Dep {
17206            nome: "caixa-teia".to_string(),
17207            versao: "^0.1".to_string(),
17208            fonte: None,
17209            opcional: false,
17210            caracteristicas: vec!["http".to_string()],
17211        };
17212        assert_eq!(one.caracteristicas(), &["http".to_string()]);
17213        // Multi-entry form — the substrate's set-shaped multi-feature
17214        // enable, exercising the accessor over a length-two slice with
17215        // no duplicate collapse.
17216        let two = Dep {
17217            nome: "caixa-teia".to_string(),
17218            versao: "^0.1".to_string(),
17219            fonte: None,
17220            opcional: false,
17221            caracteristicas: vec!["http".to_string(), "json".to_string()],
17222        };
17223        assert_eq!(
17224            two.caracteristicas(),
17225            &["http".to_string(), "json".to_string()],
17226        );
17227    }
17228
17229    #[test]
17230    fn dep_caracteristicas_is_by_borrow_pointer_identity() {
17231        // Zero-copy pin: the accessor must borrow into the field's own
17232        // `Vec<String>` storage, not clone into a side buffer. If a
17233        // future rewrite regresses to `self.caracteristicas.clone()` or
17234        // an owned-buffer shape, the two pointers diverge and this pin
17235        // fails at build time. Peer of the sibling per-`Dep`
17236        // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
17237        // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
17238        // borrow discipline extended onto the outer-`Dep` `&[String]`
17239        // slice-projection axis.
17240        let d = Dep {
17241            nome: "caixa-teia".to_string(),
17242            versao: "^0.1".to_string(),
17243            fonte: None,
17244            opcional: false,
17245            caracteristicas: vec!["http".to_string(), "json".to_string()],
17246        };
17247        assert!(std::ptr::eq(
17248            d.caracteristicas().as_ptr(),
17249            d.caracteristicas.as_ptr(),
17250        ));
17251    }
17252
17253    #[test]
17254    fn dep_validate_reads_caracteristicas_through_accessor() {
17255        // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
17256        // linear walk consumes the feature-toggle list through the
17257        // lifted accessor — a well-formed `:caracteristicas` set passes
17258        // (positive control), an empty-string entry surfaces the
17259        // [`DepError::CaracteristicaEmpty`] variant quoting the offending
17260        // `Dep::nome`, and a within-list duplicate surfaces the
17261        // [`DepError::CaracteristicaDuplicate`] variant so a future
17262        // regression that detoured the walk through a different byte-
17263        // string list (say a per-scope override projector) would surface
17264        // here at build time. Peer of the sibling
17265        // `dep_validate_reads_fonte_through_accessor` /
17266        // `dep_validate_reads_requirement_through_accessor` composition
17267        // pins on the `:fonte` / `:versao` axes.
17268        // Positive control: two distinct well-formed feature names pass.
17269        Dep {
17270            nome: "caixa-teia".to_string(),
17271            versao: "^0.1".to_string(),
17272            fonte: None,
17273            opcional: false,
17274            caracteristicas: vec!["http".to_string(), "json".to_string()],
17275        }
17276        .validate()
17277        .unwrap();
17278        // Negative control 1: empty-string feature-name entry — the
17279        // accessor still returns `&[""]` and the walk raises the typed
17280        // empty-first carrier.
17281        let err = Dep {
17282            nome: "caixa-teia".to_string(),
17283            versao: "^0.1".to_string(),
17284            fonte: None,
17285            opcional: false,
17286            caracteristicas: vec![String::new()],
17287        }
17288        .validate()
17289        .unwrap_err();
17290        assert!(
17291            matches!(
17292                &err,
17293                DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
17294            ),
17295            "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
17296        );
17297        // Negative control 2: within-list duplicate — the accessor's
17298        // slice view carries both entries, and the walk's dedup arm
17299        // raises the typed duplicate carrier quoting the offending
17300        // feature name verbatim.
17301        let err = Dep {
17302            nome: "caixa-teia".to_string(),
17303            versao: "^0.1".to_string(),
17304            fonte: None,
17305            opcional: false,
17306            caracteristicas: vec!["http".to_string(), "http".to_string()],
17307        }
17308        .validate()
17309        .unwrap_err();
17310        assert!(
17311            matches!(
17312                &err,
17313                DepError::CaracteristicaDuplicate {
17314                    nome,
17315                    caracteristica,
17316                } if nome == "caixa-teia" && caracteristica == "http",
17317            ),
17318            "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
17319        );
17320    }
17321
17322    // ── Dep::opcional accessor pins ───────────────────────────────────
17323    //
17324    // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
17325    // equal projection over the default-`false` / explicit-`true`
17326    // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
17327    // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
17328    // exercising the accessor's accept-set over every author-surface
17329    // `:fonte` shape × every author-surface `:opcional` shape; and by-
17330    // `Copy` idempotency so the projection stays value-return (no
17331    // silent detour to a fresh `&bool` borrow that would introduce a
17332    // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
17333    // shape elides). No composition pin — `:opcional` does not
17334    // participate in [`Dep::validate`] (an opcional dep with any bool
17335    // value is validate-accepted; the missing-source arm is a resolver-
17336    // side runtime dispatch, not a build-time refusal), so the axis
17337    // reduces to the value-shape + `Copy` pin pair the peer
17338    // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
17339    // outer-`Option<Copy>` accessor pins already carry.
17340
17341    #[test]
17342    fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
17343        // Default-`false` form via the [`Dep::simple`] constructor —
17344        // the accessor projects the `false` bit the default-fill sets.
17345        assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
17346        // Default-`false` form via the [`Dep::git`] constructor — same
17347        // default fill; the accessor projects `false` regardless of the
17348        // `:fonte` arm.
17349        assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
17350        // Explicit-`true` form × plain-shorthand `:fonte` — the
17351        // canonical author-surface "this dep may be missing" shape.
17352        let plain_true = Dep {
17353            nome: "caixa-teia".to_string(),
17354            versao: "^0.1".to_string(),
17355            fonte: None,
17356            opcional: true,
17357            caracteristicas: Vec::new(),
17358        };
17359        assert!(plain_true.opcional());
17360        // Explicit-`true` form × explicit git-source — the accessor
17361        // projects the bit verbatim regardless of the `:fonte` arm.
17362        let git_true = Dep {
17363            nome: "caixa-teia".to_string(),
17364            versao: "^0.1".to_string(),
17365            fonte: Some(DepSource::Git {
17366                repo: "github:pleme-io/caixa-teia".to_string(),
17367                tag: Some("v0.1.0".to_string()),
17368                rev: None,
17369                branch: None,
17370            }),
17371            opcional: true,
17372            caracteristicas: Vec::new(),
17373        };
17374        assert!(git_true.opcional());
17375        // Explicit-`true` form × explicit path-source — the dev-only
17376        // local-filesystem arm the [`Dep`] docstring's third fixture
17377        // carries.
17378        let path_true = Dep {
17379            nome: "caixa-teia".to_string(),
17380            versao: "0.1.0".to_string(),
17381            fonte: Some(DepSource::Path {
17382                caminho: "../caixa-teia".to_string(),
17383            }),
17384            opcional: true,
17385            caracteristicas: Vec::new(),
17386        };
17387        assert!(path_true.opcional());
17388    }
17389
17390    #[test]
17391    fn dep_opcional_projects_bool_by_copy() {
17392        // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
17393        // (`bool: Copy`) — the accessor does not borrow `&self` past
17394        // the call (no lifetime on the return type), and calling the
17395        // accessor twice on the same [`Dep`] must yield discriminant-
17396        // equal values (idempotent, no side effects on `&self`). Peer
17397        // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
17398        // `max_restarts_projects_option_by_copy` (eba5211) /
17399        // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
17400        // outer-`Caixa` altitude — extended here to the outer-`Dep`
17401        // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
17402        // replaces the pointer-equality claim the sibling per-`Dep`
17403        // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
17404        // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
17405        // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
17406        // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
17407        // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
17408        // the same discriminant, so the axis reduces to discriminant
17409        // equality).
17410        //
17411        // Pins against a future silent detour that returned a fresh
17412        // `&bool` reference (which would type-check but silently
17413        // introduce a borrow of `&self` past the call, collapsing the
17414        // load-bearing "no lifetime on the return type" `Copy`
17415        // projection the plain-`Copy`-scalar axis's `bool` shape
17416        // carries) or a stale-read side effect that flipped the outer
17417        // discriminant on successive calls.
17418        for opcional in [false, true] {
17419            let d = Dep {
17420                nome: "caixa-teia".to_string(),
17421                versao: "^0.1".to_string(),
17422                fonte: None,
17423                opcional,
17424                caracteristicas: Vec::new(),
17425            };
17426            let first = d.opcional();
17427            let second = d.opcional();
17428            assert_eq!(
17429                first, second,
17430                "Dep::opcional must be idempotent — two successive calls \
17431                 on the same &self must return the same bool",
17432            );
17433            assert_eq!(
17434                first, opcional,
17435                "Dep::opcional must return :opcional verbatim by Copy — \
17436                 got {first}, expected {opcional}",
17437            );
17438            assert_eq!(
17439                d.opcional(),
17440                d.opcional,
17441                "Dep::opcional accessor and self.opcional field access \
17442                 must byte-equal — a bit-flip drift would silently split \
17443                 the paired resolver-side drop-vs-error dispatch from \
17444                 the storage-side default-fill the [`Dep::simple`] / \
17445                 [`Dep::git`] constructor pair carries",
17446            );
17447        }
17448    }
17449
17450    // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
17451
17452    #[test]
17453    fn sole_pin_returns_none_for_path_source() {
17454        // A path source carries no git-ref, so `sole_pin()` returns
17455        // `None` structurally — the sibling arm every git-fetching
17456        // consumer partitions off before reaching for a git-ref. Pins
17457        // the Path-arm branch of the accessor against a future silent
17458        // detour that treats a `Self::Path` as an unpinned-git source
17459        // and returns the wrong "no pin" signal (e.g. the empty string,
17460        // or a hard-coded `Some("HEAD")` matching the caixa-crd
17461        // path-arm `git_ref` fill).
17462        let s = DepSource::Path {
17463            caminho: "../local-caixa".to_string(),
17464        };
17465        assert_eq!(s.sole_pin(), None);
17466    }
17467
17468    #[test]
17469    fn sole_pin_returns_none_for_unpinned_git_source() {
17470        // The [`DepSource::default_github`] shorthand shape carries no
17471        // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
17472        // returns `None`. This is the shape caixa-resolver's `fetch_dep`
17473        // materializes when the author omits `:fonte` entirely, then
17474        // hands to `fetch_git` which raises `ResolveError::MissingPin`
17475        // on the `None` arm — the accessor's return matches the arm
17476        // the resolver's diagnostic keys off.
17477        let s = DepSource::default_github("pleme-io", "caixa-teia");
17478        assert_eq!(s.sole_pin(), None);
17479    }
17480
17481    #[test]
17482    fn sole_pin_returns_rev_when_only_rev_is_set() {
17483        let s = DepSource::Git {
17484            repo: "github:o/x".into(),
17485            tag: None,
17486            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17487            branch: None,
17488        };
17489        assert_eq!(
17490            s.sole_pin(),
17491            Some("deadbeefcafebabe1234567890abcdef12345678")
17492        );
17493    }
17494
17495    #[test]
17496    fn sole_pin_returns_tag_when_only_tag_is_set() {
17497        let s = DepSource::Git {
17498            repo: "github:o/x".into(),
17499            tag: Some("v0.1.0".into()),
17500            rev: None,
17501            branch: None,
17502        };
17503        assert_eq!(s.sole_pin(), Some("v0.1.0"));
17504    }
17505
17506    #[test]
17507    fn sole_pin_returns_branch_when_only_branch_is_set() {
17508        let s = DepSource::Git {
17509            repo: "github:o/x".into(),
17510            tag: None,
17511            rev: None,
17512            branch: Some("main".into()),
17513        };
17514        assert_eq!(s.sole_pin(), Some("main"));
17515    }
17516
17517    #[test]
17518    fn sole_pin_precedence_rev_beats_tag_and_branch() {
17519        // Precedence: rev > tag > branch. Validate() rejects
17520        // multiple-pin shapes, but the accessor's precedence is defined
17521        // for pre-validate consumers (the resolver's `MissingPin`
17522        // diagnostic path, the caixa-crd round-trip's default `"main"`
17523        // fallback) and as defense-in-depth if the gate is ever
17524        // bypassed. Pins the same precedence caixa-resolver's
17525        // `fetch_git` and caixa-crd's `dep_into_ref` already apply
17526        // inline.
17527        let s = DepSource::Git {
17528            repo: "github:o/x".into(),
17529            tag: Some("v1".into()),
17530            rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
17531            branch: Some("main".into()),
17532        };
17533        assert_eq!(
17534            s.sole_pin(),
17535            Some("deadbeefcafebabe1234567890abcdef12345678")
17536        );
17537    }
17538
17539    #[test]
17540    fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
17541        let s = DepSource::Git {
17542            repo: "github:o/x".into(),
17543            tag: Some("v1".into()),
17544            rev: None,
17545            branch: Some("main".into()),
17546        };
17547        assert_eq!(s.sole_pin(), Some("v1"));
17548    }
17549
17550    #[test]
17551    fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17552        // Fail-before-pass-after byte-parity pin: the substrate accessor
17553        // must return byte-identical to the inline
17554        // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17555        // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17556        // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17557        // time if the accessor's precedence silently drifts from the
17558        // consumer-side cascade — the exact drift this lift converges
17559        // to one substrate primitive to close structurally.
17560        //
17561        // Iterates through the 2^3 = 8 combinations of (tag, rev,
17562        // branch) each-either-`None`-or-`Some`, so every arm of the
17563        // precedence cascade lands under the pin. `validate()` refuses
17564        // the 4 multi-pin combinations, but the accessor's return is
17565        // defined on all 8.
17566        let vals = [Some("R".to_string()), None];
17567        for tag in &vals {
17568            for rev in &vals {
17569                for branch in &vals {
17570                    let s = DepSource::Git {
17571                        repo: "github:o/x".into(),
17572                        tag: tag.clone(),
17573                        rev: rev.clone(),
17574                        branch: branch.clone(),
17575                    };
17576                    // The exact inline cascade the two pre-lift
17577                    // consumer sites hand-rolled, byte-for-byte.
17578                    let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17579                    assert_eq!(
17580                        s.sole_pin(),
17581                        expected,
17582                        "sole_pin() must byte-equal \
17583                         rev.or(tag).or(branch) for \
17584                         (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17585                         a drift would silently split caixa-resolver's \
17586                         fetch_git checkout target from caixa-crd's \
17587                         dep_into_ref git_ref fill",
17588                    );
17589                }
17590            }
17591        }
17592    }
17593
17594    // Fail-before-pass-after pins on the eleven
17595    // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17596    // constructors folded from the [`DepSource::validate_caminho`]
17597    // wire-up sites. Each pins the generated ctor's output to the
17598    // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17599    // any wrapper-side lowercase / trim / re-order / silent-field-swap
17600    // regression on the two-field `{ nome: nome.to_string(), caminho:
17601    // caminho.to_string() }` construction surfaces here rather than at
17602    // a downstream diagnostic-shape mismatch. Peer of the sibling
17603    // `empty_child_version_ctor_matches_struct_literal_wrap` /
17604    // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17605    // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17606    // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17607    // pins on the peer `SupervisorError` / `AplicacaoError` /
17608    // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17609
17610    #[test]
17611    fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17612        assert_eq!(
17613            DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17614            DepError::FonteCaminhoAbsolute {
17615                nome: "caixa-teia".to_string(),
17616                caminho: "/home/me/work/caixa-teia".to_string(),
17617            },
17618            "generated fonte_caminho_absolute ctor must produce byte-equal \
17619             DepError to the open-coded struct-literal wrap on the same \
17620             (&str, &str) fixture",
17621        );
17622    }
17623
17624    #[test]
17625    fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17626        assert_eq!(
17627            DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17628            DepError::FonteCaminhoTildeExpansion {
17629                nome: "caixa-teia".to_string(),
17630                caminho: "~/work/caixa-teia".to_string(),
17631            },
17632        );
17633    }
17634
17635    #[test]
17636    fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17637        assert_eq!(
17638            DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17639            DepError::FonteCaminhoVarExpansion {
17640                nome: "caixa-teia".to_string(),
17641                caminho: "$HOME/work/caixa-teia".to_string(),
17642            },
17643        );
17644    }
17645
17646    #[test]
17647    fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17648        assert_eq!(
17649            DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17650            DepError::FonteCaminhoLeadingWhitespace {
17651                nome: "caixa-teia".to_string(),
17652                caminho: " ../caixa-teia".to_string(),
17653            },
17654        );
17655    }
17656
17657    #[test]
17658    fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17659        assert_eq!(
17660            DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17661            DepError::FonteCaminhoLeadingHyphen {
17662                nome: "caixa-teia".to_string(),
17663                caminho: "-rf".to_string(),
17664            },
17665        );
17666    }
17667
17668    #[test]
17669    fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17670        assert_eq!(
17671            DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17672            DepError::FonteCaminhoBackslash {
17673                nome: "caixa-teia".to_string(),
17674                caminho: "..\\caixa-teia".to_string(),
17675            },
17676        );
17677    }
17678
17679    #[test]
17680    fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17681        assert_eq!(
17682            DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17683            DepError::FonteCaminhoShellPipe {
17684                nome: "caixa-teia".to_string(),
17685                caminho: "../caixa-teia|evil".to_string(),
17686            },
17687        );
17688    }
17689
17690    #[test]
17691    fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17692        assert_eq!(
17693            DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17694            DepError::FonteCaminhoShellSemicolon {
17695                nome: "caixa-teia".to_string(),
17696                caminho: "../caixa-teia;evil".to_string(),
17697            },
17698        );
17699    }
17700
17701    #[test]
17702    fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17703        assert_eq!(
17704            DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17705            DepError::FonteCaminhoShellBackground {
17706                nome: "caixa-teia".to_string(),
17707                caminho: "../caixa-teia&".to_string(),
17708            },
17709        );
17710    }
17711
17712    #[test]
17713    fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17714        assert_eq!(
17715            DepError::fonte_caminho_shell_command_substitution(
17716                "caixa-teia",
17717                "../caixa-teia`whoami`",
17718            ),
17719            DepError::FonteCaminhoShellCommandSubstitution {
17720                nome: "caixa-teia".to_string(),
17721                caminho: "../caixa-teia`whoami`".to_string(),
17722            },
17723        );
17724    }
17725
17726    #[test]
17727    fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17728        assert_eq!(
17729            DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17730            DepError::FonteCaminhoTrailingSlash {
17731                nome: "caixa-teia".to_string(),
17732                caminho: "../caixa-teia/".to_string(),
17733            },
17734        );
17735    }
17736
17737    #[test]
17738    fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17739        // Cross-axis pin: sweep the two constructor input axes
17740        // (`nome: &str`, `caminho: &str`) through a non-default fixture
17741        // pair against every generated arm in the
17742        // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17743        // / trim / truncate / re-order on the two-field
17744        // `{ nome, caminho }` construction — or a silent field swap
17745        // between the two axes at codegen time — surfaces here rather
17746        // than at a downstream diagnostic-shape mismatch. Peer of the
17747        // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17748        // to_string` cross-axis routing pin on the peer
17749        // `SupervisorError` envelope, extended here onto the
17750        // `DepError` `{ nome: String, caminho: String }` envelope so
17751        // every substrate-primitive ctor family in caixa-core
17752        // guarantees each `&str`-field construction routes the
17753        // caller's `&str` verbatim through `.to_string()`.
17754        let nome = "sibling-teia";
17755        let caminho = "../workspace/sibling";
17756        let cases: [(DepError, DepError); 11] = [
17757            (
17758                DepError::fonte_caminho_absolute(nome, caminho),
17759                DepError::FonteCaminhoAbsolute {
17760                    nome: nome.to_string(),
17761                    caminho: caminho.to_string(),
17762                },
17763            ),
17764            (
17765                DepError::fonte_caminho_tilde_expansion(nome, caminho),
17766                DepError::FonteCaminhoTildeExpansion {
17767                    nome: nome.to_string(),
17768                    caminho: caminho.to_string(),
17769                },
17770            ),
17771            (
17772                DepError::fonte_caminho_var_expansion(nome, caminho),
17773                DepError::FonteCaminhoVarExpansion {
17774                    nome: nome.to_string(),
17775                    caminho: caminho.to_string(),
17776                },
17777            ),
17778            (
17779                DepError::fonte_caminho_leading_whitespace(nome, caminho),
17780                DepError::FonteCaminhoLeadingWhitespace {
17781                    nome: nome.to_string(),
17782                    caminho: caminho.to_string(),
17783                },
17784            ),
17785            (
17786                DepError::fonte_caminho_leading_hyphen(nome, caminho),
17787                DepError::FonteCaminhoLeadingHyphen {
17788                    nome: nome.to_string(),
17789                    caminho: caminho.to_string(),
17790                },
17791            ),
17792            (
17793                DepError::fonte_caminho_backslash(nome, caminho),
17794                DepError::FonteCaminhoBackslash {
17795                    nome: nome.to_string(),
17796                    caminho: caminho.to_string(),
17797                },
17798            ),
17799            (
17800                DepError::fonte_caminho_shell_pipe(nome, caminho),
17801                DepError::FonteCaminhoShellPipe {
17802                    nome: nome.to_string(),
17803                    caminho: caminho.to_string(),
17804                },
17805            ),
17806            (
17807                DepError::fonte_caminho_shell_semicolon(nome, caminho),
17808                DepError::FonteCaminhoShellSemicolon {
17809                    nome: nome.to_string(),
17810                    caminho: caminho.to_string(),
17811                },
17812            ),
17813            (
17814                DepError::fonte_caminho_shell_background(nome, caminho),
17815                DepError::FonteCaminhoShellBackground {
17816                    nome: nome.to_string(),
17817                    caminho: caminho.to_string(),
17818                },
17819            ),
17820            (
17821                DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17822                DepError::FonteCaminhoShellCommandSubstitution {
17823                    nome: nome.to_string(),
17824                    caminho: caminho.to_string(),
17825                },
17826            ),
17827            (
17828                DepError::fonte_caminho_trailing_slash(nome, caminho),
17829                DepError::FonteCaminhoTrailingSlash {
17830                    nome: nome.to_string(),
17831                    caminho: caminho.to_string(),
17832                },
17833            ),
17834        ];
17835        for (via_ctor, via_struct_literal) in cases {
17836            assert_eq!(
17837                via_ctor, via_struct_literal,
17838                "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17839                 through `.to_string()` in declared field order — a field-swap or \
17840                 silent-conversion regression surfaces here rather than at a \
17841                 downstream diagnostic-shape mismatch",
17842            );
17843        }
17844    }
17845
17846    // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17847    //    envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17848    //    (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17849    //    enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17850    //    `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17851
17852    #[test]
17853    fn versao_empty_ctor_matches_struct_literal_wrap() {
17854        assert_eq!(
17855            DepError::versao_empty("caixa-teia"),
17856            DepError::VersaoEmpty {
17857                nome: "caixa-teia".to_string(),
17858            },
17859        );
17860    }
17861
17862    #[test]
17863    fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17864        assert_eq!(
17865            DepError::fonte_repo_empty("caixa-teia"),
17866            DepError::FonteRepoEmpty {
17867                nome: "caixa-teia".to_string(),
17868            },
17869        );
17870    }
17871
17872    #[test]
17873    fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17874        assert_eq!(
17875            DepError::fonte_pin_missing("caixa-teia"),
17876            DepError::FontePinMissing {
17877                nome: "caixa-teia".to_string(),
17878            },
17879        );
17880    }
17881
17882    #[test]
17883    fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17884        assert_eq!(
17885            DepError::fonte_caminho_empty("caixa-teia"),
17886            DepError::FonteCaminhoEmpty {
17887                nome: "caixa-teia".to_string(),
17888            },
17889        );
17890    }
17891
17892    #[test]
17893    fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17894        assert_eq!(
17895            DepError::caracteristica_empty("caixa-teia"),
17896            DepError::CaracteristicaEmpty {
17897                nome: "caixa-teia".to_string(),
17898            },
17899        );
17900    }
17901
17902    #[test]
17903    fn dep_nome_only_ctors_route_nome_through_to_string() {
17904        // Cross-axis routing pin: sweep the single constructor input
17905        // axis (`nome: &str`) through a non-default fixture against
17906        // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17907        // any wrapper-side lowercase / trim / truncate at codegen time
17908        // — or a silent field re-name away from the canonical `nome`
17909        // axis on any one variant — surfaces here rather than at a
17910        // downstream diagnostic-shape mismatch. Peer of the sibling
17911        // `fonte_caminho_ctors_route_nome_and_caminho_through_
17912        // to_string` cross-axis routing pin on the same envelope's
17913        // two-slot family (f85f145) and of the peer
17914        // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17915        // pin on the `SupervisorError` single-slot family (db09650).
17916        let nome = "sibling-teia";
17917        let cases: [(DepError, DepError); 5] = [
17918            (
17919                DepError::versao_empty(nome),
17920                DepError::VersaoEmpty {
17921                    nome: nome.to_string(),
17922                },
17923            ),
17924            (
17925                DepError::fonte_repo_empty(nome),
17926                DepError::FonteRepoEmpty {
17927                    nome: nome.to_string(),
17928                },
17929            ),
17930            (
17931                DepError::fonte_pin_missing(nome),
17932                DepError::FontePinMissing {
17933                    nome: nome.to_string(),
17934                },
17935            ),
17936            (
17937                DepError::fonte_caminho_empty(nome),
17938                DepError::FonteCaminhoEmpty {
17939                    nome: nome.to_string(),
17940                },
17941            ),
17942            (
17943                DepError::caracteristica_empty(nome),
17944                DepError::CaracteristicaEmpty {
17945                    nome: nome.to_string(),
17946                },
17947            ),
17948        ];
17949        for (via_ctor, via_struct_literal) in cases {
17950            assert_eq!(
17951                via_ctor, via_struct_literal,
17952                "dep_nome_only_ctors!-generated ctor must route `nome` \
17953                 through `.to_string()` onto the canonical `nome` field \
17954                 — a field-rename or silent-conversion regression surfaces \
17955                 here rather than at a downstream diagnostic-shape mismatch",
17956            );
17957        }
17958    }
17959
17960    // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17961    //    &'static str }` two-slot envelope on `DepError`, strict
17962    //    sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17963    //    same envelope's `{ nome: String }` one-slot shape and of the
17964    //    peer `supervisor_caixa_only_ctors!` (db09650) on the
17965    //    `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17966
17967    #[test]
17968    fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17969        assert_eq!(
17970            DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17971            DepError::DuplicateNome {
17972                nome: "caixa-teia".to_string(),
17973                list: crate::render::DEP_AUTHOR_KEY_DEPS,
17974            },
17975            "generated duplicate_nome ctor must produce byte-equal \
17976             `DepError::DuplicateNome` to the pre-lift struct-literal \
17977             wrap on the same scalar fixtures",
17978        );
17979    }
17980
17981    #[test]
17982    fn dep_is_self_ctor_matches_struct_literal_wrap() {
17983        assert_eq!(
17984            DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17985            DepError::DepIsSelf {
17986                nome: "orquestra".to_string(),
17987                list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17988            },
17989            "generated dep_is_self ctor must produce byte-equal \
17990             `DepError::DepIsSelf` to the pre-lift struct-literal \
17991             wrap on the same scalar fixtures",
17992        );
17993    }
17994
17995    #[test]
17996    fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17997        // Cross-axis routing pin: sweep the two constructor input axes
17998        // (`nome: &str`, `list: &'static str`) through non-default
17999        // fixtures against every generated arm in the
18000        // [`dep_nome_list_ctors!`] macro, so any wrapper-side
18001        // lowercase / trim / truncate at codegen time — or a silent
18002        // field re-name away from the canonical `nome` / `list` axes
18003        // on any one variant, or a `list` axis silently rerouted
18004        // through `.to_string()` instead of passed as `&'static str`
18005        // verbatim — surfaces here rather than at a downstream
18006        // diagnostic-shape mismatch. Peer of the sibling
18007        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18008        // (792aa92) on the same envelope's one-slot family, and of the
18009        // peer
18010        // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
18011        // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
18012        // two-slot `{ caixa: String, reason: String }` shape.
18013        let nome = "sibling-teia";
18014        let cases: [(DepError, DepError); 4] = [
18015            (
18016                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18017                DepError::DuplicateNome {
18018                    nome: nome.to_string(),
18019                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18020                },
18021            ),
18022            (
18023                DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18024                DepError::DuplicateNome {
18025                    nome: nome.to_string(),
18026                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18027                },
18028            ),
18029            (
18030                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
18031                DepError::DepIsSelf {
18032                    nome: nome.to_string(),
18033                    list: crate::render::DEP_AUTHOR_KEY_DEPS,
18034                },
18035            ),
18036            (
18037                DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
18038                DepError::DepIsSelf {
18039                    nome: nome.to_string(),
18040                    list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18041                },
18042            ),
18043        ];
18044        for (via_ctor, via_struct_literal) in cases {
18045            assert_eq!(
18046                via_ctor, via_struct_literal,
18047                "dep_nome_list_ctors!-generated ctor must route `nome` \
18048                 through `.to_string()` onto the canonical `nome` field \
18049                 and pass `list` verbatim onto the canonical `&'static str` \
18050                 `list` field — a field-rename, silent-conversion, or \
18051                 axis-swap regression surfaces here rather than at a \
18052                 downstream diagnostic-shape mismatch",
18053            );
18054        }
18055    }
18056
18057    // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
18058    //    value: String, reason: String }` four-slot envelope on
18059    //    `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
18060    //    `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
18061    //    and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
18062    //    envelope, and of the peer `contrato_pair_value_reason_ctors!`
18063    //    (14e13f1) four-slot fold on the sibling `AplicacaoError`
18064    //    envelope. Single-variant lift closing the last open-coded ctor
18065    //    site on the `:fonte (:tipo git …)` value-shape trajectory.
18066
18067    #[test]
18068    fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
18069        // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
18070        // ctor: sweep both wire-up-shape arms (the refname-pin arm
18071        // routing `":tag"` / `":branch"` value through
18072        // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
18073        // routing `":rev"` through [`crate::render::is_git_oid`]) and
18074        // assert byte-equal `PartialEq` against the pre-lift
18075        // struct-literal, so any wrapper-side field-rename /
18076        // silent-conversion regression surfaces here rather than at a
18077        // downstream diagnostic-shape mismatch. Peer of the sibling
18078        // per-envelope byte-equal ctor pins
18079        // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
18080        // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
18081        // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
18082        assert_eq!(
18083            DepError::fonte_pin_shape(
18084                "caixa-teia",
18085                ":tag",
18086                "v0.1.0 ",
18087                "trailing whitespace".to_string(),
18088            ),
18089            DepError::FontePinShape {
18090                nome: "caixa-teia".to_string(),
18091                pin: ":tag".to_string(),
18092                value: "v0.1.0 ".to_string(),
18093                reason: "trailing whitespace".to_string(),
18094            },
18095            "fonte_pin_shape ctor must produce byte-equal \
18096             `DepError::FontePinShape` to the pre-lift struct-literal \
18097             wrap on a refname-pin (`:tag` / `:branch`) fixture",
18098        );
18099        assert_eq!(
18100            DepError::fonte_pin_shape(
18101                "caixa-teia",
18102                ":rev",
18103                "DEADBEEF",
18104                "abbreviated OID rejected".to_string(),
18105            ),
18106            DepError::FontePinShape {
18107                nome: "caixa-teia".to_string(),
18108                pin: ":rev".to_string(),
18109                value: "DEADBEEF".to_string(),
18110                reason: "abbreviated OID rejected".to_string(),
18111            },
18112            "fonte_pin_shape ctor must produce byte-equal \
18113             `DepError::FontePinShape` to the pre-lift struct-literal \
18114             wrap on a hex-OID-pin (`:rev`) fixture",
18115        );
18116    }
18117
18118    #[test]
18119    fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
18120        // Cross-axis routing pin: sweep every one of the four
18121        // constructor input axes (`nome: &str`, `pin: &str`,
18122        // `value: &str`, `reason: String`) through non-default
18123        // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
18124        // any wrapper-side lowercase / trim / truncate at codegen time
18125        // — or a silent field re-name / axis-swap on any one of the
18126        // four fields, or a `reason` axis silently routed through
18127        // `.to_string()` instead of forwarded owned — surfaces here
18128        // rather than at a downstream diagnostic-shape mismatch. Peer
18129        // of the sibling
18130        // `dep_nome_only_ctors_route_nome_through_to_string` pin
18131        // (792aa92) and
18132        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18133        // pin (6f5e0cd) on the same envelope's one- and two-slot
18134        // families. Distinct-per-axis fixtures rule out any two-axis
18135        // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
18136        // etc.) that would still pass a same-fixture-per-axis pin.
18137        let nome = "sibling-teia";
18138        let pin = ":branch";
18139        let value = "feature/bar";
18140        let reason = "embedded space".to_string();
18141        let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
18142        let via_struct_literal = DepError::FontePinShape {
18143            nome: nome.to_string(),
18144            pin: pin.to_string(),
18145            value: value.to_string(),
18146            reason: reason.clone(),
18147        };
18148        assert_eq!(
18149            via_ctor, via_struct_literal,
18150            "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
18151             through `.to_string()` onto their canonical fields and \
18152             forward `reason` owned onto the canonical `reason` field \
18153             — a field-rename, silent-conversion, or axis-swap \
18154             regression surfaces here rather than at a downstream \
18155             diagnostic-shape mismatch",
18156        );
18157        let DepError::FontePinShape {
18158            nome: n,
18159            pin: p,
18160            value: v,
18161            reason: r,
18162        } = via_ctor
18163        else {
18164            panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
18165        };
18166        assert_eq!(n, nome);
18167        assert_eq!(p, pin);
18168        assert_eq!(v, value);
18169        assert_eq!(r, reason);
18170    }
18171
18172    // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
18173    //    caminho: String, byte: u8 }` three-slot envelope on `DepError`,
18174    //    strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
18175    //    the same envelope's `{ nome: String, caminho: String }` two-slot
18176    //    shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
18177    //    same envelope's `{ nome: String }` one-slot shape.
18178
18179    #[test]
18180    fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
18181        assert_eq!(
18182            DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
18183            DepError::FonteCaminhoControlChar {
18184                nome: "caixa-teia".to_string(),
18185                caminho: "../caixa-teia\x00foo".to_string(),
18186                byte: 0x00,
18187            },
18188        );
18189    }
18190
18191    #[test]
18192    fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
18193        assert_eq!(
18194            DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
18195            DepError::FonteCaminhoShellRedirection {
18196                nome: "caixa-teia".to_string(),
18197                caminho: "../caixa-teia>log".to_string(),
18198                byte: b'>',
18199            },
18200        );
18201    }
18202
18203    #[test]
18204    #[allow(
18205        clippy::too_many_lines,
18206        reason = "cross-axis routing pin sweeps twelve typed variants, one per \
18207                  byte-classification arm on the {nome,caminho,byte} envelope; \
18208                  the linear per-variant repetition is exactly what the sweep \
18209                  is pinning — a helper macro would hide the shape the fold is \
18210                  keying on"
18211    )]
18212    fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
18213        // Cross-axis routing pin: sweep the three constructor input axes
18214        // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
18215        // non-default fixture triple against every generated arm in the
18216        // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
18217        // lowercase / trim / truncate on the two `&str` axes — a silent
18218        // field swap between `nome` and `caminho`, or a silent
18219        // re-classification of the offending byte — surfaces here rather
18220        // than at a downstream diagnostic-shape mismatch. Peer of the
18221        // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
18222        // to_string` cross-axis routing pin on the same envelope's
18223        // two-slot family (f85f145) and of the sibling
18224        // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
18225        // same envelope's one-slot family (792aa92), extended here onto
18226        // the `{ nome: String, caminho: String, byte: u8 }` three-slot
18227        // envelope so every substrate-primitive ctor family in
18228        // caixa-core's `DepError` envelope guarantees each field routes
18229        // the caller's value verbatim through `.to_string()` (or byte-
18230        // identity for `byte: u8`) in declared field order.
18231        let nome = "sibling-teia";
18232        let caminho = "../workspace/sibling";
18233        let byte = 0x2A_u8;
18234        let cases: [(DepError, DepError); 12] = [
18235            (
18236                DepError::fonte_caminho_control_char(nome, caminho, byte),
18237                DepError::FonteCaminhoControlChar {
18238                    nome: nome.to_string(),
18239                    caminho: caminho.to_string(),
18240                    byte,
18241                },
18242            ),
18243            (
18244                DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
18245                DepError::FonteCaminhoShellRedirection {
18246                    nome: nome.to_string(),
18247                    caminho: caminho.to_string(),
18248                    byte,
18249                },
18250            ),
18251            (
18252                DepError::fonte_caminho_shell_glob(nome, caminho, byte),
18253                DepError::FonteCaminhoShellGlob {
18254                    nome: nome.to_string(),
18255                    caminho: caminho.to_string(),
18256                    byte,
18257                },
18258            ),
18259            (
18260                DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
18261                DepError::FonteCaminhoShellSubshellGrouping {
18262                    nome: nome.to_string(),
18263                    caminho: caminho.to_string(),
18264                    byte,
18265                },
18266            ),
18267            (
18268                DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
18269                DepError::FonteCaminhoShellBraceExpansion {
18270                    nome: nome.to_string(),
18271                    caminho: caminho.to_string(),
18272                    byte,
18273                },
18274            ),
18275            (
18276                DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
18277                DepError::FonteCaminhoShellBracketExpansion {
18278                    nome: nome.to_string(),
18279                    caminho: caminho.to_string(),
18280                    byte,
18281                },
18282            ),
18283            (
18284                DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
18285                DepError::FonteCaminhoShellQuoteGrouping {
18286                    nome: nome.to_string(),
18287                    caminho: caminho.to_string(),
18288                    byte,
18289                },
18290            ),
18291            (
18292                DepError::fonte_caminho_shell_comment(nome, caminho, byte),
18293                DepError::FonteCaminhoShellComment {
18294                    nome: nome.to_string(),
18295                    caminho: caminho.to_string(),
18296                    byte,
18297                },
18298            ),
18299            (
18300                DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
18301                DepError::FonteCaminhoUrlPercentEncoding {
18302                    nome: nome.to_string(),
18303                    caminho: caminho.to_string(),
18304                    byte,
18305                },
18306            ),
18307            (
18308                DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
18309                DepError::FonteCaminhoShellVariableExpansion {
18310                    nome: nome.to_string(),
18311                    caminho: caminho.to_string(),
18312                    byte,
18313                },
18314            ),
18315            (
18316                DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
18317                DepError::FonteCaminhoShellHistoryExpansion {
18318                    nome: nome.to_string(),
18319                    caminho: caminho.to_string(),
18320                    byte,
18321                },
18322            ),
18323            (
18324                DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
18325                DepError::FonteCaminhoShellHistorySubstitution {
18326                    nome: nome.to_string(),
18327                    caminho: caminho.to_string(),
18328                    byte,
18329                },
18330            ),
18331        ];
18332        for (via_ctor, via_struct_literal) in cases {
18333            assert_eq!(
18334                via_ctor, via_struct_literal,
18335                "fonte_caminho_byte_ctors!-generated ctor must route \
18336                 (nome, caminho, byte) through `.to_string()` / byte-\
18337                 identity in declared field order — a field-swap or \
18338                 silent-conversion regression surfaces here rather than \
18339                 at a downstream diagnostic-shape mismatch",
18340            );
18341        }
18342    }
18343
18344    #[test]
18345    fn dep_list_as_ref_str_routes_through_as_str_accessor() {
18346        // Fail-before-pass-after byte-parity pin on the lifted
18347        // `impl AsRef<str> for DepList` — asserts the standard-
18348        // library trait impl and the substrate-primitive
18349        // [`super::DepList::as_str`] `pub const fn` accessor resolve
18350        // to the same `&str` per instance across the two-arm closed
18351        // set, so any future silent detour that routes the impl
18352        // through a divergent projection (a per-arm inline
18353        // `match self { DepList::Prod => ":deps", … }` re-inlining
18354        // that opens a compile-time link to the un-lifted arm-literal,
18355        // a swap onto a second projection axis) trips at caixa-core
18356        // test time under `PartialEq` rather than at a downstream
18357        // `impl AsRef<str>`-bound consumer's silent split. Sweeps
18358        // every one of the two arms [`super::DepList::ALL`] carries
18359        // so no arm's projection is covered only by the sibling
18360        // `Display` path. Peer of the sibling
18361        // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
18362        // (1723611) on the top-level dialect-classification closed-
18363        // set typed enum, and the peer
18364        // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
18365        // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
18366        // typed enum — the pins together close the substrate
18367        // primitive's `AsRef<str>` projection axis onto the seventh
18368        // (and last unlifted) closed-set typed enum on the caixa
18369        // surface.
18370        for &list in super::DepList::ALL {
18371            assert_eq!(
18372                <super::DepList as AsRef<str>>::as_ref(&list),
18373                list.as_str(),
18374                "AsRef<str> impl on DepList::{list:?} must byte-equal \
18375                 DepList::as_str on the same instance — divergence \
18376                 signals a silent detour off the substrate-primitive \
18377                 accessor"
18378            );
18379        }
18380    }
18381
18382    #[test]
18383    fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
18384        // Fail-before-pass-after byte-parity pin on the three-path
18385        // convergence discipline the [`super::DepList`] two-list
18386        // dep-graph closed-set typed enum now carries on the `&str`-
18387        // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
18388        // newly lifted impl), `format!("{v}")` (the pre-existing
18389        // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
18390        // primitive `pub const fn` accessor both trait impls delegate
18391        // through) must resolve to the same byte-string on every
18392        // instance across the two-arm closed set. Refuses any future
18393        // divergence between the two trait impls (a stray
18394        // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
18395        // rather than delegating through the shared accessor; a
18396        // hypothetical `AsRef<str>` rewrite that inlines a per-arm
18397        // literal cascade) that would silently split the two
18398        // projection paths of the same closed-set typed enum. Mirrors
18399        // the sibling three-path-convergence discipline the peer
18400        // [`crate::CaixaDialeto`] typed enum carries
18401        // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
18402        // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
18403        // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
18404        // d8136db), the peer [`crate::CaixaKind`] triple
18405        // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
18406        // cd2091f), and the [`crate::CaixaVersion`] typed newtype
18407        // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
18408        // 16d5c7e).
18409        for &list in super::DepList::ALL {
18410            let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
18411            let via_display: String = format!("{list}");
18412            let via_accessor: &str = list.as_str();
18413            assert_eq!(via_as_ref, via_accessor);
18414            assert_eq!(via_display, via_accessor);
18415            assert_eq!(via_as_ref, via_display.as_str());
18416        }
18417    }
18418
18419    #[test]
18420    fn dep_list_try_from_str_routes_through_from_wire_accessor() {
18421        // Fail-before-pass-after byte-parity pin on the newly lifted
18422        // `impl TryFrom<&str> for DepList` — asserts the standard-
18423        // library trait impl and the substrate-primitive
18424        // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
18425        // to the same two-arm accept-set across every arm the
18426        // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
18427        // the sibling
18428        // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
18429        // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
18430        // and the 12 other substrate-wide trait-idiomatic reverse-
18431        // projection routes-through pins — closes the campaign's
18432        // completeness gap on the two-list dep-graph closed-set enum.
18433        for &list in super::DepList::ALL {
18434            let wire = list.as_str();
18435            assert_eq!(
18436                <super::DepList as TryFrom<&str>>::try_from(wire),
18437                Ok(list),
18438                "TryFrom<&str> impl on DepList must round-trip \
18439                 DepList::{list:?}.as_str() = {wire:?} back to \
18440                 Ok(DepList::{list:?}) — divergence from \
18441                 DepList::from_wire signals a silent detour off the \
18442                 substrate-primitive accessor"
18443            );
18444            assert_eq!(
18445                <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
18446                super::DepList::from_wire(wire),
18447                "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
18448                 DepList::from_wire on the same input"
18449            );
18450        }
18451    }
18452
18453    #[test]
18454    fn dep_list_try_from_str_rejects_unknown_byte_strings() {
18455        // Rejection witness on the `impl TryFrom<&str> for DepList` —
18456        // sweeps candidate byte-strings outside the two-arm accept-set
18457        // the sibling [`super::DepList::as_str`] emits (`:deps` /
18458        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
18459        // future accidental widening of the trait impl's accept-set (a
18460        // stray case-fold path, a silent inclusion of a rebrand alias
18461        // like `":packages"`, an English rebrand `":dev-deps"` in
18462        // reverse arm-order that would silently swap the two arms) trips
18463        // at caixa-core test time. Peer of the sibling
18464        // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
18465        // (5b828ed) rejection witness.
18466        let rejected: &[&str] = &[
18467            "",
18468            " ",
18469            "\t",
18470            "\n",
18471            ":deps ",
18472            " :deps",
18473            ":DEPS",
18474            ":Deps",
18475            ":Deps-Dev",
18476            ":deps_dev",
18477            ":deps-development",
18478            ":dev-deps",
18479            ":packages",
18480            ":packages-dev",
18481            "deps",
18482            "deps-dev",
18483            "Prod",
18484            "Dev",
18485            "prod",
18486            "dev",
18487            "\":deps\"",
18488            "\":deps-dev\"",
18489            ":deps\n",
18490            ":deps-dev\n",
18491        ];
18492        for &input in rejected {
18493            assert_eq!(
18494                <super::DepList as TryFrom<&str>>::try_from(input),
18495                Err(()),
18496                "TryFrom<&str> impl on DepList must reject unknown \
18497                 byte-string {input:?} — divergence from \
18498                 DepList::from_wire on the same input signals a silent \
18499                 accept-set widening past the two lifted \
18500                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
18501            );
18502            assert_eq!(
18503                <super::DepList as TryFrom<&str>>::try_from(input).ok(),
18504                super::DepList::from_wire(input),
18505                "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
18506                 DepList::from_wire on the same input — divergence signals \
18507                 the two reverse-projection paths have drifted onto \
18508                 different accept-sets"
18509            );
18510        }
18511    }
18512
18513    #[test]
18514    fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
18515        // Fail-before-pass-after byte-parity pin on the newly lifted
18516        // `impl From<DepList> for &'static str` — asserts the standard-
18517        // library trait impl and the substrate-primitive
18518        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18519        // the same two-arm emit-set across every arm the exhaustive
18520        // [`super::DepList::ALL`] slice enumerates. Materializes the
18521        // `<&'static str as From<DepList>>::from` output in a
18522        // `const`-shape binding to make the `'static` lifetime promise
18523        // a build-time invariant — a future accidental downgrade of
18524        // either arm to a non-`&'static str` (a `String::leak()`-
18525        // produced return, a `Box::leak`-cast) trips at caixa-core
18526        // build time rather than at a downstream `'static`-bound
18527        // consumer. Peer of the sibling
18528        // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
18529        // (523157d) and the 13 other substrate-wide forward-projection
18530        // routes-through pins.
18531        const PROD: &str = super::DepList::Prod.as_str();
18532        const DEV: &str = super::DepList::Dev.as_str();
18533        for &list in super::DepList::ALL {
18534            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18535            let via_method: &'static str = list.as_str();
18536            assert_eq!(
18537                via_trait, via_method,
18538                "From<DepList> for &'static str impl must round-trip \
18539                 DepList::{list:?} to the same lifted \
18540                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18541                 DepList::as_str returns — divergence signals a silent \
18542                 detour off the substrate-primitive accessor"
18543            );
18544            let via_into: &'static str = list.into();
18545            assert_eq!(
18546                via_into, via_method,
18547                "Into<&'static str>::into on DepList::{list:?} must \
18548                 byte-equal DepList::as_str on the same input — the \
18549                 blanket-derived Into shape must resolve to the same \
18550                 as_str dispatch as the explicit From impl"
18551            );
18552        }
18553        assert_eq!(
18554            [PROD, DEV],
18555            [
18556                crate::render::DEP_AUTHOR_KEY_DEPS,
18557                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18558            ],
18559            "const-context DepList::as_str must resolve to the two lifted \
18560             DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18561             of either arm to a non-const or non-static byte-string breaks \
18562             the `&'static str`-lifetime promise the paired \
18563             From<DepList> for &'static str impl carries by construction"
18564        );
18565    }
18566
18567    #[test]
18568    fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18569        // Cross-axis partition pin: the paired trait-idiomatic
18570        // `From<DepList> for &'static str` forward projection and the
18571        // method-named [`super::DepList::as_str`] forward projection
18572        // must resolve identically on every arm, locking the two paths
18573        // together so any future detour trips at caixa-core test time.
18574        // Then a round-trip witness: every arm's forward `From` output
18575        // re-parses through the paired trait-idiomatic reverse
18576        // `TryFrom<&str>` back to the original variant, closing the
18577        // two-way `DepList ↔ &'static str` round-trip on the trait-
18578        // idiomatic axis pair, mirroring the pre-existing method-named
18579        // `as_str` + `from_wire` round-trip. Peer of the sibling
18580        // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18581        // (523157d).
18582        for &list in super::DepList::ALL {
18583            let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18584            let via_method: &'static str = list.as_str();
18585            assert_eq!(
18586                via_trait, via_method,
18587                "From<DepList> for &'static str and DepList::as_str must \
18588                 resolve identically on DepList::{list:?} — divergence \
18589                 signals the two forward-projection paths have drifted \
18590                 onto different emit-sets"
18591            );
18592        }
18593        for &list in super::DepList::ALL {
18594            let emitted: &'static str = list.into();
18595            let re_parsed: Result<super::DepList, ()> =
18596                <super::DepList as TryFrom<&str>>::try_from(emitted);
18597            assert_eq!(
18598                re_parsed,
18599                Ok(list),
18600                "trait-idiomatic axis pair must round-trip \
18601                 DepList::{list:?} through `.into::<&'static str>()` and \
18602                 back through `TryFrom<&str>` — a break signals the \
18603                 forward-emit and reverse-parse axes have drifted onto \
18604                 different vocabularies"
18605            );
18606        }
18607    }
18608
18609    #[test]
18610    fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18611        // Fail-before-pass-after byte-parity pin on the newly lifted
18612        // `impl From<&DepList> for &'static str` — asserts the borrowed-
18613        // input standard-library trait impl and the substrate-primitive
18614        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18615        // the same two-arm emit-set across every arm the exhaustive
18616        // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18617        // does not auto-derive the borrowed-input sibling from a paired
18618        // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18619        // U: From<T>` blanket in `core`), so the borrowed-input axis is
18620        // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18621        // shape over [`super::DepList::ALL`] (whose iterator yields
18622        // `&DepList`, not `DepList`) reaches through this impl and no
18623        // other — the paired owned-input [`From<DepList>`] impl requires
18624        // an explicit `.copied()` / dereference before the trait fires.
18625        // Materializes the `<&'static str as From<&DepList>>::from`
18626        // output in a `const`-shape binding to make the `'static`
18627        // lifetime promise a build-time invariant.
18628        const PROD: &str = super::DepList::Prod.as_str();
18629        const DEV: &str = super::DepList::Dev.as_str();
18630        for list in super::DepList::ALL {
18631            let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18632            let via_method: &'static str = list.as_str();
18633            assert_eq!(
18634                via_trait, via_method,
18635                "From<&DepList> for &'static str impl must round-trip \
18636                 &DepList::{list:?} to the same lifted \
18637                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18638                 DepList::as_str returns — divergence signals a silent \
18639                 detour off the substrate-primitive accessor"
18640            );
18641            let via_into: &'static str = list.into();
18642            assert_eq!(
18643                via_into, via_method,
18644                "Into<&'static str>::into on &DepList::{list:?} must \
18645                 byte-equal DepList::as_str on the same input — the \
18646                 blanket-derived Into shape must resolve to the same \
18647                 as_str dispatch as the explicit From impl"
18648            );
18649        }
18650        assert_eq!(
18651            [PROD, DEV],
18652            [
18653                crate::render::DEP_AUTHOR_KEY_DEPS,
18654                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18655            ],
18656            "const-context DepList::as_str must resolve to the two lifted \
18657             DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18658             From<&DepList> for &'static str impl inherits its `'static` \
18659             lifetime promise from the same accessor the owned-input \
18660             sibling routes through"
18661        );
18662    }
18663
18664    #[test]
18665    fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18666        // Cross-axis partition pin: the paired trait-idiomatic
18667        // owned-input `From<DepList> for &'static str` (523157d
18668        // campaign-shape) and borrowed-input `From<&DepList> for
18669        // &'static str` (this lift) forward projections must resolve
18670        // identically on every arm, locking the two input-shape paths
18671        // together so any future detour trips at caixa-core test time.
18672        // Then a witness that a `.iter().map(Into::into)` pipe over
18673        // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18674        // materializes the two-arm accept-set through the borrowed-
18675        // input axis alone — the exact shape a future M4 admission-
18676        // webhook rejection body composer, a future substrate-wide
18677        // per-arm diagnostic column, or a
18678        // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18679        //     .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18680        // through — closing the two-way owned/borrowed input-shape
18681        // symmetry on the forward-projection trait-idiomatic axis.
18682        for &list in super::DepList::ALL {
18683            let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18684            let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18685            assert_eq!(
18686                owned, borrowed,
18687                "From<DepList> and From<&DepList> for &'static str must \
18688                 resolve identically on DepList::{list:?} — divergence \
18689                 signals the owned-input and borrowed-input forward-\
18690                 projection paths have drifted onto different emit-sets"
18691            );
18692        }
18693        let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18694        let via_method: Vec<&'static str> =
18695            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18696        assert_eq!(
18697            via_iter, via_method,
18698            "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18699             `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18700             input `From<&DepList> for &'static str` axis is what makes \
18701             the `.iter().map(Into::into)` shape route through the \
18702             substrate-primitive `DepList::as_str` accessor rather than \
18703             through a per-call-site `.copied()` / dereference detour"
18704        );
18705    }
18706
18707    #[test]
18708    fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18709        // Fail-before-pass-after byte-parity pin on the newly lifted
18710        // `impl From<DepList> for String` — asserts the owned-`String`
18711        // -returning standard-library trait impl and the substrate-
18712        // primitive [`super::DepList::as_str`] `pub const fn` accessor
18713        // resolve to the same two-arm emit-set across every arm the
18714        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18715        // standard library does not carry a blanket
18716        // `impl<T: AsRef<str>> From<T> for String` (nor an
18717        // `impl<T: fmt::Display> From<T> for String`), so the
18718        // owned-`String` forward-projection axis is a distinct trait-
18719        // idiomatic surface that a `let key: String = list.into();`-
18720        // shaped call site reaches through this impl and no other — the
18721        // paired sibling `From<DepList> for &'static str` impl forces
18722        // every owned-`String` call site through an explicit
18723        // `.to_owned()` / `String::from` restatement. Peer of the
18724        // first-mover
18725        // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18726        // (7baa18a), the second-peer
18727        // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18728        // (7851725), the third-peer
18729        // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18730        // (231a18c), and the fourth-peer
18731        // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18732        // (88942cd) — extends the trait-idiomatic owned-`String`
18733        // forward-projection axis onto the fifth closed-set fieldless
18734        // typed enum on the caixa surface (the two-list dep-graph axis).
18735        for &variant in super::DepList::ALL {
18736            let via_trait: String = <String as From<super::DepList>>::from(variant);
18737            let via_method: &'static str = variant.as_str();
18738            assert_eq!(
18739                via_trait.as_str(),
18740                via_method,
18741                "From<DepList> for String impl must round-trip \
18742                 DepList::{variant:?} to the same lifted \
18743                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18744                 DepList::as_str returns — divergence signals a silent \
18745                 detour off the substrate-primitive accessor"
18746            );
18747            let via_into: String = variant.into();
18748            assert_eq!(
18749                via_into.as_str(),
18750                via_method,
18751                "Into<String>::into on DepList::{variant:?} must \
18752                 byte-equal DepList::as_str on the same input — the \
18753                 blanket-derived Into shape must resolve to the same \
18754                 as_str dispatch as the explicit From impl"
18755            );
18756        }
18757    }
18758
18759    #[test]
18760    fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18761        // Cross-axis partition pin: the paired trait-idiomatic
18762        // owned-`String` `From<DepList> for String` (this lift) and
18763        // owned-`&'static str` `From<DepList> for &'static str`
18764        // (523157d campaign-shape) forward projections must resolve
18765        // identically on every arm, locking the two return-type-shape
18766        // paths together so any future detour trips at caixa-core test
18767        // time. Also byte-parity witness against the sibling
18768        // [`ToString::to_string`] surface routed through
18769        // [`std::fmt::Display`] — the three owned-heap-string paths
18770        // (`.into::<String>()`, `String::from`, `.to_string()`) must
18771        // resolve identically on every arm so a future consumer that
18772        // picks any of the three lands on the same two-arm lifted
18773        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18774        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18775        // Then a `.iter().copied().map(String::from)` pipe witness
18776        // over [`super::DepList::ALL`] that materializes the two-arm
18777        // accept-set through the owned-`String` axis alone — the exact
18778        // shape a future M4 admission-webhook rejection body composer
18779        // or a
18780        // `HashMap::<String, DepList>::from_iter(
18781        //     DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18782        // style owned-key per-list lookup reaches through — closing the
18783        // owned-`String` forward-projection axis's iterator-pipe shape.
18784        // Then a direct round-trip witness through the paired
18785        // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18786        // owned-`String`'s [`String::as_str`] borrow that closes the
18787        // two-way `Self → String → Self` round-trip on the trait-
18788        // idiomatic owned-`String` forward + reverse axis pair.
18789        //
18790        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18791        // `From` emit lands on the lowercase Portuguese `as_str`
18792        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18793        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18794        // forcing the round-trip through an intermediate
18795        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18796        // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18797        // parse resolve through the same lifted
18798        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18799        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18800        // construction (there is no wire/diagnostic axis split on this
18801        // enum), so the owned-`String` forward axis and the reverse
18802        // axis compose directly — matching the peer
18803        // [`crate::supervisor::RestartStrategy`] /
18804        // [`crate::supervisor::RestartPolicy`] /
18805        // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18806        for &list in super::DepList::ALL {
18807            let owned_string: String = <String as From<super::DepList>>::from(list);
18808            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18809            assert_eq!(
18810                owned_string.as_str(),
18811                owned_static,
18812                "From<DepList> for String and From<DepList> for \
18813                 &'static str must resolve identically on \
18814                 DepList::{list:?} — divergence signals the owned-\
18815                 `String` and owned-`&'static str` forward-projection \
18816                 return-type-shape paths have drifted onto different \
18817                 emit-sets"
18818            );
18819            let via_to_string: String = list.to_string();
18820            assert_eq!(
18821                owned_string, via_to_string,
18822                "From<DepList> for String must byte-equal \
18823                 DepList::to_string on DepList::{list:?} — divergence \
18824                 signals the trait-idiomatic owned-`String` forward-\
18825                 projection axis and the ToString-through-Display axis \
18826                 have drifted onto different emit-sets"
18827            );
18828        }
18829        let via_iter: Vec<String> = super::DepList::ALL
18830            .iter()
18831            .copied()
18832            .map(String::from)
18833            .collect();
18834        let via_method: Vec<String> = super::DepList::ALL
18835            .iter()
18836            .map(|l| l.as_str().to_owned())
18837            .collect();
18838        assert_eq!(
18839            via_iter, via_method,
18840            "`.iter().copied().map(String::from)` over DepList::ALL must \
18841             byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18842             every arm — the owned-`String` `From<DepList> for String` \
18843             axis is what makes the `String::from` composition route \
18844             through the substrate-primitive `DepList::as_str` accessor \
18845             rather than through a per-call-site `.to_owned()` / \
18846             `String::from(list.as_str())` detour"
18847        );
18848        for &variant in super::DepList::ALL {
18849            let emitted: String = variant.into();
18850            let re_parsed: Result<super::DepList, ()> =
18851                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18852            assert_eq!(
18853                re_parsed,
18854                Ok(variant),
18855                "trait-idiomatic owned-`String` forward-projection + \
18856                 reverse-projection axis pair must round-trip \
18857                 DepList::{variant:?} through `.into::<String>()` and \
18858                 back through `TryFrom<&str>` on the owned-`String`'s \
18859                 String::as_str borrow — a break signals the owned-\
18860                 `String` forward-emit and reverse-parse axes have \
18861                 drifted onto different vocabularies (unlike the peer \
18862                 CaixaKind axis pair, DepList's forward emit and \
18863                 reverse parse share the same lifted \
18864                 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18865                 round-trip composes directly)"
18866            );
18867        }
18868    }
18869
18870    #[test]
18871    fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18872        // Fail-before-pass-after byte-parity pin on the newly lifted
18873        // `impl From<&DepList> for String` — asserts the borrowed-input
18874        // owned-`String`-returning standard-library trait impl and the
18875        // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18876        // accessor resolve to the same two-arm emit-set across every
18877        // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18878        // Rust's standard library does not carry a blanket
18879        // `impl<T: AsRef<str>> From<&T> for String` (nor an
18880        // `impl<T: fmt::Display> From<&T> for String`), so the
18881        // borrowed-input owned-`String` forward-projection axis is a
18882        // distinct trait-idiomatic surface that a
18883        // `let key: String = (&list).into();`-shaped call site reaches
18884        // through this impl and no other — the paired sibling
18885        // `From<DepList> for String` impl forces every borrowed-input
18886        // call site through an explicit `Copy` deref
18887        // (`String::from(*list)`) or an `.as_str().to_owned()` /
18888        // `.to_string()` detour. Peer of the first-mover
18889        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18890        // (579385f) and the second-peer
18891        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18892        // (8465740) — extends the trait-idiomatic borrowed-input owned-
18893        // `String` forward-projection axis off the M2 OTP-shape sibling
18894        // axis pair onto the first non-M2 closed-set fieldless typed
18895        // enum peer (the two-list dep-graph axis).
18896        for &variant in super::DepList::ALL {
18897            let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18898            let via_method: &'static str = variant.as_str();
18899            assert_eq!(
18900                via_trait.as_str(),
18901                via_method,
18902                "From<&DepList> for String impl must round-trip \
18903                 &DepList::{variant:?} to the same lifted \
18904                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18905                 DepList::as_str returns — divergence signals a silent \
18906                 detour off the substrate-primitive accessor"
18907            );
18908            let via_into: String = (&variant).into();
18909            assert_eq!(
18910                via_into.as_str(),
18911                via_method,
18912                "Into<String>::into on &DepList::{variant:?} must \
18913                 byte-equal DepList::as_str on the same input — the \
18914                 blanket-derived Into shape must resolve to the same \
18915                 as_str dispatch as the explicit From impl"
18916            );
18917        }
18918    }
18919
18920    #[test]
18921    fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18922        // Cross-axis partition pin: the newly lifted trait-idiomatic
18923        // borrowed-input owned-`String` `From<&DepList> for String`
18924        // (this lift), the paired owned-input owned-`String`
18925        // `From<DepList> for String` (32b0ee8), the paired borrowed-
18926        // input owned-`&'static str` `From<&DepList> for &'static str`
18927        // (64aa742), and the paired owned-input owned-`&'static str`
18928        // `From<DepList> for &'static str` (3455cbf) — every corner of
18929        // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18930        // idiomatic projection family — must resolve identically on
18931        // every arm, locking the four return-shape × input-shape paths
18932        // together so any future detour trips at caixa-core test time.
18933        // Also byte-parity witness against the sibling
18934        // [`ToString::to_string`] surface routed through
18935        // [`std::fmt::Display`] and a direct round-trip witness through
18936        // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18937        // the owned-`String`'s [`String::as_str`] borrow that closes
18938        // the two-way `&Self → String → Self` round-trip on the trait-
18939        // idiomatic borrowed-input owned-`String` forward + reverse
18940        // axis pair. Peer of the first-mover
18941        // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18942        // (579385f) and the second-peer
18943        // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18944        // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18945        // String}` 2×2 projection corner on the third substrate-wide
18946        // closed-set fieldless typed enum peer (the two-list dep-graph
18947        // axis, first outside the M2 OTP-shape sibling pair).
18948        //
18949        // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18950        // `From` emit lands on the lowercase Portuguese `as_str`
18951        // diagnostic vocabulary while the reverse `TryFrom<&str>`
18952        // parses the `PascalCase` `wire_name` author-surface vocabulary,
18953        // forcing the round-trip through an intermediate
18954        // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18955        // [`super::DepList::as_str`] emit and
18956        // [`super::DepList::from_wire`] parse resolve through the same
18957        // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18958        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18959        // construction (there is no wire/diagnostic axis split on this
18960        // enum), so the borrowed-input owned-`String` forward axis and
18961        // the reverse axis compose directly — matching the peer
18962        // [`crate::supervisor::RestartStrategy`] /
18963        // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18964        // `String` axis pairs.
18965        for &list in super::DepList::ALL {
18966            let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18967            let owned_string: String = <String as From<super::DepList>>::from(list);
18968            let borrowed_static: &'static str =
18969                <&'static str as From<&super::DepList>>::from(&list);
18970            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18971            assert_eq!(
18972                borrowed_string, owned_string,
18973                "From<&DepList> for String and From<DepList> for String \
18974                 must resolve identically on DepList::{list:?} — \
18975                 divergence signals the borrowed-input and owned-input \
18976                 owned-`String` forward-projection input-shape paths \
18977                 have drifted onto different emit-sets"
18978            );
18979            assert_eq!(
18980                borrowed_string.as_str(),
18981                borrowed_static,
18982                "From<&DepList> for String and From<&DepList> for \
18983                 &'static str must resolve identically on \
18984                 DepList::{list:?} — divergence signals the borrowed-\
18985                 input `&'static str` and owned-`String` return-shape \
18986                 paths have drifted onto different emit-sets"
18987            );
18988            assert_eq!(
18989                borrowed_string.as_str(),
18990                owned_static,
18991                "From<&DepList> for String and From<DepList> for \
18992                 &'static str must resolve identically on \
18993                 DepList::{list:?} — divergence signals a break in the \
18994                 diagonal corner of the {{Self, &Self}} × {{&'static \
18995                 str, String}} 2×2 trait-idiomatic projection family"
18996            );
18997            let via_to_string: String = list.to_string();
18998            assert_eq!(
18999                borrowed_string, via_to_string,
19000                "From<&DepList> for String must byte-equal \
19001                 DepList::to_string on DepList::{list:?} — divergence \
19002                 signals the trait-idiomatic borrowed-input owned-\
19003                 `String` forward-projection axis and the ToString-\
19004                 through-Display axis have drifted onto different \
19005                 emit-sets"
19006            );
19007        }
19008        let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
19009        let via_method: Vec<String> = super::DepList::ALL
19010            .iter()
19011            .map(|l| l.as_str().to_owned())
19012            .collect();
19013        assert_eq!(
19014            via_iter, via_method,
19015            "`.iter().map(String::from)` over DepList::ALL — a call \
19016             site whose iteration axis holds `&DepList` by construction \
19017             — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
19018             on every arm — the borrowed-input owned-`String` \
19019             `From<&DepList> for String` axis is what makes the \
19020             `String::from` composition route through the substrate-\
19021             primitive `DepList::as_str` accessor without a spurious \
19022             `Copy` deref (which would only be reachable through the \
19023             owned-input `From<DepList> for String` axis by first \
19024             calling `.copied()` on the iterator)"
19025        );
19026        for &variant in super::DepList::ALL {
19027            let emitted: String = (&variant).into();
19028            let re_parsed: Result<super::DepList, ()> =
19029                <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
19030            assert_eq!(
19031                re_parsed,
19032                Ok(variant),
19033                "trait-idiomatic borrowed-input owned-`String` \
19034                 forward-projection + reverse-projection axis pair must \
19035                 round-trip &DepList::{variant:?} through \
19036                 `.into::<String>()` on the borrowed-input surface and \
19037                 back through `TryFrom<&str>` on the owned-`String`'s \
19038                 String::as_str borrow — a break signals the \
19039                 borrowed-input owned-`String` forward-emit and \
19040                 reverse-parse axes have drifted onto different \
19041                 vocabularies (unlike the peer CaixaKind axis pair, \
19042                 DepList's forward emit and reverse parse share the \
19043                 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
19044                 construction, so the round-trip composes directly)"
19045            );
19046        }
19047    }
19048
19049    #[test]
19050    fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
19051        // Fail-before-pass-after byte-parity pin on the newly lifted
19052        // `impl From<DepList> for std::borrow::Cow<'static, str>` —
19053        // asserts the standard-library trait impl and the substrate-
19054        // primitive [`super::DepList::as_str`] `pub const fn`
19055        // accessor resolve to the same two-arm emit-set across every
19056        // arm the exhaustive [`super::DepList::ALL`] slice
19057        // enumerates. Rust's standard library does not carry a
19058        // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
19059        // (nor an `impl<T: fmt::Display> From<T> for
19060        // Cow<'static, str>`), so the `Cow<'static, str>` forward-
19061        // projection axis is a distinct trait-idiomatic surface that
19062        // a `let key: Cow<'static, str> = list.into();`-shaped call
19063        // site reaches through this impl and no other — the paired
19064        // sibling `From<DepList> for &'static str` and
19065        // `From<DepList> for String` impls force every
19066        // `Cow<'static, str>`-parameterized call site through a
19067        // `Cow::Borrowed(list.as_str())` /
19068        // `Cow::Owned(list.to_string())` composition whose type
19069        // bounds have no compile-time link back to the substrate
19070        // primitive.
19071        //
19072        // Also asserts the projection lands on the zero-alloc
19073        // [`std::borrow::Cow::Borrowed`] arm (not the
19074        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19075        // [`super::DepList::as_str`] accessor's `&'static str`
19076        // return lifetime by construction (each match arm resolves
19077        // to one of the two lifted
19078        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19079        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
19080        // &str` values) makes the borrowed arm the type-correct
19081        // projection with no runtime allocation. Any future silent
19082        // detour that routes the impl through the owned arm trips
19083        // at caixa-core test time under the
19084        // [`std::borrow::Cow::Borrowed`] discriminator witness
19085        // rather than at a downstream `Cow<'static, str>`-bound
19086        // consumer's silent allocation.
19087        //
19088        // First-mover on the outside-M3 substrate-wide tier of the
19089        // substrate-wide trait-idiomatic
19090        // [`std::borrow::Cow<'static, str>`] forward-projection
19091        // campaign — extends the axis off the paired
19092        // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
19093        // the paired M2 OTP-shape
19094        // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
19095        // and [`crate::supervisor::RestartPolicy`] (0612398 +
19096        // ee577fd), and the paired M3-mesh-shape
19097        // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
19098        // [`crate::aplicacao::PlacementStrategy`] (eee504d +
19099        // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
19100        // peers onto the first outside-M3 caixa-core peer (the two-
19101        // list dep-graph axis), opening the outside-M3 caixa-core
19102        // tier of the substrate-wide Cow<'static, str> forward-
19103        // projection campaign's owned-input corner.
19104        for &variant in super::DepList::ALL {
19105            let via_trait: std::borrow::Cow<'static, str> =
19106                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19107            let via_method: &'static str = variant.as_str();
19108            assert_eq!(
19109                via_trait.as_ref(),
19110                via_method,
19111                "From<DepList> for Cow<'static, str> impl must \
19112                 round-trip DepList::{variant:?} to the same lifted \
19113                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19114                 DepList::as_str returns — divergence signals a \
19115                 silent detour off the substrate-primitive accessor"
19116            );
19117            assert!(
19118                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19119                "From<DepList> for Cow<'static, str> impl must land \
19120                 on the zero-alloc Cow::Borrowed arm on \
19121                 DepList::{variant:?} — a Cow::Owned outcome signals \
19122                 the projection has silently allocated where the \
19123                 substrate-primitive DepList::as_str `&'static str` \
19124                 return makes the borrowed arm the type-correct \
19125                 projection"
19126            );
19127            let via_into: std::borrow::Cow<'static, str> = variant.into();
19128            assert_eq!(
19129                via_into.as_ref(),
19130                via_method,
19131                "Into<Cow<'static, str>>::into on DepList::\
19132                 {variant:?} must byte-equal DepList::as_str on the \
19133                 same input — the blanket-derived Into shape must \
19134                 resolve to the same as_str dispatch as the explicit \
19135                 From impl"
19136            );
19137            assert!(
19138                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19139                "Into<Cow<'static, str>>::into on DepList::\
19140                 {variant:?} must land on the zero-alloc \
19141                 Cow::Borrowed arm — the blanket-derived Into shape \
19142                 must resolve to the same Cow::Borrowed dispatch as \
19143                 the explicit From impl"
19144            );
19145        }
19146    }
19147
19148    #[test]
19149    fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19150        // Cross-axis partition pin: the newly lifted trait-idiomatic
19151        // `From<DepList> for std::borrow::Cow<'static, str>` (this
19152        // lift), the paired owned-input `From<DepList> for
19153        // &'static str` (3455cbf), and the paired owned-input
19154        // `From<DepList> for String` (32b0ee8) forward projections
19155        // must resolve identically on every arm, locking the three
19156        // return-shape paths together by construction so any future
19157        // detour trips at caixa-core test time. Also byte-parity
19158        // witness against the sibling [`ToString::to_string`]
19159        // surface routed through [`std::fmt::Display`] — every
19160        // owned-heap-string path (the `Cow::Owned` promotion of
19161        // this axis's `.into_owned()`, `From<DepList> for String`,
19162        // and `.to_string()`) resolves to the same two-arm lifted
19163        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19164        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19165        // arm.
19166        //
19167        // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
19168        // witness over [`super::DepList::ALL`] that materializes the
19169        // two-arm accept-set through the
19170        // [`std::borrow::Cow<'static, str>`] axis alone — the exact
19171        // shape a future M4 admission-webhook rejection body's
19172        // accepted-`:deps` / `:deps-dev` list-key enumeration, a
19173        // future substrate-wide per-arm diagnostic surface whose
19174        // typing rules out the sibling [`AsRef<str>`] borrowed
19175        // return, or a future per-arm dep-list emitter that binds
19176        // through a [`std::borrow::Cow<'static, str>`] boundary
19177        // reaches through — opening the composable-projection axis
19178        // on the first outside-M3 caixa-core closed-set fieldless
19179        // typed enum peer on the caixa surface. The pipe witness
19180        // also pins the zero-alloc discipline: every element in the
19181        // collected vector satisfies the
19182        // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
19183        // accidental silent-allocation regression on the pipe's
19184        // iteration axis is a caixa-core-test-time failure.
19185        for &variant in super::DepList::ALL {
19186            let via_cow: std::borrow::Cow<'static, str> =
19187                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19188            let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19189            let via_string: String = <String as From<super::DepList>>::from(variant);
19190            assert_eq!(
19191                via_cow.as_ref(),
19192                via_static,
19193                "From<DepList> for Cow<'static, str> and \
19194                 From<DepList> for &'static str must resolve \
19195                 identically on DepList::{variant:?} — divergence \
19196                 signals the Cow<'static, str> and &'static str \
19197                 return-shape paths have drifted onto different \
19198                 emit-sets"
19199            );
19200            assert_eq!(
19201                via_cow.as_ref(),
19202                via_string.as_str(),
19203                "From<DepList> for Cow<'static, str> and \
19204                 From<DepList> for String must resolve identically \
19205                 on DepList::{variant:?} — divergence signals the \
19206                 Cow<'static, str> and String return-shape paths \
19207                 have drifted onto different emit-sets"
19208            );
19209            let via_to_string: String = variant.to_string();
19210            assert_eq!(
19211                via_cow.as_ref(),
19212                via_to_string.as_str(),
19213                "From<DepList> for Cow<'static, str> must byte-equal \
19214                 DepList::to_string on DepList::{variant:?} — \
19215                 divergence signals the trait-idiomatic \
19216                 Cow<'static, str> forward-projection axis and the \
19217                 ToString-through-Display axis have drifted onto \
19218                 different emit-sets"
19219            );
19220        }
19221        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19222            .iter()
19223            .copied()
19224            .map(std::borrow::Cow::from)
19225            .collect();
19226        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19227            .iter()
19228            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19229            .collect();
19230        assert_eq!(
19231            via_iter, via_method,
19232            "`.iter().copied().map(Cow::from)` over DepList::ALL \
19233             must byte-equal `.iter().map(|l| \
19234             Cow::Borrowed(l.as_str()))` on every arm — the trait-\
19235             idiomatic `From<DepList> for Cow<'static, str>` axis is \
19236             what makes the `Cow::from` composition route through \
19237             the substrate-primitive `DepList::as_str` accessor with \
19238             the zero-alloc Cow::Borrowed arm by construction, \
19239             rather than a per-call-site `Cow::Owned(list.to_string())` \
19240             allocation"
19241        );
19242        for cow in &via_iter {
19243            assert!(
19244                matches!(cow, std::borrow::Cow::Borrowed(_)),
19245                "every element of the .iter().copied().map(Cow::from) \
19246                 pipe over DepList::ALL must land on the zero-alloc \
19247                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19248                 signals the pipe's iteration axis has silently \
19249                 allocated where the substrate-primitive \
19250                 DepList::as_str `&'static str` return makes the \
19251                 borrowed arm the type-correct projection"
19252            );
19253        }
19254    }
19255
19256    #[test]
19257    fn dep_list_from_borrowed_into_static_cow_str_routes_through_as_str_accessor() {
19258        // Fail-before-pass-after byte-parity pin on the newly lifted
19259        // `impl From<&DepList> for std::borrow::Cow<'static, str>` —
19260        // asserts the borrowed-input standard-library trait impl and
19261        // the substrate-primitive [`super::DepList::as_str`] `pub const
19262        // fn` accessor resolve to the same two-arm emit-set across
19263        // every arm the exhaustive [`super::DepList::ALL`] slice
19264        // enumerates. Rust's standard library does not carry a blanket
19265        // `impl<T: AsRef<str>> From<&T> for Cow<'static, str>` (nor a
19266        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19267        // the borrowed-input `Cow<'static, str>` forward-projection
19268        // axis is a distinct trait-idiomatic surface that a
19269        // `let key: Cow<'static, str> = (&list).into();`-shaped call
19270        // site or a `DepList::ALL.iter().map(Cow::from)`-shaped pipe
19271        // reaches through this impl and no other — the paired owned-
19272        // input `From<DepList> for Cow<'static, str>` impl (6858bac)
19273        // forces every borrowed-input call site through an explicit
19274        // `Copy` deref (`Cow::from(*list)`) or a
19275        // `Cow::Borrowed(list.as_str())` open-code whose type bounds
19276        // have no compile-time link back to the substrate primitive.
19277        //
19278        // Also asserts the projection lands on the zero-alloc
19279        // [`std::borrow::Cow::Borrowed`] arm (not the
19280        // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
19281        // [`super::DepList::as_str`] accessor's `&'static str` return
19282        // lifetime by construction (each match arm resolves to one of
19283        // the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19284        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19285        // values) makes the borrowed arm the type-correct projection
19286        // with no runtime allocation on the borrowed-input surface
19287        // just as on the paired owned-input surface.
19288        //
19289        // Closes the `{Self, &Self}` input-shape corner on the outside-
19290        // M3 caixa-core two-list dep-graph [`Cow<'static, str>`] axis
19291        // on the first outside-M3 caixa-core closed-set fieldless typed
19292        // enum peer on the caixa surface, exactly as afdf0f4 closed it
19293        // on the second M3-mesh-primitive peer
19294        // ([`crate::aplicacao::PlacementStrategy`]) one commit after
19295        // the owning half (eee504d) landed, as 25690ef closed it on
19296        // the first M3-mesh-primitive peer
19297        // ([`crate::aplicacao::WitShape`]) one commit after the owning
19298        // half (8634dec) landed, as d45c409 closed it on the top-level
19299        // [`crate::CaixaKind`] one commit after the owning half
19300        // (99c1735) landed, and as 9b3e4b3 / ee577fd closed it on the
19301        // M2 OTP-shape [`crate::supervisor::RestartStrategy`] /
19302        // [`crate::supervisor::RestartPolicy`] sibling peers one
19303        // commit after (7dd28b3 / 0612398) landed.
19304        for &variant in super::DepList::ALL {
19305            let via_trait: std::borrow::Cow<'static, str> =
19306                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19307            let via_method: &'static str = variant.as_str();
19308            assert_eq!(
19309                via_trait.as_ref(),
19310                via_method,
19311                "From<&DepList> for Cow<'static, str> impl must \
19312                 round-trip &DepList::{variant:?} to the same lifted \
19313                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19314                 DepList::as_str returns — divergence signals a silent \
19315                 detour off the substrate-primitive accessor"
19316            );
19317            assert!(
19318                matches!(via_trait, std::borrow::Cow::Borrowed(_)),
19319                "From<&DepList> for Cow<'static, str> impl must land \
19320                 on the zero-alloc Cow::Borrowed arm on \
19321                 &DepList::{variant:?} — a Cow::Owned outcome signals \
19322                 the projection has silently allocated where the \
19323                 substrate-primitive DepList::as_str `&'static str` \
19324                 return makes the borrowed arm the type-correct \
19325                 projection"
19326            );
19327            let via_into: std::borrow::Cow<'static, str> = (&variant).into();
19328            assert_eq!(
19329                via_into.as_ref(),
19330                via_method,
19331                "Into<Cow<'static, str>>::into on &DepList::\
19332                 {variant:?} must byte-equal DepList::as_str on the \
19333                 same input — the blanket-derived Into shape must \
19334                 resolve to the same as_str dispatch as the explicit \
19335                 From impl"
19336            );
19337            assert!(
19338                matches!(via_into, std::borrow::Cow::Borrowed(_)),
19339                "Into<Cow<'static, str>>::into on &DepList::\
19340                 {variant:?} must land on the zero-alloc \
19341                 Cow::Borrowed arm — the blanket-derived Into shape \
19342                 must resolve to the same Cow::Borrowed dispatch as \
19343                 the explicit From impl"
19344            );
19345        }
19346    }
19347
19348    #[test]
19349    fn dep_list_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
19350        // Cross-axis partition pin: the newly lifted trait-idiomatic
19351        // borrowed-input `From<&DepList> for std::borrow::Cow<'static,
19352        // str>` (this lift), the paired owned-input `From<DepList> for
19353        // std::borrow::Cow<'static, str>` (6858bac), the paired
19354        // borrowed-input owned-`&'static str` `From<&DepList> for
19355        // &'static str` (3455cbf), and the paired borrowed-input
19356        // owned-`String` `From<&DepList> for String` must resolve
19357        // identically on every arm, locking the four return-shape ×
19358        // input-shape paths together by construction so any future
19359        // detour trips at caixa-core test time. Also byte-parity
19360        // witness against the sibling [`ToString::to_string`] surface
19361        // routed through [`std::fmt::Display`] — every owned-heap-
19362        // string path (this axis's `.into_owned()` promotion, the
19363        // paired [`From<&DepList> for String`], and `.to_string()`)
19364        // resolves to the same two-arm lifted
19365        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19366        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
19367        // arm.
19368        //
19369        // Then a `.iter().map(std::borrow::Cow::from)` pipe witness
19370        // over [`super::DepList::ALL`] — whose iterator yields
19371        // `&DepList` by construction, so the borrowed-input
19372        // [`Cow<'static, str>`] axis is what routes the pipe through
19373        // the substrate-primitive [`super::DepList::as_str`] accessor
19374        // without a spurious [`Copy`] deref (which would only be
19375        // reachable through the owned-input [`From<DepList> for
19376        // Cow<'static, str>`] axis by first calling `.copied()` on the
19377        // iterator). The pipe witness also pins the zero-alloc
19378        // discipline: every element in the collected vector satisfies
19379        // the [`std::borrow::Cow::Borrowed`] arm predicate, so a
19380        // future accidental silent-allocation regression on the pipe's
19381        // iteration axis is a caixa-core-test-time failure. Peer of
19382        // the sibling
19383        // [`placement_strategy_from_borrowed_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
19384        // (afdf0f4) on the M3 mesh-shape `:placement :estrategia`
19385        // axis — extends the whole borrowed-input `Cow<'static, str>`
19386        // + paired `{&'static str, String}` cross-axis-parity corner
19387        // onto the first outside-M3 caixa-core closed-set fieldless
19388        // typed enum peer on the caixa surface.
19389        for &variant in super::DepList::ALL {
19390            let borrowed_cow: std::borrow::Cow<'static, str> =
19391                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19392            let owned_cow: std::borrow::Cow<'static, str> =
19393                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19394            let borrowed_static: &'static str =
19395                <&'static str as From<&super::DepList>>::from(&variant);
19396            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19397            assert_eq!(
19398                borrowed_cow, owned_cow,
19399                "From<&DepList> for Cow<'static, str> and \
19400                 From<DepList> for Cow<'static, str> must resolve \
19401                 identically on DepList::{variant:?} — divergence \
19402                 signals the borrowed-input and owned-input \
19403                 Cow<'static, str> forward-projection input-shape \
19404                 paths have drifted onto different emit-sets"
19405            );
19406            assert_eq!(
19407                borrowed_cow.as_ref(),
19408                borrowed_static,
19409                "From<&DepList> for Cow<'static, str> and \
19410                 From<&DepList> for &'static str must resolve \
19411                 identically on DepList::{variant:?} — divergence \
19412                 signals the borrowed-input Cow<'static, str> and \
19413                 &'static str return-shape paths have drifted onto \
19414                 different emit-sets"
19415            );
19416            assert_eq!(
19417                borrowed_cow.as_ref(),
19418                borrowed_string.as_str(),
19419                "From<&DepList> for Cow<'static, str> and \
19420                 From<&DepList> for String must resolve identically \
19421                 on DepList::{variant:?} — divergence signals the \
19422                 borrowed-input Cow<'static, str> and owned-`String` \
19423                 return-shape paths have drifted onto different \
19424                 emit-sets"
19425            );
19426            let via_to_string: String = variant.to_string();
19427            assert_eq!(
19428                borrowed_cow.as_ref(),
19429                via_to_string.as_str(),
19430                "From<&DepList> for Cow<'static, str> must byte-equal \
19431                 DepList::to_string on DepList::{variant:?} — \
19432                 divergence signals the trait-idiomatic borrowed-input \
19433                 Cow<'static, str> forward-projection axis and the \
19434                 ToString-through-Display axis have drifted onto \
19435                 different emit-sets"
19436            );
19437        }
19438        let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19439            .iter()
19440            .map(std::borrow::Cow::from)
19441            .collect();
19442        let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
19443            .iter()
19444            .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
19445            .collect();
19446        assert_eq!(
19447            via_iter, via_method,
19448            "`.iter().map(Cow::from)` over DepList::ALL — a call site \
19449             whose iteration axis holds &DepList by construction — \
19450             must byte-equal `.iter().map(|l| \
19451             Cow::Borrowed(l.as_str()))` on every arm — the borrowed-\
19452             input Cow<'static, str> `From<&DepList> for Cow<'static, \
19453             str>` axis is what makes the `Cow::from` composition \
19454             route through the substrate-primitive `DepList::as_str` \
19455             accessor with the zero-alloc Cow::Borrowed arm by \
19456             construction and without a spurious `Copy` deref (which \
19457             would only be reachable through the owned-input \
19458             `From<DepList> for Cow<'static, str>` axis by first \
19459             calling `.copied()` on the iterator)"
19460        );
19461        for cow in &via_iter {
19462            assert!(
19463                matches!(cow, std::borrow::Cow::Borrowed(_)),
19464                "every element of the .iter().map(Cow::from) pipe \
19465                 over DepList::ALL must land on the zero-alloc \
19466                 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
19467                 signals the pipe's iteration axis has silently \
19468                 allocated where the substrate-primitive \
19469                 DepList::as_str `&'static str` return makes the \
19470                 borrowed arm the type-correct projection"
19471            );
19472        }
19473    }
19474
19475    #[test]
19476    fn dep_list_from_into_box_str_routes_through_as_str_accessor() {
19477        // Fail-before-pass-after byte-parity pin on the newly lifted
19478        // `impl From<DepList> for Box<str>` — asserts the owned-input
19479        // standard-library trait impl and the substrate-primitive
19480        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19481        // the same two-arm emit-set (the paired
19482        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19483        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19484        // byte-strings) across every arm the exhaustive
19485        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19486        // core-internal tier of the substrate-wide [`Box<str>`] forward-
19487        // projection campaign onto the second caixa-core-internal peer,
19488        // after the render-side path-shape-diagnostic
19489        // [`super::super::render::PathShapeViolation`] pair (0d87a72,
19490        // both corners in one axis) opened the tier. Rust's standard
19491        // library carries `impl From<&str> for Box<str>` and
19492        // `impl From<String> for Box<str>` but no blanket
19493        // `impl<T: AsRef<str>> From<T> for Box<str>`, so this axis is a
19494        // distinct trait-idiomatic surface that a
19495        // `let key: Box<str> = list.into();`-shaped call site reaches
19496        // through this impl and no other — a paired
19497        // `Box::from(list.as_str())` open-code has no compile-time link
19498        // back to the substrate primitive.
19499        for &variant in super::DepList::ALL {
19500            let via_trait: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19501            let via_method: &'static str = variant.as_str();
19502            assert_eq!(
19503                via_trait.as_ref(),
19504                via_method,
19505                "From<DepList> for Box<str> impl must round-trip \
19506                 DepList::{variant:?} to the same lifted \
19507                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19508                 DepList::as_str returns — divergence signals a silent \
19509                 detour off the substrate-primitive accessor"
19510            );
19511            let via_into: Box<str> = variant.into();
19512            assert_eq!(
19513                via_into.as_ref(),
19514                via_method,
19515                "Into<Box<str>>::into on DepList::{variant:?} must \
19516                 byte-equal DepList::as_str on the same input — the \
19517                 blanket-derived Into shape must resolve to the same \
19518                 as_str dispatch as the explicit From impl"
19519            );
19520        }
19521    }
19522
19523    #[test]
19524    fn dep_list_from_borrowed_into_box_str_routes_through_as_str_accessor() {
19525        // Fail-before-pass-after byte-parity pin on the newly lifted
19526        // `impl From<&DepList> for Box<str>` — asserts the borrowed-input
19527        // standard-library trait impl and the substrate-primitive
19528        // [`super::DepList::as_str`] `pub const fn` accessor resolve to
19529        // the same two-arm emit-set (the paired
19530        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19531        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19532        // byte-strings) across every arm the exhaustive
19533        // [`super::DepList::ALL`] slice enumerates. Rust's standard
19534        // library carries `impl From<&str> for Box<str>` and
19535        // `impl From<String> for Box<str>` but no blanket
19536        // `impl<T: AsRef<str>> From<&T> for Box<str>` (nor a `Copy`-based
19537        // `impl<T: Copy, U: From<T>> From<&T> for U`), so the borrowed-
19538        // input [`Box<str>`] forward-projection axis is a distinct
19539        // trait-idiomatic surface that a
19540        // `DepList::ALL.iter().map(Box::<str>::from)`-shaped pipe (whose
19541        // iterator over `&'static [DepList]` yields `&DepList` by
19542        // construction) or a `let key: Box<str> = (&list).into();`-shaped
19543        // call site reaches through this impl and no other — the paired
19544        // owned-input `From<DepList> for Box<str>` impl alone would force
19545        // every borrowed-input call site through an explicit `Copy` deref
19546        // (`Box::<str>::from(*list)`) or a
19547        // `Box::<str>::from(list.as_str())` open-code whose type bounds
19548        // have no compile-time link back to the substrate primitive.
19549        //
19550        // Closes the `{Self, &Self}` input-shape corner on the second
19551        // caixa-core-internal closed-set fieldless typed enum peer of
19552        // the substrate-wide [`Box<str>`] forward-projection campaign —
19553        // one commit after the paired render-side path-shape-diagnostic
19554        // [`super::super::render::PathShapeViolation`] pair (0d87a72)
19555        // opened the caixa-core-internal tier — matching the trajectory
19556        // the paired caixa-theme `Semantic` pair (0cd7dc3, both corners
19557        // in one axis), the caixa-provedor `FerriteRuntime` pair
19558        // (14886a8, both corners in one axis), and the render-side
19559        // `PathShapeViolation` pair (0d87a72, both corners in one axis)
19560        // walked before it.
19561        for &variant in super::DepList::ALL {
19562            let via_trait: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19563            let via_method: &'static str = variant.as_str();
19564            assert_eq!(
19565                via_trait.as_ref(),
19566                via_method,
19567                "From<&DepList> for Box<str> impl must round-trip \
19568                 &DepList::{variant:?} to the same lifted \
19569                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19570                 DepList::as_str returns — divergence signals a silent \
19571                 detour off the substrate-primitive accessor"
19572            );
19573            let via_into: Box<str> = (&variant).into();
19574            assert_eq!(
19575                via_into.as_ref(),
19576                via_method,
19577                "Into<Box<str>>::into on &DepList::{variant:?} must \
19578                 byte-equal DepList::as_str on the same input — the \
19579                 blanket-derived Into shape on the borrowed-input \
19580                 surface must resolve to the same as_str dispatch as \
19581                 the explicit From impl"
19582            );
19583        }
19584
19585        // Pipe witness — the distinguishing shape that forces the
19586        // borrowed-input axis to be independent of the owned-input
19587        // peer. `DepList::ALL.iter()` yields `&DepList` by
19588        // construction, so `.map(Box::<str>::from)` resolves through
19589        // the borrowed-input `From<&DepList> for Box<str>` impl and
19590        // no other — without this axis, the same pipe would force an
19591        // explicit `.copied()` restatement whose type bounds bypass
19592        // the substrate primitive.
19593        let via_pipe: Vec<Box<str>> = super::DepList::ALL.iter().map(Box::<str>::from).collect();
19594        let via_accessor: Vec<&'static str> =
19595            super::DepList::ALL.iter().map(|l| l.as_str()).collect();
19596        assert_eq!(
19597            via_pipe.len(),
19598            via_accessor.len(),
19599            "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19600             preserve arity against the paired DepList::as_str \
19601             accessor — a length divergence signals the borrowed-input \
19602             axis has silently rejected an arm"
19603        );
19604        for (pipe_arm, accessor_arm) in via_pipe.iter().zip(via_accessor.iter()) {
19605            assert_eq!(
19606                pipe_arm.as_ref(),
19607                *accessor_arm,
19608                "DepList::ALL.iter().map(Box::<str>::from) pipe must \
19609                 byte-equal the paired \
19610                 DepList::ALL.iter().map(|l| l.as_str()) pipe on every \
19611                 arm — divergence signals the borrowed-input \
19612                 `From<&DepList> for Box<str>` axis has silently \
19613                 detoured off the substrate-primitive accessor"
19614            );
19615        }
19616    }
19617
19618    #[test]
19619    fn dep_list_from_into_arc_str_routes_through_as_str_accessor() {
19620        // Fail-before-pass-after byte-parity pin on the newly lifted
19621        // `impl From<DepList> for std::sync::Arc<str>` — asserts the
19622        // owned-input standard-library trait impl and the substrate-
19623        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19624        // resolve to the same two-arm emit-set (the paired
19625        // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
19626        // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
19627        // byte-strings) across every arm the exhaustive
19628        // [`super::DepList::ALL`] slice enumerates. Extends the caixa-
19629        // core-internal tier of the substrate-wide
19630        // [`std::sync::Arc<str>`] forward-projection campaign onto the
19631        // second caixa-core-internal peer, after the top-level
19632        // [`crate::CaixaKind`] pair (c17be64, both corners in one axis)
19633        // opened the tier. Rust's standard library carries
19634        // `impl From<&str> for std::sync::Arc<str>` and
19635        // `impl From<String> for std::sync::Arc<str>` but no blanket
19636        // `impl<T: AsRef<str>> From<T> for std::sync::Arc<str>` (nor an
19637        // `impl<T: fmt::Display> From<T> for std::sync::Arc<str>`), so
19638        // this axis is a distinct trait-idiomatic surface that a
19639        // `let key: std::sync::Arc<str> = list.into();`-shaped call site
19640        // reaches through this impl and no other — a paired
19641        // `std::sync::Arc::<str>::from(list.as_str())` open-code has no
19642        // compile-time link back to the substrate primitive, and a two-
19643        // step `std::sync::Arc::<str>::from(String::from(list))`
19644        // composition through the owned-`String` axis allocates twice
19645        // (once into the intermediate `String`, once into the
19646        // [`std::sync::Arc<str>`] on the `From<String>` conversion)
19647        // where the single-step trait impl allocates once.
19648        //
19649        // Cross-axis byte-parity witness against the sibling owned-input
19650        // `{&'static str, String, Cow<'static, str>, Box<str>}` return-
19651        // shape axes — locking the five return-shape paths on the owned-
19652        // input surface together by construction so any future detour
19653        // off the substrate-primitive [`super::DepList::as_str`] accessor
19654        // trips at caixa-core test time.
19655        for &variant in super::DepList::ALL {
19656            let via_trait: std::sync::Arc<str> =
19657                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19658            let via_method: &'static str = variant.as_str();
19659            assert_eq!(
19660                via_trait.as_ref(),
19661                via_method,
19662                "From<DepList> for std::sync::Arc<str> impl must round-\
19663                 trip DepList::{variant:?} to the same lifted \
19664                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19665                 DepList::as_str returns — divergence signals a silent \
19666                 detour off the substrate-primitive accessor"
19667            );
19668            let via_into: std::sync::Arc<str> = variant.into();
19669            assert_eq!(
19670                via_into.as_ref(),
19671                via_method,
19672                "Into<std::sync::Arc<str>>::into on DepList::{variant:?} \
19673                 must byte-equal DepList::as_str on the same input — \
19674                 the blanket-derived Into shape must resolve to the same \
19675                 as_str dispatch as the explicit From impl"
19676            );
19677            let owned_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
19678            assert_eq!(
19679                via_trait.as_ref(),
19680                owned_static,
19681                "From<DepList> for std::sync::Arc<str> and \
19682                 From<DepList> for &'static str must resolve identically \
19683                 on DepList::{variant:?} — divergence signals the owned-\
19684                 input std::sync::Arc<str> and &'static str return-shape \
19685                 paths have drifted onto different emit-sets"
19686            );
19687            let owned_string: String = <String as From<super::DepList>>::from(variant);
19688            assert_eq!(
19689                via_trait.as_ref(),
19690                owned_string.as_str(),
19691                "From<DepList> for std::sync::Arc<str> and \
19692                 From<DepList> for String must resolve identically on \
19693                 DepList::{variant:?} — divergence signals the owned-\
19694                 input std::sync::Arc<str> and owned-`String` return-shape \
19695                 paths have drifted onto different emit-sets"
19696            );
19697            let owned_cow: std::borrow::Cow<'static, str> =
19698                <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
19699            assert_eq!(
19700                via_trait.as_ref(),
19701                owned_cow.as_ref(),
19702                "From<DepList> for std::sync::Arc<str> and \
19703                 From<DepList> for Cow<'static, str> must resolve \
19704                 identically on DepList::{variant:?} — divergence signals \
19705                 the owned-input std::sync::Arc<str> and \
19706                 Cow<'static, str> return-shape paths have drifted onto \
19707                 different emit-sets"
19708            );
19709            let owned_box: Box<str> = <Box<str> as From<super::DepList>>::from(variant);
19710            assert_eq!(
19711                via_trait.as_ref(),
19712                owned_box.as_ref(),
19713                "From<DepList> for std::sync::Arc<str> and \
19714                 From<DepList> for Box<str> must resolve identically on \
19715                 DepList::{variant:?} — divergence signals the owned-\
19716                 input std::sync::Arc<str> and Box<str> return-shape \
19717                 paths have drifted onto different emit-sets"
19718            );
19719        }
19720    }
19721
19722    #[test]
19723    #[allow(
19724        clippy::too_many_lines,
19725        reason = "cross-axis partition pin folds four borrowed-input \
19726                  return-shape paths (&'static str, String, Cow<'static, \
19727                  str>, Box<str>) plus the paired owned-input Arc<str> \
19728                  witness and the .iter().map(std::sync::Arc::<str>::from) \
19729                  pipe witness into one exhaustive round-trip over \
19730                  DepList::ALL — the accepted line-count cost of keying \
19731                  the whole borrowed-input Arc<str> corner to the \
19732                  substrate-primitive as_str accessor at the same test-site"
19733    )]
19734    fn dep_list_from_borrowed_into_arc_str_routes_through_as_str_accessor() {
19735        // Fail-before-pass-after byte-parity pin on the newly lifted
19736        // `impl From<&DepList> for std::sync::Arc<str>` — asserts the
19737        // borrowed-input standard-library trait impl and the substrate-
19738        // primitive [`super::DepList::as_str`] `pub const fn` accessor
19739        // resolve to the same two-arm emit-set across every arm the
19740        // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
19741        // standard library does not carry a blanket
19742        // `impl<T: AsRef<str>> From<&T> for std::sync::Arc<str>` (nor a
19743        // `Copy`-based `impl<T: Copy, U: From<T>> From<&T> for U`), so
19744        // the borrowed-input `std::sync::Arc<str>` forward-projection
19745        // axis is a distinct trait-idiomatic surface that a
19746        // `let key: std::sync::Arc<str> = (&list).into();`-shaped call
19747        // site or a
19748        // `DepList::ALL.iter().map(std::sync::Arc::<str>::from)`-shaped
19749        // pipe reaches through this impl and no other — the paired
19750        // owned-input `From<DepList> for std::sync::Arc<str>` impl alone
19751        // forces every borrowed-input call site through a spurious
19752        // `Copy` deref
19753        // (`std::sync::Arc::<str>::from((*list).as_str())`) or a
19754        // `.copied()` restatement whose type bounds have no compile-time
19755        // link back to the substrate primitive.
19756        //
19757        // Closes the `{Self, &Self}` input-shape corner on the second
19758        // caixa-core-internal closed-set fieldless typed enum peer of
19759        // the substrate-wide trait-idiomatic [`std::sync::Arc<str>`]
19760        // forward-projection campaign — one commit after the paired
19761        // top-level [`crate::CaixaKind`] pair (c17be64) opened the
19762        // caixa-core-internal tier — matching the
19763        // `{Self, &Self} × {&'static str, String, Cow<'static, str>,
19764        // Box<str>}` 2×4 forward-projection matrix the peer projection
19765        // surfaces already close on this same enum.
19766        //
19767        // Cross-axis partition pin against the paired owned-input
19768        // [`From<DepList> for std::sync::Arc<str>`] and the sibling
19769        // borrowed-input `{&'static str, String, Cow<'static, str>,
19770        // Box<str>}` return-shape axes — locking the five return-shape
19771        // × input-shape paths on the borrowed-input surface together by
19772        // construction so any future detour off the substrate-primitive
19773        // accessor trips at caixa-core test time. Then a
19774        // `.iter().map(std::sync::Arc::<str>::from)` pipe witness over
19775        // [`super::DepList::ALL`] — whose iterator yields `&DepList` by
19776        // construction, so the borrowed-input
19777        // [`std::sync::Arc<str>`] axis is what routes the pipe through
19778        // the substrate-primitive [`super::DepList::as_str`] accessor
19779        // without a spurious [`Copy`] deref (which would only be
19780        // reachable through the owned-input
19781        // [`From<DepList> for std::sync::Arc<str>`] axis by first
19782        // calling `.copied()` on the iterator).
19783        for &variant in super::DepList::ALL {
19784            let via_trait: std::sync::Arc<str> =
19785                <std::sync::Arc<str> as From<&super::DepList>>::from(&variant);
19786            let via_method: &'static str = variant.as_str();
19787            assert_eq!(
19788                via_trait.as_ref(),
19789                via_method,
19790                "From<&DepList> for std::sync::Arc<str> impl must round-\
19791                 trip &DepList::{variant:?} to the same lifted \
19792                 crate::render::DEP_AUTHOR_KEY_DEPS* const \
19793                 DepList::as_str returns — divergence signals a silent \
19794                 detour off the substrate-primitive accessor"
19795            );
19796            let via_into: std::sync::Arc<str> = (&variant).into();
19797            assert_eq!(
19798                via_into.as_ref(),
19799                via_method,
19800                "Into<std::sync::Arc<str>>::into on &DepList::\
19801                 {variant:?} must byte-equal DepList::as_str on the \
19802                 same input — the blanket-derived Into shape on the \
19803                 borrowed-input surface must resolve to the same as_str \
19804                 dispatch as the explicit From impl"
19805            );
19806            let owned_arc: std::sync::Arc<str> =
19807                <std::sync::Arc<str> as From<super::DepList>>::from(variant);
19808            assert_eq!(
19809                via_trait, owned_arc,
19810                "From<&DepList> for std::sync::Arc<str> and \
19811                 From<DepList> for std::sync::Arc<str> must resolve \
19812                 identically on DepList::{variant:?} — divergence \
19813                 signals the borrowed-input and owned-input \
19814                 std::sync::Arc<str> forward-projection input-shape \
19815                 paths have drifted onto different emit-sets"
19816            );
19817            let borrowed_static: &'static str =
19818                <&'static str as From<&super::DepList>>::from(&variant);
19819            assert_eq!(
19820                via_trait.as_ref(),
19821                borrowed_static,
19822                "From<&DepList> for std::sync::Arc<str> and \
19823                 From<&DepList> for &'static str must resolve \
19824                 identically on DepList::{variant:?} — divergence \
19825                 signals the borrowed-input std::sync::Arc<str> and \
19826                 &'static str return-shape paths have drifted onto \
19827                 different emit-sets"
19828            );
19829            let borrowed_string: String = <String as From<&super::DepList>>::from(&variant);
19830            assert_eq!(
19831                via_trait.as_ref(),
19832                borrowed_string.as_str(),
19833                "From<&DepList> for std::sync::Arc<str> and \
19834                 From<&DepList> for String must resolve identically on \
19835                 DepList::{variant:?} — divergence signals the \
19836                 borrowed-input std::sync::Arc<str> and owned-`String` \
19837                 return-shape paths have drifted onto different emit-\
19838                 sets"
19839            );
19840            let borrowed_cow: std::borrow::Cow<'static, str> =
19841                <std::borrow::Cow<'static, str> as From<&super::DepList>>::from(&variant);
19842            assert_eq!(
19843                via_trait.as_ref(),
19844                borrowed_cow.as_ref(),
19845                "From<&DepList> for std::sync::Arc<str> and \
19846                 From<&DepList> for Cow<'static, str> must resolve \
19847                 identically on DepList::{variant:?} — divergence \
19848                 signals the borrowed-input std::sync::Arc<str> and \
19849                 Cow<'static, str> return-shape paths have drifted onto \
19850                 different emit-sets"
19851            );
19852            let borrowed_box: Box<str> = <Box<str> as From<&super::DepList>>::from(&variant);
19853            assert_eq!(
19854                via_trait.as_ref(),
19855                borrowed_box.as_ref(),
19856                "From<&DepList> for std::sync::Arc<str> and \
19857                 From<&DepList> for Box<str> must resolve identically \
19858                 on DepList::{variant:?} — divergence signals the \
19859                 borrowed-input std::sync::Arc<str> and Box<str> \
19860                 return-shape paths have drifted onto different emit-sets"
19861            );
19862        }
19863        let via_iter: Vec<std::sync::Arc<str>> = super::DepList::ALL
19864            .iter()
19865            .map(std::sync::Arc::<str>::from)
19866            .collect();
19867        let via_method: Vec<std::sync::Arc<str>> = super::DepList::ALL
19868            .iter()
19869            .map(|l| std::sync::Arc::<str>::from(l.as_str()))
19870            .collect();
19871        assert_eq!(
19872            via_iter, via_method,
19873            "`.iter().map(std::sync::Arc::<str>::from)` over \
19874             DepList::ALL — a call site whose iteration axis holds \
19875             `&DepList` by construction — must byte-equal \
19876             `.iter().map(|l| std::sync::Arc::<str>::from(l.as_str()))` \
19877             on every arm — the borrowed-input std::sync::Arc<str> \
19878             `From<&DepList> for std::sync::Arc<str>` axis is what \
19879             makes the `std::sync::Arc::<str>::from` composition route \
19880             through the substrate-primitive `DepList::as_str` \
19881             accessor without a spurious `Copy` deref (which would \
19882             only be reachable through the owned-input \
19883             `From<DepList> for std::sync::Arc<str>` axis by first \
19884             calling `.copied()` on the iterator)"
19885        );
19886    }
19887
19888    #[test]
19889    fn dep_list_author_keys_covers_every_arm() {
19890        // Load-bearing pin on the substrate-canonical
19891        // [`super::DepList::AUTHOR_KEYS`] exhaustive accept-set roster
19892        // on the `:`-prefixed kebab-case tatara-lisp author-surface
19893        // key axis: every variant of the sibling
19894        // [`super::DepList::ALL`] exhaustive-iteration surface must
19895        // project through [`super::DepList::as_str`] onto an entry the
19896        // [`super::DepList::AUTHOR_KEYS`] roster carries, and the
19897        // roster's length must byte-equal `super::DepList::ALL.len()`
19898        // so a silent skew between the [`super::DepList::as_str`]
19899        // match's arm-set and the roster's arm-set trips here at
19900        // caixa-core test time rather than at a downstream M4
19901        // `mesh.pleme.io/v1alpha1/Caixa` CR admission-webhook rejection
19902        // body's `:deps` / `:deps-dev` accepted-key enumeration miss /
19903        // a `feira dep --list …` "did you mean" hint drift / a
19904        // downstream [`super::DepError`] widening's typed `list:
19905        // DepList` carry that fans on the enum through a stale
19906        // accepted-set. A future arm addition (a `:build-dep` or
19907        // `:tool-dep` third list once the substrate grows Cargo-style
19908        // split-graphs — both trajectory items the sibling
19909        // [`super::DepList::from_wire`] doc block already names)
19910        // extends [`super::DepList::ALL`] as a single edit and this
19911        // pin sweeps the new arm by iteration; the paired
19912        // [`super::DepList::AUTHOR_KEYS`] roster must grow in lockstep
19913        // or this assertion trips. Every entry is further pinned to
19914        // open with the ASCII `:` byte (the tatara-lisp author-surface
19915        // keyword marker) so a silent collapse of the author-key axis
19916        // with any hypothetical peer un-prefixed wire-form axis (an
19917        // entry byte-identical to a sibling `deps` / `deps-dev`
19918        // bare-kebab byte-string that would let an author-key-axis
19919        // consumer accept the un-prefixed vocabulary) trips here
19920        // rather than at a downstream consumer's
19921        // vocabulary-collision miss.
19922        //
19923        // Peer of the sibling
19924        // [`crate::kind::tests::caixa_kind_wire_names_covers_every_arm`]
19925        // (bd708bd) /
19926        // [`crate::kind::tests::caixa_kind_labels_covers_every_arm`]
19927        // (427fe75) /
19928        // [`crate::supervisor::tests::restart_strategy_wire_names_covers_every_arm`]
19929        // (3033f45) /
19930        // [`crate::supervisor::tests::restart_policy_wire_names_covers_every_arm`]
19931        // (ce9412b) /
19932        // [`crate::aplicacao::tests::placement_strategy_wire_names_covers_every_arm`]
19933        // (3e5b194) /
19934        // [`crate::aplicacao::tests::wit_shape_labels_covers_every_arm`]
19935        // (9d9f585) /
19936        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
19937        // (b553ec9) /
19938        // [`crate::upgrade::tests::upgrade_instruction_lisp_forms_covers_every_arm`]
19939        // (1898d77) /
19940        // [`crate::upgrade::tests::upgrade_instruction_wire_forms_covers_every_arm`]
19941        // (cc42c0e) pins — the same closed-set exhaustive-roster
19942        // coverage discipline extended here onto the two-list dep-graph
19943        // closed-set typed enum, the ninth substrate-side closed-set
19944        // typed enum on the roster axis and the last unlifted
19945        // `&'static str`-carrying closed-set typed enum on the top-
19946        // level manifest surface to converge onto the discipline.
19947        //
19948        // Fail-before-pass-after locally verified by mutating one arm
19949        // of the paired [`crate::render::DEP_AUTHOR_KEY_*`] const
19950        // family (e.g. rebranding `DEP_AUTHOR_KEY_DEPS_DEV` from
19951        // `":deps-dev"` to `":deps_dev"`) — the length pin still
19952        // passes but the `contains` check fires on the mutated arm;
19953        // and by shortening the roster to one entry — the length pin
19954        // fires first.
19955        assert_eq!(
19956            super::DepList::AUTHOR_KEYS.len(),
19957            super::DepList::ALL.len(),
19958            "DepList::AUTHOR_KEYS.len() must byte-equal \
19959             DepList::ALL.len() — a mismatch means the roster and \
19960             the enum's arm-set have drifted; downstream consumers \
19961             that fan through both will silently disagree on the \
19962             accepted arm-set"
19963        );
19964        for &variant in super::DepList::ALL {
19965            let key = variant.as_str();
19966            assert!(
19967                super::DepList::AUTHOR_KEYS.contains(&key),
19968                "DepList::{variant:?}.as_str() = {key:?} must be a \
19969                 member of DepList::AUTHOR_KEYS — the emitter and the \
19970                 roster have drifted out of lockstep"
19971            );
19972        }
19973        for tag in super::DepList::AUTHOR_KEYS {
19974            let first = tag.chars().next().unwrap_or_else(|| {
19975                panic!(
19976                    "DepList::AUTHOR_KEYS entry {tag:?} must be a \
19977                     non-empty `:`-prefixed kebab-case tatara-lisp \
19978                     author-surface key byte-string"
19979                )
19980            });
19981            assert_eq!(
19982                first, ':',
19983                "DepList::AUTHOR_KEYS entry {tag:?} must open with \
19984                 the ASCII `:` byte (tatara-lisp author-surface \
19985                 keyword marker) — an un-prefixed entry would \
19986                 collide the roster with any hypothetical peer bare-\
19987                 kebab wire-form axis a downstream consumer might \
19988                 disambiguate against"
19989            );
19990        }
19991        // Pin the exact two-arm roster in declaration order so a
19992        // future arm-swap on either the roster or the paired
19993        // `render::DEP_AUTHOR_KEY_*` constants (a rebrand of the
19994        // arm-key mapping that leaves both the length pin and the
19995        // membership pin passing on their own) trips at caixa-core
19996        // test time under `assert_eq!`. Order matches variant
19997        // declaration order verbatim (`Prod` → `Dev`) so the roster
19998        // is the canonical ordering every listing / rendering
19999        // consumer defers to. Same declaration-order pin the sibling
20000        // [`crate::aplicacao::tests::rate_limit_unit_suffixes_covers_every_arm`]
20001        // (b553ec9) closes on the M3 `:politicas :rate-limit`
20002        // canonical-suffix axis.
20003        assert_eq!(
20004            super::DepList::AUTHOR_KEYS,
20005            &[
20006                crate::render::DEP_AUTHOR_KEY_DEPS,
20007                crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
20008            ],
20009            "DepList::AUTHOR_KEYS must enumerate every arm's \
20010             author-surface key exactly once, in variant declaration \
20011             order (Prod → Dev)"
20012        );
20013    }
20014
20015    #[test]
20016    fn dep_list_from_str_routes_through_try_from_str_impl() {
20017        // Fail-before-pass-after byte-parity pin on the newly lifted
20018        // `impl std::str::FromStr for DepList` — asserts the standard-
20019        // library `.parse()` parse-axis entry point and the paired
20020        // [`super::DepList::try_from`] `TryFrom<&str>` impl (which in
20021        // turn routes through the substrate-primitive
20022        // [`super::DepList::from_wire`] `Option<Self>` accessor)
20023        // resolve to the same two-arm accept-set across every arm the
20024        // exhaustive [`super::DepList::ALL`] slice enumerates. First-
20025        // mover on the substrate-wide `FromStr` parse-axis campaign —
20026        // the peer method-named `from_wire` accessor and the paired
20027        // `TryFrom<&str>` trait impl fix the two-arm accept set; this
20028        // pin locks the `FromStr::from_str` trait entry point onto the
20029        // same set so any future divergence (a stray per-arm `match s`
20030        // re-inlining that opens a compile-time link to an un-lifted
20031        // arm-literal, a swap onto a hand-rolled parser that widens
20032        // the accept-set past the two wire-format consts) trips at
20033        // caixa-core test time.
20034        use std::str::FromStr;
20035        for &list in super::DepList::ALL {
20036            let wire = list.as_str();
20037            assert_eq!(
20038                <super::DepList as FromStr>::from_str(wire),
20039                Ok(list),
20040                "FromStr impl on DepList must round-trip \
20041                 DepList::{list:?}.as_str() = {wire:?} back to \
20042                 Ok(DepList::{list:?}) — divergence from \
20043                 DepList::try_from signals a silent detour off the \
20044                 paired reverse-projection trait impl"
20045            );
20046            assert_eq!(
20047                <super::DepList as FromStr>::from_str(wire).ok(),
20048                super::DepList::from_wire(wire),
20049                "FromStr ok()-projection on {wire:?} must byte-equal \
20050                 DepList::from_wire on the same input — divergence \
20051                 signals the two reverse-projection trait paths have \
20052                 drifted off the substrate-primitive accessor"
20053            );
20054            // `.parse::<DepList>()` short-form witness — the stdlib
20055            // consumer surface that reaches the enum through the
20056            // `T: FromStr` bound, not through `TryFrom<&str>`.
20057            let via_parse: Result<super::DepList, ()> = wire.parse();
20058            assert_eq!(
20059                via_parse,
20060                Ok(list),
20061                "`{wire:?}`.parse::<DepList>() must resolve to \
20062                 Ok(DepList::{list:?}) — divergence signals the \
20063                 stdlib `.parse()` short-form has drifted from the \
20064                 lifted `FromStr::from_str` impl"
20065            );
20066        }
20067    }
20068
20069    #[test]
20070    fn dep_list_from_str_rejects_unknown_byte_strings() {
20071        // Rejection witness on the `impl FromStr for DepList` —
20072        // sweeps candidate byte-strings outside the two-arm accept-set
20073        // the sibling [`super::DepList::as_str`] emits (`:deps` /
20074        // `:deps-dev`) and asserts every one lands on `Err(())`, so a
20075        // future accidental widening of the trait impl's accept-set (a
20076        // stray case-fold path, a silent inclusion of a rebrand alias
20077        // like `":packages"`, an English rebrand `":dev-deps"` in
20078        // reverse arm-order that would silently swap the two arms) trips
20079        // at caixa-core test time. Peer of the sibling
20080        // `dep_list_try_from_str_rejects_unknown_byte_strings` rejection
20081        // witness — the two pins together bracket both reverse-projection
20082        // trait impls against the same rejected set.
20083        use std::str::FromStr;
20084        let rejected: &[&str] = &[
20085            "",
20086            " ",
20087            "\t",
20088            "\n",
20089            ":deps ",
20090            " :deps",
20091            ":DEPS",
20092            ":Deps",
20093            ":Deps-Dev",
20094            ":deps_dev",
20095            ":deps-development",
20096            ":dev-deps",
20097            ":packages",
20098            ":packages-dev",
20099            "deps",
20100            "deps-dev",
20101            "Prod",
20102            "Dev",
20103            "prod",
20104            "dev",
20105            "\":deps\"",
20106            "\":deps-dev\"",
20107            ":deps\n",
20108            ":deps-dev\n",
20109        ];
20110        for &input in rejected {
20111            assert_eq!(
20112                <super::DepList as FromStr>::from_str(input),
20113                Err(()),
20114                "FromStr impl on DepList must reject unknown \
20115                 byte-string {input:?} — divergence from \
20116                 DepList::from_wire on the same input signals a silent \
20117                 accept-set widening past the two lifted \
20118                 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
20119            );
20120            assert_eq!(
20121                <super::DepList as FromStr>::from_str(input).ok(),
20122                super::DepList::from_wire(input),
20123                "FromStr ok()-projection on {input:?} must byte-equal \
20124                 DepList::from_wire on the same input — divergence \
20125                 signals the FromStr trait path has drifted off the \
20126                 substrate-primitive accessor"
20127            );
20128            let via_parse: Result<super::DepList, ()> = input.parse();
20129            assert_eq!(
20130                via_parse,
20131                Err(()),
20132                "`{input:?}`.parse::<DepList>() must reject the \
20133                 unknown byte-string — divergence signals the stdlib \
20134                 `.parse()` short-form has drifted from the lifted \
20135                 `FromStr::from_str` impl"
20136            );
20137        }
20138    }
20139}
20140
20141#[cfg(test)]
20142mod dep_source_is_variant_tests {
20143    use super::*;
20144
20145    fn all_variants() -> Vec<(DepSource, &'static str)> {
20146        vec![
20147            (
20148                DepSource::Git {
20149                    repo: "github:pleme-io/caixa-teia".into(),
20150                    tag: Some("v0.1.0".into()),
20151                    rev: None,
20152                    branch: None,
20153                },
20154                "Git",
20155            ),
20156            (
20157                DepSource::Path {
20158                    caminho: "../caixa-teia".into(),
20159                },
20160                "Path",
20161            ),
20162        ]
20163    }
20164
20165    fn predicate_row(s: &DepSource) -> [bool; 2] {
20166        [s.is_git(), s.is_path()]
20167    }
20168
20169    // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
20170    // derive-generated per-arm predicate partition — for every variant
20171    // in `all_variants()`, the observed 2-slot predicate row must equal
20172    // a one-hot row with the `true` at exactly the same index as the
20173    // variant's declaration order. Expected rows are generated live
20174    // from the enumeration rather than transcribed by hand, so a
20175    // copy-paste flip that reroutes one arm through the wrong predicate
20176    // lane trips at the identity-diagonal assertion the way every peer
20177    // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
20178    // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
20179    // / [`crate::upgrade::UpgradeInstruction`] /
20180    // [`crate::aplicacao::PlacementStrategy`] /
20181    // [`crate::aplicacao::RateLimitUnit`] /
20182    // [`crate::aplicacao::WitTarget`] /
20183    // [`crate::render::PathShapeViolation`] partition pin already does.
20184    #[test]
20185    fn dep_source_is_variant_predicates_partition_the_arm_set() {
20186        let variants = all_variants();
20187        for (idx, (variant, name)) in variants.iter().enumerate() {
20188            let observed = predicate_row(variant);
20189            let mut expected = [false; 2];
20190            expected[idx] = true;
20191            assert_eq!(
20192                observed, expected,
20193                "DepSource::{name} at declaration-order slot {idx} must \
20194                 satisfy exactly one is_* predicate (its own); observed \
20195                 row must equal the one-hot expected row — a drift \
20196                 would silently reroute one `:fonte`-arm consumer \
20197                 through the wrong predicate lane"
20198            );
20199        }
20200    }
20201
20202    // Byte-parity pin on the two field-agnostic `matches!` shapes the
20203    // per-arm arm-discriminator predicates replace at any future
20204    // consumer site (a `:fonte`-shape-only lint rule that flags path
20205    // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
20206    // a future admission-webhook that rejects `:fonte` shapes outside
20207    // the `is_git()` accept-set, a caixa-lacre indexing pass that
20208    // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
20209    // Refuses a future accidental split between the derived predicate
20210    // and its `matches!` shape — a hand-rolled shadow impl that
20211    // overrides one path, an accidental rebrand that leaves one
20212    // consumer on the raw `matches!` form — on the two load-bearing
20213    // `:fonte`-arm-discriminator axes every downstream substrate
20214    // consumer of the dep-source axis keys off.
20215    #[test]
20216    fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
20217        for (variant, name) in all_variants() {
20218            let via_matches_git = matches!(variant, DepSource::Git { .. });
20219            let via_predicate_git = variant.is_git();
20220            assert_eq!(
20221                via_predicate_git, via_matches_git,
20222                "DepSource::{name}.is_git() must byte-equal \
20223                 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
20224                 future converged consumer site would silently \
20225                 disagree with its pre-lift shape"
20226            );
20227            let via_matches_path = matches!(variant, DepSource::Path { .. });
20228            let via_predicate_path = variant.is_path();
20229            assert_eq!(
20230                via_predicate_path, via_matches_path,
20231                "DepSource::{name}.is_path() must byte-equal \
20232                 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
20233                 future converged consumer site would silently \
20234                 disagree with its pre-lift shape"
20235            );
20236        }
20237    }
20238
20239    // Cross-pin against every constructor path that materializes a
20240    // [`DepSource`] shape today (the [`DepSource::default_github`]
20241    // resolver-side fallback that materializes an unpinned
20242    // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
20243    // surface constructor that materializes a pinned `:tag`-carrying
20244    // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
20245    // fixture family builds inline). Every constructor's return must
20246    // satisfy the arm-discriminator predicate the constructor's
20247    // variant name matches — a future constructor addition (an
20248    // in-tree registry-fetch pin, a `DepSource::Feira` variant the
20249    // enclosing docstring already names as a trajectory item) surfaces
20250    // as a build-time failure that names the offending drift when its
20251    // return arm doesn't route through the paired predicate.
20252    #[test]
20253    fn dep_source_constructors_route_through_paired_is_variant_predicate() {
20254        let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
20255        assert!(
20256            via_default_github.is_git(),
20257            "DepSource::default_github must materialize a Git-arm shape — \
20258             a future constructor that routed through a non-Git arm \
20259             (a registry-fetch pin, a `DepSource::Feira` promotion) \
20260             would silently split the resolver's unpinned-shorthand \
20261             materializer from the sole_pin() precedence cascade"
20262        );
20263        assert!(
20264            !via_default_github.is_path(),
20265            "DepSource::default_github must NOT materialize a Path-arm \
20266             shape — the paired negation pin"
20267        );
20268
20269        let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
20270            .fonte
20271            .expect("Dep::git materializes a Some(fonte)");
20272        assert!(
20273            via_dep_git.is_git(),
20274            "Dep::git's `:fonte` materialization must land on the Git \
20275             arm — the author-surface pinned-git constructor's return \
20276             must route through the paired predicate"
20277        );
20278        assert!(!via_dep_git.is_path(), "paired negation pin");
20279
20280        let via_path = DepSource::Path {
20281            caminho: "../caixa-teia".into(),
20282        };
20283        assert!(
20284            via_path.is_path(),
20285            "the dev-mode Path-arm materialization must satisfy is_path()"
20286        );
20287        assert!(!via_path.is_git(), "paired negation pin");
20288    }
20289
20290    // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
20291    //    String, reason: String }` three-slot envelope on `DepError`,
20292    //    strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
20293    //    the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
20294    //    (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
20295    //    envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
20296    //    `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
20297    //    (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
20298
20299    #[test]
20300    fn versao_invalid_ctor_matches_struct_literal_wrap() {
20301        assert_eq!(
20302            DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
20303            DepError::VersaoInvalid {
20304                nome: "caixa-teia".to_string(),
20305                versao: "^0..1".to_string(),
20306                reason: "invalid comparator".to_string(),
20307            },
20308            "versao_invalid ctor must produce byte-equal \
20309             `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
20310        );
20311    }
20312
20313    #[test]
20314    fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
20315        assert_eq!(
20316            DepError::fonte_repo_shape(
20317                "caixa-teia",
20318                "-upload-pack=evil",
20319                "leading dash rejected".to_string(),
20320            ),
20321            DepError::FonteRepoShape {
20322                nome: "caixa-teia".to_string(),
20323                repo: "-upload-pack=evil".to_string(),
20324                reason: "leading dash rejected".to_string(),
20325            },
20326            "fonte_repo_shape ctor must produce byte-equal \
20327             `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
20328        );
20329    }
20330
20331    #[test]
20332    fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
20333        assert_eq!(
20334            DepError::caracteristica_invalid(
20335                "caixa-teia",
20336                "bad feature!",
20337                "embedded space rejected".to_string(),
20338            ),
20339            DepError::CaracteristicaInvalid {
20340                nome: "caixa-teia".to_string(),
20341                caracteristica: "bad feature!".to_string(),
20342                reason: "embedded space rejected".to_string(),
20343            },
20344            "caracteristica_invalid ctor must produce byte-equal \
20345             `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
20346        );
20347    }
20348
20349    #[test]
20350    fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
20351        // Cross-axis routing pin: sweep the three constructor input axes
20352        // (`nome: &str`, `<axis>: &str`, `reason: String`) through
20353        // distinct-per-axis fixtures against every generated arm in the
20354        // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
20355        // lowercase / trim / truncate on the two `&str` axes — a silent
20356        // field swap between `nome`, the middle `<axis>` field, and
20357        // `reason`, or a `reason` axis silently rerouted through
20358        // `.to_string()` instead of forwarded owned — surfaces here rather
20359        // than at a downstream diagnostic-shape mismatch. Peer of the
20360        // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
20361        // through_to_string` (0e35793) cross-axis routing pin on the same
20362        // envelope's `{ nome, caminho, byte }` three-slot family and of
20363        // the peer `dep_nome_list_ctors_route_nome_and_list_through_
20364        // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
20365        // — extended here onto the `{ nome, <axis>: String, reason:
20366        // String }` three-slot envelope so every substrate-primitive ctor
20367        // family in caixa-core's `DepError` envelope guarantees each field
20368        // routes the caller's value verbatim through `.to_string()` (or
20369        // owned-forward for `reason: String`) in declared field order.
20370        // Distinct-per-axis fixtures rule out any two-axis swap
20371        // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
20372        // same-fixture-per-axis pin.
20373        let nome = "sibling-teia";
20374        let axis = "distinct-axis-value";
20375        let reason = "distinct rejection sentence".to_string();
20376        assert_eq!(
20377            DepError::versao_invalid(nome, axis, reason.clone()),
20378            DepError::VersaoInvalid {
20379                nome: nome.to_string(),
20380                versao: axis.to_string(),
20381                reason: reason.clone(),
20382            },
20383            "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
20384             `reason` → `reason` in declared field order",
20385        );
20386        assert_eq!(
20387            DepError::fonte_repo_shape(nome, axis, reason.clone()),
20388            DepError::FonteRepoShape {
20389                nome: nome.to_string(),
20390                repo: axis.to_string(),
20391                reason: reason.clone(),
20392            },
20393            "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
20394             `reason` → `reason` in declared field order",
20395        );
20396        assert_eq!(
20397            DepError::caracteristica_invalid(nome, axis, reason.clone()),
20398            DepError::CaracteristicaInvalid {
20399                nome: nome.to_string(),
20400                caracteristica: axis.to_string(),
20401                reason: reason.clone(),
20402            },
20403            "caracteristica_invalid must route `nome` → `nome`, \
20404             `axis` → `caracteristica`, `reason` → `reason` in declared \
20405             field order",
20406        );
20407    }
20408
20409    // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
20410    //    two-slot envelope on `DepError`, missing rung between
20411    //    `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
20412    //    envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
20413    //    three-slot `{ nome, <axis>: String, reason: String }` envelope.
20414    //    Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
20415    //    two-slot `{ nome, list: &'static str }` envelope (same slot
20416    //    count, `&'static str` axis instead of owned `String` axis).
20417
20418    #[test]
20419    fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
20420        assert_eq!(
20421            DepError::fonte_pin_empty("caixa-teia", ":tag"),
20422            DepError::FontePinEmpty {
20423                nome: "caixa-teia".to_string(),
20424                pin: ":tag".to_string(),
20425            },
20426            "fonte_pin_empty ctor must produce byte-equal \
20427             `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
20428             on the same `(&str, &str)` fixture",
20429        );
20430    }
20431
20432    #[test]
20433    fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
20434        assert_eq!(
20435            DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
20436            DepError::FontePinAmbiguous {
20437                nome: "caixa-teia".to_string(),
20438                pins: ":tag, :rev".to_string(),
20439            },
20440            "fonte_pin_ambiguous ctor must produce byte-equal \
20441             `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
20442             wrap on the same `(&str, &str)` fixture",
20443        );
20444    }
20445
20446    #[test]
20447    fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
20448        assert_eq!(
20449            DepError::caracteristica_duplicate("caixa-teia", "http"),
20450            DepError::CaracteristicaDuplicate {
20451                nome: "caixa-teia".to_string(),
20452                caracteristica: "http".to_string(),
20453            },
20454            "caracteristica_duplicate ctor must produce byte-equal \
20455             `DepError::CaracteristicaDuplicate` to the pre-lift \
20456             struct-literal wrap on the same `(&str, &str)` fixture",
20457        );
20458    }
20459
20460    #[test]
20461    fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
20462        // Owned-`String` routing pin: thread the real
20463        // `set.join(", ")` `String` carrier through the ctor's
20464        // `&str`-parameter Deref coercion, so the ambiguity-arm
20465        // wire-up site's actual `&set.join(", ")` shape stays
20466        // byte-equal to a direct `":tag, :rev"` literal. A future
20467        // parameter-shape change silently dropping the Deref
20468        // coercion route (e.g., a switch to `impl Into<String>`)
20469        // surfaces here rather than at the wire-up's compile
20470        // error far from the ctor definition.
20471        let set: Vec<&'static str> = vec![":tag", ":rev"];
20472        let joined: String = set.join(", ");
20473        assert_eq!(
20474            DepError::fonte_pin_ambiguous("caixa-teia", &joined),
20475            DepError::FontePinAmbiguous {
20476                nome: "caixa-teia".to_string(),
20477                pins: ":tag, :rev".to_string(),
20478            },
20479            "fonte_pin_ambiguous ctor must accept an owned-`String` \
20480             `&set.join(\", \")` carrier via Deref coercion — the exact \
20481             shape the ambiguity-arm wire-up site passes into it",
20482        );
20483    }
20484
20485    #[test]
20486    fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
20487        // Cross-axis routing pin: sweep the two constructor input axes
20488        // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
20489        // fixtures against every generated arm in the
20490        // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
20491        // trim / truncate at codegen time — a silent field swap between
20492        // `nome` and the middle `<axis>` field, or a `<axis>` axis
20493        // silently rerouted through the wrong field on any one variant
20494        // — surfaces here rather than at a downstream diagnostic-shape
20495        // mismatch. Peer of the sibling
20496        // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
20497        // (6f5e0cd) pin on the same envelope's peer two-slot family
20498        // (`{ nome, list: &'static str }`) and of the sibling
20499        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20500        // (5621f8a) pin on the same envelope's three-slot `{ nome,
20501        // <axis>: String, reason: String }` family — extended here onto
20502        // the `{ nome, <axis>: String }` two-slot envelope so the last
20503        // per-`DepError`-two-slot-owned-axis rung on the ctor-family
20504        // ladder guarantees each field routes the caller's value
20505        // verbatim through `.to_string()` in declared field order.
20506        // Distinct-per-axis fixtures rule out any two-axis swap
20507        // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
20508        // per-axis pin.
20509        let nome = "sibling-teia";
20510        let axis = "distinct-axis-value";
20511        assert_eq!(
20512            DepError::fonte_pin_empty(nome, axis),
20513            DepError::FontePinEmpty {
20514                nome: nome.to_string(),
20515                pin: axis.to_string(),
20516            },
20517            "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
20518             in declared field order",
20519        );
20520        assert_eq!(
20521            DepError::fonte_pin_ambiguous(nome, axis),
20522            DepError::FontePinAmbiguous {
20523                nome: nome.to_string(),
20524                pins: axis.to_string(),
20525            },
20526            "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
20527             in declared field order",
20528        );
20529        assert_eq!(
20530            DepError::caracteristica_duplicate(nome, axis),
20531            DepError::CaracteristicaDuplicate {
20532                nome: nome.to_string(),
20533                caracteristica: axis.to_string(),
20534            },
20535            "caracteristica_duplicate must route `nome` → `nome`, \
20536             `axis` → `caracteristica` in declared field order",
20537        );
20538    }
20539
20540    #[test]
20541    fn nome_invalid_ctor_matches_struct_literal_wrap() {
20542        // Equivalence pin: the ctor produces byte-equal
20543        // `DepError::NomeInvalid` to the pre-lift open-coded struct-
20544        // literal that cloned the offending `:deps :nome` verbatim and
20545        // forwarded the [`crate::render::is_dns_1123_label`]-shaped
20546        // owned `reason` payload at the caller site inside
20547        // [`Dep::validate`]. Guards any future field-addition /
20548        // reordering / accessor-return tweak on the variant. Sibling of
20549        // the peer four-slot `fonte_pin_shape` ctor equivalence pins
20550        // (below) and the sibling three-slot
20551        // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
20552        // pin on the same envelope's three-slot `{ nome, <axis>: String,
20553        // reason: String }` family.
20554        let nome = "Caixa-Teia";
20555        let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
20556        let via_ctor = DepError::nome_invalid(nome, reason.clone());
20557        let via_literal = DepError::NomeInvalid {
20558            nome: nome.to_string(),
20559            reason,
20560        };
20561        assert_eq!(
20562            via_ctor, via_literal,
20563            "nome_invalid(nome, reason) must byte-equal the open-coded \
20564             NomeInvalid struct-literal on the same `(nome, reason)` fixture"
20565        );
20566        assert_eq!(
20567            via_ctor.to_string(),
20568            via_literal.to_string(),
20569            "Display byte-string must byte-equal the open-coded struct-literal"
20570        );
20571    }
20572
20573    #[test]
20574    fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
20575        // Boundary-sweep pin on the ctor's two-slot projection: sweep
20576        // the two ctor input axes (`nome: &str`, `reason: String`)
20577        // through distinct-per-axis fixtures against a representative
20578        // set of DNS-1123-refused `:deps :nome` byte-strings, so any
20579        // wrapper-side silent lowercase / trim / truncate at codegen
20580        // time — a silent field swap between `nome` and `reason`, an
20581        // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
20582        // divergence on the `reason` axis — surfaces at caixa-core
20583        // build time rather than at a downstream diagnostic consumer
20584        // that reads `err.nome` / `err.reason` back and gets a different
20585        // value than the one it stored. Peer of the sibling
20586        // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
20587        // (7f7c950) pin on the same envelope's peer two-slot family
20588        // (`{ nome, <axis>: String }`) — extended here onto the
20589        // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
20590        // variant carries. Distinct-per-axis fixtures rule out any
20591        // two-axis swap (`nome` ↔ `reason`) that would still pass a
20592        // same-fixture-per-axis pin. The sweep list carries a mixed
20593        // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
20594        // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
20595        // over-63-byte) so a future silent per-input normalization
20596        // surfaces on the arm that diverges.
20597        for nome in [
20598            "Caixa-Teia",
20599            "caixa_teia",
20600            "caixa.teia",
20601            "-caixa-teia",
20602            "caixa-teia-",
20603            "caixa/teia",
20604            &"a".repeat(64),
20605        ] {
20606            let reason = crate::render::is_dns_1123_label(nome)
20607                .expect_err("fixture must be a DNS-1123-refused label");
20608            let via_ctor = DepError::nome_invalid(nome, reason.clone());
20609            let DepError::NomeInvalid {
20610                nome: stored_nome,
20611                reason: stored_reason,
20612            } = via_ctor
20613            else {
20614                panic!("nome_invalid must construct NomeInvalid for {nome:?}");
20615            };
20616            assert_eq!(
20617                stored_nome, nome,
20618                "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
20619            );
20620            assert_eq!(
20621                stored_reason, reason,
20622                "reason slot must forward the owned `String` verbatim for {nome:?}"
20623            );
20624        }
20625    }
20626
20627    #[test]
20628    fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
20629        // End-to-end pin: the sole in-crate wire-up site
20630        // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
20631        // [`DepError::nome_invalid`] and the observed `Err` byte-equals
20632        // the ctor's output on the same DNS-1123-refused `:deps :nome`
20633        // fixture, with identical `Display` rendering. A future silent
20634        // de-lift of the wire-up back to the open-coded struct-literal
20635        // trips this test at caixa-core build time rather than at a
20636        // downstream diagnostic consumer far from the wire-up commit.
20637        // Sibling of the peer
20638        // `nome_invalid_diagnostic_carries_offending_name` pattern-match
20639        // pin on the same wire-up — extended here from a `matches!`
20640        // shape check to a byte-identity + Display parity route through
20641        // the ctor.
20642        let d = Dep::simple("Caixa_Teia", "^0.1");
20643        let observed = d.validate().unwrap_err();
20644        let reason = crate::render::is_dns_1123_label("Caixa_Teia")
20645            .expect_err("fixture must be DNS-1123-refused");
20646        let expected = DepError::nome_invalid("Caixa_Teia", reason);
20647        assert_eq!(
20648            observed, expected,
20649            "Dep::validate's DNS-1123 refusal arm must byte-equal \
20650             nome_invalid(nome, reason)"
20651        );
20652        assert_eq!(
20653            observed.to_string(),
20654            expected.to_string(),
20655            "Display byte-string parity"
20656        );
20657    }
20658}