caixa_core/dep.rs
1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17/// :versao "^0.1"
18/// :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22/// :versao "*"
23/// :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27/// :versao "0.1.0"
28/// :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33 /// Caixa name — must match the target caixa's `:nome`.
34 pub nome: String,
35
36 /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37 pub versao: String,
38
39 /// Where to fetch the caixa from. Defaults to the feira registry.
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub fonte: Option<DepSource>,
42
43 /// If true, a missing `:fonte` is not a build failure.
44 #[serde(default, skip_serializing_if = "is_false")]
45 pub opcional: bool,
46
47 /// Feature flags to enable on the target caixa.
48 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81 /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82 /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83 /// or any git-ssh URL.
84 Git {
85 repo: String,
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 tag: Option<String>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 rev: Option<String>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 branch: Option<String>,
92 },
93 /// Local filesystem path — dev only; cannot be published.
94 Path { caminho: String },
95}
96
97impl DepSource {
98 /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99 ///
100 /// This is the resolver-side fallback for `dep.fonte: None`, not an
101 /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102 /// all `None`) and is therefore rejected by [`Self::validate`]. The
103 /// resolver fills the pin in at fetch time from the resolved commit;
104 /// authors never serialize this shape as a `Dep::fonte` value.
105 #[must_use]
106 pub fn default_github(org: &str, nome: &str) -> Self {
107 Self::Git {
108 repo: format!("github:{org}/{nome}"),
109 tag: None,
110 rev: None,
111 branch: None,
112 }
113 }
114
115 /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116 /// every consumer that reads "which single git ref does this source
117 /// resolve to?" keys off — returns the author-declared `:tag` /
118 /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119 /// borrowed from the typed slot's own `Option<String>` storage; `None`
120 /// on [`Self::Path`] (a path source carries no git-ref) and on a
121 /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122 /// `None` (the [`Self::default_github`] shorthand shape the resolver
123 /// materializes when the author omits `:fonte` — rejected by
124 /// [`Self::validate`], but the accessor's return is defined on this
125 /// arm too so pre-validate consumers reach for the same typed dispatch
126 /// as post-validate ones).
127 ///
128 /// **Precedence: rev > tag > branch.** The canonical precedence every
129 /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130 /// per-fetch `git checkout <ref>` reads through the same
131 /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132 /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133 /// through the same cascade at caixa-crd/src/conversion.rs. The
134 /// [`Self::validate`] gate enforces "exactly one pin set" — under
135 /// that invariant every accepted [`Self::Git`] carries exactly one
136 /// non-`None` pin and the precedence is unobservable, but the
137 /// precedence remains defined for pre-validate consumers (the
138 /// resolver's `MissingPin` diagnostic path, the caixa-crd
139 /// round-trip's default `"main"` fallback the author never sees a
140 /// diagnostic on) and defense-in-depth for a hypothetical future
141 /// state where multiple pins survive the gate. The precedence is
142 /// **rev before tag** because `:rev` (a git commit OID) is the
143 /// reproducibility-strongest identifier — an OID resolves to exactly
144 /// one commit regardless of which refname points at it, whereas
145 /// `:tag` and `:branch` are refnames the remote can silently move
146 /// (a tag re-push, a branch head advance); the resolver's freeze
147 /// step at fetch time promotes the resolved commit to `:rev` for
148 /// exactly this reason. **Tag before branch** because `:tag` is
149 /// conventionally immutable (a release tag) whereas `:branch` is
150 /// conventionally mutable (a tracking ref) — a caixa carrying both
151 /// a release tag and a tracking branch reads as "prefer the release
152 /// pin, fall through to the tracking pin only if the release is
153 /// missing". The cascade order also matches the byte-order every
154 /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155 /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156 /// [`Self::validate`]'s `pins` array).
157 ///
158 /// Prior to this lift the "sole set pin" projection sat twice in the
159 /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160 /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161 /// { … })?;`) and at caixa-crd's `dep_into_ref`
162 /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163 /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164 /// of the same precedence cascade with no compile-time link back to
165 /// the typed slot. A future extension of the pin axis to a richer
166 /// author surface (a `:commit` pin peer of `:rev` once the substrate
167 /// grows a signed-commit-verification pin, a `:ref` pin the M4
168 /// substrate operator resolves per-cluster ahead of fetch, a
169 /// promotion of the plain `Option<String>` pins to a typed
170 /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171 /// once the sibling [`crate::render::is_git_oid`] /
172 /// [`crate::render::is_git_ref_name`] gates land as typed
173 /// constructors) would have had to be threaded through both
174 /// open-coded copies in lockstep or the resolver's `git checkout`
175 /// target would silently disagree with the CRD's `git_ref` fill —
176 /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177 /// "v1"))` would ship with the resolver checking out `deadbeef`
178 /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179 /// lacre closure disagreeing with the emitted K8s CR the operator
180 /// reads. Lifting the resolution to a typed method on the substrate
181 /// primitive means both downstream consumers reach for exactly one
182 /// typed dispatch — the resolver's accept-set migrates as a unit on
183 /// any future pin-axis addition.
184 ///
185 /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186 /// `Option<&DepSource>` composite-reference accessor on the outer-
187 /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188 /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189 /// git-fetching consumer runs after the outer `:fonte` slot resolves
190 /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191 /// substrate primitive, thin projections at each consumer" discipline
192 /// the outer accessor family already carries.
193 #[must_use]
194 pub fn sole_pin(&self) -> Option<&str> {
195 match self {
196 Self::Git {
197 tag, rev, branch, ..
198 } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199 Self::Path { .. } => None,
200 }
201 }
202
203 /// Validate the `:fonte` value-shape: every author-surface
204 /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205 /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206 /// value; every `:fonte (:tipo path …)` must carry a non-empty
207 /// `:caminho`.
208 ///
209 /// Called from [`Dep::validate`] with the dep's `:nome` so every
210 /// diagnostic carries the offending entry verbatim — same
211 /// self-locating shape the `:deps :versao` (2420c44),
212 /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213 /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214 /// (3f9d7a0) gates already expose.
215 ///
216 /// Until this gate landed `:fonte` was the only `:deps`-related
217 /// typed surface still untyped past `Caixa::from_lisp`:
218 /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219 /// passed parse and surfaced as a git-clone failure at
220 /// lacre-resolve time, far from the source caixa.lisp.
221 /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222 /// passed parse and surfaced as the resolver's
223 /// [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224 /// at fetch time, again far from the source caixa.lisp; lifting
225 /// to validate-time gives the author the same diagnostic at the
226 /// edit site.
227 /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228 /// pins set — passed parse and the resolver silently picked
229 /// `:rev > :tag > :branch`, ignoring the other pins with no
230 /// diagnostic; the author had no way to know their `:branch`
231 /// was dropped. This is the canonical "pin drift" footgun.
232 /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233 /// passed parse and surfaced as `git checkout ""` at fetch time.
234 /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235 /// parse and surfaced as
236 /// [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237 /// with `path: PathBuf("")` — not actionable.
238 ///
239 /// Each rejected shape maps to a typed
240 /// [`DepError::Fonte*`] variant that names the offending
241 /// dep's `:nome` and the specific axis, so the author can grep
242 /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243 /// one edit.
244 pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245 match self {
246 Self::Git {
247 repo,
248 tag,
249 rev,
250 branch,
251 } => {
252 if repo.is_empty() {
253 return Err(DepError::fonte_repo_empty(nome));
254 }
255 // The `:repo` value flows verbatim into the caixa-resolver's
256 // `git clone <repo>` subprocess invocation. Until this gate
257 // landed `:repo` was the last untyped `:fonte`-related axis
258 // past the empty arm: a malformed-but-non-empty repo URL
259 // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260 // `":repo "-upload-pack=evil""` leading `-` — the canonical
261 // CLI-argument-injection vector at the `git clone` boundary;
262 // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263 // reads as a relative filesystem path rather than the
264 // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265 // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266 // silently passed validate and the failure surfaced at
267 // lacre-resolve time with a porcelain-quoting-confused error
268 // far from the source caixa.lisp. The lifted predicate makes
269 // the git-porcelain-URL intersection-floor a substrate-level
270 // invariant at validate time, peer with the three pin axes
271 // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272 // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273 // — every `:fonte (:tipo git …)` past validate is now
274 // structurally accept-shaped on every axis the resolver
275 // consumes (the `:repo` URL the `git clone` invokes against,
276 // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277 // accepts, the `:rev` commit OID the lacre's content-
278 // addressing equality probe resolves), closing the
279 // `:fonte` slot's value-shape trajectory end-to-end.
280 if let Err(reason) = crate::render::is_git_repo_url(repo) {
281 return Err(DepError::fonte_repo_shape(nome, repo, reason));
282 }
283 let pins: [(&'static str, Option<&String>); 3] = [
284 (":tag", tag.as_ref()),
285 (":rev", rev.as_ref()),
286 (":branch", branch.as_ref()),
287 ];
288 let set: Vec<&'static str> =
289 pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290 match set.len() {
291 0 => {
292 return Err(DepError::fonte_pin_missing(nome));
293 }
294 1 => {
295 for (pin, value) in pins {
296 if value.is_some_and(String::is_empty) {
297 return Err(DepError::fonte_pin_empty(nome, pin));
298 }
299 }
300 }
301 _ => {
302 return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303 }
304 }
305 // Per-pin value-shape gate. The refname-shaped axes
306 // (`:tag` + `:branch`) route through
307 // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308 // `:rev` axis routes through
309 // [`crate::render::is_git_oid`]. The two predicates
310 // partition the `:fonte` pin axes structurally — refname
311 // vs. hex commit — so a cross-axis mis-slot (the
312 // canonical "I conflated `:rev` and `:branch`" footgun:
313 // `:rev "main"` defeating the reproducibility contract,
314 // `:tag "deadbeef…"` mis-slotting a SHA into the
315 // refname-shaped axis) lands at the offending axis's
316 // predicate, not at lacre-resolve `git fetch` /
317 // `git checkout` time. Their valid sets intersect at
318 // the empty set: every refname is rejected by
319 // `is_git_oid`, every OID is rejected by
320 // `is_git_ref_name`, structurally.
321 //
322 // Until this gate landed `:tag` / `:branch` were the
323 // refname-shaped axes still untyped past the empty-pin
324 // arm: a malformed-but-non-empty refname
325 // (`:tag "v0.1.0 "` trailing space — the canonical
326 // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327 // with git's atomic-rename guard suffix; `:tag "../escape"`
328 // path-traversal via consecutive dots; `:branch "main "`
329 // trailing space; `:branch "feature/foo bar"` embedded
330 // space; `:branch "@"` the literal HEAD alias;
331 // `:branch "refs/heads/main"` the fully-qualified ref
332 // copied from `git show-ref` output that resolves to
333 // a literal ref named `refs/heads/refs/heads/main` on
334 // disk) silently passed validate; the `:rev` axis was
335 // the last `:fonte`-related axis still untyped past the
336 // empty-pin arm: a malformed-but-non-empty hex-OID
337 // (`:rev "main"` conflating with `:branch` — the
338 // reproducibility-contract leak; `:rev "v0.1.0"`
339 // conflating with `:tag` — the same mis-slot on the
340 // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341 // 6-char prefix that's ambiguous across repo history;
342 // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343 // inconsistently against `git rev-parse HEAD`'s
344 // lowercase emission) silently passed validate and the
345 // failure surfaced at lacre-resolve `git fetch` /
346 // `git checkout` time with a quoting-confused error
347 // far from the source caixa.lisp, with no field naming
348 // which `:deps` entry carried the typo. Lifting both
349 // gates to caixa-build time matches the value-shape
350 // trajectory the peer typed axes already follow
351 // (c4213a4 typed WitContract endpoint/subject/slot;
352 // eb3456d :entrada :paths; c7d05ec :entrada :host;
353 // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354 // 63e18a0 :contratos :subject; 2f4316e :contratos
355 // :slot; e70d213 :fonte :tag + :branch) — the typed
356 // slot's valid set matches its downstream consumer's
357 // accepted set (here, the git porcelain's refname /
358 // commit-OID grammars at `git fetch` / `git checkout`
359 // time), structurally. Same diagnostic shape every
360 // per-axis value-shape lift already exposes
361 // (`*Invalid { axis, reason }`); the `value:` field
362 // carries the offending refname / OID verbatim so the
363 // author can grep their caixa.lisp for the
364 // `:tag "<value>"` / `:branch "<value>"` /
365 // `:rev "<value>"` literal and fix it in one edit.
366 for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367 if let Some(v) = value
368 && let Err(reason) = crate::render::is_git_ref_name(v)
369 {
370 return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371 }
372 }
373 if let Some(v) = rev.as_ref()
374 && let Err(reason) = crate::render::is_git_oid(v)
375 {
376 return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377 }
378 Ok(())
379 }
380 Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381 }
382 }
383
384 /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385 /// `:caminho` axis. Walks the leading-byte cascade closed by the
386 /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387 /// orthogonal embedded-control-byte arm (d624c8d) covering
388 /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389 /// embedded-`\` Windows-path-separator arm closing the
390 /// cross-host-OS-separator divergence vector on the same
391 /// THEORY.md §V.2 render-determinism axis.
392 ///
393 /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394 /// per-arm cascade now spans nine diagnostic shapes — every new
395 /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396 /// a future glob-metachar `*` / `?` arm) lands here rather than
397 /// re-inflating `Self::validate`. The
398 /// function stays a thin per-arm linear walk for one reason: each
399 /// arm's diagnostic carries a distinct typed [`DepError`] variant
400 /// rather than a parser-shaped `reason` string, so collapsing the
401 /// cascade onto a generic [`crate::render`] predicate would regress
402 /// the per-arm self-locating diagnostic that `feira lint` consumers
403 /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404 /// [`crate::render::is_git_repo_url`], etc.) lives on the
405 /// reason-string-shaped axes; the `:caminho` axis keeps its
406 /// per-arm variant shape.
407 #[allow(
408 clippy::too_many_lines,
409 reason = "the per-arm cascade is structurally flat by design — every \
410 `:caminho` arm carries its own typed [`DepError`] variant + \
411 per-arm Why comment, so collapsing the cascade onto a generic \
412 [`crate::render`] predicate would regress the per-arm self-locating \
413 diagnostic the `feira lint` consumer surface depends on"
414 )]
415 fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416 if caminho.is_empty() {
417 return Err(DepError::fonte_caminho_empty(nome));
418 }
419 // Reproducibility gate on the `:fonte (:tipo path …)`
420 // `:caminho` axis. The lacre pipeline embeds the value
421 // verbatim in its per-dep content-address
422 // (`conteudo: format!("path:{caminho}")`,
423 // caixa-resolver/src/resolve.rs:189) and that string
424 // folds into the BLAKE3 closure the lacre keys every
425 // downstream consumer (the substrate's reproducibility
426 // contract, CAIXA-SDLC §III.2 — the lacre is the
427 // build's content-addressed identity, peer of the Nix
428 // store path) against. Until this gate landed an
429 // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430 // canonical "I dragged the folder out of Finder into
431 // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432 // the macOS path-layout peer; the
433 // `${WORKSPACE}/caixa-teia` shell-expanded literal
434 // pasted from a CI manifest) silently passed validate
435 // and the failure surfaced *as a successful build with
436 // a divergent lacre*: the BLAKE3 closure on Alice's
437 // workstation differed from the closure on Bob's
438 // workstation, two CI runners with different
439 // `${HOME}` layouts emitted two distinct
440 // content-addresses for the byte-identical caixa, and
441 // the substrate's "the lacre is the build's identity"
442 // contract silently broke far from the source
443 // caixa.lisp — the most insidious failure mode the
444 // typed slot can carry (no error surfaces; the
445 // divergence is invisible until two machines compare
446 // lacres). The same THEORY.md §V.2 render-determinism
447 // discipline `is_sandboxed_relative_path` already
448 // applies on the M2 typed path-slots
449 // (`:behavior :on-*`, `:upgrade-from :state-change
450 // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451 // narrowed to the absolute-vs-relative axis only:
452 // `:fonte :caminho`'s canonical author-surface form is
453 // the `..`-traversing sibling-workspace path
454 // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455 // full `is_sandboxed_relative_path` lift would
456 // structurally reject every legitimate path-fonte
457 // dep. The narrower
458 // `std::path::Path::is_absolute` cut admits the
459 // sibling-workspace form while still rejecting the
460 // host-layout-leaking absolute shape — the
461 // reproducibility contract bites at exactly the
462 // absolute boundary, and that's the axis the
463 // substrate-level invariant is meant to hold. Same
464 // diagnostic shape every per-axis value-shape lift on
465 // the surrounding [`DepError::Fonte*`] cluster carries
466 // (the offending `:nome` + offending `:caminho`
467 // quoted verbatim so the author can grep their
468 // caixa.lisp for the `:caminho "<value>"` literal and
469 // fix it in one edit). The empty arm strictly
470 // precedes this arm so the blank-string footgun
471 // surfaces the more self-locating
472 // `FonteCaminhoEmpty` diagnostic (the empty string
473 // is not absolute under `Path::new("").is_absolute()`
474 // so the precedence is a no-op at value level — the
475 // pin matters only at the diagnostic-shape level if
476 // a future codec round-trip ever produces an empty
477 // string that probes as absolute).
478 if std::path::Path::new(caminho).is_absolute() {
479 return Err(DepError::fonte_caminho_absolute(nome, caminho));
480 }
481 // Reproducibility gate's tilde-expansion arm. The b94fd83
482 // `FonteCaminhoAbsolute` closes the leading-`/`
483 // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484 // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485 // doc footgun) silently passed both the empty arm and
486 // the absolute arm because `Path::new("~").is_absolute()`
487 // returns `false` — `~` is a shell-expansion convention,
488 // not a POSIX path component, so `std::path::Path` treats
489 // it as a literal directory-name segment. The lacre
490 // pipeline then embedded the value verbatim
491 // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492 // failure mode forked per consumer:
493 //
494 // - The caixa-resolver's `Path` arm folds `:caminho`
495 // through `Path::new(caminho).join(<file>)` without
496 // `~`-expansion, so the build looked for a literal
497 // `./~/work/caixa-teia` subdirectory and failed at
498 // resolve time with a `No such file or directory`
499 // error far from the source caixa.lisp (the lacre
500 // itself, though, was already byte-identical across
501 // machines — every machine emitted the same
502 // `path:~/work/caixa-teia` content-address).
503 // - A future caixa-resolver pass that *does* expand `~`
504 // (the canonical shell-convention idiom every
505 // resolver eventually reaches for once an author
506 // reports the literal-`~`-directory bug) would re-
507 // introduce the host-layout-leak the b94fd83 absolute
508 // gate closes: Alice's `~` expands to `/home/alice`,
509 // Bob's to `/home/bob`, two CI runners with different
510 // `$HOME` layouts resolve to two distinct paths for
511 // the byte-identical caixa, and the substrate's
512 // "the lacre is the build's identity" contract
513 // silently breaks far from the source caixa.lisp.
514 //
515 // Closing the gate at `DepSource::validate` (here at the
516 // canonical caixa-build-time boundary, peer with the
517 // absolute arm above) refuses both failure modes
518 // structurally: the typed accepted set excludes every
519 // `~`-prefixed authoring shape, so the resolver is
520 // free to grow `~`-expansion (or any other convention-
521 // expansion the substrate adopts) without re-opening
522 // the host-layout-leak at the typed boundary. Same
523 // diagnostic shape every per-axis value-shape gate on
524 // the surrounding [`DepError::Fonte*`] cluster carries
525 // (the offending `:nome` + offending `:caminho` quoted
526 // verbatim so the author can grep their caixa.lisp for
527 // the `:caminho "<value>"` literal and fix it in one
528 // edit).
529 //
530 // The cascade preserves narrower-diagnostic-first
531 // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532 // → `FonteCaminhoTildeExpansion`. The empty arm
533 // structurally precedes both (the bytes "" / "~" don't
534 // overlap), and the absolute arm structurally precedes
535 // the tilde arm (an absolute path can't start with `~`
536 // since absolute paths start with `/`; the bytes "/" /
537 // "~" don't overlap either). Both arms are
538 // value-disjoint, so the precedence is a no-op at value
539 // level — the pin matters only at the diagnostic-shape
540 // level if a future codec round-trip ever produces a
541 // value that probes as both absolute and tilde-prefixed.
542 if caminho.starts_with('~') {
543 return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544 }
545 // Reproducibility gate's shell-variable-expansion arm.
546 // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547 // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548 // closes the leading-`~` shell-home-expansion shape; the
549 // leading-`$` is the sibling shell-variable-expansion shape
550 // — same host-layout-leaking semantic, different syntactic
551 // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552 // canonical paste-from-`echo $HOME`-doc footgun) and the
553 // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554 // the canonical paste-from-CI-manifest footgun every
555 // GitHub Actions / GitLab CI / Drone manifest carries)
556 // silently passed every prior arm because
557 // `Path::is_absolute` returns false on `$` (the `$` is a
558 // shell convention, not a POSIX path component, so
559 // `std::path::Path` treats it as a literal directory-name
560 // segment) and the tilde arm's `starts_with('~')` doesn't
561 // fire.
562 //
563 // Same per-consumer failure-fork the tilde arm closes:
564 //
565 // - The caixa-resolver's `Path` arm folds `:caminho`
566 // through `Path::new(caminho).join(<file>)` without
567 // `$`-expansion, so the build looks for a literal
568 // `./$HOME/work/caixa-teia` subdirectory and fails at
569 // resolve time with a `No such file or directory`
570 // error far from the source caixa.lisp.
571 // - A future caixa-resolver pass that *does* expand
572 // `$VAR` (the shell-convention idiom every resolver
573 // eventually reaches for once an author reports the
574 // literal-`$HOME`-directory bug, especially for CI's
575 // `${WORKSPACE}` idiom) would re-introduce the host-
576 // layout-leak the b94fd83 absolute gate closes:
577 // Alice's `$HOME` expands to `/home/alice`, Bob's to
578 // `/home/bob`, two CI runners with different
579 // `${WORKSPACE}` layouts resolve to two distinct
580 // paths for the byte-identical caixa, and the
581 // substrate's "the lacre is the build's identity"
582 // contract silently breaks far from the source
583 // caixa.lisp.
584 //
585 // Closing the gate at `DepSource::validate` (here at the
586 // canonical caixa-build-time boundary, peer with the
587 // absolute + tilde arms above) refuses both failure modes
588 // structurally. Same diagnostic shape every per-axis
589 // value-shape gate on the surrounding [`DepError::Fonte*`]
590 // cluster carries (the offending `:nome` + offending
591 // `:caminho` quoted verbatim).
592 //
593 // The cascade preserves narrower-diagnostic-first ordering:
594 // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595 // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596 // The empty arm structurally precedes all three subsequent
597 // arms; the absolute arm structurally precedes both the
598 // tilde and the var arms (absolute paths start with `/`,
599 // the bytes `/` / `~` / `$` don't overlap at the leading
600 // position); the tilde arm structurally precedes the var
601 // arm (`~` and `$` don't overlap at the leading position).
602 // Every pair is value-disjoint, so the precedence is a
603 // no-op at value level — the pin matters only at the
604 // diagnostic-shape level if a future codec round-trip ever
605 // produces a probe-as-both value.
606 //
607 // The gate covers every leading-`$` shape: the canonical
608 // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609 // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610 // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611 // GitHub Actions / GitLab CI / Drone paste footgun), the
612 // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613 // (degenerate "I meant `$HOME` and forgot the rest"). All
614 // shapes route through the same `caminho.starts_with('$')`
615 // byte check.
616 if caminho.starts_with('$') {
617 return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618 }
619 // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620 // f4efe9c arms closed the leading-byte host-layout-leak shapes
621 // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622 // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623 // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624 // *except* the ASCII space byte `0x20`). The bare ASCII space at
625 // the leading position is the orthogonal paste-from-aligned-doc
626 // shape that silently passed every prior arm: `Path::is_absolute`
627 // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628 // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629 // the value's last byte is not `/`, so the canonical
630 // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631 // form in a multi-entry `:deps` block sits at the same column —
632 // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633 // it from the rendered alignment into a fresh entry preserves the
634 // leading whitespace verbatim) silently rendered as a path with
635 // a leading-space directory component the resolver folds through
636 // `Path::join` looking for a literal `./ ../caixa-teia`
637 // subdirectory that fails at resolve time with a non-self-
638 // locating `No such file or directory` error.
639 //
640 // The lacre pipeline's reproducibility contract bites
641 // strictly at this byte: `path:" ../caixa-teia"` and
642 // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643 // (`conteudo: format!("path:{caminho}")`,
644 // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645 // semantic-identical caixa, and the substrate's "the lacre is
646 // the build's identity" contract (CAIXA-SDLC §III.2) silently
647 // breaks across two workstations whose authors differ only in
648 // paste-from-aligned-doc whitespace habits — the most insidious
649 // failure mode the typed slot can carry (no error surfaces; the
650 // divergence is invisible until two machines compare lacres).
651 //
652 // The arm fires AFTER the absolute / tilde / var leading-byte
653 // arms (each names the more self-locating shell-convention
654 // diagnostic on values that probe as that arm's leading-byte
655 // sentinel followed by a leading space — e.g.
656 // `:caminho "/ /foo"` surfaces `FonteCaminhoAbsolute` because
657 // the leading byte is `/`, not space) and BEFORE the
658 // embedded-control-byte arm (a leading-space value with an
659 // embedded control byte surfaces the broader leading-space
660 // diagnostic because the cascade walks leading-byte arms first
661 // — peer with how `FonteCaminhoAbsolute` precedes
662 // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663 //
664 // The peer single-token-shaped axes already reject leading
665 // whitespace on the same paste-from-aligned-doc contract:
666 // [`crate::render::is_git_repo_url`] rejects leading whitespace
667 // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668 // leading whitespace on `:fonte :tag`/`:branch`,
669 // [`crate::render::is_chart_description_shape`] rejects leading
670 // whitespace on `:descricao`,
671 // [`crate::render::is_spdx_expression_shape`] rejects leading
672 // whitespace on `:licenca`. Closing the same byte on
673 // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674 // space anywhere in a typed string slot" invariant structurally
675 // consistent across every value-shape-gated typed surface (the
676 // `:caminho` axis was the last typed string surface still
677 // admitting a leading space byte).
678 if caminho.starts_with(' ') {
679 return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680 }
681 // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682 // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683 // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684 // this arm closes the orthogonal leading-`-` axis on the same
685 // subprocess-argument-boundary the peer `is_git_repo_url` arm
686 // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687 // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688 // `:fonte :tag` / `:branch`) already reject.
689 //
690 // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691 // content-address (`conteudo: format!("path:{caminho}")`,
692 // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693 // value through `Path::join` looking for a literal `./{caminho}`
694 // subdirectory. Every downstream subprocess that consumes the
695 // resolved path — a `git -C {caminho} <verb>` invocation, a
696 // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697 // future operator-side `nix build --path {caminho}` spawn, an
698 // `xargs` / `find {caminho}` / `stat {caminho}` /
699 // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700 // as a CLI flag rather than a positional path when the
701 // subprocess invocation does not carry a `--` argument-list
702 // terminator between the flag block and the path argument. The
703 // canonical footguns:
704 //
705 // - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706 // `find -rf` reinterpretation; the byte the peer
707 // `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708 // example paste-idiom carries as its first token).
709 // - `:caminho "-C"` — `git -C` config-injection paste
710 // (`git -C -C` reinterprets the second `-C` as another
711 // `--change-directory` flag rather than the path
712 // argument; the canonical `git -C <path>` porcelain
713 // idiom every multi-repo workspace tool carries).
714 // - `:caminho "--upload-pack=cat /etc/passwd"` — the
715 // canonical long-flag CLI-arg-injection vector at every
716 // git porcelain entry point (`git clone`, `git fetch`,
717 // `git ls-remote`) that consumes a path or URL
718 // argument; peer with `is_git_repo_url`'s leading-`-`
719 // arm (render.rs:2037) on the sibling `:fonte :repo`
720 // axis, which the arm's diagnostic explicitly cites.
721 // - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722 // override paste-idiom (paste-from-`git -c foo=bar`
723 // shell-history footgun that reinterprets the value as
724 // a `[foo] bar` config injection on every git porcelain
725 // entry point).
726 //
727 // POSIX `std::path::Path` treats a leading `-` as a literal
728 // filename byte, so the resolver folds `-rf` through `Path::join`
729 // and looks for a literal `./-rf` subdirectory — the failure
730 // surfaces at resolve time with a non-self-locating `No such
731 // file or directory` error far from the source caixa.lisp, and
732 // the value rides through the lacre content-address into every
733 // downstream shell-spawned subprocess. On any consumer that
734 // shells out without the `--` terminator (the common case at
735 // every porcelain entry-point) the reinterpretation is silent
736 // and the failure mode is arbitrary-argument-injection.
737 //
738 // The arm fires AFTER the absolute / tilde / var / leading-space
739 // leading-byte arms (each names the more self-locating shell-
740 // convention diagnostic on values that probe as that arm's
741 // leading-byte sentinel — the byte sets are pairwise disjoint at
742 // the leading position, so the precedence pin is a no-op at
743 // value level, but the ordering keeps every leading-byte arm's
744 // diagnostic-shape stable) and BEFORE the embedded-control-byte
745 // arm (a leading-`-` value with an embedded control byte
746 // surfaces the narrower leading-`-` diagnostic because the
747 // cascade walks leading-byte arms first — peer with how
748 // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749 // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750 // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751 //
752 // The peer single-token-shaped axes already reject leading `-`
753 // on the same CLI-arg-injection contract:
754 // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755 // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756 // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757 // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758 // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759 // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760 // [`crate::render::is_cargo_feature_name`] rejects it on
761 // `:caracteristicas`, and the feira `init` / `add <nome>`
762 // positional gate (868c191) rejects it on the CLI positional
763 // itself. Closing the same byte on `:fonte :caminho` makes the
764 // substrate-wide "no leading `-` anywhere in a typed single-
765 // token string slot routed through a subprocess argument"
766 // invariant structurally consistent across every value-shape-
767 // gated typed surface (the `:caminho` axis was the last typed
768 // string surface still admitting a leading `-` byte).
769 if caminho.starts_with('-') {
770 return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771 }
772 // Reproducibility gate's embedded-control-byte arm. The
773 // b94fd83 + a5c248e + f4efe9c arms closed the three
774 // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775 // this arm closes the orthogonal embedded-control-byte
776 // axis — any ASCII control byte (`0x00..=0x1F` plus
777 // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778 // shape every peer single-token-typed-slot value-shape
779 // predicate the surrounding [`crate::render`] cluster
780 // gates against (the lifted `is_git_repo_url` arm on
781 // `:fonte :repo`, the `is_git_ref_name` arm on
782 // `:tag`/`:branch`, the `is_chart_description_shape` /
783 // `is_chart_maintainer_name_shape` /
784 // `is_chart_keyword_shape` arms on the
785 // Helm-chart-shaped axes); now consistent on the
786 // `:caminho` axis too.
787 //
788 // Until this gate landed any embedded control byte
789 // silently passed validate, the lacre pipeline embedded
790 // the value verbatim in its per-dep content-address
791 // (`conteudo: format!("path:{caminho}")`,
792 // caixa-resolver/src/resolve.rs:189), and the failure
793 // forked per byte and per consumer:
794 //
795 // - NUL (`0x00`) the canonical "POSIX paths cannot
796 // contain a NUL byte" shape: every `std::fs` syscall
797 // routes the path through `CString::new`, which
798 // fails with `NulError` on the first NUL byte; the
799 // build would surface a `NulError` at resolve time
800 // far from the source caixa.lisp.
801 // - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802 // multiline-doc footgun: a `:caminho
803 // "../caixa-teia\nrm -rf /"` value (paste landed mid-
804 // `:caminho` block from a multi-line code-fence)
805 // silently round-trips through `Path::join` but the
806 // embedded newline class is a sibling of the CRLF-at-
807 // subprocess-argument injection vector
808 // `is_git_repo_url` already closes on `:repo`.
809 // - Tab (`0x09`) the canonical paste-from-aligned-table
810 // footgun: the tab is invisible in most editors, and
811 // the lacre embeds the value verbatim so two
812 // paste-from-distinct-tables yield divergent lacres
813 // across host editors that strip vs preserve tabs.
814 // - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815 // paste-from-binary-blob shape every peer single-
816 // token-shaped slot rejects under the same
817 // `b < 0x20 || b == 0x7F` predicate.
818 //
819 // Mirrors the cascade discipline every prior `:caminho`
820 // arm establishes: `FonteCaminhoEmpty` →
821 // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822 // → `FonteCaminhoVarExpansion` →
823 // `FonteCaminhoLeadingWhitespace` →
824 // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825 // The six leading-byte arms structurally precede the
826 // embedded-byte arm because the leading-byte shapes are
827 // the more self-locating diagnostic on values that probe
828 // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829 // narrower `FonteCaminhoAbsolute` rather than the broader
830 // embedded-control-byte arm); the precedence pin matters
831 // at the diagnostic-shape level even though the empty /
832 // absolute / tilde / var arms are value-disjoint from a
833 // bare control byte (which would itself be a leading
834 // byte under the empty / absolute / tilde / var arms'
835 // leading-position semantics, but those arms guard the
836 // specific shell-convention characters `/` / `~` / `$`
837 // — a leading `0x01` byte falls through to this arm).
838 for &b in caminho.as_bytes() {
839 if b < 0x20 || b == 0x7F {
840 return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841 }
842 }
843 // Reproducibility gate's Windows-path-separator arm. The four
844 // leading-byte arms (`/` / `~` / `$`) and the embedded-
845 // control-byte arm close the host-layout-leaking + paste-from-
846 // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847 // the orthogonal cross-host-OS-separator shape — same render-
848 // determinism axis, different semantic mechanism. POSIX
849 // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850 // inside a single path component (so `..\caixa-teia` is one
851 // directory named literally `..\caixa-teia`, sibling of `.`
852 // and `..`); Windows [`std::path::Path`] treats `\` as a
853 // primary path separator equal to `/` (so `..\caixa-teia` is
854 // the parent's sibling directory `caixa-teia`). The lacre
855 // pipeline embeds the value verbatim in its per-dep content-
856 // address (`conteudo: format!("path:{caminho}")`, caixa-
857 // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858 // values resolve to two distinct directories across runner
859 // OSes — the same THEORY.md §V.2 render-determinism contract
860 // the absolute / tilde / var arms protect, here against the
861 // cross-host-OS-separator divergence vector. Even on POSIX-
862 // only resolvers (the canonical pleme-io substrate posture),
863 // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864 // PowerShell `Get-Location` paste-idiom footgun) silently
865 // passes every prior arm because `Path::is_absolute` returns
866 // false on `..` and `\` is neither a leading-byte sentinel
867 // nor a control byte, then the resolver folds the value
868 // through `Path::new(caminho).join(<file>)` looking for a
869 // literal `./..\caixa-teia` subdirectory and fails at
870 // resolve time with a non-self-locating `No such file or
871 // directory` error far from the source caixa.lisp.
872 //
873 // The peer single-token-shaped axes on the same git-CLI /
874 // path-CLI consumer cluster already reject `\` under the same
875 // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876 // line 1441 (`"must not contain \\ … the canonical Windows-
877 // path-leak footgun; use / for hierarchical refs"`) gates
878 // `:fonte :tag` / `:fonte :branch` against the same byte,
879 // and [`crate::render::is_gateway_api_http_path`] line 506
880 // includes `\` in the eleven-byte RFC-3986-reserved rejection
881 // set on `:entrada :paths`. Closing the same byte on `:fonte
882 // :caminho` makes the substrate-wide "no Windows path
883 // separator anywhere in a typed string slot" invariant
884 // structurally consistent across every path-shaped typed
885 // surface (the `:caminho` axis was the last typed string
886 // surface still admitting `\`).
887 //
888 // The arm fires AFTER the control-char arm because the
889 // control-char diagnostic is the more self-locating axis on
890 // values that probe as both (`"..\caixa\0teia"` carries both
891 // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892 // rejected byte, so `FonteCaminhoControlChar` wins). Same
893 // narrower-diagnostic-first cascade discipline every prior
894 // arm establishes. A pure-`\` value
895 // (`"..\caixa-teia"` with no control bytes) falls through
896 // every prior arm and lands here.
897 for &b in caminho.as_bytes() {
898 if b == b'\\' {
899 return Err(DepError::fonte_caminho_backslash(nome, caminho));
900 }
901 }
902 // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903 // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904 // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905 // paste-from-shell-prompt footgun class, different syntactic surface.
906 // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907 // single path component (so `../caixa-teia>output` is one directory
908 // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909 // but every interactive shell (bash / zsh / fish / nushell) lexes
910 // `<` / `>` as input / output redirection operators — a `:caminho
911 // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912 // pipeline that wrote build output and forgot to trim the redirect"
913 // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914 // redirection paste idiom) silently passes every prior arm because
915 // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916 // byte sentinels nor control bytes nor `\`, and the value's last byte
917 // isn't `/`. The resolver folds the value through
918 // `Path::new(caminho).join(<file>)` looking for a literal
919 // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920 // with a non-self-locating `No such file or directory` error far
921 // from the source caixa.lisp.
922 //
923 // The lacre pipeline embeds the value verbatim in its per-dep
924 // content-address (`conteudo: format!("path:{caminho}")`,
925 // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926 // the BLAKE3 closure and rides downstream as part of the build's
927 // identity. The bytes carry a second class of hazard the prior
928 // separator-shaped arms don't: every typed-string slot whose value
929 // ever flows verbatim into a shell-spawned subprocess (the caixa-
930 // resolver's `git clone` invocation, a future `feira tofu` shell-
931 // out, a future operator-side `nix flake check` spawn) is the
932 // canonical CRLF-at-subprocess-argument / shell-metachar injection
933 // surface that every peer single-token-shaped typed slot already
934 // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935 // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936 // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937 // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938 // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939 // shell-metachar-injection banner. The `:caminho` axis was the last
940 // typed string surface still admitting these two bytes; this arm
941 // closes the gap so the substrate-wide "no shell-redirection
942 // metacharacter anywhere in a typed string slot" invariant is now
943 // structurally consistent across every path-shaped typed surface.
944 //
945 // The arm fires AFTER the control-char arm + backslash arm because
946 // both prior arms carry more self-locating diagnostics on values
947 // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948 // cross-OS-separator divergence is the load-bearing axis, so the
949 // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950 // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951 // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952 // because the embedded redirection byte is the more semantic-
953 // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954 // but the load-bearing diagnostic is the embedded `<` shell-
955 // redirection — the trailing `/` is the secondary observation, and
956 // an author who removes the `<` is likely to also tab-strip the
957 // trailing separator).
958 for &b in caminho.as_bytes() {
959 if b == b'<' || b == b'>' {
960 return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961 }
962 }
963 // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964 // arm closes the `<` / `>` input/output redirection sentinels; `|`
965 // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966 // shell-prompt footgun class, different syntactic surface. POSIX
967 // `std::path::Path` treats `|` as a literal path-component byte (so
968 // `../caixa-teia|tee` is one directory named literally
969 // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970 // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971 // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972 // `ls ../caixa-teia | grep` line out of a shell-history block and
973 // forgot to trim the pipeline tail" footgun) or `:caminho
974 // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975 // circuit OR line" idiom) silently passes every prior arm because
976 // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977 // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978 // value's last byte isn't `/`. The resolver folds the value through
979 // `Path::new(caminho).join(<file>)` looking for a literal
980 // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981 // with a non-self-locating `No such file or directory` error far
982 // from the source caixa.lisp.
983 //
984 // The lacre pipeline embeds the value verbatim in its per-dep
985 // content-address (`conteudo: format!("path:{caminho}")`,
986 // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987 // BLAKE3 closure and rides downstream as part of the build's identity
988 // into every shell-spawned subprocess (the caixa-resolver's `git
989 // clone` invocation, a future `feira tofu` shell-out, a future
990 // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991 // subprocess-argument / shell-metachar injection surface every peer
992 // single-token-shaped typed slot already closes. The peer path-shaped
993 // axis [`crate::render::is_gateway_api_http_path`]
994 // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996 // axis was the last typed path-string surface still admitting this
997 // byte; this arm closes the gap so the substrate-wide "no shell-
998 // composition metacharacter anywhere in a typed string slot that
999 // flows verbatim into a shell-spawned subprocess" invariant extends
1000 // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001 // `:caminho` axis.
1002 //
1003 // The arm fires AFTER the shell-redirection arm because the prior
1004 // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005 // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006 // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007 // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008 // cascade discipline every prior `:caminho` arm establishes). The arm
1009 // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010 // the more semantic-locating axis on probe-as-both values
1011 // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012 // embedded `|` shell-pipe — the trailing `/` is the secondary
1013 // observation, and an author who removes the `|` is likely to also
1014 // tab-strip the trailing separator).
1015 for &b in caminho.as_bytes() {
1016 if b == b'|' {
1017 return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018 }
1019 }
1020 // Reproducibility gate's shell-command-separator arm. The 124106f
1021 // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022 // shell-command-separator sentinel — same paste-from-shell-prompt
1023 // footgun class, different syntactic surface. POSIX `std::path::Path`
1024 // treats `;` as a literal path-component byte (so
1025 // `../caixa-teia;rm -rf /` is one directory named literally
1026 // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027 // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028 // sequential-command terminator that fires the next command
1029 // regardless of the prior command's exit status — a `:caminho
1030 // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031 // one-liner that chained a cleanup tail after the directory name"
1032 // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033 // POSIX `case` arm's `;;` terminator into the middle of a path"
1034 // idiom) silently passes every prior arm because `Path::is_absolute`
1035 // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036 // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037 // byte isn't `/`. The resolver folds the value through
1038 // `Path::new(caminho).join(<file>)` looking for a literal
1039 // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040 // time with a non-self-locating `No such file or directory` error far
1041 // from the source caixa.lisp.
1042 //
1043 // The lacre pipeline embeds the value verbatim in its per-dep
1044 // content-address (`conteudo: format!("path:{caminho}")`,
1045 // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046 // BLAKE3 closure and rides downstream as part of the build's identity
1047 // into every shell-spawned subprocess (the caixa-resolver's `git
1048 // clone` invocation, a future `feira tofu` shell-out, a future
1049 // operator-side `nix flake check` spawn) as the canonical
1050 // shell-metachar injection surface every peer single-token-shaped
1051 // typed slot already closes. The peer path-shaped axis
1052 // [`crate::render::is_gateway_api_http_path`]
1053 // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055 // axis was the last typed path-string surface still admitting this
1056 // byte; this arm closes the gap so the substrate-wide "no shell-
1057 // composition metacharacter anywhere in a typed string slot that
1058 // flows verbatim into a shell-spawned subprocess" invariant extends
1059 // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060 // `:caminho` axis.
1061 //
1062 // The arm fires AFTER the shell-pipe arm because the prior arm's
1063 // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064 // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065 // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066 // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067 // cascade discipline every prior `:caminho` arm establishes). The arm
1068 // fires BEFORE the trailing-`/` arm because the embedded
1069 // command-separator byte is the more semantic-locating axis on
1070 // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071 // load-bearing diagnostic is the embedded `;` shell-command-
1072 // separator — the trailing `/` is the secondary observation, and an
1073 // author who removes the `;` is likely to also tab-strip the trailing
1074 // separator).
1075 for &b in caminho.as_bytes() {
1076 if b == b';' {
1077 return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078 }
1079 }
1080 // Reproducibility gate's shell-background / logical-AND arm. The
1081 // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082 // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083 // — same paste-from-shell-prompt footgun class, different
1084 // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085 // literal path-component byte (so `../caixa-teia & sleep 1` is
1086 // one directory named literally `../caixa-teia & sleep 1`,
1087 // sibling of `.` and `..`), but every interactive shell
1088 // (bash / zsh / fish / nushell) lexes `&` two ways:
1089 //
1090 // - Single `&` as the background-task terminator that detaches
1091 // the prior command into the background and returns control
1092 // to the prompt immediately (the canonical `cmd &` idiom
1093 // every long-running pipeline uses);
1094 // - Double `&&` as the logical-AND list operator that fires
1095 // the next command only if the prior command succeeded (the
1096 // canonical `make && make install` idiom every build script
1097 // carries).
1098 //
1099 // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100 // pasted a `cd path & sleep 1` background-launch into the
1101 // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102 // (the symmetric "I copied a `cd path && make` build chain"
1103 // idiom) silently passes every prior arm because
1104 // `Path::is_absolute` returns false on `..`, `&` is neither a
1105 // leading-byte sentinel nor a control byte nor `\` nor
1106 // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107 // The resolver folds the value through
1108 // `Path::new(caminho).join(<file>)` looking for a literal
1109 // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110 // time with a non-self-locating `No such file or directory`
1111 // error far from the source caixa.lisp.
1112 //
1113 // The lacre pipeline embeds the value verbatim in its per-dep
1114 // content-address (`conteudo: format!("path:{caminho}")`,
1115 // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116 // the BLAKE3 closure and rides downstream as part of the build's
1117 // identity into every shell-spawned subprocess (the
1118 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119 // shell-out, a future operator-side `nix flake check` spawn) as
1120 // the canonical shell-metachar injection surface every peer
1121 // single-token-shaped typed slot already closes. The peer
1122 // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123 // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125 // `:caminho` axis was the last typed path-string surface still
1126 // admitting this byte; this arm closes the gap so the
1127 // substrate-wide "no shell-composition metacharacter anywhere
1128 // in a typed string slot that flows verbatim into a
1129 // shell-spawned subprocess" invariant extends from
1130 // shell-command-separator (`;`) to shell-background /
1131 // logical-AND (`&`) on the `:caminho` axis.
1132 //
1133 // The arm fires AFTER the shell-command-separator arm because
1134 // the prior arm's `cmd-a; cmd-b` shape is the more common
1135 // shell-history paste idiom on values that probe as both
1136 // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137 // command-separator-tail paste is the load-bearing root-cause
1138 // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139 // discipline every prior `:caminho` arm establishes). The arm
1140 // fires BEFORE the trailing-`/` arm because the embedded
1141 // background / list-AND byte is the more semantic-locating axis
1142 // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143 // load-bearing diagnostic is the embedded `&` shell-background
1144 // / logical-AND metachar — the trailing `/` is the secondary
1145 // observation, and an author who removes the `&` is likely to
1146 // also tab-strip the trailing separator).
1147 for &b in caminho.as_bytes() {
1148 if b == b'&' {
1149 return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150 }
1151 }
1152 // Reproducibility gate's shell-command-substitution arm. The
1153 // e12e4f3 shell-background / logical-AND arm closes the `&`
1154 // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155 // command-substitution sentinel — every POSIX shell (sh /
1156 // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157 // the canonical legacy wrapper that runs the enclosed command
1158 // and substitutes its standard-output verbatim into the
1159 // surrounding word (a `whoami` wrapped in backticks expands
1160 // to the current user's name; a `cat /etc/passwd` wrapped in
1161 // backticks expands to the file's contents — the canonical
1162 // CWE-78 shell-command-injection vector every shell-side
1163 // hardening guide enumerates first). POSIX
1164 // `std::path::Path` treats backtick as a literal path-
1165 // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166 // is one directory named literally that, sibling of `.` and
1167 // `..`).
1168 //
1169 // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170 // canonical "I pasted a shell one-liner carrying a backticked
1171 // `whoami` command-substitution expansion into the `:caminho`
1172 // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173 // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174 // path` working-directory expansion") silently passes every
1175 // prior arm because `Path::is_absolute` returns false on
1176 // `..`, the backtick byte is neither a leading-byte sentinel
1177 // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178 // modern `$()` form at leading position only; backtick is
1179 // the orthogonal legacy form) nor a control byte nor `\` nor
1180 // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181 // byte isn't `/`. The resolver folds the value through
1182 // `Path::new(caminho).join(<file>)` looking for a literal
1183 // subdirectory whose name embeds the backticked token and
1184 // fails at resolve time with a non-self-locating `No such
1185 // file or directory` error far from the source caixa.lisp.
1186 //
1187 // The lacre pipeline embeds the value verbatim in its per-
1188 // dep content-address (`conteudo: format!("path:{caminho}")`,
1189 // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190 // lands in the BLAKE3 closure and rides downstream as part
1191 // of the build's identity into every shell-spawned
1192 // subprocess (the caixa-resolver's `git clone` invocation, a
1193 // future `feira tofu` shell-out, a future operator-side
1194 // `nix flake check` spawn) as the canonical shell-metachar
1195 // injection surface every peer single-token-shaped typed
1196 // slot already closes. The peer path-shaped axis
1197 // [`crate::render::is_gateway_api_http_path`]
1198 // (caixa-core/src/render.rs:506) rejects backtick as part of
1199 // its eleven-byte RFC-3986-reserved set on `:entrada
1200 // :paths`. The `:caminho` axis was the last typed path-
1201 // string surface still admitting this byte; this arm closes
1202 // the gap so the substrate-wide "no shell-composition
1203 // metacharacter anywhere in a typed string slot that flows
1204 // verbatim into a shell-spawned subprocess" invariant
1205 // extends from shell-background / logical-AND (`&`) to
1206 // shell-command-substitution (backtick) on the `:caminho`
1207 // axis.
1208 //
1209 // The arm fires AFTER the shell-background arm because the
1210 // prior arm's `cmd & sleep` shape is the more common shell-
1211 // history paste idiom on values that probe as both (a
1212 // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213 // both `&` and a backtick — the background-launch tail is
1214 // the load-bearing root-cause edit, so
1215 // `FonteCaminhoShellBackground` wins; same cascade
1216 // discipline every prior `:caminho` arm establishes). The
1217 // arm fires BEFORE the trailing-`/` arm because the
1218 // embedded command-substitution byte is the more semantic-
1219 // locating axis on probe-as-both values (a
1220 // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221 // load-bearing diagnostic is the embedded backtick shell-
1222 // command-substitution metachar — the trailing `/` is the
1223 // secondary observation, and an author who removes the
1224 // backtick is likely to also tab-strip the trailing
1225 // separator).
1226 for &b in caminho.as_bytes() {
1227 if b == b'`' {
1228 return Err(DepError::fonte_caminho_shell_command_substitution(
1229 nome, caminho,
1230 ));
1231 }
1232 }
1233 // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234 // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235 // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236 // paste-from-shell-prompt footgun class, different syntactic surface.
1237 // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238 // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239 // sequence of characters in a path component (including the empty
1240 // sequence), `?` matches exactly one character. POSIX
1241 // `std::path::Path` treats both bytes as literal path-component bytes
1242 // (so `../caixa-teia/*.lisp` is one directory named literally
1243 // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244 //
1245 // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246 // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247 // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248 // `rm foo?` single-char-wildcard removal idiom") silently passes
1249 // every prior arm because `Path::is_absolute` returns false on `..`,
1250 // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251 // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252 // value's last byte isn't `/`. The resolver folds the value through
1253 // `Path::new(caminho).join(<file>)` looking for a literal
1254 // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255 // non-self-locating `No such file or directory` error far from the
1256 // source caixa.lisp.
1257 //
1258 // The lacre pipeline embeds the value verbatim in its per-dep
1259 // content-address (`conteudo: format!("path:{caminho}")`,
1260 // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261 // the BLAKE3 closure and rides downstream as part of the build's
1262 // identity into every shell-spawned subprocess (the caixa-resolver's
1263 // `git clone` invocation, a future `feira tofu` shell-out, a future
1264 // operator-side `nix flake check` spawn) as the canonical
1265 // shell-metachar / pathname-expansion surface every peer
1266 // single-token-shaped typed slot already closes. The peer path-shaped
1267 // axis [`crate::render::is_gateway_api_http_path`]
1268 // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270 // `:caminho` axis was the last typed path-string surface still
1271 // admitting these two bytes; this arm closes the gap so the
1272 // substrate-wide "no shell-composition / glob-expansion
1273 // metacharacter anywhere in a typed string slot that flows verbatim
1274 // into a shell-spawned subprocess" invariant extends from
1275 // shell-command-substitution (backtick) to glob-expansion
1276 // (`*` / `?`) on the `:caminho` axis.
1277 //
1278 // The arm fires AFTER the backtick arm because the prior arm's
1279 // CWE-78 shell-command-injection vector is the load-bearing
1280 // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281 // carries both backtick and `*` — the command-substitution paste
1282 // is the load-bearing root-cause edit, so
1283 // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284 // discipline every prior `:caminho` arm establishes). The arm
1285 // fires BEFORE the trailing-`/` arm because the embedded glob
1286 // byte is the more semantic-locating axis on probe-as-both values
1287 // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288 // embedded `*` glob metachar — the trailing `/` is the secondary
1289 // observation, and an author who removes the `*` is likely to
1290 // also tab-strip the trailing separator).
1291 for &b in caminho.as_bytes() {
1292 if b == b'*' || b == b'?' {
1293 return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294 }
1295 }
1296 // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297 // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298 // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299 // grouping sentinels — same paste-from-shell-prompt footgun class,
1300 // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301 // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302 // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303 // shell with a fresh environment scope (the canonical sandboxing
1304 // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305 // to scope a `cd` to one subshell without disturbing the parent's
1306 // working directory), and `$(<cmd>)` is the modern Bourne
1307 // command-substitution shape the upstream f4efe9c
1308 // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309 // the closing `)` byte completes that substitution shape and must
1310 // be refused on the same axis (peer with the
1311 // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312 // same byte-pair on the sibling `:fonte :repo` axis under the
1313 // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314 // POSIX `std::path::Path` treats both bytes as literal path-
1315 // component bytes (so `../caixa-teia/(date)` is one directory
1316 // named literally `../caixa-teia/(date)`, sibling of `.` and
1317 // `..`).
1318 //
1319 // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320 // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321 // liner whose modern command-substitution expansion lands the
1322 // current date as a subdirectory name" footgun) or `:caminho
1323 // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324 // `(cd foo && pwd)` subshell-grouping working-directory probe
1325 // idiom") silently passes every prior arm because
1326 // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327 // neither leading-byte sentinels nor control bytes nor `\` nor
1328 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329 // and the value's last byte isn't `/`. The resolver folds the
1330 // value through `Path::new(caminho).join(<file>)` looking for a
1331 // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332 // at resolve time with a non-self-locating `No such file or
1333 // directory` error far from the source caixa.lisp.
1334 //
1335 // The lacre pipeline embeds the value verbatim in its per-dep
1336 // content-address (`conteudo: format!("path:{caminho}")`,
1337 // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338 // in the BLAKE3 closure and rides downstream as part of the
1339 // build's identity into every shell-spawned subprocess (the
1340 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341 // shell-out, a future operator-side `nix flake check` spawn) as
1342 // the canonical shell-metachar / subshell-grouping surface every
1343 // peer single-token-shaped typed slot already closes. The peer
1344 // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345 // rejects the same byte pair on `:fonte :repo` under the same
1346 // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347 // `:caminho` axis was the last typed path-string surface still
1348 // admitting these two bytes;
1349 // this arm closes the gap so the substrate-wide "no shell-
1350 // composition metacharacter anywhere in a typed string slot that
1351 // flows verbatim into a shell-spawned subprocess" invariant
1352 // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353 // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354 // leading-`$` arm, the typed `:caminho` accepted set now
1355 // structurally excludes the entire modern Bourne
1356 // command-substitution surface — leading `$` closes the
1357 // leading byte of every `$(<cmd>)` shape, this arm closes the
1358 // trailing `)` boundary.
1359 //
1360 // The arm fires AFTER the shell-glob arm because the prior arm's
1361 // `*` / `?` pathname-expansion shape is the more common shell-
1362 // history paste idiom on values that probe as both
1363 // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364 // glob-paste-tail is the load-bearing root-cause edit, so
1365 // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366 // prior `:caminho` arm establishes). The arm fires BEFORE the
1367 // trailing-`/` arm because the embedded subshell-grouping byte
1368 // is the more semantic-locating axis on probe-as-both values
1369 // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370 // is the embedded `(` shell-subshell-grouping metachar — the
1371 // trailing `/` is the secondary observation, and an author who
1372 // removes the `(` is likely to also tab-strip the trailing
1373 // separator).
1374 for &b in caminho.as_bytes() {
1375 if b == b'(' || b == b')' {
1376 return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377 nome, caminho, b,
1378 ));
1379 }
1380 }
1381 // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382 // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383 // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384 // URI-Template-placeholder byte pair — same paste-from-shell-
1385 // prompt + paste-from-templated-doc footgun class, different
1386 // syntactic surface. Every POSIX-derived shell that implements
1387 // brace expansion (bash / zsh / ksh / fish; the canonical
1388 // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389 // `cp file{,.bak}` idiom every shell-history block carries)
1390 // expands `{a,b,c}` to the cross-product of its comma-separated
1391 // members and `{1..10}` to the integer range; RFC 6570 reserves
1392 // the matched pair for URI Template placeholders (the canonical
1393 // `https://{host}/{org}/{repo}` substitution shape every
1394 // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395 // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396 // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397 // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398 // shape) emit. POSIX `std::path::Path` treats both bytes as
1399 // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400 // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401 // sibling of `.` and `..`).
1402 //
1403 // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404 // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405 // expansion one-liner that fans across two siblings" footgun)
1406 // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407 // a `{{org}}` Mustache / Helm template placeholder out of a
1408 // README quick-start and forgot to substitute") silently passes
1409 // every prior arm because `Path::is_absolute` returns false on
1410 // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411 // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412 // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413 // byte isn't `/`. The resolver folds the value through
1414 // `Path::new(caminho).join(<file>)` looking for a literal
1415 // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416 // at resolve time with a non-self-locating `No such file or
1417 // directory` error far from the source caixa.lisp.
1418 //
1419 // The lacre pipeline embeds the value verbatim in its per-dep
1420 // content-address (`conteudo: format!("path:{caminho}")`,
1421 // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422 // lands in the BLAKE3 closure and rides downstream as part of
1423 // the build's identity into every shell-spawned subprocess
1424 // (the caixa-resolver's `git clone` invocation, a future
1425 // `feira tofu` shell-out, a future operator-side `nix flake
1426 // check` spawn) as the canonical shell-metachar / brace-
1427 // expansion surface every peer single-token-shaped typed
1428 // slot already closes. The peer git-source axis
1429 // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430 // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431 // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432 // shell-brace-expansion banner. The `:caminho` axis was the last
1433 // typed path-string surface still admitting these two bytes;
1434 // this arm closes the gap so the substrate-wide "no shell-
1435 // composition metacharacter anywhere in a typed string slot
1436 // that flows verbatim into a shell-spawned subprocess"
1437 // invariant extends from shell-subshell-grouping (`(` / `)`)
1438 // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439 // and the typed `:caminho` accepted set now also structurally
1440 // excludes the URI Template / templating-engine placeholder
1441 // surface that would silently round-trip through any
1442 // downstream IaC templating-engine layer.
1443 //
1444 // The arm fires AFTER the shell-subshell-grouping arm because
1445 // the prior arm's `(` / `)` shape is the more semantic-locating
1446 // axis on values that probe as both (`"../{cd foo}(date)"`
1447 // carries both `{` and `(` — the parenthesis-pair is the
1448 // load-bearing modern-Bourne-command-substitution surface the
1449 // prior arm closes; same cascade discipline every prior
1450 // `:caminho` arm establishes). The arm fires BEFORE the
1451 // trailing-`/` arm because the embedded brace-expansion byte
1452 // is the more semantic-locating axis on probe-as-both values
1453 // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454 // load-bearing diagnostic is the embedded `{` brace-expansion
1455 // metachar — the trailing `/` is the secondary observation,
1456 // and an author who removes the `{` is likely to also tab-
1457 // strip the trailing separator).
1458 for &b in caminho.as_bytes() {
1459 if b == b'{' || b == b'}' {
1460 return Err(DepError::fonte_caminho_shell_brace_expansion(
1461 nome, caminho, b,
1462 ));
1463 }
1464 }
1465 // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466 // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467 // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468 // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469 // footgun class, different syntactic surface. Every POSIX shell
1470 // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471 // bracket pair as the glob character-class operator: `[abc]`
1472 // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473 // ASCII letter; `[^x]` negates (the canonical
1474 // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475 // lowercase-sibling glob every shell-history block carries —
1476 // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477 // closing the unbounded pathname-expansion sentinels). The
1478 // bracket pair additionally carries the POSIX `test` /
1479 // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480 // the canonical idiom every shell-script conditional uses) and
1481 // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482 // bracket pair is the TOML inline-array delimiter
1483 // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484 // manifest cross-idiom-leak vector), the YAML flow-sequence
1485 // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486 // values.yaml cross-idiom leak), the JSON array delimiter,
1487 // and the POSIX-ERE / PCRE bracket-expression / character-
1488 // class anchor (the canonical paste-from-regex-doc shape).
1489 // POSIX `std::path::Path` treats both bytes as literal path-
1490 // component bytes (so `../[caixa-teia]` is one directory
1491 // named literally `../[caixa-teia]`, sibling of `.` and
1492 // `..`).
1493 //
1494 // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495 // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496 // one-liner that matches every lowercase-sibling-suffix
1497 // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498 // build"` (the symmetric "I pasted a TOML inline-array /
1499 // YAML flow-sequence shape out of an aligned manifest"
1500 // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501 // `*.[ch]` C-source character-class paste-from-shell-history
1502 // shape) silently passes every prior arm because
1503 // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504 // neither leading-byte sentinels nor control bytes nor `\`
1505 // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506 // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507 // last byte isn't `/`. The resolver folds the value through
1508 // `Path::new(caminho).join(<file>)` looking for a literal
1509 // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510 // time with a non-self-locating `No such file or directory`
1511 // error far from the source caixa.lisp.
1512 //
1513 // The lacre pipeline embeds the value verbatim in its per-dep
1514 // content-address (`conteudo: format!("path:{caminho}")`,
1515 // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516 // lands in the BLAKE3 closure and rides downstream as part of
1517 // the build's identity into every shell-spawned subprocess
1518 // (the caixa-resolver's `git clone` invocation, a future
1519 // `feira tofu` shell-out, a future operator-side `nix flake
1520 // check` spawn) as the canonical shell-metachar / glob-
1521 // character-class / TOML-array surface every peer single-
1522 // token-shaped typed slot already closes. The `:caminho` axis
1523 // was the last typed path-string surface still admitting
1524 // these two bytes; this arm closes the gap so the substrate-
1525 // wide "no shell-composition metacharacter anywhere in a
1526 // typed string slot that flows verbatim into a shell-spawned
1527 // subprocess" invariant extends from shell-brace-expansion
1528 // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529 // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530 // the typed `:caminho` accepted set now structurally excludes
1531 // the entire POSIX pathname-expansion / glob surface —
1532 // unbounded glob (`*` / `?`) AND bounded character-class
1533 // (`[abc]` / `[a-z]`).
1534 //
1535 // The arm fires AFTER the shell-brace-expansion arm because
1536 // the prior arm's `{` / `}` shape is the more semantic-
1537 // locating axis on values that probe as both
1538 // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539 // expansion fan is the load-bearing root-cause edit, so
1540 // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541 // discipline every prior `:caminho` arm establishes). The arm
1542 // fires BEFORE the trailing-`/` arm because the embedded
1543 // bracket-expansion byte is the more semantic-locating axis
1544 // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545 // load-bearing diagnostic is the embedded `[` glob-character-
1546 // class metachar — the trailing `/` is the secondary
1547 // observation, and an author who removes the `[` is likely
1548 // to also tab-strip the trailing separator).
1549 for &b in caminho.as_bytes() {
1550 if b == b'[' || b == b']' {
1551 return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552 nome, caminho, b,
1553 ));
1554 }
1555 }
1556 // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557 // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558 // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559 // delimiter pair — same paste-from-shell-prompt footgun class,
1560 // different syntactic surface. Every POSIX shell (sh / bash /
1561 // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562 // string-literal quoting operator: `'…'` is the strong
1563 // (no-expansion) single-quoted string and `"…"` is the weak
1564 // (variable-/command-substitution-preserving) double-quoted
1565 // string — the canonical `cd '../caixa-teia'` shell-history
1566 // idiom every path-with-embedded-whitespace paste block carries,
1567 // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568 // shape. Beyond shell, the two bytes carry the JSON string-literal
1569 // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570 // config cross-idiom-leak vector), the YAML double-quoted +
1571 // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572 // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573 // manifest cross-idiom leak), the TOML basic + literal string
1574 // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575 // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576 // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577 // — the canonical "I copied the entire `:caminho "..."` slot
1578 // rather than just the string body" author-surface footgun),
1579 // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580 // excludes both bytes from the `unreserved / pct-encoded /
1581 // sub-delims / ":" / "@"` `pchar` production. POSIX
1582 // `std::path::Path` treats both bytes as literal path-component
1583 // bytes (so `../"caixa-teia"` is one directory named literally
1584 // `../"caixa-teia"`, sibling of `.` and `..`).
1585 //
1586 // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587 // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588 // quoting preserved the sibling-workspace path verbatim across
1589 // the whitespace paste boundary" footgun), `:caminho
1590 // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591 // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592 // string / paste-from-tatara-lisp string-literal cross-idiom-
1593 // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594 // quote "I pasted a JSON key-value pair fragment into the
1595 // middle of the path" idiom) silently passes every prior arm
1596 // because `Path::is_absolute` returns false on `..` / `'` /
1597 // `"`, `'` / `"` are neither leading-byte sentinels nor
1598 // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599 // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600 // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601 // folds the value through `Path::new(caminho).join(<file>)`
1602 // looking for a literal `./'../caixa-teia'` subdirectory and
1603 // fails at resolve time with a non-self-locating `No such file
1604 // or directory` error far from the source caixa.lisp.
1605 //
1606 // The lacre pipeline embeds the value verbatim in its per-dep
1607 // content-address (`conteudo: format!("path:{caminho}")`,
1608 // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609 // lands in the BLAKE3 closure and rides downstream as part of
1610 // the build's identity into every shell-spawned subprocess
1611 // (the caixa-resolver's `git clone` invocation, a future
1612 // `feira tofu` shell-out, a future operator-side `nix flake
1613 // check` spawn) as the canonical shell-metachar / string-
1614 // literal-delimiter surface every peer single-token-shaped
1615 // typed slot already closes. The peer `:fonte :repo` axis
1616 // closes both bytes under the same shell-quote-grouping /
1617 // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618 // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619 // `:caminho` axis was the last typed path-string surface
1620 // still admitting these two bytes; this arm closes the gap
1621 // so the substrate-wide "no shell-composition metacharacter
1622 // anywhere in a typed string slot that flows verbatim into a
1623 // shell-spawned subprocess" invariant extends from shell-
1624 // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625 // / `"`) on the `:caminho` axis. Together with the peer
1626 // JSON / YAML / TOML string-literal delimiters closing at
1627 // this arm and the 598b770 `{` / `}` brace-expansion arm
1628 // closing the templating-engine-placeholder boundary, the
1629 // typed `:caminho` accepted set now structurally excludes
1630 // the entire cross-config-DSL string-literal / templating
1631 // paste-from-aligned-manifest cross-idiom-leak surface that
1632 // would silently round-trip through any downstream JSON /
1633 // YAML / TOML / HCL / tatara-lisp parsing layer.
1634 //
1635 // The arm fires AFTER the shell-bracket-expansion arm because
1636 // the prior arm's `[` / `]` shape is the more semantic-
1637 // locating axis on values that probe as both (`"../[a-z]'x'"`
1638 // carries both `[` and `'` — the glob-character-class
1639 // expansion is the load-bearing root-cause edit, so
1640 // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641 // discipline every prior `:caminho` arm establishes). The arm
1642 // fires BEFORE the trailing-`/` arm because the embedded
1643 // quote-grouping byte is the more semantic-locating axis on
1644 // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645 // the load-bearing diagnostic is the embedded `'` shell-
1646 // string-literal metachar — the trailing `/` is the secondary
1647 // observation, and an author who removes the `'` is likely to
1648 // also tab-strip the trailing separator).
1649 for &b in caminho.as_bytes() {
1650 if b == b'\'' || b == b'"' {
1651 return Err(DepError::fonte_caminho_shell_quote_grouping(
1652 nome, caminho, b,
1653 ));
1654 }
1655 }
1656 // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657 // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658 // the orthogonal "byte at which four distinct downstream parsers all
1659 // truncate the value at the first occurrence" surface, and no prior arm
1660 // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661 // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662 // of a word (or after unquoted whitespace) as the comment-lead: from
1663 // that byte to the end of the physical line is a comment discarded
1664 // before command parsing (`cd ../caixa-teia # legacy sibling` — the
1665 // canonical paste-from-shell-history-with-trailing-annotation shape
1666 // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667 // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668 // at any position preceded by whitespace or at line-start (`path:
1669 // ../caixa-teia # pin` — the canonical paste-from-values.yaml /
1670 // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671 // treats `;` as the comment-lead but a growing number of consumer
1672 // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673 // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674 // the comment-lead too — the pair extends the cross-config-DSL
1675 // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676 // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677 // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678 // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679 // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680 // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681 // `#` selects a flake output — the same axis the peer
1682 // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683 // surface at a68f818 with the same downstream-drops-the-tail
1684 // rationale).
1685 //
1686 // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687 // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688 // paste-from-shell-history-with-trailing-annotation footgun),
1689 // `:caminho "../caixa-teia # pin"` (the symmetric YAML flow-scalar
1690 // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691 // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692 // silently passes every prior arm because `Path::is_absolute` returns
1693 // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694 // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695 // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696 // and the value's last byte isn't `/`. The resolver folds the value
1697 // through `Path::new(caminho).join(<file>)` looking for a literal
1698 // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699 // resolve time with a non-self-locating `No such file or directory`
1700 // error far from the source caixa.lisp — while every downstream
1701 // shell / YAML / URL parser silently truncates the value at the `#`
1702 // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703 // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704 // an emitted YAML `path:` scalar disagree with the resolver on which
1705 // directory the value names. Two workstations whose downstream
1706 // shell / YAML / URL parsing layers differ in unquoted-`#`
1707 // recognition emit divergent build artifacts for the byte-identical
1708 // caixa.lisp value.
1709 //
1710 // The lacre pipeline embeds the value verbatim in its per-dep
1711 // content-address (`conteudo: format!("path:{caminho}")`,
1712 // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713 // closure and rides downstream as part of the build's identity into
1714 // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715 // invocation, a future `feira tofu` shell-out, a future operator-side
1716 // `nix flake check` spawn) as the canonical shell-metachar /
1717 // comment-lead / URL-fragment-delimiter surface every peer
1718 // single-token-shaped typed slot already closes. The peer `:fonte
1719 // :repo` axis closes the byte under the URL-fragment-identifier
1720 // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721 // the last typed path-string surface still admitting the byte. This
1722 // arm closes the gap so the substrate-wide "no shell-composition
1723 // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724 // typed string slot that flows verbatim into a shell-spawned
1725 // subprocess or downstream YAML / URL parser" invariant extends from
1726 // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727 // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728 // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729 // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730 // templating-engine-placeholder boundary, the typed `:caminho`
1731 // accepted set now structurally excludes the entire
1732 // paste-with-trailing-annotation / paste-from-URL-permalink /
1733 // paste-from-YAML-comment cross-idiom-leak surface that would
1734 // silently round-trip through any downstream shell / YAML / URL /
1735 // dotenv / gitconfig / HCL parsing layer to a different value than
1736 // the resolver's `Path::join` sees.
1737 //
1738 // The arm fires AFTER the shell-quote-grouping arm because the prior
1739 // arm's `'` / `"` shape is the more semantic-locating axis on values
1740 // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741 // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742 // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743 // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744 // trailing-`/` arm because the embedded comment-lead / fragment-
1745 // delimiter byte is the more semantic-locating axis on probe-as-both
1746 // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747 // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748 // observation, and an author who removes the `#pin` fragment is
1749 // likely to also tab-strip the trailing separator).
1750 for &b in caminho.as_bytes() {
1751 if b == b'#' {
1752 return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753 }
1754 }
1755 // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756 // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757 // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758 // byte — the mandatory encoding mechanism for every byte outside the
1759 // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760 // itself must be percent-encoded as `%25` to appear literally inside
1761 // a URL value. The byte carries three distinct render-determinism
1762 // hazards on the `:caminho` axis, no prior arm has covered it, and
1763 // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764 // already closes the same byte under the same URL-percent-encoding
1765 // banner — the `:caminho` axis was the last typed path-string surface
1766 // still admitting the byte.
1767 //
1768 // First, the paste-from-browser-address-bar percent-encoded-space
1769 // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770 // README hyperlink / a browser address bar / a percent-encoded
1771 // permalink expecting `%20` to decode to a literal space at the
1772 // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773 // literal path-component byte, so `Path::join` looks for a literal
1774 // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775 // non-self-locating `No such file or directory` error far from the
1776 // source caixa.lisp — while the author's mental model was
1777 // `../caixa teia`, the decoded shape. Two authors whose only
1778 // difference is percent-encoding presence resolve to two distinct
1779 // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780 // for what they intended as the byte-identical sibling-workspace
1781 // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782 // content-address (`conteudo: format!("path:{caminho}")`,
1783 // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784 // downstream into the BLAKE3 closure and locks the substrate's
1785 // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786 // to the wrong encoding — the same THEORY.md §V.2 render-
1787 // determinism vector every prior `:caminho` arm protects.
1788 //
1789 // Second, the printf-format-specifier lead footgun: `%` is the C /
1790 // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791 // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792 // shell-diagnostic one-liner carries) and the printf builtin is
1793 // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794 // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795 // value flowing into any future `feira` verb that shells out with a
1796 // printf-formatted path template silently gets reinterpreted as a
1797 // format-directive rather than a literal byte — the canonical
1798 // CWE-134 format-string-injection vector.
1799 //
1800 // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801 // ksh reserve `%N` at word-start as the job-control specifier —
1802 // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803 // "the most recent job whose command started with `foo`". A future
1804 // `feira` verb that invokes `kill %1` on a caminho-scoped
1805 // subprocess would silently redirect the signal to a wrong target.
1806 //
1807 // Beyond the three shell-side hazards, `%` is a first-class parser
1808 // byte in three cross-config-DSL layers the substrate's paste-idiom
1809 // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810 // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811 // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812 // YAML directive block silently trips the YAML directive parser on
1813 // any downstream emitted YAML manifest); Prometheus / Grafana
1814 // template syntax uses `%(var)s` as the substitution lead; and Nix
1815 // interpolation uses `${var}` (not `%`) but Envsubst /
1816 // Kubernetes / OpenShift template layers use `%VAR%` as the
1817 // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818 // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819 //
1820 // The three malformed-`%HH` classes documented on the peer
1821 // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822 //
1823 // - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824 // where `%` isn't followed by two hex digits) — every WHATWG-
1825 // conformant URL parser rejects the value at parse time per
1826 // RFC 3986 §2.1, but the byte rides into the lacre before
1827 // the resolver subprocess crosses the URL-parser boundary.
1828 // - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829 // intending the `%2F` as the URL encoding of `/`) locks a
1830 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831 // the byte-identical `path:../caixa/teia` form.
1832 // - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833 // already itself an encoded `%`, so the intent was likely a
1834 // literal `%20` that survived one round-trip through a
1835 // URL-encoder that shouldn't have run) locks a triply-
1836 // divergent closure across the encoded / once-decoded /
1837 // twice-decoded chain.
1838 //
1839 // POSIX `std::path::Path` treats the byte as a literal path-
1840 // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841 // paste-from-browser-address-bar percent-encoded-space footgun),
1842 // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843 // directive-block cross-idiom leak), or `:caminho
1844 // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845 // shell-diagnostic-one-liner shape) silently passes every prior arm
1846 // because `Path::is_absolute` returns false on `..`, `%` is neither
1847 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850 // value's last byte isn't `/`. The resolver folds the value through
1851 // `Path::new(caminho).join(<file>)` looking for a literal
1852 // subdirectory named `../caixa%20teia` and fails at resolve time
1853 // with a non-self-locating `No such file or directory` error far
1854 // from the source caixa.lisp — while every downstream URL parser /
1855 // shell printf builtin / YAML directive parser silently
1856 // reinterprets the byte to a different value than the resolver's
1857 // `Path::join` sees. Two workstations whose downstream URL / shell
1858 // / YAML layers differ in `%HH` recognition emit divergent build
1859 // artifacts for the byte-identical caixa.lisp value.
1860 //
1861 // The lacre pipeline embeds the value verbatim in its per-dep
1862 // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863 // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864 // closure and rides into every shell-spawned subprocess (the
1865 // resolver's `git clone`, a future `feira tofu` shell-out, a
1866 // future operator-side `nix flake check` spawn) as the canonical
1867 // URL-percent-encoding-escape / printf-format-specifier / bash-
1868 // job-control-specifier surface every peer single-token-shaped
1869 // typed slot already closes. This arm closes the gap so the
1870 // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871 // specifier / job-control-specifier / YAML-directive-lead byte
1872 // anywhere in a typed string slot that flows verbatim into a
1873 // shell-spawned subprocess or downstream URL / printf / YAML
1874 // parser" invariant extends from shell-comment / URL-fragment
1875 // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876 // `:caminho` axis.
1877 //
1878 // The arm fires AFTER the shell-comment arm because the prior
1879 // arm's `#` shape is the more semantic-locating axis on values
1880 // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881 // and `#` — the URL-fragment-identifier is the load-bearing
1882 // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883 // same cascade discipline every prior `:caminho` arm establishes).
1884 // The arm fires BEFORE the trailing-`/` arm because the embedded
1885 // percent-encoding-escape byte is the more semantic-locating axis
1886 // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887 // the load-bearing diagnostic is the embedded `%` percent-
1888 // encoding-escape — the trailing `/` is the secondary observation,
1889 // and an author who decodes the `%20` to a literal space is
1890 // likely to also tab-strip the trailing separator).
1891 for &b in caminho.as_bytes() {
1892 if b == b'%' {
1893 return Err(DepError::fonte_caminho_url_percent_encoding(
1894 nome, caminho, b,
1895 ));
1896 }
1897 }
1898 // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899 // command-substitution / arithmetic-expansion arm. The f4efe9c
1900 // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901 // through `FonteCaminhoVarExpansion` under the leading-byte-
1902 // sentinel host-layout-leak banner (peer with the b94fd83
1903 // absolute / a5c248e tilde leading-byte arms), but the arm
1904 // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905 // (embedded `$HOME` in a nested path segment — the canonical
1906 // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907 // an author copies a partially-substituted shell one-liner and
1908 // the leading segment is a literal `../foo` while the mid
1909 // segment carries the un-substituted `$HOME` template), a
1910 // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911 // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912 // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913 // (the paste-from-shell-prompt command-substitution idiom), or
1914 // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915 // idiom) silently passes every prior arm because
1916 // `Path::is_absolute` returns false on `..`, `$` is neither a
1917 // leading-byte sentinel (the f4efe9c arm fires only at position
1918 // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919 // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920 // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921 // value's last byte isn't `/`. Note that `$(...)` command-
1922 // substitution and `$((...))` arithmetic-expansion each carry
1923 // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924 // arm catches structurally at the earlier `(` position — but
1925 // an author who reaches for the sh-brace-substitution
1926 // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927 // which no prior arm covers. This arm closes the last
1928 // positional gap on the `$` byte on the `:caminho` axis so
1929 // every position — leading (`FonteCaminhoVarExpansion`) and
1930 // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931 // structurally rejected.
1932 //
1933 // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934 // ash / fish / nushell) lexes `$` as the variable-expansion /
1935 // command-substitution / arithmetic-expansion operator per
1936 // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937 // Expansion) expands a named variable, `${<name>}` (Parameter
1938 // Expansion braced form) does the same with an explicit token
1939 // boundary, `$(<cmd>)` (Command Substitution modern form,
1940 // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941 // already closes) runs a subshell and substitutes its stdout,
1942 // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943 // arithmetic expression. Every form is a host-layout /
1944 // environment-state / shell-subprocess-side-effect leak when
1945 // the byte lands in a value the resolver passes to a shell-
1946 // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947 // the Nix `${var}` string-interpolation lead (the paste-from-
1948 // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949 // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950 // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951 // variable lead (the paste-from-`Makefile` shape), the
1952 // JavaScript / TypeScript template-literal `${expr}` interp
1953 // lead (the paste-from-JS-template-string idiom in a
1954 // multi-lang-monorepo where a `path` attribute gets copied out
1955 // of a `package.json` script or a Vite config), the envsubst /
1956 // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957 // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958 // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959 // from-`.php`-config footgun), the Perl scalar-variable lead
1960 // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961 // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962 // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963 // cross-idiom paste-footgun surface is broader than any single
1964 // shell layer — `$` is a first-class parser byte in nearly
1965 // every config / templating / build-system DSL the substrate's
1966 // paste-idiom surface routinely crosses. The peer `:fonte
1967 // :repo` axis closes the byte under the shell-variable-
1968 // expansion / URL-sub-delim banner (b9d187c `$` on
1969 // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970 // axes close `$` as part of `is_git_ref_name`'s printable-
1971 // ASCII-restricted grammar (`git check-ref-format` rejects the
1972 // byte outright), and the peer `:entrada :paths` axis closes
1973 // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974 // reserved set. The `:caminho` axis was the last typed path-
1975 // string surface still admitting `$` at positions other than 0.
1976 //
1977 // POSIX `std::path::Path` treats `$` as a literal path-
1978 // component byte, so `:caminho "../foo$HOME/bar"` silently
1979 // routes through `Path::new(caminho).join(<file>)` looking for
1980 // a literal `./{caminho}` subdirectory that fails at resolve
1981 // time with a non-self-locating `No such file or directory`
1982 // error far from the source caixa.lisp. But every downstream
1983 // shell / envsubst / Nix / Make / K8s-template parser silently
1984 // reinterprets the byte to a different value than the
1985 // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986 // to a `cd '{caminho}'` command line, a `nix flake check`
1987 // invocation on an emitted YAML `path:` scalar folded through
1988 // envsubst, or a `helm template` invocation with a
1989 // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990 // template all disagree with the resolver on which directory
1991 // the value names. Two workstations whose downstream shell /
1992 // envsubst / Nix / Make / K8s-template parsing layers differ
1993 // in `$VAR` recognition (or, worse, expand the byte against
1994 // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995 // `$HOME=/home/bob`) emit divergent build artifacts for the
1996 // byte-identical caixa.lisp value. Even in the case where the
1997 // resolver strictly does NOT expand `$VAR` (the current
1998 // implementation) the divergence still bites at the lacre-
1999 // identity axis: the lacre pipeline embeds the value verbatim
2000 // in its per-dep content-address (`conteudo:
2001 // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002 // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003 // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004 // one author would have produced by substituting the literal
2005 // value at author time, defeating the THEORY.md §V.2 render-
2006 // determinism contract on the same axis every prior `:caminho`
2007 // arm protects.
2008 //
2009 // Beyond the render-determinism / host-layout-leak vectors,
2010 // `$` at any position in a value flowing verbatim into a
2011 // shell-spawned subprocess is the canonical CWE-78 shell-
2012 // command-injection surface every peer single-token-shaped
2013 // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014 // that rides into a future `feira tofu` shell-out as `cd
2015 // '../foo$(whoami)/bar'` gets substituted by the shell at
2016 // subprocess-argument-expansion time even inside single quotes
2017 // in fewer positions than one might expect (the substitution
2018 // fires only outside single-quoting per POSIX §2.2.2, but
2019 // eval-style wrappers and `sh -c` layers that route the value
2020 // through re-parsing round-trip the substitution — the same
2021 // vector the c370458 backtick arm closes at the sibling
2022 // command-substitution-legacy-form surface). Every future
2023 // `feira` verb that shells out with a `caminho`-formatted
2024 // subprocess argument silently inherits this substitution
2025 // vector unless the typed slot's accepted set structurally
2026 // excludes the byte.
2027 //
2028 // Frontier inspiration: OTP's `gen_server` return-value grammar
2029 // rejects mid-tuple shell-metachar bytes by construction —
2030 // `{noreply, State}` never carries a raw `$` because the
2031 // Erlang term type system has no notion of "string that gets
2032 // shelled out"; caixa's typed slots inherit the same
2033 // structural discipline (types-are-theorems, the compounding
2034 // mandate's leverage-point-1) by refusing values that would
2035 // silently reinterpret at any downstream layer. Peer with
2036 // Unison's content-addressed code (no ambient environment —
2037 // every reference is a hash, no `$VAR` substitution possible)
2038 // and Pony's capabilities (a path capability that carries a
2039 // `$` would be ill-typed at the reference layer).
2040 //
2041 // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042 // e3558fa `%` arm) because a value carrying both `%` and `$`
2043 // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044 // encoded space next to a `$HOME` template") surfaces the
2045 // narrower URL-encoding diagnostic first — the paste-from-
2046 // browser-address-bar shape is the load-bearing self-locating
2047 // edit on every probe-as-both value; same cascade discipline
2048 // every prior `:caminho` arm establishes (a323db8 % before
2049 // this arm, this arm before trailing-`/`). The arm fires
2050 // BEFORE the trailing-`/` arm because the embedded shell-
2051 // variable-expansion byte is the more semantic-locating axis
2052 // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053 // but the load-bearing diagnostic is the embedded `$` — the
2054 // trailing `/` is the secondary observation, and an author
2055 // who substitutes the `$HOME` template with a literal value is
2056 // likely to also tab-strip the trailing separator).
2057 for &b in caminho.as_bytes() {
2058 if b == b'$' {
2059 return Err(DepError::fonte_caminho_shell_variable_expansion(
2060 nome, caminho, b,
2061 ));
2062 }
2063 }
2064 // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065 // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066 // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067 // orthogonal POSIX shell-history-expansion sentinel every interactive
2068 // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069 // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070 // re-runs the most recent history entry beginning with `command`,
2071 // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072 // last word of the prior command, `!:N` substitutes the Nth word,
2073 // `^old^new` rewrites the prior command's `old` to `new` (the
2074 // canonical set of `set -o histexpand` operators bash's default
2075 // interactive session enables). Beyond the shell-history layer,
2076 // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077 // admits the byte inside a path segment, but every WHATWG-conformant
2078 // special-scheme URL parser percent-encodes it inside a query
2079 // component via the 'special-query percent-encode set' the peer
2080 // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081 // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082 // (logical-negation prefix — the paste-from-source-code idiom where
2083 // an author copies `!path.exists()` out of a Rust snippet and the
2084 // trailing punctuation crosses the string-literal boundary); the
2085 // canonical English-typography emphasis / exclamation mark (the
2086 // paste-from-prose enthusiasm-form idiom where an author writes
2087 // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088 // to a kebab-case slug); and the Nix flake-ref import-attribute
2089 // `import ./foo.nix { … }` sibling operator surface.
2090 //
2091 // POSIX `std::path::Path` treats `!` as a literal path-component
2092 // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093 // from-shell-history footgun where the author copies a `cd
2094 // ../caixa-teia && !sudo make install` one-liner from a quick-
2095 // start README and the trailing `!sudo` rides in verbatim as a
2096 // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097 // `!!` repeat-prior-command paste idiom), a `:caminho
2098 // "../caixa-teia!"` (the English-typography enthusiasm-form
2099 // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100 // last-word-substitution shape) silently pass every prior arm
2101 // because `Path::is_absolute` returns false on `..`, `!` is neither
2102 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105 // and the value's last byte isn't `/`. The resolver folds the value
2106 // through `Path::new(caminho).join(<file>)` looking for a literal
2107 // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108 // with a non-self-locating `No such file or directory` error far
2109 // from the source caixa.lisp — while every downstream interactive
2110 // shell with `set -o histexpand` reinterprets the byte as the
2111 // history-expansion prefix, and the failure mode forks per
2112 // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113 // line executed under `bash -i` (the operator-notebook interactive
2114 // shell) substitutes the `!sudo` reference to the most recent
2115 // history entry starting with `sudo`, silently invoking whatever
2116 // privileged command that entry named.
2117 //
2118 // The lacre pipeline embeds the value verbatim in its per-dep
2119 // content-address (`conteudo: format!("path:{caminho}")`,
2120 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121 // BLAKE3 closure and rides into every shell-spawned subprocess
2122 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123 // a future operator-side `nix flake check` spawn) as the
2124 // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125 // every peer single-token-shaped typed slot already closes. The
2126 // peer `:fonte :repo` axis closes the byte under the same shell-
2127 // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128 // `is_git_repo_url`); the `:caminho` axis was the last typed
2129 // path-string surface still admitting the byte. This arm closes
2130 // the gap so the substrate-wide "no shell-composition
2131 // metacharacter / history-expansion sentinel anywhere in a typed
2132 // string slot that flows verbatim into a shell-spawned subprocess"
2133 // invariant extends from shell-variable-expansion (`$`) to shell-
2134 // history-expansion (`!`) on the `:caminho` axis. Together with
2135 // the peer c370458 backtick command-substitution-legacy-form arm
2136 // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137 // sibling `:repo` axis, the typed `:caminho` accepted set now
2138 // structurally excludes every byte the POSIX shell §2.6 Word
2139 // Expansions section, §2.3 Token Recognition step 6, and every
2140 // history-expansion / brace-expansion / pathname-expansion /
2141 // parameter-expansion / command-substitution / arithmetic-
2142 // expansion operator lexes as a first-class parser byte.
2143 //
2144 // Frontier inspiration: Unison's content-addressed code (no
2145 // ambient environment — every reference is a hash, no `!<num>`
2146 // history-index substitution possible; the caixa substrate's
2147 // lacre discipline arrives at the same guarantee by refusing
2148 // bytes at manifest-parse time that would reinterpret against
2149 // ambient shell history state); Pony's capabilities (a path
2150 // capability that carries a `!` would be ill-typed at the
2151 // reference layer).
2152 //
2153 // The arm fires AFTER the shell-variable-expansion arm because a
2154 // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155 // canonical "I pasted a `$HOME`-templated path adjacent to a
2156 // trailing `!sudo` history-expansion") surfaces the narrower
2157 // shell-variable-expansion diagnostic first — the paste-from-CI-
2158 // manifest-with-`$VAR`-template shape is the load-bearing self-
2159 // locating edit on every probe-as-both value; same cascade
2160 // discipline every prior `:caminho` arm establishes. The arm
2161 // fires BEFORE the trailing-`/` arm because the embedded shell-
2162 // history-expansion byte is the more semantic-locating axis on
2163 // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164 // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165 // is the secondary observation, and an author who removes the
2166 // `!sudo` history reference is likely to also tab-strip the
2167 // trailing separator).
2168 for &b in caminho.as_bytes() {
2169 if b == b'!' {
2170 return Err(DepError::fonte_caminho_shell_history_expansion(
2171 nome, caminho, b,
2172 ));
2173 }
2174 }
2175 // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176 // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177 // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178 // (`0x5E`) is the paired-operator half of the same bash-reference
2179 // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180 // form (POSIX bash rewrites the prior command's `old` string to
2181 // `new` and re-executes it, the canonical typo-correction one-
2182 // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183 // trailing substitution fragment verbatim into a `:caminho` value
2184 // when the author trims only the leading `git clone` prefix). The
2185 // peer `:fonte :repo` axis closes the byte under the same
2186 // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187 // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188 // path-string surface still admitting the byte after 6a04767
2189 // landed the `!` arm.
2190 //
2191 // Beyond bash history-substitution, `^` carries five distinct
2192 // downstream-reinterpretation surfaces the typed slot's accepted
2193 // set must structurally exclude:
2194 //
2195 // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196 // layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197 // required to percent-encode-or-refuse at the wire boundary.
2198 // The WHATWG URL spec's 'fragment percent-encode set' maps
2199 // `^` → `%5E` at the query / fragment component transition;
2200 // libcurl silently percent-encodes the byte on the wire, so a
2201 // `:caminho "../foo^bar"` value the resolver's `Path::join`
2202 // sees as a literal `./../foo^bar` subdirectory diverges from
2203 // the byte-transformed `%5E` shape any downstream `feira tofu`
2204 // curl-invocation or artifact-registry-fetch would emit — the
2205 // canonical wire-boundary divergence vector the peer
2206 // `{`, `}`, `|`, `\` `:caminho` arms already close (
2207 // `FonteCaminhoShellBraceExpansion` at 598b770,
2208 // `FonteCaminhoShellPipe` at the pipe arm,
2209 // `FonteCaminhoBackslash` at the backslash arm).
2210 // 2. **Regex character-class negation prefix `[^abc]`** — the
2211 // canonical paste-from-doc-regex-pipeline footgun where an
2212 // author copies a `grep '[^abc]'` idiom from a docs quick-
2213 // listing and the character-class negation byte rides in
2214 // verbatim.
2215 // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216 // JavaScript / Nix / Go — the paste-from-source-code idiom
2217 // where an author copies an `x ^ y`-shaped expression out of
2218 // a source snippet and the operator crosses the string-
2219 // literal boundary.
2220 // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221 // escapes the next character in a `cmd.exe` batch context (a
2222 // peer of the backslash arm's Windows-separator-leak vector).
2223 // A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224 // file footgun reinterprets at every `cmd.exe`-spawned
2225 // subprocess (the resolver's future Windows-runner shell-out,
2226 // the operator's WinRM path, a future PowerShell-embedded
2227 // invocation).
2228 // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229 // paste-from-typeset-doc footgun where a mathematical
2230 // superscript notation (`x^2` / `M^T`) leaks from prose.
2231 //
2232 // POSIX `std::path::Path` treats `^` as a literal path-component
2233 // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234 // substitution), `:caminho "../foo^"` (trailing history-
2235 // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236 // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237 // arm at 986963b fires first on this shape), or `:caminho
2238 // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239 // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240 // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241 // / `"` / `#` / `%` / `$` / `!`) and route through
2242 // `Path::new(caminho).join(<file>)` looking for a literal
2243 // `./{caminho}` subdirectory that fails at resolve time with a
2244 // non-self-locating `No such file or directory` error far from
2245 // the source caixa.lisp — while every downstream shell / curl /
2246 // regex / `cmd.exe` layer reinterprets the byte to its own
2247 // semantic.
2248 //
2249 // The lacre pipeline embeds the value verbatim in its per-dep
2250 // content-address (`conteudo: format!("path:{caminho}")`,
2251 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252 // BLAKE3 closure and rides into every shell-spawned subprocess
2253 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254 // a future operator-side `nix flake check` spawn) as the
2255 // canonical shell-history-substitution / RFC-3986-unwise /
2256 // regex-negation surface every peer single-token-shaped typed
2257 // slot already closes. This arm together with the immediate-
2258 // predecessor `!` arm (6a04767) closes the full `set -o
2259 // histexpand` operator surface on the `:caminho` axis — the
2260 // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261 // quick-substitution form via `^` — so the substrate-wide "no
2262 // shell-history operator anywhere in a typed string slot that
2263 // flows verbatim into a shell-spawned subprocess" invariant
2264 // extends from the `!` prefix half to the `^` quick-substitution
2265 // half. Every peer bash-history operator now fails at manifest-
2266 // parse time with a self-locating diagnostic naming the offending
2267 // caixa.lisp rather than at resolve-time as a `Path::join`-
2268 // derived `No such file or directory` (harmless but non-self-
2269 // locating) or worse riding into a downstream `bash -i` context
2270 // that reinterprets the byte-pair against ambient history state.
2271 //
2272 // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273 // "Quick substitution. Repeat the previous command, replacing
2274 // string1 with string2." + RFC 3986 §2 'unwise' set
2275 // ("characters that gateways and other transport agents are
2276 // known to sometimes modify") + Pony's capabilities (a path
2277 // capability that carries a `^` would be ill-typed at the
2278 // reference layer, matching the same structural discipline the
2279 // sibling `!` history-expansion arm inherits from Unison's
2280 // content-addressed no-ambient-history discipline).
2281 //
2282 // The arm fires AFTER the shell-history-expansion `!` arm because
2283 // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284 // the canonical "I pasted a `!sudo` history-reference next to a
2285 // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286 // form `!` diagnostic first — the `!` form is the load-bearing
2287 // self-locating edit on every probe-as-both value (an author who
2288 // removes the `!sudo` reference is likely to also strip the
2289 // paired `^` substitution fragment); same cascade discipline
2290 // every prior `:caminho` arm establishes. The arm fires BEFORE
2291 // the trailing-`/` arm because the embedded shell-history-
2292 // substitution byte is the more semantic-locating axis on
2293 // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294 // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295 // is the secondary observation, and an author who removes the
2296 // `^bar` substitution fragment is likely to also tab-strip the
2297 // trailing separator).
2298 for &b in caminho.as_bytes() {
2299 if b == b'^' {
2300 return Err(DepError::fonte_caminho_shell_history_substitution(
2301 nome, caminho, b,
2302 ));
2303 }
2304 }
2305 // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306 // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307 // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308 // backslash arm closes the cross-host-OS-separator vector. The
2309 // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310 // footgun — `Path::join("../caixa-teia")` and
2311 // `Path::join("../caixa-teia/")` resolve to the same directory
2312 // (POSIX path-component-walk treats trailing `/` as a no-op for
2313 // directory targets, which `:caminho` always names — the sibling-
2314 // workspace dep root is structurally a directory). The lacre
2315 // pipeline embeds the value verbatim in its per-dep content-address
2316 // (`conteudo: format!("path:{caminho}")`,
2317 // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318 // semantic-meaning yields two distinct BLAKE3 closures depending on
2319 // whether the author shell-tab-completed the path (every interactive
2320 // shell appends `/` on tab-completing a directory, idiomatic in
2321 // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322 // shells emits without trailing `/`, but `realpath -e -m` on a
2323 // directory with trailing `/` preserves it), or copied a Cargo
2324 // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325 // (Cargo accepts both shapes and folds them the same way). Two
2326 // workstations whose authors differ only in tab-completion habits
2327 // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328 // and the substrate's "the lacre is the build's identity" contract
2329 // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330 //
2331 // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332 // arm protects, here against the trailing-separator divergence
2333 // vector: every typed slot's accepted set excludes byte-divergent
2334 // values that round-trip to the same downstream semantic. The peer
2335 // path-shaped axes already reject trailing separators on the same
2336 // contract: [`crate::render::is_gateway_api_http_path`] gates
2337 // `:entrada :paths` against any non-canonical normalization, and
2338 // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339 // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340 // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341 // whose canonical form would re-introduce determinism divergence.
2342 //
2343 // The arm fires last in the cascade because every prior arm carries
2344 // a more self-locating diagnostic on values that probe as both
2345 // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346 // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347 // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348 // the load-bearing diagnostic is the absolute host-layout-leak —
2349 // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350 // but the load-bearing diagnostic is the Windows-separator cross-
2351 // OS divergence — the backslash arm wins). The arm covers every
2352 // shape where the last byte is `/` regardless of length, including
2353 // the degenerate single-`/` (which the absolute arm catches first)
2354 // and the consecutive-`//` (where every prior arm passes on the
2355 // bytes other than the trailing `/`).
2356 if caminho.as_bytes().last() == Some(&b'/') {
2357 return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358 }
2359 Ok(())
2360 }
2361}
2362
2363impl Dep {
2364 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365 /// accessor every consumer of the dep-graph identity axis keys off —
2366 /// returns the author-declared `:nome` byte-string verbatim as a
2367 /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368 ///
2369 /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370 /// label that names the target caixa (validated by [`Self::validate`]
2371 /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372 /// same accept-set the peer caixa-identifier axes carry — top-level
2373 /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374 /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375 /// downstream consumer that fans on the dep's name-identity keys off
2376 /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377 /// [`crate::render::insert_first_seen`] dedup key + the paired
2378 /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379 /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380 /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381 /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382 /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383 /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384 /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385 /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386 /// every `caixa-resolver` `ResolveError::MissingPath` /
2387 /// `ResolveError::MissingPin` carrier that names the offending dep
2388 /// (`resolve.rs:177,206`), each resolved
2389 /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390 /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391 /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392 ///
2393 /// Prior to this lift the `.nome` byte-string was read inline at every
2394 /// production site — the [`crate::Caixa::validate_deps`] paired
2395 /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396 /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397 /// parent-equality checks, and every caixa-resolver / caixa-feira
2398 /// site enumerated above — open-coded field-accesses that expressed
2399 /// no compile-time link back to the typed slot. A future extension of
2400 /// the `:deps :nome` axis to a richer author surface (a per-scope
2401 /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402 /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403 /// namespace-qualified rewrite the future M4 lacre-federation layer
2404 /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405 /// to a richer scoped-identifier newtype once cross-registry federation
2406 /// lands) would have had to be threaded through every open-coded copy
2407 /// in lockstep or two consumers would silently disagree on which caixa
2408 /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409 /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410 /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411 /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412 /// requeue-suppression seen-set, one build-time diagnostic
2413 /// disagreeing with the run-time closure the substrate's lacre
2414 /// pipeline actually materializes. Lifting the resolution rule to a
2415 /// typed method on the substrate primitive means every downstream
2416 /// consumer of the caixa's per-`:deps` identity surface reaches for
2417 /// exactly one typed dispatch — the resolver's accept-set migrates as
2418 /// a unit on any future axis addition.
2419 ///
2420 /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421 /// `&str`-return required-scalar projection pattern the sibling
2422 /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423 /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424 /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425 /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426 /// accessors — same "one typed dispatch on the substrate primitive,
2427 /// thin projections at each consumer" discipline extended onto the
2428 /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429 /// remaining unlifted caixa-name-referencing accessor family in the
2430 /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431 /// term the field's docstring already reaches for ("Caixa name — must
2432 /// match the target caixa's `:nome`") and the peer caixa-identity
2433 /// accessor family the substrate already carries.
2434 #[must_use]
2435 pub const fn nome(&self) -> &str {
2436 self.nome.as_str()
2437 }
2438
2439 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440 /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441 /// the dep-graph version-pin axis keys off — returns the author-
2442 /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443 /// borrowed from the typed slot's own [`String`] storage.
2444 ///
2445 /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446 /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447 /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448 /// entry-point consumes — same accept-set the peer requirement-
2449 /// carrying axes carry (per-`:membros`
2450 /// [`crate::Membro::versao_requirement`], per-`:children`
2451 /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452 /// through the shared
2453 /// [`crate::render::require_valid_versao_requirement`] cascade in
2454 /// [`Self::validate`]. Every downstream consumer that fans on the
2455 /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456 /// `require_valid_versao_requirement` gate + the paired
2457 /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458 /// requirement-shape rejection, the `feira lock` stub-resolver's
2459 /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460 /// `conteudo` hash-input interpolation and the paired
2461 /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462 /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463 ///
2464 /// Prior to this lift the `.versao` byte-string was read inline at
2465 /// every production site — the [`Self::validate`] paired
2466 /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467 /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468 /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469 /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470 /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471 /// same shapes — open-coded field-accesses that expressed no
2472 /// compile-time link back to the typed slot. A future extension of
2473 /// the `:deps :versao` axis to a richer author surface (a per-scope
2474 /// version-lock overlay the resolver folds through the
2475 /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476 /// docstring already acknowledges, a per-cluster canary-version
2477 /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478 /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479 /// once cross-registry federation lands) would have had to be
2480 /// threaded through every open-coded copy in lockstep or two
2481 /// consumers would silently disagree on which release constraint a
2482 /// given dep resolves to — the [`Self::validate`] requirement-gate
2483 /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484 /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485 /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486 /// content-addressed hash the substrate's fetch pipeline actually
2487 /// materializes, one build-time diagnostic disagreeing with the
2488 /// run-time closure. Lifting the resolution rule to a typed method
2489 /// on the substrate primitive means every downstream consumer of
2490 /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491 /// one typed dispatch — the resolver's accept-set migrates as a
2492 /// unit on any future axis addition.
2493 ///
2494 /// Second accessor on the outer `Dep` type — folds on the outer-
2495 /// `Dep` `&str`-return required-scalar projection pattern the
2496 /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497 /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498 /// (a40b0e3) / per-`:children`
2499 /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500 /// family) member/child version-pin accessors — the three
2501 /// requirement-carrying axes (`Dep::versao_requirement` on the
2502 /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503 /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504 /// Supervisor side) now share one accessor discipline for the
2505 /// shared substrate concept "another caixa referenced by a
2506 /// Cargo-shaped semver requirement". The pair
2507 /// `(nome(), versao_requirement())` jointly projects the
2508 /// `(nome, versao)` field pair every dep-graph consumer that fans
2509 /// on per-dep identity + version pin keys off. Named
2510 /// `versao_requirement()` rather than `versao()` because the field's
2511 /// storage-side `.versao` label is already the author-surface term
2512 /// (`:versao`); the accessor's name carries the semantic role — the
2513 /// semver *requirement* string the shared
2514 /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515 /// raw field access and a typed dispatch read differently at every
2516 /// consumer site. Matches the peer
2517 /// [`crate::Membro::versao_requirement`] /
2518 /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519 /// discipline verbatim.
2520 #[must_use]
2521 pub const fn versao_requirement(&self) -> &str {
2522 self.versao.as_str()
2523 }
2524
2525 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526 /// Zig-store-model per-dep source-tuple optional-composite-reference
2527 /// accessor every consumer of the dep-graph fetch-source axis keys
2528 /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529 /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530 /// own `Option<DepSource>` storage, with `None` naming the "author
2531 /// omitted `:fonte`" shorthand every resolver-side default-fill
2532 /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533 /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534 /// the [`Dep::fonte`] field docstring already documents) treats as
2535 /// the "resolve through the configured default host / org
2536 /// (`github:<default-org>/<nome>`)" partition.
2537 ///
2538 /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539 /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540 /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541 /// rev, branch }` for the git-clone arm every published caixa
2542 /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543 /// local-filesystem arm every unpublishable in-tree checkout
2544 /// resolves through. Every downstream consumer that fans on the
2545 /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546 /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547 /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548 /// diagnostics through the [`DepError::Fonte*`] carrier family
2549 /// naming the offending `Dep::nome`), the caixa-crd conversion
2550 /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551 /// `{repo, git_ref}` pair the K8s-CR side consumes
2552 /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553 /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554 /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555 /// concrete `DepSource` at run time.
2556 ///
2557 /// Prior to this lift the `.fonte` typed slot was read inline at
2558 /// every production site — the [`Self::validate`]
2559 /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560 /// gate delegates through, the caixa-crd `dep_into_ref`
2561 /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562 /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563 /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564 /// coded field-accesses that expressed no compile-time link back to
2565 /// the typed slot. A future extension of the `:deps :fonte` axis
2566 /// to a richer author surface (a per-scope source-override table
2567 /// the resolver folds through the `~/.config/caixa/config.yaml`
2568 /// entry the [`Dep`] docstring already acknowledges, a per-org
2569 /// mirror-fallback list the future M4 lacre-federation resolver
2570 /// consults ahead of the `default_github` fallback, a promotion of
2571 /// the plain `Option<DepSource>` to a richer
2572 /// `{primary, mirrors, integrity}` triple once cross-registry
2573 /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574 /// M4 lacre gate binds against ahead of the git-fetch) would have
2575 /// had to be threaded through every open-coded copy in lockstep or
2576 /// two consumers would silently disagree on which fetch source a
2577 /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578 /// gate reading the author-declared source while the caixa-crd
2579 /// projector read a per-scope-override-resolved source would
2580 /// silently split the build-time refusal from the CR the
2581 /// substrate's admission pipeline actually materializes, one
2582 /// build-time diagnostic disagreeing with the run-time closure.
2583 /// Lifting the resolution rule to a typed method on the substrate
2584 /// primitive means every downstream consumer of the caixa's per-
2585 /// `:deps` fetch-source surface reaches for exactly one typed
2586 /// dispatch — the resolver's accept-set migrates as a unit on any
2587 /// future axis addition.
2588 ///
2589 /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590 /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591 /// reference projection pattern the sibling per-`Dep` `:opcional`
2592 /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593 /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594 /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595 /// `Option<&Composite>` composite-reference sub-family the
2596 /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597 /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598 /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599 /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600 /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601 /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602 /// accessor already carries — extends that "one typed dispatch on
2603 /// the substrate primitive, thin projections at each consumer"
2604 /// discipline onto the third outer typed-slot altitude that carries
2605 /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606 /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607 /// copy or clone) because every downstream consumer of the fonte
2608 /// composite treats it as a read-only per-arm dispatch source — the
2609 /// reference-view is the narrowest borrow that supports every
2610 /// present + roadmapped consumer (per-arm match projection at the
2611 /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612 /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613 /// `default_github` fill applies" partition every resolver
2614 /// consults, `.cloned()`-on-demand for the two resolver-side
2615 /// default-fill call sites that require an owned `DepSource` for
2616 /// `Option::unwrap_or_else`) without cloning the composite through
2617 /// every consumer's fast path. The `Option` half of the return-type
2618 /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619 /// side default applies" partition (not a default composite the
2620 /// downstream must reject on emptiness) — the accessor projects the
2621 /// raw `Option<DepSource>` slot's presence bit through the
2622 /// reference-return unchanged. Named `fonte()` to match the storage
2623 /// field's name verbatim and the tatara-lisp author-surface term
2624 /// (`:fonte`) the field's own docstring already carries.
2625 ///
2626 /// Declared `pub const fn` — the body projects through
2627 /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628 /// well within the workspace MSRV, so every downstream `const`-
2629 /// context consumer of the per-`Dep` `:fonte` composite-reference
2630 /// accessor reaches through the same typed dispatch on the
2631 /// substrate primitive at const-eval time as at runtime. The
2632 /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633 /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634 /// that forwards through each lifted accessor) locks the posture
2635 /// load-bearing at caixa-core build time — any future accidental
2636 /// downgrade to non-`const` fails the wrapper with E0015
2637 /// (`cannot call non-const method`), strictly stronger than a
2638 /// runtime `assert!` and side-stepping the destructor-in-const
2639 /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640 /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641 /// `WitContract` pre-projection accessor family's `const`-eval-
2642 /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643 /// accessor family's parallel pass (231a968) — same "one canonical
2644 /// dispatch per axis, `const`-eval posture pinned at the substrate
2645 /// primitive, thin projections at each consumer" discipline
2646 /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647 ///
2648 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649 #[must_use]
2650 pub const fn fonte(&self) -> Option<&DepSource> {
2651 self.fonte.as_ref()
2652 }
2653
2654 /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655 /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656 /// every consumer of the dep-graph feature-flag axis keys off —
2657 /// returns the author-declared `:caracteristicas` feature-name list
2658 /// verbatim as a `&[String]` slice-view over the same backing buffer
2659 /// the raw `self.caracteristicas.as_slice()` field access borrows
2660 /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661 /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662 /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663 /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664 /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665 /// — possibly empty — and the returned `&[String]` degenerates to
2666 /// an empty slice on that arm without any silent `None` collapse).
2667 ///
2668 /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669 /// carries the set-shaped feature-toggle list the substrate walks
2670 /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671 /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672 /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673 /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674 /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675 /// walk, empty-first / value-shape-second / duplicate-third
2676 /// precedence via the peer per-axis two-arm cascade discipline every
2677 /// substrate-blessed Vec-keyed-by-name slot already follows).
2678 /// Every downstream consumer that fans on the dep's feature-toggle
2679 /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680 /// per-entry linear walk that gates each feature-name byte-string
2681 /// through the empty / value-shape / duplicate arms (raising the
2682 /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683 /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684 /// offending `Dep::nome`), and every future
2685 /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686 /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687 /// future caixa-resolver per-dep feature-projection walk that folds
2688 /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689 /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690 /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691 /// features slice the K8s-CR admission gate consumes, the future
2692 /// per-cluster feature-overlay the M4 lacre-federation resolver
2693 /// composes ahead of the substrate-wide feature-name accept-set).
2694 ///
2695 /// Prior to this lift the `.caracteristicas` byte-string list was
2696 /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697 /// &self.caracteristicas` walk — the only in-crate consumer of the
2698 /// raw field beyond the per-`Dep` constructor pair
2699 /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700 /// round-trip / per-test fixture-mutation paths — an open-coded
2701 /// field-access that expressed no compile-time link back to the
2702 /// typed slot. A future extension of the `:caracteristicas` axis to
2703 /// a richer author surface (a per-scope feature-overlay the resolver
2704 /// folds through the `~/.config/caixa/config.yaml` entry the
2705 /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706 /// activation overlay the future M4 lacre-federation layer applies
2707 /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708 /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709 /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710 /// docstring anticipates lands) would have had to be threaded
2711 /// through every open-coded copy in lockstep or two consumers
2712 /// would silently disagree on which feature closure a given dep
2713 /// activates — the [`Self::validate_caracteristicas`] gate walking
2714 /// the author-declared list while a downstream caixa-resolver
2715 /// consumer walked a per-scope-override-resolved list would
2716 /// silently split the build-time refusal from the lacre closure
2717 /// the substrate's fetch pipeline actually materializes, one
2718 /// build-time diagnostic disagreeing with the run-time closure.
2719 /// Lifting the resolution rule to a typed method on the substrate
2720 /// primitive means every downstream consumer of the caixa's per-
2721 /// `:deps` feature-toggle surface reaches for exactly one typed
2722 /// dispatch — the resolver's accept-set migrates as a unit on any
2723 /// future axis addition.
2724 ///
2725 /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726 /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727 /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728 /// future outer scalar lift folds on and closes the outer-`Dep`
2729 /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731 /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732 /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733 /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734 /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735 /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736 /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737 /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738 /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739 /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740 /// altitude — extends the "one typed dispatch on the substrate
2741 /// primitive, thin projections at each consumer" discipline onto the
2742 /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743 /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744 /// because every downstream consumer of the feature-toggle list
2745 /// treats it as a read-only sequence — the slice-view is the
2746 /// narrowest borrow that supports every present + roadmapped
2747 /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748 /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749 /// the typed view reaches for (the storage-side `Vec` remains
2750 /// reachable through the `pub caracteristicas` field for the
2751 /// mutation-carrying serde round-trip and per-test fixture-mutation
2752 /// paths). Named `caracteristicas()` to match the storage field's
2753 /// name verbatim and the tatara-lisp author-surface term
2754 /// (`:caracteristicas`) the field's own docstring already carries.
2755 ///
2756 /// Declared `pub const fn` — the body projects through
2757 /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758 /// well within the workspace MSRV, so every downstream `const`-
2759 /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760 /// accessor reaches through the same typed dispatch on the
2761 /// substrate primitive at const-eval time as at runtime. Pinned
2762 /// load-bearing by the paired
2763 /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764 /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765 /// the full pin-shape rationale.
2766 ///
2767 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768 #[must_use]
2769 pub const fn caracteristicas(&self) -> &[String] {
2770 self.caracteristicas.as_slice()
2771 }
2772
2773 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774 /// missing-source-tolerance flag scalar accessor every consumer of
2775 /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776 /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777 /// typed slot's own `bool` storage (no borrow of `&self` past the
2778 /// call; the `Copy`-return arm matches the peer
2779 /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780 /// projected sibling discipline the outer flat-spread family
2781 /// already carries). Default-`false` (`#[serde(default,
2782 /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783 /// `Dep` past parse definitionally carries a `bool` — `false` when
2784 /// the author omits `:opcional` — and the returned value degenerates
2785 /// to `false` on that arm without any silent `None` collapse).
2786 ///
2787 /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788 /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789 /// missing-source arm as a soft-fail rather than a build refusal"
2790 /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791 /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792 /// dropped from the resolved dep-graph rather than tripping the
2793 /// build-refusal edge that a mandatory `:opcional false` entry
2794 /// would). Every downstream consumer that fans on the dep's
2795 /// missing-source-tolerance keys off this accessor: the future
2796 /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797 /// dispatch on the opcional bit ahead of the lacre closure
2798 /// materialization), the future caixa-crd per-`spec.deps`
2799 /// `optional` boolean the K8s-CR admission gate consumes on the
2800 /// per-dep partition, and the future feira / caixa-resolver /
2801 /// caixa-crd feature-projection walk that folds the opcional bit
2802 /// into the resolved feature-closure the future M4 lacre-federation
2803 /// layer emits.
2804 ///
2805 /// Prior to this lift the `.opcional` `bool` slot was read inline
2806 /// at the sole in-crate consumer site — the tests-module
2807 /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808 /// pinning the [`Self::simple`] constructor's default-`false` fill
2809 /// (the only in-crate read of the raw field beyond the per-`Dep`
2810 /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811 /// serde round-trip / per-test fixture-mutation paths) — an open-
2812 /// coded field-access that expressed no compile-time link back to
2813 /// the typed slot. A future extension of the `:opcional` axis to a
2814 /// richer author surface (a per-scope opcional-override the resolver
2815 /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816 /// docstring already acknowledges, a per-cluster opcional-override
2817 /// the future M4 lacre-federation layer applies per-CR, a promotion
2818 /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819 /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820 /// roadmap lands) would have had to be threaded through every open-
2821 /// coded copy in lockstep or two consumers would silently disagree
2822 /// on which missing-source arm a given dep resolves to — the
2823 /// [`Self::simple`] constructor's default-`false` fill reading
2824 /// verbatim while a downstream caixa-resolver consumer read a per-
2825 /// scope-override-resolved bit would silently split the build-time
2826 /// arm from the lacre closure the substrate's fetch pipeline
2827 /// actually materializes, one build-time diagnostic disagreeing
2828 /// with the run-time closure. Lifting the resolution rule to a
2829 /// typed method on the substrate primitive means every downstream
2830 /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831 /// reaches for exactly one typed dispatch — the resolver's accept-
2832 /// set migrates as a unit on any future axis addition.
2833 ///
2834 /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835 /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837 /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838 /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839 /// `:caracteristicas`) now routes through exactly one typed
2840 /// dispatch on the substrate primitive. First outer-`Dep`
2841 /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842 /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843 /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844 /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845 /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846 /// already carries — extends the "one typed dispatch on the
2847 /// substrate primitive, thin projections at each consumer"
2848 /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849 /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850 /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851 /// every downstream consumer treats it as a plain discriminant
2852 /// value — the by-value return is the narrowest return-shape that
2853 /// supports every present + roadmapped consumer (`.then(…)` early
2854 /// return on the resolver-side drop-vs-error partition, direct
2855 /// bool composition with a per-scope-override projector, plain
2856 /// `if dep.opcional() { … }` early return at every future admission
2857 /// gate) without leaking the storage field's `bool`-in-`&self`
2858 /// lifetime the by-value return elides. Marked `pub const fn` so
2859 /// the accessor is `const`-callable — same discipline the peer
2860 /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861 /// accessor carries. Named `opcional()` to match the storage
2862 /// field's name verbatim and the tatara-lisp author-surface term
2863 /// (`:opcional`) the field's own docstring already carries.
2864 #[must_use]
2865 pub const fn opcional(&self) -> bool {
2866 self.opcional
2867 }
2868
2869 /// Build a minimal registry-sourced dep.
2870 #[must_use]
2871 pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872 Self {
2873 nome: nome.into(),
2874 versao: versao.into(),
2875 fonte: None,
2876 opcional: false,
2877 caracteristicas: Vec::new(),
2878 }
2879 }
2880
2881 /// Build a Git-sourced dep (tag-based).
2882 #[must_use]
2883 pub fn git(
2884 nome: impl Into<String>,
2885 versao: impl Into<String>,
2886 repo: impl Into<String>,
2887 tag: impl Into<String>,
2888 ) -> Self {
2889 Self {
2890 nome: nome.into(),
2891 versao: versao.into(),
2892 fonte: Some(DepSource::Git {
2893 repo: repo.into(),
2894 tag: Some(tag.into()),
2895 rev: None,
2896 branch: None,
2897 }),
2898 opcional: false,
2899 caracteristicas: Vec::new(),
2900 }
2901 }
2902
2903 /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904 /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905 /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906 /// semver requirement.
2907 ///
2908 /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909 /// is the same Cargo-shaped requirement string `:membros :versao`
2910 /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911 /// and `:children :versao` (validated at
2912 /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913 /// the lacre pipeline resolves all three axes through the same
2914 /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915 /// `:deps :versao` was the last `:versao` axis untyped past
2916 /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917 /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918 /// leaking-into-:versao `"v0.1"` typo, the accidental
2919 /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920 /// surfaced at lacre-resolve time, far from the source
2921 /// caixa.lisp, with no field naming which `:deps` entry carried
2922 /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923 /// the offending entry's `:nome` + the offending `:versao`
2924 /// verbatim + the parser's own wording in `reason`, so the
2925 /// author's grep target is unambiguous.
2926 ///
2927 /// The author surface for `:deps :nome` is the same DNS-1123 label
2928 /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929 /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930 /// `:membros :caixa` (validated at
2931 /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932 /// `:children :caixa` (validated at
2933 /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934 /// :nome` value flows verbatim through the lacre pipeline as the
2935 /// target caixa's `:nome` (which the gate at the *target* side now
2936 /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937 /// `lareira-<nome>` Helm chart name segment, the per-dep
2938 /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939 /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940 /// this gate landed `:deps :nome` was the fourth and last
2941 /// DNS-1123-shaped caixa-identifier axis still untyped past
2942 /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943 /// Teia"` uppercase — the canonical "I copied the README header"
2944 /// typo; `"caixa_teia"` underscore — the Go module / Python
2945 /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946 /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947 /// silently passed parse and surfaced at lacre-resolve time when
2948 /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949 /// — far from the source `:deps` entry, with a diagnostic naming
2950 /// the *target's* `:nome` rather than the dep entry that referenced
2951 /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952 /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953 /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954 /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955 /// so every downstream consumer (caixa-resolver's lacre fetch,
2956 /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957 /// fan-out emitter) reaches for the name knowing the value is
2958 /// apiserver-valid without re-validating.
2959 ///
2960 /// Empty checks fire first (narrower diagnostic), parse last —
2961 /// same ordering discipline as
2962 /// [`crate::AplicacaoSpec::validate_membros`] and
2963 /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964 /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965 /// structurally necessary even with the parse arm in place. The
2966 /// `:nome` shape gate runs after the `:nome` empty gate and before
2967 /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968 /// sees the name-side diagnostic first (the name is the
2969 /// self-locating axis — without it, the parse diagnostic can't
2970 /// quote `:nome "<bad>"`).
2971 pub fn validate(&self) -> Result<(), DepError> {
2972 if self.nome.is_empty() {
2973 return Err(DepError::NomeEmpty);
2974 }
2975 if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976 return Err(DepError::nome_invalid(&self.nome, reason));
2977 }
2978 // Delegate the empty-first + `parse_requirement` cascade to the
2979 // shared [`crate::render::require_valid_versao_requirement`]
2980 // helper — same two-arm shape the peer
2981 // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982 // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983 // :versao` route through, so drift between the three axes'
2984 // accepted requirement sets is structurally impossible and the
2985 // parse-side no-op the empty-first arm closes (semver's empty
2986 // parse yields an implicit `*`) lives in exactly one predicate.
2987 crate::render::require_valid_versao_requirement(
2988 self.versao_requirement(),
2989 || DepError::versao_empty(&self.nome),
2990 |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991 )?;
2992 if let Some(fonte) = self.fonte() {
2993 fonte.validate(&self.nome)?;
2994 }
2995 self.validate_caracteristicas()?;
2996 Ok(())
2997 }
2998
2999 /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000 /// are operationally meaningless. The `:caracteristicas` slot is
3001 /// a set of feature toggles to enable on the target caixa — same
3002 /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003 /// two structural footguns close here:
3004 ///
3005 /// - empty-string entry (`(:caracteristicas (""))`): the future
3006 /// caixa-resolver lacre pipeline would consume the empty
3007 /// identifier as a no-op feature enable, silently dropping the
3008 /// author's intent far from the source `caixa.lisp`;
3009 /// - duplicate entry within one dep (`(:caracteristicas ("http"
3010 /// "http"))`): the feature-toggle slot is set-shaped (enabling
3011 /// a feature twice has no additional semantic — there is no
3012 /// `feature × 2`), so two entries naming the same feature are
3013 /// a silent miscount, the same set-not-multiset distinction
3014 /// every peer Vec-keyed-by-name axis already closes
3015 /// ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016 /// `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017 /// on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018 /// on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019 /// on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020 /// on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021 /// on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022 /// / [`crate::UpgradeError::DuplicateStateChange`] /
3023 /// [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024 /// entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025 /// on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026 /// immediate-predecessor 359fba5 closed).
3027 ///
3028 /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029 /// every peer set-not-multiset gate uses; the empty arm fires
3030 /// before the duplicate arm so an entry with both an empty feature
3031 /// *and* a duplicate of some later feature surfaces the empty-
3032 /// shape diagnostic first (the empty-feature axis is the
3033 /// more-actionable defect since the missing-name renders the
3034 /// duplicate-key arm ambiguous: two `""` entries would both report
3035 /// `caracteristica: ""` with no way to distinguish the offending
3036 /// site). Empty-first cascade discipline mirrors every peer per-
3037 /// entry shape + duplicate gate
3038 /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039 /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040 /// before `MembroDuplicate`).
3041 ///
3042 /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043 /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044 /// fires between the empty arm and the duplicate arm — the
3045 /// canonical per-entry-shape-before-cross-entry-uniqueness
3046 /// precedence every peer two-arm + value-shape gate establishes
3047 /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048 /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049 /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050 /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051 /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052 /// Until the value-shape arm landed `:caracteristicas` accepted
3053 /// every non-empty distinct string — a structurally invalid
3054 /// feature name (`"http feature"` whitespace, `"+http"` the
3055 /// canonical paste-from-`+optional-feature` doc activation-form
3056 /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057 /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058 /// only applies inside list-grammar contexts, `"http,json"`
3059 /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060 /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061 /// inconsistently across NFC/NFD normalization, the 65-byte
3062 /// paste-from-binary slug) silently passed validate and the
3063 /// failure surfaced at `cargo metadata` time as the
3064 /// `restricted_names::validate_feature_name` parser's rejection,
3065 /// far from the source `caixa.lisp`, with no field naming which
3066 /// `:deps` entry's `:caracteristicas` carried the typo. The
3067 /// lifted predicate makes the Cargo-feature-name-grammar
3068 /// intersection-floor a substrate-level invariant at validate
3069 /// time — same trajectory as the eight peer
3070 /// [`crate::render`] value-shape predicates each typed surface
3071 /// downstream of a structured grammar already follows
3072 /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073 /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074 /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075 /// [`is_nats_subject`](crate::render::is_nats_subject),
3076 /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077 /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078 /// [`is_git_oid`](crate::render::is_git_oid),
3079 /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080 fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081 let mut seen = std::collections::HashSet::new();
3082 for c in self.caracteristicas() {
3083 if c.is_empty() {
3084 return Err(DepError::caracteristica_empty(&self.nome));
3085 }
3086 if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087 return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088 }
3089 crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090 DepError::caracteristica_duplicate(&self.nome, c)
3091 })?;
3092 }
3093 Ok(())
3094 }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140 deps: &[Dep],
3141 deps_dev: &[Dep],
3142 parent_nome: &str,
3143) -> Result<(), DepError> {
3144 for dep in deps {
3145 if dep.nome() == parent_nome {
3146 return Err(DepError::dep_is_self(
3147 parent_nome,
3148 crate::render::DEP_AUTHOR_KEY_DEPS,
3149 ));
3150 }
3151 }
3152 for dep in deps_dev {
3153 if dep.nome() == parent_nome {
3154 return Err(DepError::dep_is_self(
3155 parent_nome,
3156 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157 ));
3158 }
3159 }
3160 Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202 /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203 /// lacre closure resolves at every build. Wire-format
3204 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205 Prod,
3206 /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207 /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208 /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209 Dev,
3210}
3211
3212impl DepList {
3213 /// Exhaustive iteration surface for every consumer that reads the
3214 /// full closed-set (the future M4 admission webhook's per-list
3215 /// summary rejection body, any future round-trip pin harness). A
3216 /// future variant addition extends this slice as a single edit and
3217 /// every consumer picks up the new entry by construction — the
3218 /// compiler-checked exhaustiveness on the sibling method `match`
3219 /// arms is the build-time guarantee that no arm forgets to grow.
3220 pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222 /// Canonical author-surface tag every substrate consumer that
3223 /// names the offending dep-list in a diagnostic reaches for —
3224 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226 /// the same `&'static str` payload the sibling
3227 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228 /// already carry. Routing every dep-list diagnostic through the
3229 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230 /// literal-carry axis on the two-list dep-graph surface — a
3231 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232 /// wire-format promotion (a distinct diagnostic form for the
3233 /// `Dev` arm) reaches every consumer through one edit on the
3234 /// canonical constant, not a coordinated rewrite across the
3235 /// substrate's dep-graph consumers.
3236 #[must_use]
3237 pub const fn as_str(self) -> &'static str {
3238 match self {
3239 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241 }
3242 }
3243
3244 /// Substrate-canonical reverse projection on the two-list dep-graph
3245 /// axis — parses the author-surface wire tag back to the typed
3246 /// variant, or `None` when `s` is outside the closed-set arm-string
3247 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251 /// the round-trip migrate through one caixa-core edit on any future
3252 /// list-axis addition.
3253 ///
3254 /// Prior to this lift the substrate carried only the forward
3255 /// `Self → &str` projection on the two-list dep-graph axis (the
3256 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257 /// through it, the two [`DepError::DuplicateNome`] /
3258 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259 /// as a `&'static str` `list:` field). Every future consumer that
3260 /// wanted to promote the wire tag back to the typed enum (a future
3261 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262 /// wire form into the typed enum before dispatching to
3263 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265 /// wire re-parse of the per-list diagnostic body, a future
3266 /// [`DepError`] widening that promotes the two `list: &'static str`
3267 /// fields to a typed `list: DepList` carry so downstream consumers
3268 /// dispatch on the enum rather than string-comparing the wire
3269 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271 /// compile-time link back to the typed [`DepList`] enum. A future
3272 /// variant addition (a `:build-dep` or `:test-dep` third list once
3273 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276 /// would silently split the wire byte-string the emitter walks from
3277 /// the parser's arm-set — the round-trip would carry the new list
3278 /// through the forward projection but land on the fallback silently
3279 /// at every non-updated reverse parser, far from the arm-addition
3280 /// commit that caused the drift. Lifting the resolver to a typed
3281 /// method on the substrate primitive closes the drift footgun by
3282 /// construction: the parser's accept-set is the same set the
3283 /// [`Self::as_str`] emitter walks (routed through the same lifted
3284 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286 /// of the round-trip migrate through one caixa-core edit on any
3287 /// future list-axis addition.
3288 ///
3289 /// Same closed-set-reverse-projection discipline the sibling
3290 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295 /// carry on the peer wire-side `str → Self` axes — extended onto
3296 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297 /// closed-set typed enum on the caixa surface to converge on the
3298 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299 /// `from_str`) to match the peer shapes verbatim and side-step the
3300 /// derived [`std::str::FromStr`] impls the sibling
3301 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304 /// caller picks the diagnostic form appropriate for its use site —
3305 /// a future `feira dep --list …` arg-parse that surfaces
3306 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308 /// path folds `None` onto its per-CR structured refusal body.
3309 #[must_use]
3310 pub fn from_wire(s: &str) -> Option<Self> {
3311 match s {
3312 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314 _ => None,
3315 }
3316 }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335 f.write_str(self.as_str())
3336 }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391 fn as_ref(&self) -> &str {
3392 self.as_str()
3393 }
3394}
3395
3396/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3397/// [`DepList`] closed-set typed enum — routes through the paired
3398/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3399/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3400/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3401/// through, rather than an open-coded per-arm
3402/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3403/// has no compile-time link back to the substrate primitive.
3404///
3405/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3406/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3407/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3408/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3409/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3410/// which silently omitted [`DepList`] despite this enum being listed
3411/// as a sibling closed-set fieldless typed enum in every peer's
3412/// docstring). Every sibling closed-set fieldless typed enum on the
3413/// caixa surface now carries both trait-idiomatic axes
3414/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3415/// against the substrate-primitive canonical projection accessors
3416/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3417/// closed-set is the fifteenth and true-final peer.
3418///
3419/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3420/// `Option<Self>` return-shape's deliberate deferral of error typing:
3421/// the caller picks the diagnostic form appropriate for its use site
3422/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3423/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3424/// the M4 admission-webhook rejection body wraps `Err(())` with the
3425/// accepted-set enumeration).
3426///
3427/// Pinned load-bearing by
3428/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3429/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3430/// accept-set) and
3431/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3432/// (rejection witness against silent accept-set widening).
3433impl TryFrom<&str> for DepList {
3434 type Error = ();
3435
3436 fn try_from(s: &str) -> Result<Self, Self::Error> {
3437 Self::from_wire(s).ok_or(())
3438 }
3439}
3440
3441/// Trait-idiomatic *forward* projection on the two-list dep-graph
3442/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3443/// routes byte-for-byte through the paired substrate-primitive
3444/// [`DepList::as_str`] `pub const fn` accessor so
3445/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3446/// reaches the same two-arm lifted
3447/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3448/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3449/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3450/// surfaces already return.
3451///
3452/// Closes the substrate-wide trait-idiomatic forward-projection
3453/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3454/// via 523157d and traced through the 13 sibling closed-set typed
3455/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3456/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3457/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3458/// every peer's docstring naming it as a sibling. Paired with the
3459/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3460/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3461/// idiomatic axis pair, mirroring the pre-existing method-named
3462/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3463/// substrate-primitive axis pair.
3464///
3465/// The paired [`DepList::as_str`] returns `&'static str` by
3466/// construction — each arm resolves to a
3467/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3468/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3469/// static lifetime — so the trait's return-type promise is upheld
3470/// structurally.
3471///
3472/// Pinned load-bearing by
3473/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3474/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3475/// emit-set, plus a `const`-context materialization witness for the
3476/// `&'static str` lifetime promise) and
3477/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3478/// (partition pin + two-way round-trip through the paired
3479/// [`TryFrom<&str>`] axis).
3480impl From<DepList> for &'static str {
3481 fn from(list: DepList) -> &'static str {
3482 list.as_str()
3483 }
3484}
3485
3486/// Trait-idiomatic *forward* projection on the two-list dep-graph
3487/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3488/// `&'static str` axis — the borrowed-input companion to the paired
3489/// owned-input [`From<DepList> for &'static str`] impl immediately
3490/// above. Routes byte-for-byte through the same substrate-primitive
3491/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3492/// binds a `&DepList` through the standard-library `.into()` /
3493/// [`From<&Self> for &'static str`] axis (a
3494/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3495/// per-arm accept-set materializer that iterates the substrate-
3496/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3497/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3498/// forces every call site through an explicit `.copied()` /
3499/// dereference / [`Copy`]-bound restatement rather than the direct
3500/// trait-idiomatic projection; a future generic
3501/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3502/// that walks the `iter().map(Into::into)` shape verbatim; the future
3503/// M4 admission-webhook rejection body that composes the accepted-set
3504/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3505/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3506/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3507/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3508/// owned-input [`From<DepList> for &'static str`], the sibling
3509/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3510/// surfaces already return.
3511///
3512/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3513/// forward-projection family on the last-touched closed-set fieldless
3514/// typed enum — first-mover on the borrowed-input axis, mirroring the
3515/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3516/// input axis (523157d). Rust's `From` trait does not auto-derive the
3517/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3518/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3519/// in `core`), so every closed-set typed enum that carries the
3520/// owned-input axis but not the borrowed-input axis forces every
3521/// borrowed-input call site through a `.copied()` /
3522/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3523/// bounds have no compile-time link to the substrate primitive. The
3524/// remaining fourteen substrate-wide closed-set fieldless typed enum
3525/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3526/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3527/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3528/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3529/// of this campaign.
3530///
3531/// Pinned load-bearing by
3532/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3533/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3534/// emit-set via a borrowed input, plus a `const`-context materialization
3535/// witness) and
3536/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3537/// (cross-axis partition pin against the paired owned-input
3538/// [`From<DepList> for &'static str`] impl).
3539impl From<&DepList> for &'static str {
3540 fn from(list: &DepList) -> &'static str {
3541 list.as_str()
3542 }
3543}
3544
3545/// Trait-idiomatic *forward* projection on the two-list dep-graph
3546/// [`DepList`] closed-set typed enum from an *owned* input onto the
3547/// owned-[`String`] axis — routes byte-for-byte through the
3548/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3549/// every consumer that binds a [`DepList`] through the standard-library
3550/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3551/// axis reaches the same two-arm lifted
3552/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3553/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3554/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3555/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3556/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3557///
3558/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3559/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3560/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3561/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3562/// second-of-two-in-M2 per-child restart-decision axis, then onto
3563/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3564/// closed-set fieldless typed enum on the caixa surface, then onto
3565/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3566/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3567/// Rust's standard library does not carry a blanket
3568/// `impl<T: AsRef<str>> From<T> for String` (nor an
3569/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3570/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3571/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3572/// quadruple but not the owned-[`String`] axis forces every owned-string
3573/// call site through a `.to_string()` / `.as_str().to_owned()` /
3574/// `String::from(list.as_str())` detour whose type bounds have no
3575/// compile-time link to the substrate primitive.
3576///
3577/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3578/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3579/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3580/// share one vocabulary by construction — `PascalCase` on the three
3581/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3582/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3583/// emit and [`DepList::from_wire`] parse resolve through the same
3584/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3585/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3586/// (there is no wire/diagnostic axis split on this enum — both halves
3587/// of the round-trip route through the same two `pub const &str` values),
3588/// so the owned-[`String`] forward projection this impl exposes composes
3589/// directly with the paired trait-idiomatic reverse
3590/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3591/// borrow — no intermediate wire-vocab hop like the peer
3592/// [`crate::CaixaKind`] axis pair requires.
3593///
3594/// The remaining ten closed-set typed enums on the caixa substrate
3595/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3596/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3597/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3598/// this campaign — each carries the same paired [`AsRef<str>`] /
3599/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3600/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3601/// axis extends onto.
3602///
3603/// Pinned load-bearing by
3604/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3605/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3606/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3607/// witness) and
3608/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3609/// (cross-axis partition against the sibling owned-`&'static str` axis
3610/// and the [`ToString::to_string`] surface, a
3611/// `.iter().copied().map(String::from)` pipe witness over
3612/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3613/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3614/// borrow — composes directly without the wire-vocab intermediate hop
3615/// the peer [`crate::CaixaKind`] axis pair requires).
3616impl From<DepList> for String {
3617 fn from(list: DepList) -> String {
3618 list.as_str().to_owned()
3619 }
3620}
3621
3622/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3623/// projection on the two-list dep-graph [`DepList`] closed-set typed
3624/// enum — the fourth (and closing) corner of the
3625/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3626/// projection family on this enum, mirror of the peer M2 OTP-shape
3627/// [`From<&RestartStrategy> for String`] (579385f) and
3628/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3629/// closed the corner on the sibling supervisor-level restart-strategy
3630/// and per-child restart-decision enums. Routes byte-for-byte through
3631/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3632/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3633/// [`&DepList`] and needs an owned [`String`] — a future
3634/// `serde_json::Value::String(String::from(&list))` structured-payload
3635/// composer over a borrowed field, a future `Iterator::map` over
3636/// `&[DepList]` that projects to owned keys through
3637/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3638/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3639/// alone forces every call site through an explicit `.copied()` /
3640/// spurious [`Copy`] deref restatement rather than the direct trait-
3641/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3642/// that keys off a borrowed-iteration axis where dereferencing the list
3643/// would force an unnecessary `Copy` at every step, the future
3644/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3645/// per-list author-surface-tag diagnostic emit whose iteration axis is
3646/// borrowed by construction — reaches the same two-arm lifted
3647/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3648/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3649/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3650/// three other trait-idiomatic forward-projection impls
3651/// ([`From<DepList> for &'static str`],
3652/// [`From<&DepList> for &'static str`],
3653/// [`From<DepList> for String`]) already return.
3654///
3655/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3656/// owned-`String` output* forward-projection family opened on
3657/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3658/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3659/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3660/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3661/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3662/// standard library does not carry a blanket
3663/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3664/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3665/// typed enum that carries the paired `AsRef<str>` / `Display` /
3666/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3667/// `From<Self> for String` quintuple but not the borrowed-input owned-
3668/// [`String`] axis forces every borrowed-input owned-string call site
3669/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3670/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3671/// whose type bounds have no compile-time link to the substrate
3672/// primitive.
3673///
3674/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3675/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3676/// axis pairs (whose forward emit and reverse parse share one
3677/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3678/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3679/// [`DepList::from_wire`] parse resolve through the same lifted
3680/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3681/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3682/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3683/// tags — there is no wire/diagnostic axis split on this enum), so the
3684/// borrowed-input owned-[`String`] projection this impl exposes
3685/// composes directly with the paired trait-idiomatic reverse
3686/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3687/// borrow — no intermediate wire-vocab hop like the peer
3688/// [`crate::CaixaKind`] axis pair requires.
3689///
3690/// The remaining ten closed-set typed enums on the caixa substrate
3691/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3692/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3693/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3694/// are the future targets of this 2×2-completion campaign — each
3695/// carries the same paired quintuple that this borrowed-input owned-
3696/// [`String`] axis extends onto.
3697///
3698/// Pinned load-bearing by
3699/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3700/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3701/// emit-set through the borrowed-input surface) and
3702/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3703/// (cross-axis partition pin against the paired owned-input owned-
3704/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3705/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3706/// impl, and the sibling [`ToString::to_string`] surface routed through
3707/// [`std::fmt::Display`], plus a direct round-trip witness through
3708/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3709/// borrow that closes the two-way `&Self → String → Self` round-trip
3710/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3711/// reverse axis pair).
3712impl From<&DepList> for String {
3713 fn from(list: &DepList) -> String {
3714 list.as_str().to_owned()
3715 }
3716}
3717
3718/// Errors raised by [`Dep::validate`].
3719///
3720/// Mirrors the per-axis error families the other `:versao`-carrying
3721/// typed surfaces expose
3722/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3723/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3724/// [`crate::SupervisorError::EmptyChildVersion`] /
3725/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3726/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3727#[derive(Debug, Error, PartialEq, Eq)]
3728pub enum DepError {
3729 #[error(
3730 ":deps entry has empty :nome (every dep must name a target caixa; \
3731 omit the entry instead of carrying an empty name)"
3732 )]
3733 NomeEmpty,
3734 #[error(
3735 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3736 (the value flows verbatim as the target caixa's `:nome`, the rendered \
3737 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3738 value, and the resolver's checkout-directory leaf — each apiserver-side \
3739 schema rejects non-DNS-1123 names at admission time; use a lowercase \
3740 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3741 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3742 )]
3743 NomeInvalid { nome: String, reason: String },
3744 #[error(
3745 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3746 constraint that resolves through the lacre pipeline)"
3747 )]
3748 VersaoEmpty { nome: String },
3749 #[error(
3750 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3751 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3752 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3753 and `:children :versao` carry; the lacre pipeline resolves all three \
3754 through the same parser)"
3755 )]
3756 VersaoInvalid {
3757 nome: String,
3758 versao: String,
3759 reason: String,
3760 },
3761 #[error(
3762 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3763 (every git source must name a repo — use a `github:org/repo` \
3764 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3765 entire :fonte block to fall back to the default-host resolver \
3766 convention)"
3767 )]
3768 FonteRepoEmpty { nome: String },
3769 #[error(
3770 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3771 invalid value-shape: {reason} (the value flows verbatim into the \
3772 caixa-resolver's `git clone <repo>` subprocess invocation; every \
3773 documented form carries a `:` separator and no whitespace / \
3774 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3775 an `https://host/path` / `ssh://[user@]host/path` / \
3776 `git://host/path` / `file:///path` URL, or the `git@host:path` \
3777 scp-style SSH form)"
3778 )]
3779 FonteRepoShape {
3780 nome: String,
3781 repo: String,
3782 reason: String,
3783 },
3784 #[error(
3785 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3786 (set exactly one of :tag, :rev, or :branch so the resolver \
3787 can pick a reproducible commit; omit the entire :fonte block \
3788 to fall back to the default-host resolver convention, which \
3789 resolves the latest tag matching :versao)"
3790 )]
3791 FontePinMissing { nome: String },
3792 #[error(
3793 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3794 set ({pins}); exactly one of :tag, :rev, or :branch must be \
3795 set so the resolver's checkout target is unambiguous (the \
3796 resolver's silent precedence is :rev > :tag > :branch — if \
3797 you intended one specifically, drop the others)"
3798 )]
3799 FontePinAmbiguous { nome: String, pins: String },
3800 #[error(
3801 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3802 (a set pin must name a non-empty git ref; drop the {pin} key \
3803 entirely to fall through to another pin axis)"
3804 )]
3805 FontePinEmpty { nome: String, pin: String },
3806 #[error(
3807 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3808 value-shape: {reason} (the git porcelain enforces the same shape at \
3809 `git fetch` / `git checkout` time on every pin; use a leaf refname \
3810 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3811 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3812 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3813 prepends at clone time, and avoid abbreviated SHAs which are \
3814 ambiguous across repository history)"
3815 )]
3816 FontePinShape {
3817 nome: String,
3818 pin: String,
3819 value: String,
3820 reason: String,
3821 },
3822 #[error(
3823 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3824 (every path source must name a non-empty filesystem path; \
3825 omit the entire :fonte block to fall back to the default-host \
3826 resolver convention)"
3827 )]
3828 FonteCaminhoEmpty { nome: String },
3829 #[error(
3830 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3831 absolute (the lacre pipeline embeds the value verbatim in its \
3832 per-dep content-address `path:{caminho}` at \
3833 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3834 BLAKE3 closure differ across machines — defeating the \
3835 reproducibility contract that's load-bearing for CSE; express \
3836 the path relative to the caixa.lisp location, e.g. \
3837 \"../caixa-teia\" for a sibling workspace dep)"
3838 )]
3839 FonteCaminhoAbsolute { nome: String, caminho: String },
3840 #[error(
3841 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3842 with `~` (the leading-tilde is a shell-expansion convention, not a \
3843 POSIX path component — `Path::is_absolute` returns false on it, so \
3844 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3845 pipeline embeds the value verbatim in its per-dep content-address \
3846 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3847 caixa-resolver folds it through `Path::join` without `~`-expansion, \
3848 so the build looks for a literal `./{caminho}` subdirectory and \
3849 fails at resolve time far from the source caixa.lisp; even worse, a \
3850 future caixa-resolver pass that *does* expand `~` would silently \
3851 re-open the host-layout-leak the b94fd83 absolute gate closes — \
3852 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3853 runners with different `$HOME` layouts resolve to two distinct paths \
3854 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3855 determinism contract; express the path relative to the caixa.lisp \
3856 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3857 spell out the full relative path explicitly if a workstation-rooted \
3858 dep is genuinely intended)"
3859 )]
3860 FonteCaminhoTildeExpansion { nome: String, caminho: String },
3861 #[error(
3862 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3863 with `$` (the leading-`$` is a shell-variable-expansion convention, \
3864 not a POSIX path component — `Path::is_absolute` returns false on it \
3865 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3866 embeds the value verbatim in its per-dep content-address \
3867 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3868 caixa-resolver folds it through `Path::join` without `$`-expansion, \
3869 so the build looks for a literal `./{caminho}` subdirectory and \
3870 fails at resolve time far from the source caixa.lisp; even worse, a \
3871 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3872 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3873 invites) would silently re-open the host-layout-leak the b94fd83 \
3874 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3875 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3876 layouts resolve to two distinct paths for the byte-identical caixa, \
3877 defeating the THEORY.md §V.2 render-determinism contract; express \
3878 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3879 for a sibling workspace dep, or spell out the full relative path \
3880 explicitly if a workstation-rooted dep is genuinely intended)"
3881 )]
3882 FonteCaminhoVarExpansion { nome: String, caminho: String },
3883 #[error(
3884 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3885 with a space (the leading ASCII space `0x20` is the orthogonal \
3886 paste-from-aligned-doc footgun that silently passes \
3887 `Path::is_absolute` and every prior leading-byte arm — \
3888 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3889 `./ ../caixa-teia` subdirectory the resolver fails to find at \
3890 resolve time with a non-self-locating `No such file or directory` \
3891 error far from the source caixa.lisp; the lacre pipeline embeds \
3892 the value verbatim in its per-dep content-address `path:{caminho}` \
3893 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3894 semantic-identical caixa values (` ../caixa-teia` vs \
3895 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3896 workstations whose authors differ only in paste-from-aligned- \
3897 caixa.lisp-doc whitespace habits — the most insidious failure \
3898 mode the typed slot can carry (no error surfaces; the divergence \
3899 is invisible until two machines compare lacres), defeating the \
3900 THEORY.md §V.2 render-determinism contract. The canonical \
3901 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3902 a multi-entry `:deps` block sits at the same column — an author \
3903 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3904 the rendered alignment into a fresh entry preserves the leading \
3905 whitespace verbatim); peer `:fonte :repo` axis already rejects \
3906 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3907 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3908 `is_chart_description_shape`, `:licenca` via \
3909 `is_spdx_expression_shape`. Drop the leading space; express the \
3910 path as a bare relative single-token like \"../caixa-teia\")"
3911 )]
3912 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3913 #[error(
3914 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3915 with `-` (the canonical CLI-argument-injection footgun on the \
3916 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3917 its per-dep content-address `path:{caminho}` at \
3918 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3919 through `Path::join` looking for a literal `./{caminho}` \
3920 subdirectory. Every downstream subprocess that consumes the resolved \
3921 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3922 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3923 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3924 value as a CLI flag rather than a positional path when the invocation \
3925 does not carry a `--` argument-list terminator between the flag block \
3926 and the path (the common case at every porcelain entry point). The \
3927 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3928 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3929 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3930 CLI-arg-injection vector at every git porcelain entry point that \
3931 consumes a path or URL argument, peer with is_git_repo_url's \
3932 leading-`-` arm on the sibling `:fonte :repo` axis), \
3933 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3934 POSIX `std::path::Path` treats a leading `-` as a literal filename \
3935 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3936 for a literal `./-rf` subdirectory that fails at resolve time with a \
3937 non-self-locating `No such file or directory` error far from the \
3938 source caixa.lisp — but on any downstream shell-out without `--` the \
3939 reinterpretation is silent and the failure mode is arbitrary-\
3940 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3941 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3942 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3943 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3944 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3945 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3946 `:children :caixa`, `:deps :nome`, cluster names); \
3947 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3948 the feira `init` / `add <nome>` positional gate (868c191) rejects \
3949 leading `-` on the CLI positional itself. Express the path as a bare \
3950 relative single-token like \"../caixa-teia\" — the sibling-workspace \
3951 directory name carries no leading-hyphen semantic, and `./` / `../` \
3952 prefixes structurally partition the leading-byte set to safe values.)"
3953 )]
3954 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3955 #[error(
3956 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3957 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3958 every `std::fs` syscall routes the path through `CString::new` which \
3959 fails with `NulError` at resolve time; the lacre pipeline embeds the \
3960 value verbatim in its per-dep content-address `path:{caminho}` at \
3961 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3962 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3963 determinism contract — the canonical paste-from-multiline-doc \
3964 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3965 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3966 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3967 already gates against. Express the path as a relative single-line ASCII \
3968 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3969 )]
3970 FonteCaminhoControlChar {
3971 nome: String,
3972 caminho: String,
3973 byte: u8,
3974 },
3975 #[error(
3976 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3977 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3978 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3979 not the parent's sibling — and the caixa-resolver folds the value through \
3980 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3981 resolve time with a non-self-locating `No such file or directory` error far \
3982 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3983 primary path separator equal to `/`, so byte-identical caixa.lisp values \
3984 resolve to two distinct directories across runner OSes — the lacre pipeline \
3985 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3986 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3987 determinism contract via the cross-host-OS-separator divergence vector. The \
3988 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3989 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3990 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3991 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3992 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3993 \"../caixa-teia\" for a sibling workspace dep)"
3994 )]
3995 FonteCaminhoBackslash { nome: String, caminho: String },
3996 #[error(
3997 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3998 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3999 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4000 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4001 paste-from-shell-pipeline footgun where an author copies a `command > log` \
4002 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4003 as literal path-component bytes, so the resolver folds the value through \
4004 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4005 subdirectory and fails at resolve time with a non-self-locating `No such \
4006 file or directory` error far from the source caixa.lisp. The lacre pipeline \
4007 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4008 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4009 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4010 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4011 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4012 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4013 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4014 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4015 RFC-3986-reserved set. Express the path as a bare relative single-token like \
4016 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4017 redirection semantic.",
4018 ch = *byte as char
4019 )]
4020 FonteCaminhoShellRedirection {
4021 nome: String,
4022 caminho: String,
4023 byte: u8,
4024 },
4025 #[error(
4026 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4027 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4028 `|` as the pipe operator that wires one command's stdout to the next command's \
4029 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4030 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4031 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4032 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4033 treats `|` as a literal path-component byte, so the resolver folds the value \
4034 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4035 subdirectory and fails at resolve time with a non-self-locating `No such file or \
4036 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4037 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4038 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4039 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4040 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4041 subprocess-argument / shell-metachar injection surface every peer single-token-\
4042 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4043 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4044 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4045 workspace directory name carries no shell-pipe semantic."
4046 )]
4047 FonteCaminhoShellPipe { nome: String, caminho: String },
4048 #[error(
4049 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4050 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4051 / nushell — lexes `;` as the sequential-command terminator that fires the next \
4052 command regardless of the prior command's exit status, so `:caminho \
4053 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4054 footgun where an author copies a `cd path; do-thing` chain without trimming \
4055 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4056 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4057 literal path-component byte, so the resolver folds the value through \
4058 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4059 subdirectory and fails at resolve time with a non-self-locating `No such file \
4060 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4061 the value verbatim in its per-dep content-address `path:{caminho}` at \
4062 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4063 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4064 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4065 canonical shell-metachar injection surface every peer single-token-shaped \
4066 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4067 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4068 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4069 workspace directory name carries no shell-command-separator semantic."
4070 )]
4071 FonteCaminhoShellSemicolon { nome: String, caminho: String },
4072 #[error(
4073 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4074 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4075 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4076 terminator detaching the prior command and returning control immediately to \
4077 the prompt, double `&&` as the logical-AND list operator firing the next \
4078 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4079 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4080 sleep 1` background-launch one-liner or a `cd path && make install` build-\
4081 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4082 05c358e closed the sequential-command-separator vector, this arm closes the \
4083 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4084 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4085 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4086 byte lands in the BLAKE3 closure and rides into every shell-spawned \
4087 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4088 future operator-side `nix` spawn) as the canonical shell-metachar injection \
4089 surface every peer single-token-shaped typed slot already closes. The peer \
4090 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4091 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4092 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4093 shell-background / logical-AND semantic."
4094 )]
4095 FonteCaminhoShellBackground { nome: String, caminho: String },
4096 #[error(
4097 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4098 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4099 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4100 wrapper that runs the enclosed command and substitutes its standard-output \
4101 verbatim into the surrounding word, so a backticked `whoami` expands to the \
4102 current user's name and a backticked `cat /etc/passwd` expands to the file's \
4103 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4104 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4105 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4106 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4107 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4108 background / logical-AND vector, this arm closes the orthogonal command-\
4109 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4110 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4111 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4112 value verbatim in its per-dep content-address `path:{caminho}` at \
4113 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4114 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4115 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4116 shell-metachar injection surface every peer single-token-shaped typed slot \
4117 already closes. The peer `:entrada :paths` axis rejects the byte via \
4118 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4119 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4120 directory name carries no shell-command-substitution semantic."
4121 )]
4122 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4123 #[error(
4124 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4125 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4126 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4127 expansion wildcards: `*` matches any sequence of characters in a path component \
4128 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4129 canonical paste-from-shell-listing footgun where an author copies a \
4130 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4131 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4132 `std::path::Path` treats both bytes as literal path-component bytes, so the \
4133 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4134 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4135 locating `No such file or directory` error far from the source caixa.lisp. The \
4136 lacre pipeline embeds the value verbatim in its per-dep content-address \
4137 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4138 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4139 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4140 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4141 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4142 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4143 reserved set. Express the path as a bare relative single-token like \
4144 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4145 / pathname-expansion semantic.",
4146 ch = *byte as char
4147 )]
4148 FonteCaminhoShellGlob {
4149 nome: String,
4150 caminho: String,
4151 byte: u8,
4152 },
4153 #[error(
4154 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4155 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4156 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4157 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4158 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4159 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4160 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4161 arm closes the leading byte of — together the two arms now structurally exclude the \
4162 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4163 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4164 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4165 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4166 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4167 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4168 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4169 self-locating `No such file or directory` error far from the source caixa.lisp. The \
4170 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4171 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4172 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4173 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4174 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4175 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4176 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4177 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4178 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4179 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4180 subshell-grouping semantic.",
4181 ch = *byte as char
4182 )]
4183 FonteCaminhoShellSubshellGrouping {
4184 nome: String,
4185 caminho: String,
4186 byte: u8,
4187 },
4188 #[error(
4189 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4190 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4191 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4192 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4193 comma-separated members and `{{1..10}}` expands to the integer range — the \
4194 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4195 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4196 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4197 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4198 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4199 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4200 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4201 `std::path::Path` treats the byte as a literal path-component byte, so a \
4202 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4203 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4204 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4205 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4206 silently passes every prior arm and the resolver folds the value through \
4207 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4208 resolve time with a non-self-locating `No such file or directory` error far from \
4209 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4210 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4211 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4212 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4213 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4214 expansion / URI-Template-placeholder surface every peer single-token-shaped \
4215 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4216 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4217 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4218 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4219 directory name carries no shell-brace-expansion / URI-Template-placeholder \
4220 semantic; if two siblings actually need pinning, author two separate `:deps` \
4221 entries rather than one brace-expanded `:caminho` value.",
4222 ch = *byte as char
4223 )]
4224 FonteCaminhoShellBraceExpansion {
4225 nome: String,
4226 caminho: String,
4227 byte: u8,
4228 },
4229 #[error(
4230 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4231 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4232 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4233 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4234 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4235 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4236 glob every shell-history block carries; the bracket pair additionally carries the \
4237 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4238 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4239 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4240 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4241 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4242 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4243 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4244 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4245 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4246 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4247 leak) silently passes every prior arm and the resolver folds the value through \
4248 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4249 resolve time with a non-self-locating `No such file or directory` error far from \
4250 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4251 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4252 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4253 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4254 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4255 surface every peer single-token-shaped typed slot already closes. Express the path \
4256 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4257 directory name carries no shell-bracket-expansion / glob-character-class / array-\
4258 literal semantic; if a family of sibling caixas actually needs pinning, author \
4259 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4260 ch = *byte as char
4261 )]
4262 FonteCaminhoShellBracketExpansion {
4263 nome: String,
4264 caminho: String,
4265 byte: u8,
4266 },
4267 #[error(
4268 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4269 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4270 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4271 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4272 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4273 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4274 every path-with-embedded-whitespace paste block carries and the symmetric \
4275 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4276 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4277 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4278 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4279 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4280 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4281 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4282 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4283 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4284 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4285 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4286 production. POSIX `std::path::Path` treats the byte as a literal path-component \
4287 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4288 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4289 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4290 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4291 shape) silently passes every prior arm and the resolver folds the value through \
4292 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4293 resolve time with a non-self-locating `No such file or directory` error far from \
4294 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4295 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4296 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4297 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4298 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4299 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4300 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4301 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4302 `is_git_repo_url`). Express the path as a bare relative single-token like \
4303 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4304 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4305 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4306 quoting on the outer syntactic layer, so an inner quote pair would nest and \
4307 desugar to a broken layer).",
4308 ch = *byte as char
4309 )]
4310 FonteCaminhoShellQuoteGrouping {
4311 nome: String,
4312 caminho: String,
4313 byte: u8,
4314 },
4315 #[error(
4316 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4317 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4318 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4319 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4320 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4321 discarding the byte and everything after it to the end of the physical line \
4322 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
4323 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4324 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4325 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
4326 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4327 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4328 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4329 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4330 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4331 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4332 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4333 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4334 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4335 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4336 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
4337 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4338 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4339 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4340 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4341 fails at resolve time with a non-self-locating `No such file or directory` \
4342 error far from the source caixa.lisp — while every downstream shell / YAML / \
4343 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4344 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4345 scalar disagree with the resolver on which directory the value names. The \
4346 lacre pipeline embeds the value verbatim in its per-dep content-address \
4347 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4348 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4349 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4350 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4351 fragment-delimiter surface every peer single-token-shaped typed slot already \
4352 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4353 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4354 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4355 workspace directory name carries no shell-comment / URL-fragment / YAML-\
4356 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4357 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4358 and drop any `#fragment` tail entirely (fragment identifiers select \
4359 renderings, not directories, and `:caminho` names a directory).",
4360 ch = *byte as char
4361 )]
4362 FonteCaminhoShellComment {
4363 nome: String,
4364 caminho: String,
4365 byte: u8,
4366 },
4367 #[error(
4368 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4369 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4370 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4371 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4372 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4373 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4374 literally inside a URL value. The canonical paste-from-browser-address-bar \
4375 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4376 encoded README hyperlink / browser address bar / percent-encoded permalink \
4377 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4378 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4379 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4380 `std::path::Path` treats the byte as a literal path-component byte, so \
4381 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4382 resolve time with a non-self-locating `No such file or directory` error far \
4383 from the source caixa.lisp — while every downstream URL parser / shell printf \
4384 builtin / YAML directive parser silently reinterprets the byte to a different \
4385 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4386 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4387 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4388 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4389 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4390 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4391 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4392 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4393 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4394 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4395 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4396 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4397 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4398 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4399 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4400 printf-format-specifier / job-control-specifier surface every peer single-\
4401 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4402 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4403 `is_git_repo_url`). Express the path as a bare relative single-token like \
4404 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4405 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4406 any `%20` percent-encoded-space with a literal space then reject the whole \
4407 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4408 directory name never carries an embedded space in practice); drop any \
4409 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4410 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4411 ch = *byte as char
4412 )]
4413 FonteCaminhoUrlPercentEncoding {
4414 nome: String,
4415 caminho: String,
4416 byte: u8,
4417 },
4418 #[error(
4419 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4420 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4421 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4422 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4423 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4424 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4425 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4426 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4427 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4428 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4429 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4430 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4431 the byte is a first-class parser byte in nearly every config / templating / \
4432 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4433 `std::path::Path` treats the byte as a literal path-component byte, so the \
4434 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4435 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4436 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4437 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4438 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4439 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4440 subdirectory that fails at resolve time with a non-self-locating `No such file \
4441 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4442 the value verbatim in its per-dep content-address `path:{caminho}` at \
4443 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4444 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4445 time lock to two distinct BLAKE3 closures across two workstations whose \
4446 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4447 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4448 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4449 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4450 is the canonical CWE-78 shell-command-injection surface every peer single-\
4451 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4452 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4453 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4454 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4455 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4456 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4457 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4458 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4459 so every position — leading and embedded — is structurally rejected. Substitute \
4460 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4461 time, or express the path as a bare relative single-token like \
4462 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4463 variable-expansion / command-substitution / arithmetic-expansion semantic.",
4464 ch = *byte as char
4465 )]
4466 FonteCaminhoShellVariableExpansion {
4467 nome: String,
4468 caminho: String,
4469 byte: u8,
4470 },
4471 #[error(
4472 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4473 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4474 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4475 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4476 reference §9.3: `!command` re-runs the most recent history entry beginning with \
4477 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4478 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4479 and the substitution fires at every history-expansion-enabled shell context — \
4480 `set -o histexpand` is bash's default for interactive sessions and the layer \
4481 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4482 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4483 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4484 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4485 encodes it inside a query component via the 'special-query percent-encode set' \
4486 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4487 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4488 prefix — the paste-from-source-code idiom where an author copies \
4489 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4490 the string-literal boundary); the canonical English-typography emphasis / \
4491 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4492 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4493 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4494 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4495 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4496 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4497 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4498 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4499 repeat-prior-command paste idiom), the English-typography `:caminho \
4500 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4501 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4502 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4503 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4504 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4505 subdirectory that fails at resolve time with a non-self-locating `No such file \
4506 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4507 the value verbatim in its per-dep content-address `path:{caminho}` at \
4508 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4509 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4510 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4511 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4512 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4513 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4514 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4515 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4516 name carries no shell-history-expansion / bang-operator semantic; drop any \
4517 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4518 idiom; and drop any trailing English-typography exclamation mark that pasted \
4519 from prose.",
4520 ch = *byte as char
4521 )]
4522 FonteCaminhoShellHistoryExpansion {
4523 nome: String,
4524 caminho: String,
4525 byte: u8,
4526 },
4527 #[error(
4528 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4529 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4530 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4531 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4532 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4533 substitution' history operator that rewrites the prior command's `old` string to \
4534 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4535 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4536 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4537 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4538 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4539 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4540 literal value diverges from every downstream `feira tofu` curl-invocation / \
4541 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4542 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4543 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4544 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4545 `std::path::Path` treats `^` as a literal path-component byte, so \
4546 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4547 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4548 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4549 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4550 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4551 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4552 that fails at resolve time with a non-self-locating `No such file or directory` \
4553 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4554 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4555 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4556 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4557 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4558 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4559 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4560 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4561 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4562 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4563 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4564 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4565 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4566 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4567 drop any trailing `^` history-substitution-open fragment.",
4568 ch = *byte as char
4569 )]
4570 FonteCaminhoShellHistorySubstitution {
4571 nome: String,
4572 caminho: String,
4573 byte: u8,
4574 },
4575 #[error(
4576 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4577 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4578 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4579 value verbatim in its per-dep content-address `path:{caminho}` at \
4580 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4581 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4582 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4583 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4584 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4585 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4586 trailing `/`; every `:caminho` value names a sibling-workspace directory \
4587 already, so the trailing separator carries no information. Use \
4588 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4589 )]
4590 FonteCaminhoTrailingSlash { nome: String, caminho: String },
4591 #[error(
4592 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4593 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4594 apply the same set-not-multiset discipline; one package per table), and \
4595 two entries naming the same caixa carry two version constraints / source \
4596 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4597 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4598 silently overwrites the first at the resolver-side `concrete_versao` step, \
4599 and the dropped entry's pin / features never reach the closure — far from \
4600 the source caixa.lisp, with no field naming which `:deps` entry was the \
4601 silent loser. If two version constraints are genuinely needed (the rare \
4602 multi-version closure case the lacre pipeline doesn't yet support), the \
4603 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4604 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4605 )]
4606 DuplicateNome { nome: String, list: &'static str },
4607 #[error(
4608 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4609 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4610 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4611 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4612 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4613 with the canonical kebab-case feature name the target caixa declares."
4614 )]
4615 CaracteristicaEmpty { nome: String },
4616 #[error(
4617 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4618 feature name: {reason} (the value flows verbatim into Cargo's \
4619 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4620 parser enforces the same shape at `cargo metadata` time; use a single-token \
4621 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4622 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4623 an ASCII alphanumeric or `_`)"
4624 )]
4625 CaracteristicaInvalid {
4626 nome: String,
4627 caracteristica: String,
4628 reason: String,
4629 },
4630 #[error(
4631 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4632 every feature-flag list keys its entries by name (Cargo's \
4633 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4634 per feature per dep), and two entries naming the same feature are a redundant \
4635 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4636 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4637 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4638 feature once regardless of declaration count, so the duplicate's pin / position never \
4639 reaches the closure with no field naming the silent loser. One entry per feature per \
4640 dep; if two distinct features are intended, name each verbatim."
4641 )]
4642 CaracteristicaDuplicate {
4643 nome: String,
4644 caracteristica: String,
4645 },
4646 #[error(
4647 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4648 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4649 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4650 rejects mid-traversal far from the source caixa.lisp or recurses on until \
4651 it exhausts its stack). Every :nome is globally-unique substrate identity, \
4652 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4653 *is* the parent itself, not a coincidentally-named peer. Drop the \
4654 self-referential dep entry — to reference code from this caixa, use \
4655 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4656 referencing the caixa's own code surface) instead."
4657 )]
4658 DepIsSelf { nome: String, list: &'static str },
4659}
4660
4661// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4662// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4663// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4664// variant — the paired `{ nome: String, caminho: String }` two-slot family
4665// on [`DepError`], sibling of the peer
4666// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4667// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4668// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4669// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4670// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4671// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4672// `{ de, para, wit, expected }`), and
4673// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4674// variants on `{ de, para, <field>: String, reason: String }`) on the
4675// `AplicacaoError` envelopes, the peer
4676// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4677// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4678// (0419438, 4 variants on `{ caixa, kind, slots }`),
4679// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4680// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4681// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4682// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4683// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4684// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4685// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4686// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4687//
4688// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4689// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4690// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4691// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4692// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4693// CommandSubstitution}` on the four single-byte shell operators; and the
4694// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4695// opened the identical `DepError::FonteCaminho<Variant> { nome:
4696// nome.to_string(), caminho: caminho.to_string() }` four-line
4697// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4698// — the exact "same block re-inlined at every consumer" shape the PRIME
4699// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4700// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4701// families each closed on their sibling envelopes. The eleven variants
4702// share one `{ nome: String, caminho: String }` shape, so the fold routes
4703// each wire-up site through one dispatch per typed variant.
4704//
4705// The macro below generates one `#[must_use]` inherent constructor per
4706// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4707// wire-up site collapses onto one dispatch:
4708// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4709// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4710// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4711// once — inside the macro — rather than at every wire-up site.
4712//
4713// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4714// shapes at the per-byte-classification arms — the
4715// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4716// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4717// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4718// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4719// cluster — carry an additional `byte: u8` naming the offending byte and
4720// so would break the uniform-two-field routing this macro promises. They
4721// instead fold onto the sibling three-field envelope through
4722// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4723// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4724// two-slot family is the `byte: u8` classification the arms carry. The
4725// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4726// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4727// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4728// envelope.
4729//
4730// Every future consumer that wants to construct one of these eleven
4731// variants outside the current in-crate [`DepSource::validate_caminho`]
4732// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4733// at lacre-resolve time re-checking the same value-shape axes the resolver
4734// consumes, a future `feira validate --deps` per-caixa admission verb
4735// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4736// rejecting a `:caminho` value against a cluster-local snapshot) now
4737// reaches each variant through one call rather than re-inlining the
4738// four-line struct-literal in lockstep with the eleven in-crate wire-up
4739// sites.
4740macro_rules! fonte_caminho_ctors {
4741 ($($ctor:ident => $variant:ident),* $(,)?) => {
4742 impl DepError {
4743 $(
4744 #[doc = concat!(
4745 "Construct a [`DepError::",
4746 stringify!($variant),
4747 "`] naming the offending `:deps :nome` + `:fonte ",
4748 "(:tipo path …) :caminho` pair. Folds the uniform ",
4749 "`Self::",
4750 stringify!($variant),
4751 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4752 "two-slot struct-literal onto one substrate primitive so ",
4753 "every [`DepSource::validate_caminho`] wire-up on this ",
4754 "variant reads through one dispatch rather than the ",
4755 "pre-lift four-line open-coded block."
4756 )]
4757 #[must_use]
4758 pub fn $ctor(nome: &str, caminho: &str) -> Self {
4759 Self::$variant {
4760 nome: nome.to_string(),
4761 caminho: caminho.to_string(),
4762 }
4763 }
4764 )*
4765 }
4766 };
4767}
4768
4769fonte_caminho_ctors! {
4770 fonte_caminho_absolute => FonteCaminhoAbsolute,
4771 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4772 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4773 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4774 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4775 fonte_caminho_backslash => FonteCaminhoBackslash,
4776 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4777 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4778 fonte_caminho_shell_background => FonteCaminhoShellBackground,
4779 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4780 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4781}
4782
4783// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4784// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4785// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4786// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4787// three-slot family on [`DepError`], strict sibling of the peer
4788// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4789// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4790// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4791// axis broke its uniform-two-field routing — the exact "future compounding
4792// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4793// here. Third fold family on this `DepError` envelope, sibling of the peer
4794// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4795// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4796// same enum.
4797//
4798// Each of the twelve wire-up sites on this shape (the control-byte arm
4799// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4800// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4801// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4802// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4803// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4804// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4805// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4806// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4807// `FonteCaminhoShellHistoryExpansion` on `!`, and
4808// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4809// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4810// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4811// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4812// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4813// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4814// closed on the sibling two-field envelope of this same enum. The twelve
4815// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4816// the fold routes each wire-up site through one dispatch per typed variant.
4817//
4818// The macro below generates one `#[must_use]` inherent constructor per
4819// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4820// so every wire-up site collapses onto one dispatch:
4821// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4822// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4823// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4824// `byte`) is spelled once — inside the macro — rather than at every wire-up
4825// site.
4826//
4827// Every future consumer that wants to construct one of these twelve
4828// variants outside the current in-crate [`DepSource::validate_caminho`]
4829// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4830// at lacre-resolve time re-checking the same value-shape axes the resolver
4831// consumes, a future `feira validate --deps` per-caixa admission verb
4832// re-checking the `:fonte :caminho` axis against the shell-metachar
4833// classification bytes this cluster catches, a per-lacre overlay resolver
4834// rejecting a `:caminho` value against a cluster-local snapshot) now
4835// reaches each variant through one call rather than re-inlining the
4836// five-line struct-literal in lockstep with the twelve in-crate wire-up
4837// sites.
4838macro_rules! fonte_caminho_byte_ctors {
4839 ($($ctor:ident => $variant:ident),* $(,)?) => {
4840 impl DepError {
4841 $(
4842 #[doc = concat!(
4843 "Construct a [`DepError::",
4844 stringify!($variant),
4845 "`] naming the offending `:deps :nome` + `:fonte ",
4846 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4847 "classification. Folds the uniform `Self::",
4848 stringify!($variant),
4849 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4850 "byte }` three-slot struct-literal onto one substrate ",
4851 "primitive so every [`DepSource::validate_caminho`] wire-up ",
4852 "on this variant reads through one dispatch rather than ",
4853 "the pre-lift five-line open-coded block."
4854 )]
4855 #[must_use]
4856 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4857 Self::$variant {
4858 nome: nome.to_string(),
4859 caminho: caminho.to_string(),
4860 byte,
4861 }
4862 }
4863 )*
4864 }
4865 };
4866}
4867
4868fonte_caminho_byte_ctors! {
4869 fonte_caminho_control_char => FonteCaminhoControlChar,
4870 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4871 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4872 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4873 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4874 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4875 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4876 fonte_caminho_shell_comment => FonteCaminhoShellComment,
4877 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4878 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4879 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4880 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4881}
4882
4883// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4884// single-slot struct-variant wire-up sites scattered across
4885// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4886// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4887// substrate primitive per typed variant — the paired `{ nome: String }`
4888// single-slot family on [`DepError`], sibling of the peer
4889// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4890// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4891// the same enum, and of the peer
4892// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4893// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4894// axis. Second fold family on this `DepError` envelope, and the first on
4895// the single-`{ nome }` shape.
4896//
4897// The five wire-up sites this fold closes each opened the identical
4898// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4899// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4900// local — the exact "same block re-inlined at every consumer" shape the
4901// PRIME DIRECTIVE names as a bug. The five variants share one
4902// `{ nome: String }` shape, so the fold routes each wire-up site through
4903// one dispatch per typed variant.
4904//
4905// The macro below generates one `#[must_use]` inherent constructor per
4906// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4907// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4908// pre-lift struct-literal on the same `&str` fixture. The uniform
4909// one-field construction (`nome.to_string()`) is spelled once — inside
4910// the macro — rather than at every wire-up site. Callers that hold a
4911// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4912// and lets the macro-owned `.to_string()` produce the fresh owning copy
4913// the enum variant needs; the semantics collapse onto the same
4914// `.clone()`-equivalent one this fold replaces at every site.
4915//
4916// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4917// on the same envelope stays on its pre-lift open-coded wire-up shape —
4918// it carries no `nome` field (the offending `:nome` value *is* the empty
4919// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4920// signature this macro promises does not apply. Every future consumer
4921// that wants to construct one of these five variants outside the current
4922// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4923// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4924// re-validator at lacre-resolve time, a future `feira validate --deps`
4925// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4926// these empty-value shapes against a cluster-local snapshot) now reaches
4927// each variant through one call rather than re-inlining the three-line
4928// struct-literal in lockstep with the five in-crate wire-up sites.
4929macro_rules! dep_nome_only_ctors {
4930 ($($ctor:ident => $variant:ident),* $(,)?) => {
4931 impl DepError {
4932 $(
4933 #[doc = concat!(
4934 "Construct a [`DepError::",
4935 stringify!($variant),
4936 "`] naming the offending `:deps :nome`. Folds the ",
4937 "uniform `Self::",
4938 stringify!($variant),
4939 " { nome: nome.to_string() }` one-field ",
4940 "struct-literal onto one substrate primitive so every ",
4941 "in-crate wire-up on this variant reads through one ",
4942 "dispatch rather than the pre-lift three-line ",
4943 "open-coded block."
4944 )]
4945 #[must_use]
4946 pub fn $ctor(nome: &str) -> Self {
4947 Self::$variant { nome: nome.to_string() }
4948 }
4949 )*
4950 }
4951 };
4952}
4953
4954dep_nome_only_ctors! {
4955 versao_empty => VersaoEmpty,
4956 fonte_repo_empty => FonteRepoEmpty,
4957 fonte_pin_missing => FontePinMissing,
4958 fonte_caminho_empty => FonteCaminhoEmpty,
4959 caracteristica_empty => CaracteristicaEmpty,
4960}
4961
4962// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4963// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4964// [`crate::manifest::Caixa::validate_deps`] +
4965// [`validate_no_self_dep`] onto one substrate-primitive family per
4966// typed variant — the `DepError`-side siblings of the peer
4967// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4968// on the `SupervisorError { caixa: String }` one-slot envelope and of
4969// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4970// `DepError { nome: String }` one-slot envelope. The two variants
4971// carry the same `{ nome: String, list: &'static str }` two-slot
4972// shape: the `nome` field names the offending dep the diagnostic
4973// points the author back at, and the `list` field carries the
4974// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4975// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4976// [`validate_deps`] arms, and via the paired
4977// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4978// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4979// canonicals on the [`validate_no_self_dep`] arm) so the author can
4980// grep their caixa.lisp for the offending list block in one edit.
4981//
4982// Each of the four wire-up sites opened the same struct-literal
4983// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4984// two-line block — the exact "same block re-inlined at every
4985// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4986// altitude the peer `DepError` / `SupervisorError` /
4987// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4988// already closed on their sibling envelopes. The two `#[must_use]`
4989// inherent constructors below fold each wire-up onto one dispatch:
4990// `DepError::duplicate_nome(<nome>, <list>)` and
4991// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4992// pre-lift struct-literal on the same scalar fixtures. The `list:
4993// &'static str` parameter (not `impl Into<String>`) preserves the
4994// exact wire tag every consumer already passes verbatim — no
4995// downstream diagnostic reshaping at the lift, matching the peer
4996// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4997// contract each wire-up site already keys off.
4998macro_rules! dep_nome_list_ctors {
4999 ($($ctor:ident => $variant:ident),* $(,)?) => {
5000 impl DepError {
5001 $(
5002 #[doc = concat!(
5003 "Construct a [`DepError::",
5004 stringify!($variant),
5005 "`] naming the offending `:deps :nome` and the ",
5006 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5007 "the diagnostic points the author back at. Folds ",
5008 "the uniform `Self::",
5009 stringify!($variant),
5010 " { nome: nome.to_string(), list }` two-field ",
5011 "struct-literal onto one substrate primitive so ",
5012 "every in-crate wire-up on this variant reads ",
5013 "through one dispatch rather than the pre-lift ",
5014 "open-coded struct-literal block."
5015 )]
5016 #[must_use]
5017 pub fn $ctor(nome: &str, list: &'static str) -> Self {
5018 Self::$variant { nome: nome.to_string(), list }
5019 }
5020 )*
5021 }
5022 };
5023}
5024
5025dep_nome_list_ctors! {
5026 duplicate_nome => DuplicateNome,
5027 dep_is_self => DepIsSelf,
5028}
5029
5030// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5031// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5032// <value>.to_string(), reason }` struct-variant wire-up sites at
5033// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5034// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5035// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5036// primitive family per typed variant — the `DepError`-side siblings of the
5037// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5038// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5039// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5040// the two-slot `{ nome, caminho }` envelope, and
5041// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5042// caminho, byte }` envelope. The three variants share the same
5043// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5044// the `nome` field names the offending dep the diagnostic points the
5045// author back at, the middle `<axis>: String` field carries the offending
5046// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5047// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5048// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5049// field carries the parser-shaped rejection sentence the paired
5050// [`crate::render::require_valid_versao_requirement`] /
5051// [`crate::render::is_git_repo_url`] /
5052// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5053// axis-field name differs across variants (`versao` / `repo` /
5054// `caracteristica`) so the ctor family below takes the axis field name as
5055// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5056// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5057// -> Self` inherent constructor per typed variant that spells the uniform
5058// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5059// `reason` forwarded owned) exactly once. Peer of the sibling
5060// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5061// family on the `AplicacaoError` envelope's mirror-symmetric
5062// `{ <field>: String, reason: String }` two-slot shape — same
5063// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5064// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5065// envelope keys off (every `DepError` variant carries the offending
5066// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5067// offending block in one edit).
5068//
5069// The three wire-up sites this fold closes are:
5070// - [`DepSource::validate`]'s `:repo` value-shape arm
5071// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5072// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5073// rejects the offending URL);
5074// - [`Dep::validate`]'s `:versao` requirement-shape arm
5075// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5076// self.versao_requirement().to_string(), reason }` inside the
5077// [`crate::render::require_valid_versao_requirement`] callback pair);
5078// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5079// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5080// caracteristica: c.clone(), reason })` after
5081// [`crate::render::is_cargo_feature_name`] rejects the offending
5082// feature-name).
5083//
5084// Each opened the identical five-line struct-literal against the same
5085// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5086// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5087// same altitude the peer four already-lifted `DepError` ctor families
5088// closed on their sibling shape-envelopes. The three variant / axis-field
5089// discriminators are the only things that vary between them; the rest of
5090// the struct-literal is a byte-for-byte re-inline.
5091//
5092// Every future consumer wanting to raise one of these three diagnostics
5093// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5094// time re-checking each declared dep against the same requirement +
5095// git-URL + feature-name value-shape cascade, a future `feira validate
5096// --deps` per-caixa admission verb re-running the shape gates on demand,
5097// a per-lacre overlay resolver rejecting an author-supplied dep against a
5098// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5099// the five-line struct-literal in lockstep with the three in-crate
5100// wire-up sites.
5101macro_rules! dep_nome_axis_reason_ctors {
5102 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5103 impl DepError {
5104 $(
5105 #[doc = concat!(
5106 "Construct a [`DepError::",
5107 stringify!($variant),
5108 "`] naming the offending `:deps :nome`, the offending ",
5109 "`:", stringify!($axis), "` axis value, and the ",
5110 "parser-shaped rejection `reason`. Folds the uniform ",
5111 "`Self::",
5112 stringify!($variant),
5113 " { nome: nome.to_string(), ",
5114 stringify!($axis),
5115 ": ",
5116 stringify!($axis),
5117 ".to_string(), reason }` three-field struct-literal ",
5118 "onto one substrate primitive so every in-crate ",
5119 "wire-up on this variant reads through one dispatch ",
5120 "rather than the pre-lift five-line open-coded block. ",
5121 "The `nome: &str` and `",
5122 stringify!($axis),
5123 ": &str` parameters accept `&str` literals and ",
5124 "`&String` (via Deref coercion) so every existing ",
5125 "wire-up threads through the ctor without a ",
5126 "pre-conversion; the `reason: String` parameter takes ",
5127 "an owned `String` (not `impl Into<String>`) matching ",
5128 "the paired `crate::render::*` predicate's ",
5129 "`Result<(), String>` return shape every wire-up ",
5130 "already holds owned at the call site."
5131 )]
5132 #[must_use]
5133 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5134 Self::$variant {
5135 nome: nome.to_string(),
5136 $axis: $axis.to_string(),
5137 reason,
5138 }
5139 }
5140 )*
5141 }
5142 };
5143}
5144
5145dep_nome_axis_reason_ctors! {
5146 versao_invalid => VersaoInvalid { versao },
5147 fonte_repo_shape => FonteRepoShape { repo },
5148 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5149}
5150
5151// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5152// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5153// <value>.to_string() }` struct-variant wire-up sites at
5154// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5155// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5156// per-entry set-not-multiset dedup closure onto one substrate-primitive
5157// family per typed variant — the missing two-slot rung on the
5158// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5159// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5160// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5161// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5162// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5163// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5164// symmetric sibling of the peer
5165// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5166// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5167// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5168// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5169// owned altitude the `DepError` envelope keys off (every `DepError`
5170// variant carries the offending `:deps :nome` verbatim so the author
5171// can grep their caixa.lisp for the offending block in one edit). The
5172// three variants share the same `{ nome: String, <axis>: String }`
5173// two-slot shape: the `nome` field names the offending dep the
5174// diagnostic points the author back at, and the middle `<axis>:
5175// String` field carries the offending per-envelope axis value verbatim
5176// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5177// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5178// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5179// The middle axis-field name differs across variants (`pin` / `pins` /
5180// `caracteristica`) so the ctor family below takes the axis field name
5181// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5182// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5183// Self` inherent constructor per typed variant that spells the
5184// uniform two-field construction (`nome.to_string()` /
5185// `<axis>.to_string()`) exactly once.
5186//
5187// The three wire-up sites this fold closes are:
5188// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5189// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5190// pin.to_string() });` inside the `set.len() == 1` branch after the
5191// `is_some_and(String::is_empty)` iterator);
5192// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5193// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5194// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5195// - [`Dep::validate_caracteristicas`]'s per-entry
5196// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5197// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5198// [`crate::render::insert_first_seen`]).
5199//
5200// Each opened the identical four-line struct-literal against the same
5201// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5202// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5203// same altitude the peer four already-lifted `DepError` ctor families
5204// closed on their sibling shape-envelopes. The three variant / axis-
5205// field discriminators are the only things that vary between them;
5206// the rest of the struct-literal is a byte-for-byte re-inline.
5207//
5208// Every future consumer wanting to raise one of these three
5209// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5210// at lacre-resolve time re-checking each declared dep against the
5211// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5212// set-not-multiset cascade, a future `feira validate --deps` per-
5213// caixa admission verb re-running the shape gates on demand, a
5214// per-lacre overlay resolver rejecting an author-supplied dep against
5215// a cluster-local snapshot the M4 CR materializer projects) now
5216// reaches one dispatch rather than re-inlining the four-line struct-
5217// literal in lockstep with the three in-crate wire-up sites.
5218macro_rules! dep_nome_axis_ctors {
5219 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5220 impl DepError {
5221 $(
5222 #[doc = concat!(
5223 "Construct a [`DepError::",
5224 stringify!($variant),
5225 "`] naming the offending `:deps :nome` and the ",
5226 "offending `:", stringify!($axis), "` axis value. ",
5227 "Folds the uniform `Self::",
5228 stringify!($variant),
5229 " { nome: nome.to_string(), ",
5230 stringify!($axis),
5231 ": ",
5232 stringify!($axis),
5233 ".to_string() }` two-field struct-literal onto one ",
5234 "substrate primitive so every in-crate wire-up on ",
5235 "this variant reads through one dispatch rather than ",
5236 "the pre-lift four-line open-coded block. Both `nome: ",
5237 "&str` and `",
5238 stringify!($axis),
5239 ": &str` parameters accept `&str` literals and ",
5240 "`&String` (via Deref coercion) so every existing ",
5241 "wire-up threads through the ctor without a pre-",
5242 "conversion."
5243 )]
5244 #[must_use]
5245 pub fn $ctor(nome: &str, $axis: &str) -> Self {
5246 Self::$variant {
5247 nome: nome.to_string(),
5248 $axis: $axis.to_string(),
5249 }
5250 }
5251 )*
5252 }
5253 };
5254}
5255
5256dep_nome_axis_ctors! {
5257 fonte_pin_empty => FontePinEmpty { pin },
5258 fonte_pin_ambiguous => FontePinAmbiguous { pins },
5259 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5260}
5261
5262// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5263// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5264// struct-variant wire-up sites at [`DepSource::validate`]'s
5265// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5266// the `DepError` envelope — the last open-coded ctor site remaining on
5267// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5268// carries, and the single-variant sibling of the peer four already-
5269// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5270// on the two-slot `{ nome, caminho }` envelope,
5271// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5272// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5273// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5274// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5275// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5276// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5277// `{ …, value: String, reason: String }` payload shape, one axis
5278// removed at the `nome`-only-owner altitude the `DepError` envelope
5279// keys off (no `edge_pair()` de/para pair).
5280//
5281// The two wire-up sites this fold closes are the paired refname-pin
5282// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5283// pin: pin.to_string(), value: v.clone(), reason }` inside the
5284// `[(":tag", tag), (":branch", branch)]` iterator against
5285// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5286// (`|| DepError::FontePinShape { nome: nome.to_string(),
5287// pin: ":rev".to_string(), value: v.clone(), reason }` against
5288// [`crate::render::is_git_oid`]) — each opened the identical
5289// `DepError::FontePinShape { … }` six-line struct-literal against the
5290// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5291// tuple, the exact "same block re-inlined at every consumer" shape
5292// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5293// the only thing that varies between them (`":tag"`/`":branch"` on
5294// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5295// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5296// route through the same ctor because their `pin` field carries the
5297// author-surface tag verbatim (matching the `FontePinEmpty` /
5298// `FontePinAmbiguous` sibling variants' `pin: String` axis
5299// convention), so the offending author can grep their caixa.lisp for
5300// the offending `:tag "<value>"` / `:branch "<value>"` /
5301// `:rev "<value>"` literal in one edit.
5302//
5303// The single ctor below folds each wire-up onto one dispatch:
5304// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5305// the pre-lift struct-literal on the same `(&str, &str, &str,
5306// String)` fixture. The uniform four-field construction
5307// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5308// `reason` forwarded owned) is spelled once here rather than at every
5309// wire-up site. The `reason: String` field takes an owned `String`
5310// (not `impl Into<String>`) matching the two call sites' pre-existing
5311// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5312// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5313// predicates return `Result<(), String>`, so the caller always holds
5314// an owned `String` at the wire-up site and threading it through the
5315// ctor without a `.into()` shim keeps the routing shape byte-equal to
5316// the pre-lift block. The `value: &str` parameter accepts both `&str`
5317// literals (unused today) and `&String` (from the caller-held
5318// `v: &String` on each arm, via Deref coercion), so every existing
5319// wire-up threads through the ctor without a pre-conversion.
5320//
5321// Every future consumer that wants to construct this variant outside
5322// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5323// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5324// re-checking the same value-shape axes the resolver consumes, a
5325// future `feira validate --deps` per-caixa admission verb re-checking
5326// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5327// resolver rejecting a git-pin value against a cluster-local
5328// snapshot) now reaches this variant through one call rather than
5329// re-inlining the six-line struct-literal in lockstep with the two
5330// in-crate wire-up sites.
5331impl DepError {
5332 /// Construct a [`DepError::FontePinShape`] naming the offending
5333 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5334 /// axis tag, the offending value, and the parser-shaped `reason`.
5335 /// Folds the uniform
5336 /// `Self::FontePinShape { nome: nome.to_string(),
5337 /// pin: pin.to_string(), value: value.to_string(), reason }`
5338 /// four-field struct-literal onto one substrate primitive so
5339 /// every [`DepSource::validate`] wire-up on this variant reads
5340 /// through one dispatch rather than the pre-lift six-line
5341 /// open-coded block. The `nome` string threads verbatim from
5342 /// [`Dep::nome`] at the call site; the `pin` string carries the
5343 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5344 /// `value` string carries the offending refname / hex-OID
5345 /// verbatim; and `reason` forwards the owned `String` returned
5346 /// by [`crate::render::is_git_ref_name`] /
5347 /// [`crate::render::is_git_oid`] without a `.into()` shim.
5348 #[must_use]
5349 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5350 Self::FontePinShape {
5351 nome: nome.to_string(),
5352 pin: pin.to_string(),
5353 value: value.to_string(),
5354 reason,
5355 }
5356 }
5357
5358 /// Construct a [`DepError::NomeInvalid`] naming the offending
5359 /// `:deps :nome` byte-string and the parser-shaped rejection
5360 /// `reason` returned by [`crate::render::is_dns_1123_label`].
5361 ///
5362 /// Folds the uniform
5363 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5364 /// struct-literal onto one substrate primitive so every wire-up on
5365 /// this variant reads through one dispatch rather than the pre-lift
5366 /// four-line open-coded `DepError::NomeInvalid { nome:
5367 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5368 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5369 /// ctor-family ladder (`{ nome }` one-slot →
5370 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5371 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5372 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5373 /// `{ nome, <axis>: String, reason: String }` three-slot →
5374 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5375 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5376 /// — the sole variant on the envelope carrying the
5377 /// `{ nome: String, reason: String }` two-slot shape without a
5378 /// middle axis, matching the peer
5379 /// [`crate::manifest::ManifestError::NomeInvalid`] +
5380 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5381 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5382 /// four-axis DNS-1123 caixa-identifier diagnostic family the
5383 /// existing `nome_invalid_diagnostic_carries_offending_name` test
5384 /// pins on this envelope.
5385 ///
5386 /// The `nome: &str` parameter accepts `&str` literals and `&String`
5387 /// (via Deref coercion) so the sole in-crate wire-up threads through
5388 /// the ctor without a pre-conversion; the `reason: String`
5389 /// parameter takes an owned `String` (not `impl Into<String>`)
5390 /// matching the [`crate::render::is_dns_1123_label`] predicate's
5391 /// `Result<(), String>` return shape the sole wire-up site already
5392 /// holds owned at the call site, keeping the routing byte-equal to
5393 /// the pre-lift block. Same owned-`String`-forward `reason` payload
5394 /// discipline as the sibling three-slot family
5395 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5396 /// and the four-slot [`DepError::fonte_pin_shape`] on
5397 /// `{ nome, pin, value, reason }`.
5398 ///
5399 /// Every future consumer that raises the same diagnostic outside
5400 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5401 /// re-validator at lacre-resolve time re-checking each declared
5402 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5403 /// side schema uses (the `:nome` value flows verbatim as the target
5404 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5405 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5406 /// checkout-directory leaf), a future `feira validate --deps`
5407 /// per-caixa admission verb re-running the shape gate on demand, a
5408 /// per-lacre overlay resolver rejecting an author-supplied dep's
5409 /// `:nome` against a cluster-local snapshot the M4 CR materializer
5410 /// projects, a future authoring-surface widening the field into a
5411 /// `(String, Vec<Suggestion>)` pair carrying a
5412 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5413 /// variant through one call rather than re-inlining the four-line
5414 /// struct-literal in lockstep with the one in-crate wire-up site.
5415 #[must_use]
5416 pub fn nome_invalid(nome: &str, reason: String) -> Self {
5417 Self::NomeInvalid {
5418 nome: nome.to_string(),
5419 reason,
5420 }
5421 }
5422}
5423
5424#[allow(clippy::trivially_copy_pass_by_ref)]
5425fn is_false(b: &bool) -> bool {
5426 !*b
5427}
5428
5429#[cfg(test)]
5430mod tests {
5431 use super::*;
5432
5433 #[test]
5434 fn registry_dep_is_minimal() {
5435 let d = Dep::simple("caixa-teia", "^0.1");
5436 assert_eq!(d.nome, "caixa-teia");
5437 assert_eq!(d.versao, "^0.1");
5438 assert!(d.fonte.is_none());
5439 assert!(!d.opcional());
5440 assert!(d.caracteristicas().is_empty());
5441 }
5442
5443 #[test]
5444 fn dep_string_scalar_accessor_pair_is_const_fn() {
5445 // Fail-before-pass-after pin on [`Dep::nome`] +
5446 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5447 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5448 // entry's [`String`] storage through the `pub const fn`
5449 // [`String::as_str`] (const-stable since Rust 1.87, well
5450 // within the workspace MSRV) — any future accidental
5451 // downgrade to non-`const` fails the corresponding
5452 // `<name>_via_const_fn` wrapper at caixa-core build time with
5453 // E0015 (`cannot call non-const method`), strictly stronger
5454 // than a runtime `assert!`. Sibling of the peer
5455 // per-M2/M3/universal-axis `String → &str` scalar-accessor
5456 // family pins on the sibling `const`-eval-surface passes
5457 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5458 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5459 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5460 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5461 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5462 // [`crate::aplicacao::Entrada::destination`] at the M3
5463 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5464 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5465 // M2 supervisor-tree axis,
5466 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5467 // M2 upgrade axis, and the per-`:contratos`
5468 // [`crate::aplicacao::WitContract::source`] /
5469 // [`crate::aplicacao::WitContract::destination`] /
5470 // [`crate::aplicacao::WitContract::world_ref`] trio the
5471 // sibling pin at 279823b already anchors).
5472 const fn nome_via_const_fn(d: &Dep) -> &str {
5473 d.nome()
5474 }
5475 const fn versao_via_const_fn(d: &Dep) -> &str {
5476 d.versao_requirement()
5477 }
5478 for (nome, versao) in [
5479 ("caixa-teia", "^0.1"),
5480 ("caixa-mesh", "~0.2.3"),
5481 ("caixa-helm", "*"),
5482 ] {
5483 let d = Dep::simple(nome, versao);
5484 assert_eq!(nome_via_const_fn(&d), d.nome());
5485 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5486 assert_eq!(d.nome(), nome);
5487 assert_eq!(d.versao_requirement(), versao);
5488 }
5489 }
5490
5491 #[test]
5492 fn dep_outer_accessor_family_is_const_fn() {
5493 // Fail-before-pass-after pin on [`Dep::fonte`] +
5494 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5495 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5496 // entry's composite / list storage through a `pub const fn`
5497 // stdlib method (`Option::<DepSource>::as_ref` /
5498 // `Vec::<String>::as_slice`, both const-stable since Rust
5499 // 1.83, well within the workspace MSRV). Any future
5500 // accidental downgrade to non-`const` fails the corresponding
5501 // `<name>_via_const_fn` wrapper at caixa-core build time with
5502 // E0015 (`cannot call non-const method`), strictly stronger
5503 // than a runtime `assert!` and side-stepping the destructor-
5504 // in-const restriction the `Dep` fixture's `String` /
5505 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5506 // direct-`const _: () = assert!(...)` residence.
5507 //
5508 // Peer of the sibling per-`Dep` scalar-accessor pair pin
5509 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5510 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5511 // the `const`-eval-surface discipline onto the composite-
5512 // reference and slice-return arms of the outer-`Dep` accessor
5513 // family, closing the four-slot outer surface (`:nome` +
5514 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5515 // posture. The `:opcional` `bool` arm already carries the
5516 // posture through [`Dep::opcional`]'s prior `pub const fn`
5517 // declaration, so this pin lands the last two unlifted
5518 // outer-`Dep` accessors and closes the family.
5519 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5520 d.fonte()
5521 }
5522 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5523 d.caracteristicas()
5524 }
5525 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5526 let empty = Dep::simple("caixa-teia", "^0.1");
5527 assert!(fonte_via_const_fn(&empty).is_none());
5528 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5529 assert!(caracteristicas_via_const_fn(&empty).is_empty());
5530 assert_eq!(
5531 caracteristicas_via_const_fn(&empty),
5532 empty.caracteristicas()
5533 );
5534 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5535 // still empty.
5536 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5537 assert!(fonte_via_const_fn(&git).is_some());
5538 assert_eq!(fonte_via_const_fn(&git), git.fonte());
5539 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5540 // Populated `:caracteristicas` — exercise the non-empty
5541 // slice-view arm to pin the accessor's borrow shape against
5542 // both a `Vec::new()` empty backing buffer and a populated one.
5543 let mut with_features = Dep::simple("caixa-teia", "^0.1");
5544 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5545 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5546 assert_eq!(
5547 caracteristicas_via_const_fn(&with_features),
5548 with_features.caracteristicas()
5549 );
5550 }
5551
5552 #[test]
5553 fn git_dep_carries_tag() {
5554 let d = Dep::git("t", "*", "github:o/r", "v1");
5555 match d.fonte {
5556 Some(DepSource::Git {
5557 ref repo, ref tag, ..
5558 }) => {
5559 assert_eq!(repo, "github:o/r");
5560 assert_eq!(tag.as_deref(), Some("v1"));
5561 }
5562 _ => panic!("expected Git source"),
5563 }
5564 }
5565
5566 #[test]
5567 fn validate_accepts_simple_dep() {
5568 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5569 }
5570
5571 #[test]
5572 fn validate_rejects_empty_nome() {
5573 // The fail-before-pass-after pin for `:nome ""`: the empty-name
5574 // arm fires first so the per-entry parse-side diagnostic doesn't
5575 // emit a useless `nome: ""` reference.
5576 let mut d = Dep::simple("placeholder", "^0.1");
5577 d.nome = String::new();
5578 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5579 }
5580
5581 #[test]
5582 fn validate_rejects_empty_versao() {
5583 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5584 // semver crate accepts the empty string as a wildcard match),
5585 // so the empty-`:versao` arm is structurally necessary even
5586 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5587 // `EmptyChildVersion` ordering on the other two `:versao` axes.
5588 let mut d = Dep::simple("caixa-teia", "ignored");
5589 d.versao = String::new();
5590 let err = d.validate().unwrap_err();
5591 assert!(
5592 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5593 "got {err:?}"
5594 );
5595 }
5596
5597 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5598
5599 #[test]
5600 fn validate_rejects_nome_with_uppercase() {
5601 // The fail-before-pass-after pin: a non-empty but uppercase
5602 // `:nome` silently passed `validate()` on every pre-gate
5603 // codebase because the prior shape only refused the empty
5604 // string. The DNS-1123 violation surfaced far downstream at
5605 // lacre-resolve time when the *target* caixa's `:nome` failed
5606 // its own gate — far from the `:deps` entry, with a diagnostic
5607 // naming the target rather than the dep entry that referenced
5608 // it. Same fail-before-pass-after fixture pinned for
5609 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5610 // and Caixa `:nome` (6c992f8).
5611 let d = Dep::simple("Caixa-Teia", "^0.1");
5612 let err = d.validate().unwrap_err();
5613 assert!(
5614 matches!(
5615 err,
5616 DepError::NomeInvalid { ref nome, ref reason }
5617 if nome == "Caixa-Teia" && reason.contains("uppercase")
5618 ),
5619 "got {err:?}"
5620 );
5621 }
5622
5623 #[test]
5624 fn validate_rejects_nome_with_underscore() {
5625 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5626 // "I'm thinking of Go module names / Python identifiers" leak.
5627 // Same fixture pinned for the peer caixa-identifier axes.
5628 let d = Dep::simple("caixa_teia", "^0.1");
5629 let err = d.validate().unwrap_err();
5630 assert!(
5631 matches!(
5632 err,
5633 DepError::NomeInvalid { ref nome, ref reason }
5634 if nome == "caixa_teia" && reason.contains('_')
5635 ),
5636 "got {err:?}"
5637 );
5638 }
5639
5640 #[test]
5641 fn validate_rejects_nome_with_dot() {
5642 // A `:deps :nome` is a single DNS-1123 *label*, not a
5643 // subdomain — dots are rejected. The `"caixa.teia"` shape is
5644 // the canonical "I confused the dep name with the FQDN /
5645 // namespace" footgun, distinct from the legitimate
5646 // `:fonte :repo "github:org/caixa-teia"` axis.
5647 let d = Dep::simple("caixa.teia", "^0.1");
5648 let err = d.validate().unwrap_err();
5649 assert!(
5650 matches!(
5651 err,
5652 DepError::NomeInvalid { ref nome, ref reason }
5653 if nome == "caixa.teia" && reason.contains('.')
5654 ),
5655 "got {err:?}"
5656 );
5657 }
5658
5659 #[test]
5660 fn validate_rejects_nome_with_leading_hyphen() {
5661 // RFC 1123 requires alphanumeric at both label boundaries.
5662 // Pinned in parity with the peer DNS-1123 fixtures.
5663 let d = Dep::simple("-caixa-teia", "^0.1");
5664 let err = d.validate().unwrap_err();
5665 assert!(
5666 matches!(
5667 err,
5668 DepError::NomeInvalid { ref nome, ref reason }
5669 if nome == "-caixa-teia" && reason.contains("alphanumeric")
5670 ),
5671 "got {err:?}"
5672 );
5673 }
5674
5675 #[test]
5676 fn validate_rejects_nome_with_trailing_hyphen() {
5677 let d = Dep::simple("caixa-teia-", "^0.1");
5678 let err = d.validate().unwrap_err();
5679 assert!(
5680 matches!(
5681 err,
5682 DepError::NomeInvalid { ref nome, ref reason }
5683 if nome == "caixa-teia-" && reason.contains("alphanumeric")
5684 ),
5685 "got {err:?}"
5686 );
5687 }
5688
5689 #[test]
5690 fn validate_rejects_nome_with_slash() {
5691 // The canonical "I copied the GitHub repo path into `:nome`
5692 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5693 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5694 // the local-name slot. Same fixture pinned for `:membros
5695 // :caixa` (3f9d7a0).
5696 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5697 let err = d.validate().unwrap_err();
5698 assert!(
5699 matches!(
5700 err,
5701 DepError::NomeInvalid { ref nome, ref reason }
5702 if nome == "pleme-io/caixa-teia" && reason.contains('/')
5703 ),
5704 "got {err:?}"
5705 );
5706 }
5707
5708 #[test]
5709 fn validate_rejects_nome_too_long() {
5710 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5711 // Built from a valid character set so the length-bound
5712 // diagnostic surfaces before any per-character check (the
5713 // order pin parallel to the per-character predicates inside
5714 // [`crate::render::is_dns_1123_label`]).
5715 let long = "a".repeat(64);
5716 let d = Dep::simple(&long, "^0.1");
5717 let err = d.validate().unwrap_err();
5718 assert!(
5719 matches!(
5720 err,
5721 DepError::NomeInvalid { ref nome, ref reason }
5722 if nome.len() == 64 && reason.contains("max length of 63")
5723 ),
5724 "got {err:?}"
5725 );
5726 }
5727
5728 #[test]
5729 fn validate_accepts_canonical_nome_labels() {
5730 // Positive-control sweep — every form the K8s apiserver
5731 // accepts as a DNS-1123 label must round-trip through
5732 // validate. Covers a hyphen-bearing label, a numeric-suffix
5733 // label, a leading-digit label, a single-character label, and
5734 // a 63-byte (exactly the cap) label — the same fixture set
5735 // the peer `:membros :caixa` / `:children :caixa` positive
5736 // controls pin.
5737 for nome in [
5738 "caixa-teia",
5739 "caixa-resolver2",
5740 "2nd-tier-cache",
5741 "x",
5742 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5743 ] {
5744 Dep::simple(nome, "^0.1")
5745 .validate()
5746 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5747 }
5748 }
5749
5750 #[test]
5751 fn nome_empty_takes_precedence_over_nome_invalid() {
5752 // Ordering pin: `NomeEmpty` is the more self-locating
5753 // diagnostic on `""` and must lead — `is_dns_1123_label` is
5754 // only reached after the empty-check fires at the call site.
5755 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5756 // (3f9d7a0) on the peer caixa-identifier axis.
5757 let mut d = Dep::simple("placeholder", "^0.1");
5758 d.nome = String::new();
5759 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5760 }
5761
5762 #[test]
5763 fn nome_invalid_fires_before_versao_empty() {
5764 // Ordering pin: a malformed `:nome` fires before any `:versao`
5765 // axis check on the *same* entry — the per-entry shape gates
5766 // run top-to-bottom (nome empty → nome shape → versao empty →
5767 // versao parse → fonte shape), so a one-entry caixa.lisp with
5768 // both wrong sees the name-side diagnostic first (the name is
5769 // the self-locating axis — without a valid name, the parse
5770 // diagnostic can't quote `:nome "<bad>"`). Same ordering
5771 // discipline as `membro_caixa_invalid_fires_before_versao_check`
5772 // (3f9d7a0).
5773 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5774 d.versao = String::new();
5775 let err = d.validate().unwrap_err();
5776 assert!(
5777 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5778 "got {err:?}"
5779 );
5780 }
5781
5782 #[test]
5783 fn nome_invalid_fires_before_versao_invalid() {
5784 // Ordering pin: a malformed `:nome` fires before the `:versao`
5785 // parse-side check on the *same* entry. Pin separately from
5786 // the empty-versao ordering so a future re-ordering surfaces
5787 // here, parallel to the b0c8389 / c4213a4 trajectory.
5788 let d = Dep::simple("Caixa-Teia", "^^0.1");
5789 let err = d.validate().unwrap_err();
5790 assert!(
5791 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5792 "got {err:?}"
5793 );
5794 }
5795
5796 #[test]
5797 fn nome_invalid_fires_before_fonte_invalid() {
5798 // Ordering pin: a malformed `:nome` fires before the `:fonte`
5799 // shape check on the *same* entry. The `:fonte` diagnostic
5800 // names the offending dep's `:nome` verbatim (via
5801 // `DepSource::validate(&self.nome)`), so a non-self-locating
5802 // name would taint the downstream diagnostic too — the gate
5803 // ordering keeps both diagnostics individually self-locating.
5804 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5805 d.fonte = Some(DepSource::Git {
5806 repo: String::new(),
5807 tag: None,
5808 rev: None,
5809 branch: None,
5810 });
5811 let err = d.validate().unwrap_err();
5812 assert!(
5813 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5814 "got {err:?}"
5815 );
5816 }
5817
5818 #[test]
5819 fn nome_invalid_diagnostic_carries_offending_name() {
5820 // The diagnostic-shape pin: the error names the offending
5821 // `:nome` value verbatim so the author can grep their
5822 // caixa.lisp without re-running the build, and carries a
5823 // non-empty `reason` from `is_dns_1123_label` so the
5824 // predicate's own wording flows through to the diagnostic.
5825 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5826 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5827 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5828 // share a structurally-equivalent diagnostic family.
5829 let d = Dep::simple("Caixa_Teia", "^0.1");
5830 let err = d.validate().unwrap_err();
5831 let DepError::NomeInvalid { nome, reason } = err else {
5832 panic!("expected NomeInvalid, got other variant");
5833 };
5834 assert_eq!(nome, "Caixa_Teia");
5835 assert!(
5836 !reason.is_empty(),
5837 "NomeInvalid `reason` must carry the predicate's wording verbatim"
5838 );
5839 }
5840
5841 #[test]
5842 fn validate_rejects_invalid_versao_requirement() {
5843 // The fail-before-pass-after pin: a non-empty but malformed
5844 // requirement (`"^bad-version"`) silently passed every pre-gate
5845 // codebase because `:deps :versao` wasn't validated. The parse
5846 // failure surfaced far downstream at lacre-resolve time with a
5847 // `semver::Error` that didn't name which `:deps` entry carried
5848 // the typo. The new gate moves the check to caixa-build time
5849 // at the source caixa.lisp.
5850 let d = Dep::simple("caixa-teia", "^bad-version");
5851 let err = d.validate().unwrap_err();
5852 assert!(
5853 matches!(
5854 err,
5855 DepError::VersaoInvalid { ref nome, ref versao, .. }
5856 if nome == "caixa-teia" && versao == "^bad-version"
5857 ),
5858 "got {err:?}"
5859 );
5860 }
5861
5862 #[test]
5863 fn validate_rejects_versao_with_double_caret_typo() {
5864 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5865 // Cargo-shaped requirement on first glance but fails the parser
5866 // because semver doesn't accept stacked operators. Pin this
5867 // adjacent-shape footgun explicitly so a future relaxation that
5868 // accepts "looks-canonical-but-isn't" forms surfaces here, in
5869 // parity with the `:membros` / `:children` fixtures.
5870 let d = Dep::simple("caixa-teia", "^^0.1");
5871 let err = d.validate().unwrap_err();
5872 assert!(
5873 matches!(
5874 err,
5875 DepError::VersaoInvalid { ref nome, ref versao, .. }
5876 if nome == "caixa-teia" && versao == "^^0.1"
5877 ),
5878 "got {err:?}"
5879 );
5880 }
5881
5882 #[test]
5883 fn validate_rejects_versao_with_v_prefixed_tag() {
5884 // `"v0.1"` is the canonical "git-tag-shape leaking into the
5885 // semver requirement slot" typo — an author copies the
5886 // publish-side git-tag string verbatim into `:versao`, but
5887 // Cargo's semver parser rejects the leading `v`. Same fixture
5888 // pinned for `:membros :versao` (9888b13) and `:children
5889 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5890 // are *accepted* by the semver crate as an `*` wildcard on the
5891 // patch axis — they're a Cargo-side valid shape, not a typo.)
5892 let d = Dep::simple("caixa-teia", "v0.1");
5893 let err = d.validate().unwrap_err();
5894 assert!(
5895 matches!(
5896 err,
5897 DepError::VersaoInvalid { ref nome, ref versao, .. }
5898 if nome == "caixa-teia" && versao == "v0.1"
5899 ),
5900 "got {err:?}"
5901 );
5902 }
5903
5904 #[test]
5905 fn validate_accepts_canonical_versao_forms() {
5906 // The five Cargo-shaped requirement forms `:membros :versao`
5907 // and `:children :versao` already accept via
5908 // `crate::parse_requirement` must pass the deps gate without
5909 // re-validating at the resolver layer. Pin every leg so a
5910 // future tightening of the canonical set surfaces here as a
5911 // test failure.
5912 for form in [
5913 "^0.1", // caret — minor-range pin (the most common shape)
5914 "~0.1.2", // tilde — patch-range pin
5915 "0.1.0", // exact — single-version pin
5916 "*", // wildcard — explicitly any-version
5917 ">=0.1, <2", // multi-range — comma-separated comparators
5918 ] {
5919 Dep::simple("caixa-teia", form)
5920 .validate()
5921 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5922 }
5923 }
5924
5925 #[test]
5926 fn versao_empty_takes_precedence_over_invalid() {
5927 // Order pin: the existing `VersaoEmpty` diagnostic (which
5928 // doesn't try to parse) fires before the new `VersaoInvalid`
5929 // parse-side diagnostic, so an empty `:versao` keeps its
5930 // narrower error message — `parse_requirement("")` would
5931 // otherwise return `Ok(STAR)` and silently pass, but the empty
5932 // arm catches it first.
5933 let mut d = Dep::simple("caixa-teia", "ignored");
5934 d.versao = String::new();
5935 let err = d.validate().unwrap_err();
5936 assert!(
5937 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5938 "got {err:?}"
5939 );
5940 }
5941
5942 #[test]
5943 fn nome_empty_takes_precedence_over_versao_invalid() {
5944 // Order pin: even when `:versao` is malformed and would raise
5945 // its own diagnostic, `:nome ""` fires first because the
5946 // per-entry parse diagnostic needs a non-empty name to be
5947 // self-locating. Mirrors the
5948 // `membros_validation_runs_before_contratos_membership_check`
5949 // ordering on the typed-graph layer.
5950 let mut d = Dep::simple("placeholder", "^bad");
5951 d.nome = String::new();
5952 let err = d.validate().unwrap_err();
5953 assert_eq!(err, DepError::NomeEmpty);
5954 }
5955
5956 #[test]
5957 fn versao_invalid_diagnostic_carries_offending_versao() {
5958 // The diagnostic-shape pin: the error names the offending
5959 // `:versao` value verbatim so the author can grep their
5960 // caixa.lisp without re-running the build, and carries a
5961 // non-empty `reason` from `semver::VersionReq::parse` so the
5962 // parser's own wording flows through to the diagnostic.
5963 let d = Dep::simple("caixa-teia", "not-a-req");
5964 let err = d.validate().unwrap_err();
5965 let DepError::VersaoInvalid {
5966 nome,
5967 versao,
5968 reason,
5969 } = err
5970 else {
5971 panic!("expected VersaoInvalid, got other variant");
5972 };
5973 assert_eq!(nome, "caixa-teia");
5974 assert_eq!(versao, "not-a-req");
5975 assert!(
5976 !reason.is_empty(),
5977 "VersaoInvalid `reason` must carry the parser's wording verbatim"
5978 );
5979 }
5980
5981 // -- :fonte value-shape gate ------------------------------------------
5982
5983 fn dep_with_fonte(fonte: DepSource) -> Dep {
5984 let mut d = Dep::simple("caixa-teia", "^0.1");
5985 d.fonte = Some(fonte);
5986 d
5987 }
5988
5989 #[test]
5990 fn validate_accepts_git_fonte_with_tag() {
5991 // The positive-control pin on the canonical git source — exactly
5992 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5993 // shape every existing caixa-resolver integration test uses.
5994 let d = dep_with_fonte(DepSource::Git {
5995 repo: "github:pleme-io/caixa-teia".into(),
5996 tag: Some("v0.1.0".into()),
5997 rev: None,
5998 branch: None,
5999 });
6000 d.validate().unwrap();
6001 }
6002
6003 #[test]
6004 fn validate_accepts_git_fonte_with_rev() {
6005 // Each of the three pin axes is independently a valid single-pin
6006 // shape; pin the :rev arm so a future relaxation that only
6007 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6008 // OID — the canonical `git rev-parse HEAD` emission shape the
6009 // `crate::render::is_git_oid` value-shape gate now requires;
6010 // abbreviated OIDs are ambiguous across repo history and
6011 // rejected at this gate (pinned separately by
6012 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6013 let d = dep_with_fonte(DepSource::Git {
6014 repo: "github:pleme-io/caixa-teia".into(),
6015 tag: None,
6016 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6017 branch: None,
6018 });
6019 d.validate().unwrap();
6020 }
6021
6022 #[test]
6023 fn validate_accepts_git_fonte_with_branch() {
6024 // The :branch arm is the third valid single-pin shape — pinned
6025 // separately so the gate-accepts-all-three-pin-axes contract is
6026 // a build-error to relax.
6027 let d = dep_with_fonte(DepSource::Git {
6028 repo: "github:pleme-io/caixa-teia".into(),
6029 tag: None,
6030 rev: None,
6031 branch: Some("main".into()),
6032 });
6033 d.validate().unwrap();
6034 }
6035
6036 #[test]
6037 fn validate_accepts_path_fonte() {
6038 // The positive-control pin on the path source — non-empty
6039 // :caminho, no pin axes (paths have no commit identity). Pinned
6040 // so a future "paths must also pin a rev" tightening surfaces
6041 // here as a structural decision, not a silent break.
6042 let d = dep_with_fonte(DepSource::Path {
6043 caminho: "../caixa-teia".into(),
6044 });
6045 d.validate().unwrap();
6046 }
6047
6048 #[test]
6049 fn validate_rejects_git_fonte_with_empty_repo() {
6050 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6051 // "v1")`: the empty-repo shape silently passed every pre-gate
6052 // codebase because `:fonte` wasn't validated. The git-clone
6053 // failure surfaced far downstream at lacre-resolve time with no
6054 // field naming which `:deps` entry carried the typo. The new
6055 // gate moves the check to caixa-build time at the source
6056 // caixa.lisp.
6057 let d = dep_with_fonte(DepSource::Git {
6058 repo: String::new(),
6059 tag: Some("v0.1.0".into()),
6060 rev: None,
6061 branch: None,
6062 });
6063 let err = d.validate().unwrap_err();
6064 assert!(
6065 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6066 "got {err:?}"
6067 );
6068 }
6069
6070 // -- :repo value-shape gate -------------------------------------------
6071 //
6072 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6073 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6074 // codebase admitted any non-empty string; the new
6075 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6076 // URL intersection-floor at validate time, peer with the three pin
6077 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6078 // `is_git_oid`). Every test in this section is a fail-before /
6079 // pass-after pin on a specific authoring footgun.
6080
6081 #[test]
6082 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6083 // The canonical paste-from-doc footgun on `:repo` — an author
6084 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6085 // a doc paragraph. Until this gate landed the empty-repo arm
6086 // passed (the string isn't empty), the resolver issued
6087 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6088 // surfaced at clone time with a quoting-confused error far from
6089 // the source caixa.lisp. Same paste-from-doc footgun the
6090 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6091 // axis — now closed on the `:repo` URL axis too.
6092 let d = dep_with_fonte(DepSource::Git {
6093 repo: "github:pleme-io/caixa-teia ".into(),
6094 tag: Some("v0.1.0".into()),
6095 rev: None,
6096 branch: None,
6097 });
6098 let err = d.validate().unwrap_err();
6099 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6100 panic!("expected FonteRepoShape, got other variant");
6101 };
6102 assert_eq!(nome, "caixa-teia");
6103 assert_eq!(repo, "github:pleme-io/caixa-teia ");
6104 assert!(
6105 reason.contains("whitespace"),
6106 "reason must surface the whitespace arm, got {reason:?}"
6107 );
6108 }
6109
6110 #[test]
6111 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6112 // The canonical CLI-argument-injection footgun at the `git clone`
6113 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6114 // argv parser read the value as a CLI flag, escaping the
6115 // subprocess argument boundary. The `--` separator workaround
6116 // does not fix the typed slot's accepted set; the gate rejects
6117 // the shape upstream at validate time so the resolver never
6118 // invokes a `git clone -…` subprocess.
6119 let d = dep_with_fonte(DepSource::Git {
6120 repo: "-upload-pack=evil".into(),
6121 tag: Some("v0.1.0".into()),
6122 rev: None,
6123 branch: None,
6124 });
6125 let err = d.validate().unwrap_err();
6126 let DepError::FonteRepoShape { repo, reason, .. } = err else {
6127 panic!("expected FonteRepoShape, got other variant");
6128 };
6129 assert_eq!(repo, "-upload-pack=evil");
6130 assert!(
6131 reason.contains("must not start with `-`"),
6132 "reason must surface the leading-`-` arm, got {reason:?}"
6133 );
6134 }
6135
6136 #[test]
6137 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6138 // The canonical paste-from-multiline-doc footgun — a `:repo`
6139 // string with an embedded `\n` silently breaks git's URL parser
6140 // and is a class of CRLF-injection at the subprocess-argument
6141 // boundary. Caught by the control-char arm (0x0A < 0x20).
6142 let d = dep_with_fonte(DepSource::Git {
6143 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6144 tag: Some("v0.1.0".into()),
6145 rev: None,
6146 branch: None,
6147 });
6148 let err = d.validate().unwrap_err();
6149 let DepError::FonteRepoShape { reason, .. } = err else {
6150 panic!("expected FonteRepoShape, got other variant");
6151 };
6152 assert!(
6153 reason.contains("control character"),
6154 "reason must surface the control-char arm, got {reason:?}"
6155 );
6156 }
6157
6158 #[test]
6159 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6160 // Tab is the sibling whitespace footgun (the canonical
6161 // copy-from-aligned-table paste); pinned separately from the
6162 // space arm so a future relaxation that only catches one
6163 // surfaces here.
6164 let d = dep_with_fonte(DepSource::Git {
6165 repo: "github:pleme-io/caixa-teia\t".into(),
6166 tag: Some("v0.1.0".into()),
6167 rev: None,
6168 branch: None,
6169 });
6170 let err = d.validate().unwrap_err();
6171 assert!(
6172 matches!(
6173 err,
6174 DepError::FonteRepoShape { ref reason, .. }
6175 if reason.contains("whitespace")
6176 ),
6177 "got {err:?}"
6178 );
6179 }
6180
6181 #[test]
6182 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6183 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6184 // non-ASCII silently breaks at git's URL parser and round-trips
6185 // inconsistently across NFC/NFD normalization on APFS /
6186 // case-folding filesystems. Same intersection-floor
6187 // [`is_git_ref_name`] enforces on the refname axes.
6188 let d = dep_with_fonte(DepSource::Git {
6189 repo: "https://github.com/pleme-io/café".into(),
6190 tag: Some("v0.1.0".into()),
6191 rev: None,
6192 branch: None,
6193 });
6194 let err = d.validate().unwrap_err();
6195 assert!(
6196 matches!(
6197 err,
6198 DepError::FonteRepoShape { ref reason, .. }
6199 if reason.contains("non-ASCII")
6200 ),
6201 "got {err:?}"
6202 );
6203 }
6204
6205 #[test]
6206 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6207 // The fail-before-pass-after pin for the canonical paste-from-
6208 // browser-address-bar footgun on `:repo`: an author copies a
6209 // GitHub permalink to a README anchor / line-permalink and
6210 // forgets to trim the `#fragment` tail. Until this arm landed
6211 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6212 // silently passed every prior arm (no whitespace, no control
6213 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6214 // or `:`), libcurl's URL parser stripped the `#readme` tail
6215 // before opening the HTTPS transport, and the lacre embedded
6216 // the value verbatim in its per-dep BLAKE3 closure — two
6217 // authors whose values differ only in their fragment anchor
6218 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6219 // `git clone` but lock to two distinct lacres, defeating the
6220 // THEORY.md §V.2 render-determinism contract. Same value-shape
6221 // axis-floor every peer typed surface enforces; peer `:fonte
6222 // :tag` / `:fonte :branch` already reject the byte-class through
6223 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6224 // URL grammar admitted) and `:entrada :paths` rejects `#` as
6225 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6226 let d = dep_with_fonte(DepSource::Git {
6227 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6228 tag: Some("v0.1.0".into()),
6229 rev: None,
6230 branch: None,
6231 });
6232 let err = d.validate().unwrap_err();
6233 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6234 panic!("expected FonteRepoShape, got other variant");
6235 };
6236 assert_eq!(nome, "caixa-teia");
6237 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6238 assert!(
6239 reason.contains("must not contain `#`"),
6240 "reason must surface the fragment-`#` arm, got {reason:?}"
6241 );
6242 assert!(
6243 reason.contains("fragment"),
6244 "reason must name the URL fragment grammar, got {reason:?}"
6245 );
6246 }
6247
6248 #[test]
6249 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6250 // The symmetric paste-from-Nix-flake-ref footgun — an author
6251 // confuses the Nix flake-reference idiom (`github:foo/
6252 // bar#packageName`, where `#packageName` selects a flake
6253 // output) with the bare git `:repo` shape. The pleme-io
6254 // substrate authors compose flakes downstream of caixa
6255 // (caixa-flake renders a flake.nix), so the cross-idiom leak
6256 // is the canonical near-miss: the author writes the
6257 // flake-ref shape into a git `:repo` slot. Pinned separately
6258 // from the HTTPS-anchor arm so a future relaxation that
6259 // narrows to one URL scheme surfaces here.
6260 let d = dep_with_fonte(DepSource::Git {
6261 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6262 tag: Some("v0.1.0".into()),
6263 rev: None,
6264 branch: None,
6265 });
6266 let err = d.validate().unwrap_err();
6267 let DepError::FonteRepoShape { reason, .. } = err else {
6268 panic!("expected FonteRepoShape, got other variant");
6269 };
6270 assert!(
6271 reason.contains("must not contain `#`"),
6272 "reason must surface the fragment-`#` arm, got {reason:?}"
6273 );
6274 assert!(
6275 reason.contains("Nix flake"),
6276 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6277 );
6278 }
6279
6280 #[test]
6281 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6282 // The fail-before-pass-after pin for the canonical paste-from-
6283 // browser-address-bar footgun on `:repo` (peer with the
6284 // a68f818 fragment-`#` arm on the same axis). An author
6285 // copies a GitHub tab deep-link out of the address bar and
6286 // forgets to trim the `?tab=…` query tail. Until this arm
6287 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6288 // silently passed every prior arm (no whitespace, no control
6289 // chars, no non-ASCII, no `#` fragment, contains a `:`,
6290 // doesn't start with `-` or `:`); GitHub silently ignored
6291 // the `?query` tail and served the same repo regardless;
6292 // the lacre embedded the value verbatim in its per-dep
6293 // BLAKE3 closure — two authors whose values differ only in
6294 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6295 // `?utm_source=twitter`) resolve to the byte-identical
6296 // upstream `git clone` but lock to two distinct lacres,
6297 // defeating the THEORY.md §V.2 render-determinism contract
6298 // on the same axis the `#` fragment arm closes. Same value-
6299 // shape axis-floor every peer typed surface enforces; peer
6300 // `:fonte :tag` / `:fonte :branch` already reject the byte-
6301 // class through `is_git_ref_name`'s alphabet (refspec glob
6302 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6303 // :paths` rejects `?` as the query separator in
6304 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6305 let d = dep_with_fonte(DepSource::Git {
6306 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6307 tag: Some("v0.1.0".into()),
6308 rev: None,
6309 branch: None,
6310 });
6311 let err = d.validate().unwrap_err();
6312 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6313 panic!("expected FonteRepoShape, got other variant");
6314 };
6315 assert_eq!(nome, "caixa-teia");
6316 assert_eq!(
6317 repo,
6318 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6319 );
6320 assert!(
6321 reason.contains("must not contain `?`"),
6322 "reason must surface the query-`?` arm, got {reason:?}"
6323 );
6324 assert!(
6325 reason.contains("query"),
6326 "reason must name the URL query grammar, got {reason:?}"
6327 );
6328 }
6329
6330 #[test]
6331 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6332 // The symmetric paste-from-social-share footgun — an author
6333 // copies a repo URL out of a Slack unfurl / Twitter share /
6334 // newsletter link / Discord embed and forgets to trim the
6335 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6336 // campaign-tracker tail. Every major social-share / unfurl /
6337 // newsletter platform appends these UTM parameters; the
6338 // canonical near-miss on the `:repo` axis. Pinned separately
6339 // from the GitHub-tab-deep-link arm so a future relaxation
6340 // that narrows to one query-parameter class surfaces here.
6341 let d = dep_with_fonte(DepSource::Git {
6342 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6343 .into(),
6344 tag: Some("v0.1.0".into()),
6345 rev: None,
6346 branch: None,
6347 });
6348 let err = d.validate().unwrap_err();
6349 let DepError::FonteRepoShape { reason, .. } = err else {
6350 panic!("expected FonteRepoShape, got other variant");
6351 };
6352 assert!(
6353 reason.contains("must not contain `?`"),
6354 "reason must surface the query-`?` arm, got {reason:?}"
6355 );
6356 assert!(
6357 reason.contains("campaign-tracker"),
6358 "reason must name the campaign-tracker paste footgun, got {reason:?}"
6359 );
6360 }
6361
6362 #[test]
6363 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6364 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6365 // both per-byte arms inside the same `for &b in s.as_bytes()`
6366 // loop, so the byte that appears first in the value's byte
6367 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6368 // (fragment before query — unusual URL-grammar but value-
6369 // disjoint at byte level) carries both `#` and `?`; the `#`
6370 // byte appears first, so the fragment-`#` arm fires, surfacing
6371 // the more self-locating diagnostic on the byte the author
6372 // pasted earliest in the URL. Mirrors the peer cascade
6373 // discipline `fonte_repo_control_char_fires_before_fragment`
6374 // pins on the prior `:repo` byte-class arm.
6375 let d = dep_with_fonte(DepSource::Git {
6376 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6377 tag: Some("v0.1.0".into()),
6378 rev: None,
6379 branch: None,
6380 });
6381 let err = d.validate().unwrap_err();
6382 let DepError::FonteRepoShape { reason, .. } = err else {
6383 panic!("expected FonteRepoShape, got other variant");
6384 };
6385 assert!(
6386 reason.contains("must not contain `#`"),
6387 "reason must surface the fragment-`#` arm (fires before query-`?` when \
6388 `#` byte appears first in value), got {reason:?}"
6389 );
6390 }
6391
6392 #[test]
6393 fn fonte_repo_control_char_fires_before_fragment() {
6394 // Cascade pin: the control-char arm structurally precedes the
6395 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6396 // positive on both arms (contains LF and `#`), but the narrower
6397 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6398 // (`control character`) wins so the author sees the more
6399 // self-locating arm first. Mirrors the peer cascade discipline
6400 // every prior `:repo` byte-class arm establishes.
6401 let d = dep_with_fonte(DepSource::Git {
6402 repo: "github:pleme-io/caixa-teia\n#readme".into(),
6403 tag: Some("v0.1.0".into()),
6404 rev: None,
6405 branch: None,
6406 });
6407 let err = d.validate().unwrap_err();
6408 let DepError::FonteRepoShape { reason, .. } = err else {
6409 panic!("expected FonteRepoShape, got other variant");
6410 };
6411 assert!(
6412 reason.contains("control character"),
6413 "reason must surface the control-char arm, got {reason:?}"
6414 );
6415 }
6416
6417 #[test]
6418 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6419 // The fail-before-pass-after pin for the canonical Windows-
6420 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6421 // backslash arm on the sibling `:caminho` path-fonte axis).
6422 // An author pastes a Windows Explorer address-bar / PowerShell
6423 // `Get-Location` output into a `file://` URL slot, producing
6424 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6425 // value silently passed every prior arm (no whitespace, no
6426 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6427 // with `-` or `:`); libcurl's URL parser silently translates
6428 // `\` → `/` on some platforms and refuses it on others, so
6429 // the byte rides verbatim into the lacre's per-dep content-
6430 // address but is silently rewritten / rejected at the wire —
6431 // two authors whose `:repo` values differ only in backslash-
6432 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6433 // resolve to the byte-identical local clone but lock to two
6434 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6435 // render-determinism contract on the same axis the `#`
6436 // fragment and `?` query arms close. Same value-shape axis-
6437 // floor every peer typed surface enforces; the `:caminho`
6438 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6439 let d = dep_with_fonte(DepSource::Git {
6440 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6441 tag: Some("v0.1.0".into()),
6442 rev: None,
6443 branch: None,
6444 });
6445 let err = d.validate().unwrap_err();
6446 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6447 panic!("expected FonteRepoShape, got other variant");
6448 };
6449 assert_eq!(nome, "caixa-teia");
6450 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6451 assert!(
6452 reason.contains("must not contain `\\`"),
6453 "reason must surface the backslash-`\\` arm, got {reason:?}"
6454 );
6455 assert!(
6456 reason.contains("Windows"),
6457 "reason must name the Windows-path-confusion footgun, got {reason:?}"
6458 );
6459 }
6460
6461 #[test]
6462 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6463 // The symmetric Win32-shell-mangled-slashes footgun — an author
6464 // copies `https://github.com/foo/bar` into a Win32 shell that
6465 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6466 // separator-coercion bug), pastes the result into a `:repo`
6467 // slot, and produces `https:\\github.com\foo\bar`. Pinned
6468 // separately from the `file://` Explorer-paste arm so a future
6469 // relaxation that narrows to one URL scheme surfaces here.
6470 let d = dep_with_fonte(DepSource::Git {
6471 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6472 tag: Some("v0.1.0".into()),
6473 rev: None,
6474 branch: None,
6475 });
6476 let err = d.validate().unwrap_err();
6477 let DepError::FonteRepoShape { reason, .. } = err else {
6478 panic!("expected FonteRepoShape, got other variant");
6479 };
6480 assert!(
6481 reason.contains("must not contain `\\`"),
6482 "reason must surface the backslash-`\\` arm, got {reason:?}"
6483 );
6484 assert!(
6485 reason.contains("path separator") || reason.contains("path-segment separator"),
6486 "reason must name the URL path-segment separator grammar, got {reason:?}"
6487 );
6488 }
6489
6490 #[test]
6491 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6492 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6493 // are both per-byte arms inside the same `for &b in s.as_bytes()`
6494 // loop, so the byte that appears first in the value's byte order
6495 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6496 // both `#` and `\`; the `#` byte appears first, so the fragment-
6497 // `#` arm fires, surfacing the more self-locating diagnostic on
6498 // the byte the author pasted earliest in the URL. Mirrors the
6499 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6500 // pins on the prior `:repo` byte-class arm.
6501 let d = dep_with_fonte(DepSource::Git {
6502 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6503 tag: Some("v0.1.0".into()),
6504 rev: None,
6505 branch: None,
6506 });
6507 let err = d.validate().unwrap_err();
6508 let DepError::FonteRepoShape { reason, .. } = err else {
6509 panic!("expected FonteRepoShape, got other variant");
6510 };
6511 assert!(
6512 reason.contains("must not contain `#`"),
6513 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6514 `#` byte appears first in value), got {reason:?}"
6515 );
6516 }
6517
6518 #[test]
6519 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6520 // The fail-before-pass-after pin for the canonical URI Template
6521 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6522 // README quick-start snippet / OpenAPI `servers:` URL / Helm
6523 // chart `home:` template that carries unresolved
6524 // `{org}` / `{repo}` placeholders and pastes the raw template
6525 // into the `:repo` slot, expecting the substrate to resolve the
6526 // placeholder downstream. Until this arm landed the value
6527 // silently passed every prior arm (no whitespace, no control
6528 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6529 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6530 // / `%7D` on the wire, so the byte rides verbatim into the
6531 // lacre's per-dep content-address but round-trips inconsistently
6532 // between the lacre's per-dep content-address and the
6533 // resolver's `git clone <repo>` invocation, defeating the
6534 // THEORY.md §V.2 render-determinism contract on the same axis
6535 // the `#` fragment, `?` query, and `\` backslash arms close;
6536 // every git porcelain entry-point additionally fetches a
6537 // nonexistent literal-`{placeholder}`-named path far from the
6538 // source caixa.lisp.
6539 let d = dep_with_fonte(DepSource::Git {
6540 repo: "https://github.com/{org}/caixa-teia".into(),
6541 tag: Some("v0.1.0".into()),
6542 rev: None,
6543 branch: None,
6544 });
6545 let err = d.validate().unwrap_err();
6546 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6547 panic!("expected FonteRepoShape, got other variant");
6548 };
6549 assert_eq!(nome, "caixa-teia");
6550 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6551 assert!(
6552 reason.contains("must not contain `{`"),
6553 "reason must surface the open-brace `{{` arm, got {reason:?}"
6554 );
6555 assert!(
6556 reason.contains("URI Template") || reason.contains("RFC 6570"),
6557 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6558 );
6559 }
6560
6561 #[test]
6562 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6563 // The symmetric Mustache / Handlebars doubled-brace
6564 // substitution-form footgun every CI / IaC templating engine
6565 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6566 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6567 // chart README quick-start snippet emits. Pinned separately
6568 // from the single-`{` `{org}` arm so a future relaxation that
6569 // narrows to one substitution-form surfaces here.
6570 let d = dep_with_fonte(DepSource::Git {
6571 repo: "https://github.com/{{org}}/caixa-teia".into(),
6572 tag: Some("v0.1.0".into()),
6573 rev: None,
6574 branch: None,
6575 });
6576 let err = d.validate().unwrap_err();
6577 let DepError::FonteRepoShape { reason, .. } = err else {
6578 panic!("expected FonteRepoShape, got other variant");
6579 };
6580 assert!(
6581 reason.contains("must not contain `{`"),
6582 "reason must surface the open-brace `{{` arm, got {reason:?}"
6583 );
6584 }
6585
6586 #[test]
6587 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6588 // Asymmetric `}`-only shape — covers the closing-brace-by-
6589 // itself footgun (an author truncated `{org}/{repo}` mid-edit
6590 // and left a trailing `}` from the prior template fragment,
6591 // or pasted a value that included a closing brace from a
6592 // surrounding shell context). Pinned to ensure the predicate
6593 // refuses each brace independently rather than only when both
6594 // appear — a future regression that ANDs the two byte tests
6595 // surfaces here.
6596 let d = dep_with_fonte(DepSource::Git {
6597 repo: "https://github.com/pleme-io/caixa-teia}".into(),
6598 tag: Some("v0.1.0".into()),
6599 rev: None,
6600 branch: None,
6601 });
6602 let err = d.validate().unwrap_err();
6603 let DepError::FonteRepoShape { reason, .. } = err else {
6604 panic!("expected FonteRepoShape, got other variant");
6605 };
6606 assert!(
6607 reason.contains("must not contain `}`"),
6608 "reason must surface the close-brace `}}` arm, got {reason:?}"
6609 );
6610 }
6611
6612 #[test]
6613 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6614 // Cascade pin: the fragment-`#` arm and the template-`{` /
6615 // `}` arm are both per-byte arms inside the same
6616 // `for &b in s.as_bytes()` loop, so the byte that appears
6617 // first in the value's byte order wins. A `:repo
6618 // "https://github.com/p/x#readme{org}"` carries both `#` and
6619 // `{`; the `#` byte appears first, so the fragment-`#` arm
6620 // fires, surfacing the more self-locating diagnostic on the
6621 // byte the author pasted earliest in the URL. Mirrors the
6622 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6623 // pins on the prior `:repo` byte-class arm.
6624 let d = dep_with_fonte(DepSource::Git {
6625 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6626 tag: Some("v0.1.0".into()),
6627 rev: None,
6628 branch: None,
6629 });
6630 let err = d.validate().unwrap_err();
6631 let DepError::FonteRepoShape { reason, .. } = err else {
6632 panic!("expected FonteRepoShape, got other variant");
6633 };
6634 assert!(
6635 reason.contains("must not contain `#`"),
6636 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6637 `#` byte appears first in value), got {reason:?}"
6638 );
6639 }
6640
6641 #[test]
6642 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6643 // The fail-before-pass-after pin for the canonical
6644 // shell-output-redirection footgun on `:repo`: an author
6645 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6646 // / `… >output.txt`) into the `:repo` slot without trimming
6647 // the redirect. Until this arm landed the value silently
6648 // passed every prior arm (no whitespace, no control chars,
6649 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6650 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6651 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6652 // percent-encode set maps `>` → `%3E` on the wire, so the
6653 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6654 // but is silently rewritten or rejected at libcurl's URL-
6655 // parser layer — two authors whose values differ only in
6656 // their redirect tail (`>build.log` vs nothing) resolve to
6657 // the byte-identical upstream `git clone` but lock to two
6658 // distinct lacres, defeating the THEORY.md §V.2 render-
6659 // determinism contract. Peer with the `:caminho` axis's
6660 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6661 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6662 // byte RFC-3986-reserved set on `:entrada :paths`.
6663 let d = dep_with_fonte(DepSource::Git {
6664 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6665 tag: Some("v0.1.0".into()),
6666 rev: None,
6667 branch: None,
6668 });
6669 let err = d.validate().unwrap_err();
6670 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6671 panic!("expected FonteRepoShape, got other variant");
6672 };
6673 assert_eq!(nome, "caixa-teia");
6674 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6675 assert!(
6676 reason.contains("must not contain `>`"),
6677 "reason must surface the output-redirection `>` arm, got {reason:?}"
6678 );
6679 assert!(
6680 reason.contains("redirection") || reason.contains("'delims'"),
6681 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6682 );
6683 }
6684
6685 #[test]
6686 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6687 // The symmetric shell-input-redirection footgun — an author
6688 // pastes a shell-pipeline head (`git clone <input.url` /
6689 // `cat <README.md`) into the `:repo` slot. Pinned separately
6690 // from the `>`-output arm so a future relaxation that only
6691 // catches one of the two redirect bytes surfaces here. Peer
6692 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6693 // arm which closes both `<` and `>` under the same banner.
6694 let d = dep_with_fonte(DepSource::Git {
6695 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6696 tag: Some("v0.1.0".into()),
6697 rev: None,
6698 branch: None,
6699 });
6700 let err = d.validate().unwrap_err();
6701 let DepError::FonteRepoShape { reason, .. } = err else {
6702 panic!("expected FonteRepoShape, got other variant");
6703 };
6704 assert!(
6705 reason.contains("must not contain `<`"),
6706 "reason must surface the input-redirection `<` arm, got {reason:?}"
6707 );
6708 assert!(
6709 reason.contains("RFC 3986") || reason.contains("'unwise'"),
6710 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6711 );
6712 }
6713
6714 #[test]
6715 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6716 // The fail-before-pass-after pin for the canonical
6717 // paste-from-shell-prompt-with-backticked-substitution footgun
6718 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6719 // `:caminho` path-fonte axis). An author pastes a URL whose
6720 // segment carries a backticked command-substitution wrapper
6721 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6722 // from a doc / README quick-start snippet that expected the
6723 // substrate to substitute the value downstream. Until this arm
6724 // landed the value silently passed every prior arm (no
6725 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6726 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6727 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6728 // 'unwise' set and the WHATWG URL spec's fragment percent-
6729 // encode set maps `` ` `` → `%60` on the wire, so the byte
6730 // rides verbatim into the lacre's per-dep BLAKE3 closure but
6731 // is silently rewritten or rejected at libcurl's URL-parser
6732 // layer — two authors whose values differ only in their
6733 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6734 // byte-identical upstream `git clone` but lock to two distinct
6735 // lacres, defeating the THEORY.md §V.2 render-determinism
6736 // contract. Peer with the `:caminho` axis's
6737 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6738 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6739 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6740 let d = dep_with_fonte(DepSource::Git {
6741 repo: "https://github.com/pleme-io/`whoami`/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, "https://github.com/pleme-io/`whoami`/caixa-teia");
6752 assert!(
6753 reason.contains("must not contain `` ` ``"),
6754 "reason must surface the backtick command-substitution arm, got {reason:?}"
6755 );
6756 assert!(
6757 reason.contains("command-substitution") || reason.contains("'unwise'"),
6758 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6759 got {reason:?}"
6760 );
6761 }
6762
6763 #[test]
6764 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6765 // Cascade pin: the fragment-`#` arm and the backtick command-
6766 // substitution arm are both per-byte arms inside the same
6767 // `for &b in s.as_bytes()` loop, so the byte that appears first
6768 // in the value's byte order wins. A `:repo
6769 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6770 // and backtick; the `#` byte appears first, so the fragment-
6771 // `#` arm fires, surfacing the more self-locating diagnostic
6772 // on the byte the author pasted earliest in the URL. Mirrors
6773 // the peer cascade discipline
6774 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6775 // pins on the prior `:repo` byte-class arm.
6776 let d = dep_with_fonte(DepSource::Git {
6777 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6778 tag: Some("v0.1.0".into()),
6779 rev: None,
6780 branch: None,
6781 });
6782 let err = d.validate().unwrap_err();
6783 let DepError::FonteRepoShape { reason, .. } = err else {
6784 panic!("expected FonteRepoShape, got other variant");
6785 };
6786 assert!(
6787 reason.contains("must not contain `#`"),
6788 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6789 appears first in value), got {reason:?}"
6790 );
6791 }
6792
6793 #[test]
6794 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6795 // Cascade pin: the shell-redirection `<` / `>` arm and the
6796 // backtick command-substitution arm are both per-byte arms
6797 // inside the same `for &b in s.as_bytes()` loop, so the byte
6798 // that appears first in the value's byte order wins. A `:repo
6799 // "https://github.com/p/x>build.log/`whoami`"` carries both
6800 // `>` and backtick; the `>` byte appears first, so the
6801 // shell-redirection arm fires, surfacing the more self-
6802 // locating diagnostic on the byte the author pasted earliest
6803 // in the URL. Pins the natural-order cascade so a future
6804 // reorder of the per-byte arms surfaces here.
6805 let d = dep_with_fonte(DepSource::Git {
6806 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6807 tag: Some("v0.1.0".into()),
6808 rev: None,
6809 branch: None,
6810 });
6811 let err = d.validate().unwrap_err();
6812 let DepError::FonteRepoShape { reason, .. } = err else {
6813 panic!("expected FonteRepoShape, got other variant");
6814 };
6815 assert!(
6816 reason.contains("must not contain `>`"),
6817 "reason must surface the shell-redirection `>` arm (fires before backtick when \
6818 `>` byte appears first in value), got {reason:?}"
6819 );
6820 }
6821
6822 #[test]
6823 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6824 // Cascade pin: the fragment-`#` arm and the shell-redirection
6825 // `<` / `>` arm are both per-byte arms inside the same
6826 // `for &b in s.as_bytes()` loop, so the byte that appears
6827 // first in the value's byte order wins. A `:repo
6828 // "https://github.com/p/x#readme>build.log"` carries both
6829 // `#` and `>`; the `#` byte appears first, so the fragment-
6830 // `#` arm fires, surfacing the more self-locating diagnostic
6831 // on the byte the author pasted earliest in the URL. Mirrors
6832 // the peer cascade discipline
6833 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6834 // pins on the prior `:repo` byte-class arm.
6835 let d = dep_with_fonte(DepSource::Git {
6836 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6837 tag: Some("v0.1.0".into()),
6838 rev: None,
6839 branch: None,
6840 });
6841 let err = d.validate().unwrap_err();
6842 let DepError::FonteRepoShape { reason, .. } = err else {
6843 panic!("expected FonteRepoShape, got other variant");
6844 };
6845 assert!(
6846 reason.contains("must not contain `#`"),
6847 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6848 `#` byte appears first in value), got {reason:?}"
6849 );
6850 }
6851
6852 #[test]
6853 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6854 // The fail-before-pass-after pin for the canonical
6855 // paste-from-shell-prompt-with-piped-pipeline footgun on
6856 // `:repo` (peer with the 124106f pipe arm on the sibling
6857 // `:caminho` path-fonte axis). An author pastes a shell
6858 // pipeline (`git clone <url> | tee build.log`,
6859 // `git ls-remote <url> | head`) into the `:repo` slot,
6860 // forgetting to trim the `| <consumer>` tail. Until this arm
6861 // landed the value silently passed every prior arm (no
6862 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6863 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6864 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6865 // 'unwise' set and the WHATWG URL spec's fragment percent-
6866 // encode set maps `|` → `%7C` on the wire, so the byte rides
6867 // verbatim into the lacre's per-dep BLAKE3 closure but is
6868 // silently rewritten or rejected at libcurl's URL-parser
6869 // layer — two authors whose values differ only in their pipe
6870 // tail (`|tee build.log` vs nothing) resolve to the byte-
6871 // identical upstream `git clone` but lock to two distinct
6872 // lacres, defeating the THEORY.md §V.2 render-determinism
6873 // contract. Peer with the `:caminho` axis's
6874 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6875 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6876 // RFC-3986-reserved set on `:entrada :paths`.
6877 let d = dep_with_fonte(DepSource::Git {
6878 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6879 tag: Some("v0.1.0".into()),
6880 rev: None,
6881 branch: None,
6882 });
6883 let err = d.validate().unwrap_err();
6884 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6885 panic!("expected FonteRepoShape, got other variant");
6886 };
6887 assert_eq!(nome, "caixa-teia");
6888 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6889 assert!(
6890 reason.contains("must not contain `|`"),
6891 "reason must surface the shell-pipe arm, got {reason:?}"
6892 );
6893 assert!(
6894 reason.contains("pipe") || reason.contains("'unwise'"),
6895 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6896 );
6897 }
6898
6899 #[test]
6900 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6901 // Cascade pin: the fragment-`#` arm and the pipe arm are both
6902 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6903 // so the byte that appears first in the value's byte order
6904 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6905 // both `#` and `|`; the `#` byte appears first, so the
6906 // fragment-`#` arm fires, surfacing the more self-locating
6907 // diagnostic on the byte the author pasted earliest in the
6908 // URL. Mirrors the peer cascade discipline
6909 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6910 // pins on the prior `:repo` byte-class arm.
6911 let d = dep_with_fonte(DepSource::Git {
6912 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6913 tag: Some("v0.1.0".into()),
6914 rev: None,
6915 branch: None,
6916 });
6917 let err = d.validate().unwrap_err();
6918 let DepError::FonteRepoShape { reason, .. } = err else {
6919 panic!("expected FonteRepoShape, got other variant");
6920 };
6921 assert!(
6922 reason.contains("must not contain `#`"),
6923 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6924 appears first in value), got {reason:?}"
6925 );
6926 }
6927
6928 #[test]
6929 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6930 // Cascade pin: the backtick arm and the pipe arm are both per-
6931 // byte arms inside the same `for &b in s.as_bytes()` loop, so
6932 // the byte that appears first in the value's byte order wins.
6933 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6934 // `` ` `` and `|`; the backtick byte appears first, so the
6935 // backtick arm fires, surfacing the more self-locating
6936 // diagnostic on the byte the author pasted earliest in the
6937 // URL. Pins the natural-order cascade so a future reorder of
6938 // the per-byte arms surfaces here.
6939 let d = dep_with_fonte(DepSource::Git {
6940 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6941 tag: Some("v0.1.0".into()),
6942 rev: None,
6943 branch: None,
6944 });
6945 let err = d.validate().unwrap_err();
6946 let DepError::FonteRepoShape { reason, .. } = err else {
6947 panic!("expected FonteRepoShape, got other variant");
6948 };
6949 assert!(
6950 reason.contains("must not contain `` ` ``"),
6951 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6952 appears first in value), got {reason:?}"
6953 );
6954 }
6955
6956 #[test]
6957 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6958 // The fail-before-pass-after pin for the canonical
6959 // paste-from-shell-prompt-with-sequential-command-tail footgun
6960 // on `:repo` (peer with the 05c358e `;` arm on the sibling
6961 // `:caminho` path-fonte axis). An author pastes a shell
6962 // one-liner that chained a cleanup tail after the URL
6963 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6964 // echo done`) into the `:repo` slot, forgetting to trim the
6965 // `; <cmd>` tail. Until this arm landed the value silently
6966 // passed every prior `is_git_repo_url` arm (no whitespace, no
6967 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6968 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6969 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6970 // reserved set and the WHATWG URL spec's fragment percent-
6971 // encode set maps `;` → `%3B` on the wire, so the byte rides
6972 // verbatim into the lacre's per-dep BLAKE3 closure but is
6973 // silently rewritten at libcurl's URL-parser layer — two
6974 // authors whose values differ only in their sequential-command
6975 // tail (`; rm -rf build` vs nothing) resolve to the byte-
6976 // identical upstream `git clone` but lock to two distinct
6977 // lacres, defeating the THEORY.md §V.2 render-determinism
6978 // contract. Peer with the `:caminho` axis's
6979 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6980 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6981 // byte RFC-3986-reserved set on `:entrada :paths`.
6982 let d = dep_with_fonte(DepSource::Git {
6983 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6984 tag: Some("v0.1.0".into()),
6985 rev: None,
6986 branch: None,
6987 });
6988 let err = d.validate().unwrap_err();
6989 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6990 panic!("expected FonteRepoShape, got other variant");
6991 };
6992 assert_eq!(nome, "caixa-teia");
6993 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6994 assert!(
6995 reason.contains("must not contain `;`"),
6996 "reason must surface the shell-command-separator arm, got {reason:?}"
6997 );
6998 assert!(
6999 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7000 "reason must name the shell-command-separator / RFC-3986-sub-delims \
7001 rationale, got {reason:?}"
7002 );
7003 }
7004
7005 #[test]
7006 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7007 // Cascade pin: the fragment-`#` arm and the semicolon arm are
7008 // both per-byte arms inside the same `for &b in s.as_bytes()`
7009 // loop, so the byte that appears first in the value's byte
7010 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7011 // carries both `#` and `;`; the `#` byte appears first, so the
7012 // fragment-`#` arm fires, surfacing the more self-locating
7013 // diagnostic on the byte the author pasted earliest in the URL.
7014 // Mirrors the peer cascade discipline
7015 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7016 // pins on the prior `:repo` byte-class arm.
7017 let d = dep_with_fonte(DepSource::Git {
7018 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7019 tag: Some("v0.1.0".into()),
7020 rev: None,
7021 branch: None,
7022 });
7023 let err = d.validate().unwrap_err();
7024 let DepError::FonteRepoShape { reason, .. } = err else {
7025 panic!("expected FonteRepoShape, got other variant");
7026 };
7027 assert!(
7028 reason.contains("must not contain `#`"),
7029 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7030 byte appears first in value), got {reason:?}"
7031 );
7032 }
7033
7034 #[test]
7035 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7036 // Cascade pin: the pipe arm and the semicolon arm are both
7037 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7038 // so the byte that appears first in the value's byte order
7039 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7040 // both `|` and `;`; the `|` byte appears first, so the
7041 // pipe arm fires, surfacing the more self-locating diagnostic
7042 // on the byte the author pasted earliest in the URL. Pins the
7043 // natural-order cascade so a future reorder of the per-byte
7044 // arms surfaces here.
7045 let d = dep_with_fonte(DepSource::Git {
7046 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7047 tag: Some("v0.1.0".into()),
7048 rev: None,
7049 branch: None,
7050 });
7051 let err = d.validate().unwrap_err();
7052 let DepError::FonteRepoShape { reason, .. } = err else {
7053 panic!("expected FonteRepoShape, got other variant");
7054 };
7055 assert!(
7056 reason.contains("must not contain `|`"),
7057 "reason must surface the pipe arm (fires before semicolon when `|` byte \
7058 appears first in value), got {reason:?}"
7059 );
7060 }
7061
7062 #[test]
7063 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7064 // The fail-before-pass-after pin for the canonical
7065 // paste-from-shell-prompt-with-background-launch-tail footgun
7066 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7067 // `:caminho` path-fonte axis). An author pastes a shell one-
7068 // liner that detached the clone into the background
7069 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7070 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7071 // `&& <cmd>` tail. Until this arm landed the value silently
7072 // passed every prior `is_git_repo_url` arm (no whitespace,
7073 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7074 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7075 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7076 // the 'sub-delims' / reserved set and the WHATWG URL spec's
7077 // fragment percent-encode set maps `&` → `%26` on the wire,
7078 // so the byte rides verbatim into the lacre's per-dep
7079 // BLAKE3 closure but is silently rewritten at libcurl's
7080 // URL-parser layer — two authors whose values differ only
7081 // in their background-launch tail (`& sleep 1` vs nothing)
7082 // resolve to the byte-identical upstream `git clone` but
7083 // lock to two distinct lacres, defeating the THEORY.md
7084 // §V.2 render-determinism contract. Peer with the
7085 // `:caminho` axis's `FonteCaminhoShellBackground` arm
7086 // (e12e4f3) on the sibling path-fonte axis, and
7087 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7088 // reserved set on `:entrada :paths`.
7089 let d = dep_with_fonte(DepSource::Git {
7090 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7091 tag: Some("v0.1.0".into()),
7092 rev: None,
7093 branch: None,
7094 });
7095 let err = d.validate().unwrap_err();
7096 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7097 panic!("expected FonteRepoShape, got other variant");
7098 };
7099 assert_eq!(nome, "caixa-teia");
7100 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7101 assert!(
7102 reason.contains("must not contain `&`"),
7103 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7104 );
7105 assert!(
7106 reason.contains("background-task") || reason.contains("'sub-delims'"),
7107 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7108 got {reason:?}"
7109 );
7110 }
7111
7112 #[test]
7113 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7114 // The fail-before-pass-after pin for the symmetric `&&`
7115 // logical-AND build-chain paste footgun: an author pastes
7116 // a `git clone <url> && cd <repo>` build-chain one-liner
7117 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7118 // is the same `&` byte twice in a row; the per-byte arm
7119 // fires on the first `&` it sees. Pinned separately from
7120 // the single-`&` background-launch shape so a future
7121 // diagnostic-surface change that special-cased the
7122 // doubled-byte form surfaces here.
7123 let d = dep_with_fonte(DepSource::Git {
7124 repo: "github:pleme-io/caixa-teia&&echo".into(),
7125 tag: Some("v0.1.0".into()),
7126 rev: None,
7127 branch: None,
7128 });
7129 let err = d.validate().unwrap_err();
7130 let DepError::FonteRepoShape { reason, .. } = err else {
7131 panic!("expected FonteRepoShape, got other variant");
7132 };
7133 assert!(
7134 reason.contains("must not contain `&`"),
7135 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7136 shape too, got {reason:?}"
7137 );
7138 }
7139
7140 #[test]
7141 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7142 // Cascade pin: the fragment-`#` arm and the background-`&`
7143 // arm are both per-byte arms inside the same `for &b in
7144 // s.as_bytes()` loop, so the byte that appears first in the
7145 // value's byte order wins. A `:repo
7146 // "https://github.com/p/x#readme & sleep"` carries both `#`
7147 // and `&`; the `#` byte appears first, so the fragment-`#`
7148 // arm fires, surfacing the more self-locating diagnostic on
7149 // the byte the author pasted earliest in the URL. Mirrors
7150 // the peer cascade discipline
7151 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7152 // on the prior `:repo` byte-class arm.
7153 let d = dep_with_fonte(DepSource::Git {
7154 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7155 tag: Some("v0.1.0".into()),
7156 rev: None,
7157 branch: None,
7158 });
7159 let err = d.validate().unwrap_err();
7160 let DepError::FonteRepoShape { reason, .. } = err else {
7161 panic!("expected FonteRepoShape, got other variant");
7162 };
7163 assert!(
7164 reason.contains("must not contain `#`"),
7165 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7166 byte appears first in value), got {reason:?}"
7167 );
7168 }
7169
7170 #[test]
7171 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7172 // Cascade pin: the semicolon arm and the background-`&` arm
7173 // are both per-byte arms inside the same `for &b in
7174 // s.as_bytes()` loop, so the byte that appears first in the
7175 // value's byte order wins. A `:repo
7176 // "https://github.com/p/x; rm & sleep"` carries both `;` and
7177 // `&`; the `;` byte appears first, so the semicolon arm
7178 // fires, surfacing the more self-locating diagnostic on the
7179 // byte the author pasted earliest in the URL. Pins the
7180 // natural-order cascade so a future reorder of the per-byte
7181 // arms surfaces here.
7182 let d = dep_with_fonte(DepSource::Git {
7183 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7184 tag: Some("v0.1.0".into()),
7185 rev: None,
7186 branch: None,
7187 });
7188 let err = d.validate().unwrap_err();
7189 let DepError::FonteRepoShape { reason, .. } = err else {
7190 panic!("expected FonteRepoShape, got other variant");
7191 };
7192 assert!(
7193 reason.contains("must not contain `;`"),
7194 "reason must surface the semicolon arm (fires before background-`&` when `;` \
7195 byte appears first in value), got {reason:?}"
7196 );
7197 }
7198
7199 #[test]
7200 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7201 // The fail-before-pass-after pin for the canonical
7202 // paste-from-shell-prompt-with-unsubstituted-variable footgun
7203 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7204 // `:caminho` path-fonte axis). An author pastes a shell one-
7205 // liner that referenced an environment variable
7206 // (`git clone https://github.com/$ORG/x`, `git clone
7207 // github:$USER/repo`) into the `:repo` slot, forgetting to
7208 // substitute the literal value at author time. Until this arm
7209 // landed the value silently passed every prior
7210 // `is_git_repo_url` arm (no whitespace, no control chars, no
7211 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7212 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7213 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7214 // reserved set and the WHATWG URL spec's fragment percent-
7215 // encode set maps `$` → `%24` on the wire, so the byte rides
7216 // verbatim into the lacre's per-dep BLAKE3 closure but is
7217 // silently rewritten at libcurl's URL-parser layer — two
7218 // authors whose values differ only in their `$VAR` /
7219 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7220 // identical upstream `git clone` but lock to two distinct
7221 // lacres, defeating the THEORY.md §V.2 render-determinism
7222 // contract. Beyond determinism, the value is a structural
7223 // host-layout leak: two authors with the same `:repo` slot
7224 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7225 // different upstreams. Peer with the `:caminho` axis's
7226 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7227 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7228 // byte RFC-3986-reserved set on `:entrada :paths`.
7229 let d = dep_with_fonte(DepSource::Git {
7230 repo: "https://github.com/$ORG/caixa-teia".into(),
7231 tag: Some("v0.1.0".into()),
7232 rev: None,
7233 branch: None,
7234 });
7235 let err = d.validate().unwrap_err();
7236 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7237 panic!("expected FonteRepoShape, got other variant");
7238 };
7239 assert_eq!(nome, "caixa-teia");
7240 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7241 assert!(
7242 reason.contains("must not contain `$`"),
7243 "reason must surface the shell-variable-expansion arm, got {reason:?}"
7244 );
7245 assert!(
7246 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7247 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7248 rationale, got {reason:?}"
7249 );
7250 }
7251
7252 #[test]
7253 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7254 // The fail-before-pass-after pin for the symmetric POSIX-
7255 // shell braced `${VAR}` expansion paste footgun: an author
7256 // pastes a CI-manifest line `git clone
7257 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7258 // Actions / GitLab CI / Drone shape) and forgets to
7259 // substitute the literal value. The `${...}` shape is the
7260 // same `$` byte at the leading position of the expansion;
7261 // the per-byte arm fires on the `$`. Pinned separately from
7262 // the bare-`$VAR` shape so a future diagnostic-surface
7263 // change that special-cased the braced form surfaces here.
7264 let d = dep_with_fonte(DepSource::Git {
7265 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7266 tag: Some("v0.1.0".into()),
7267 rev: None,
7268 branch: None,
7269 });
7270 let err = d.validate().unwrap_err();
7271 let DepError::FonteRepoShape { reason, .. } = err else {
7272 panic!("expected FonteRepoShape, got other variant");
7273 };
7274 assert!(
7275 reason.contains("must not contain `$`"),
7276 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7277 shape too, got {reason:?}"
7278 );
7279 }
7280
7281 #[test]
7282 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7283 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7284 // arm are both per-byte arms inside the same `for &b in
7285 // s.as_bytes()` loop, so the byte that appears first in the
7286 // value's byte order wins. A `:repo
7287 // "https://github.com/p/x#readme$HOME"` carries both `#` and
7288 // `$`; the `#` byte appears first, so the fragment-`#` arm
7289 // fires, surfacing the more self-locating diagnostic on the
7290 // byte the author pasted earliest in the URL. Mirrors the
7291 // peer cascade discipline
7292 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7293 // on the prior `:repo` byte-class arm.
7294 let d = dep_with_fonte(DepSource::Git {
7295 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7296 tag: Some("v0.1.0".into()),
7297 rev: None,
7298 branch: None,
7299 });
7300 let err = d.validate().unwrap_err();
7301 let DepError::FonteRepoShape { reason, .. } = err else {
7302 panic!("expected FonteRepoShape, got other variant");
7303 };
7304 assert!(
7305 reason.contains("must not contain `#`"),
7306 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7307 `#` byte appears first in value), got {reason:?}"
7308 );
7309 }
7310
7311 #[test]
7312 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7313 // Cascade pin: the background-`&` arm and the
7314 // var-expansion-`$` arm are both per-byte arms inside the
7315 // same `for &b in s.as_bytes()` loop, so the byte that
7316 // appears first in the value's byte order wins. A `:repo
7317 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7318 // `$`; the `&` byte appears first, so the background arm
7319 // fires, surfacing the more self-locating diagnostic on the
7320 // byte the author pasted earliest in the URL. Pins the
7321 // natural-order cascade so a future reorder of the per-byte
7322 // arms surfaces here — `$` is the most recent byte-class arm,
7323 // so the cascade-pin sweep extends to cover every immediately
7324 // prior byte arm (`#`, `&`) firing first when ordered ahead
7325 // of `$` in the value.
7326 let d = dep_with_fonte(DepSource::Git {
7327 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7328 tag: Some("v0.1.0".into()),
7329 rev: None,
7330 branch: None,
7331 });
7332 let err = d.validate().unwrap_err();
7333 let DepError::FonteRepoShape { reason, .. } = err else {
7334 panic!("expected FonteRepoShape, got other variant");
7335 };
7336 assert!(
7337 reason.contains("must not contain `&`"),
7338 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7339 `&` byte appears first in value), got {reason:?}"
7340 );
7341 }
7342
7343 #[test]
7344 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7345 // The fail-before-pass-after pin for the canonical
7346 // paste-from-shell-prompt glob footgun on `:repo` (peer with
7347 // the cf9034b `*` / `?` arm on the sibling `:caminho`
7348 // path-fonte axis). An author pastes a shell one-liner that
7349 // referenced a glob expansion (`ls
7350 // github.com/pleme-io/caixa-*`, `git clone
7351 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7352 // to substitute the literal repo name. Until this arm landed
7353 // the `*` byte silently passed every prior `is_git_repo_url`
7354 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7355 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7356 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7357 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7358 // the WHATWG URL spec's special-query percent-encode set maps
7359 // `*` → `%2A` on the wire, so the byte rides verbatim into
7360 // the lacre's per-dep BLAKE3 closure but is silently
7361 // rewritten at libcurl's URL-parser layer — two authors
7362 // whose values differ only in their asterisk presence
7363 // resolve to the byte-identical upstream `git clone` but
7364 // lock to two distinct lacres, defeating the THEORY.md §V.2
7365 // render-determinism contract. Peer with the `:caminho`
7366 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7367 // sibling path-fonte axis, and the `is_git_ref_name`
7368 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7369 // axes.
7370 let d = dep_with_fonte(DepSource::Git {
7371 repo: "https://github.com/pleme-io/caixa-*".into(),
7372 tag: Some("v0.1.0".into()),
7373 rev: None,
7374 branch: None,
7375 });
7376 let err = d.validate().unwrap_err();
7377 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7378 panic!("expected FonteRepoShape, got other variant");
7379 };
7380 assert_eq!(nome, "caixa-teia");
7381 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7382 assert!(
7383 reason.contains("must not contain `*`"),
7384 "reason must surface the shell-glob arm, got {reason:?}"
7385 );
7386 assert!(
7387 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7388 "reason must name the shell-glob / pathname-expansion / \
7389 RFC-3986-sub-delims rationale, got {reason:?}"
7390 );
7391 }
7392
7393 #[test]
7394 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7395 // The fail-before-pass-after pin for the symmetric bash
7396 // `globstar` recursive-glob paste footgun: an author pastes
7397 // a `ls github.com/pleme-io/**/x` (the canonical
7398 // `globstar`-shopt-enabled recursive-listing tail) into the
7399 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7400 // the per-byte arm fires on the first `*`. Pinned
7401 // separately from the single-`*` shape so a future
7402 // diagnostic-surface change that special-cased the
7403 // double-`*` form surfaces here.
7404 let d = dep_with_fonte(DepSource::Git {
7405 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7406 tag: Some("v0.1.0".into()),
7407 rev: None,
7408 branch: None,
7409 });
7410 let err = d.validate().unwrap_err();
7411 let DepError::FonteRepoShape { reason, .. } = err else {
7412 panic!("expected FonteRepoShape, got other variant");
7413 };
7414 assert!(
7415 reason.contains("must not contain `*`"),
7416 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7417 got {reason:?}"
7418 );
7419 }
7420
7421 #[test]
7422 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7423 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7424 // both per-byte arms inside the same `for &b in s.as_bytes()`
7425 // loop, so the byte that appears first in the value's byte
7426 // order wins. A `:repo
7427 // "https://github.com/p/x#readme*tail"` carries both `#` and
7428 // `*`; the `#` byte appears first, so the fragment-`#` arm
7429 // fires, surfacing the more self-locating diagnostic on the
7430 // byte the author pasted earliest in the URL. Mirrors the
7431 // peer cascade discipline
7432 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7433 // on the prior `:repo` byte-class arm.
7434 let d = dep_with_fonte(DepSource::Git {
7435 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7436 tag: Some("v0.1.0".into()),
7437 rev: None,
7438 branch: None,
7439 });
7440 let err = d.validate().unwrap_err();
7441 let DepError::FonteRepoShape { reason, .. } = err else {
7442 panic!("expected FonteRepoShape, got other variant");
7443 };
7444 assert!(
7445 reason.contains("must not contain `#`"),
7446 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7447 appears first in value), got {reason:?}"
7448 );
7449 }
7450
7451 #[test]
7452 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7453 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7454 // arm are both per-byte arms inside the same `for &b in
7455 // s.as_bytes()` loop, so the byte that appears first in the
7456 // value's byte order wins. A `:repo
7457 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7458 // the `$` byte appears first, so the var-expansion arm
7459 // fires, surfacing the more self-locating diagnostic on the
7460 // byte the author pasted earliest in the URL. Pins the
7461 // natural-order cascade so a future reorder of the per-byte
7462 // arms surfaces here — `*` is the most recent byte-class
7463 // arm, so the cascade-pin sweep extends to cover the
7464 // immediately prior `$` byte arm firing first when ordered
7465 // ahead of `*` in the value.
7466 let d = dep_with_fonte(DepSource::Git {
7467 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7468 tag: Some("v0.1.0".into()),
7469 rev: None,
7470 branch: None,
7471 });
7472 let err = d.validate().unwrap_err();
7473 let DepError::FonteRepoShape { reason, .. } = err else {
7474 panic!("expected FonteRepoShape, got other variant");
7475 };
7476 assert!(
7477 reason.contains("must not contain `$`"),
7478 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7479 byte appears first in value), got {reason:?}"
7480 );
7481 }
7482
7483 #[test]
7484 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7485 // The fail-before-pass-after pin for the canonical paste-from-
7486 // shell-prompt subshell-grouping footgun on `:repo`. An author
7487 // pastes a doc / README snippet carrying a regex-alternation
7488 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7489 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7490 // `:repo` slot, forgetting to substitute one literal org name.
7491 // Until this arm landed the `(` byte silently passed every
7492 // prior `is_git_repo_url` arm (no whitespace, no control
7493 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7494 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7495 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7496 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7497 // URL spec's special-query percent-encode set maps `(` →
7498 // `%28` and `)` → `%29` on the wire, so the byte rides
7499 // verbatim into the lacre's per-dep BLAKE3 closure but is
7500 // silently rewritten at libcurl's URL-parser layer —
7501 // defeating the THEORY.md §V.2 render-determinism contract on
7502 // the same axis the prior twelve byte-class arms close.
7503 let d = dep_with_fonte(DepSource::Git {
7504 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7505 tag: Some("v0.1.0".into()),
7506 rev: None,
7507 branch: None,
7508 });
7509 let err = d.validate().unwrap_err();
7510 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7511 panic!("expected FonteRepoShape, got other variant");
7512 };
7513 assert_eq!(nome, "caixa-teia");
7514 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7515 assert!(
7516 reason.contains("must not contain `(`"),
7517 "reason must surface the subshell-open-paren arm, got {reason:?}"
7518 );
7519 assert!(
7520 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7521 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7522 got {reason:?}"
7523 );
7524 }
7525
7526 #[test]
7527 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7528 // The symmetric arm pin on the closing `)` byte: an author
7529 // pastes a `$(date)` command-substitution wrapper or a
7530 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7531 // Pinned separately from the opening `(` shape so a future
7532 // diagnostic-surface change that only checked one boundary
7533 // surfaces here. The `(` byte appears earlier in the
7534 // canonical regex / subshell wrapper so the per-byte loop
7535 // fires on `(` first; this test exercises a `:repo` value
7536 // carrying only the closing `)` byte (no opening paren) so
7537 // the `)` arm fires directly — pinning the byte-class arm
7538 // independent of order.
7539 let d = dep_with_fonte(DepSource::Git {
7540 repo: "github:pleme-io/caixa-teia)tail".into(),
7541 tag: Some("v0.1.0".into()),
7542 rev: None,
7543 branch: None,
7544 });
7545 let err = d.validate().unwrap_err();
7546 let DepError::FonteRepoShape { reason, .. } = err else {
7547 panic!("expected FonteRepoShape, got other variant");
7548 };
7549 assert!(
7550 reason.contains("must not contain `)`"),
7551 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7552 got {reason:?}"
7553 );
7554 }
7555
7556 #[test]
7557 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7558 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7559 // are both per-byte arms inside the same `for &b in
7560 // s.as_bytes()` loop, so the byte that appears first in the
7561 // value's byte order wins. A `:repo
7562 // "https://github.com/p/x#readme(tail)"` carries both `#` and
7563 // `(`; the `#` byte appears first, so the fragment-`#` arm
7564 // fires, surfacing the more self-locating diagnostic on the
7565 // byte the author pasted earliest in the URL. Mirrors the
7566 // peer cascade discipline
7567 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7568 // on the prior `:repo` byte-class arm.
7569 let d = dep_with_fonte(DepSource::Git {
7570 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7571 tag: Some("v0.1.0".into()),
7572 rev: None,
7573 branch: None,
7574 });
7575 let err = d.validate().unwrap_err();
7576 let DepError::FonteRepoShape { reason, .. } = err else {
7577 panic!("expected FonteRepoShape, got other variant");
7578 };
7579 assert!(
7580 reason.contains("must not contain `#`"),
7581 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7582 byte appears first in value), got {reason:?}"
7583 );
7584 }
7585
7586 #[test]
7587 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7588 // Cascade pin: the glob-`*` arm (the immediate-predecessor
7589 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7590 // per-byte arms inside the same `for &b in s.as_bytes()`
7591 // loop, so the byte that appears first in the value's byte
7592 // order wins. A `:repo
7593 // "https://github.com/p/x-*-(date)"` carries both `*` and
7594 // `(`; the `*` byte appears first, so the glob arm fires,
7595 // surfacing the more self-locating diagnostic on the byte
7596 // the author pasted earliest in the URL. Pins the natural-
7597 // order cascade so a future reorder of the per-byte arms
7598 // surfaces here — `(` is the most recent byte-class arm,
7599 // so the cascade-pin sweep extends to cover the immediately
7600 // prior `*` byte arm firing first when ordered ahead of `(`
7601 // in the value.
7602 let d = dep_with_fonte(DepSource::Git {
7603 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7604 tag: Some("v0.1.0".into()),
7605 rev: None,
7606 branch: None,
7607 });
7608 let err = d.validate().unwrap_err();
7609 let DepError::FonteRepoShape { reason, .. } = err else {
7610 panic!("expected FonteRepoShape, got other variant");
7611 };
7612 assert!(
7613 reason.contains("must not contain `*`"),
7614 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7615 appears first in value), got {reason:?}"
7616 );
7617 }
7618
7619 #[test]
7620 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7621 // The fail-before-pass-after pin for the canonical paste-from-
7622 // doc-shell-quoting footgun on `:repo`. An author copies a
7623 // README quick-start snippet (`$ git clone "https://github.com/
7624 // foo/bar"`) and keeps the surrounding double-quote bytes when
7625 // pasting into the `:repo` slot — the doc wraps the URL in
7626 // double quotes so the shell doesn't re-lex metachars inside,
7627 // but the typed slot is itself a byte-level string parser, not
7628 // a shell context, so the quote bytes ride into the value
7629 // verbatim. Until this arm landed the `"` byte silently passed
7630 // every prior `is_git_repo_url` arm (no whitespace, no control
7631 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7632 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7633 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7634 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7635 // `` ` ``) every URL parser is required to refuse or percent-
7636 // encode, and the WHATWG URL spec's 'C0 control percent-encode
7637 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7638 // into the lacre's per-dep BLAKE3 closure but is silently
7639 // rewritten at libcurl's URL-parser layer, defeating the
7640 // THEORY.md §V.2 render-determinism contract.
7641 let d = dep_with_fonte(DepSource::Git {
7642 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7643 tag: Some("v0.1.0".into()),
7644 rev: None,
7645 branch: None,
7646 });
7647 let err = d.validate().unwrap_err();
7648 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7649 panic!("expected FonteRepoShape, got other variant");
7650 };
7651 assert_eq!(nome, "caixa-teia");
7652 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7653 assert!(
7654 reason.contains("must not contain `\"`"),
7655 "reason must surface the shell-double-quote arm, got {reason:?}"
7656 );
7657 assert!(
7658 reason.contains("double-quote") || reason.contains("'delims'"),
7659 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7660 got {reason:?}"
7661 );
7662 }
7663
7664 #[test]
7665 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7666 // The symmetric stray-quote tail pin: an author pastes only a
7667 // closing `"` from a shell-history line like `git clone
7668 // "https://github.com/foo/bar" && cd …` (the trim went too
7669 // far in one direction but not the other) into the `:repo`
7670 // slot. Pinned separately from the wrapped-quote shape so a
7671 // future diagnostic-surface change that only checked one
7672 // boundary (only leading, only trailing, only paired) surfaces
7673 // here — the per-byte arm fires anywhere `"` appears.
7674 let d = dep_with_fonte(DepSource::Git {
7675 repo: "github:pleme-io/caixa-teia\"".into(),
7676 tag: Some("v0.1.0".into()),
7677 rev: None,
7678 branch: None,
7679 });
7680 let err = d.validate().unwrap_err();
7681 let DepError::FonteRepoShape { reason, .. } = err else {
7682 panic!("expected FonteRepoShape, got other variant");
7683 };
7684 assert!(
7685 reason.contains("must not contain `\"`"),
7686 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7687 got {reason:?}"
7688 );
7689 }
7690
7691 #[test]
7692 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7693 // Cascade pin: the fragment-`#` arm and the double-quote arm
7694 // are both per-byte arms inside the same `for &b in
7695 // s.as_bytes()` loop, so the byte that appears first in the
7696 // value's byte order wins. A `:repo
7697 // "https://github.com/p/x#readme\"tail"` carries both `#` and
7698 // `"`; the `#` byte appears first, so the fragment-`#` arm
7699 // fires, surfacing the more self-locating diagnostic on the
7700 // byte the author pasted earliest in the URL.
7701 let d = dep_with_fonte(DepSource::Git {
7702 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7703 tag: Some("v0.1.0".into()),
7704 rev: None,
7705 branch: None,
7706 });
7707 let err = d.validate().unwrap_err();
7708 let DepError::FonteRepoShape { reason, .. } = err else {
7709 panic!("expected FonteRepoShape, got other variant");
7710 };
7711 assert!(
7712 reason.contains("must not contain `#`"),
7713 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7714 byte appears first in value), got {reason:?}"
7715 );
7716 }
7717
7718 #[test]
7719 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7720 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7721 // byte-class arm, 3b99147) and the double-quote arm are both
7722 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7723 // so the byte that appears first in the value's byte order
7724 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7725 // and `"`; the `(` byte appears first, so the subshell arm
7726 // fires, surfacing the more self-locating diagnostic on the
7727 // byte the author pasted earliest in the URL. Pins the natural-
7728 // order cascade so a future reorder of the per-byte arms
7729 // surfaces here — `"` is the most recent byte-class arm, so
7730 // the cascade-pin sweep extends to cover the immediately prior
7731 // `(` byte arm firing first when ordered ahead of `"` in the
7732 // value.
7733 let d = dep_with_fonte(DepSource::Git {
7734 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7735 tag: Some("v0.1.0".into()),
7736 rev: None,
7737 branch: None,
7738 });
7739 let err = d.validate().unwrap_err();
7740 let DepError::FonteRepoShape { reason, .. } = err else {
7741 panic!("expected FonteRepoShape, got other variant");
7742 };
7743 assert!(
7744 reason.contains("must not contain `(`"),
7745 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7746 byte appears first in value), got {reason:?}"
7747 );
7748 }
7749
7750 #[test]
7751 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7752 // The fail-before-pass-after pin for the canonical paste-from-
7753 // doc-strong-quoting footgun on `:repo`. An author copies a
7754 // security-conscious README quick-start snippet (`$ git clone
7755 // 'https://github.com/foo/bar'`) and keeps the surrounding
7756 // single-quote bytes when pasting into the `:repo` slot — the
7757 // doc strong-quotes the URL so the shell suppresses every form
7758 // of expansion on the bytes inside (no `$`, no backtick, no
7759 // glob, no word-splitting), but the typed slot is itself a
7760 // byte-level string parser, not a shell context, so the quote
7761 // bytes ride into the value verbatim. Until this arm landed the
7762 // `'` byte silently passed every prior `is_git_repo_url` arm
7763 // (no whitespace, no control chars, no non-ASCII, no `#`, no
7764 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7765 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7766 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7767 // set, peer with the `\"` 'delims' double-quote arm and the
7768 // partner ASCII shell-string-delimiter byte every byte-level
7769 // string parser sharing a value-shape with a shell argument
7770 // must refuse on a URL-shaped slot.
7771 let d = dep_with_fonte(DepSource::Git {
7772 repo: "'https://github.com/pleme-io/caixa-teia'".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 { nome, repo, reason } = err else {
7779 panic!("expected FonteRepoShape, got other variant");
7780 };
7781 assert_eq!(nome, "caixa-teia");
7782 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7783 assert!(
7784 reason.contains("must not contain `'`"),
7785 "reason must surface the shell-single-quote arm, got {reason:?}"
7786 );
7787 assert!(
7788 reason.contains("single-quote") || reason.contains("strong-quote"),
7789 "reason must name the shell-single-quote / strong-quote rationale, \
7790 got {reason:?}"
7791 );
7792 }
7793
7794 #[test]
7795 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7796 // The symmetric English-typography pin: an author writes
7797 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7798 // from-prose idiom every README / commit-message / chat-thread
7799 // reference to a repo carries) expecting the substrate to
7800 // coerce it to a kebab-case slug — but the byte rides into the
7801 // lacre verbatim. Pinned separately from the wrapped-quote
7802 // shape so a future diagnostic-surface change that only checked
7803 // the boundary positions (only leading, only trailing, only
7804 // paired) surfaces here — the per-byte arm fires anywhere `'`
7805 // appears in the value.
7806 let d = dep_with_fonte(DepSource::Git {
7807 repo: "github:pleme-io/repo's-fork".into(),
7808 tag: Some("v0.1.0".into()),
7809 rev: None,
7810 branch: None,
7811 });
7812 let err = d.validate().unwrap_err();
7813 let DepError::FonteRepoShape { reason, .. } = err else {
7814 panic!("expected FonteRepoShape, got other variant");
7815 };
7816 assert!(
7817 reason.contains("must not contain `'`"),
7818 "reason must surface the shell-single-quote arm on the mid-string \
7819 apostrophe shape, got {reason:?}"
7820 );
7821 }
7822
7823 #[test]
7824 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7825 // Cascade pin: the fragment-`#` arm and the single-quote arm
7826 // are both per-byte arms inside the same `for &b in
7827 // s.as_bytes()` loop, so the byte that appears first in the
7828 // value's byte order wins. A `:repo
7829 // "https://github.com/p/x#readme'tail"` carries both `#` and
7830 // `'`; the `#` byte appears first, so the fragment-`#` arm
7831 // fires, surfacing the more self-locating diagnostic on the
7832 // byte the author pasted earliest in the URL.
7833 let d = dep_with_fonte(DepSource::Git {
7834 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7835 tag: Some("v0.1.0".into()),
7836 rev: None,
7837 branch: None,
7838 });
7839 let err = d.validate().unwrap_err();
7840 let DepError::FonteRepoShape { reason, .. } = err else {
7841 panic!("expected FonteRepoShape, got other variant");
7842 };
7843 assert!(
7844 reason.contains("must not contain `#`"),
7845 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7846 byte appears first in value), got {reason:?}"
7847 );
7848 }
7849
7850 #[test]
7851 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7852 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7853 // byte-class arm, 4267d8b) and the single-quote arm are both
7854 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7855 // so the byte that appears first in the value's byte order
7856 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7857 // `'`; the `"` byte appears first, so the double-quote arm
7858 // fires, surfacing the more self-locating diagnostic on the
7859 // byte the author pasted earliest in the URL. Pins the natural-
7860 // order cascade so a future reorder of the per-byte arms
7861 // surfaces here — `'` is the most recent byte-class arm, so
7862 // the cascade-pin sweep extends to cover the immediately prior
7863 // `"` byte arm firing first when ordered ahead of `'` in the
7864 // value.
7865 let d = dep_with_fonte(DepSource::Git {
7866 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7867 tag: Some("v0.1.0".into()),
7868 rev: None,
7869 branch: None,
7870 });
7871 let err = d.validate().unwrap_err();
7872 let DepError::FonteRepoShape { reason, .. } = err else {
7873 panic!("expected FonteRepoShape, got other variant");
7874 };
7875 assert!(
7876 reason.contains("must not contain `\"`"),
7877 "reason must surface the double-quote arm (fires before single-quote when `\"` \
7878 byte appears first in value), got {reason:?}"
7879 );
7880 }
7881
7882 #[test]
7883 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7884 // The fail-before-pass-after pin for the canonical paste-from-
7885 // shell-history footgun on `:repo`. An author copies a `git
7886 // clone <url>!sudo make install` one-liner from a README's
7887 // quick-start snippet, intending the trailing `!sudo` as a
7888 // shell-history-expansion reference but the typed slot is itself
7889 // a byte-level string parser, not a shell context, so the byte
7890 // rides into the value verbatim. Until this arm landed the `!`
7891 // byte silently passed every prior `is_git_repo_url` arm (no
7892 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7893 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7894 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7895 // start with `-` or `:`); bash with the default `histexpand`
7896 // mode rewrites `!command` to the most recent history entry
7897 // beginning with `command`, the canonical RCE-class injection
7898 // vector when the byte rides into a shell argument.
7899 let d = dep_with_fonte(DepSource::Git {
7900 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7901 tag: Some("v0.1.0".into()),
7902 rev: None,
7903 branch: None,
7904 });
7905 let err = d.validate().unwrap_err();
7906 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7907 panic!("expected FonteRepoShape, got other variant");
7908 };
7909 assert_eq!(nome, "caixa-teia");
7910 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7911 assert!(
7912 reason.contains("must not contain `!`"),
7913 "reason must surface the shell-history-expansion arm, got {reason:?}"
7914 );
7915 assert!(
7916 reason.contains("history-expansion") || reason.contains("bang"),
7917 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7918 );
7919 }
7920
7921 #[test]
7922 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7923 // The symmetric `!!` repeat-prior-command pin: an author paste-
7924 // trims a `git clone <url>` retry idiom from shell history that
7925 // expands to the previous command via `!!`. Pinned separately
7926 // from the wrapped `!command` shape so a future diagnostic-
7927 // surface change that only checked the leading or paired-bang
7928 // position surfaces here — the per-byte arm fires anywhere `!`
7929 // appears in the value.
7930 let d = dep_with_fonte(DepSource::Git {
7931 repo: "github:pleme-io/caixa-teia!!".into(),
7932 tag: Some("v0.1.0".into()),
7933 rev: None,
7934 branch: None,
7935 });
7936 let err = d.validate().unwrap_err();
7937 let DepError::FonteRepoShape { reason, .. } = err else {
7938 panic!("expected FonteRepoShape, got other variant");
7939 };
7940 assert!(
7941 reason.contains("must not contain `!`"),
7942 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7943 got {reason:?}"
7944 );
7945 }
7946
7947 #[test]
7948 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7949 // Cascade pin: the fragment-`#` arm and the bang arm are both
7950 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7951 // so the byte that appears first in the value's byte order
7952 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7953 // both `#` and `!`; the `#` byte appears first, so the
7954 // fragment-`#` arm fires, surfacing the more self-locating
7955 // diagnostic on the byte the author pasted earliest in the URL.
7956 let d = dep_with_fonte(DepSource::Git {
7957 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7958 tag: Some("v0.1.0".into()),
7959 rev: None,
7960 branch: None,
7961 });
7962 let err = d.validate().unwrap_err();
7963 let DepError::FonteRepoShape { reason, .. } = err else {
7964 panic!("expected FonteRepoShape, got other variant");
7965 };
7966 assert!(
7967 reason.contains("must not contain `#`"),
7968 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7969 appears first in value), got {reason:?}"
7970 );
7971 }
7972
7973 #[test]
7974 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7975 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7976 // byte-class arm, e7a109f) and the bang arm are both per-byte
7977 // arms inside the same `for &b in s.as_bytes()` loop, so the
7978 // byte that appears first in the value's byte order wins. A
7979 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7980 // `'` byte appears first, so the single-quote arm fires,
7981 // surfacing the more self-locating diagnostic on the byte the
7982 // author pasted earliest in the URL. Pins the natural-order
7983 // cascade so a future reorder of the per-byte arms surfaces
7984 // here — `!` is the most recent byte-class arm, so the
7985 // cascade-pin sweep extends to cover the immediately prior `'`
7986 // byte arm firing first when ordered ahead of `!` in the value.
7987 let d = dep_with_fonte(DepSource::Git {
7988 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7989 tag: Some("v0.1.0".into()),
7990 rev: None,
7991 branch: None,
7992 });
7993 let err = d.validate().unwrap_err();
7994 let DepError::FonteRepoShape { reason, .. } = err else {
7995 panic!("expected FonteRepoShape, got other variant");
7996 };
7997 assert!(
7998 reason.contains("must not contain `'`"),
7999 "reason must surface the single-quote arm (fires before bang when `'` byte \
8000 appears first in value), got {reason:?}"
8001 );
8002 }
8003
8004 #[test]
8005 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8006 // The fail-before-pass-after pin for the canonical
8007 // list-separator-belongs-to-list-grammar footgun on `:repo`.
8008 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8009 // one-liner from a multi-repo bootstrap doc, intending the
8010 // comma to separate multiple repo entries but the typed
8011 // `:repo` slot names *one* repo (the list-separator belongs
8012 // to the `:deps` list grammar, not to the value). Until this
8013 // arm landed the `,` byte silently passed every prior
8014 // `is_git_repo_url` arm (no whitespace, no control chars, no
8015 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8016 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8017 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8018 // `:`); the byte rode into the lacre's per-dep content-
8019 // address and the resolver's `git clone <repo>` subprocess
8020 // invocation, where no host's repo registry resolved the
8021 // comma-bearing slug.
8022 let d = dep_with_fonte(DepSource::Git {
8023 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8024 tag: Some("v0.1.0".into()),
8025 rev: None,
8026 branch: None,
8027 });
8028 let err = d.validate().unwrap_err();
8029 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8030 panic!("expected FonteRepoShape, got other variant");
8031 };
8032 assert_eq!(nome, "caixa-teia");
8033 assert_eq!(
8034 repo,
8035 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8036 );
8037 assert!(
8038 reason.contains("must not contain `,`"),
8039 "reason must surface the list-separator-comma arm, got {reason:?}"
8040 );
8041 assert!(
8042 reason.contains("list-separator") || reason.contains("sub-delims"),
8043 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8044 got {reason:?}"
8045 );
8046 }
8047
8048 #[test]
8049 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8050 // The symmetric trailing-`,` paste-from-prose pin: an author
8051 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8052 // comma every README-prose list-of-projects sentence carries,
8053 // mistakenly retained when the slug is pasted mid-sentence)
8054 // expecting the substrate to coerce it to a kebab-case slug.
8055 // Pinned separately from the wrapped mid-token shape so a
8056 // future diagnostic-surface change that only checked the
8057 // leading or paired-comma position surfaces here — the
8058 // per-byte arm fires anywhere `,` appears in the value.
8059 let d = dep_with_fonte(DepSource::Git {
8060 repo: "github:pleme-io/caixa-feira,".into(),
8061 tag: Some("v0.1.0".into()),
8062 rev: None,
8063 branch: None,
8064 });
8065 let err = d.validate().unwrap_err();
8066 let DepError::FonteRepoShape { reason, .. } = err else {
8067 panic!("expected FonteRepoShape, got other variant");
8068 };
8069 assert!(
8070 reason.contains("must not contain `,`"),
8071 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8072 got {reason:?}"
8073 );
8074 }
8075
8076 #[test]
8077 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8078 // Cascade pin: the fragment-`#` arm and the comma arm are
8079 // both per-byte arms inside the same `for &b in s.as_bytes()`
8080 // loop, so the byte that appears first in the value's byte
8081 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8082 // carries both `#` and `,`; the `#` byte appears first, so
8083 // the fragment-`#` arm fires, surfacing the more self-
8084 // locating diagnostic on the byte the author pasted earliest
8085 // in the URL.
8086 let d = dep_with_fonte(DepSource::Git {
8087 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8088 tag: Some("v0.1.0".into()),
8089 rev: None,
8090 branch: None,
8091 });
8092 let err = d.validate().unwrap_err();
8093 let DepError::FonteRepoShape { reason, .. } = err else {
8094 panic!("expected FonteRepoShape, got other variant");
8095 };
8096 assert!(
8097 reason.contains("must not contain `#`"),
8098 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8099 appears first in value), got {reason:?}"
8100 );
8101 }
8102
8103 #[test]
8104 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8105 // Cascade pin: the bang-`!` arm (the immediate-predecessor
8106 // byte-class arm, 7d53c68) and the comma arm are both
8107 // per-byte arms inside the same `for &b in s.as_bytes()`
8108 // loop, so the byte that appears first in the value's byte
8109 // order wins. A `:repo "github:p/x!mid,tail"` carries both
8110 // `!` and `,`; the `!` byte appears first, so the bang arm
8111 // fires, surfacing the more self-locating diagnostic on the
8112 // byte the author pasted earliest in the URL. Pins the
8113 // natural-order cascade so a future reorder of the per-byte
8114 // arms surfaces here — `,` is the most recent byte-class
8115 // arm, so the cascade-pin sweep extends to cover the
8116 // immediately prior `!` byte arm firing first when ordered
8117 // ahead of `,` in the value.
8118 let d = dep_with_fonte(DepSource::Git {
8119 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8120 tag: Some("v0.1.0".into()),
8121 rev: None,
8122 branch: None,
8123 });
8124 let err = d.validate().unwrap_err();
8125 let DepError::FonteRepoShape { reason, .. } = err else {
8126 panic!("expected FonteRepoShape, got other variant");
8127 };
8128 assert!(
8129 reason.contains("must not contain `!`"),
8130 "reason must surface the bang arm (fires before comma when `!` byte \
8131 appears first in value), got {reason:?}"
8132 );
8133 }
8134
8135 #[test]
8136 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8137 // The fail-before-pass-after pin for the canonical
8138 // shell-env-var-assignment-belongs-to-shell-grammar footgun
8139 // on `:repo`. An author copies
8140 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8141 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8142 // git clone <url>`, etc. — the canonical
8143 // git-troubleshooting README idiom for a one-shot env-var
8144 // scoped to the `git clone` invocation) from a shell-prompt
8145 // one-liner, intending the `KEY=VALUE` prefix as a shell-
8146 // grammar env-var assignment but the typed `:repo` slot is
8147 // a value parser, not a shell context, so the bytes ride
8148 // into the value verbatim. Until this arm landed the `=`
8149 // byte silently passed every prior `is_git_repo_url` arm
8150 // (no whitespace, no control chars, no non-ASCII, no `#`,
8151 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8152 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8153 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8154 // the byte rode into the lacre's per-dep content-address
8155 // and the resolver's `git clone <repo>` subprocess
8156 // invocation, where the upstream host's git porcelain
8157 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8158 // path that no host's repo registry resolves.
8159 let d = dep_with_fonte(DepSource::Git {
8160 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8161 tag: Some("v0.1.0".into()),
8162 rev: None,
8163 branch: None,
8164 });
8165 let err = d.validate().unwrap_err();
8166 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8167 panic!("expected FonteRepoShape, got other variant");
8168 };
8169 assert_eq!(nome, "caixa-teia");
8170 assert_eq!(
8171 repo,
8172 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8173 );
8174 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8175 // appears before the ` ` byte at position 21, so the `=`
8176 // arm fires (not the whitespace arm) — both arms guard
8177 // the slot, but the per-byte for-loop scans left-to-right
8178 // and the first matching byte wins.
8179 assert!(
8180 reason.contains("must not contain `=`"),
8181 "reason must surface the equals-`=` arm on the env-var-assignment \
8182 paste shape, got {reason:?}"
8183 );
8184 assert!(
8185 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8186 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8187 );
8188 }
8189
8190 #[test]
8191 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8192 // The symmetric paste-from-gitconfig pin: an author copies
8193 // `url=https://github.com/p/x` from `git config --get-all
8194 // remote.origin.url` output, a `.gitconfig` `[remote
8195 // "origin"] url = https://…` ini-stanza paste, or a
8196 // `git config remote.origin.url <value>` doc snippet,
8197 // intending the `url=` prefix as the ini-key but the typed
8198 // `:repo` slot is a URL value parser, not a gitconfig
8199 // grammar. With no leading whitespace and no earlier-arm
8200 // bytes in the value, the `=` arm itself fires (rather
8201 // than cascading to the whitespace arm as in the env-var
8202 // paste shape). Pinned separately so a future diagnostic-
8203 // surface change that only checked the whitespace-leading
8204 // shape surfaces here — the per-byte arm fires anywhere
8205 // `=` appears in the value.
8206 let d = dep_with_fonte(DepSource::Git {
8207 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8208 tag: Some("v0.1.0".into()),
8209 rev: None,
8210 branch: None,
8211 });
8212 let err = d.validate().unwrap_err();
8213 let DepError::FonteRepoShape { reason, .. } = err else {
8214 panic!("expected FonteRepoShape, got other variant");
8215 };
8216 assert!(
8217 reason.contains("must not contain `=`"),
8218 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8219 paste shape, got {reason:?}"
8220 );
8221 assert!(
8222 reason.contains("key-value-separator") || reason.contains("sub-delims"),
8223 "reason must name the key-value-separator / RFC-3986-sub-delims \
8224 rationale, got {reason:?}"
8225 );
8226 }
8227
8228 #[test]
8229 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8230 // Cascade pin: the fragment-`#` arm and the `=` arm are
8231 // both per-byte arms inside the same `for &b in s.as_bytes()`
8232 // loop, so the byte that appears first in the value's byte
8233 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8234 // carries both `#` and `=`; the `#` byte appears first, so
8235 // the fragment-`#` arm fires, surfacing the more self-
8236 // locating diagnostic on the byte the author pasted earliest
8237 // in the URL.
8238 let d = dep_with_fonte(DepSource::Git {
8239 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8240 tag: Some("v0.1.0".into()),
8241 rev: None,
8242 branch: None,
8243 });
8244 let err = d.validate().unwrap_err();
8245 let DepError::FonteRepoShape { reason, .. } = err else {
8246 panic!("expected FonteRepoShape, got other variant");
8247 };
8248 assert!(
8249 reason.contains("must not contain `#`"),
8250 "reason must surface the fragment-`#` arm (fires before equals when \
8251 `#` byte appears first in value), got {reason:?}"
8252 );
8253 }
8254
8255 #[test]
8256 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8257 // Cascade pin: the comma-`,` arm (the immediate-predecessor
8258 // byte-class arm, 775b80e) and the `=` arm are both per-byte
8259 // arms inside the same `for &b in s.as_bytes()` loop, so
8260 // the byte that appears first in the value's byte order
8261 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8262 // and `=`; the `,` byte appears first, so the comma arm
8263 // fires, surfacing the more self-locating diagnostic on
8264 // the byte the author pasted earliest in the URL. Pins the
8265 // natural-order cascade so a future reorder of the per-byte
8266 // arms surfaces here — `=` is the most recent byte-class
8267 // arm, so the cascade-pin sweep extends to cover the
8268 // immediately prior `,` byte arm firing first when ordered
8269 // ahead of `=` in the value.
8270 let d = dep_with_fonte(DepSource::Git {
8271 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8272 tag: Some("v0.1.0".into()),
8273 rev: None,
8274 branch: None,
8275 });
8276 let err = d.validate().unwrap_err();
8277 let DepError::FonteRepoShape { reason, .. } = err else {
8278 panic!("expected FonteRepoShape, got other variant");
8279 };
8280 assert!(
8281 reason.contains("must not contain `,`"),
8282 "reason must surface the comma arm (fires before equals when `,` byte \
8283 appears first in value), got {reason:?}"
8284 );
8285 }
8286
8287 #[test]
8288 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8289 // The fail-before-pass-after pin for the canonical paste-from-
8290 // browser-address-bar percent-encoded-space footgun on `:repo`.
8291 // An author copies `https://github.com/p/x%20test` from a
8292 // browser address bar (or a percent-encoded README hyperlink,
8293 // or a `curl --data-urlencode` shell-pipeline output)
8294 // intending `%20` as the URL encoding of a literal space; the
8295 // typed `:repo` slot already rejects the literal space byte
8296 // (the whitespace arm at the top of `is_git_repo_url`), so an
8297 // author trying to express "I really meant a space" reaches
8298 // for percent-encoding. Until this arm landed the `%` byte
8299 // silently passed every prior `is_git_repo_url` arm and rode
8300 // verbatim into the lacre's per-dep content-address — but
8301 // libcurl re-percent-encodes `%` to `%25` on the wire (since
8302 // `%` is reserved as the escape-sequence lead-in), so the
8303 // wire request becomes `https://github.com/p/x%2520test`, a
8304 // path the lacre's content-address never names. The classic
8305 // render-determinism violation on the encoding-mechanism axis
8306 // itself.
8307 let d = dep_with_fonte(DepSource::Git {
8308 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8309 tag: Some("v0.1.0".into()),
8310 rev: None,
8311 branch: None,
8312 });
8313 let err = d.validate().unwrap_err();
8314 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8315 panic!("expected FonteRepoShape, got other variant");
8316 };
8317 assert_eq!(nome, "caixa-teia");
8318 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8319 assert!(
8320 reason.contains("must not contain `%`"),
8321 "reason must surface the percent-`%` arm on the percent-encoded-space \
8322 paste shape, got {reason:?}"
8323 );
8324 assert!(
8325 reason.contains("percent-encoding") || reason.contains("%25"),
8326 "reason must name the percent-encoding / `%25` re-encoding rationale, \
8327 got {reason:?}"
8328 );
8329 }
8330
8331 #[test]
8332 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8333 // The symmetric over-encoded-path-separator pin: an author
8334 // writes `:repo "https://github.com/p%2Fx"` intending the
8335 // `%2F` as the URL encoding of `/` (the canonical
8336 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8337 // footgun every API client library and OAuth redirect-URI
8338 // documentation surfaces — the `/` is the URL-path-separator
8339 // and some templates percent-encode it to escape interpretation
8340 // as a path separator). The GitHub Smart-HTTP transport
8341 // resolves the URL's path-segment grammar before the
8342 // percent-decoding pass, so the value identifies a different
8343 // resource on the wire than the literal-`/` form the lacre's
8344 // content-address must agree with — two authors whose `:repo`
8345 // values differ only in their `/` vs `%2F` presence lock to
8346 // two distinct BLAKE3 closures for the byte-identical upstream
8347 // `git clone`. Pinned separately so a future diagnostic
8348 // surface that only catches the `%20` shape surfaces here too.
8349 let d = dep_with_fonte(DepSource::Git {
8350 repo: "https://github.com/pleme-io%2Fcaixa-teia".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 percent-`%` arm on the over-encoded-path \
8362 shape, got {reason:?}"
8363 );
8364 assert!(
8365 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8366 "reason must name the render-determinism / BLAKE3-closure rationale, \
8367 got {reason:?}"
8368 );
8369 }
8370
8371 #[test]
8372 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8373 // Cascade pin: the fragment-`#` arm and the `%` arm are both
8374 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8375 // so the byte that appears first in the value's byte order
8376 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8377 // both `#` and `%`; the `#` byte appears first, so the
8378 // fragment-`#` arm fires, surfacing the more self-locating
8379 // diagnostic on the byte the author pasted earliest in the URL.
8380 let d = dep_with_fonte(DepSource::Git {
8381 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8382 tag: Some("v0.1.0".into()),
8383 rev: None,
8384 branch: None,
8385 });
8386 let err = d.validate().unwrap_err();
8387 let DepError::FonteRepoShape { reason, .. } = err else {
8388 panic!("expected FonteRepoShape, got other variant");
8389 };
8390 assert!(
8391 reason.contains("must not contain `#`"),
8392 "reason must surface the fragment-`#` arm (fires before percent when \
8393 `#` byte appears first in value), got {reason:?}"
8394 );
8395 }
8396
8397 #[test]
8398 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8399 // Cascade pin: the equals-`=` arm (the immediate-predecessor
8400 // byte-class arm, acf99af) and the `%` arm are both per-byte
8401 // arms inside the same `for &b in s.as_bytes()` loop, so the
8402 // byte that appears first in the value's byte order wins.
8403 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8404 // the `=` byte appears first, so the equals arm fires,
8405 // surfacing the more self-locating diagnostic on the byte the
8406 // author pasted earliest in the URL. Pins the natural-order
8407 // cascade so a future reorder of the per-byte arms surfaces
8408 // here — `%` is the most recent byte-class arm, so the
8409 // cascade-pin sweep extends to cover the immediately prior
8410 // `=` byte arm firing first when ordered ahead of `%` in the
8411 // value.
8412 let d = dep_with_fonte(DepSource::Git {
8413 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8414 tag: Some("v0.1.0".into()),
8415 rev: None,
8416 branch: None,
8417 });
8418 let err = d.validate().unwrap_err();
8419 let DepError::FonteRepoShape { reason, .. } = err else {
8420 panic!("expected FonteRepoShape, got other variant");
8421 };
8422 assert!(
8423 reason.contains("must not contain `=`"),
8424 "reason must surface the equals arm (fires before percent when `=` byte \
8425 appears first in value), got {reason:?}"
8426 );
8427 }
8428
8429 #[test]
8430 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8431 // The fail-before-pass-after pin for the canonical paste-from-
8432 // shell-history footgun on `:repo`. An author copies a
8433 // `git clone <url>` line from their terminal followed by a
8434 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8435 // history shorthand (the `^old^new^` form re-runs the prior
8436 // history entry with the first `old` substituted by `new`,
8437 // bash's default behavior on interactive sessions with
8438 // `set -o histexpand`), forgetting to trim the trailing
8439 // `^...^...` shell-history fragment from the URL value. The
8440 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8441 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8442 // classes), the WHATWG URL spec's 'fragment percent-encode
8443 // set' maps `^` → `%5E` on the wire, so the byte rides
8444 // verbatim into the lacre's per-dep content-address but
8445 // libcurl re-encodes it to `%5E` at `git clone` time — the
8446 // classic render-determinism violation on the same axis the
8447 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8448 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8449 // `#` arms close.
8450 let d = dep_with_fonte(DepSource::Git {
8451 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8452 tag: Some("v0.1.0".into()),
8453 rev: None,
8454 branch: None,
8455 });
8456 let err = d.validate().unwrap_err();
8457 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8458 panic!("expected FonteRepoShape, got other variant");
8459 };
8460 assert_eq!(nome, "caixa-teia");
8461 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8462 assert!(
8463 reason.contains("must not contain `^`"),
8464 "reason must surface the caret-`^` arm on the paste-from-shell-history \
8465 shape, got {reason:?}"
8466 );
8467 assert!(
8468 reason.contains("history-substitution") || reason.contains("%5E"),
8469 "reason must name the shell-history-substitution / `%5E` wire-encoding \
8470 rationale, got {reason:?}"
8471 );
8472 }
8473
8474 #[test]
8475 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8476 // The symmetric paste-from-doc-grep-pipeline footgun: an
8477 // author writes `:repo "github:p/^archived"` after copying a
8478 // `grep '^archived'` regex-anchor / negation idiom from a
8479 // doc / README quick-listing snippet, expecting the substrate
8480 // to coerce it to a literal repo name. The byte rides
8481 // verbatim into the lacre's per-dep content-address and
8482 // diverges from the byte-identical literal `archived` form
8483 // every other author authored — the canonical render-
8484 // determinism violation pin on the second footgun shape the
8485 // caret-`^` arm closes.
8486 let d = dep_with_fonte(DepSource::Git {
8487 repo: "github:pleme-io/^archived".into(),
8488 tag: Some("v0.1.0".into()),
8489 rev: None,
8490 branch: None,
8491 });
8492 let err = d.validate().unwrap_err();
8493 let DepError::FonteRepoShape { reason, .. } = err else {
8494 panic!("expected FonteRepoShape, got other variant");
8495 };
8496 assert!(
8497 reason.contains("must not contain `^`"),
8498 "reason must surface the caret-`^` arm on the regex-anchor shape, \
8499 got {reason:?}"
8500 );
8501 assert!(
8502 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8503 "reason must name the render-determinism / BLAKE3-closure rationale, \
8504 got {reason:?}"
8505 );
8506 }
8507
8508 #[test]
8509 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8510 // Cascade pin: the `%` arm (the immediate-predecessor byte-
8511 // class arm, a323db8) and the `^` arm are both per-byte arms
8512 // inside the same `for &b in s.as_bytes()` loop, so the byte
8513 // that appears first in the value's byte order wins. A
8514 // `:repo "https://github.com/p/x%20mid^tail"` carries both
8515 // `%` and `^`; the `%` byte appears first, so the percent
8516 // arm fires, surfacing the more self-locating diagnostic on
8517 // the byte the author pasted earliest in the URL. Pins the
8518 // natural-order cascade so a future reorder of the per-byte
8519 // arms surfaces here — `^` is the most recent byte-class arm,
8520 // so the cascade-pin sweep extends to cover the immediately
8521 // prior `%` byte arm firing first when ordered ahead of `^`
8522 // in the value.
8523 let d = dep_with_fonte(DepSource::Git {
8524 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8525 tag: Some("v0.1.0".into()),
8526 rev: None,
8527 branch: None,
8528 });
8529 let err = d.validate().unwrap_err();
8530 let DepError::FonteRepoShape { reason, .. } = err else {
8531 panic!("expected FonteRepoShape, got other variant");
8532 };
8533 assert!(
8534 reason.contains("must not contain `%`"),
8535 "reason must surface the percent arm (fires before caret when `%` byte \
8536 appears first in value), got {reason:?}"
8537 );
8538 }
8539
8540 #[test]
8541 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8542 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8543 // (no `github:` prefix, no scheme). Every documented form
8544 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8545 // `file://`, or `git@host:path`); a bare `org/repo` is
8546 // ambiguous (`git clone` reads as a relative filesystem path
8547 // rather than the GitHub-shorthand expansion the author
8548 // probably intended) and the gate rejects the shape upstream.
8549 let d = dep_with_fonte(DepSource::Git {
8550 repo: "pleme-io/caixa-teia".into(),
8551 tag: Some("v0.1.0".into()),
8552 rev: None,
8553 branch: None,
8554 });
8555 let err = d.validate().unwrap_err();
8556 let DepError::FonteRepoShape { reason, .. } = err else {
8557 panic!("expected FonteRepoShape, got other variant");
8558 };
8559 assert!(
8560 reason.contains("must contain a `:`"),
8561 "reason must surface the missing-`:` arm, got {reason:?}"
8562 );
8563 assert!(
8564 reason.contains("github:"),
8565 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8566 );
8567 }
8568
8569 #[test]
8570 fn validate_rejects_git_fonte_with_repo_leading_colon() {
8571 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8572 // scheme that no git porcelain entry-point accepts. Pinned
8573 // separately from the missing-`:` arm because a value with a
8574 // leading `:` does technically contain a `:` separator; the
8575 // shape gate rejects on a dedicated arm so the diagnostic
8576 // names the specific footgun.
8577 let d = dep_with_fonte(DepSource::Git {
8578 repo: ":pleme-io/caixa-teia".into(),
8579 tag: Some("v0.1.0".into()),
8580 rev: None,
8581 branch: None,
8582 });
8583 let err = d.validate().unwrap_err();
8584 let DepError::FonteRepoShape { reason, .. } = err else {
8585 panic!("expected FonteRepoShape, got other variant");
8586 };
8587 assert!(
8588 reason.contains("must not start with `:`"),
8589 "reason must surface the leading-`:` arm, got {reason:?}"
8590 );
8591 }
8592
8593 #[test]
8594 fn validate_rejects_git_fonte_with_repo_too_long() {
8595 // The cap arm — a `:repo` value longer than
8596 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8597 // structurally untenable on every realistic landing site (the
8598 // resolver's `git clone` invocation, the future M4 CR
8599 // materializer's per-dep `repo:` axis); a value of that length
8600 // is almost certainly a paste-from-binary slug.
8601 let too_long = format!(
8602 "github:pleme-io/{}",
8603 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8604 );
8605 let d = dep_with_fonte(DepSource::Git {
8606 repo: too_long.clone(),
8607 tag: Some("v0.1.0".into()),
8608 rev: None,
8609 branch: None,
8610 });
8611 let err = d.validate().unwrap_err();
8612 let DepError::FonteRepoShape { reason, .. } = err else {
8613 panic!("expected FonteRepoShape, got other variant");
8614 };
8615 assert!(
8616 reason.contains("2048"),
8617 "reason must name the cap, got {reason:?}"
8618 );
8619 }
8620
8621 #[test]
8622 fn validate_accepts_canonical_git_fonte_repo_shapes() {
8623 // The positive-control sweep: every documented author shape on
8624 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8625 // must pass the value-shape gate. Pinned so a future tightening
8626 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8627 // here as a structural decision. Each form is exercised with the
8628 // same canonical `:tag` pin so only the `:repo` axis varies.
8629 for repo in [
8630 // The pleme-io registry-shorthand convention — `github:org/repo`.
8631 "github:pleme-io/caixa-teia",
8632 // Other host-aliased shorthands (the resolver's pluggable
8633 // host-prefix table).
8634 "gitlab:pleme-io/caixa-teia",
8635 "codeberg:pleme-io/caixa-teia",
8636 "sourcehut:~pleme-io/caixa-teia",
8637 // Full HTTPS URL with and without `.git` suffix.
8638 "https://github.com/pleme-io/caixa-teia",
8639 "https://github.com/pleme-io/caixa-teia.git",
8640 // HTTP (rare; dev / mirror).
8641 "http://example.com/pleme-io/caixa-teia.git",
8642 // SSH URL.
8643 "ssh://git@github.com/pleme-io/caixa-teia.git",
8644 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8645 // Scp-style SSH — the canonical `git@host:path` short form.
8646 "git@github.com:pleme-io/caixa-teia.git",
8647 "git@git.example.com:team/private.git",
8648 // Anonymous git protocol.
8649 "git://git.example.com/pleme-io/caixa-teia.git",
8650 // Local file URL (dev path).
8651 "file:///tmp/caixa-teia",
8652 ] {
8653 let d = dep_with_fonte(DepSource::Git {
8654 repo: repo.into(),
8655 tag: Some("v0.1.0".into()),
8656 rev: None,
8657 branch: None,
8658 });
8659 d.validate()
8660 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8661 }
8662 }
8663
8664 #[test]
8665 fn fonte_repo_empty_takes_precedence_over_shape() {
8666 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8667 // diagnostic; doesn't try to parse the URL shape) fires before
8668 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8669 // keeps its narrower error message. Mirrors
8670 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8671 // on the ordering layer.
8672 let d = dep_with_fonte(DepSource::Git {
8673 repo: String::new(),
8674 tag: Some("v0.1.0".into()),
8675 rev: None,
8676 branch: None,
8677 });
8678 let err = d.validate().unwrap_err();
8679 assert!(
8680 matches!(err, DepError::FonteRepoEmpty { .. }),
8681 "got {err:?}"
8682 );
8683 }
8684
8685 #[test]
8686 fn fonte_repo_shape_fires_before_pin_missing() {
8687 // Order pin: a malformed `:repo` value on a dep with no pin set
8688 // surfaces the `:repo` shape diagnostic (the more self-locating
8689 // axis — the `:repo` is the load-bearing identity of the source;
8690 // a missing pin is downstream from "do we even know the repo")
8691 // rather than collapsing onto the pin-missing diagnostic. The
8692 // shape gate runs inline before the pin enumeration in
8693 // `DepSource::validate`.
8694 let d = dep_with_fonte(DepSource::Git {
8695 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8696 tag: None,
8697 rev: None,
8698 branch: None,
8699 });
8700 let err = d.validate().unwrap_err();
8701 assert!(
8702 matches!(err, DepError::FonteRepoShape { .. }),
8703 "got {err:?}"
8704 );
8705 }
8706
8707 #[test]
8708 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8709 // The diagnostic-shape pin: the error names the offending
8710 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8711 // so the author can grep their caixa.lisp without re-running
8712 // the build. Mirrors the diagnostic-shape sweep on every prior
8713 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8714 let d = dep_with_fonte(DepSource::Git {
8715 repo: "pleme-io/caixa-teia".into(),
8716 tag: Some("v0.1.0".into()),
8717 rev: None,
8718 branch: None,
8719 });
8720 let err = d.validate().unwrap_err();
8721 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8722 panic!("expected FonteRepoShape, got other variant");
8723 };
8724 assert_eq!(nome, "caixa-teia");
8725 assert_eq!(repo, "pleme-io/caixa-teia");
8726 assert!(
8727 !reason.is_empty(),
8728 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8729 );
8730 }
8731
8732 #[test]
8733 fn validate_rejects_git_fonte_with_no_pin() {
8734 // The fail-before-pass-after pin for the canonical
8735 // `(:tipo git :repo "github:pleme-io/x")` shape with no
8736 // :tag/:rev/:branch — until this gate landed the resolver's
8737 // ResolveError::MissingPin surfaced at fetch time, far from the
8738 // source caixa.lisp. The new gate moves the check to validate
8739 // time and names the offending dep.
8740 let d = dep_with_fonte(DepSource::Git {
8741 repo: "github:pleme-io/caixa-teia".into(),
8742 tag: None,
8743 rev: None,
8744 branch: None,
8745 });
8746 let err = d.validate().unwrap_err();
8747 assert!(
8748 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8749 "got {err:?}"
8750 );
8751 }
8752
8753 #[test]
8754 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8755 // The canonical "pin drift" footgun: an author writes
8756 // `:tag "v1"` and later adds `:branch "main"` without removing
8757 // the :tag, and the resolver silently picks :tag (precedence
8758 // :rev > :tag > :branch). The :branch was dropped with no
8759 // diagnostic. The gate now rejects multi-pin shapes so the
8760 // author makes the precedence explicit at the source.
8761 let d = dep_with_fonte(DepSource::Git {
8762 repo: "github:pleme-io/caixa-teia".into(),
8763 tag: Some("v0.1.0".into()),
8764 rev: None,
8765 branch: Some("main".into()),
8766 });
8767 let err = d.validate().unwrap_err();
8768 let DepError::FontePinAmbiguous { nome, pins } = err else {
8769 panic!("expected FontePinAmbiguous");
8770 };
8771 assert_eq!(nome, "caixa-teia");
8772 assert!(pins.contains(":tag"));
8773 assert!(pins.contains(":branch"));
8774 assert!(!pins.contains(":rev"));
8775 }
8776
8777 #[test]
8778 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8779 // Sibling arm of the pin-drift footgun: :tag + :rev set
8780 // simultaneously. Pinned separately so a future relaxation
8781 // that only catches the (:tag, :branch) pair surfaces here.
8782 let d = dep_with_fonte(DepSource::Git {
8783 repo: "github:pleme-io/caixa-teia".into(),
8784 tag: Some("v0.1.0".into()),
8785 rev: Some("c0ffee".into()),
8786 branch: None,
8787 });
8788 let err = d.validate().unwrap_err();
8789 let DepError::FontePinAmbiguous { nome, pins } = err else {
8790 panic!("expected FontePinAmbiguous");
8791 };
8792 assert_eq!(nome, "caixa-teia");
8793 assert!(pins.contains(":tag"));
8794 assert!(pins.contains(":rev"));
8795 }
8796
8797 #[test]
8798 fn validate_rejects_git_fonte_with_all_three_pins() {
8799 // The maximal ambiguity case — every pin axis set. Pinned so a
8800 // future relaxation that only catches pairs surfaces here. The
8801 // diagnostic must enumerate every offending axis so the author
8802 // sees the full set, not just the first match.
8803 let d = dep_with_fonte(DepSource::Git {
8804 repo: "github:pleme-io/caixa-teia".into(),
8805 tag: Some("v0.1.0".into()),
8806 rev: Some("c0ffee".into()),
8807 branch: Some("main".into()),
8808 });
8809 let err = d.validate().unwrap_err();
8810 let DepError::FontePinAmbiguous { nome, pins } = err else {
8811 panic!("expected FontePinAmbiguous");
8812 };
8813 assert_eq!(nome, "caixa-teia");
8814 assert!(pins.contains(":tag"));
8815 assert!(pins.contains(":rev"));
8816 assert!(pins.contains(":branch"));
8817 }
8818
8819 #[test]
8820 fn validate_rejects_git_fonte_with_empty_tag_pin() {
8821 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8822 // inner string is empty. Distinct from FontePinMissing (where
8823 // every axis is None) — pinned separately so a future
8824 // tightening collapsing them surfaces here as a structural
8825 // decision.
8826 let d = dep_with_fonte(DepSource::Git {
8827 repo: "github:pleme-io/caixa-teia".into(),
8828 tag: Some(String::new()),
8829 rev: None,
8830 branch: None,
8831 });
8832 let err = d.validate().unwrap_err();
8833 let DepError::FontePinEmpty { nome, pin } = err else {
8834 panic!("expected FontePinEmpty");
8835 };
8836 assert_eq!(nome, "caixa-teia");
8837 assert_eq!(pin, ":tag");
8838 }
8839
8840 #[test]
8841 fn validate_rejects_git_fonte_with_empty_rev_pin() {
8842 // Sibling arm — the empty-pin diagnostic names which axis
8843 // carries the empty value, so the author's grep target is
8844 // unambiguous.
8845 let d = dep_with_fonte(DepSource::Git {
8846 repo: "github:pleme-io/caixa-teia".into(),
8847 tag: None,
8848 rev: Some(String::new()),
8849 branch: None,
8850 });
8851 let err = d.validate().unwrap_err();
8852 let DepError::FontePinEmpty { nome, pin } = err else {
8853 panic!("expected FontePinEmpty");
8854 };
8855 assert_eq!(nome, "caixa-teia");
8856 assert_eq!(pin, ":rev");
8857 }
8858
8859 #[test]
8860 fn validate_rejects_path_fonte_with_empty_caminho() {
8861 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8862 // until this gate landed the resolver's
8863 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8864 // fetch time — not actionable. The new gate moves the check to
8865 // validate time and names the offending dep.
8866 let d = dep_with_fonte(DepSource::Path {
8867 caminho: String::new(),
8868 });
8869 let err = d.validate().unwrap_err();
8870 assert!(
8871 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8872 "got {err:?}"
8873 );
8874 }
8875
8876 #[test]
8877 fn validate_rejects_path_fonte_with_absolute_caminho() {
8878 // The fail-before-pass-after pin for the absolute-`:caminho`
8879 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8880 // Until this gate landed an absolute `:caminho` silently
8881 // passed validate; the lacre pipeline embedded the
8882 // host-specific filesystem path verbatim in its
8883 // content-address (`conteudo: format!("path:{caminho}")`,
8884 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8885 // differed per machine — the build succeeded but two CI
8886 // runners with different `${HOME}` layouts emitted two
8887 // distinct lacres for the byte-identical caixa, silently
8888 // breaking the THEORY.md §V.2 render-determinism contract
8889 // far from the source caixa.lisp. The new gate moves the
8890 // check to validate time and names the offending dep +
8891 // caminho verbatim.
8892 let d = dep_with_fonte(DepSource::Path {
8893 caminho: "/home/me/work/caixa-teia".into(),
8894 });
8895 let err = d.validate().unwrap_err();
8896 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8897 panic!("expected FonteCaminhoAbsolute, got other variant");
8898 };
8899 assert_eq!(nome, "caixa-teia");
8900 assert_eq!(caminho, "/home/me/work/caixa-teia");
8901 }
8902
8903 #[test]
8904 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8905 // The canonical sibling-workspace dep form
8906 // (`:caminho "../caixa-teia"`) remains accepted. The
8907 // absolute-path gate above is specifically narrower than the
8908 // shared [`crate::render::is_sandboxed_relative_path`]
8909 // predicate (which additionally forbids `..` traversal): a
8910 // local-path dep's canonical author surface is the in-tree
8911 // sibling-workspace path, so a full sandboxed-relative-path
8912 // lift would structurally reject every legitimate path-fonte
8913 // dep. Pinned so a future tightening to the full predicate
8914 // surfaces here as a structural decision, not a silent break.
8915 let d = dep_with_fonte(DepSource::Path {
8916 caminho: "../caixa-teia".into(),
8917 });
8918 d.validate().unwrap();
8919 }
8920
8921 #[test]
8922 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8923 // A multi-segment relative `:caminho`
8924 // (`"vendor/forks/caixa-teia"`) remains accepted — the
8925 // absolute-path gate brackets the host-layout-leaking shape
8926 // at the leading-`/` boundary only; every relative shape past
8927 // the empty arm continues to pass. Pinned alongside the
8928 // `..`-traversal positive control so a future tightening
8929 // surfaces the full set of legitimate relative forms here
8930 // rather than at a downstream consumer.
8931 let d = dep_with_fonte(DepSource::Path {
8932 caminho: "vendor/forks/caixa-teia".into(),
8933 });
8934 d.validate().unwrap();
8935 }
8936
8937 #[test]
8938 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8939 // The fail-before-pass-after pin for the tilde-expansion
8940 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8941 // Until this gate landed the b94fd83 absolute arm let `~/foo`
8942 // through (`Path::is_absolute` returns false on a leading `~`
8943 // — the tilde is a shell-expansion convention, not a POSIX
8944 // path component), so the lacre embedded the value verbatim
8945 // and the resolver folded it through `Path::join` without
8946 // expansion, looking for a literal `./~/work/caixa-teia`
8947 // subdirectory and failing at resolve time with a
8948 // `No such file or directory` error far from the source
8949 // caixa.lisp. The new gate moves the check to validate time
8950 // and names the offending dep + caminho verbatim.
8951 let d = dep_with_fonte(DepSource::Path {
8952 caminho: "~/work/caixa-teia".into(),
8953 });
8954 let err = d.validate().unwrap_err();
8955 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8956 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8957 };
8958 assert_eq!(nome, "caixa-teia");
8959 assert_eq!(caminho, "~/work/caixa-teia");
8960 }
8961
8962 #[test]
8963 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8964 // The bare `~` form (canonical "I meant `$HOME` and forgot
8965 // the rest"): both the leading-tilde arm catches it and the
8966 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8967 // sweeps through the same arm. Pinned both to ensure the
8968 // gate doesn't narrow to `~/` only.
8969 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8970 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8971 let err = d.validate().unwrap_err();
8972 assert!(
8973 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8974 "{s:?} → {err:?}",
8975 );
8976 }
8977 }
8978
8979 #[test]
8980 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8981 // The leading-`~` is the canonical shell-expansion footgun —
8982 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8983 // backup-file-suffix idiom) is a legitimate POSIX path byte
8984 // with no shell-expansion semantic at the leading position.
8985 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8986 // sweep that would break every legitimate-shape backup-file
8987 // path.
8988 let d = dep_with_fonte(DepSource::Path {
8989 caminho: "../foo~bar/caixa-teia".into(),
8990 });
8991 d.validate().unwrap();
8992 }
8993
8994 #[test]
8995 fn fonte_caminho_empty_fires_before_tilde_expansion() {
8996 // Cascade pin: the empty arm structurally precedes the
8997 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8998 // pin establishes the precedence at the diagnostic-shape
8999 // level should a future codec round-trip ever produce a
9000 // probe-as-both value. Mirrors the peer
9001 // `fonte_repo_empty_fires_before_pin_missing` cascade
9002 // discipline.
9003 let d = dep_with_fonte(DepSource::Path {
9004 caminho: String::new(),
9005 });
9006 let err = d.validate().unwrap_err();
9007 assert!(
9008 matches!(err, DepError::FonteCaminhoEmpty { .. }),
9009 "got {err:?}",
9010 );
9011 }
9012
9013 #[test]
9014 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9015 // Diagnostic-shape pin (peer with
9016 // `validate_rejects_path_fonte_with_absolute_caminho`'s
9017 // payload assertion): the error's Display surfaces both the
9018 // offending `:nome` and the offending `:caminho` verbatim
9019 // so a `feira lint` run can render the diagnostic without
9020 // re-parsing.
9021 let d = dep_with_fonte(DepSource::Path {
9022 caminho: "~alice/dev/caixa-teia".into(),
9023 });
9024 let rendered = d.validate().unwrap_err().to_string();
9025 assert!(
9026 rendered.contains("caixa-teia"),
9027 "diagnostic must name the offending dep: {rendered}",
9028 );
9029 assert!(
9030 rendered.contains("~alice/dev/caixa-teia"),
9031 "diagnostic must quote the offending caminho: {rendered}",
9032 );
9033 assert!(
9034 rendered.contains('~'),
9035 "diagnostic must reference the tilde footgun: {rendered}",
9036 );
9037 }
9038
9039 #[test]
9040 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9041 // The fail-before-pass-after pin for the shell-variable-
9042 // expansion `:caminho` shape: `(:tipo path :caminho
9043 // "$HOME/work/caixa-teia")`. Until this gate landed the
9044 // b94fd83 absolute arm + the a5c248e tilde arm both let
9045 // `$HOME/foo` through (`Path::is_absolute` returns false on
9046 // a leading `$` — the `$` is a shell convention, not a POSIX
9047 // path component; `starts_with('~')` returns false too), so
9048 // the lacre embedded the value verbatim and the resolver
9049 // folded it through `Path::join` without `$`-expansion,
9050 // looking for a literal `./$HOME/work/caixa-teia`
9051 // subdirectory and failing at resolve time with a
9052 // `No such file or directory` error far from the source
9053 // caixa.lisp. The new gate moves the check to validate time
9054 // and names the offending dep + caminho verbatim.
9055 let d = dep_with_fonte(DepSource::Path {
9056 caminho: "$HOME/work/caixa-teia".into(),
9057 });
9058 let err = d.validate().unwrap_err();
9059 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9060 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9061 };
9062 assert_eq!(nome, "caixa-teia");
9063 assert_eq!(caminho, "$HOME/work/caixa-teia");
9064 }
9065
9066 #[test]
9067 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9068 // Sweep over every leading-`$` shape: the `${VAR}`-braced
9069 // form (canonical "paste-from-CI-manifest" footgun every
9070 // GitHub Actions / GitLab CI / Drone manifest carries on
9071 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9072 // canonical "I'm referencing a per-user config dir"),
9073 // and the bare `$` (canonical "I meant `$HOME` and forgot
9074 // the rest"). All shapes route through the same gate's
9075 // byte check. Pinned so the gate doesn't narrow to a
9076 // single shape (e.g. `$HOME/` only).
9077 for s in [
9078 "${HOME}/work/caixa-teia",
9079 "${WORKSPACE}/caixa-teia",
9080 "$XDG_CONFIG_HOME/caixa",
9081 "$",
9082 ] {
9083 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9084 let err = d.validate().unwrap_err();
9085 assert!(
9086 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9087 "{s:?} → {err:?}",
9088 );
9089 }
9090 }
9091
9092 #[test]
9093 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9094 // The `$` byte is the canonical shell-variable-expansion /
9095 // command-substitution / arithmetic-expansion sentinel and
9096 // is rejected at *every* position on the `:caminho` axis: the
9097 // leading arm surfaces `FonteCaminhoVarExpansion`, the
9098 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9099 // (6620f39). Pinned so a future arm doesn't narrow the gate
9100 // back to the leading position and re-open the paste-from-
9101 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9102 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9103 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9104 // the lacre content-address (`path:{caminho}`,
9105 // caixa-resolver/src/resolve.rs:189).
9106 let d = dep_with_fonte(DepSource::Path {
9107 caminho: "../foo$bar/caixa-teia".into(),
9108 });
9109 let err = d.validate().unwrap_err();
9110 assert!(
9111 matches!(
9112 err,
9113 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9114 ),
9115 "got {err:?}",
9116 );
9117 }
9118
9119 #[test]
9120 fn fonte_caminho_tilde_fires_before_var_expansion() {
9121 // Cascade pin: the tilde arm structurally precedes the var
9122 // arm (the bytes `~` and `$` don't overlap at the leading
9123 // position), but the pin establishes the precedence at the
9124 // diagnostic-shape level should a future codec round-trip
9125 // ever produce a probe-as-both value. Mirrors the peer
9126 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9127 // discipline on the immediate-predecessor arm.
9128 let d = dep_with_fonte(DepSource::Path {
9129 caminho: "~/work/caixa-teia".into(),
9130 });
9131 let err = d.validate().unwrap_err();
9132 assert!(
9133 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9134 "got {err:?}",
9135 );
9136 }
9137
9138 #[test]
9139 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9140 // Diagnostic-shape pin (peer with
9141 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9142 // payload assertion on the immediate-predecessor arm): the
9143 // error's Display surfaces both the offending `:nome` and
9144 // the offending `:caminho` verbatim plus the `$` footgun
9145 // character itself so a `feira lint` run can render the
9146 // diagnostic without re-parsing.
9147 let d = dep_with_fonte(DepSource::Path {
9148 caminho: "${WORKSPACE}/caixa-teia".into(),
9149 });
9150 let rendered = d.validate().unwrap_err().to_string();
9151 assert!(
9152 rendered.contains("caixa-teia"),
9153 "diagnostic must name the offending dep: {rendered}",
9154 );
9155 assert!(
9156 rendered.contains("${WORKSPACE}/caixa-teia"),
9157 "diagnostic must quote the offending caminho: {rendered}",
9158 );
9159 assert!(
9160 rendered.contains('$'),
9161 "diagnostic must reference the dollar footgun: {rendered}",
9162 );
9163 }
9164
9165 #[test]
9166 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9167 // The fail-before-pass-after pin for the load-bearing NUL byte:
9168 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9169 // routes the path through `CString::new` which fails with
9170 // `NulError`); until this gate landed a `:caminho
9171 // "../caixa\0teia"` silently passed validate, the lacre
9172 // pipeline embedded the value verbatim, and the failure
9173 // surfaced at the resolver's `Path::join` → `CString::new`
9174 // boundary with a non-self-locating `NulError` far from the
9175 // source caixa.lisp. The new gate moves the check to validate
9176 // time and names the offending dep + caminho + offending byte
9177 // verbatim.
9178 let d = dep_with_fonte(DepSource::Path {
9179 caminho: "../caixa\0teia".into(),
9180 });
9181 let err = d.validate().unwrap_err();
9182 let DepError::FonteCaminhoControlChar {
9183 nome,
9184 caminho,
9185 byte,
9186 } = err
9187 else {
9188 panic!("expected FonteCaminhoControlChar, got {err:?}");
9189 };
9190 assert_eq!(nome, "caixa-teia");
9191 assert_eq!(caminho, "../caixa\0teia");
9192 assert_eq!(byte, 0x00);
9193 }
9194
9195 #[test]
9196 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9197 // The canonical paste-from-multiline-doc footgun on `:caminho`
9198 // — author copies `"../caixa-teia\n"` (trailing newline) out
9199 // of a multi-line code-fence or, worse, a `:caminho
9200 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9201 // injection sibling on the path axis the `is_git_repo_url`
9202 // control-char arm already closes on `:repo`). Pinned
9203 // separately from the NUL arm so a future relaxation that
9204 // catches one but not the other surfaces here.
9205 let d = dep_with_fonte(DepSource::Path {
9206 caminho: "../caixa-teia\n".into(),
9207 });
9208 let err = d.validate().unwrap_err();
9209 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9210 panic!("expected FonteCaminhoControlChar, got {err:?}");
9211 };
9212 assert_eq!(byte, 0x0A);
9213 }
9214
9215 #[test]
9216 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9217 // The CRLF sibling of the LF arm — Windows-line-ending
9218 // paste-from-multiline-doc on a `\r\n`-terminated buffer
9219 // leaves a stray `\r` mid-string after the LF strip. Pinned
9220 // separately from the LF arm so a future relaxation that
9221 // only catches LF surfaces here.
9222 let d = dep_with_fonte(DepSource::Path {
9223 caminho: "../caixa-teia\r".into(),
9224 });
9225 let err = d.validate().unwrap_err();
9226 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9227 panic!("expected FonteCaminhoControlChar, got {err:?}");
9228 };
9229 assert_eq!(byte, 0x0D);
9230 }
9231
9232 #[test]
9233 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9234 // The canonical paste-from-aligned-table footgun — a `\t`
9235 // mid-`:caminho` is invisible in most editors but rides
9236 // through the lacre's content-address verbatim, so two
9237 // paste-from-distinct-tables (one editor strips tabs, one
9238 // preserves them) yield divergent lacres for the byte-
9239 // identical-looking caixa. Pinned separately from the
9240 // whitespace-shaped LF/CR arms so a future relaxation that
9241 // narrows to line-terminator-only surfaces here.
9242 let d = dep_with_fonte(DepSource::Path {
9243 caminho: "../caixa\tteia".into(),
9244 });
9245 let err = d.validate().unwrap_err();
9246 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9247 panic!("expected FonteCaminhoControlChar, got {err:?}");
9248 };
9249 assert_eq!(byte, 0x09);
9250 }
9251
9252 #[test]
9253 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9254 // The DEL byte (`0x7F`) closes the upper-end paste-from-
9255 // binary-blob footgun — the gate's contract is `b < 0x20 ||
9256 // b == 0x7F`, matching the `is_git_repo_url` /
9257 // `is_git_ref_name` predicates' control-char arms. Pinned
9258 // separately from the lower-range arms so a future narrowing
9259 // to `< 0x20` only surfaces here.
9260 let d = dep_with_fonte(DepSource::Path {
9261 caminho: "../caixa\x7fteia".into(),
9262 });
9263 let err = d.validate().unwrap_err();
9264 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9265 panic!("expected FonteCaminhoControlChar, got {err:?}");
9266 };
9267 assert_eq!(byte, 0x7F);
9268 }
9269
9270 #[test]
9271 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9272 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9273 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9274 // are opaque byte sequences and UTF-8 multi-byte sequences
9275 // are a legitimate filename shape (the `café-teia/foo` idiom).
9276 // Pinned so the gate doesn't widen to a full ASCII-only sweep
9277 // that would break every legitimate-shape UTF-8 path.
9278 let d = dep_with_fonte(DepSource::Path {
9279 caminho: "../café-teia/foo".into(),
9280 });
9281 d.validate().unwrap();
9282 }
9283
9284 #[test]
9285 fn fonte_caminho_var_fires_before_control_char() {
9286 // Cascade pin: the var-expansion arm structurally precedes the
9287 // control-char arm. A value like `"$\n"` probes positive on
9288 // both arms (`starts_with('$')` and contains LF), but the
9289 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9290 // wins so the author sees the more self-locating shell-
9291 // expansion arm first. Mirrors the
9292 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9293 // discipline on the immediate-predecessor arm.
9294 let d = dep_with_fonte(DepSource::Path {
9295 caminho: "$HOME\n".into(),
9296 });
9297 let err = d.validate().unwrap_err();
9298 assert!(
9299 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9300 "got {err:?}",
9301 );
9302 }
9303
9304 #[test]
9305 fn validate_rejects_path_fonte_with_leading_space_caminho() {
9306 // The fail-before-pass-after pin for the leading ASCII space
9307 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9308 // Until this gate landed the b94fd83 absolute arm + the a5c248e
9309 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9310 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9311 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9312 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9313 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9314 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9315 // are caught, but the most common whitespace `0x20` space is
9316 // not). The lacre embedded the value verbatim and the resolver
9317 // folded it through `Path::join` looking for a literal `./ ../
9318 // caixa-teia` subdirectory and failing at resolve time with a
9319 // non-self-locating `No such file or directory` error far from
9320 // the source caixa.lisp. The new gate moves the check to
9321 // validate time and names the offending dep + caminho verbatim.
9322 let d = dep_with_fonte(DepSource::Path {
9323 caminho: " ../caixa-teia".into(),
9324 });
9325 let err = d.validate().unwrap_err();
9326 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9327 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9328 };
9329 assert_eq!(nome, "caixa-teia");
9330 assert_eq!(caminho, " ../caixa-teia");
9331 }
9332
9333 #[test]
9334 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9335 // The aligned-doc paste footgun sweep: more than one leading
9336 // space (`" ../caixa-teia"` — the canonical "I selected the
9337 // aligned column from a four-`:fonte`-entry `:deps` block"
9338 // paste) routes through the same gate's `starts_with(' ')`
9339 // byte check. Pinned so the gate doesn't narrow to a
9340 // single-space prefix.
9341 let d = dep_with_fonte(DepSource::Path {
9342 caminho: " ../caixa-teia".into(),
9343 });
9344 let err = d.validate().unwrap_err();
9345 assert!(
9346 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9347 "got {err:?}",
9348 );
9349 }
9350
9351 #[test]
9352 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9353 // The leading-space is the canonical paste-from-aligned-doc
9354 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9355 // canonical "I have a directory with a space in its name"
9356 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9357 // legitimate path with no whitespace-leak semantic at the
9358 // non-leading position. Pinned so the gate doesn't widen to a
9359 // full no-space-anywhere sweep that would break every
9360 // legitimate-shape space-in-filename path.
9361 let d = dep_with_fonte(DepSource::Path {
9362 caminho: "../my dir/caixa-teia".into(),
9363 });
9364 d.validate().unwrap();
9365 }
9366
9367 #[test]
9368 fn fonte_caminho_var_fires_before_leading_whitespace() {
9369 // Cascade pin: the var-expansion arm structurally precedes the
9370 // leading-whitespace arm. A value like `"$ "` would probe positive
9371 // on var (`starts_with('$')`) but the leading-byte arms walk
9372 // left-to-right so the var arm fires on the leading `$` before
9373 // the leading-whitespace arm probes. Mirrors the
9374 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9375 // discipline on the immediate-predecessor arms.
9376 let d = dep_with_fonte(DepSource::Path {
9377 caminho: "$VAR".into(),
9378 });
9379 let err = d.validate().unwrap_err();
9380 assert!(
9381 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9382 "got {err:?}",
9383 );
9384 }
9385
9386 #[test]
9387 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9388 // Cascade pin: the leading-whitespace arm structurally precedes
9389 // the control-char arm. A value like `" ../foo\n"` probes
9390 // positive on both (starts with space AND contains LF), but
9391 // the narrower leading-byte diagnostic
9392 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9393 // more self-locating paste-from-aligned-doc arm first. Mirrors
9394 // the `fonte_caminho_var_fires_before_control_char` cascade
9395 // discipline on the immediate-predecessor arm.
9396 let d = dep_with_fonte(DepSource::Path {
9397 caminho: " ../foo\n".into(),
9398 });
9399 let err = d.validate().unwrap_err();
9400 assert!(
9401 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9402 "got {err:?}",
9403 );
9404 }
9405
9406 #[test]
9407 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9408 // Diagnostic-shape pin (peer with
9409 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9410 // payload assertion on the immediate-predecessor arm): the
9411 // error's Display surfaces both the offending `:nome` and the
9412 // offending `:caminho` verbatim, so a `feira lint` run can
9413 // render the diagnostic without re-parsing and the author can
9414 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9415 // one edit.
9416 let d = dep_with_fonte(DepSource::Path {
9417 caminho: " ../caixa-teia".into(),
9418 });
9419 let rendered = d.validate().unwrap_err().to_string();
9420 assert!(
9421 rendered.contains("caixa-teia"),
9422 "diagnostic must name the offending dep: {rendered}",
9423 );
9424 assert!(
9425 rendered.contains(" ../caixa-teia"),
9426 "diagnostic must quote the offending caminho: {rendered}",
9427 );
9428 assert!(
9429 rendered.contains("space"),
9430 "diagnostic must name the space footgun: {rendered}",
9431 );
9432 }
9433
9434 #[test]
9435 fn fonte_caminho_absolute_fires_before_control_char() {
9436 // Cascade pin on the sibling leading-byte arm: a leading `/`
9437 // value with embedded control byte (`"/etc/passwd\n"`) routes
9438 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9439 // — the host-layout-leak diagnostic is the load-bearing axis,
9440 // the control byte is the secondary observation. Same precedence
9441 // logic on every prior leading-byte arm.
9442 let d = dep_with_fonte(DepSource::Path {
9443 caminho: "/etc/passwd\n".into(),
9444 });
9445 let err = d.validate().unwrap_err();
9446 assert!(
9447 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9448 "got {err:?}",
9449 );
9450 }
9451
9452 #[test]
9453 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9454 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9455 // injection `:caminho` shape sweep. Until this gate landed
9456 // every prior leading-byte arm passed a leading-`-` value
9457 // through: `Path::is_absolute` returns false on `-` (the
9458 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9459 // `starts_with('$')` / `starts_with(' ')` all return false,
9460 // and `0x2D` sits outside the control-byte set. The lacre
9461 // embedded the value verbatim and the resolver folded it
9462 // through `Path::join` looking for a literal `./-rf` /
9463 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9464 // `Path::join` time is non-self-locating but harmless, while
9465 // the failure at every downstream `git -C {caminho}` /
9466 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9467 // is arbitrary-CLI-arg-injection because none of those
9468 // porcelains carry a `--` argument-list terminator between
9469 // the flag block and the path argument. The new arm moves the
9470 // rejection to `Caixa::from_lisp` boundary time and names
9471 // the offending dep + caminho verbatim.
9472 //
9473 // Sweep spans the canonical CLI-arg-injection shapes matching
9474 // the peer sweep on the sibling `is_git_ref_name` /
9475 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9476 // `find -rf` reinterpretation vector), `-C` (the `git -C`
9477 // change-directory-config-injection paste), long-flag
9478 // `--upload-pack=cat /etc/passwd` (the canonical
9479 // arbitrary-command-execution vector on every git porcelain
9480 // entry point), git-config-injection `--config=core.merge=ours`,
9481 // and the degenerate single-byte `-` value.
9482 for caminho in [
9483 "-rf",
9484 "-C",
9485 "--upload-pack=cat /etc/passwd",
9486 "--config=core.merge=ours",
9487 "-",
9488 ] {
9489 let d = dep_with_fonte(DepSource::Path {
9490 caminho: caminho.into(),
9491 });
9492 let err = d.validate().unwrap_err();
9493 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9494 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9495 };
9496 assert_eq!(nome, "caixa-teia");
9497 assert_eq!(got, caminho);
9498 }
9499 }
9500
9501 #[test]
9502 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9503 // The leading-`-` is the canonical CLI-arg-injection footgun
9504 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9505 // canonical kebab-separator-between-alphanumeric-segments
9506 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9507 // — a mid-path segment starting with `-`, still a legitimate
9508 // POSIX filename byte at that non-leading position because the
9509 // subprocess reads the whole `{caminho}` value as one positional
9510 // argument, so only the very first byte of the composite path
9511 // string is at the CLI-arg-injection boundary) is a legitimate
9512 // path with no CLI-flag-reinterpretation semantic at the non-
9513 // leading position of the top-level value. Pinned so the gate
9514 // doesn't widen to a full no-`-`-anywhere sweep that would
9515 // break every legitimate-shape kebab-in-filename path (i.e.
9516 // essentially every sibling-workspace caixa dep).
9517 for caminho in [
9518 "../caixa-teia",
9519 "../caixa-teia/-hidden",
9520 "./my-lib",
9521 "../foo-bar/baz",
9522 ] {
9523 let d = dep_with_fonte(DepSource::Path {
9524 caminho: caminho.into(),
9525 });
9526 d.validate()
9527 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9528 }
9529 }
9530
9531 #[test]
9532 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9533 // Cascade pin: the leading-whitespace arm structurally precedes
9534 // the leading-hyphen arm. A value like `" -rf"` probes positive
9535 // on both (leading space AND, one byte in, a `-` — though the
9536 // leading-hyphen arm probes only the very first byte so it
9537 // wouldn't fire on this value; the pin instead documents the
9538 // arm order on the more common "leading space then a hyphen"
9539 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9540 // The narrower leading-space diagnostic (the paste-from-aligned-
9541 // doc footgun) wins so the author sees the more self-locating
9542 // whitespace arm first. Mirrors the
9543 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9544 // discipline on the immediate-predecessor arm.
9545 let d = dep_with_fonte(DepSource::Path {
9546 caminho: " -rf".into(),
9547 });
9548 let err = d.validate().unwrap_err();
9549 assert!(
9550 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9551 "got {err:?}",
9552 );
9553 }
9554
9555 #[test]
9556 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9557 // Cascade pin: the leading-hyphen arm structurally precedes
9558 // the control-char arm. A value like `"-rf\n"` probes positive
9559 // on both (starts with `-` AND contains LF), but the narrower
9560 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9561 // the author sees the more self-locating CLI-arg-injection arm
9562 // first. Mirrors the
9563 // `fonte_caminho_leading_whitespace_fires_before_control_char`
9564 // cascade discipline on the immediate-predecessor arm.
9565 let d = dep_with_fonte(DepSource::Path {
9566 caminho: "-rf\n".into(),
9567 });
9568 let err = d.validate().unwrap_err();
9569 assert!(
9570 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9571 "got {err:?}",
9572 );
9573 }
9574
9575 #[test]
9576 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9577 // Diagnostic-shape pin (peer with
9578 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9579 // payload assertion on the immediate-predecessor arm): the
9580 // error's Display surfaces both the offending `:nome` and the
9581 // offending `:caminho` verbatim plus the CLI-argument-injection
9582 // vocabulary, so a `feira lint` run can render the diagnostic
9583 // without re-parsing and the author can grep their caixa.lisp
9584 // for `:caminho "<value>"` and fix it in one edit.
9585 let d = dep_with_fonte(DepSource::Path {
9586 caminho: "--upload-pack=cat /etc/passwd".into(),
9587 });
9588 let rendered = d.validate().unwrap_err().to_string();
9589 assert!(
9590 rendered.contains("caixa-teia"),
9591 "diagnostic must name the offending dep: {rendered}",
9592 );
9593 assert!(
9594 rendered.contains("--upload-pack=cat /etc/passwd"),
9595 "diagnostic must quote the offending caminho: {rendered}",
9596 );
9597 assert!(
9598 rendered.contains("CLI-argument-injection"),
9599 "diagnostic must name the CLI-argument-injection vector: {rendered}",
9600 );
9601 assert!(
9602 rendered.contains("`-`"),
9603 "diagnostic must name the offending byte: {rendered}",
9604 );
9605 }
9606
9607 #[test]
9608 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9609 // Diagnostic-shape pin (peer with
9610 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9611 // payload assertion on the immediate-predecessor arm): the
9612 // error's Display surfaces the offending `:nome`, the
9613 // offending `:caminho` verbatim, and the offending byte in
9614 // hex form (`0x09` for tab) so a `feira lint` run can render
9615 // the diagnostic without re-parsing.
9616 let d = dep_with_fonte(DepSource::Path {
9617 caminho: "../caixa\tteia".into(),
9618 });
9619 let rendered = d.validate().unwrap_err().to_string();
9620 assert!(
9621 rendered.contains("caixa-teia"),
9622 "diagnostic must name the offending dep: {rendered}",
9623 );
9624 assert!(
9625 rendered.contains("../caixa\tteia"),
9626 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9627 );
9628 assert!(
9629 rendered.contains("0x09"),
9630 "diagnostic must name the offending byte in hex: {rendered:?}",
9631 );
9632 }
9633
9634 #[test]
9635 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9636 // The fail-before-pass-after pin for the canonical Windows-
9637 // path-separator paste footgun: an author who pastes a path
9638 // from Windows-Explorer's `Copy as path`, PowerShell's
9639 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9640 // produces `..\caixa-teia`-shape values that silently passed
9641 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9642 // false; `\` is neither a leading-byte sentinel nor a
9643 // control byte). On POSIX resolvers the value rides through
9644 // `Path::join` as a literal directory name and fails at
9645 // resolve time with `No such file or directory`; on Windows
9646 // resolvers the value resolves to the parent's sibling — two
9647 // distinct directories for the byte-identical caixa.lisp.
9648 // The new arm moves the rejection to validate time and names
9649 // the offending dep + caminho verbatim.
9650 let d = dep_with_fonte(DepSource::Path {
9651 caminho: "..\\caixa-teia".into(),
9652 });
9653 let err = d.validate().unwrap_err();
9654 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9655 panic!("expected FonteCaminhoBackslash, got {err:?}");
9656 };
9657 assert_eq!(nome, "caixa-teia");
9658 assert_eq!(caminho, "..\\caixa-teia");
9659 }
9660
9661 #[test]
9662 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9663 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9664 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9665 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9666 // false (POSIX absolute paths start with `/`, drive letters
9667 // are not a POSIX concept), so the b94fd83 absolute arm
9668 // doesn't fire; the value contains `\` bytes that this arm
9669 // now catches with the more self-locating Windows-path-
9670 // separator diagnostic. Pinned separately from the bare
9671 // `..\caixa-teia` shape so a future arm that targets only
9672 // leading-`..\` doesn't regress the drive-letter coverage.
9673 let d = dep_with_fonte(DepSource::Path {
9674 caminho: "C:\\work\\caixa-teia".into(),
9675 });
9676 let err = d.validate().unwrap_err();
9677 assert!(
9678 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9679 "got {err:?}",
9680 );
9681 }
9682
9683 #[test]
9684 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9685 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9686 // PowerShell tab-completion-on-a-directory append). Pinned
9687 // separately from the embedded-`\` shape so the gate's
9688 // contract is "any `\` anywhere", not "any `\` not at end".
9689 let d = dep_with_fonte(DepSource::Path {
9690 caminho: "..\\caixa-teia\\".into(),
9691 });
9692 let err = d.validate().unwrap_err();
9693 assert!(
9694 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9695 "got {err:?}",
9696 );
9697 }
9698
9699 #[test]
9700 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9701 // The positive-control pin: the gate targets `\` only,
9702 // never `/`. The canonical relative POSIX path
9703 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9704 // so legitimate nested-directory deps aren't broken. Pinned
9705 // so the gate doesn't accidentally widen to a "no path
9706 // separators at all" sweep.
9707 let d = dep_with_fonte(DepSource::Path {
9708 caminho: "../caixa-teia/foo/bar".into(),
9709 });
9710 d.validate().unwrap();
9711 }
9712
9713 #[test]
9714 fn fonte_caminho_control_char_fires_before_backslash() {
9715 // Cascade pin: the control-char arm structurally precedes the
9716 // backslash arm. A value like `"..\caixa\0teia"` probes
9717 // positive on both (`\` byte + NUL byte), but the control-
9718 // char diagnostic wins so the author sees the more self-
9719 // locating POSIX-syscall-rejected-byte diagnostic first
9720 // (NUL outright breaks `CString::new` at every `std::fs`
9721 // syscall boundary; the `\` divergence is the cross-OS-
9722 // separator axis). Mirrors the
9723 // `fonte_caminho_var_fires_before_control_char` cascade
9724 // discipline on the immediate-predecessor arm.
9725 let d = dep_with_fonte(DepSource::Path {
9726 caminho: "..\\caixa\0teia".into(),
9727 });
9728 let err = d.validate().unwrap_err();
9729 assert!(
9730 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9731 "got {err:?}",
9732 );
9733 }
9734
9735 #[test]
9736 fn fonte_caminho_absolute_fires_before_backslash() {
9737 // Cascade pin on the load-bearing leading-byte arm: a leading
9738 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9739 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9740 // — the host-layout-leak diagnostic is the load-bearing
9741 // axis, the `\` byte is the secondary observation. Same
9742 // precedence logic as every prior leading-byte arm.
9743 let d = dep_with_fonte(DepSource::Path {
9744 caminho: "/etc/passwd\\foo".into(),
9745 });
9746 let err = d.validate().unwrap_err();
9747 assert!(
9748 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9749 "got {err:?}",
9750 );
9751 }
9752
9753 #[test]
9754 fn fonte_caminho_var_fires_before_backslash() {
9755 // Cascade pin on the var-expansion arm: a leading-`$` value
9756 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9757 // PowerShell-env-var paste-from-CI-manifest footgun) routes
9758 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9759 // The shell-expansion diagnostic is the more self-locating
9760 // axis since both the leading `$` and the embedded `\`
9761 // are Windows-shell artifacts but the `$` is the root-cause
9762 // surface (an author who removes the `$` is likely to leave
9763 // the `\` too).
9764 let d = dep_with_fonte(DepSource::Path {
9765 caminho: "$WORKSPACE\\caixa-teia".into(),
9766 });
9767 let err = d.validate().unwrap_err();
9768 assert!(
9769 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9770 "got {err:?}",
9771 );
9772 }
9773
9774 #[test]
9775 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9776 // Diagnostic-shape pin (peer with the prior
9777 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9778 // on every preceding arm): the error's Display surfaces the
9779 // offending `:nome` and the offending `:caminho` verbatim
9780 // so a `feira lint` run can render the diagnostic without
9781 // re-parsing.
9782 let d = dep_with_fonte(DepSource::Path {
9783 caminho: "..\\caixa-teia".into(),
9784 });
9785 let rendered = d.validate().unwrap_err().to_string();
9786 assert!(
9787 rendered.contains("caixa-teia"),
9788 "diagnostic must name the offending dep: {rendered}",
9789 );
9790 assert!(
9791 rendered.contains("..\\caixa-teia"),
9792 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9793 );
9794 assert!(
9795 rendered.contains('\\'),
9796 "diagnostic must reference the backslash footgun: {rendered:?}",
9797 );
9798 }
9799
9800 #[test]
9801 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9802 // The fail-before-pass-after pin for the canonical trailing-`/`
9803 // paste footgun: an author who shell-tab-completes a sibling
9804 // directory (every interactive shell — bash/zsh/fish/nushell —
9805 // appends `/` on tab-completing a directory) produces
9806 // `"../caixa-teia/"`-shape values that silently passed every
9807 // prior arm (the leading byte is `.`, no control bytes, no
9808 // backslash). `Path::join` resolves both shapes to the same
9809 // directory at the resolver, but the lacre embeds the value
9810 // verbatim and the BLAKE3 closures diverge across two
9811 // workstations whose authors differ only in tab-completion
9812 // habits.
9813 let d = dep_with_fonte(DepSource::Path {
9814 caminho: "../caixa-teia/".into(),
9815 });
9816 let err = d.validate().unwrap_err();
9817 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9818 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9819 };
9820 assert_eq!(nome, "caixa-teia");
9821 assert_eq!(caminho, "../caixa-teia/");
9822 }
9823
9824 #[test]
9825 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9826 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9827 // directory and tab-completed it" footgun). Pinned separately
9828 // from the canonical `"../caixa-teia/"` shape so the gate's
9829 // contract is "any trailing `/`", not "trailing `/` after a leaf
9830 // name".
9831 let d = dep_with_fonte(DepSource::Path {
9832 caminho: "./".into(),
9833 });
9834 let err = d.validate().unwrap_err();
9835 assert!(
9836 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9837 "got {err:?}",
9838 );
9839 }
9840
9841 #[test]
9842 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9843 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9844 // that double-templated `${VAR}/` over an already-`/`-suffixed
9845 // path" footgun). The gate fires on the last byte being `/`
9846 // regardless of how many `/` precede it; the arm contract is
9847 // "the value ends with `/`", structurally.
9848 let d = dep_with_fonte(DepSource::Path {
9849 caminho: "../caixa-teia//".into(),
9850 });
9851 let err = d.validate().unwrap_err();
9852 assert!(
9853 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9854 "got {err:?}",
9855 );
9856 }
9857
9858 #[test]
9859 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9860 // The `"../"` shape (the canonical "I want the parent" tab-
9861 // completion footgun on a bare `..` path). Pinned separately so
9862 // the gate doesn't accidentally narrow to "trailing `/` only on
9863 // multi-segment paths".
9864 let d = dep_with_fonte(DepSource::Path {
9865 caminho: "../".into(),
9866 });
9867 let err = d.validate().unwrap_err();
9868 assert!(
9869 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9870 "got {err:?}",
9871 );
9872 }
9873
9874 #[test]
9875 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9876 // The positive-control pin: the gate targets the trailing byte
9877 // only, never internal `/` separators. The canonical nested
9878 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9879 // to validate cleanly so legitimate deeply-nested deps aren't
9880 // broken. Pinned so the gate doesn't accidentally widen to a
9881 // "no `/` separators anywhere" sweep that would defeat the
9882 // entire path-fonte author surface.
9883 let d = dep_with_fonte(DepSource::Path {
9884 caminho: "../caixa-teia/foo/bar".into(),
9885 });
9886 d.validate().unwrap();
9887 }
9888
9889 #[test]
9890 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9891 // The positive-control pin on the degenerate single-`.` shape
9892 // (the canonical "the caixa.lisp's own directory" idiom). The
9893 // gate fires on the trailing byte being `/`, not on the path
9894 // being short, so `"."` (one byte, not `/`) must continue to
9895 // validate cleanly.
9896 let d = dep_with_fonte(DepSource::Path {
9897 caminho: ".".into(),
9898 });
9899 d.validate().unwrap();
9900 }
9901
9902 #[test]
9903 fn fonte_caminho_control_char_fires_before_trailing_slash() {
9904 // Cascade pin: the control-char arm structurally precedes the
9905 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9906 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9907 // (control bytes are the paste-from-multiline-doc footgun the
9908 // d624c8d arm already closes). Mirrors the
9909 // `fonte_caminho_control_char_fires_before_backslash` cascade
9910 // discipline on the immediate-predecessor arm.
9911 let d = dep_with_fonte(DepSource::Path {
9912 caminho: "../foo\n/".into(),
9913 });
9914 let err = d.validate().unwrap_err();
9915 assert!(
9916 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9917 "got {err:?}",
9918 );
9919 }
9920
9921 #[test]
9922 fn fonte_caminho_backslash_fires_before_trailing_slash() {
9923 // Cascade pin on the backslash arm: a value like `"..\foo/"`
9924 // ends in `/` but the embedded `\` is the load-bearing
9925 // diagnostic (the cross-host-OS-separator divergence vector
9926 // the 3a4e1d7 arm closes). Same precedence logic as the prior
9927 // narrower-diagnostic-first cascade.
9928 let d = dep_with_fonte(DepSource::Path {
9929 caminho: "..\\caixa-teia/".into(),
9930 });
9931 let err = d.validate().unwrap_err();
9932 assert!(
9933 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9934 "got {err:?}",
9935 );
9936 }
9937
9938 #[test]
9939 fn fonte_caminho_absolute_fires_before_trailing_slash() {
9940 // Cascade pin on the load-bearing leading-byte arm: a leading
9941 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9942 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9943 // — the host-layout-leak diagnostic is the load-bearing axis,
9944 // the trailing `/` is the secondary observation. Same
9945 // precedence logic as every prior leading-byte arm.
9946 let d = dep_with_fonte(DepSource::Path {
9947 caminho: "/etc/passwd/".into(),
9948 });
9949 let err = d.validate().unwrap_err();
9950 assert!(
9951 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9952 "got {err:?}",
9953 );
9954 }
9955
9956 #[test]
9957 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9958 // Diagnostic-shape pin (peer with the prior
9959 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9960 // every preceding arm): the error's Display surfaces the
9961 // offending `:nome` and the offending `:caminho` verbatim so a
9962 // `feira lint` run can render the diagnostic without re-parsing.
9963 let d = dep_with_fonte(DepSource::Path {
9964 caminho: "../caixa-teia/".into(),
9965 });
9966 let rendered = d.validate().unwrap_err().to_string();
9967 assert!(
9968 rendered.contains("caixa-teia"),
9969 "diagnostic must name the offending dep: {rendered}",
9970 );
9971 assert!(
9972 rendered.contains("../caixa-teia/"),
9973 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9974 );
9975 assert!(
9976 rendered.contains("trailing"),
9977 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9978 );
9979 }
9980
9981 // -- :caminho shell-redirection metacharacter arm -----------------------
9982
9983 #[test]
9984 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9985 // The fail-before-pass-after pin for the canonical output-redirection
9986 // paste footgun: an author copies a shell pipeline tail
9987 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9988 // line including the `> build.log` redirect" idiom) and silently
9989 // passed every prior arm (`Path::is_absolute` false on `..`, no
9990 // control bytes, no backslash, doesn't end in `/`). The lacre
9991 // embedded the value verbatim, the resolver folded it through
9992 // `Path::join` looking for a literal `./../caixa-teia>build.log`
9993 // subdirectory, and the failure surfaced at resolve time with a
9994 // non-self-locating `No such file or directory` error. The new arm
9995 // moves the rejection to validate time and names the offending dep
9996 // + caminho + byte verbatim.
9997 let d = dep_with_fonte(DepSource::Path {
9998 caminho: "../caixa-teia>build.log".into(),
9999 });
10000 let err = d.validate().unwrap_err();
10001 let DepError::FonteCaminhoShellRedirection {
10002 nome,
10003 caminho,
10004 byte,
10005 } = err
10006 else {
10007 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10008 };
10009 assert_eq!(nome, "caixa-teia");
10010 assert_eq!(caminho, "../caixa-teia>build.log");
10011 assert_eq!(byte, b'>');
10012 }
10013
10014 #[test]
10015 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10016 // The symmetric input-redirection paste shape
10017 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10018 // `command < input.lisp` line from a tatara-lisp REPL log"
10019 // idiom). Pinned separately from the `>` shape so the gate's
10020 // contract is "any `<` or `>` anywhere", not single-byte coverage.
10021 let d = dep_with_fonte(DepSource::Path {
10022 caminho: "../caixa-teia<input.lisp".into(),
10023 });
10024 let err = d.validate().unwrap_err();
10025 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10026 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10027 };
10028 assert_eq!(byte, b'<');
10029 }
10030
10031 #[test]
10032 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10033 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10034 // "I forgot the source side of the redirect" idiom). Pinned
10035 // separately from the embedded-byte shapes so the gate covers
10036 // every position, not only mid-path.
10037 let d = dep_with_fonte(DepSource::Path {
10038 caminho: ">../caixa-teia".into(),
10039 });
10040 let err = d.validate().unwrap_err();
10041 assert!(
10042 matches!(
10043 err,
10044 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10045 ),
10046 "got {err:?}",
10047 );
10048 }
10049
10050 #[test]
10051 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10052 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10053 // the canonical "I copied a `>>` append redirect" idiom). The arm
10054 // fires on the first `>` encountered; pinned so a future arm that
10055 // tries to distinguish `>` from `>>` doesn't break the broader
10056 // contract.
10057 let d = dep_with_fonte(DepSource::Path {
10058 caminho: "../caixa-teia>>build.log".into(),
10059 });
10060 let err = d.validate().unwrap_err();
10061 assert!(
10062 matches!(
10063 err,
10064 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10065 ),
10066 "got {err:?}",
10067 );
10068 }
10069
10070 #[test]
10071 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10072 // The positive-control pin: the gate targets only `<` / `>`,
10073 // never adjacent printable ASCII or POSIX-valid bytes. The
10074 // canonical relative POSIX path (`"../caixa-teia"`) and a
10075 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10076 // continue to validate cleanly so the gate doesn't widen to a
10077 // "no printable punctuation anywhere" sweep that would defeat
10078 // the entire path-fonte author surface.
10079 let d = dep_with_fonte(DepSource::Path {
10080 caminho: "../caixa-teia/foo/bar".into(),
10081 });
10082 d.validate().unwrap();
10083 }
10084
10085 #[test]
10086 fn fonte_caminho_backslash_fires_before_shell_redirection() {
10087 // Cascade pin on the immediate-predecessor arm: a value carrying
10088 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10089 // canonical "I pasted a Windows-shell command with output
10090 // redirect" footgun) routes through `FonteCaminhoBackslash` not
10091 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10092 // divergence is the load-bearing axis (an author who removes
10093 // the `\` is the root-cause edit; the `>` falls away in the
10094 // same edit since it's downstream of the Windows-shell
10095 // convention).
10096 let d = dep_with_fonte(DepSource::Path {
10097 caminho: "..\\caixa-teia>build.log".into(),
10098 });
10099 let err = d.validate().unwrap_err();
10100 assert!(
10101 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10102 "got {err:?}",
10103 );
10104 }
10105
10106 #[test]
10107 fn fonte_caminho_control_char_fires_before_shell_redirection() {
10108 // Cascade pin on the embedded-control-byte arm: a value carrying
10109 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10110 // canonical paste-from-multiline-doc footgun where a newline
10111 // landed mid-caminho) routes through `FonteCaminhoControlChar`
10112 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10113 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10114 // load-bearing axis on every value that probes positive for
10115 // both — mirrors the cascade discipline on every prior arm.
10116 let d = dep_with_fonte(DepSource::Path {
10117 caminho: "../foo\n>bar".into(),
10118 });
10119 let err = d.validate().unwrap_err();
10120 assert!(
10121 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10122 "got {err:?}",
10123 );
10124 }
10125
10126 #[test]
10127 fn fonte_caminho_absolute_fires_before_shell_redirection() {
10128 // Cascade pin on the load-bearing leading-byte arm: a leading
10129 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10130 // routes through `FonteCaminhoAbsolute` not
10131 // `FonteCaminhoShellRedirection` — the host-layout-leak
10132 // diagnostic is the load-bearing axis, the `>` byte is the
10133 // secondary observation. Same precedence logic as every prior
10134 // leading-byte arm.
10135 let d = dep_with_fonte(DepSource::Path {
10136 caminho: "/etc/passwd>out".into(),
10137 });
10138 let err = d.validate().unwrap_err();
10139 assert!(
10140 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10141 "got {err:?}",
10142 );
10143 }
10144
10145 #[test]
10146 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10147 // Cascade pin on the immediate-successor arm: a value carrying
10148 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10149 // canonical "I tab-completed a path that already had a
10150 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10151 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10152 // the more semantic-locating axis (an author who removes the
10153 // `<` / `>` typically also drops the trailing separator since
10154 // both are paste-from-shell artifacts).
10155 let d = dep_with_fonte(DepSource::Path {
10156 caminho: "../foo></".into(),
10157 });
10158 let err = d.validate().unwrap_err();
10159 assert!(
10160 matches!(
10161 err,
10162 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10163 ),
10164 "got {err:?}",
10165 );
10166 }
10167
10168 #[test]
10169 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10170 // Diagnostic-shape pin (peer with
10171 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10172 // payload assertion on the closest peer arm that also carries a
10173 // `byte` field): the error's Display surfaces the offending
10174 // `:nome`, the offending `:caminho` verbatim, and the offending
10175 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10176 // run can render the diagnostic without re-parsing.
10177 let d = dep_with_fonte(DepSource::Path {
10178 caminho: "../caixa-teia>build.log".into(),
10179 });
10180 let rendered = d.validate().unwrap_err().to_string();
10181 assert!(
10182 rendered.contains("caixa-teia"),
10183 "diagnostic must name the offending dep: {rendered}",
10184 );
10185 assert!(
10186 rendered.contains("../caixa-teia>build.log"),
10187 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10188 );
10189 assert!(
10190 rendered.contains("0x3e"),
10191 "diagnostic must name the offending byte in hex: {rendered:?}",
10192 );
10193 assert!(
10194 rendered.contains("redirection"),
10195 "diagnostic must name the shell-redirection footgun: {rendered:?}",
10196 );
10197 }
10198
10199 // -- :caminho shell-pipe metacharacter arm ----------------------------
10200
10201 #[test]
10202 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10203 // The fail-before-pass-after pin for the canonical shell-pipe
10204 // paste footgun: an author copies a shell-history line
10205 // (`"../caixa-teia | grep foo"` — the canonical "I selected
10206 // the whole `ls dir | grep` line out of zsh history") and
10207 // silently passed every prior arm (`Path::is_absolute` false
10208 // on `..`, no control bytes, no backslash, no `<` / `>`,
10209 // doesn't end in `/`). The lacre embedded the value verbatim,
10210 // the resolver folded it through `Path::join` looking for a
10211 // literal `./../caixa-teia | grep foo` subdirectory, and the
10212 // failure surfaced at resolve time with a non-self-locating
10213 // `No such file or directory` error. The new arm moves the
10214 // rejection to validate time and names the offending dep +
10215 // caminho verbatim.
10216 let d = dep_with_fonte(DepSource::Path {
10217 caminho: "../caixa-teia | grep foo".into(),
10218 });
10219 let err = d.validate().unwrap_err();
10220 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10221 panic!("expected FonteCaminhoShellPipe, got {err:?}");
10222 };
10223 assert_eq!(nome, "caixa-teia");
10224 assert_eq!(caminho, "../caixa-teia | grep foo");
10225 }
10226
10227 #[test]
10228 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10229 // Leading-position `|` shape (`"|../caixa-teia"` — the
10230 // degenerate "I forgot the source side of the pipe" idiom).
10231 // Pinned separately from the embedded-byte shape so the gate
10232 // covers every position, not only mid-path.
10233 let d = dep_with_fonte(DepSource::Path {
10234 caminho: "|../caixa-teia".into(),
10235 });
10236 let err = d.validate().unwrap_err();
10237 assert!(
10238 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10239 "got {err:?}",
10240 );
10241 }
10242
10243 #[test]
10244 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10245 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10246 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10247 // idiom). The arm fires on the first `|` encountered; pinned
10248 // so a future arm that tries to distinguish `|` from `||`
10249 // doesn't break the broader contract.
10250 let d = dep_with_fonte(DepSource::Path {
10251 caminho: "../caixa-teia||fallback".into(),
10252 });
10253 let err = d.validate().unwrap_err();
10254 assert!(
10255 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10256 "got {err:?}",
10257 );
10258 }
10259
10260 #[test]
10261 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10262 // The positive-control pin: the gate targets only `|`, never
10263 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10264 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10265 // pathed variant with adjacent printable punctuation
10266 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10267 // cleanly so the gate doesn't widen to a "no printable
10268 // punctuation anywhere" sweep that would defeat the entire
10269 // path-fonte author surface.
10270 let d = dep_with_fonte(DepSource::Path {
10271 caminho: "../caixa-teia/sub-dir.v2".into(),
10272 });
10273 d.validate().unwrap();
10274 }
10275
10276 #[test]
10277 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10278 // Cascade pin on the immediate-predecessor arm: a value carrying
10279 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10280 // canonical "I pasted a `cmd < input | tee` pipeline tail"
10281 // footgun) routes through `FonteCaminhoShellRedirection` not
10282 // `FonteCaminhoShellPipe`. The input/output redirection
10283 // metachar carries the more self-locating `byte: u8` payload
10284 // (it names which of `<` or `>` triggered), so the prior arm
10285 // wins on every probe-as-both value — same cascade discipline
10286 // every prior `:caminho` arm establishes.
10287 let d = dep_with_fonte(DepSource::Path {
10288 caminho: "../caixa-teia<input|tee".into(),
10289 });
10290 let err = d.validate().unwrap_err();
10291 assert!(
10292 matches!(
10293 err,
10294 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10295 ),
10296 "got {err:?}",
10297 );
10298 }
10299
10300 #[test]
10301 fn fonte_caminho_backslash_fires_before_shell_pipe() {
10302 // Cascade pin on the upstream backslash arm: a value carrying
10303 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10304 // "I pasted a Windows-shell command with pipe to tee"
10305 // footgun) routes through `FonteCaminhoBackslash` not
10306 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10307 // divergence is the load-bearing axis on every probe-as-both
10308 // value (an author who removes the `\` is the root-cause edit;
10309 // the `|` falls away in the same edit since it's downstream of
10310 // the Windows-shell convention).
10311 let d = dep_with_fonte(DepSource::Path {
10312 caminho: "..\\caixa-teia|tee".into(),
10313 });
10314 let err = d.validate().unwrap_err();
10315 assert!(
10316 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10317 "got {err:?}",
10318 );
10319 }
10320
10321 #[test]
10322 fn fonte_caminho_control_char_fires_before_shell_pipe() {
10323 // Cascade pin on the embedded-control-byte arm: a value
10324 // carrying both a control byte and `|` (`"../foo\n|bar"` —
10325 // the canonical paste-from-multiline-doc footgun where a
10326 // newline landed mid-caminho) routes through
10327 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10328 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10329 // diagnostic is the load-bearing axis on every value that
10330 // probes positive for both — mirrors the cascade discipline
10331 // on every prior arm.
10332 let d = dep_with_fonte(DepSource::Path {
10333 caminho: "../foo\n|bar".into(),
10334 });
10335 let err = d.validate().unwrap_err();
10336 assert!(
10337 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10338 "got {err:?}",
10339 );
10340 }
10341
10342 #[test]
10343 fn fonte_caminho_absolute_fires_before_shell_pipe() {
10344 // Cascade pin on the load-bearing leading-byte arm: a leading
10345 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10346 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10347 // — the host-layout-leak diagnostic is the load-bearing axis,
10348 // the `|` byte is the secondary observation. Same precedence
10349 // logic as every prior leading-byte arm.
10350 let d = dep_with_fonte(DepSource::Path {
10351 caminho: "/etc/passwd|tee".into(),
10352 });
10353 let err = d.validate().unwrap_err();
10354 assert!(
10355 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10356 "got {err:?}",
10357 );
10358 }
10359
10360 #[test]
10361 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10362 // Cascade pin on the immediate-successor arm: a value carrying
10363 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10364 // "I tab-completed a path that already had a pipeline tail"
10365 // footgun) routes through `FonteCaminhoShellPipe` not
10366 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10367 // the more semantic-locating axis (an author who removes the
10368 // `|` typically also drops the trailing separator since both
10369 // are paste-from-shell artifacts).
10370 let d = dep_with_fonte(DepSource::Path {
10371 caminho: "../foo|tee/".into(),
10372 });
10373 let err = d.validate().unwrap_err();
10374 assert!(
10375 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10376 "got {err:?}",
10377 );
10378 }
10379
10380 #[test]
10381 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10382 // Diagnostic-shape pin (peer with
10383 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10384 // on the closest single-byte peer arm): the error's Display
10385 // surfaces the offending `:nome` and the offending `:caminho`
10386 // verbatim, and names the shell-pipe footgun explicitly so a
10387 // `feira lint` run can render the diagnostic without
10388 // re-parsing.
10389 let d = dep_with_fonte(DepSource::Path {
10390 caminho: "../caixa-teia | grep foo".into(),
10391 });
10392 let rendered = d.validate().unwrap_err().to_string();
10393 assert!(
10394 rendered.contains("caixa-teia"),
10395 "diagnostic must name the offending dep: {rendered}",
10396 );
10397 assert!(
10398 rendered.contains("../caixa-teia | grep foo"),
10399 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10400 );
10401 assert!(
10402 rendered.contains('|'),
10403 "diagnostic must reference the pipe footgun: {rendered:?}",
10404 );
10405 assert!(
10406 rendered.contains("pipe"),
10407 "diagnostic must name the shell-pipe footgun: {rendered:?}",
10408 );
10409 }
10410
10411 // -- :caminho shell-command-separator metacharacter arm ---------------
10412
10413 #[test]
10414 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10415 // The fail-before-pass-after pin for the canonical shell-command-
10416 // separator paste footgun: an author copies a shell one-liner
10417 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10418 // whole `cd path; do-thing` chain out of a shell-history block")
10419 // and silently passed every prior arm (`Path::is_absolute` false
10420 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10421 // doesn't end in `/`). The lacre embedded the value verbatim, the
10422 // resolver folded it through `Path::join` looking for a literal
10423 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10424 // surfaced at resolve time with a non-self-locating `No such file
10425 // or directory` error. The new arm moves the rejection to validate
10426 // time and names the offending dep + caminho verbatim.
10427 let d = dep_with_fonte(DepSource::Path {
10428 caminho: "../caixa-teia; rm -rf build".into(),
10429 });
10430 let err = d.validate().unwrap_err();
10431 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10432 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10433 };
10434 assert_eq!(nome, "caixa-teia");
10435 assert_eq!(caminho, "../caixa-teia; rm -rf build");
10436 }
10437
10438 #[test]
10439 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10440 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10441 // "I forgot the prior command side of the separator" idiom).
10442 // Pinned separately from the embedded-byte shape so the gate
10443 // covers every position, not only mid-path.
10444 let d = dep_with_fonte(DepSource::Path {
10445 caminho: ";../caixa-teia".into(),
10446 });
10447 let err = d.validate().unwrap_err();
10448 assert!(
10449 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10450 "got {err:?}",
10451 );
10452 }
10453
10454 #[test]
10455 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10456 // The POSIX `case` arm `;;` terminator shape
10457 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10458 // arm tail" idiom). The arm fires on the first `;` encountered;
10459 // pinned so a future arm that tries to distinguish `;` from `;;`
10460 // doesn't break the broader contract.
10461 let d = dep_with_fonte(DepSource::Path {
10462 caminho: "../caixa-teia;;next".into(),
10463 });
10464 let err = d.validate().unwrap_err();
10465 assert!(
10466 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10467 "got {err:?}",
10468 );
10469 }
10470
10471 #[test]
10472 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10473 // The positive-control pin: the gate targets only `;`, never
10474 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10475 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10476 // pathed variant with adjacent printable punctuation
10477 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10478 // cleanly so the gate doesn't widen to a "no printable
10479 // punctuation anywhere" sweep that would defeat the entire
10480 // path-fonte author surface.
10481 let d = dep_with_fonte(DepSource::Path {
10482 caminho: "../caixa-teia/sub-dir.v2".into(),
10483 });
10484 d.validate().unwrap();
10485 }
10486
10487 #[test]
10488 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10489 // Cascade pin on the immediate-predecessor arm: a value carrying
10490 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10491 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10492 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10493 // pipeline-tail paste is the load-bearing root-cause edit on
10494 // every probe-as-both value (an author who removes the `|`
10495 // typically also drops the trailing `; cleanup` since both are
10496 // the same paste-from-shell-history artifact) — same cascade
10497 // discipline every prior `:caminho` arm establishes.
10498 let d = dep_with_fonte(DepSource::Path {
10499 caminho: "../caixa-teia | tee; rm".into(),
10500 });
10501 let err = d.validate().unwrap_err();
10502 assert!(
10503 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10504 "got {err:?}",
10505 );
10506 }
10507
10508 #[test]
10509 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10510 // Cascade pin on the upstream shell-redirection arm: a value
10511 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10512 // the canonical "I pasted a `cmd > log; cleanup` chain"
10513 // footgun) routes through `FonteCaminhoShellRedirection` not
10514 // `FonteCaminhoShellSemicolon`. The input/output redirection
10515 // metachar carries the more self-locating `byte: u8` payload
10516 // (it names which of `<` or `>` triggered), so the prior arm
10517 // wins on every probe-as-both value.
10518 let d = dep_with_fonte(DepSource::Path {
10519 caminho: "../caixa-teia>log; rm".into(),
10520 });
10521 let err = d.validate().unwrap_err();
10522 assert!(
10523 matches!(
10524 err,
10525 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10526 ),
10527 "got {err:?}",
10528 );
10529 }
10530
10531 #[test]
10532 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10533 // Cascade pin on the upstream backslash arm: a value carrying
10534 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10535 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10536 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10537 // The cross-host-OS-separator divergence is the load-bearing axis
10538 // on every probe-as-both value (an author who removes the `\` is
10539 // the root-cause edit; the `;` falls away in the same edit since
10540 // it's downstream of the Windows-shell convention).
10541 let d = dep_with_fonte(DepSource::Path {
10542 caminho: "..\\caixa-teia;rm".into(),
10543 });
10544 let err = d.validate().unwrap_err();
10545 assert!(
10546 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10547 "got {err:?}",
10548 );
10549 }
10550
10551 #[test]
10552 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10553 // Cascade pin on the embedded-control-byte arm: a value carrying
10554 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10555 // paste-from-multiline-doc footgun where a newline landed mid-
10556 // caminho) routes through `FonteCaminhoControlChar` not
10557 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10558 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10559 // on every value that probes positive for both — mirrors the
10560 // cascade discipline on every prior arm.
10561 let d = dep_with_fonte(DepSource::Path {
10562 caminho: "../foo\n;bar".into(),
10563 });
10564 let err = d.validate().unwrap_err();
10565 assert!(
10566 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10567 "got {err:?}",
10568 );
10569 }
10570
10571 #[test]
10572 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10573 // Cascade pin on the load-bearing leading-byte arm: a leading
10574 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10575 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10576 // — the host-layout-leak diagnostic is the load-bearing axis,
10577 // the `;` byte is the secondary observation. Same precedence
10578 // logic as every prior leading-byte arm.
10579 let d = dep_with_fonte(DepSource::Path {
10580 caminho: "/etc/passwd;rm".into(),
10581 });
10582 let err = d.validate().unwrap_err();
10583 assert!(
10584 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10585 "got {err:?}",
10586 );
10587 }
10588
10589 #[test]
10590 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10591 // Cascade pin on the immediate-successor arm: a value carrying
10592 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10593 // "I tab-completed a path that already had a `; cleanup` tail"
10594 // footgun) routes through `FonteCaminhoShellSemicolon` not
10595 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10596 // the more semantic-locating axis (an author who removes the
10597 // `;` typically also drops the trailing separator since both
10598 // are paste-from-shell artifacts).
10599 let d = dep_with_fonte(DepSource::Path {
10600 caminho: "../foo;rm/".into(),
10601 });
10602 let err = d.validate().unwrap_err();
10603 assert!(
10604 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10605 "got {err:?}",
10606 );
10607 }
10608
10609 #[test]
10610 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10611 // Diagnostic-shape pin (peer with
10612 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10613 // on the closest single-byte peer arm): the error's Display
10614 // surfaces the offending `:nome` and the offending `:caminho`
10615 // verbatim, and names the shell-command-separator footgun
10616 // explicitly so a `feira lint` run can render the diagnostic
10617 // without re-parsing.
10618 let d = dep_with_fonte(DepSource::Path {
10619 caminho: "../caixa-teia; rm -rf build".into(),
10620 });
10621 let rendered = d.validate().unwrap_err().to_string();
10622 assert!(
10623 rendered.contains("caixa-teia"),
10624 "diagnostic must name the offending dep: {rendered}",
10625 );
10626 assert!(
10627 rendered.contains("../caixa-teia; rm -rf build"),
10628 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10629 );
10630 assert!(
10631 rendered.contains(';'),
10632 "diagnostic must reference the semicolon footgun: {rendered:?}",
10633 );
10634 assert!(
10635 rendered.contains("command-separator"),
10636 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10637 );
10638 }
10639
10640 #[test]
10641 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10642 // The fail-before-pass-after pin for the canonical shell-
10643 // background-task paste footgun: an author copies a shell one-
10644 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10645 // the whole `cd path & sleep 1` background-launch out of a
10646 // shell-history block") and silently passed every prior arm
10647 // (`Path::is_absolute` false on `..`, no control bytes, no
10648 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10649 // The lacre embedded the value verbatim, the resolver folded it
10650 // through `Path::join` looking for a literal `./../caixa-teia &
10651 // sleep 1` subdirectory, and the failure surfaced at resolve
10652 // time with a non-self-locating `No such file or directory`
10653 // error. The new arm moves the rejection to validate time and
10654 // names the offending dep + caminho verbatim.
10655 let d = dep_with_fonte(DepSource::Path {
10656 caminho: "../caixa-teia & sleep 1".into(),
10657 });
10658 let err = d.validate().unwrap_err();
10659 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10660 panic!("expected FonteCaminhoShellBackground, got {err:?}");
10661 };
10662 assert_eq!(nome, "caixa-teia");
10663 assert_eq!(caminho, "../caixa-teia & sleep 1");
10664 }
10665
10666 #[test]
10667 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10668 // Leading-position `&` shape (`"&../caixa-teia"` — the
10669 // degenerate "I forgot the prior command side of the
10670 // background terminator" idiom). Pinned separately from the
10671 // embedded-byte shape so the gate covers every position, not
10672 // only mid-path.
10673 let d = dep_with_fonte(DepSource::Path {
10674 caminho: "&../caixa-teia".into(),
10675 });
10676 let err = d.validate().unwrap_err();
10677 assert!(
10678 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10679 "got {err:?}",
10680 );
10681 }
10682
10683 #[test]
10684 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10685 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10686 // canonical "I copied a `cd path && make` build chain" idiom
10687 // every Makefile / shell-script wraps). The arm fires on the
10688 // first `&` encountered; pinned so a future arm that tries to
10689 // distinguish `&` from `&&` doesn't break the broader contract.
10690 let d = dep_with_fonte(DepSource::Path {
10691 caminho: "../caixa-teia && make".into(),
10692 });
10693 let err = d.validate().unwrap_err();
10694 assert!(
10695 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10696 "got {err:?}",
10697 );
10698 }
10699
10700 #[test]
10701 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10702 // The positive-control pin: the gate targets only `&`, never
10703 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10704 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10705 // pathed variant with adjacent printable punctuation
10706 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10707 // cleanly so the gate doesn't widen to a "no printable
10708 // punctuation anywhere" sweep that would defeat the entire
10709 // path-fonte author surface.
10710 let d = dep_with_fonte(DepSource::Path {
10711 caminho: "../caixa-teia/sub-dir.v2".into(),
10712 });
10713 d.validate().unwrap();
10714 }
10715
10716 #[test]
10717 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10718 // Cascade pin on the immediate-predecessor arm: a value carrying
10719 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10720 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10721 // routes through `FonteCaminhoShellSemicolon` not
10722 // `FonteCaminhoShellBackground`. The sequential-command-
10723 // separator paste is the more common shell-history paste idiom
10724 // on every probe-as-both value (an author who removes the `;`
10725 // typically also drops the trailing `& sleep` since both are
10726 // paste-from-shell-history artifacts) — same cascade discipline
10727 // every prior `:caminho` arm establishes.
10728 let d = dep_with_fonte(DepSource::Path {
10729 caminho: "../caixa-teia; rm & sleep".into(),
10730 });
10731 let err = d.validate().unwrap_err();
10732 assert!(
10733 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10734 "got {err:?}",
10735 );
10736 }
10737
10738 #[test]
10739 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10740 // Cascade pin on the upstream shell-pipe arm: a value carrying
10741 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10742 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10743 // chain" footgun) routes through `FonteCaminhoShellPipe` not
10744 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10745 // load-bearing root-cause edit on every probe-as-both value.
10746 let d = dep_with_fonte(DepSource::Path {
10747 caminho: "../caixa-teia | tee & sleep".into(),
10748 });
10749 let err = d.validate().unwrap_err();
10750 assert!(
10751 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10752 "got {err:?}",
10753 );
10754 }
10755
10756 #[test]
10757 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10758 // Cascade pin on the upstream shell-redirection arm: a value
10759 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10760 // the canonical "I pasted a `cmd > log & sleep` background-
10761 // redirect chain" footgun) routes through
10762 // `FonteCaminhoShellRedirection` not
10763 // `FonteCaminhoShellBackground`. The input/output redirection
10764 // metachar carries the more self-locating `byte: u8` payload
10765 // (it names which of `<` or `>` triggered), so the prior arm
10766 // wins on every probe-as-both value.
10767 let d = dep_with_fonte(DepSource::Path {
10768 caminho: "../caixa-teia>log & sleep".into(),
10769 });
10770 let err = d.validate().unwrap_err();
10771 assert!(
10772 matches!(
10773 err,
10774 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10775 ),
10776 "got {err:?}",
10777 );
10778 }
10779
10780 #[test]
10781 fn fonte_caminho_backslash_fires_before_shell_background() {
10782 // Cascade pin on the upstream backslash arm: a value carrying
10783 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10784 // "I pasted a Windows-shell `cd ..\path & sleep` background-
10785 // launch chain") routes through `FonteCaminhoBackslash` not
10786 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10787 // divergence is the load-bearing axis on every probe-as-both
10788 // value (an author who removes the `\` is the root-cause edit;
10789 // the `&` falls away in the same edit since it's downstream of
10790 // the Windows-shell convention).
10791 let d = dep_with_fonte(DepSource::Path {
10792 caminho: "..\\caixa-teia & sleep".into(),
10793 });
10794 let err = d.validate().unwrap_err();
10795 assert!(
10796 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10797 "got {err:?}",
10798 );
10799 }
10800
10801 #[test]
10802 fn fonte_caminho_control_char_fires_before_shell_background() {
10803 // Cascade pin on the embedded-control-byte arm: a value
10804 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10805 // the canonical paste-from-multiline-doc footgun where a
10806 // newline landed mid-caminho) routes through
10807 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10808 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10809 // diagnostic is the load-bearing axis on every value that
10810 // probes positive for both — mirrors the cascade discipline on
10811 // every prior arm.
10812 let d = dep_with_fonte(DepSource::Path {
10813 caminho: "../foo\n&sleep".into(),
10814 });
10815 let err = d.validate().unwrap_err();
10816 assert!(
10817 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10818 "got {err:?}",
10819 );
10820 }
10821
10822 #[test]
10823 fn fonte_caminho_absolute_fires_before_shell_background() {
10824 // Cascade pin on the load-bearing leading-byte arm: a leading
10825 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10826 // through `FonteCaminhoAbsolute` not
10827 // `FonteCaminhoShellBackground` — the host-layout-leak
10828 // diagnostic is the load-bearing axis, the `&` byte is the
10829 // secondary observation. Same precedence logic as every prior
10830 // leading-byte arm.
10831 let d = dep_with_fonte(DepSource::Path {
10832 caminho: "/etc/passwd & sleep".into(),
10833 });
10834 let err = d.validate().unwrap_err();
10835 assert!(
10836 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10837 "got {err:?}",
10838 );
10839 }
10840
10841 #[test]
10842 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10843 // Cascade pin on the immediate-successor arm: a value carrying
10844 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10845 // canonical "I tab-completed a path that already had a `&
10846 // sleep` background-launch tail" footgun) routes through
10847 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10848 // The embedded shell-metachar is the more semantic-locating
10849 // axis (an author who removes the `&` typically also drops
10850 // the trailing separator since both are paste-from-shell
10851 // artifacts).
10852 let d = dep_with_fonte(DepSource::Path {
10853 caminho: "../foo&sleep/".into(),
10854 });
10855 let err = d.validate().unwrap_err();
10856 assert!(
10857 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10858 "got {err:?}",
10859 );
10860 }
10861
10862 #[test]
10863 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10864 // Diagnostic-shape pin (peer with
10865 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10866 // on the closest single-byte peer arm): the error's Display
10867 // surfaces the offending `:nome` and the offending `:caminho`
10868 // verbatim, and names the shell-background / logical-AND
10869 // footgun explicitly so a `feira lint` run can render the
10870 // diagnostic without re-parsing.
10871 let d = dep_with_fonte(DepSource::Path {
10872 caminho: "../caixa-teia & sleep 1".into(),
10873 });
10874 let rendered = d.validate().unwrap_err().to_string();
10875 assert!(
10876 rendered.contains("caixa-teia"),
10877 "diagnostic must name the offending dep: {rendered}",
10878 );
10879 assert!(
10880 rendered.contains("../caixa-teia & sleep 1"),
10881 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10882 );
10883 assert!(
10884 rendered.contains('&'),
10885 "diagnostic must reference the ampersand footgun: {rendered:?}",
10886 );
10887 assert!(
10888 rendered.contains("background") || rendered.contains("list-AND"),
10889 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10890 );
10891 }
10892
10893 #[test]
10894 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10895 // The fail-before-pass-after pin for the canonical shell-
10896 // command-substitution paste footgun: an author copies a
10897 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10898 // — the canonical "I pasted a path that included a `pwd`
10899 // / `whoami` / `date` legacy command-substitution expansion
10900 // out of a shell-history block") and silently passed every
10901 // prior arm (`Path::is_absolute` false on `..`, no control
10902 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10903 // end in `/`). The lacre embedded the value verbatim, the
10904 // resolver folded it through `Path::join` looking for a
10905 // literal `./../caixa-teia/`whoami`` subdirectory, and the
10906 // failure surfaced at resolve time with a non-self-locating
10907 // `No such file or directory` error. The new arm moves the
10908 // rejection to validate time and names the offending dep +
10909 // caminho verbatim.
10910 let d = dep_with_fonte(DepSource::Path {
10911 caminho: "../caixa-teia/`whoami`".into(),
10912 });
10913 let err = d.validate().unwrap_err();
10914 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10915 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10916 };
10917 assert_eq!(nome, "caixa-teia");
10918 assert_eq!(caminho, "../caixa-teia/`whoami`");
10919 }
10920
10921 #[test]
10922 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10923 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10924 // the canonical `<backtick>pwd<backtick>/path` working-
10925 // directory expansion shape every shell-side path-composition
10926 // idiom carries). Pinned separately from the embedded-byte
10927 // shape so the gate covers every position, not only mid-path.
10928 let d = dep_with_fonte(DepSource::Path {
10929 caminho: "`pwd`/caixa-teia".into(),
10930 });
10931 let err = d.validate().unwrap_err();
10932 assert!(
10933 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10934 "got {err:?}",
10935 );
10936 }
10937
10938 #[test]
10939 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10940 // Trailing-position backtick shape (`"../caixa-teia`"` — the
10941 // degenerate "I selected an unbalanced backtick out of a
10942 // shell-history block" idiom that probes for the cascade's
10943 // last-byte handling). The trailing-`/` arm fires only on
10944 // last-byte `/`; an unbalanced trailing backtick must route
10945 // through this arm regardless of position.
10946 let d = dep_with_fonte(DepSource::Path {
10947 caminho: "../caixa-teia`".into(),
10948 });
10949 let err = d.validate().unwrap_err();
10950 assert!(
10951 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10952 "got {err:?}",
10953 );
10954 }
10955
10956 #[test]
10957 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10958 // The canonical balanced-pair shape (``"../<backtick>cat
10959 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10960 // command-injection paste idiom every shell-side hardening
10961 // guide enumerates first). The arm fires on the first
10962 // backtick encountered; pinned so a future arm that tries to
10963 // distinguish the opening from the closing byte doesn't break
10964 // the broader contract.
10965 let d = dep_with_fonte(DepSource::Path {
10966 caminho: "../`cat /etc/passwd`".into(),
10967 });
10968 let err = d.validate().unwrap_err();
10969 assert!(
10970 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10971 "got {err:?}",
10972 );
10973 }
10974
10975 #[test]
10976 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10977 // The positive-control pin: the gate targets only the
10978 // backtick byte, never adjacent printable ASCII or POSIX-
10979 // valid bytes. The canonical relative POSIX path
10980 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10981 // adjacent printable punctuation
10982 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10983 // cleanly so the gate doesn't widen to a "no printable
10984 // punctuation anywhere" sweep that would defeat the entire
10985 // path-fonte author surface.
10986 let d = dep_with_fonte(DepSource::Path {
10987 caminho: "../caixa-teia/sub-dir.v2".into(),
10988 });
10989 d.validate().unwrap();
10990 }
10991
10992 #[test]
10993 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10994 // Cascade pin on the immediate-predecessor arm: a value
10995 // carrying both `&` and a backtick (``"../caixa-teia &
10996 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10997 // `cmd & <backtick>sleep N<backtick>` background-launch +
10998 // command-substitution chain" footgun) routes through
10999 // `FonteCaminhoShellBackground` not
11000 // `FonteCaminhoShellCommandSubstitution`. The background-
11001 // launch tail is the more common shell-history paste idiom
11002 // on every probe-as-both value — same cascade discipline
11003 // every prior `:caminho` arm establishes.
11004 let d = dep_with_fonte(DepSource::Path {
11005 caminho: "../caixa-teia & `sleep 1`".into(),
11006 });
11007 let err = d.validate().unwrap_err();
11008 assert!(
11009 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11010 "got {err:?}",
11011 );
11012 }
11013
11014 #[test]
11015 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11016 // Cascade pin on the upstream shell-semicolon arm: a value
11017 // carrying both `;` and a backtick (``"../caixa-teia;
11018 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11019 // `cmd; <backtick>follow-up<backtick>` sequential-chain
11020 // footgun) routes through `FonteCaminhoShellSemicolon` not
11021 // `FonteCaminhoShellCommandSubstitution`. The sequential-
11022 // command-separator paste is the load-bearing root-cause
11023 // edit on every probe-as-both value.
11024 let d = dep_with_fonte(DepSource::Path {
11025 caminho: "../caixa-teia; `whoami`".into(),
11026 });
11027 let err = d.validate().unwrap_err();
11028 assert!(
11029 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11030 "got {err:?}",
11031 );
11032 }
11033
11034 #[test]
11035 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11036 // Cascade pin on the upstream shell-pipe arm: a value
11037 // carrying both `|` and a backtick (``"../caixa-teia |
11038 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11039 // command-substitution paste idiom) routes through
11040 // `FonteCaminhoShellPipe` not
11041 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11042 // paste is the load-bearing root-cause edit on every
11043 // probe-as-both value.
11044 let d = dep_with_fonte(DepSource::Path {
11045 caminho: "../caixa-teia | `tee log`".into(),
11046 });
11047 let err = d.validate().unwrap_err();
11048 assert!(
11049 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11050 "got {err:?}",
11051 );
11052 }
11053
11054 #[test]
11055 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11056 // Cascade pin on the upstream shell-redirection arm: a value
11057 // carrying both `>` and a backtick (``"../caixa-teia>log
11058 // <backtick>date<backtick>"`` — the canonical "I pasted a
11059 // `cmd > log <backtick>date<backtick>` redirect-plus-
11060 // substitution chain" footgun) routes through
11061 // `FonteCaminhoShellRedirection` not
11062 // `FonteCaminhoShellCommandSubstitution`. The input/output
11063 // redirection metachar carries the more self-locating `byte`
11064 // payload (it names which of `<` or `>` triggered), so the
11065 // prior arm wins on every probe-as-both value.
11066 let d = dep_with_fonte(DepSource::Path {
11067 caminho: "../caixa-teia>log `date`".into(),
11068 });
11069 let err = d.validate().unwrap_err();
11070 assert!(
11071 matches!(
11072 err,
11073 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11074 ),
11075 "got {err:?}",
11076 );
11077 }
11078
11079 #[test]
11080 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11081 // Cascade pin on the upstream backslash arm: a value
11082 // carrying both `\` and a backtick (``"..\caixa-teia
11083 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11084 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11085 // chain") routes through `FonteCaminhoBackslash` not
11086 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11087 // separator divergence is the load-bearing axis on every
11088 // probe-as-both value (an author who removes the `\` is the
11089 // root-cause edit; the backtick falls away in the same edit
11090 // since it's downstream of the Windows-shell convention).
11091 let d = dep_with_fonte(DepSource::Path {
11092 caminho: "..\\caixa-teia `whoami`".into(),
11093 });
11094 let err = d.validate().unwrap_err();
11095 assert!(
11096 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11097 "got {err:?}",
11098 );
11099 }
11100
11101 #[test]
11102 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11103 // Cascade pin on the embedded-control-byte arm: a value
11104 // carrying both a control byte and a backtick (`"../foo\n
11105 // `whoami`"` — the canonical paste-from-multiline-doc
11106 // footgun where a newline landed mid-caminho between two
11107 // paste fragments) routes through `FonteCaminhoControlChar`
11108 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11109 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11110 // is the load-bearing axis on every value that probes
11111 // positive for both — mirrors the cascade discipline on
11112 // every prior arm.
11113 let d = dep_with_fonte(DepSource::Path {
11114 caminho: "../foo\n`whoami`".into(),
11115 });
11116 let err = d.validate().unwrap_err();
11117 assert!(
11118 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11119 "got {err:?}",
11120 );
11121 }
11122
11123 #[test]
11124 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11125 // Cascade pin on the load-bearing leading-byte arm: a
11126 // leading `/` value with embedded backtick (``"/etc/passwd
11127 // <backtick>whoami<backtick>"``) routes through
11128 // `FonteCaminhoAbsolute` not
11129 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11130 // leak diagnostic is the load-bearing axis, the backtick
11131 // byte is the secondary observation. Same precedence logic
11132 // as every prior leading-byte arm.
11133 let d = dep_with_fonte(DepSource::Path {
11134 caminho: "/etc/passwd `whoami`".into(),
11135 });
11136 let err = d.validate().unwrap_err();
11137 assert!(
11138 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11139 "got {err:?}",
11140 );
11141 }
11142
11143 #[test]
11144 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11145 // Cascade pin on the immediate-successor arm: a value
11146 // carrying both a backtick and a trailing `/`
11147 // (``"../`whoami`/"`` — the canonical "I tab-completed a
11148 // path that already had a backticked `whoami` substitution
11149 // tail" footgun) routes through
11150 // `FonteCaminhoShellCommandSubstitution` not
11151 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11152 // is the more semantic-locating axis (an author who removes
11153 // the backtick typically also drops the trailing separator
11154 // since both are paste-from-shell artifacts).
11155 let d = dep_with_fonte(DepSource::Path {
11156 caminho: "../`whoami`/".into(),
11157 });
11158 let err = d.validate().unwrap_err();
11159 assert!(
11160 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11161 "got {err:?}",
11162 );
11163 }
11164
11165 #[test]
11166 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11167 // Diagnostic-shape pin (peer with
11168 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11169 // on the closest single-byte peer arm): the error's Display
11170 // surfaces the offending `:nome` and the offending `:caminho`
11171 // verbatim, and names the shell-command-substitution footgun
11172 // explicitly so a `feira lint` run can render the diagnostic
11173 // without re-parsing.
11174 let d = dep_with_fonte(DepSource::Path {
11175 caminho: "../caixa-teia/`whoami`".into(),
11176 });
11177 let rendered = d.validate().unwrap_err().to_string();
11178 assert!(
11179 rendered.contains("caixa-teia"),
11180 "diagnostic must name the offending dep: {rendered}",
11181 );
11182 assert!(
11183 rendered.contains("../caixa-teia/`whoami`"),
11184 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11185 );
11186 assert!(
11187 rendered.contains('`'),
11188 "diagnostic must reference the backtick footgun: {rendered:?}",
11189 );
11190 assert!(
11191 rendered.contains("command-substitution"),
11192 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11193 );
11194 }
11195
11196 #[test]
11197 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11198 // The fail-before-pass-after pin for the canonical pathname-
11199 // expansion paste footgun: an author copies an `ls
11200 // ../caixa-teia/*` shell-listing tail into the `:caminho`
11201 // slot and silently passes every prior arm
11202 // (`Path::is_absolute` false on `..`, no control bytes, no
11203 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11204 // doesn't end in `/`). The lacre embedded the value
11205 // verbatim, the resolver folded it through `Path::join`
11206 // looking for a literal `./../caixa-teia/*` subdirectory,
11207 // and the failure surfaced at resolve time with a non-self-
11208 // locating `No such file or directory` error. The new arm
11209 // moves the rejection to validate time and names the
11210 // offending dep + caminho + byte verbatim.
11211 let d = dep_with_fonte(DepSource::Path {
11212 caminho: "../caixa-teia/*".into(),
11213 });
11214 let err = d.validate().unwrap_err();
11215 let DepError::FonteCaminhoShellGlob {
11216 nome,
11217 caminho,
11218 byte,
11219 } = err
11220 else {
11221 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11222 };
11223 assert_eq!(nome, "caixa-teia");
11224 assert_eq!(caminho, "../caixa-teia/*");
11225 assert_eq!(byte, b'*');
11226 }
11227
11228 #[test]
11229 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11230 // The symmetric single-char-wildcard paste shape
11231 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11232 // out of shell history" idiom). Pinned separately from the
11233 // `*` shape so the gate's contract is "any `*` or `?`
11234 // anywhere", not single-byte coverage.
11235 let d = dep_with_fonte(DepSource::Path {
11236 caminho: "../foo?".into(),
11237 });
11238 let err = d.validate().unwrap_err();
11239 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11240 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11241 };
11242 assert_eq!(byte, b'?');
11243 }
11244
11245 #[test]
11246 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11247 // Leading-position `*` shape (`"*/caixa-teia"` — the
11248 // degenerate "I selected only the wildcard prefix out of a
11249 // shell-glob expression" idiom). Pinned separately from the
11250 // embedded-byte shapes so the gate covers every position,
11251 // not only mid-path.
11252 let d = dep_with_fonte(DepSource::Path {
11253 caminho: "*/caixa-teia".into(),
11254 });
11255 let err = d.validate().unwrap_err();
11256 assert!(
11257 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11258 "got {err:?}",
11259 );
11260 }
11261
11262 #[test]
11263 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11264 // The bash/zsh `globstar` recursive-glob shape
11265 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11266 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11267 // The arm fires on the first `*` encountered; pinned so a
11268 // future arm that tries to distinguish single `*` from
11269 // double `**` doesn't break the broader contract.
11270 let d = dep_with_fonte(DepSource::Path {
11271 caminho: "../caixa-teia/**/foo".into(),
11272 });
11273 let err = d.validate().unwrap_err();
11274 assert!(
11275 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11276 "got {err:?}",
11277 );
11278 }
11279
11280 #[test]
11281 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11282 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11283 // — the "I selected `*.lisp` to mean every Lisp source file
11284 // in the dep root" footgun the prior arms structurally
11285 // cannot catch since `.` is a POSIX-valid path-component
11286 // byte). Pinned so the gate's contract covers the most
11287 // idiomatic glob-paste shape every author meets first.
11288 let d = dep_with_fonte(DepSource::Path {
11289 caminho: "../caixa-teia/*.lisp".into(),
11290 });
11291 let err = d.validate().unwrap_err();
11292 assert!(
11293 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11294 "got {err:?}",
11295 );
11296 }
11297
11298 #[test]
11299 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11300 // The positive-control pin: the gate targets only `*` /
11301 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11302 // The canonical relative POSIX path (`"../caixa-teia"`) and
11303 // a nested deeply-pathed variant with adjacent printable
11304 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11305 // to validate cleanly so the gate doesn't widen to a "no
11306 // printable punctuation anywhere" sweep that would defeat
11307 // the entire path-fonte author surface.
11308 let d = dep_with_fonte(DepSource::Path {
11309 caminho: "../caixa-teia/sub-dir.v2".into(),
11310 });
11311 d.validate().unwrap();
11312 }
11313
11314 #[test]
11315 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11316 // Cascade pin on the immediate-predecessor arm: a value
11317 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11318 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11319 // command-substitution + glob chain") routes through
11320 // `FonteCaminhoShellCommandSubstitution` not
11321 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11322 // injection vector is the load-bearing root-cause edit on
11323 // every probe-as-both value — same cascade discipline every
11324 // prior `:caminho` arm establishes.
11325 let d = dep_with_fonte(DepSource::Path {
11326 caminho: "../`whoami`/*".into(),
11327 });
11328 let err = d.validate().unwrap_err();
11329 assert!(
11330 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11331 "got {err:?}",
11332 );
11333 }
11334
11335 #[test]
11336 fn fonte_caminho_shell_background_fires_before_shell_glob() {
11337 // Cascade pin on the upstream shell-background arm: a value
11338 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11339 // canonical "I pasted a `cmd & ls /*` background + glob
11340 // chain" footgun) routes through `FonteCaminhoShellBackground`
11341 // not `FonteCaminhoShellGlob`. The background-launch tail is
11342 // the load-bearing root-cause edit on every probe-as-both
11343 // value.
11344 let d = dep_with_fonte(DepSource::Path {
11345 caminho: "../caixa-teia & ls /*".into(),
11346 });
11347 let err = d.validate().unwrap_err();
11348 assert!(
11349 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11350 "got {err:?}",
11351 );
11352 }
11353
11354 #[test]
11355 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11356 // Cascade pin on the upstream shell-semicolon arm: a value
11357 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11358 // canonical sequential-cleanup + glob paste idiom) routes
11359 // through `FonteCaminhoShellSemicolon` not
11360 // `FonteCaminhoShellGlob`. The sequential-command-separator
11361 // paste is the load-bearing root-cause edit on every
11362 // probe-as-both value.
11363 let d = dep_with_fonte(DepSource::Path {
11364 caminho: "../caixa-teia; rm *".into(),
11365 });
11366 let err = d.validate().unwrap_err();
11367 assert!(
11368 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11369 "got {err:?}",
11370 );
11371 }
11372
11373 #[test]
11374 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11375 // Cascade pin on the upstream shell-pipe arm: a value
11376 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11377 // canonical pipeline-to-glob paste idiom) routes through
11378 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11379 // pipeline-tail paste is the load-bearing root-cause edit
11380 // on every probe-as-both value.
11381 let d = dep_with_fonte(DepSource::Path {
11382 caminho: "../caixa-teia | ls *".into(),
11383 });
11384 let err = d.validate().unwrap_err();
11385 assert!(
11386 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11387 "got {err:?}",
11388 );
11389 }
11390
11391 #[test]
11392 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11393 // Cascade pin on the upstream shell-redirection arm: a value
11394 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11395 // canonical "I pasted a `cmd > log *` redirect-plus-glob
11396 // chain" footgun) routes through
11397 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11398 // The input/output redirection metachar carries the more
11399 // self-locating `byte` payload (it names which of `<` or `>`
11400 // triggered), so the prior arm wins on every probe-as-both
11401 // value.
11402 let d = dep_with_fonte(DepSource::Path {
11403 caminho: "../caixa-teia>log *".into(),
11404 });
11405 let err = d.validate().unwrap_err();
11406 assert!(
11407 matches!(
11408 err,
11409 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11410 ),
11411 "got {err:?}",
11412 );
11413 }
11414
11415 #[test]
11416 fn fonte_caminho_backslash_fires_before_shell_glob() {
11417 // Cascade pin on the upstream backslash arm: a value
11418 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11419 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11420 // expression" footgun) routes through
11421 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11422 // cross-host-OS-separator divergence is the load-bearing
11423 // axis on every probe-as-both value (an author who removes
11424 // the `\` is the root-cause edit; the `*` falls away in the
11425 // same edit since it's downstream of the Windows-shell
11426 // convention).
11427 let d = dep_with_fonte(DepSource::Path {
11428 caminho: "..\\caixa-teia\\*".into(),
11429 });
11430 let err = d.validate().unwrap_err();
11431 assert!(
11432 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11433 "got {err:?}",
11434 );
11435 }
11436
11437 #[test]
11438 fn fonte_caminho_control_char_fires_before_shell_glob() {
11439 // Cascade pin on the embedded-control-byte arm: a value
11440 // carrying both a control byte and `*` (`"../foo\n*"` — the
11441 // canonical paste-from-multiline-doc footgun where a
11442 // newline landed mid-caminho between two paste fragments)
11443 // routes through `FonteCaminhoControlChar` not
11444 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11445 // NUL-`CString::new`-fail diagnostic is the load-bearing
11446 // axis on every value that probes positive for both —
11447 // mirrors the cascade discipline on every prior arm.
11448 let d = dep_with_fonte(DepSource::Path {
11449 caminho: "../foo\n*".into(),
11450 });
11451 let err = d.validate().unwrap_err();
11452 assert!(
11453 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11454 "got {err:?}",
11455 );
11456 }
11457
11458 #[test]
11459 fn fonte_caminho_absolute_fires_before_shell_glob() {
11460 // Cascade pin on the load-bearing leading-byte arm: a
11461 // leading `/` value with embedded `*` (`"/etc/*"`) routes
11462 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11463 // — the host-layout-leak diagnostic is the load-bearing
11464 // axis, the glob byte is the secondary observation. Same
11465 // precedence logic as every prior leading-byte arm.
11466 let d = dep_with_fonte(DepSource::Path {
11467 caminho: "/etc/*".into(),
11468 });
11469 let err = d.validate().unwrap_err();
11470 assert!(
11471 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11472 "got {err:?}",
11473 );
11474 }
11475
11476 #[test]
11477 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11478 // Cascade pin on the immediate-successor arm: a value
11479 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11480 // canonical "I tab-completed a path that already had a
11481 // glob-expansion tail" footgun) routes through
11482 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11483 // The embedded shell-metachar is the more semantic-locating
11484 // axis (an author who removes the `*` typically also drops
11485 // the trailing separator since both are paste-from-shell
11486 // artifacts).
11487 let d = dep_with_fonte(DepSource::Path {
11488 caminho: "../foo*/".into(),
11489 });
11490 let err = d.validate().unwrap_err();
11491 assert!(
11492 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11493 "got {err:?}",
11494 );
11495 }
11496
11497 #[test]
11498 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11499 // Diagnostic-shape pin (peer with
11500 // `fonte_caminho_shell_redirection_diagnostic_*` on the
11501 // closest two-byte peer arm): the error's Display surfaces
11502 // the offending `:nome`, the offending `:caminho` verbatim,
11503 // the offending byte's hex / character form, and names the
11504 // shell-glob / pathname-expansion footgun explicitly so a
11505 // `feira lint` run can render the diagnostic without
11506 // re-parsing.
11507 let d = dep_with_fonte(DepSource::Path {
11508 caminho: "../caixa-teia/*.lisp".into(),
11509 });
11510 let rendered = d.validate().unwrap_err().to_string();
11511 assert!(
11512 rendered.contains("caixa-teia"),
11513 "diagnostic must name the offending dep: {rendered}",
11514 );
11515 assert!(
11516 rendered.contains("../caixa-teia/*.lisp"),
11517 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11518 );
11519 assert!(
11520 rendered.contains("0x2a"),
11521 "diagnostic must surface the offending byte hex: {rendered:?}",
11522 );
11523 assert!(
11524 rendered.contains("glob"),
11525 "diagnostic must name the shell-glob footgun: {rendered:?}",
11526 );
11527 assert!(
11528 rendered.contains("pathname-expansion"),
11529 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11530 );
11531 }
11532
11533 #[test]
11534 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11535 // The fail-before-pass-after pin for the canonical modern-Bourne
11536 // command-substitution paste footgun: an author copies a
11537 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11538 // `$(<cmd>)` expansion would land the current date as a
11539 // subdirectory name and silently passed every prior arm
11540 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11541 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11542 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11543 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11544 // sits mid-path). The lacre embedded the value verbatim, the
11545 // resolver folded it through `Path::join` looking for a literal
11546 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11547 // surfaced at resolve time with a non-self-locating `No such
11548 // file or directory` error. The new arm moves the rejection to
11549 // validate time and names the offending dep + caminho + byte
11550 // verbatim. The arm fires on the first `(` encountered (the
11551 // opening byte of `$(date)`).
11552 let d = dep_with_fonte(DepSource::Path {
11553 caminho: "../caixa-teia/$(date)/build".into(),
11554 });
11555 let err = d.validate().unwrap_err();
11556 let DepError::FonteCaminhoShellSubshellGrouping {
11557 nome,
11558 caminho,
11559 byte,
11560 } = err
11561 else {
11562 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11563 };
11564 assert_eq!(nome, "caixa-teia");
11565 assert_eq!(caminho, "../caixa-teia/$(date)/build");
11566 assert_eq!(byte, b'(');
11567 }
11568
11569 #[test]
11570 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11571 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11572 // the degenerate "I selected an unbalanced closing paren out of
11573 // a shell-history block" idiom that probes for the cascade's
11574 // last-byte handling on a value carrying only the closing byte).
11575 // Pinned separately from the open-paren shape so the gate's
11576 // contract is "any `(` or `)` anywhere", not single-byte
11577 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11578 // caminho_carrying_question_glob` shape on the immediate-
11579 // predecessor `FonteCaminhoShellGlob` arm.
11580 let d = dep_with_fonte(DepSource::Path {
11581 caminho: "../caixa-teia)".into(),
11582 });
11583 let err = d.validate().unwrap_err();
11584 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11585 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11586 };
11587 assert_eq!(byte, b')');
11588 }
11589
11590 #[test]
11591 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11592 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11593 // canonical "I selected a `(cd foo)` subshell-grouping prefix
11594 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11595 // Pinned separately from the embedded-byte shape so the gate
11596 // covers every position, not only mid-path.
11597 let d = dep_with_fonte(DepSource::Path {
11598 caminho: "(cd foo)/caixa-teia".into(),
11599 });
11600 let err = d.validate().unwrap_err();
11601 assert!(
11602 matches!(
11603 err,
11604 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11605 ),
11606 "got {err:?}",
11607 );
11608 }
11609
11610 #[test]
11611 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11612 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11613 // — the canonical "I copied a `(pwd)` working-directory-probe
11614 // subshell-grouping idiom every shell-history block carries"
11615 // footgun). The value carries no other cascade-preceding
11616 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11617 // `*` / `?`) so the arm fires on the first `(` encountered;
11618 // pinned so a future arm that tries to distinguish the
11619 // opening from the closing byte doesn't break the broader
11620 // contract. Mirrors the peer
11621 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11622 // backtick_pair` shape on the upstream `FonteCaminhoShell\
11623 // CommandSubstitution` arm.
11624 let d = dep_with_fonte(DepSource::Path {
11625 caminho: "../(pwd)/caixa-teia".into(),
11626 });
11627 let err = d.validate().unwrap_err();
11628 assert!(
11629 matches!(
11630 err,
11631 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11632 ),
11633 "got {err:?}",
11634 );
11635 }
11636
11637 #[test]
11638 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11639 // The positive-control pin: the gate targets only `(` / `)`,
11640 // never adjacent printable ASCII or POSIX-valid bytes. The
11641 // canonical relative POSIX path (`"../caixa-teia"`) and a
11642 // nested deeply-pathed variant with adjacent printable
11643 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11644 // validate cleanly so the gate doesn't widen to a "no printable
11645 // punctuation anywhere" sweep that would defeat the entire
11646 // path-fonte author surface.
11647 let d = dep_with_fonte(DepSource::Path {
11648 caminho: "../caixa-teia/sub-dir.v2".into(),
11649 });
11650 d.validate().unwrap();
11651 }
11652
11653 #[test]
11654 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11655 // Cascade pin on the immediate-predecessor arm: a value
11656 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11657 // canonical "I pasted a glob expansion followed by a
11658 // subshell-grouping tail" footgun) routes through
11659 // `FonteCaminhoShellGlob` not
11660 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11661 // shape is the more common shell-history paste idiom on every
11662 // probe-as-both value — same cascade discipline every prior
11663 // `:caminho` arm establishes.
11664 let d = dep_with_fonte(DepSource::Path {
11665 caminho: "../caixa-teia/*(date)".into(),
11666 });
11667 let err = d.validate().unwrap_err();
11668 assert!(
11669 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11670 "got {err:?}",
11671 );
11672 }
11673
11674 #[test]
11675 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11676 // Cascade pin on the upstream shell-command-substitution arm: a
11677 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11678 // — the canonical "I pasted a legacy-backtick + modern-paren
11679 // command-substitution chain" footgun) routes through
11680 // `FonteCaminhoShellCommandSubstitution` not
11681 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11682 // command-injection vector is the load-bearing root-cause edit
11683 // on every probe-as-both value.
11684 let d = dep_with_fonte(DepSource::Path {
11685 caminho: "../`whoami`/$(date)".into(),
11686 });
11687 let err = d.validate().unwrap_err();
11688 assert!(
11689 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11690 "got {err:?}",
11691 );
11692 }
11693
11694 #[test]
11695 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11696 // Cascade pin on the upstream shell-background arm: a value
11697 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11698 // the canonical "I pasted a `cmd & (cd foo)` background-launch
11699 // + subshell-grouping chain" footgun) routes through
11700 // `FonteCaminhoShellBackground` not
11701 // `FonteCaminhoShellSubshellGrouping`. The background-launch
11702 // tail is the load-bearing root-cause edit on every probe-as-
11703 // both value.
11704 let d = dep_with_fonte(DepSource::Path {
11705 caminho: "../caixa-teia & (cd foo)".into(),
11706 });
11707 let err = d.validate().unwrap_err();
11708 assert!(
11709 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11710 "got {err:?}",
11711 );
11712 }
11713
11714 #[test]
11715 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11716 // Cascade pin on the upstream shell-semicolon arm: a value
11717 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11718 // the canonical sequential-cleanup + subshell-grouping paste
11719 // idiom) routes through `FonteCaminhoShellSemicolon` not
11720 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11721 // separator paste is the load-bearing root-cause edit on
11722 // every probe-as-both value.
11723 let d = dep_with_fonte(DepSource::Path {
11724 caminho: "../caixa-teia; (cd foo)".into(),
11725 });
11726 let err = d.validate().unwrap_err();
11727 assert!(
11728 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11729 "got {err:?}",
11730 );
11731 }
11732
11733 #[test]
11734 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11735 // Cascade pin on the upstream shell-pipe arm: a value carrying
11736 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11737 // canonical pipeline-to-subshell-grouping paste idiom) routes
11738 // through `FonteCaminhoShellPipe` not
11739 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11740 // is the load-bearing root-cause edit on every probe-as-both
11741 // value.
11742 let d = dep_with_fonte(DepSource::Path {
11743 caminho: "../caixa-teia | (tee log)".into(),
11744 });
11745 let err = d.validate().unwrap_err();
11746 assert!(
11747 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11748 "got {err:?}",
11749 );
11750 }
11751
11752 #[test]
11753 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11754 // Cascade pin on the upstream shell-redirection arm: a value
11755 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11756 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11757 // plus-subshell-grouping chain" footgun) routes through
11758 // `FonteCaminhoShellRedirection` not
11759 // `FonteCaminhoShellSubshellGrouping`. The input/output
11760 // redirection metachar carries the more self-locating `byte`
11761 // payload (it names which of `<` or `>` triggered), so the
11762 // prior arm wins on every probe-as-both value.
11763 let d = dep_with_fonte(DepSource::Path {
11764 caminho: "../caixa-teia>log (cd foo)".into(),
11765 });
11766 let err = d.validate().unwrap_err();
11767 assert!(
11768 matches!(
11769 err,
11770 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11771 ),
11772 "got {err:?}",
11773 );
11774 }
11775
11776 #[test]
11777 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11778 // Cascade pin on the upstream backslash arm: a value carrying
11779 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11780 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11781 // through `FonteCaminhoBackslash` not
11782 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11783 // separator divergence is the load-bearing axis on every
11784 // probe-as-both value (an author who removes the `\` is the
11785 // root-cause edit; the `(` falls away in the same edit since
11786 // it's downstream of the Windows-shell convention).
11787 let d = dep_with_fonte(DepSource::Path {
11788 caminho: "..\\caixa-teia\\(cd foo)".into(),
11789 });
11790 let err = d.validate().unwrap_err();
11791 assert!(
11792 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11793 "got {err:?}",
11794 );
11795 }
11796
11797 #[test]
11798 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11799 // Cascade pin on the embedded-control-byte arm: a value
11800 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11801 // the canonical paste-from-multiline-doc footgun where a
11802 // newline landed mid-caminho between two paste fragments)
11803 // routes through `FonteCaminhoControlChar` not
11804 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11805 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11806 // load-bearing axis on every value that probes positive for
11807 // both — mirrors the cascade discipline on every prior arm.
11808 let d = dep_with_fonte(DepSource::Path {
11809 caminho: "../foo\n(cd bar)".into(),
11810 });
11811 let err = d.validate().unwrap_err();
11812 assert!(
11813 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11814 "got {err:?}",
11815 );
11816 }
11817
11818 #[test]
11819 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11820 // Cascade pin on the load-bearing leading-byte arm: a leading
11821 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11822 // through `FonteCaminhoAbsolute` not
11823 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11824 // diagnostic is the load-bearing axis, the subshell-grouping
11825 // byte is the secondary observation. Same precedence logic as
11826 // every prior leading-byte arm.
11827 let d = dep_with_fonte(DepSource::Path {
11828 caminho: "/etc/(cd foo)".into(),
11829 });
11830 let err = d.validate().unwrap_err();
11831 assert!(
11832 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11833 "got {err:?}",
11834 );
11835 }
11836
11837 #[test]
11838 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11839 // Cascade pin on the upstream leading-`$` var-expansion arm: a
11840 // value carrying both a leading `$` and a `(` (`"$(date)/\
11841 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11842 // command-substitution at the head of a sibling-workspace
11843 // path" footgun) routes through `FonteCaminhoVarExpansion` not
11844 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11845 // shell-variable-expansion is the more self-locating diagnostic
11846 // on values that probe as both — same load-bearing-leading-
11847 // byte cascade discipline every prior `:caminho` arm
11848 // establishes. Closing both halves of `$(<cmd>)` structurally
11849 // (leading `$` here, trailing `)` on the new arm) excludes the
11850 // entire modern Bourne command-substitution surface from the
11851 // typed `:caminho` accepted set; the cascade preserves the
11852 // narrower leading-byte diagnostic on values that probe both
11853 // halves at the canonical leading position.
11854 let d = dep_with_fonte(DepSource::Path {
11855 caminho: "$(date)/caixa-teia".into(),
11856 });
11857 let err = d.validate().unwrap_err();
11858 assert!(
11859 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11860 "got {err:?}",
11861 );
11862 }
11863
11864 #[test]
11865 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11866 // Cascade pin on the immediate-successor arm: a value carrying
11867 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11868 // "I tab-completed a path that already had a subshell-grouping
11869 // expansion tail" footgun) routes through
11870 // `FonteCaminhoShellSubshellGrouping` not
11871 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11872 // the more semantic-locating axis (an author who removes the
11873 // `(` typically also drops the trailing separator since both
11874 // are paste-from-shell artifacts).
11875 let d = dep_with_fonte(DepSource::Path {
11876 caminho: "../(cd foo)/".into(),
11877 });
11878 let err = d.validate().unwrap_err();
11879 assert!(
11880 matches!(
11881 err,
11882 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11883 ),
11884 "got {err:?}",
11885 );
11886 }
11887
11888 #[test]
11889 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11890 // Diagnostic-shape pin (peer with
11891 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11892 // on the closest two-byte peer arm): the error's Display
11893 // surfaces the offending `:nome`, the offending `:caminho`
11894 // verbatim, the offending byte's hex / character form, and
11895 // names the shell-subshell-grouping footgun explicitly so a
11896 // `feira lint` run can render the diagnostic without re-
11897 // parsing.
11898 let d = dep_with_fonte(DepSource::Path {
11899 caminho: "../caixa-teia/$(date)/build".into(),
11900 });
11901 let rendered = d.validate().unwrap_err().to_string();
11902 assert!(
11903 rendered.contains("caixa-teia"),
11904 "diagnostic must name the offending dep: {rendered}",
11905 );
11906 assert!(
11907 rendered.contains("../caixa-teia/$(date)/build"),
11908 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11909 );
11910 assert!(
11911 rendered.contains("0x28"),
11912 "diagnostic must surface the offending byte hex: {rendered:?}",
11913 );
11914 assert!(
11915 rendered.contains("subshell-grouping"),
11916 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11917 );
11918 assert!(
11919 rendered.contains("command-substitution"),
11920 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11921 {rendered:?}",
11922 );
11923 }
11924
11925 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11926 //
11927 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11928 // `)`) byte-pair arm: the same per-byte cascade with the same
11929 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11930 // `}` brace-expansion / URI-Template placeholder axis. The peer
11931 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11932 // byte pair on the sibling `:fonte :repo` axis under the same
11933 // banner.
11934
11935 #[test]
11936 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11937 // The fail-before-pass-after pin for the canonical paste-from-
11938 // shell-history brace-expansion footgun: an author copies a
11939 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11940 // liner whose `{a,b}` brace expansion fans across two siblings
11941 // and silently passed every prior arm (`Path::is_absolute`
11942 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11943 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11944 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11945 // `FonteCaminhoVarExpansion` arm doesn't fire because the
11946 // value starts with `..` not `$`). The lacre embedded the
11947 // value verbatim, the resolver folded it through `Path::join`
11948 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11949 // subdirectory, and the failure surfaced at resolve time with
11950 // a non-self-locating `No such file or directory` error. The
11951 // new arm moves the rejection to validate time and names the
11952 // offending dep + caminho + byte verbatim. The arm fires on
11953 // the first `{` encountered.
11954 let d = dep_with_fonte(DepSource::Path {
11955 caminho: "../{caixa-teia,caixa-helm}/build".into(),
11956 });
11957 let err = d.validate().unwrap_err();
11958 let DepError::FonteCaminhoShellBraceExpansion {
11959 nome,
11960 caminho,
11961 byte,
11962 } = err
11963 else {
11964 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11965 };
11966 assert_eq!(nome, "caixa-teia");
11967 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11968 assert_eq!(byte, b'{');
11969 }
11970
11971 #[test]
11972 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11973 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11974 // the degenerate "I selected an unbalanced closing brace out
11975 // of a shell-history block" idiom that probes for the
11976 // cascade's last-byte handling on a value carrying only the
11977 // closing byte). Pinned separately from the open-brace shape
11978 // so the gate's contract is "any `{` or `}` anywhere", not
11979 // single-byte coverage. Mirrors the peer
11980 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11981 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11982 // arm.
11983 let d = dep_with_fonte(DepSource::Path {
11984 caminho: "../caixa-teia}".into(),
11985 });
11986 let err = d.validate().unwrap_err();
11987 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11988 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11989 };
11990 assert_eq!(byte, b'}');
11991 }
11992
11993 #[test]
11994 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11995 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11996 // — the canonical "I selected a `{a,b}` brace-expansion prefix
11997 // out of a shell-history one-liner" idiom). Pinned separately
11998 // from the embedded-byte shape so the gate covers every
11999 // position, not only mid-path.
12000 let d = dep_with_fonte(DepSource::Path {
12001 caminho: "{caixa-teia,caixa-helm}/build".into(),
12002 });
12003 let err = d.validate().unwrap_err();
12004 assert!(
12005 matches!(
12006 err,
12007 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12008 ),
12009 "got {err:?}",
12010 );
12011 }
12012
12013 #[test]
12014 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12015 // The canonical URI-Template / Mustache / Helm doubled-brace
12016 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12017 // "I copied a `https://github.com/{{org}}/caixa-teia` README
12018 // quick-start / OpenAPI spec / Helm chart `home:` template
12019 // and forgot to substitute the placeholder" footgun). The arm
12020 // fires on the first `{` encountered; pinned so the gate's
12021 // coverage extends from the bare-brace shell-history shape to
12022 // the doubled-brace URI-Template / templating-engine shape.
12023 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12024 // sibling `:fonte :repo` axis.
12025 let d = dep_with_fonte(DepSource::Path {
12026 caminho: "../{{org}}/caixa-teia".into(),
12027 });
12028 let err = d.validate().unwrap_err();
12029 assert!(
12030 matches!(
12031 err,
12032 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12033 ),
12034 "got {err:?}",
12035 );
12036 }
12037
12038 #[test]
12039 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12040 // The canonical bash brace-range-expansion shape (`"../caixa-
12041 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12042 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12043 // sequence-range form to the `{a,b,c}` comma-separated form).
12044 // The arm fires on the first `{` encountered; pinned so the
12045 // gate's coverage extends from the comma-separated form to
12046 // the integer-range form.
12047 let d = dep_with_fonte(DepSource::Path {
12048 caminho: "../caixa-v{1..10}".into(),
12049 });
12050 let err = d.validate().unwrap_err();
12051 assert!(
12052 matches!(
12053 err,
12054 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12055 ),
12056 "got {err:?}",
12057 );
12058 }
12059
12060 #[test]
12061 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12062 // The positive-control pin: the gate targets only `{` / `}`,
12063 // never adjacent printable ASCII or POSIX-valid bytes. The
12064 // canonical relative POSIX path (`"../caixa-teia"`) and a
12065 // nested deeply-pathed variant with adjacent printable
12066 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12067 // validate cleanly so the gate doesn't widen to a "no
12068 // printable punctuation anywhere" sweep that would defeat
12069 // the entire path-fonte author surface. Peer with
12070 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12071 // on the immediate-predecessor arm.
12072 let d = dep_with_fonte(DepSource::Path {
12073 caminho: "../caixa-teia/sub-dir.v2".into(),
12074 });
12075 d.validate().unwrap();
12076 }
12077
12078 #[test]
12079 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12080 // Cascade pin on the immediate-predecessor arm: a value
12081 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12082 // canonical "I pasted a subshell-grouping followed by a
12083 // brace-expansion tail" footgun) routes through
12084 // `FonteCaminhoShellSubshellGrouping` not
12085 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12086 // shape is the more semantic-locating axis on every probe-
12087 // as-both value because it closes both halves of the modern
12088 // Bourne `$(<cmd>)` command-substitution surface — same
12089 // cascade discipline every prior `:caminho` arm establishes.
12090 let d = dep_with_fonte(DepSource::Path {
12091 caminho: "../(cd foo)/{a,b}".into(),
12092 });
12093 let err = d.validate().unwrap_err();
12094 assert!(
12095 matches!(
12096 err,
12097 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12098 ),
12099 "got {err:?}",
12100 );
12101 }
12102
12103 #[test]
12104 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12105 // Cascade pin on the upstream shell-glob arm: a value carrying
12106 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12107 // "I pasted a glob expansion followed by a brace-expansion
12108 // tail" footgun) routes through `FonteCaminhoShellGlob` not
12109 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12110 // shape is the load-bearing root-cause edit on every
12111 // probe-as-both value.
12112 let d = dep_with_fonte(DepSource::Path {
12113 caminho: "../caixa-teia/*{a,b}".into(),
12114 });
12115 let err = d.validate().unwrap_err();
12116 assert!(
12117 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12118 "got {err:?}",
12119 );
12120 }
12121
12122 #[test]
12123 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12124 // Cascade pin on the upstream shell-command-substitution arm:
12125 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12126 // — the canonical "I pasted a legacy-backtick command-
12127 // substitution followed by a brace-expansion fan-out" footgun)
12128 // routes through `FonteCaminhoShellCommandSubstitution` not
12129 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12130 // command-injection vector is the load-bearing root-cause
12131 // edit on every probe-as-both value.
12132 let d = dep_with_fonte(DepSource::Path {
12133 caminho: "../`whoami`/{a,b}".into(),
12134 });
12135 let err = d.validate().unwrap_err();
12136 assert!(
12137 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12138 "got {err:?}",
12139 );
12140 }
12141
12142 #[test]
12143 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12144 // Cascade pin on the upstream shell-background arm: a value
12145 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12146 // canonical "I pasted a `cmd & {fork-fan}` background-launch
12147 // + brace-expansion chain" footgun) routes through
12148 // `FonteCaminhoShellBackground` not
12149 // `FonteCaminhoShellBraceExpansion`. The background-launch
12150 // tail is the load-bearing root-cause edit on every
12151 // probe-as-both value.
12152 let d = dep_with_fonte(DepSource::Path {
12153 caminho: "../caixa-teia & {a,b}".into(),
12154 });
12155 let err = d.validate().unwrap_err();
12156 assert!(
12157 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12158 "got {err:?}",
12159 );
12160 }
12161
12162 #[test]
12163 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12164 // Cascade pin on the upstream shell-semicolon arm: a value
12165 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12166 // canonical sequential-cleanup + brace-expansion paste
12167 // idiom) routes through `FonteCaminhoShellSemicolon` not
12168 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12169 // separator paste is the load-bearing root-cause edit on
12170 // every probe-as-both value.
12171 let d = dep_with_fonte(DepSource::Path {
12172 caminho: "../caixa-teia; {a,b}".into(),
12173 });
12174 let err = d.validate().unwrap_err();
12175 assert!(
12176 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12177 "got {err:?}",
12178 );
12179 }
12180
12181 #[test]
12182 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12183 // Cascade pin on the upstream shell-pipe arm: a value
12184 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12185 // — the canonical pipeline-to-brace-expansion paste idiom)
12186 // routes through `FonteCaminhoShellPipe` not
12187 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12188 // is the load-bearing root-cause edit on every probe-as-
12189 // both value.
12190 let d = dep_with_fonte(DepSource::Path {
12191 caminho: "../caixa-teia | {tee,cat}".into(),
12192 });
12193 let err = d.validate().unwrap_err();
12194 assert!(
12195 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12196 "got {err:?}",
12197 );
12198 }
12199
12200 #[test]
12201 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12202 // Cascade pin on the upstream shell-redirection arm: a value
12203 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12204 // the canonical "I pasted a `cmd > log {a,b}` redirect-
12205 // plus-brace-expansion chain" footgun) routes through
12206 // `FonteCaminhoShellRedirection` not
12207 // `FonteCaminhoShellBraceExpansion`. The input/output
12208 // redirection metachar carries the more self-locating
12209 // `byte` payload, so the prior arm wins on every probe-
12210 // as-both value.
12211 let d = dep_with_fonte(DepSource::Path {
12212 caminho: "../caixa-teia>log {a,b}".into(),
12213 });
12214 let err = d.validate().unwrap_err();
12215 assert!(
12216 matches!(
12217 err,
12218 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12219 ),
12220 "got {err:?}",
12221 );
12222 }
12223
12224 #[test]
12225 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12226 // Cascade pin on the upstream backslash arm: a value
12227 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12228 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12229 // chain") routes through `FonteCaminhoBackslash` not
12230 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12231 // separator divergence is the load-bearing axis on every
12232 // probe-as-both value.
12233 let d = dep_with_fonte(DepSource::Path {
12234 caminho: "..\\caixa-teia\\{a,b}".into(),
12235 });
12236 let err = d.validate().unwrap_err();
12237 assert!(
12238 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12239 "got {err:?}",
12240 );
12241 }
12242
12243 #[test]
12244 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12245 // Cascade pin on the embedded-control-byte arm: a value
12246 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12247 // the canonical paste-from-multiline-doc footgun where a
12248 // newline landed mid-caminho between two paste fragments)
12249 // routes through `FonteCaminhoControlChar` not
12250 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12251 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12252 // load-bearing axis on every value that probes positive for
12253 // both — mirrors the cascade discipline on every prior arm.
12254 let d = dep_with_fonte(DepSource::Path {
12255 caminho: "../foo\n{a,b}".into(),
12256 });
12257 let err = d.validate().unwrap_err();
12258 assert!(
12259 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12260 "got {err:?}",
12261 );
12262 }
12263
12264 #[test]
12265 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12266 // Cascade pin on the load-bearing leading-byte arm: a
12267 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12268 // routes through `FonteCaminhoAbsolute` not
12269 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12270 // diagnostic is the load-bearing axis, the brace-expansion
12271 // byte is the secondary observation. Same precedence logic
12272 // as every prior leading-byte arm.
12273 let d = dep_with_fonte(DepSource::Path {
12274 caminho: "/etc/{a,b}".into(),
12275 });
12276 let err = d.validate().unwrap_err();
12277 assert!(
12278 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12279 "got {err:?}",
12280 );
12281 }
12282
12283 #[test]
12284 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12285 // Cascade pin on the upstream leading-`$` var-expansion
12286 // arm: a value carrying both a leading `$` and a `{`
12287 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12288 // `${ORG}` shell-variable + curly-brace expansion at the
12289 // head of a sibling-workspace path" footgun) routes through
12290 // `FonteCaminhoVarExpansion` not
12291 // `FonteCaminhoShellBraceExpansion`. The leading-byte
12292 // shell-variable-expansion is the more self-locating
12293 // diagnostic on values that probe as both — same
12294 // load-bearing-leading-byte cascade discipline every prior
12295 // `:caminho` arm establishes.
12296 let d = dep_with_fonte(DepSource::Path {
12297 caminho: "${ORG}/caixa-teia".into(),
12298 });
12299 let err = d.validate().unwrap_err();
12300 assert!(
12301 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12302 "got {err:?}",
12303 );
12304 }
12305
12306 #[test]
12307 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12308 // Cascade pin on the immediate-successor arm: a value
12309 // carrying both `{` and a trailing `/`
12310 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12311 // tab-completed a path that already had a brace-expansion
12312 // expansion tail" footgun) routes through
12313 // `FonteCaminhoShellBraceExpansion` not
12314 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12315 // is the more semantic-locating axis (an author who removes
12316 // the `{` typically also drops the trailing separator since
12317 // both are paste-from-shell artifacts).
12318 let d = dep_with_fonte(DepSource::Path {
12319 caminho: "../{caixa-teia,caixa-helm}/".into(),
12320 });
12321 let err = d.validate().unwrap_err();
12322 assert!(
12323 matches!(
12324 err,
12325 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12326 ),
12327 "got {err:?}",
12328 );
12329 }
12330
12331 #[test]
12332 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12333 // Diagnostic-shape pin (peer with
12334 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12335 // on the closest two-byte peer arm): the error's Display
12336 // surfaces the offending `:nome`, the offending `:caminho`
12337 // verbatim, the offending byte's hex / character form, and
12338 // names the shell-brace-expansion / URI-Template footgun
12339 // explicitly so a `feira lint` run can render the diagnostic
12340 // without re-parsing.
12341 let d = dep_with_fonte(DepSource::Path {
12342 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12343 });
12344 let rendered = d.validate().unwrap_err().to_string();
12345 assert!(
12346 rendered.contains("caixa-teia"),
12347 "diagnostic must name the offending dep: {rendered}",
12348 );
12349 assert!(
12350 rendered.contains("../{caixa-teia,caixa-helm}/build"),
12351 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12352 );
12353 assert!(
12354 rendered.contains("0x7b"),
12355 "diagnostic must surface the offending byte hex: {rendered:?}",
12356 );
12357 assert!(
12358 rendered.contains("brace-expansion"),
12359 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12360 );
12361 assert!(
12362 rendered.contains("URI Template"),
12363 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12364 {rendered:?}",
12365 );
12366 }
12367
12368 #[test]
12369 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12370 // The canonical paste-from-shell-history bracket-glob /
12371 // character-class footgun: an author copies a
12372 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12373 // `[a-z]` POSIX glob character-class matches every lowercase-
12374 // ASCII-suffix sibling caixa directory and silently passed
12375 // every prior arm (`Path::is_absolute` false on `..`, no
12376 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12377 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12378 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12379 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12380 // value starts with `..` not `$`). The lacre embedded the
12381 // value verbatim, the resolver folded it through
12382 // `Path::join` looking for a literal `./../caixa-[a-z]/
12383 // build` subdirectory, and the failure surfaced at resolve
12384 // time with a non-self-locating `No such file or directory`
12385 // error. The new arm moves the rejection to validate time
12386 // and names the offending dep + caminho + byte verbatim.
12387 // The arm fires on the first `[` encountered.
12388 let d = dep_with_fonte(DepSource::Path {
12389 caminho: "../caixa-[a-z]/build".into(),
12390 });
12391 let err = d.validate().unwrap_err();
12392 let DepError::FonteCaminhoShellBracketExpansion {
12393 nome,
12394 caminho,
12395 byte,
12396 } = err
12397 else {
12398 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12399 };
12400 assert_eq!(nome, "caixa-teia");
12401 assert_eq!(caminho, "../caixa-[a-z]/build");
12402 assert_eq!(byte, b'[');
12403 }
12404
12405 #[test]
12406 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12407 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12408 // — the degenerate "I selected an unbalanced closing bracket
12409 // out of a glob character-class block" idiom that probes for
12410 // the cascade's last-byte handling on a value carrying only
12411 // the closing byte). Pinned separately from the open-bracket
12412 // shape so the gate's contract is "any `[` or `]` anywhere",
12413 // not single-byte coverage. Mirrors the peer
12414 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12415 // shape on the immediate-predecessor
12416 // `FonteCaminhoShellBraceExpansion` arm.
12417 let d = dep_with_fonte(DepSource::Path {
12418 caminho: "../caixa-teia]".into(),
12419 });
12420 let err = d.validate().unwrap_err();
12421 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12422 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12423 };
12424 assert_eq!(byte, b']');
12425 }
12426
12427 #[test]
12428 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12429 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12430 // canonical "I selected a `[caixa-teia]` TOML-table-header /
12431 // glob-character-class prefix out of an aligned config /
12432 // shell-history one-liner" idiom). Pinned separately from
12433 // the embedded-byte shape so the gate covers every position,
12434 // not only mid-path.
12435 let d = dep_with_fonte(DepSource::Path {
12436 caminho: "[caixa-teia]/build".into(),
12437 });
12438 let err = d.validate().unwrap_err();
12439 assert!(
12440 matches!(
12441 err,
12442 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12443 ),
12444 "got {err:?}",
12445 );
12446 }
12447
12448 #[test]
12449 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12450 // The canonical TOML inline-array / YAML flow-sequence
12451 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12452 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12453 // inline-array out of a sibling-Cargo manifest" cross-idiom
12454 // leak; the symmetric YAML flow-sequence form `paths: [/a,
12455 // /b]` paste-from-values.yaml shape carries the same
12456 // bracket pair). The arm fires on the first `[` encountered;
12457 // pinned so the gate's coverage extends from the bare-
12458 // bracket glob-character-class shape to the TOML / YAML /
12459 // JSON array-literal shape.
12460 let d = dep_with_fonte(DepSource::Path {
12461 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12462 });
12463 let err = d.validate().unwrap_err();
12464 assert!(
12465 matches!(
12466 err,
12467 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12468 ),
12469 "got {err:?}",
12470 );
12471 }
12472
12473 #[test]
12474 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12475 // The canonical POSIX `test` / `[` builtin command paste
12476 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12477 // script conditional every paste-from-shell-script idiom
12478 // carries; bash's `[[ <expr> ]]` extended-test grammar
12479 // would surface the same byte pair). The arm fires on the
12480 // first `[` encountered; pinned so the gate's coverage
12481 // extends from the embedded-glob-character-class shape to
12482 // the leading-`test`-builtin / extended-test form.
12483 let d = dep_with_fonte(DepSource::Path {
12484 caminho: "../[ -d caixa-teia ]".into(),
12485 });
12486 let err = d.validate().unwrap_err();
12487 assert!(
12488 matches!(
12489 err,
12490 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12491 ),
12492 "got {err:?}",
12493 );
12494 }
12495
12496 #[test]
12497 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12498 // The positive-control pin: the gate targets only `[` /
12499 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12500 // The canonical relative POSIX path (`"../caixa-teia"`) and
12501 // a nested deeply-pathed variant with adjacent printable
12502 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12503 // to validate cleanly so the gate doesn't widen to a "no
12504 // printable punctuation anywhere" sweep that would defeat
12505 // the entire path-fonte author surface. Peer with
12506 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12507 // on the immediate-predecessor arm.
12508 let d = dep_with_fonte(DepSource::Path {
12509 caminho: "../caixa-teia/sub-dir.v2".into(),
12510 });
12511 d.validate().unwrap();
12512 }
12513
12514 #[test]
12515 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12516 // Cascade pin on the immediate-predecessor arm: a value
12517 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12518 // canonical "I pasted a brace-expansion fan followed by a
12519 // glob-character-class tail" footgun) routes through
12520 // `FonteCaminhoShellBraceExpansion` not
12521 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12522 // fan is the load-bearing root-cause edit on every
12523 // probe-as-both value because the bracket-class tail
12524 // typically rides on a prior brace-expansion expansion;
12525 // same cascade discipline every prior `:caminho` arm
12526 // establishes.
12527 let d = dep_with_fonte(DepSource::Path {
12528 caminho: "../{a,b}[ch]".into(),
12529 });
12530 let err = d.validate().unwrap_err();
12531 assert!(
12532 matches!(
12533 err,
12534 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12535 ),
12536 "got {err:?}",
12537 );
12538 }
12539
12540 #[test]
12541 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12542 // Cascade pin on the upstream shell-subshell-grouping arm:
12543 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12544 // the canonical "I pasted a subshell-grouping followed by
12545 // a glob-character-class tail" footgun) routes through
12546 // `FonteCaminhoShellSubshellGrouping` not
12547 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12548 // `$(<cmd>)` command-substitution boundary is the load-
12549 // bearing axis on every probe-as-both value.
12550 let d = dep_with_fonte(DepSource::Path {
12551 caminho: "../(cd foo)/[ch]".into(),
12552 });
12553 let err = d.validate().unwrap_err();
12554 assert!(
12555 matches!(
12556 err,
12557 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12558 ),
12559 "got {err:?}",
12560 );
12561 }
12562
12563 #[test]
12564 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12565 // Cascade pin on the upstream shell-glob arm: a value
12566 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12567 // canonical "I pasted a `*.[ch]` C-source-file glob whose
12568 // unbounded `*` precedes the bracket character-class"
12569 // footgun) routes through `FonteCaminhoShellGlob` not
12570 // `FonteCaminhoShellBracketExpansion`. The unbounded
12571 // pathname-expansion sentinel is the load-bearing root-
12572 // cause edit on every probe-as-both value — the unbounded
12573 // `*` carries the more aggressive expansion vector than
12574 // the bounded `[ch]` class, so the prior arm wins.
12575 let d = dep_with_fonte(DepSource::Path {
12576 caminho: "../caixa-teia/*[ch]".into(),
12577 });
12578 let err = d.validate().unwrap_err();
12579 assert!(
12580 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12581 "got {err:?}",
12582 );
12583 }
12584
12585 #[test]
12586 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12587 // Cascade pin on the upstream shell-command-substitution
12588 // arm: a value carrying both a backtick and `[`
12589 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12590 // legacy-backtick command-substitution followed by a
12591 // glob-character-class tail" footgun) routes through
12592 // `FonteCaminhoShellCommandSubstitution` not
12593 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12594 // command-injection vector is the load-bearing root-cause
12595 // edit on every probe-as-both value.
12596 let d = dep_with_fonte(DepSource::Path {
12597 caminho: "../`whoami`/[ch]".into(),
12598 });
12599 let err = d.validate().unwrap_err();
12600 assert!(
12601 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12602 "got {err:?}",
12603 );
12604 }
12605
12606 #[test]
12607 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12608 // Cascade pin on the upstream shell-background arm: a
12609 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12610 // — the canonical "I pasted a `cmd & [glob]` background-
12611 // launch + bracket-class chain" footgun) routes through
12612 // `FonteCaminhoShellBackground` not
12613 // `FonteCaminhoShellBracketExpansion`. The background-
12614 // launch tail is the load-bearing root-cause edit on
12615 // every probe-as-both value.
12616 let d = dep_with_fonte(DepSource::Path {
12617 caminho: "../caixa-teia & [ch]".into(),
12618 });
12619 let err = d.validate().unwrap_err();
12620 assert!(
12621 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12622 "got {err:?}",
12623 );
12624 }
12625
12626 #[test]
12627 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12628 // Cascade pin on the upstream shell-semicolon arm: a value
12629 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12630 // canonical sequential-cleanup + bracket-class paste
12631 // idiom) routes through `FonteCaminhoShellSemicolon` not
12632 // `FonteCaminhoShellBracketExpansion`. The sequential-
12633 // command-separator paste is the load-bearing root-cause
12634 // edit on every probe-as-both value.
12635 let d = dep_with_fonte(DepSource::Path {
12636 caminho: "../caixa-teia; [ch]".into(),
12637 });
12638 let err = d.validate().unwrap_err();
12639 assert!(
12640 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12641 "got {err:?}",
12642 );
12643 }
12644
12645 #[test]
12646 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12647 // Cascade pin on the upstream shell-pipe arm: a value
12648 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12649 // the canonical pipeline-to-bracket-class paste idiom)
12650 // routes through `FonteCaminhoShellPipe` not
12651 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12652 // paste is the load-bearing root-cause edit on every
12653 // probe-as-both value.
12654 let d = dep_with_fonte(DepSource::Path {
12655 caminho: "../caixa-teia | [tee]".into(),
12656 });
12657 let err = d.validate().unwrap_err();
12658 assert!(
12659 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12660 "got {err:?}",
12661 );
12662 }
12663
12664 #[test]
12665 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12666 // Cascade pin on the upstream shell-redirection arm: a
12667 // value carrying both `>` and `[` (`"../caixa-teia>log
12668 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12669 // redirect-plus-bracket chain" footgun) routes through
12670 // `FonteCaminhoShellRedirection` not
12671 // `FonteCaminhoShellBracketExpansion`. The input/output
12672 // redirection metachar carries the more self-locating
12673 // `byte` payload, so the prior arm wins on every
12674 // probe-as-both value.
12675 let d = dep_with_fonte(DepSource::Path {
12676 caminho: "../caixa-teia>log [ch]".into(),
12677 });
12678 let err = d.validate().unwrap_err();
12679 assert!(
12680 matches!(
12681 err,
12682 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12683 ),
12684 "got {err:?}",
12685 );
12686 }
12687
12688 #[test]
12689 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12690 // Cascade pin on the upstream backslash arm: a value
12691 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12692 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12693 // chain") routes through `FonteCaminhoBackslash` not
12694 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12695 // separator divergence is the load-bearing axis on every
12696 // probe-as-both value.
12697 let d = dep_with_fonte(DepSource::Path {
12698 caminho: "..\\caixa-teia\\[ch]".into(),
12699 });
12700 let err = d.validate().unwrap_err();
12701 assert!(
12702 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12703 "got {err:?}",
12704 );
12705 }
12706
12707 #[test]
12708 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12709 // Cascade pin on the embedded-control-byte arm: a value
12710 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12711 // the canonical paste-from-multiline-doc footgun where a
12712 // newline landed mid-caminho between two paste fragments)
12713 // routes through `FonteCaminhoControlChar` not
12714 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12715 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12716 // the load-bearing axis on every value that probes
12717 // positive for both — mirrors the cascade discipline on
12718 // every prior arm.
12719 let d = dep_with_fonte(DepSource::Path {
12720 caminho: "../foo\n[ch]".into(),
12721 });
12722 let err = d.validate().unwrap_err();
12723 assert!(
12724 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12725 "got {err:?}",
12726 );
12727 }
12728
12729 #[test]
12730 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12731 // Cascade pin on the load-bearing leading-byte arm: a
12732 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12733 // routes through `FonteCaminhoAbsolute` not
12734 // `FonteCaminhoShellBracketExpansion` — the host-layout-
12735 // leak diagnostic is the load-bearing axis, the bracket-
12736 // expansion byte is the secondary observation. Same
12737 // precedence logic as every prior leading-byte arm.
12738 let d = dep_with_fonte(DepSource::Path {
12739 caminho: "/etc/[ch]".into(),
12740 });
12741 let err = d.validate().unwrap_err();
12742 assert!(
12743 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12744 "got {err:?}",
12745 );
12746 }
12747
12748 #[test]
12749 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12750 // Cascade pin on the upstream leading-`$` var-expansion
12751 // arm: a value carrying both a leading `$` and a `[`
12752 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12753 // variable + bracket-class at the head of a sibling-
12754 // workspace path" footgun) routes through
12755 // `FonteCaminhoVarExpansion` not
12756 // `FonteCaminhoShellBracketExpansion`. The leading-byte
12757 // shell-variable-expansion is the more self-locating
12758 // diagnostic on values that probe as both — same
12759 // load-bearing-leading-byte cascade discipline every
12760 // prior `:caminho` arm establishes.
12761 let d = dep_with_fonte(DepSource::Path {
12762 caminho: "$DIR/[ch]".into(),
12763 });
12764 let err = d.validate().unwrap_err();
12765 assert!(
12766 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12767 "got {err:?}",
12768 );
12769 }
12770
12771 #[test]
12772 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12773 // Cascade pin on the immediate-successor arm: a value
12774 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12775 // the canonical "I tab-completed a path that already had
12776 // a bracket-glob-character-class expansion tail" footgun)
12777 // routes through `FonteCaminhoShellBracketExpansion` not
12778 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12779 // is the more semantic-locating axis (an author who
12780 // removes the `[` typically also drops the trailing
12781 // separator since both are paste-from-shell artifacts).
12782 let d = dep_with_fonte(DepSource::Path {
12783 caminho: "../[a-z]/".into(),
12784 });
12785 let err = d.validate().unwrap_err();
12786 assert!(
12787 matches!(
12788 err,
12789 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12790 ),
12791 "got {err:?}",
12792 );
12793 }
12794
12795 #[test]
12796 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12797 // Diagnostic-shape pin (peer with
12798 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12799 // on the closest two-byte peer arm): the error's Display
12800 // surfaces the offending `:nome`, the offending `:caminho`
12801 // verbatim, the offending byte's hex / character form, and
12802 // names the shell-bracket-expansion / glob-character-class
12803 // footgun explicitly so a `feira lint` run can render the
12804 // diagnostic without re-parsing.
12805 let d = dep_with_fonte(DepSource::Path {
12806 caminho: "../caixa-[a-z]/build".into(),
12807 });
12808 let rendered = d.validate().unwrap_err().to_string();
12809 assert!(
12810 rendered.contains("caixa-teia"),
12811 "diagnostic must name the offending dep: {rendered}",
12812 );
12813 assert!(
12814 rendered.contains("../caixa-[a-z]/build"),
12815 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12816 );
12817 assert!(
12818 rendered.contains("0x5b"),
12819 "diagnostic must surface the offending byte hex: {rendered:?}",
12820 );
12821 assert!(
12822 rendered.contains("bracket-expansion"),
12823 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12824 );
12825 assert!(
12826 rendered.contains("glob-character-class"),
12827 "diagnostic must reference the POSIX glob-character-class vocabulary: \
12828 {rendered:?}",
12829 );
12830 }
12831
12832 #[test]
12833 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12834 // The canonical paste-from-shell-history strong-quoted
12835 // sibling-workspace-path footgun: an author copies a
12836 // `cd '../caixa-teia'` shell-history one-liner whose strong-
12837 // quoting preserved the path across a whitespace paste
12838 // boundary and silently passed every prior arm
12839 // (`Path::is_absolute` false on `'..`, no control bytes, no
12840 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12841 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12842 // doesn't end in `/`; the leading-`$` f4efe9c
12843 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12844 // value starts with `'` not `$`). The lacre embedded the
12845 // value verbatim, the resolver folded it through
12846 // `Path::join` looking for a literal `./'../caixa-teia'`
12847 // subdirectory, and the failure surfaced at resolve time
12848 // with a non-self-locating `No such file or directory`
12849 // error. The new arm moves the rejection to validate time
12850 // and names the offending dep + caminho + byte verbatim.
12851 // The arm fires on the first `'` encountered.
12852 let d = dep_with_fonte(DepSource::Path {
12853 caminho: "'../caixa-teia'".into(),
12854 });
12855 let err = d.validate().unwrap_err();
12856 let DepError::FonteCaminhoShellQuoteGrouping {
12857 nome,
12858 caminho,
12859 byte,
12860 } = err
12861 else {
12862 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12863 };
12864 assert_eq!(nome, "caixa-teia");
12865 assert_eq!(caminho, "'../caixa-teia'");
12866 assert_eq!(byte, b'\'');
12867 }
12868
12869 #[test]
12870 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12871 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12872 // — the canonical paste-from-JSON-config / paste-from-YAML-
12873 // flow-scalar / paste-from-TOML-basic-string / paste-from-
12874 // tatara-lisp-string-literal cross-idiom leak). Pinned
12875 // separately from the single-quote shape so the gate's
12876 // contract is "any `'` or `\"` anywhere", not single-byte
12877 // coverage. Mirrors the peer
12878 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12879 // shape on the immediate-predecessor
12880 // `FonteCaminhoShellBracketExpansion` arm.
12881 let d = dep_with_fonte(DepSource::Path {
12882 caminho: "\"../caixa-teia\"".into(),
12883 });
12884 let err = d.validate().unwrap_err();
12885 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12886 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12887 };
12888 assert_eq!(byte, b'"');
12889 }
12890
12891 #[test]
12892 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12893 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12894 // canonical "I pasted a JSON key-value pair fragment into
12895 // the middle of the path" idiom). Pinned separately from
12896 // the leading-byte shape so the gate covers every position,
12897 // not only leading.
12898 let d = dep_with_fonte(DepSource::Path {
12899 caminho: "../\"caixa-teia\"".into(),
12900 });
12901 let err = d.validate().unwrap_err();
12902 assert!(
12903 matches!(
12904 err,
12905 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12906 ),
12907 "got {err:?}",
12908 );
12909 }
12910
12911 #[test]
12912 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12913 // The canonical YAML double-quoted flow-scalar cross-idiom
12914 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12915 // `path: \"...\"` YAML flow-scalar entry out of an aligned
12916 // values.yaml / K8s manifest and dropped it verbatim into
12917 // the `:caminho` slot including the `path: ` key prefix"
12918 // paste-idiom). The arm fires on the first `"` encountered;
12919 // pinned so the gate's coverage extends from the bare-quote
12920 // paste shape to the aligned-YAML-manifest cross-idiom-leak
12921 // shape.
12922 let d = dep_with_fonte(DepSource::Path {
12923 caminho: "path: \"../caixa-teia\"".into(),
12924 });
12925 let err = d.validate().unwrap_err();
12926 assert!(
12927 matches!(
12928 err,
12929 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12930 ),
12931 "got {err:?}",
12932 );
12933 }
12934
12935 #[test]
12936 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12937 // The positive-control pin: the gate targets only `'` /
12938 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12939 // The canonical relative POSIX path (`"../caixa-teia"`) and
12940 // a nested deeply-pathed variant with adjacent printable
12941 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12942 // to validate cleanly so the gate doesn't widen to a "no
12943 // printable punctuation anywhere" sweep that would defeat
12944 // the entire path-fonte author surface. Peer with
12945 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12946 // on the immediate-predecessor arm.
12947 let d = dep_with_fonte(DepSource::Path {
12948 caminho: "../caixa-teia/sub-dir.v2".into(),
12949 });
12950 d.validate().unwrap();
12951 }
12952
12953 #[test]
12954 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12955 // Cascade pin on the immediate-predecessor arm: a value
12956 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12957 // "I pasted a glob-character-class followed by a strong-
12958 // quoted literal tail" footgun) routes through
12959 // `FonteCaminhoShellBracketExpansion` not
12960 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12961 // expansion is the load-bearing root-cause edit on every
12962 // probe-as-both value; same cascade discipline every prior
12963 // `:caminho` arm establishes.
12964 let d = dep_with_fonte(DepSource::Path {
12965 caminho: "../[a-z]'x'".into(),
12966 });
12967 let err = d.validate().unwrap_err();
12968 assert!(
12969 matches!(
12970 err,
12971 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12972 ),
12973 "got {err:?}",
12974 );
12975 }
12976
12977 #[test]
12978 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12979 // Cascade pin on the upstream shell-brace-expansion arm: a
12980 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12981 // canonical "I pasted a brace-expansion fan followed by a
12982 // strong-quoted literal tail" footgun) routes through
12983 // `FonteCaminhoShellBraceExpansion` not
12984 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12985 // is the load-bearing root-cause edit on every probe-as-
12986 // both value.
12987 let d = dep_with_fonte(DepSource::Path {
12988 caminho: "../{a,b}'x'".into(),
12989 });
12990 let err = d.validate().unwrap_err();
12991 assert!(
12992 matches!(
12993 err,
12994 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12995 ),
12996 "got {err:?}",
12997 );
12998 }
12999
13000 #[test]
13001 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13002 // Cascade pin on the upstream shell-subshell-grouping arm:
13003 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13004 // the canonical "I pasted a subshell-grouping followed by
13005 // a strong-quoted literal tail" footgun) routes through
13006 // `FonteCaminhoShellSubshellGrouping` not
13007 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13008 // `$(<cmd>)` command-substitution boundary is the load-
13009 // bearing axis on every probe-as-both value.
13010 let d = dep_with_fonte(DepSource::Path {
13011 caminho: "../(cd foo)/'x'".into(),
13012 });
13013 let err = d.validate().unwrap_err();
13014 assert!(
13015 matches!(
13016 err,
13017 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13018 ),
13019 "got {err:?}",
13020 );
13021 }
13022
13023 #[test]
13024 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13025 // Cascade pin on the upstream shell-glob arm: a value
13026 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13027 // canonical "I pasted a `*` unbounded pathname-expansion
13028 // followed by a strong-quoted literal tail" footgun) routes
13029 // through `FonteCaminhoShellGlob` not
13030 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13031 // expansion sentinel is the load-bearing root-cause edit
13032 // on every probe-as-both value.
13033 let d = dep_with_fonte(DepSource::Path {
13034 caminho: "../caixa-teia/*'x'".into(),
13035 });
13036 let err = d.validate().unwrap_err();
13037 assert!(
13038 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13039 "got {err:?}",
13040 );
13041 }
13042
13043 #[test]
13044 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13045 // Cascade pin on the upstream shell-command-substitution
13046 // arm: a value carrying both a backtick and `'`
13047 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13048 // legacy-backtick command-substitution followed by a
13049 // strong-quoted literal tail" footgun) routes through
13050 // `FonteCaminhoShellCommandSubstitution` not
13051 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13052 // command-injection vector is the load-bearing root-cause
13053 // edit on every probe-as-both value.
13054 let d = dep_with_fonte(DepSource::Path {
13055 caminho: "../`whoami`/'x'".into(),
13056 });
13057 let err = d.validate().unwrap_err();
13058 assert!(
13059 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13060 "got {err:?}",
13061 );
13062 }
13063
13064 #[test]
13065 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13066 // Cascade pin on the upstream shell-background arm: a value
13067 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13068 // canonical "I pasted a `cmd & 'literal'` background-launch
13069 // + quote chain" footgun) routes through
13070 // `FonteCaminhoShellBackground` not
13071 // `FonteCaminhoShellQuoteGrouping`. The background-launch
13072 // tail is the load-bearing root-cause edit on every
13073 // probe-as-both value.
13074 let d = dep_with_fonte(DepSource::Path {
13075 caminho: "../caixa-teia & 'x'".into(),
13076 });
13077 let err = d.validate().unwrap_err();
13078 assert!(
13079 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13080 "got {err:?}",
13081 );
13082 }
13083
13084 #[test]
13085 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13086 // Cascade pin on the upstream shell-semicolon arm: a value
13087 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13088 // canonical sequential-cleanup + quote paste idiom) routes
13089 // through `FonteCaminhoShellSemicolon` not
13090 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13091 // separator paste is the load-bearing root-cause edit on
13092 // every probe-as-both value.
13093 let d = dep_with_fonte(DepSource::Path {
13094 caminho: "../caixa-teia; 'x'".into(),
13095 });
13096 let err = d.validate().unwrap_err();
13097 assert!(
13098 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13099 "got {err:?}",
13100 );
13101 }
13102
13103 #[test]
13104 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13105 // Cascade pin on the upstream shell-pipe arm: a value
13106 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13107 // canonical pipeline-to-quoted-literal paste idiom) routes
13108 // through `FonteCaminhoShellPipe` not
13109 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13110 // is the load-bearing root-cause edit on every probe-as-
13111 // both value.
13112 let d = dep_with_fonte(DepSource::Path {
13113 caminho: "../caixa-teia | 'x'".into(),
13114 });
13115 let err = d.validate().unwrap_err();
13116 assert!(
13117 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13118 "got {err:?}",
13119 );
13120 }
13121
13122 #[test]
13123 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13124 // Cascade pin on the upstream shell-redirection arm: a
13125 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13126 // — the canonical "I pasted a `cmd > log 'literal'`
13127 // redirect-plus-quote chain" footgun) routes through
13128 // `FonteCaminhoShellRedirection` not
13129 // `FonteCaminhoShellQuoteGrouping`. The input/output
13130 // redirection metachar carries the more self-locating
13131 // `byte` payload, so the prior arm wins on every probe-as-
13132 // both value.
13133 let d = dep_with_fonte(DepSource::Path {
13134 caminho: "../caixa-teia>log 'x'".into(),
13135 });
13136 let err = d.validate().unwrap_err();
13137 assert!(
13138 matches!(
13139 err,
13140 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13141 ),
13142 "got {err:?}",
13143 );
13144 }
13145
13146 #[test]
13147 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13148 // Cascade pin on the upstream backslash arm: a value
13149 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13150 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13151 // chain" footgun) routes through `FonteCaminhoBackslash`
13152 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13153 // separator divergence is the load-bearing axis on every
13154 // probe-as-both value.
13155 let d = dep_with_fonte(DepSource::Path {
13156 caminho: "..\\caixa-teia\\'x'".into(),
13157 });
13158 let err = d.validate().unwrap_err();
13159 assert!(
13160 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13161 "got {err:?}",
13162 );
13163 }
13164
13165 #[test]
13166 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13167 // Cascade pin on the embedded-control-byte arm: a value
13168 // carrying both a control byte and `'` (`"../foo\n'x'"` —
13169 // the canonical paste-from-multiline-doc footgun where a
13170 // newline landed mid-caminho between two paste fragments)
13171 // routes through `FonteCaminhoControlChar` not
13172 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13173 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13174 // the load-bearing axis on every value that probes
13175 // positive for both — mirrors the cascade discipline on
13176 // every prior arm.
13177 let d = dep_with_fonte(DepSource::Path {
13178 caminho: "../foo\n'x'".into(),
13179 });
13180 let err = d.validate().unwrap_err();
13181 assert!(
13182 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13183 "got {err:?}",
13184 );
13185 }
13186
13187 #[test]
13188 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13189 // Cascade pin on the load-bearing leading-byte arm: a
13190 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13191 // through `FonteCaminhoAbsolute` not
13192 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13193 // diagnostic is the load-bearing axis, the quote byte is
13194 // the secondary observation. Same precedence logic as every
13195 // prior leading-byte arm.
13196 let d = dep_with_fonte(DepSource::Path {
13197 caminho: "/etc/'x'".into(),
13198 });
13199 let err = d.validate().unwrap_err();
13200 assert!(
13201 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13202 "got {err:?}",
13203 );
13204 }
13205
13206 #[test]
13207 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13208 // Cascade pin on the upstream leading-`$` var-expansion
13209 // arm: a value carrying both a leading `$` and a `'`
13210 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13211 // variable + quoted literal at the head of a sibling-
13212 // workspace path" footgun) routes through
13213 // `FonteCaminhoVarExpansion` not
13214 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13215 // shell-variable-expansion is the more self-locating
13216 // diagnostic on values that probe as both — same
13217 // load-bearing-leading-byte cascade discipline every
13218 // prior `:caminho` arm establishes.
13219 let d = dep_with_fonte(DepSource::Path {
13220 caminho: "$DIR/'x'".into(),
13221 });
13222 let err = d.validate().unwrap_err();
13223 assert!(
13224 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13225 "got {err:?}",
13226 );
13227 }
13228
13229 #[test]
13230 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13231 // Cascade pin on the immediate-successor arm: a value
13232 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13233 // — the canonical "I tab-completed a path whose strong-
13234 // quoted body already carried the quoting from a shell-
13235 // history paste" footgun) routes through
13236 // `FonteCaminhoShellQuoteGrouping` not
13237 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13238 // is the more semantic-locating axis (an author who removes
13239 // the `'` typically also drops the trailing separator since
13240 // both are paste-from-shell artifacts).
13241 let d = dep_with_fonte(DepSource::Path {
13242 caminho: "../'caixa-teia'/".into(),
13243 });
13244 let err = d.validate().unwrap_err();
13245 assert!(
13246 matches!(
13247 err,
13248 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13249 ),
13250 "got {err:?}",
13251 );
13252 }
13253
13254 #[test]
13255 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13256 // Diagnostic-shape pin (peer with
13257 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13258 // on the closest two-byte peer arm): the error's Display
13259 // surfaces the offending `:nome`, the offending `:caminho`
13260 // verbatim, the offending byte's hex / character form, and
13261 // names the shell-quote-grouping / cross-config-DSL-string-
13262 // literal-delimiter footgun explicitly so a `feira lint`
13263 // run can render the diagnostic without re-parsing.
13264 let d = dep_with_fonte(DepSource::Path {
13265 caminho: "'../caixa-teia'".into(),
13266 });
13267 let rendered = d.validate().unwrap_err().to_string();
13268 assert!(
13269 rendered.contains("caixa-teia"),
13270 "diagnostic must name the offending dep: {rendered}",
13271 );
13272 assert!(
13273 rendered.contains("'../caixa-teia'"),
13274 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13275 );
13276 assert!(
13277 rendered.contains("0x27"),
13278 "diagnostic must surface the offending byte hex: {rendered:?}",
13279 );
13280 assert!(
13281 rendered.contains("quote-grouping"),
13282 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13283 );
13284 assert!(
13285 rendered.contains("string-literal"),
13286 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13287 vocabulary: {rendered:?}",
13288 );
13289 }
13290
13291 #[test]
13292 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13293 // The canonical paste-from-shell-history-with-trailing-
13294 // annotation footgun: an author pastes a `cd ../caixa-teia
13295 // # legacy sibling` shell-history one-liner whose unquoted `#`
13296 // comment-lead separates the path from an inline annotation.
13297 // The POSIX shell trims the annotation to `../caixa-teia`
13298 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13299 // `Path::is_absolute` returns false on `..`, `#` is neither
13300 // a leading-byte sentinel nor a control byte nor `\` nor
13301 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13302 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13303 // `"`, and the value's last byte isn't `/` — so the value
13304 // silently passed every prior arm. The resolver folded the
13305 // value through `Path::join` looking for a literal
13306 // `./../caixa-teia # legacy sibling` subdirectory and the
13307 // failure surfaced at resolve time with a non-self-locating
13308 // `No such file or directory` error. The new arm moves the
13309 // rejection to validate time and names the offending dep +
13310 // caminho + byte verbatim.
13311 let d = dep_with_fonte(DepSource::Path {
13312 caminho: "../caixa-teia # legacy sibling".into(),
13313 });
13314 let err = d.validate().unwrap_err();
13315 let DepError::FonteCaminhoShellComment {
13316 nome,
13317 caminho,
13318 byte,
13319 } = err
13320 else {
13321 panic!("expected FonteCaminhoShellComment, got {err:?}");
13322 };
13323 assert_eq!(nome, "caixa-teia");
13324 assert_eq!(caminho, "../caixa-teia # legacy sibling");
13325 assert_eq!(byte, b'#');
13326 }
13327
13328 #[test]
13329 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13330 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13331 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
13332 // canonical "I copied a `path: ../caixa-teia # pin` YAML
13333 // scalar-plus-comment entry out of an aligned values.yaml and
13334 // dropped it verbatim into the `:caminho` slot" paste-idiom).
13335 // Pinned separately from the shell-history shape so the
13336 // gate's coverage extends from the single-space `#` shape to
13337 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
13338 // requires the `#` to be preceded by whitespace to lex as a
13339 // comment (bare `foo#bar` is a single scalar); the double-
13340 // space paste from an aligned manifest is the canonical
13341 // shape.
13342 let d = dep_with_fonte(DepSource::Path {
13343 caminho: "../caixa-teia # pin".into(),
13344 });
13345 let err = d.validate().unwrap_err();
13346 assert!(
13347 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13348 "got {err:?}",
13349 );
13350 }
13351
13352 #[test]
13353 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13354 // The URL-fragment-identifier paste shape
13355 // (`"../caixa-teia#readme"` — the canonical
13356 // paste-from-browser-address-bar permalink shape where the
13357 // browser preserved the `#anchor` tail on the copy). Pinned
13358 // separately from the whitespace-separated shell / YAML
13359 // comment shapes so the gate covers the unpadded RFC 3986
13360 // §3.5 fragment-delimiter position too, not only positions
13361 // preceded by unquoted whitespace. Peer with the immediate-
13362 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13363 // (a68f818) which closes the same byte under the same URL-
13364 // fragment-identifier banner.
13365 let d = dep_with_fonte(DepSource::Path {
13366 caminho: "../caixa-teia#readme".into(),
13367 });
13368 let err = d.validate().unwrap_err();
13369 assert!(
13370 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13371 "got {err:?}",
13372 );
13373 }
13374
13375 #[test]
13376 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13377 // Leading-position `#` shape (`"#../caixa-teia"` — the
13378 // "I copied a shell-comment-out entry from a commented-out
13379 // dep row" footgun). Pinned separately from the embedded
13380 // shapes so the gate covers every position, not only
13381 // whitespace-preceded / mid-value.
13382 let d = dep_with_fonte(DepSource::Path {
13383 caminho: "#../caixa-teia".into(),
13384 });
13385 let err = d.validate().unwrap_err();
13386 assert!(
13387 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13388 "got {err:?}",
13389 );
13390 }
13391
13392 #[test]
13393 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13394 // The positive-control pin: the gate targets only `#`,
13395 // never adjacent printable ASCII or POSIX-valid bytes. The
13396 // canonical relative POSIX path (`"../caixa-teia"`) and a
13397 // nested deeply-pathed variant with adjacent printable
13398 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13399 // to validate cleanly so the gate doesn't widen to a "no
13400 // printable punctuation anywhere" sweep that would defeat
13401 // the entire path-fonte author surface. Peer with
13402 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13403 // on the immediate-predecessor arm.
13404 let d = dep_with_fonte(DepSource::Path {
13405 caminho: "../caixa-teia/sub-dir.v2".into(),
13406 });
13407 d.validate().unwrap();
13408 }
13409
13410 #[test]
13411 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13412 // Cascade pin on the immediate-predecessor arm: a value
13413 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13414 // "I pasted a strong-quoted literal followed by a URL-
13415 // fragment permalink tail" footgun) routes through
13416 // `FonteCaminhoShellQuoteGrouping` not
13417 // `FonteCaminhoShellComment`. The shell-string-literal-
13418 // delimiter is the load-bearing root-cause edit on every
13419 // probe-as-both value; same cascade discipline every prior
13420 // `:caminho` arm establishes.
13421 let d = dep_with_fonte(DepSource::Path {
13422 caminho: "../'x'#pin".into(),
13423 });
13424 let err = d.validate().unwrap_err();
13425 assert!(
13426 matches!(
13427 err,
13428 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13429 ),
13430 "got {err:?}",
13431 );
13432 }
13433
13434 #[test]
13435 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13436 // Cascade pin on the upstream shell-bracket-expansion arm:
13437 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13438 // canonical "I pasted a glob-character-class followed by a
13439 // URL-fragment tail" footgun) routes through
13440 // `FonteCaminhoShellBracketExpansion` not
13441 // `FonteCaminhoShellComment`. The glob-character-class
13442 // expansion is the load-bearing root-cause edit on every
13443 // probe-as-both value.
13444 let d = dep_with_fonte(DepSource::Path {
13445 caminho: "../[a-z]#pin".into(),
13446 });
13447 let err = d.validate().unwrap_err();
13448 assert!(
13449 matches!(
13450 err,
13451 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13452 ),
13453 "got {err:?}",
13454 );
13455 }
13456
13457 #[test]
13458 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13459 // Cascade pin on the upstream shell-brace-expansion arm: a
13460 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13461 // canonical "I pasted a brace-expansion fan followed by a
13462 // URL-fragment tail" footgun) routes through
13463 // `FonteCaminhoShellBraceExpansion` not
13464 // `FonteCaminhoShellComment`. The brace-expansion fan is the
13465 // load-bearing root-cause edit on every probe-as-both value.
13466 let d = dep_with_fonte(DepSource::Path {
13467 caminho: "../{a,b}#pin".into(),
13468 });
13469 let err = d.validate().unwrap_err();
13470 assert!(
13471 matches!(
13472 err,
13473 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13474 ),
13475 "got {err:?}",
13476 );
13477 }
13478
13479 #[test]
13480 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13481 // Cascade pin on the upstream shell-subshell-grouping arm:
13482 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13483 // the canonical "I pasted a subshell-grouping followed by a
13484 // URL-fragment tail" footgun) routes through
13485 // `FonteCaminhoShellSubshellGrouping` not
13486 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13487 // command-substitution boundary is the load-bearing axis on
13488 // every probe-as-both value.
13489 let d = dep_with_fonte(DepSource::Path {
13490 caminho: "../(cd foo)#pin".into(),
13491 });
13492 let err = d.validate().unwrap_err();
13493 assert!(
13494 matches!(
13495 err,
13496 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13497 ),
13498 "got {err:?}",
13499 );
13500 }
13501
13502 #[test]
13503 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13504 // Cascade pin on the upstream shell-glob arm: a value
13505 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13506 // canonical "I pasted a `*` unbounded pathname-expansion
13507 // followed by a URL-fragment tail" footgun) routes through
13508 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13509 // The unbounded pathname-expansion sentinel is the load-
13510 // bearing root-cause edit on every probe-as-both value.
13511 let d = dep_with_fonte(DepSource::Path {
13512 caminho: "../caixa-teia/*#pin".into(),
13513 });
13514 let err = d.validate().unwrap_err();
13515 assert!(
13516 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13517 "got {err:?}",
13518 );
13519 }
13520
13521 #[test]
13522 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13523 // Cascade pin on the upstream shell-command-substitution
13524 // arm: a value carrying both a backtick and `#`
13525 // (``"../`whoami`#pin"`` — the canonical "I pasted a
13526 // legacy-backtick command-substitution followed by a URL-
13527 // fragment tail" footgun) routes through
13528 // `FonteCaminhoShellCommandSubstitution` not
13529 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13530 // injection vector is the load-bearing root-cause edit on
13531 // every probe-as-both value.
13532 let d = dep_with_fonte(DepSource::Path {
13533 caminho: "../`whoami`#pin".into(),
13534 });
13535 let err = d.validate().unwrap_err();
13536 assert!(
13537 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13538 "got {err:?}",
13539 );
13540 }
13541
13542 #[test]
13543 fn fonte_caminho_shell_background_fires_before_shell_comment() {
13544 // Cascade pin on the upstream shell-background arm: a value
13545 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13546 // the canonical "I pasted a `cmd &` background-launch
13547 // followed by a URL-fragment tail" footgun) routes through
13548 // `FonteCaminhoShellBackground` not
13549 // `FonteCaminhoShellComment`. The background-launch tail is
13550 // the load-bearing root-cause edit on every probe-as-both
13551 // value.
13552 let d = dep_with_fonte(DepSource::Path {
13553 caminho: "../caixa-teia&pin#tail".into(),
13554 });
13555 let err = d.validate().unwrap_err();
13556 assert!(
13557 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13558 "got {err:?}",
13559 );
13560 }
13561
13562 #[test]
13563 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13564 // Cascade pin on the upstream shell-semicolon arm: a value
13565 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13566 // the canonical sequential-cleanup + URL-fragment paste
13567 // idiom) routes through `FonteCaminhoShellSemicolon` not
13568 // `FonteCaminhoShellComment`. The sequential-command-
13569 // separator paste is the load-bearing root-cause edit on
13570 // every probe-as-both value.
13571 let d = dep_with_fonte(DepSource::Path {
13572 caminho: "../caixa-teia;pin#tail".into(),
13573 });
13574 let err = d.validate().unwrap_err();
13575 assert!(
13576 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13577 "got {err:?}",
13578 );
13579 }
13580
13581 #[test]
13582 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13583 // Cascade pin on the upstream shell-pipe arm: a value
13584 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13585 // the canonical pipeline-to-URL-fragment paste idiom) routes
13586 // through `FonteCaminhoShellPipe` not
13587 // `FonteCaminhoShellComment`. The pipeline-tail paste is
13588 // the load-bearing root-cause edit on every probe-as-both
13589 // value.
13590 let d = dep_with_fonte(DepSource::Path {
13591 caminho: "../caixa-teia|pin#tail".into(),
13592 });
13593 let err = d.validate().unwrap_err();
13594 assert!(
13595 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13596 "got {err:?}",
13597 );
13598 }
13599
13600 #[test]
13601 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13602 // Cascade pin on the upstream shell-redirection arm: a
13603 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13604 // — the canonical "I pasted a `cmd > log` redirect followed
13605 // by a URL-fragment tail" footgun) routes through
13606 // `FonteCaminhoShellRedirection` not
13607 // `FonteCaminhoShellComment`. The input/output redirection
13608 // metachar carries the more self-locating `byte` payload,
13609 // so the prior arm wins on every probe-as-both value.
13610 let d = dep_with_fonte(DepSource::Path {
13611 caminho: "../caixa-teia>log#pin".into(),
13612 });
13613 let err = d.validate().unwrap_err();
13614 assert!(
13615 matches!(
13616 err,
13617 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13618 ),
13619 "got {err:?}",
13620 );
13621 }
13622
13623 #[test]
13624 fn fonte_caminho_backslash_fires_before_shell_comment() {
13625 // Cascade pin on the upstream backslash arm: a value
13626 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13627 // canonical "I pasted a Windows-shell path followed by a
13628 // URL-fragment tail" footgun) routes through
13629 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13630 // The cross-host-OS-separator divergence is the load-
13631 // bearing axis on every probe-as-both value.
13632 let d = dep_with_fonte(DepSource::Path {
13633 caminho: "..\\caixa-teia#pin".into(),
13634 });
13635 let err = d.validate().unwrap_err();
13636 assert!(
13637 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13638 "got {err:?}",
13639 );
13640 }
13641
13642 #[test]
13643 fn fonte_caminho_control_char_fires_before_shell_comment() {
13644 // Cascade pin on the embedded-control-byte arm: a value
13645 // carrying both a control byte and `#` (`"../foo\n#pin"` —
13646 // the canonical paste-from-multiline-doc footgun where a
13647 // newline landed mid-caminho between the path and an
13648 // annotation) routes through `FonteCaminhoControlChar` not
13649 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13650 // byte diagnostic is the load-bearing axis on every value
13651 // that probes positive for both — mirrors the cascade
13652 // discipline on every prior arm.
13653 let d = dep_with_fonte(DepSource::Path {
13654 caminho: "../foo\n#pin".into(),
13655 });
13656 let err = d.validate().unwrap_err();
13657 assert!(
13658 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13659 "got {err:?}",
13660 );
13661 }
13662
13663 #[test]
13664 fn fonte_caminho_absolute_fires_before_shell_comment() {
13665 // Cascade pin on the load-bearing leading-byte arm: a
13666 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13667 // routes through `FonteCaminhoAbsolute` not
13668 // `FonteCaminhoShellComment` — the host-layout-leak
13669 // diagnostic is the load-bearing axis, the fragment byte is
13670 // the secondary observation. Same precedence logic as every
13671 // prior leading-byte arm.
13672 let d = dep_with_fonte(DepSource::Path {
13673 caminho: "/etc/foo#pin".into(),
13674 });
13675 let err = d.validate().unwrap_err();
13676 assert!(
13677 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13678 "got {err:?}",
13679 );
13680 }
13681
13682 #[test]
13683 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13684 // Cascade pin on the upstream leading-`$` var-expansion
13685 // arm: a value carrying both a leading `$` and a `#`
13686 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13687 // shell-variable at the head of a sibling-workspace path
13688 // followed by a URL-fragment tail" footgun) routes through
13689 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13690 // The leading-byte shell-variable-expansion is the more
13691 // self-locating diagnostic on values that probe as both.
13692 let d = dep_with_fonte(DepSource::Path {
13693 caminho: "$DIR/foo#pin".into(),
13694 });
13695 let err = d.validate().unwrap_err();
13696 assert!(
13697 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13698 "got {err:?}",
13699 );
13700 }
13701
13702 #[test]
13703 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13704 // Cascade pin on the immediate-successor arm: a value
13705 // carrying both `#` and a trailing `/`
13706 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13707 // a URL-fragment-carrying path" footgun) routes through
13708 // `FonteCaminhoShellComment` not
13709 // `FonteCaminhoTrailingSlash`. The embedded fragment /
13710 // comment-lead byte is the more semantic-locating axis (an
13711 // author who removes the `#pin` fragment typically also
13712 // drops the trailing separator since both are paste-from-
13713 // URL / paste-from-shell-tab-completion artifacts).
13714 let d = dep_with_fonte(DepSource::Path {
13715 caminho: "../caixa-teia#pin/".into(),
13716 });
13717 let err = d.validate().unwrap_err();
13718 assert!(
13719 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13720 "got {err:?}",
13721 );
13722 }
13723
13724 #[test]
13725 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13726 // Diagnostic-shape pin (peer with
13727 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13728 // on the immediate-predecessor arm): the error's Display
13729 // surfaces the offending `:nome`, the offending `:caminho`
13730 // verbatim, the offending byte's hex / character form, and
13731 // names the shell-comment / URL-fragment-identifier /
13732 // YAML-comment cross-config-DSL footgun explicitly so a
13733 // `feira lint` run can render the diagnostic without
13734 // re-parsing.
13735 let d = dep_with_fonte(DepSource::Path {
13736 caminho: "../caixa-teia#readme".into(),
13737 });
13738 let rendered = d.validate().unwrap_err().to_string();
13739 assert!(
13740 rendered.contains("caixa-teia"),
13741 "diagnostic must name the offending dep: {rendered}",
13742 );
13743 assert!(
13744 rendered.contains("../caixa-teia#readme"),
13745 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13746 );
13747 assert!(
13748 rendered.contains("0x23"),
13749 "diagnostic must surface the offending byte hex: {rendered:?}",
13750 );
13751 assert!(
13752 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13753 "diagnostic must name the shell-comment footgun: {rendered:?}",
13754 );
13755 assert!(
13756 rendered.contains("fragment") || rendered.contains("URL-fragment"),
13757 "diagnostic must reference the URL-fragment-identifier vocabulary: \
13758 {rendered:?}",
13759 );
13760 }
13761
13762 #[test]
13763 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13764 // The canonical paste-from-browser-address-bar percent-
13765 // encoded-space footgun: an author copies `../caixa%20teia`
13766 // out of a URL-encoded README hyperlink / browser address
13767 // bar / percent-encoded permalink expecting `%20` to decode
13768 // to a literal space at the filesystem layer. POSIX
13769 // `std::path::Path` treats `%` as a literal path-component
13770 // byte, so `Path::join` looks for a literal
13771 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13772 // returns false on `..`, `%` is neither a leading-byte
13773 // sentinel nor a control byte nor `\` nor `<` / `>` nor
13774 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13775 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13776 // and the value's last byte isn't `/` — so the value
13777 // silently passed every prior arm. The new arm moves the
13778 // rejection to validate time and names the offending dep +
13779 // caminho + byte verbatim.
13780 let d = dep_with_fonte(DepSource::Path {
13781 caminho: "../caixa%20teia".into(),
13782 });
13783 let err = d.validate().unwrap_err();
13784 let DepError::FonteCaminhoUrlPercentEncoding {
13785 nome,
13786 caminho,
13787 byte,
13788 } = err
13789 else {
13790 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13791 };
13792 assert_eq!(nome, "caixa-teia");
13793 assert_eq!(caminho, "../caixa%20teia");
13794 assert_eq!(byte, b'%');
13795 }
13796
13797 #[test]
13798 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13799 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13800 // intending the `%2F` as the URL encoding of `/`) locks a
13801 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13802 // the byte-identical `path:../caixa/teia` form. Pinned
13803 // separately from the space-encoded shape so the gate's
13804 // coverage extends past the single canonical `%20` example
13805 // to any two-hex-digit percent-encoded sequence.
13806 let d = dep_with_fonte(DepSource::Path {
13807 caminho: "../caixa%2Fteia".into(),
13808 });
13809 let err = d.validate().unwrap_err();
13810 assert!(
13811 matches!(
13812 err,
13813 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13814 ),
13815 "got {err:?}",
13816 );
13817 }
13818
13819 #[test]
13820 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13821 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13822 // where `%` isn't followed by two hex digits) — every
13823 // WHATWG-conformant URL parser rejects the value at parse
13824 // time per RFC 3986 §2.1, but the byte would silently ride
13825 // into the lacre before the resolver subprocess crosses the
13826 // URL-parser boundary. Pinned separately from the well-
13827 // formed `%HH` shapes so the gate covers every percent-
13828 // occurrence, not only strictly-conformant escapes.
13829 let d = dep_with_fonte(DepSource::Path {
13830 caminho: "../caixa-teia%foo".into(),
13831 });
13832 let err = d.validate().unwrap_err();
13833 assert!(
13834 matches!(
13835 err,
13836 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13837 ),
13838 "got {err:?}",
13839 );
13840 }
13841
13842 #[test]
13843 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13844 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13845 // — the canonical paste-from-top-of-doc YAML directive
13846 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13847 // separately from embedded shapes so the gate covers the
13848 // leading-position `%` too, not only mid-value occurrences.
13849 let d = dep_with_fonte(DepSource::Path {
13850 caminho: "%YAML/../caixa-teia".into(),
13851 });
13852 let err = d.validate().unwrap_err();
13853 assert!(
13854 matches!(
13855 err,
13856 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13857 ),
13858 "got {err:?}",
13859 );
13860 }
13861
13862 #[test]
13863 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13864 // The printf-format-specifier paste shape
13865 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13866 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13867 // 134 format-string-injection vector). Pinned separately
13868 // from the URL-encoding shapes so the gate's rationale
13869 // extends past the RFC 3986 axis to the C / POSIX printf
13870 // format-directive-lead axis.
13871 let d = dep_with_fonte(DepSource::Path {
13872 caminho: "../caixa-%s-teia".into(),
13873 });
13874 let err = d.validate().unwrap_err();
13875 assert!(
13876 matches!(
13877 err,
13878 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13879 ),
13880 "got {err:?}",
13881 );
13882 }
13883
13884 #[test]
13885 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13886 // The positive-control pin: the gate targets only `%`,
13887 // never adjacent printable ASCII or POSIX-valid bytes. The
13888 // canonical relative POSIX path (`"../caixa-teia"`) and a
13889 // nested deeply-pathed variant with adjacent printable
13890 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13891 // to validate cleanly so the gate doesn't widen to a "no
13892 // printable punctuation anywhere" sweep that would defeat
13893 // the entire path-fonte author surface. Peer with
13894 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13895 // on the immediate-predecessor arm.
13896 let d = dep_with_fonte(DepSource::Path {
13897 caminho: "../caixa-teia/sub-dir.v2".into(),
13898 });
13899 d.validate().unwrap();
13900 }
13901
13902 #[test]
13903 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13904 // Cascade pin on the immediate-predecessor arm: a value
13905 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13906 // canonical "I pasted a URL-fragment permalink followed by a
13907 // percent-encoded space tail" footgun) routes through
13908 // `FonteCaminhoShellComment` not
13909 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13910 // identifier is the load-bearing downstream-truncation edit
13911 // on every probe-as-both value; same cascade discipline
13912 // every prior `:caminho` arm establishes.
13913 let d = dep_with_fonte(DepSource::Path {
13914 caminho: "../caixa-teia#pin%20".into(),
13915 });
13916 let err = d.validate().unwrap_err();
13917 assert!(
13918 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13919 "got {err:?}",
13920 );
13921 }
13922
13923 #[test]
13924 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13925 // Cascade pin on the upstream shell-quote-grouping arm: a
13926 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13927 // canonical "I pasted a strong-quoted literal followed by
13928 // a percent-encoded space" footgun) routes through
13929 // `FonteCaminhoShellQuoteGrouping` not
13930 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13931 // literal-delimiter is the load-bearing root-cause edit on
13932 // every probe-as-both value.
13933 let d = dep_with_fonte(DepSource::Path {
13934 caminho: "../'x'%20teia".into(),
13935 });
13936 let err = d.validate().unwrap_err();
13937 assert!(
13938 matches!(
13939 err,
13940 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13941 ),
13942 "got {err:?}",
13943 );
13944 }
13945
13946 #[test]
13947 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13948 // Cascade pin on the upstream backslash arm: a value
13949 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13950 // canonical "I pasted a Windows-shell path followed by a
13951 // percent-encoded space" footgun) routes through
13952 // `FonteCaminhoBackslash` not
13953 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13954 // separator divergence is the load-bearing root-cause edit
13955 // on every probe-as-both value.
13956 let d = dep_with_fonte(DepSource::Path {
13957 caminho: "..\\caixa%20teia".into(),
13958 });
13959 let err = d.validate().unwrap_err();
13960 assert!(
13961 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13962 "got {err:?}",
13963 );
13964 }
13965
13966 #[test]
13967 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13968 // Cascade pin on the upstream control-char arm: a value
13969 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13970 // the canonical "I pasted a paste-from-binary-blob path
13971 // followed by a percent-encoded space" footgun) routes
13972 // through `FonteCaminhoControlChar` not
13973 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13974 // rejected byte is the load-bearing root-cause edit on
13975 // every probe-as-both value.
13976 let d = dep_with_fonte(DepSource::Path {
13977 caminho: "../caixa\0%20teia".into(),
13978 });
13979 let err = d.validate().unwrap_err();
13980 assert!(
13981 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13982 "got {err:?}",
13983 );
13984 }
13985
13986 #[test]
13987 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13988 // Cascade pin on the upstream absolute-path arm: a value
13989 // that's both absolute and carries `%` (`"/etc/passwd%20"`
13990 // — the canonical "I pasted an absolute path with a
13991 // percent-encoded space tail" footgun) routes through
13992 // `FonteCaminhoAbsolute` not
13993 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13994 // the load-bearing root-cause edit on every probe-as-both
13995 // value.
13996 let d = dep_with_fonte(DepSource::Path {
13997 caminho: "/etc/passwd%20".into(),
13998 });
13999 let err = d.validate().unwrap_err();
14000 assert!(
14001 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14002 "got {err:?}",
14003 );
14004 }
14005
14006 #[test]
14007 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14008 // Cascade pin on the upstream var-expansion arm: a value
14009 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14010 // — the canonical "I pasted a `$HOME`-rooted path with a
14011 // percent-encoded space" footgun) routes through
14012 // `FonteCaminhoVarExpansion` not
14013 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14014 // expansion is the load-bearing root-cause edit on every
14015 // probe-as-both value.
14016 let d = dep_with_fonte(DepSource::Path {
14017 caminho: "$HOME/caixa%20teia".into(),
14018 });
14019 let err = d.validate().unwrap_err();
14020 assert!(
14021 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14022 "got {err:?}",
14023 );
14024 }
14025
14026 #[test]
14027 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14028 // Cascade pin on the immediate-successor arm: a value
14029 // carrying both `%` and a trailing `/`
14030 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14031 // percent-encoded-space-carrying path" footgun) routes
14032 // through `FonteCaminhoUrlPercentEncoding` not
14033 // `FonteCaminhoTrailingSlash`. The embedded percent-
14034 // encoding-escape byte is the more semantic-locating axis
14035 // (an author who decodes the `%20` to a literal space is
14036 // likely to also tab-strip the trailing separator since
14037 // both are paste-from-URL / paste-from-shell-tab-completion
14038 // artifacts).
14039 let d = dep_with_fonte(DepSource::Path {
14040 caminho: "../caixa%20teia/".into(),
14041 });
14042 let err = d.validate().unwrap_err();
14043 assert!(
14044 matches!(
14045 err,
14046 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14047 ),
14048 "got {err:?}",
14049 );
14050 }
14051
14052 #[test]
14053 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14054 // Diagnostic-shape pin (peer with
14055 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14056 // on the immediate-predecessor arm): the error's Display
14057 // surfaces the offending `:nome`, the offending `:caminho`
14058 // verbatim, the offending byte's hex / character form, and
14059 // names the URL-percent-encoding-escape / printf-format-
14060 // specifier footgun explicitly so a `feira lint` run can
14061 // render the diagnostic without re-parsing.
14062 let d = dep_with_fonte(DepSource::Path {
14063 caminho: "../caixa%20teia".into(),
14064 });
14065 let rendered = d.validate().unwrap_err().to_string();
14066 assert!(
14067 rendered.contains("caixa-teia"),
14068 "diagnostic must name the offending dep: {rendered}",
14069 );
14070 assert!(
14071 rendered.contains("../caixa%20teia"),
14072 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14073 );
14074 assert!(
14075 rendered.contains("0x25"),
14076 "diagnostic must surface the offending byte hex: {rendered:?}",
14077 );
14078 assert!(
14079 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14080 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14081 );
14082 assert!(
14083 rendered.contains("printf") || rendered.contains("format-specifier"),
14084 "diagnostic must reference the printf-format-specifier vocabulary: \
14085 {rendered:?}",
14086 );
14087 }
14088
14089 #[test]
14090 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14091 // The canonical embedded-`$` shell-variable-expansion paste
14092 // shape (`"../foo$HOME/bar"` — an author copies a partially-
14093 // substituted shell one-liner where the leading segment is a
14094 // literal `../foo` while the mid segment carries the un-
14095 // substituted `$HOME` template). The leading-`$` position is
14096 // already gated by the f4efe9c leading-byte arm which routes
14097 // through `FonteCaminhoVarExpansion`; this arm closes the
14098 // last positional gap on `$` — every position on the axis is
14099 // structurally rejected.
14100 let d = dep_with_fonte(DepSource::Path {
14101 caminho: "../foo$HOME/bar".into(),
14102 });
14103 let err = d.validate().unwrap_err();
14104 let DepError::FonteCaminhoShellVariableExpansion {
14105 nome,
14106 caminho,
14107 byte,
14108 } = err
14109 else {
14110 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14111 };
14112 assert_eq!(nome, "caixa-teia");
14113 assert_eq!(caminho, "../foo$HOME/bar");
14114 assert_eq!(byte, b'$');
14115 }
14116
14117 #[test]
14118 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14119 // The symmetric braced-CI-manifest paste shape
14120 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14121 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14122 // footgun). Pinned separately from the bare-`$VAR` shape so
14123 // the gate covers both POSIX shell §2.6 Parameter Expansion
14124 // syntactic forms, not only the unbraced variant. The
14125 // embedded `{` byte in `${...}` is also caught by the 598b770
14126 // shell-brace-expansion arm but that arm fires earlier in
14127 // the cascade — the `$` arm's coverage extends to `${...}`
14128 // structurally, so the diagnostic asserted here is the
14129 // brace-expansion one (which is a valid outcome; the point
14130 // of the pin is that the value never survives validation).
14131 let d = dep_with_fonte(DepSource::Path {
14132 caminho: "../foo${WORKSPACE}/bar".into(),
14133 });
14134 let err = d.validate().unwrap_err();
14135 assert!(
14136 matches!(
14137 err,
14138 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14139 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14140 ),
14141 "got {err:?}",
14142 );
14143 }
14144
14145 #[test]
14146 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14147 // The paste-from-shell-prompt command-substitution idiom
14148 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14149 // `$VAR` shape so the gate's rationale extends to POSIX shell
14150 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14151 // legacy `` `<cmd>` `` form is already closed by the c370458
14152 // backtick arm). The embedded `(` byte in `$(...)` is also
14153 // caught structurally by the 0633c91 shell-subshell-grouping
14154 // arm which fires earlier in the cascade — the diagnostic
14155 // asserted here is either outcome, since both structurally
14156 // reject the value; the point of the pin is that the value
14157 // never survives validation.
14158 let d = dep_with_fonte(DepSource::Path {
14159 caminho: "../foo$(whoami)/bar".into(),
14160 });
14161 let err = d.validate().unwrap_err();
14162 assert!(
14163 matches!(
14164 err,
14165 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14166 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14167 ),
14168 "got {err:?}",
14169 );
14170 }
14171
14172 #[test]
14173 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14174 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14175 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14176 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14177 // idiom copied into a caminho template). None of the prior
14178 // shell-metachar arms cover this shape (`1` is a bare digit;
14179 // no `(` / `{` / letter follows the `$`), so the arm is the
14180 // sole gate on the shape.
14181 let d = dep_with_fonte(DepSource::Path {
14182 caminho: "../foo$1/bar".into(),
14183 });
14184 let err = d.validate().unwrap_err();
14185 assert!(
14186 matches!(
14187 err,
14188 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14189 ),
14190 "got {err:?}",
14191 );
14192 }
14193
14194 #[test]
14195 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14196 // The positive-control pin (peer with
14197 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14198 // on the immediate-predecessor arm): the gate targets only
14199 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14200 // A relative POSIX path carrying dashes / dots / slashes /
14201 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14202 // validate cleanly so the gate doesn't widen to a "no
14203 // printable punctuation anywhere" sweep that would defeat
14204 // the entire path-fonte author surface.
14205 let d = dep_with_fonte(DepSource::Path {
14206 caminho: "../caixa-teia/sub-dir.v2".into(),
14207 });
14208 d.validate().unwrap();
14209 }
14210
14211 #[test]
14212 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14213 // Cascade pin on the leading-`$` sibling arm at line 540: a
14214 // value starting with `$` and carrying an embedded `$` too
14215 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14216 // fully-templated CI path with two un-substituted variables")
14217 // routes through `FonteCaminhoVarExpansion` not
14218 // `FonteCaminhoShellVariableExpansion`. The leading-byte
14219 // host-layout-leak is the load-bearing self-locating axis
14220 // (the leading position dominates the semantic-locating
14221 // rationale on every probe-as-both value); the embedded
14222 // arm's positional-agnostic sweep catches only values whose
14223 // leading byte doesn't route through the earlier leading-
14224 // byte arms.
14225 let d = dep_with_fonte(DepSource::Path {
14226 caminho: "$HOME/foo$WORKSPACE/bar".into(),
14227 });
14228 let err = d.validate().unwrap_err();
14229 assert!(
14230 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14231 "got {err:?}",
14232 );
14233 }
14234
14235 #[test]
14236 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14237 // Cascade pin on the immediate-predecessor arm: a value
14238 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14239 // — the canonical "I pasted a percent-encoded space adjacent
14240 // to a `$HOME` template") routes through
14241 // `FonteCaminhoUrlPercentEncoding` not
14242 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14243 // encoding-escape byte is the more semantic-locating axis
14244 // (the paste-from-browser-address-bar shape is the load-
14245 // bearing self-locating edit); same cascade discipline every
14246 // prior `:caminho` arm establishes.
14247 let d = dep_with_fonte(DepSource::Path {
14248 caminho: "../foo%20$HOME/bar".into(),
14249 });
14250 let err = d.validate().unwrap_err();
14251 assert!(
14252 matches!(
14253 err,
14254 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14255 ),
14256 "got {err:?}",
14257 );
14258 }
14259
14260 #[test]
14261 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14262 // Cascade pin on the immediate-successor arm: a value
14263 // carrying both embedded `$` and a trailing `/`
14264 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14265 // `$HOME`-template-carrying path") routes through
14266 // `FonteCaminhoShellVariableExpansion` not
14267 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14268 // expansion byte is the more semantic-locating axis on
14269 // probe-as-both values (an author who substitutes the
14270 // `$HOME` template with a literal value is likely to also
14271 // tab-strip the trailing separator).
14272 let d = dep_with_fonte(DepSource::Path {
14273 caminho: "../foo$HOME/bar/".into(),
14274 });
14275 let err = d.validate().unwrap_err();
14276 assert!(
14277 matches!(
14278 err,
14279 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14280 ),
14281 "got {err:?}",
14282 );
14283 }
14284
14285 #[test]
14286 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14287 // Diagnostic-shape pin (peer with
14288 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14289 // on the immediate-predecessor arm): the error's Display
14290 // surfaces the offending `:nome`, the offending `:caminho`
14291 // verbatim, the offending byte's hex / character form, and
14292 // names the shell-variable-expansion / command-substitution
14293 // footgun explicitly so a `feira lint` run can render the
14294 // diagnostic without re-parsing.
14295 let d = dep_with_fonte(DepSource::Path {
14296 caminho: "../foo$HOME/bar".into(),
14297 });
14298 let rendered = d.validate().unwrap_err().to_string();
14299 assert!(
14300 rendered.contains("caixa-teia"),
14301 "diagnostic must name the offending dep: {rendered}",
14302 );
14303 assert!(
14304 rendered.contains("../foo$HOME/bar"),
14305 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14306 );
14307 assert!(
14308 rendered.contains("0x24"),
14309 "diagnostic must surface the offending byte hex: {rendered:?}",
14310 );
14311 assert!(
14312 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14313 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14314 );
14315 assert!(
14316 rendered.contains("command-substitution") || rendered.contains("command substitution"),
14317 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14318 );
14319 }
14320
14321 #[test]
14322 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14323 // The fail-before-pass-after pin for the canonical paste-from-
14324 // shell-history footgun on `:caminho`. An author copies a `cd
14325 // ../caixa-teia && !sudo make install` one-liner from a quick-
14326 // start README, intending the trailing `!sudo` as a shell-
14327 // history-expansion reference but the typed slot is itself a
14328 // byte-level string parser, not a shell context, so the byte
14329 // rides into the value verbatim. Until this arm landed the `!`
14330 // byte silently passed every prior `:caminho` cascade arm
14331 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14332 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14333 // `#` / `%` / `$`); bash with the default `histexpand` mode
14334 // rewrites `!command` to the most recent history entry
14335 // beginning with `command`, the canonical RCE-class injection
14336 // vector when the byte rides into a shell argument executed
14337 // under `bash -i` (the operator-notebook interactive shell).
14338 let d = dep_with_fonte(DepSource::Path {
14339 caminho: "../caixa-teia!sudo".into(),
14340 });
14341 let err = d.validate().unwrap_err();
14342 let DepError::FonteCaminhoShellHistoryExpansion {
14343 nome,
14344 caminho,
14345 byte,
14346 } = err
14347 else {
14348 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14349 };
14350 assert_eq!(nome, "caixa-teia");
14351 assert_eq!(caminho, "../caixa-teia!sudo");
14352 assert_eq!(byte, b'!');
14353 }
14354
14355 #[test]
14356 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14357 // The symmetric `!!` repeat-prior-command paste idiom (peer with
14358 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14359 // on `is_git_repo_url`). Pinned separately from the wrapped
14360 // `!command` shape so a future diagnostic-surface change that
14361 // only checked the leading or paired-bang position surfaces
14362 // here — the per-byte arm fires anywhere `!` appears in the
14363 // value, including at consecutive positions in the middle.
14364 let d = dep_with_fonte(DepSource::Path {
14365 caminho: "../foo!!/bar".into(),
14366 });
14367 let err = d.validate().unwrap_err();
14368 assert!(
14369 matches!(
14370 err,
14371 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14372 ),
14373 "got {err:?}",
14374 );
14375 }
14376
14377 #[test]
14378 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14379 // The English-typography enthusiasm-form paste-from-prose
14380 // idiom: an author writes `:caminho "../caixa-teia!"`
14381 // expecting the substrate to coerce it to a kebab-case slug.
14382 // Pinned separately from the `!<word>` shell-history shape so
14383 // the gate's rationale extends to the paste-from-prose surface
14384 // (the same rationale the peer `is_git_repo_url` bang arm at
14385 // 7d53c68 covers). None of the prior shell-metachar arms cover
14386 // this shape (no `!<word>` reference and no `!!` repeat), so
14387 // the arm is the sole gate on the shape.
14388 let d = dep_with_fonte(DepSource::Path {
14389 caminho: "../caixa-teia!".into(),
14390 });
14391 let err = d.validate().unwrap_err();
14392 assert!(
14393 matches!(
14394 err,
14395 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14396 ),
14397 "got {err:?}",
14398 );
14399 }
14400
14401 #[test]
14402 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14403 // The positive-control pin (peer with
14404 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14405 // on the immediate-predecessor arm): the gate targets only
14406 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14407 // A relative POSIX path carrying dashes / dots / slashes /
14408 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14409 // validate cleanly so the gate doesn't widen to a "no
14410 // printable punctuation anywhere" sweep that would defeat
14411 // the entire path-fonte author surface.
14412 let d = dep_with_fonte(DepSource::Path {
14413 caminho: "../caixa-teia/sub-dir.v2".into(),
14414 });
14415 d.validate().unwrap();
14416 }
14417
14418 #[test]
14419 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14420 // Cascade pin on the immediate-predecessor arm: a value
14421 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14422 // — the canonical "I pasted a `$HOME`-templated path adjacent
14423 // to a trailing `!sudo` history-expansion") routes through
14424 // `FonteCaminhoShellVariableExpansion` not
14425 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14426 // expansion byte is the more semantic-locating axis on
14427 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14428 // template shape is the load-bearing self-locating edit);
14429 // same cascade discipline every prior `:caminho` arm
14430 // establishes.
14431 let d = dep_with_fonte(DepSource::Path {
14432 caminho: "../foo$HOME/bar!sudo".into(),
14433 });
14434 let err = d.validate().unwrap_err();
14435 assert!(
14436 matches!(
14437 err,
14438 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14439 ),
14440 "got {err:?}",
14441 );
14442 }
14443
14444 #[test]
14445 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14446 // Cascade pin on the immediate-successor arm: a value carrying
14447 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14448 // — the canonical "I tab-completed a `!sudo`-carrying path")
14449 // routes through `FonteCaminhoShellHistoryExpansion` not
14450 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14451 // expansion byte is the more semantic-locating axis on probe-
14452 // as-both values (an author who removes the `!sudo` history
14453 // reference is likely to also tab-strip the trailing separator).
14454 let d = dep_with_fonte(DepSource::Path {
14455 caminho: "../caixa-teia!sudo/".into(),
14456 });
14457 let err = d.validate().unwrap_err();
14458 assert!(
14459 matches!(
14460 err,
14461 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14462 ),
14463 "got {err:?}",
14464 );
14465 }
14466
14467 #[test]
14468 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14469 // Diagnostic-shape pin (peer with
14470 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14471 // on the immediate-predecessor arm): the error's Display
14472 // surfaces the offending `:nome`, the offending `:caminho`
14473 // verbatim, the offending byte's hex / character form, and
14474 // names the shell-history-expansion / bang-operator footgun
14475 // explicitly so a `feira lint` run can render the diagnostic
14476 // without re-parsing.
14477 let d = dep_with_fonte(DepSource::Path {
14478 caminho: "../caixa-teia!sudo".into(),
14479 });
14480 let rendered = d.validate().unwrap_err().to_string();
14481 assert!(
14482 rendered.contains("caixa-teia"),
14483 "diagnostic must name the offending dep: {rendered}",
14484 );
14485 assert!(
14486 rendered.contains("../caixa-teia!sudo"),
14487 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14488 );
14489 assert!(
14490 rendered.contains("0x21"),
14491 "diagnostic must surface the offending byte hex: {rendered:?}",
14492 );
14493 assert!(
14494 rendered.contains("history-expansion") || rendered.contains("history expansion"),
14495 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14496 );
14497 assert!(
14498 rendered.contains("bang"),
14499 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14500 );
14501 }
14502
14503 #[test]
14504 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14505 // The fail-before-pass-after pin for the canonical paste-from-
14506 // shell-history-quick-substitution footgun on `:caminho`. An
14507 // author copies a `git clone <bad-url>` line from their terminal,
14508 // corrects it via bash's `^bad^good` quick-substitution history
14509 // operator (bash reference §9.3, `set -o histexpand` mode's
14510 // default for interactive sessions), and pastes the trailing
14511 // `^bad^good` substitution fragment into a `:caminho` value
14512 // without trimming the leading `git clone` prefix — the byte
14513 // rides into the manifest verbatim. Until this arm landed the
14514 // `^` byte silently passed every prior `:caminho` cascade arm
14515 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14516 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14517 // `%` / `$` / `!`); bash with the default `histexpand` mode
14518 // rewrites the prior command's `bad` string to `good` and re-
14519 // executes it, the paired-operator half of the `set -o
14520 // histexpand` feature the peer `!` arm already closes the prefix
14521 // half of. The peer `is_git_repo_url` axis rejects the byte at
14522 // 49e142f under the same shell-history-substitution / RFC-3986-
14523 // unwise banner.
14524 let d = dep_with_fonte(DepSource::Path {
14525 caminho: "../foo^bad^good".into(),
14526 });
14527 let err = d.validate().unwrap_err();
14528 let DepError::FonteCaminhoShellHistorySubstitution {
14529 nome,
14530 caminho,
14531 byte,
14532 } = err
14533 else {
14534 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14535 };
14536 assert_eq!(nome, "caixa-teia");
14537 assert_eq!(caminho, "../foo^bad^good");
14538 assert_eq!(byte, b'^');
14539 }
14540
14541 #[test]
14542 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14543 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14544 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14545 // on `is_git_repo_url`). An author copies a `grep '^archived'`
14546 // regex-anchor / negation idiom from a doc snippet and the byte
14547 // rides in verbatim. Pinned separately from the `^old^new^`
14548 // quick-substitution shape so a future diagnostic-surface change
14549 // that only checked the paired-caret history-substitution
14550 // position surfaces here — the per-byte arm fires anywhere `^`
14551 // appears in the value, including at a solitary leading-of-
14552 // segment position.
14553 let d = dep_with_fonte(DepSource::Path {
14554 caminho: "../foo/^archived".into(),
14555 });
14556 let err = d.validate().unwrap_err();
14557 assert!(
14558 matches!(
14559 err,
14560 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14561 ),
14562 "got {err:?}",
14563 );
14564 }
14565
14566 #[test]
14567 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14568 // The trailing-`^` history-substitution-open shape — an author
14569 // starts typing a `^bad^good` quick-substitution but pastes only
14570 // the leading `^` sentinel before context-switching (a bash-
14571 // reference §9.3 valid histexpand prefix on its own — even a
14572 // solitary `^` on the prior command's whole re-execution shape).
14573 // Pinned separately from the `^old^new^` full-form and the leading-
14574 // of-segment `^archived` regex-anchor shape so the gate's
14575 // rationale extends to the paste-from-shell-history-with-only-
14576 // the-first-byte-selected surface. None of the prior shell-
14577 // metachar arms cover this shape.
14578 let d = dep_with_fonte(DepSource::Path {
14579 caminho: "../caixa-teia^".into(),
14580 });
14581 let err = d.validate().unwrap_err();
14582 assert!(
14583 matches!(
14584 err,
14585 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14586 ),
14587 "got {err:?}",
14588 );
14589 }
14590
14591 #[test]
14592 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14593 // The positive-control pin (peer with
14594 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14595 // on the immediate-predecessor arm): the gate targets only
14596 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14597 // A relative POSIX path carrying dashes / dots / slashes /
14598 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14599 // continue to validate cleanly so the gate doesn't widen to
14600 // a "no printable punctuation anywhere" sweep that would
14601 // defeat the entire path-fonte author surface.
14602 let d = dep_with_fonte(DepSource::Path {
14603 caminho: "../caixa-teia/sub_v2.rc".into(),
14604 });
14605 d.validate().unwrap();
14606 }
14607
14608 #[test]
14609 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14610 // Cascade pin on the immediate-predecessor arm: a value carrying
14611 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14612 // canonical "I pasted a `!sudo` history-reference next to a
14613 // `^bad^good` quick-substitution") routes through
14614 // `FonteCaminhoShellHistoryExpansion` not
14615 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14616 // the more semantic-locating axis on probe-as-both values (an
14617 // author who removes the `!sudo` reference is likely to also
14618 // strip the paired `^` substitution fragment); same cascade
14619 // discipline every prior `:caminho` arm establishes.
14620 let d = dep_with_fonte(DepSource::Path {
14621 caminho: "../foo!sudo^bad^good".into(),
14622 });
14623 let err = d.validate().unwrap_err();
14624 assert!(
14625 matches!(
14626 err,
14627 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14628 ),
14629 "got {err:?}",
14630 );
14631 }
14632
14633 #[test]
14634 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14635 // Cascade pin on the immediate-successor arm: a value carrying
14636 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14637 // the canonical "I tab-completed a `^bad^good`-carrying path")
14638 // routes through `FonteCaminhoShellHistorySubstitution` not
14639 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14640 // substitution byte is the more semantic-locating axis on probe-
14641 // as-both values (an author who removes the `^bad^good`
14642 // substitution fragment is likely to also tab-strip the trailing
14643 // separator).
14644 let d = dep_with_fonte(DepSource::Path {
14645 caminho: "../foo^bad^good/".into(),
14646 });
14647 let err = d.validate().unwrap_err();
14648 assert!(
14649 matches!(
14650 err,
14651 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14652 ),
14653 "got {err:?}",
14654 );
14655 }
14656
14657 #[test]
14658 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14659 {
14660 // Diagnostic-shape pin (peer with
14661 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14662 // on the immediate-predecessor arm): the error's Display
14663 // surfaces the offending `:nome`, the offending `:caminho`
14664 // verbatim, the offending byte's hex form, and names the
14665 // shell-history-substitution / RFC-3986-'unwise' / regex-
14666 // negation footgun explicitly so a `feira lint` run can render
14667 // the diagnostic without re-parsing.
14668 let d = dep_with_fonte(DepSource::Path {
14669 caminho: "../foo^bad^good".into(),
14670 });
14671 let rendered = d.validate().unwrap_err().to_string();
14672 assert!(
14673 rendered.contains("caixa-teia"),
14674 "diagnostic must name the offending dep: {rendered}",
14675 );
14676 assert!(
14677 rendered.contains("../foo^bad^good"),
14678 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14679 );
14680 assert!(
14681 rendered.contains("0x5e") || rendered.contains("0x5E"),
14682 "diagnostic must surface the offending byte hex: {rendered:?}",
14683 );
14684 assert!(
14685 rendered.contains("history-substitution") || rendered.contains("history substitution"),
14686 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14687 );
14688 assert!(
14689 rendered.contains("unwise"),
14690 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14691 );
14692 }
14693
14694 #[test]
14695 fn fonte_repo_empty_fires_before_pin_missing() {
14696 // Order pin: empty `:repo` is the more self-locating diagnostic
14697 // (every git source needs a repo; the pin discussion is
14698 // secondary), so it fires before the pin-missing arm even when
14699 // both are violated. Mirrors the
14700 // `nome_empty_takes_precedence_over_versao_invalid` ordering
14701 // discipline on the per-entry layer.
14702 let d = dep_with_fonte(DepSource::Git {
14703 repo: String::new(),
14704 tag: None,
14705 rev: None,
14706 branch: None,
14707 });
14708 let err = d.validate().unwrap_err();
14709 assert!(
14710 matches!(err, DepError::FonteRepoEmpty { .. }),
14711 "got {err:?}"
14712 );
14713 }
14714
14715 #[test]
14716 fn fonte_pin_missing_fires_before_pin_empty() {
14717 // Order pin: a fully-None pin set is structurally distinct from
14718 // a Some(empty) pin — the first surfaces as FontePinMissing
14719 // (no axis chosen), the second as FontePinEmpty (axis chosen
14720 // but value blank). Pin the disjoint relationship so a future
14721 // unification collapses to one variant only as a structural
14722 // decision.
14723 let d = dep_with_fonte(DepSource::Git {
14724 repo: "github:pleme-io/caixa-teia".into(),
14725 tag: None,
14726 rev: None,
14727 branch: None,
14728 });
14729 assert!(matches!(
14730 d.validate().unwrap_err(),
14731 DepError::FontePinMissing { .. }
14732 ));
14733 }
14734
14735 #[test]
14736 fn nome_empty_takes_precedence_over_fonte_invalid() {
14737 // Order pin: a per-entry diagnostic without a non-empty :nome
14738 // can't be self-locating, so :nome "" fires first even when
14739 // :fonte is also malformed. Mirrors
14740 // `nome_empty_takes_precedence_over_versao_invalid` on the
14741 // adjacent axis.
14742 let mut d = dep_with_fonte(DepSource::Git {
14743 repo: String::new(),
14744 tag: None,
14745 rev: None,
14746 branch: None,
14747 });
14748 d.nome = String::new();
14749 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14750 }
14751
14752 #[test]
14753 fn versao_invalid_takes_precedence_over_fonte_invalid() {
14754 // Order pin: the :versao parse-side diagnostic is narrower than
14755 // the :fonte shape diagnostic — a malformed :versao always names
14756 // the parser's reason, which is more actionable than the
14757 // :fonte gate's "the pins are wrong" wording. Pin the ordering
14758 // so a re-ordering surfaces here.
14759 let mut d = dep_with_fonte(DepSource::Git {
14760 repo: String::new(),
14761 tag: None,
14762 rev: None,
14763 branch: None,
14764 });
14765 d.versao = "v0.1".into();
14766 let err = d.validate().unwrap_err();
14767 assert!(
14768 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14769 "got {err:?}"
14770 );
14771 }
14772
14773 #[test]
14774 fn fonte_invalid_diagnostic_carries_offending_nome() {
14775 // The diagnostic-shape pin: every :fonte error variant names
14776 // the offending dep's :nome verbatim, so the author can grep
14777 // caixa.lisp for the `:nome "<n>"` block and fix it in one
14778 // edit. Cover all seven variants so a future variant addition
14779 // forces a parallel diagnostic-shape decision.
14780 for (case, fonte) in [
14781 (
14782 "repo-empty",
14783 DepSource::Git {
14784 repo: String::new(),
14785 tag: Some("v1".into()),
14786 rev: None,
14787 branch: None,
14788 },
14789 ),
14790 (
14791 "repo-shape",
14792 DepSource::Git {
14793 repo: "github:p/x ".into(),
14794 tag: Some("v1".into()),
14795 rev: None,
14796 branch: None,
14797 },
14798 ),
14799 (
14800 "pin-missing",
14801 DepSource::Git {
14802 repo: "github:p/x".into(),
14803 tag: None,
14804 rev: None,
14805 branch: None,
14806 },
14807 ),
14808 (
14809 "pin-ambiguous",
14810 DepSource::Git {
14811 repo: "github:p/x".into(),
14812 tag: Some("v1".into()),
14813 rev: None,
14814 branch: Some("main".into()),
14815 },
14816 ),
14817 (
14818 "pin-empty",
14819 DepSource::Git {
14820 repo: "github:p/x".into(),
14821 tag: Some(String::new()),
14822 rev: None,
14823 branch: None,
14824 },
14825 ),
14826 (
14827 "caminho-empty",
14828 DepSource::Path {
14829 caminho: String::new(),
14830 },
14831 ),
14832 (
14833 "caminho-absolute",
14834 DepSource::Path {
14835 caminho: "/home/me/work/caixa-teia".into(),
14836 },
14837 ),
14838 ] {
14839 let d = dep_with_fonte(fonte);
14840 let msg = d
14841 .validate()
14842 .expect_err(&format!("{case}: expected fonte error"))
14843 .to_string();
14844 assert!(
14845 msg.contains("\"caixa-teia\""),
14846 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14847 );
14848 }
14849 }
14850
14851 // -- :tag / :branch value-shape gate ----------------------------------
14852
14853 #[test]
14854 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14855 // The canonical paste-from-doc footgun on `:tag` — author
14856 // copies `"v0.1.0 "` (trailing space) out of a release-notes
14857 // paragraph. Until this gate landed the empty-pin arm passed
14858 // (the string isn't empty), the resolver issued
14859 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14860 // surfaced at clone time with a quoting-confused git error
14861 // far from the source caixa.lisp. The new gate moves the
14862 // check to caixa-build time and names the offending dep +
14863 // pin + value verbatim.
14864 let d = dep_with_fonte(DepSource::Git {
14865 repo: "github:pleme-io/caixa-teia".into(),
14866 tag: Some("v0.1.0 ".into()),
14867 rev: None,
14868 branch: None,
14869 });
14870 let err = d.validate().unwrap_err();
14871 let DepError::FontePinShape {
14872 nome,
14873 pin,
14874 value,
14875 reason,
14876 } = err
14877 else {
14878 panic!("expected FontePinShape, got other variant");
14879 };
14880 assert_eq!(nome, "caixa-teia");
14881 assert_eq!(pin, ":tag");
14882 assert_eq!(value, "v0.1.0 ");
14883 assert!(
14884 reason.contains("whitespace"),
14885 "reason must surface the whitespace arm, got {reason:?}"
14886 );
14887 }
14888
14889 #[test]
14890 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14891 // The `.lock` suffix is git's atomic-rename guard for
14892 // in-flight ref updates — a refname ending in `.lock` is
14893 // unwritable on disk. Pinned separately from the whitespace
14894 // arm so a future relaxation that admits one but not the
14895 // other surfaces here.
14896 let d = dep_with_fonte(DepSource::Git {
14897 repo: "github:pleme-io/caixa-teia".into(),
14898 tag: Some("v0.1.0.lock".into()),
14899 rev: None,
14900 branch: None,
14901 });
14902 let err = d.validate().unwrap_err();
14903 let DepError::FontePinShape {
14904 pin, value, reason, ..
14905 } = err
14906 else {
14907 panic!("expected FontePinShape, got other variant");
14908 };
14909 assert_eq!(pin, ":tag");
14910 assert_eq!(value, "v0.1.0.lock");
14911 assert!(
14912 reason.contains(".lock"),
14913 "reason must surface the .lock arm, got {reason:?}"
14914 );
14915 }
14916
14917 #[test]
14918 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14919 // The canonical "branch name with spaces" footgun (`feature
14920 // foo`, `release branch`) — git's refname parser rejects raw
14921 // whitespace, and the failure surfaces at `git checkout
14922 // 'feature foo'` time with a quoting-confused error far from
14923 // the source caixa.lisp. Pinned on the `:branch` axis so the
14924 // gate-applies-to-both-:tag-and-:branch contract is a build-
14925 // error to relax.
14926 let d = dep_with_fonte(DepSource::Git {
14927 repo: "github:pleme-io/caixa-teia".into(),
14928 tag: None,
14929 rev: None,
14930 branch: Some("feature/foo bar".into()),
14931 });
14932 let err = d.validate().unwrap_err();
14933 let DepError::FontePinShape {
14934 pin, value, reason, ..
14935 } = err
14936 else {
14937 panic!("expected FontePinShape, got other variant");
14938 };
14939 assert_eq!(pin, ":branch");
14940 assert_eq!(value, "feature/foo bar");
14941 assert!(
14942 reason.contains("whitespace"),
14943 "reason must surface the whitespace arm, got {reason:?}"
14944 );
14945 }
14946
14947 #[test]
14948 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14949 // The `refs/heads/main` shape — the canonical "I copied the
14950 // fully-qualified ref out of `git show-ref` instead of the
14951 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14952 // at clone time, so this resolves to a literal ref named
14953 // `refs/heads/refs/heads/main` on disk; the silent double-
14954 // prefix is the load-bearing reason to gate at validate.
14955 // The diagnostic must enumerate the leaf the author probably
14956 // meant (`"main"`) so the fix is one edit.
14957 let d = dep_with_fonte(DepSource::Git {
14958 repo: "github:pleme-io/caixa-teia".into(),
14959 tag: None,
14960 rev: None,
14961 branch: Some("refs/heads/main".into()),
14962 });
14963 let err = d.validate().unwrap_err();
14964 let DepError::FontePinShape {
14965 pin, value, reason, ..
14966 } = err
14967 else {
14968 panic!("expected FontePinShape, got other variant");
14969 };
14970 assert_eq!(pin, ":branch");
14971 assert_eq!(value, "refs/heads/main");
14972 assert!(
14973 reason.contains("fully-qualified"),
14974 "reason must surface the qualified-prefix arm, got {reason:?}"
14975 );
14976 assert!(
14977 reason.contains("\"main\""),
14978 "reason must quote the leaf the author probably meant, got {reason:?}"
14979 );
14980 }
14981
14982 #[test]
14983 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14984 // Sibling arm of the qualified-prefix gate on the `:tag`
14985 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14986 // footgun). Pinned separately so a future relaxation that
14987 // only catches the `:branch` arm surfaces here.
14988 let d = dep_with_fonte(DepSource::Git {
14989 repo: "github:pleme-io/caixa-teia".into(),
14990 tag: Some("refs/tags/v0.1.0".into()),
14991 rev: None,
14992 branch: None,
14993 });
14994 let err = d.validate().unwrap_err();
14995 let DepError::FontePinShape {
14996 pin, value, reason, ..
14997 } = err
14998 else {
14999 panic!("expected FontePinShape, got other variant");
15000 };
15001 assert_eq!(pin, ":tag");
15002 assert_eq!(value, "refs/tags/v0.1.0");
15003 assert!(
15004 reason.contains("fully-qualified"),
15005 "reason must surface the qualified-prefix arm, got {reason:?}"
15006 );
15007 assert!(
15008 reason.contains("\"v0.1.0\""),
15009 "reason must quote the leaf the author probably meant, got {reason:?}"
15010 );
15011 }
15012
15013 #[test]
15014 fn validate_rejects_git_fonte_with_branch_named_at() {
15015 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15016 // unsourceable. Pinned so a future relaxation that admits
15017 // any single-character refname surfaces here.
15018 let d = dep_with_fonte(DepSource::Git {
15019 repo: "github:pleme-io/caixa-teia".into(),
15020 tag: None,
15021 rev: None,
15022 branch: Some("@".into()),
15023 });
15024 let err = d.validate().unwrap_err();
15025 let DepError::FontePinShape { pin, value, .. } = err else {
15026 panic!("expected FontePinShape, got other variant");
15027 };
15028 assert_eq!(pin, ":branch");
15029 assert_eq!(value, "@");
15030 }
15031
15032 #[test]
15033 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15034 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15035 // a `:tag "../escape"` (path-traversal-shaped slug) silently
15036 // passes parse and surfaces as a refname-parse error or, on
15037 // older git, a literal `../escape` checkout that escapes the
15038 // refs/ directory tree. Pinned separately from the
15039 // qualified-prefix arm so a future relaxation that catches
15040 // one but not the other surfaces here.
15041 let d = dep_with_fonte(DepSource::Git {
15042 repo: "github:pleme-io/caixa-teia".into(),
15043 tag: Some("../escape".into()),
15044 rev: None,
15045 branch: None,
15046 });
15047 let err = d.validate().unwrap_err();
15048 let DepError::FontePinShape { pin, value, .. } = err else {
15049 panic!("expected FontePinShape, got other variant");
15050 };
15051 assert_eq!(pin, ":tag");
15052 assert_eq!(value, "../escape");
15053 }
15054
15055 #[test]
15056 fn validate_accepts_git_fonte_with_hierarchical_branch() {
15057 // The positive-control pin: hierarchical refnames with one or
15058 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15059 // canonical idiom) round-trip through the gate. Pinned
15060 // separately from the leaf-`"main"` positive control so a
15061 // future tightening that rejects all multi-component refnames
15062 // surfaces here.
15063 let d = dep_with_fonte(DepSource::Git {
15064 repo: "github:pleme-io/caixa-teia".into(),
15065 tag: None,
15066 rev: None,
15067 branch: Some("feature/checkout-rewrite".into()),
15068 });
15069 d.validate().unwrap();
15070 }
15071
15072 #[test]
15073 fn validate_accepts_git_fonte_with_prerelease_tag() {
15074 // The positive-control pin: semver pre-release shape
15075 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15076 // (only consecutive `..` and trailing `.` are rejected), the
15077 // mid-component hyphen is allowed. Pinned separately from
15078 // the bare-`"v0.1.0"` positive control so a future tightening
15079 // that rejects pre-release tags surfaces here.
15080 let d = dep_with_fonte(DepSource::Git {
15081 repo: "github:pleme-io/caixa-teia".into(),
15082 tag: Some("v0.1.0-alpha.1".into()),
15083 rev: None,
15084 branch: None,
15085 });
15086 d.validate().unwrap();
15087 }
15088
15089 #[test]
15090 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15091 // The `:rev` axis is routed through `crate::render::is_git_oid`
15092 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15093 // value with refname-shape punctuation (here, a `:` mid-string
15094 // — would be a refname violation under `is_git_ref_name` too)
15095 // is rejected at the OID-shape gate. The two predicates
15096 // partition the `:fonte` pin axes structurally: an `:rev` value
15097 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15098 // *still* rejected here because every refname character outside
15099 // `[0-9a-f]` fails the OID gate. Same shape as
15100 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15101 // on the refname-shaped axes — the diagnostic names the
15102 // offending dep + pin + value verbatim. The flip-from-accept
15103 // case the prior `:tag`/`:branch` gate left as a "future axis"
15104 // (e70d213) — now landed.
15105 let d = dep_with_fonte(DepSource::Git {
15106 repo: "github:pleme-io/caixa-teia".into(),
15107 tag: None,
15108 rev: Some("c0ffee:notarefname".into()),
15109 branch: None,
15110 });
15111 let err = d.validate().unwrap_err();
15112 let DepError::FontePinShape {
15113 nome,
15114 pin,
15115 value,
15116 reason,
15117 } = err
15118 else {
15119 panic!("expected FontePinShape, got other variant");
15120 };
15121 assert_eq!(nome, "caixa-teia");
15122 assert_eq!(pin, ":rev");
15123 assert_eq!(value, "c0ffee:notarefname");
15124 assert!(
15125 !reason.is_empty(),
15126 "FontePinShape `reason` must carry the predicate's wording verbatim"
15127 );
15128 }
15129
15130 #[test]
15131 fn validate_accepts_git_fonte_with_rev_full_sha1() {
15132 // The positive-control pin on the SHA-1 OID width: exactly 40
15133 // lowercase hex characters — the canonical `git rev-parse HEAD`
15134 // emission on a SHA-1-hashed repository (the default on every
15135 // pre-2.42 git and the canonical pleme-io substrate hash).
15136 // Pinned separately from the SHA-256 positive control so a
15137 // future tightening that only admits one width surfaces here.
15138 let d = dep_with_fonte(DepSource::Git {
15139 repo: "github:pleme-io/caixa-teia".into(),
15140 tag: None,
15141 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15142 branch: None,
15143 });
15144 d.validate().unwrap();
15145 }
15146
15147 #[test]
15148 fn validate_accepts_git_fonte_with_rev_full_sha256() {
15149 // The positive-control pin on the SHA-256 OID width: exactly
15150 // 64 lowercase hex characters — `git`'s
15151 // `extensions.objectFormat = sha256` emission (GA since Git
15152 // 2.42 / Oct 2023). The substrate admits either canonical
15153 // width so an `:rev` authored against a SHA-256-hashed
15154 // upstream round-trips through the gate without per-repo
15155 // configuration. Pinned separately from the SHA-1 positive
15156 // control so a future tightening that drops one width surfaces
15157 // here as a structural decision.
15158 let d = dep_with_fonte(DepSource::Git {
15159 repo: "github:pleme-io/caixa-teia".into(),
15160 tag: None,
15161 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15162 branch: None,
15163 });
15164 d.validate().unwrap();
15165 }
15166
15167 #[test]
15168 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15169 // The canonical `git log --short` / `git rev-parse --short HEAD`
15170 // paste-from-release-notes footgun: a 7-char prefix (git's
15171 // default `core.abbrev`) silently passes string emptiness
15172 // checks and resolves to one commit today, but becomes ambiguous
15173 // tomorrow as the repo grows. Until this gate landed the empty-
15174 // pin arm passed (the string isn't empty) and the resolver
15175 // accepted the prefix through git's separate prefix-lookup pass
15176 // — defeating the reproducibility contract `:rev` carries vs.
15177 // `:tag` / `:branch`. The new gate moves the check to caixa-
15178 // build time and names the offending dep + pin + value verbatim.
15179 let d = dep_with_fonte(DepSource::Git {
15180 repo: "github:pleme-io/caixa-teia".into(),
15181 tag: None,
15182 rev: Some("c0ffee0".into()),
15183 branch: None,
15184 });
15185 let err = d.validate().unwrap_err();
15186 let DepError::FontePinShape {
15187 pin, value, reason, ..
15188 } = err
15189 else {
15190 panic!("expected FontePinShape, got other variant");
15191 };
15192 assert_eq!(pin, ":rev");
15193 assert_eq!(value, "c0ffee0");
15194 assert!(
15195 reason.contains("abbreviated") || reason.contains("ambiguous"),
15196 "reason must surface the abbreviation arm, got {reason:?}"
15197 );
15198 }
15199
15200 #[test]
15201 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15202 // The canonical "I pasted the SHA in uppercase" footgun: `git
15203 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15204 // bearing `:rev` round-trips inconsistently across the
15205 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15206 // equality-check pipeline and fails the lacre's content-
15207 // addressing probe with a confusing case-only diff. Pinned
15208 // separately from the non-hex arm so a future relaxation that
15209 // admits one but not the other surfaces here.
15210 let d = dep_with_fonte(DepSource::Git {
15211 repo: "github:pleme-io/caixa-teia".into(),
15212 tag: None,
15213 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15214 branch: None,
15215 });
15216 let err = d.validate().unwrap_err();
15217 let DepError::FontePinShape {
15218 pin, value, reason, ..
15219 } = err
15220 else {
15221 panic!("expected FontePinShape, got other variant");
15222 };
15223 assert_eq!(pin, ":rev");
15224 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15225 assert!(
15226 reason.contains("uppercase"),
15227 "reason must surface the uppercase arm, got {reason:?}"
15228 );
15229 }
15230
15231 #[test]
15232 fn validate_rejects_git_fonte_with_rev_refname_value() {
15233 // The cross-axis mis-slot footgun: `:rev "main"` — the author
15234 // conflated `:rev` (hex commit ID, immutable) and `:branch`
15235 // (mutable ref pointing at whatever HEAD is today). Until this
15236 // gate landed the resolver silently dispatched on the value
15237 // shape ("`main` doesn't look like a SHA, fall back to
15238 // refname"), defeating the `:rev` reproducibility contract.
15239 // The new gate rejects every non-hex value on the `:rev` axis,
15240 // so the `:rev`/`:branch` boundary is structurally enforced —
15241 // a refname in the `:rev` slot is a build error, not a
15242 // resolver-time silent reinterpretation.
15243 let d = dep_with_fonte(DepSource::Git {
15244 repo: "github:pleme-io/caixa-teia".into(),
15245 tag: None,
15246 rev: Some("main".into()),
15247 branch: None,
15248 });
15249 let err = d.validate().unwrap_err();
15250 let DepError::FontePinShape {
15251 pin, value, reason, ..
15252 } = err
15253 else {
15254 panic!("expected FontePinShape, got other variant");
15255 };
15256 assert_eq!(pin, ":rev");
15257 assert_eq!(value, "main");
15258 // 4 chars `main` fails the length arm before the character arm,
15259 // so the diagnostic surfaces the abbreviation wording (same
15260 // path the `c0ffee0` 7-char fixture lands on); the structural
15261 // assertion is just that the `:rev "main"` value is rejected.
15262 assert!(
15263 !reason.is_empty(),
15264 "FontePinShape reason must be non-empty for refname-shaped :rev"
15265 );
15266 }
15267
15268 #[test]
15269 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15270 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15271 // conflated `:rev` and `:tag`. Pinned separately from the
15272 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15273 // that catches one but not the other surfaces here. The
15274 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15275 // assertion is just that the cross-axis mis-slot is a build
15276 // error, regardless of which sub-arm surfaces the diagnostic
15277 // (`is_git_oid` rejects at the first violation; longer
15278 // tag-shape values would hit the non-hex arm instead).
15279 let d = dep_with_fonte(DepSource::Git {
15280 repo: "github:pleme-io/caixa-teia".into(),
15281 tag: None,
15282 rev: Some("v0.1.0".into()),
15283 branch: None,
15284 });
15285 let err = d.validate().unwrap_err();
15286 let DepError::FontePinShape {
15287 pin, value, reason, ..
15288 } = err
15289 else {
15290 panic!("expected FontePinShape, got other variant");
15291 };
15292 assert_eq!(pin, ":rev");
15293 assert_eq!(value, "v0.1.0");
15294 assert!(
15295 !reason.is_empty(),
15296 "FontePinShape reason must be non-empty for tag-shaped :rev"
15297 );
15298 }
15299
15300 #[test]
15301 fn validate_rejects_git_fonte_with_rev_too_long() {
15302 // Boundary case on the upper end: 41 hex chars — one past the
15303 // SHA-1 width, well below the SHA-256 width. Pin so a future
15304 // relaxation that admits "long enough to be a SHA" without
15305 // matching either canonical width surfaces here. The diagnostic
15306 // names the offending length verbatim so the author's grep
15307 // target is unambiguous (either trim one char or paste the
15308 // full SHA-256).
15309 let too_long: String = "0".repeat(41);
15310 let d = dep_with_fonte(DepSource::Git {
15311 repo: "github:pleme-io/caixa-teia".into(),
15312 tag: None,
15313 rev: Some(too_long.clone()),
15314 branch: None,
15315 });
15316 let err = d.validate().unwrap_err();
15317 let DepError::FontePinShape {
15318 pin, value, reason, ..
15319 } = err
15320 else {
15321 panic!("expected FontePinShape, got other variant");
15322 };
15323 assert_eq!(pin, ":rev");
15324 assert_eq!(value, too_long);
15325 assert!(
15326 reason.contains("41"),
15327 "reason must surface the offending length verbatim, got {reason:?}"
15328 );
15329 }
15330
15331 #[test]
15332 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15333 // The canonical paste-from-doc footgun on `:rev` — author
15334 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15335 // commit-message paragraph. Until this gate landed the empty-
15336 // pin arm passed (the string isn't empty), the resolver issued
15337 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15338 // clone time with a quoting-confused git error far from the
15339 // source caixa.lisp. The new gate moves the check to caixa-
15340 // build time. Length is 41 (40 hex + space) so the length arm
15341 // fires first — pinned separately from the pure-length arm to
15342 // ensure the diagnostic surfaces *some* parser wording, not
15343 // silently pass through.
15344 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15345 let d = dep_with_fonte(DepSource::Git {
15346 repo: "github:pleme-io/caixa-teia".into(),
15347 tag: None,
15348 rev: Some(with_space.clone()),
15349 branch: None,
15350 });
15351 let err = d.validate().unwrap_err();
15352 let DepError::FontePinShape {
15353 pin, value, reason, ..
15354 } = err
15355 else {
15356 panic!("expected FontePinShape, got other variant");
15357 };
15358 assert_eq!(pin, ":rev");
15359 assert_eq!(value, with_space);
15360 assert!(
15361 !reason.is_empty(),
15362 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15363 );
15364 }
15365
15366 #[test]
15367 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15368 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15369 // variant on this axis names the offending dep's `:nome` + the
15370 // `:rev` axis + the offending value verbatim, so the author's
15371 // grep target is the literal `:rev "<value>"` block in
15372 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15373 // carries_offending_nome_pin_value` test on the refname-shaped
15374 // (`:tag` / `:branch`) axes.
15375 let d = dep_with_fonte(DepSource::Git {
15376 repo: "github:p/x".into(),
15377 tag: None,
15378 rev: Some("not-a-sha".into()),
15379 branch: None,
15380 });
15381 let msg = d
15382 .validate()
15383 .expect_err(":rev: expected FontePinShape")
15384 .to_string();
15385 assert!(
15386 msg.contains("\"caixa-teia\""),
15387 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15388 );
15389 assert!(
15390 msg.contains(":rev"),
15391 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15392 );
15393 assert!(
15394 msg.contains("not-a-sha"),
15395 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15396 );
15397 }
15398
15399 #[test]
15400 fn fonte_pin_empty_fires_before_pin_shape() {
15401 // Order pin: a `Some("")` `:tag` is the more self-locating
15402 // diagnostic (the author chose an axis but left it blank;
15403 // grep is unambiguous), so it fires before the shape gate
15404 // even when both arms would match. Pinned so a future
15405 // reordering surfaces here. Mirrors the
15406 // `fonte_repo_empty_fires_before_pin_missing` ordering
15407 // discipline on the peer per-axis arms.
15408 let d = dep_with_fonte(DepSource::Git {
15409 repo: "github:pleme-io/caixa-teia".into(),
15410 tag: Some(String::new()),
15411 rev: None,
15412 branch: None,
15413 });
15414 assert!(matches!(
15415 d.validate().unwrap_err(),
15416 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15417 ));
15418 }
15419
15420 #[test]
15421 fn fonte_pin_shape_fires_after_repo_empty() {
15422 // Order pin: `:repo ""` is the more self-locating axis
15423 // (every git source needs a repo; the per-pin shape gate is
15424 // secondary), so the repo-empty arm fires before the
15425 // per-pin shape arm even when both are violated. Pinned so
15426 // a future reordering surfaces here. Mirrors
15427 // `fonte_repo_empty_fires_before_pin_missing` on the
15428 // adjacent axis pair.
15429 let d = dep_with_fonte(DepSource::Git {
15430 repo: String::new(),
15431 tag: Some("v0.1.0 ".into()),
15432 rev: None,
15433 branch: None,
15434 });
15435 assert!(matches!(
15436 d.validate().unwrap_err(),
15437 DepError::FonteRepoEmpty { .. }
15438 ));
15439 }
15440
15441 #[test]
15442 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15443 // Diagnostic-shape pin across both refname-shaped axes
15444 // (`:tag` + `:branch`): every `FontePinShape` variant names
15445 // the offending dep's `:nome` + the offending pin axis + the
15446 // offending value verbatim, so the author's grep target is
15447 // unambiguous (the literal `:tag "<value>"` / `:branch
15448 // "<value>"` lands in caixa.lisp with quotes). Cover both
15449 // pin axes so a future variant addition forces a parallel
15450 // diagnostic-shape decision.
15451 for (pin_label, fonte) in [
15452 (
15453 ":tag",
15454 DepSource::Git {
15455 repo: "github:p/x".into(),
15456 tag: Some("v0.1.0~1".into()),
15457 rev: None,
15458 branch: None,
15459 },
15460 ),
15461 (
15462 ":branch",
15463 DepSource::Git {
15464 repo: "github:p/x".into(),
15465 tag: None,
15466 rev: None,
15467 branch: Some("feature/foo*".into()),
15468 },
15469 ),
15470 ] {
15471 let d = dep_with_fonte(fonte);
15472 let msg = d
15473 .validate()
15474 .expect_err(&format!("{pin_label}: expected FontePinShape"))
15475 .to_string();
15476 assert!(
15477 msg.contains("\"caixa-teia\""),
15478 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15479 );
15480 assert!(
15481 msg.contains(pin_label),
15482 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15483 );
15484 }
15485 }
15486
15487 #[test]
15488 fn git_source_json_round_trip() {
15489 let src = DepSource::Git {
15490 repo: "github:pleme-io/caixa-teia".into(),
15491 tag: Some("v0.1.0".into()),
15492 rev: None,
15493 branch: None,
15494 };
15495 let s = serde_json::to_string(&src).unwrap();
15496 assert!(s.contains(&format!(
15497 r#""{tipo}":"{git}""#,
15498 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15499 git = crate::render::DEP_SOURCE_TIPO_GIT,
15500 )));
15501 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15502 assert!(s.contains(r#""tag":"v0.1.0""#));
15503 assert!(!s.contains("rev"));
15504 assert!(!s.contains("branch"));
15505 let round: DepSource = serde_json::from_str(&s).unwrap();
15506 assert_eq!(round, src);
15507 }
15508
15509 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15510 //
15511 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15512 // attribute on [`DepSource`] pins three load-bearing byte-sequences
15513 // that flow into every serialized `Dep.fonte` block: the outer
15514 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15515 // the two admitted variant-tag values `"git"` / `"path"` the
15516 // `rename_all = "lowercase"` attribute pins as the discriminator's
15517 // closed-set arms. The three pin tests below round-trip a
15518 // fully-populated variant of each arm through
15519 // [`serde_json::to_value`] and assert each canonical byte-sequence
15520 // appears at its axis — pins a hypothetical future
15521 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15522 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15523 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15524 // at build time rather than at fetch time when the resolver's
15525 // `Dep.fonte` dispatch silently fails to match on the drifted
15526 // discriminator. Same "serialize-and-check" discipline the peer
15527 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15528 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15529 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15530 // family in caixa-core lacking a lifted peer.
15531
15532 #[test]
15533 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15534 // Fail-before-pass-after: a future `tag = "type"` at the derive
15535 // attribute would serialize under `"type":"git"`, and this test
15536 // would trip because `"tipo"` no longer appears at the emitted
15537 // discriminator key. A future `rename_all = "kebab-case"` /
15538 // `"snake_case"` (both no-ops on `Git` since it lacks internal
15539 // word boundaries) is caught by the sibling
15540 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15541 // pin below (Path has no internal boundary either but the pair
15542 // catches any per-arm inconsistency). A future variant rename
15543 // `Git` → `Repository` would emit `"tipo":"repository"` and
15544 // trip this pin.
15545 let src = DepSource::Git {
15546 repo: "github:pleme-io/caixa-teia".into(),
15547 tag: Some("v0.1.0".into()),
15548 rev: None,
15549 branch: None,
15550 };
15551 let json = serde_json::to_value(&src).unwrap();
15552 let obj = json.as_object().expect("Git serializes as a JSON object");
15553 assert_eq!(
15554 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15555 .and_then(serde_json::Value::as_str),
15556 Some(crate::render::DEP_SOURCE_TIPO_GIT),
15557 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15558 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15559 detected in {json}"
15560 );
15561 }
15562
15563 #[test]
15564 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15565 // Fail-before-pass-after: a future variant rename `Path` →
15566 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15567 // this pin. A per-consumer disambiguation as the `defcaixa`
15568 // macro stabilizes ("caminho" → "path" for English-uniformity)
15569 // is scoped to the inner field key, not the discriminator; this
15570 // pin is orthogonal to that and catches only the outer
15571 // discriminator drift.
15572 let src = DepSource::Path {
15573 caminho: "../caixa-teia".into(),
15574 };
15575 let json = serde_json::to_value(&src).unwrap();
15576 let obj = json.as_object().expect("Path serializes as a JSON object");
15577 assert_eq!(
15578 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15579 .and_then(serde_json::Value::as_str),
15580 Some(crate::render::DEP_SOURCE_TIPO_PATH),
15581 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15582 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15583 detected in {json}"
15584 );
15585 }
15586
15587 #[test]
15588 fn dep_source_key_consts_are_pairwise_distinct() {
15589 // Cross-axis collapse detector: a hypothetical future edit that
15590 // accidentally set two of the three consts to the same byte
15591 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15592 // pass every per-arm serialize pin above but silently collapse
15593 // the discriminator's closed-set arms onto one another; this pin
15594 // catches the collapse at build time.
15595 assert_ne!(
15596 crate::render::DEP_SOURCE_KEY_TIPO,
15597 crate::render::DEP_SOURCE_TIPO_GIT,
15598 );
15599 assert_ne!(
15600 crate::render::DEP_SOURCE_KEY_TIPO,
15601 crate::render::DEP_SOURCE_TIPO_PATH,
15602 );
15603 assert_ne!(
15604 crate::render::DEP_SOURCE_TIPO_GIT,
15605 crate::render::DEP_SOURCE_TIPO_PATH,
15606 );
15607 }
15608
15609 #[test]
15610 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15611 // Shape pin against `rename_all` drift: the two variant-tag
15612 // consts must be ASCII-lowercase-only to match the
15613 // `rename_all = "lowercase"` attribute the derive uses; a future
15614 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15615 // would emit `"GIT"` / `"Git"` instead and trip this pin.
15616 for (label, s) in [
15617 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15618 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15619 ] {
15620 assert!(!s.is_empty(), "{label} must not be empty");
15621 assert!(
15622 s.bytes().all(|b| b.is_ascii_lowercase()),
15623 "{label} must be ASCII-lowercase-only (matching \
15624 rename_all = \"lowercase\"), got {s:?}",
15625 );
15626 }
15627 }
15628
15629 // ── per-entry :caracteristicas set-not-multiset gate ────────────
15630 //
15631 // Every Vec-keyed-by-name authoring surface on the typed Caixa
15632 // surface that identifies its entries by a name field now uniformly
15633 // closes the set-not-multiset discipline at build time (cite
15634 // `validate_caracteristicas`'s peer-axis enumeration). The
15635 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15636 // set-shaped (a feature is either enabled or not — there is no
15637 // `feature × 2` semantic), so two entries naming the same feature
15638 // are a redundant declaration the caixa-resolver's lacre pipeline
15639 // would silently dedup at resolve time. The empty-feature arm
15640 // closes the parallel "operationally-meaningless value" axis on
15641 // the same slot. Same linear-walk + `HashSet` + first-collision
15642 // shape every peer set gate uses; same empty-first cascade every
15643 // peer per-entry shape + duplicate gate uses (the empty-feature
15644 // axis is the more-actionable defect since two `""` entries would
15645 // both report `caracteristica: ""` under a duplicate-first
15646 // ordering, with no way to distinguish the offending site).
15647
15648 fn dep_with_features(features: &[&str]) -> Dep {
15649 Dep {
15650 nome: "caixa-teia".into(),
15651 versao: "^0.1".into(),
15652 fonte: None,
15653 opcional: false,
15654 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15655 }
15656 }
15657
15658 #[test]
15659 fn validate_rejects_empty_caracteristica() {
15660 // Fail-before-pass-after pin: every pre-gate codebase accepted
15661 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15662 // imposed no per-entry shape contract), the dep validated, and
15663 // the empty feature would have reached the future caixa-resolver
15664 // lacre pipeline as a no-op feature enable — silently dropping
15665 // the author's intent far from the source `caixa.lisp`. The new
15666 // gate surfaces the structural defect at the typed-validate
15667 // surface with a self-locating diagnostic naming the offending
15668 // dep's `:nome`.
15669 let d = dep_with_features(&[""]);
15670 assert!(
15671 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15672 "expected CaracteristicaEmpty, got {:?}",
15673 d.validate(),
15674 );
15675 }
15676
15677 #[test]
15678 fn validate_rejects_duplicate_caracteristica() {
15679 // Fail-before-pass-after pin on the set-not-multiset arm: the
15680 // feature-toggle slot is set-shaped, so `(:caracteristicas
15681 // ("http" "http"))` is a redundant declaration the lacre
15682 // pipeline dedupes silently at resolve time. The diagnostic
15683 // names the offending dep + the colliding feature verbatim so
15684 // the author can grep their caixa.lisp for `:caracteristicas`
15685 // and fix it in one edit. First-collision determinism is
15686 // pinned separately below.
15687 let d = dep_with_features(&["http", "http"]);
15688 assert!(
15689 matches!(
15690 d.validate().unwrap_err(),
15691 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15692 if nome == "caixa-teia" && caracteristica == "http"
15693 ),
15694 "expected CaracteristicaDuplicate, got {:?}",
15695 d.validate(),
15696 );
15697 }
15698
15699 #[test]
15700 fn validate_accepts_distinct_caracteristicas() {
15701 // The canonical authoring shape — every feature distinct — must
15702 // remain a clean pass (positive control sweep). Covers the
15703 // canonical kebab-case feature names a target caixa typically
15704 // declares.
15705 dep_with_features(&["http", "json", "tls"])
15706 .validate()
15707 .unwrap();
15708 }
15709
15710 #[test]
15711 fn validate_accepts_single_caracteristica() {
15712 // Single-element list is the minimum non-empty shape; passes
15713 // the gate as the identity of the duplicate check (no second
15714 // entry to collide with).
15715 dep_with_features(&["http"]).validate().unwrap();
15716 }
15717
15718 #[test]
15719 fn validate_accepts_empty_caracteristicas_list() {
15720 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15721 // produces `caracteristicas: Vec::new()`; the empty list is
15722 // the gate's empty-set identity and passes vacuously. Pin
15723 // this so a future tightening that requires ≥1 feature
15724 // surfaces here as a test failure rather than a silent
15725 // contract narrowing.
15726 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15727 assert!(dep_with_features(&[]).validate().is_ok());
15728 }
15729
15730 #[test]
15731 fn validate_caracteristica_empty_fires_before_duplicate() {
15732 // Empty-first cascade: an entry with an empty feature *and*
15733 // duplicate entries surfaces the empty diagnostic first. The
15734 // empty-feature axis is the more-actionable defect since
15735 // `caracteristica: ""` is unambiguous; under duplicate-first
15736 // ordering the diagnostic could report the empty string from
15737 // either of two empty entries with no way to distinguish.
15738 // Mirrors the peer empty-before-duplicate ordering
15739 // discipline every per-entry shape + duplicate gate establishes
15740 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15741 // `DuplicateChildCaixa`, `validate_membros`'s
15742 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15743 let d = dep_with_features(&["", "http", "http"]);
15744 assert!(matches!(
15745 d.validate().unwrap_err(),
15746 DepError::CaracteristicaEmpty { .. }
15747 ));
15748 }
15749
15750 #[test]
15751 fn validate_caracteristica_duplicate_first_collision_determinism() {
15752 // Three matching entries: the second occurrence surfaces the
15753 // diagnostic (the second is the first *collision* — the first
15754 // entry is the establishing one, not a duplicate). Mirrors
15755 // every peer first-collision posture
15756 // (`SupervisorError::DuplicateChildCaixa` reports the second
15757 // collision, `AplicacaoError::MembroDuplicate` reports the
15758 // second, `DepError::DuplicateNome` reports the second).
15759 // Pinning this so a future shortcut that flips to last-
15760 // collision (or non-deterministic) surfaces here.
15761 let d = dep_with_features(&["http", "http", "http"]);
15762 assert!(matches!(
15763 d.validate().unwrap_err(),
15764 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15765 ));
15766 }
15767
15768 #[test]
15769 fn validate_per_entry_shape_fires_before_caracteristicas() {
15770 // Per-entry shape precedence: a dep with a malformed `:nome`
15771 // (uppercase) AND duplicate `:caracteristicas` surfaces the
15772 // narrower `NomeInvalid` diagnostic first, not the set-gate
15773 // diagnostic. The `:nome` is the self-locating axis (every
15774 // diagnostic from the caracteristicas gate quotes the
15775 // offending dep's `:nome` to anchor the grep target —
15776 // surfacing the malformed name first keeps that anchor
15777 // valid). Same precedence shape every peer per-entry-shape
15778 // arm establishes against its peer set-gate
15779 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15780 // on the cross-entry `:nome` axis).
15781 let d = Dep {
15782 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15783 versao: "^0.1".into(),
15784 fonte: None,
15785 opcional: false,
15786 caracteristicas: vec!["http".into(), "http".into()],
15787 };
15788 assert!(matches!(
15789 d.validate().unwrap_err(),
15790 DepError::NomeInvalid { .. }
15791 ));
15792 }
15793
15794 // ── per-entry :caracteristicas value-shape gate ──────────────────
15795 //
15796 // Until this gate landed `:caracteristicas` only refused the empty
15797 // string and cross-entry duplicates: a non-empty distinct but
15798 // structurally invalid feature name silently passed validate and the
15799 // failure surfaced at `cargo metadata` time as Cargo's
15800 // `restricted_names::validate_feature_name` parser rejection, far from
15801 // the source `caixa.lisp` with no field naming which `:deps` entry's
15802 // `:caracteristicas` carried the typo. The lifted predicate makes the
15803 // Cargo-feature-name-grammar intersection-floor a substrate-level
15804 // invariant at validate time. Same trajectory as the eight peer
15805 // value-shape predicates each typed surface downstream of a structured
15806 // grammar already follows.
15807
15808 #[test]
15809 fn validate_rejects_caracteristica_with_leading_plus() {
15810 // Fail-before-pass-after pin on the canonical Cargo
15811 // `+<feature>` activation-form-in-feature-name-slot footgun.
15812 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15813 // `+optional-feature` as an enablement of a previously-disabled
15814 // feature; pasting that activation form into `:caracteristicas`
15815 // (which names the feature itself) silently passed pre-gate and
15816 // failed at `cargo metadata` parse time.
15817 let d = dep_with_features(&["+http"]);
15818 let err = d.validate().unwrap_err();
15819 assert!(
15820 matches!(
15821 err,
15822 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15823 if nome == "caixa-teia" && caracteristica == "+http"
15824 ),
15825 "expected CaracteristicaInvalid, got {err:?}"
15826 );
15827 }
15828
15829 #[test]
15830 fn validate_rejects_caracteristica_with_leading_hyphen() {
15831 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15832 // is a legitimate continuation character (kebab-case feature
15833 // names like `runtime-tokio` pass) but Cargo rejects it at the
15834 // start; the structural defect — and its CLI-argument-injection
15835 // adjacency at any downstream Cargo subprocess invocation — is
15836 // closed at validate time, not at `cargo metadata` time.
15837 let d = dep_with_features(&["-json"]);
15838 let err = d.validate().unwrap_err();
15839 assert!(
15840 matches!(
15841 err,
15842 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15843 ),
15844 "expected CaracteristicaInvalid, got {err:?}"
15845 );
15846 }
15847
15848 #[test]
15849 fn validate_rejects_caracteristica_with_leading_dot() {
15850 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15851 // a legitimate continuation character (version-suffix shapes
15852 // like `feat.v2` pass) but the leading-dot form is the
15853 // canonical dotted-version-suffix-as-feature-name confusion.
15854 let d = dep_with_features(&[".feat"]);
15855 let err = d.validate().unwrap_err();
15856 assert!(matches!(
15857 err,
15858 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15859 ));
15860 }
15861
15862 #[test]
15863 fn validate_rejects_caracteristica_with_whitespace() {
15864 // Fail-before-pass-after pin on the embedded-whitespace footgun:
15865 // a feature name with a space inside is structurally a multi-
15866 // token blob (the canonical paste-from-doc footgun, or an
15867 // accidental `"http server"` where the author meant
15868 // `"http-server"`).
15869 let d = dep_with_features(&["http feature"]);
15870 let err = d.validate().unwrap_err();
15871 assert!(matches!(
15872 err,
15873 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15874 ));
15875 }
15876
15877 #[test]
15878 fn validate_rejects_caracteristica_with_comma() {
15879 // Fail-before-pass-after pin on the embedded-comma footgun:
15880 // the list-separator-belongs-to-the-list-grammar
15881 // miscomprehension where the author writes
15882 // `:caracteristicas ("http,json")` intending two features but
15883 // the `Vec<String>` field consumes the bare token as one entry.
15884 let d = dep_with_features(&["http,json"]);
15885 let err = d.validate().unwrap_err();
15886 assert!(matches!(
15887 err,
15888 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15889 ));
15890 }
15891
15892 #[test]
15893 fn validate_rejects_caracteristica_with_slash() {
15894 // Fail-before-pass-after pin on the embedded-slash footgun:
15895 // Cargo's `dep/feat` namespaced-dep syntax applies inside
15896 // `[dependencies.<dep>.features]` list entries that already
15897 // name the parent dep (so the syntax says "enable feature
15898 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15899 // per-dep already (a sibling slot on the `Dep` itself), so the
15900 // segment separator within an entry must be `-`, `_`, `+`,
15901 // or `.`. The diagnostic remediation points at the canonical
15902 // Cargo namespaced-dep discipline.
15903 let d = dep_with_features(&["http/json"]);
15904 let err = d.validate().unwrap_err();
15905 assert!(matches!(
15906 err,
15907 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15908 ));
15909 }
15910
15911 #[test]
15912 fn validate_rejects_caracteristica_with_non_ascii() {
15913 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15914 // byte footgun: NFC-vs-NFD normalization across filesystems
15915 // silently rewrites the feature-key, breaking the lacre's
15916 // content-addressing invariant. Pinned at a canonical
15917 // smart-quote-paste shape (`café`) where the raw `é` byte is the
15918 // documented APFS round-trip break.
15919 let d = dep_with_features(&["caf\u{e9}"]);
15920 let err = d.validate().unwrap_err();
15921 assert!(matches!(
15922 err,
15923 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15924 ));
15925 }
15926
15927 #[test]
15928 fn validate_rejects_caracteristica_with_control_character() {
15929 // Fail-before-pass-after pin on the embedded-control-character
15930 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15931 // feature name is the canonical paste-from-multiline-doc
15932 // footgun the predicate's reason wording specifically calls out.
15933 let d = dep_with_features(&["http\njson"]);
15934 let err = d.validate().unwrap_err();
15935 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15936 }
15937
15938 #[test]
15939 fn validate_accepts_canonical_caracteristicas_shapes() {
15940 // Positive control sweep: every canonical Cargo feature name
15941 // shape the pleme-io ecosystem uses must still pass. Mirrors
15942 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15943 // sweep — drift between either landing site and the predicate's
15944 // accepted set is a build error visible at this pair of tests,
15945 // not a per-renderer "this passed validate but failed at
15946 // cargo metadata time" surprise on the next acceptance.
15947 for s in [
15948 "http",
15949 "json",
15950 "derive",
15951 "serde_json",
15952 "runtime-tokio",
15953 "tokio.full",
15954 "v0.1",
15955 "http+json",
15956 "_internal",
15957 "__private",
15958 "default",
15959 "rt-multi-thread",
15960 "feat.v2",
15961 ] {
15962 let d = dep_with_features(&[s]);
15963 d.validate().unwrap_or_else(|e| {
15964 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15965 });
15966 }
15967 }
15968
15969 #[test]
15970 fn validate_caracteristica_empty_fires_before_invalid() {
15971 // Cascade precedence pin: an entry list with both an empty
15972 // feature AND an invalid-shape feature surfaces the
15973 // `CaracteristicaEmpty` arm first (the empty value carries no
15974 // self-locating data — `caracteristica: ""` is the diagnostic
15975 // with no way to anchor a grep target — so closing the empty
15976 // axis first preserves the per-entry-shape diagnostic's
15977 // self-locating discipline). Same empty-first cascade every
15978 // peer per-entry shape gate establishes
15979 // (`SupervisorSpec::validate`'s `EmptyChildName` before
15980 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15981 // before `MembroCaixaInvalid`).
15982 let d = dep_with_features(&["", "+http"]);
15983 assert!(matches!(
15984 d.validate().unwrap_err(),
15985 DepError::CaracteristicaEmpty { .. }
15986 ));
15987 }
15988
15989 #[test]
15990 fn validate_caracteristica_invalid_fires_before_duplicate() {
15991 // Per-entry-shape precedence pin: an entry list with the same
15992 // invalid feature shape declared twice surfaces the
15993 // `CaracteristicaInvalid` diagnostic on the first entry, not
15994 // the `CaracteristicaDuplicate` on the second collision. The
15995 // per-entry shape gate fires before the cross-entry set gate
15996 // — same precedence shape every peer two-arm-plus-set gate
15997 // establishes (`SupervisorSpec::validate`'s
15998 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15999 // `validate_membros`'s `MembroCaixaInvalid` before
16000 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16001 // cross-list `DuplicateNome`).
16002 let d = dep_with_features(&["+http", "+http"]);
16003 assert!(matches!(
16004 d.validate().unwrap_err(),
16005 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16006 ));
16007 }
16008
16009 #[test]
16010 fn validate_rejects_caracteristica_at_65_byte_boundary() {
16011 // Boundary pin on the 64-byte cap — both the boundary-accepting
16012 // case and the boundary-exceeding case in one place, so a
16013 // future cap shift surfaces both arms simultaneously, mirroring
16014 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16015 // predicate-level pin at the dep-axis landing site.
16016 let max_ok = "a".repeat(64);
16017 dep_with_features(&[&max_ok])
16018 .validate()
16019 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16020 let too_long = "a".repeat(65);
16021 let d = dep_with_features(&[&too_long]);
16022 assert!(matches!(
16023 d.validate().unwrap_err(),
16024 DepError::CaracteristicaInvalid { .. }
16025 ));
16026 }
16027
16028 // ── self-dep cross-slot gate ─────────────────────────────────────
16029
16030 #[test]
16031 fn validate_no_self_dep_rejects_self_in_deps() {
16032 // A caixa whose `:deps` lists its own `:nome` is a one-node
16033 // cycle in the lacre closure's dep-graph traversal — rejected,
16034 // naming the parent and the offending list tag.
16035 let deps = vec![
16036 Dep::simple("caixa-teia", "^0.1"),
16037 Dep::simple("orquestra", "^0.1"),
16038 ];
16039 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16040 assert!(
16041 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16042 "got {err:?}"
16043 );
16044 }
16045
16046 #[test]
16047 fn validate_no_self_dep_rejects_self_in_deps_dev() {
16048 // Same gate on the `:deps-dev` axis — neither dep list is a
16049 // second-class citizen on the self-edge invariant.
16050 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16051 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16052 assert!(
16053 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16054 "got {err:?}"
16055 );
16056 }
16057
16058 #[test]
16059 fn validate_no_self_dep_deps_fires_before_deps_dev() {
16060 // Walk order pin: a caixa that self-references on both lists
16061 // surfaces the `:deps` arm first — the load-bearing axis the
16062 // lacre closure resolves at every build. Mirrors the canonical
16063 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16064 let deps = vec![Dep::simple("orquestra", "^0.1")];
16065 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16066 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16067 assert!(
16068 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16069 "got {err:?}"
16070 );
16071 }
16072
16073 #[test]
16074 fn validate_no_self_dep_accepts_distinct_names() {
16075 // Positive control: every dep names a distinct caixa. The
16076 // canonical author surface — peer of
16077 // [`validate_no_self_supervision_accepts_distinct_children`].
16078 let deps = vec![
16079 Dep::simple("caixa-teia", "^0.1"),
16080 Dep::simple("caixa-arch", "^0.1"),
16081 ];
16082 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16083 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16084 }
16085
16086 #[test]
16087 fn validate_no_self_dep_empty_lists_pass() {
16088 // A caixa with no declared deps has nothing to self-reference —
16089 // the gate is vacuously satisfied. Peer of
16090 // [`validate_no_self_supervision_empty_children_is_ok`].
16091 validate_no_self_dep(&[], &[], "orquestra").unwrap();
16092 }
16093
16094 #[test]
16095 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16096 // Diagnostic-shape pin (peer with
16097 // [`validate_no_self_supervision`]'s diagnostic): the error's
16098 // Display surfaces both the offending list tag and the
16099 // parent's `:nome` verbatim, so the author can grep their
16100 // caixa.lisp for the offending block in one edit. Names
16101 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16102 // surface — every legitimate "I want to use code from this
16103 // caixa" intent routes through one of those three slots.
16104 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16105 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16106 .unwrap_err()
16107 .to_string();
16108 assert!(
16109 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16110 "diagnostic must name the offending list tag: {rendered}",
16111 );
16112 assert!(
16113 rendered.contains("orquestra"),
16114 "diagnostic must quote the parent caixa name: {rendered}",
16115 );
16116 assert!(
16117 rendered.contains(":bibliotecas"),
16118 "diagnostic must point at the corrective code-surface slot: {rendered}",
16119 );
16120 }
16121
16122 #[test]
16123 fn validate_no_self_dep_accepts_coincidental_substring_match() {
16124 // Identity is exact-string equality, not substring — a dep
16125 // named `"orquestra-helper"` is a distinct caixa even when the
16126 // parent is `"orquestra"`. Pin the exact-match discipline so a
16127 // future relaxation that uses `contains` surfaces here, peer
16128 // with the supervision-tree and Aplicacao-membership gates
16129 // which all use exact-string equality on the typed identity.
16130 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16131 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16132 }
16133
16134 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16135
16136 #[test]
16137 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16138 // Scalar-value pin: the two author-facing kebab-case labels the
16139 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16140 // the two-list dep-graph slot axis, one arm per typed slot.
16141 // Mirrors the peer scalar-value pin the sibling
16142 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16143 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16144 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16145 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16146 // (882f498) M3 top-level author-labels, and
16147 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16148 // Supervisor top-level author-labels carry, so every kind-scoped
16149 // typed-slot-family axis routes through one canonical per-arm
16150 // declaration.
16151 //
16152 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16153 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16154 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16155 // for symmetry) lands as an edit to exactly one const, and
16156 // every consumer that reaches for the label picks it up at
16157 // build time rather than at runtime as a downstream mismatch on
16158 // a `DepError::DuplicateNome { list: … }` diagnostic far from
16159 // the rename's commit.
16160 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16161 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16162 }
16163
16164 #[test]
16165 fn dep_author_key_consts_are_pairwise_distinct() {
16166 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16167 // must not collapse onto one byte-string. A future copy-paste
16168 // slip that renamed both consts to the same value (or a rebrand
16169 // that dropped the `-dev` suffix from one but not the other)
16170 // would leave every `DepError::DuplicateNome { list: … }`
16171 // diagnostic naming an unattributable list — the linter would
16172 // route the author to the wrong caixa.lisp block, or the
16173 // cross-list precedence gate
16174 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16175 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16176 // duplicate. Peer of the sibling
16177 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16178 // other top-level kind-scoped slot-family axes carry
16179 // (implicitly held by their different byte-values today).
16180 assert_ne!(
16181 crate::render::DEP_AUTHOR_KEY_DEPS,
16182 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16183 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16184 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16185 self-locates the offending block in the author's caixa.lisp",
16186 );
16187 }
16188
16189 #[test]
16190 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16191 // Production-through-const pin: the two per-arm list tags
16192 // [`validate_no_self_dep`] threads onto the `list:` field of a
16193 // returned [`DepError::DepIsSelf`] route through the lifted
16194 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16195 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16196 // the walker (a rename that reaches one arm but not the const,
16197 // or vice versa) surfaces here at build time rather than at
16198 // runtime as a `feira lint` diagnostic naming the wrong list
16199 // tag. Mirror of the peer
16200 // [`crate::Caixa::declared_servico_slots`] production tagger
16201 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16202 // onto the two-list dep-graph gate.
16203 let deps = vec![Dep::simple("orquestra", "^0.1")];
16204 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16205 let DepError::DepIsSelf { list, .. } = err else {
16206 panic!("expected DepIsSelf from :deps walk");
16207 };
16208 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16209
16210 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16211 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16212 let DepError::DepIsSelf { list, .. } = err else {
16213 panic!("expected DepIsSelf from :deps-dev walk");
16214 };
16215 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16216 }
16217
16218 // ── Dep::nome accessor pins ───────────────────────────────────────
16219 //
16220 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16221 // projection over the plain-shorthand / explicit-git / explicit-path
16222 // fixture triad the [`Dep`] docstring lists (so the accessor's
16223 // accept-set is exercised across every author-surface `:fonte`
16224 // shape); by-borrow pointer identity so the projection stays
16225 // zero-copy at every consumer site; and validate-composition through
16226 // the [`validate_no_self_dep`] cross-slot gate reading its
16227 // parent-name equality check through the lifted accessor rather than
16228 // the raw field.
16229
16230 #[test]
16231 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16232 // Plain-shorthand form (`:fonte None`).
16233 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16234 // Explicit git-source form with a tag pin — same accessor path.
16235 assert_eq!(
16236 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16237 "caixa-teia",
16238 );
16239 // Explicit path-source form.
16240 assert_eq!(
16241 Dep {
16242 nome: "caixa-teia".to_string(),
16243 versao: "0.1.0".to_string(),
16244 fonte: Some(DepSource::Path {
16245 caminho: "../caixa-teia".to_string(),
16246 }),
16247 opcional: false,
16248 caracteristicas: Vec::new(),
16249 }
16250 .nome(),
16251 "caixa-teia",
16252 );
16253 // The empty-string `:nome` sentinel (which [`Dep::validate`]
16254 // refuses through the [`DepError::NomeEmpty`] arm) still round-
16255 // trips as an empty `&str` through the accessor — the accessor is
16256 // a projection, not a gate; the gate is [`Dep::validate`].
16257 assert_eq!(Dep::simple("", "^0.1").nome(), "");
16258 }
16259
16260 #[test]
16261 fn dep_nome_is_by_borrow_pointer_identity() {
16262 // Zero-copy pin: the accessor must borrow into the field's own
16263 // storage, not clone. If a future rewrite regresses to
16264 // `self.nome.clone().leak()` or an owned-buffer shape, the two
16265 // pointers diverge and this pin fails at build time.
16266 let d = Dep::simple("caixa-teia", "^0.1");
16267 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16268 }
16269
16270 // ── Dep::versao_requirement accessor pins ─────────────────────────
16271 //
16272 // Three coherence pins on the lifted `Dep::versao_requirement`
16273 // accessor: byte-equal projection over the plain-shorthand /
16274 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16275 // lists plus the empty-sentinel that round-trips as `""` (the accessor
16276 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16277 // borrow pointer identity so the projection stays zero-copy at every
16278 // consumer site; and validate-composition through the
16279 // [`crate::render::require_valid_versao_requirement`] cascade reading
16280 // its requirement-shape check through the lifted accessor rather than
16281 // the raw field.
16282 #[test]
16283 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16284 // Plain-shorthand form (`:fonte None`).
16285 assert_eq!(
16286 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16287 "^0.1",
16288 );
16289 // Explicit git-source form with a tag pin — same accessor path.
16290 assert_eq!(
16291 Dep::git(
16292 "caixa-teia",
16293 "~0.1.2",
16294 "github:pleme-io/caixa-teia",
16295 "v0.1.0"
16296 )
16297 .versao_requirement(),
16298 "~0.1.2",
16299 );
16300 // Explicit path-source form.
16301 assert_eq!(
16302 Dep {
16303 nome: "caixa-teia".to_string(),
16304 versao: "0.1.0".to_string(),
16305 fonte: Some(DepSource::Path {
16306 caminho: "../caixa-teia".to_string(),
16307 }),
16308 opcional: false,
16309 caracteristicas: Vec::new(),
16310 }
16311 .versao_requirement(),
16312 "0.1.0",
16313 );
16314 // The wildcard requirement (`"*"`) — the shorthand
16315 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16316 // verbatim through the accessor as `"*"`, same byte-shape the
16317 // author wrote.
16318 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16319 // The empty-string `:versao` sentinel (which [`Dep::validate`]
16320 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16321 // trips as an empty `&str` through the accessor — the accessor is
16322 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16323 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16324 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16325 }
16326
16327 #[test]
16328 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16329 // Zero-copy pin: the accessor must borrow into the field's own
16330 // storage, not clone. If a future rewrite regresses to
16331 // `self.versao.clone().leak()` or an owned-buffer shape, the two
16332 // pointers diverge and this pin fails at build time. Peer of the
16333 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16334 // discipline extended onto the requirement-carrying axis.
16335 let d = Dep::simple("caixa-teia", "^0.1");
16336 assert!(std::ptr::eq(
16337 d.versao_requirement().as_ptr(),
16338 d.versao.as_ptr(),
16339 ));
16340 }
16341
16342 #[test]
16343 fn dep_validate_reads_requirement_through_accessor() {
16344 // Composition pin: the [`Dep::validate`]
16345 // [`crate::render::require_valid_versao_requirement`] cascade
16346 // consumes the requirement string through the lifted accessor —
16347 // both the requirement-gate input and the
16348 // [`DepError::VersaoInvalid`] error-body carrier route through
16349 // `self.versao_requirement()`. A valid requirement passes
16350 // (positive control); a malformed-but-non-empty requirement fails
16351 // and the diagnostic quotes the offending byte-string verbatim
16352 // (same shape the accessor projects), so a future regression that
16353 // detoured the requirement carrier through a different byte-
16354 // string (say the parsed `VersionReq`'s `Display`, or a
16355 // normalized rewrite) would surface here at build time. The
16356 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16357 // ahead of the parse arm, pinning the empty-first cascade the
16358 // accessor's `""` sentinel round-trip acknowledges.
16359 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16360 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16361 assert!(
16362 matches!(
16363 &err,
16364 DepError::VersaoInvalid {
16365 nome,
16366 versao,
16367 ..
16368 } if nome == "caixa-teia" && versao == "v0.1",
16369 ),
16370 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16371 );
16372 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16373 assert!(
16374 matches!(
16375 &err,
16376 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16377 ),
16378 "expected VersaoEmpty from the empty-first arm, got {err:?}",
16379 );
16380 }
16381
16382 // ── Dep::fonte accessor pins ──────────────────────────────────────
16383 //
16384 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16385 // equal projection over the plain-shorthand (`:fonte None`) /
16386 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16387 // docstring lists (so the accessor's accept-set is exercised across
16388 // every author-surface `:fonte` shape and both `DepSource` variants);
16389 // pointer identity so the borrowed reference points into the field's
16390 // own `Option<DepSource>` storage (not a cloned side-buffer); and
16391 // validate-composition through the [`Dep::validate`] gate reading
16392 // its per-`:fonte` [`DepSource::validate`] delegation through the
16393 // lifted accessor rather than the raw `if let Some(ref fonte) =
16394 // self.fonte` bracket.
16395
16396 #[test]
16397 fn dep_fonte_returns_declared_source_across_shapes() {
16398 // Plain-shorthand form — `:fonte` omitted, accessor projects
16399 // the `None` partition the resolver-side default-fill treats
16400 // as "resolve through `github:<default-org>/<nome>`".
16401 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16402 // Explicit git-source form with a tag pin — same accessor path.
16403 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16404 match git.fonte() {
16405 Some(DepSource::Git {
16406 repo,
16407 tag,
16408 rev,
16409 branch,
16410 }) => {
16411 assert_eq!(repo, "github:pleme-io/caixa-teia");
16412 assert_eq!(tag.as_deref(), Some("v0.1.0"));
16413 assert!(rev.is_none());
16414 assert!(branch.is_none());
16415 }
16416 other => panic!("expected explicit git :fonte, got {other:?}"),
16417 }
16418 // Explicit path-source form — the dev-only local-filesystem
16419 // arm the [`Dep`] docstring's third fixture carries.
16420 let path = Dep {
16421 nome: "caixa-teia".to_string(),
16422 versao: "0.1.0".to_string(),
16423 fonte: Some(DepSource::Path {
16424 caminho: "../caixa-teia".to_string(),
16425 }),
16426 opcional: false,
16427 caracteristicas: Vec::new(),
16428 };
16429 match path.fonte() {
16430 Some(DepSource::Path { caminho }) => {
16431 assert_eq!(caminho, "../caixa-teia");
16432 }
16433 other => panic!("expected explicit path :fonte, got {other:?}"),
16434 }
16435 }
16436
16437 #[test]
16438 fn dep_fonte_is_by_borrow_pointer_identity() {
16439 // Zero-copy pin: the accessor must borrow into the field's own
16440 // `Option<DepSource>` storage, not clone into a side buffer. If
16441 // a future rewrite regresses to `self.fonte.clone()` or an
16442 // owned-buffer shape, the two pointers diverge and this pin
16443 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16444 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16445 // identity pins — same by-borrow discipline extended onto the
16446 // outer-`Dep` `Option<&Composite>` composite-reference axis.
16447 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16448 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16449 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16450 assert!(std::ptr::eq(accessed, raw));
16451 }
16452
16453 #[test]
16454 fn dep_validate_reads_fonte_through_accessor() {
16455 // Composition pin: [`Dep::validate`]'s per-`:fonte`
16456 // [`DepSource::validate`] delegation consumes the typed slot
16457 // through the lifted accessor — an author-omitted `:fonte`
16458 // still passes the outer gate (positive control), an explicit
16459 // well-formed git source with exactly one pin passes, and a
16460 // malformed git source (empty `:repo`) surfaces the
16461 // [`DepError::FonteRepoEmpty`] variant quoting the offending
16462 // dep's `:nome` verbatim so a future regression that detoured
16463 // the `:fonte` delegation through a different path (say a
16464 // per-scope override projector) would surface here at build
16465 // time. Peer of the sibling
16466 // `dep_validate_reads_requirement_through_accessor` composition
16467 // pin on the `:versao` axis.
16468 // Positive control 1: no `:fonte` at all.
16469 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16470 // Positive control 2: well-formed git source.
16471 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16472 .validate()
16473 .unwrap();
16474 // Negative control: empty `:repo` — the accessor still returns
16475 // `Some(&DepSource::Git { repo: "", … })` and the delegated
16476 // `DepSource::validate` gate raises the typed carrier.
16477 let bad = Dep {
16478 nome: "caixa-teia".to_string(),
16479 versao: "^0.1".to_string(),
16480 fonte: Some(DepSource::Git {
16481 repo: String::new(),
16482 tag: Some("v0.1.0".to_string()),
16483 rev: None,
16484 branch: None,
16485 }),
16486 opcional: false,
16487 caracteristicas: Vec::new(),
16488 };
16489 let err = bad.validate().unwrap_err();
16490 assert!(
16491 matches!(
16492 &err,
16493 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16494 ),
16495 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16496 );
16497 }
16498
16499 #[test]
16500 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16501 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16502 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16503 // own `:nome` through the lifted accessor rather than the raw
16504 // field. Fails-before-passes-after: with the accessor lifted the
16505 // gate reads its equality check through `dep.nome() ==
16506 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16507 // the diagnostic still names the offending list tag as expected.
16508 let deps = vec![Dep::simple("orquestra", "^0.1")];
16509 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16510 assert!(matches!(
16511 err,
16512 DepError::DepIsSelf {
16513 ref nome,
16514 list,
16515 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16516 ));
16517 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16518 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16519 assert!(matches!(
16520 err,
16521 DepError::DepIsSelf {
16522 ref nome,
16523 list,
16524 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16525 ));
16526 // A non-matching `:nome` passes through the accessor gate.
16527 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16528 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16529 }
16530
16531 // ── Dep::caracteristicas accessor pins ────────────────────────────
16532 //
16533 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16534 // byte-equal projection over the default-empty / single-entry /
16535 // multi-entry fixture triad (so the accessor's accept-set is
16536 // exercised across every author-surface `:caracteristicas` shape,
16537 // matching the peer sibling family's fixture-triad discipline); by-
16538 // borrow pointer identity so the projection stays zero-copy at every
16539 // consumer site; and validate-composition through the
16540 // [`Dep::validate_caracteristicas`] gate reading its per-entry
16541 // linear walk through the lifted accessor rather than the raw
16542 // `for c in &self.caracteristicas` bracket.
16543
16544 #[test]
16545 fn dep_caracteristicas_returns_declared_features_across_shapes() {
16546 // Default-empty form — the [`Dep::simple`] constructor's
16547 // `Vec::new()` fill; the accessor projects the empty slice
16548 // verbatim (no `None` collapse).
16549 assert!(
16550 Dep::simple("caixa-teia", "^0.1")
16551 .caracteristicas()
16552 .is_empty(),
16553 );
16554 // Single-entry form — the canonical Cargo-shaped one-feature
16555 // enable ([`crate::render::is_cargo_feature_name`] accepts the
16556 // `"http"` byte-string as a valid feature name).
16557 let one = Dep {
16558 nome: "caixa-teia".to_string(),
16559 versao: "^0.1".to_string(),
16560 fonte: None,
16561 opcional: false,
16562 caracteristicas: vec!["http".to_string()],
16563 };
16564 assert_eq!(one.caracteristicas(), &["http".to_string()]);
16565 // Multi-entry form — the substrate's set-shaped multi-feature
16566 // enable, exercising the accessor over a length-two slice with
16567 // no duplicate collapse.
16568 let two = Dep {
16569 nome: "caixa-teia".to_string(),
16570 versao: "^0.1".to_string(),
16571 fonte: None,
16572 opcional: false,
16573 caracteristicas: vec!["http".to_string(), "json".to_string()],
16574 };
16575 assert_eq!(
16576 two.caracteristicas(),
16577 &["http".to_string(), "json".to_string()],
16578 );
16579 }
16580
16581 #[test]
16582 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16583 // Zero-copy pin: the accessor must borrow into the field's own
16584 // `Vec<String>` storage, not clone into a side buffer. If a
16585 // future rewrite regresses to `self.caracteristicas.clone()` or
16586 // an owned-buffer shape, the two pointers diverge and this pin
16587 // fails at build time. Peer of the sibling per-`Dep`
16588 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16589 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16590 // borrow discipline extended onto the outer-`Dep` `&[String]`
16591 // slice-projection axis.
16592 let d = Dep {
16593 nome: "caixa-teia".to_string(),
16594 versao: "^0.1".to_string(),
16595 fonte: None,
16596 opcional: false,
16597 caracteristicas: vec!["http".to_string(), "json".to_string()],
16598 };
16599 assert!(std::ptr::eq(
16600 d.caracteristicas().as_ptr(),
16601 d.caracteristicas.as_ptr(),
16602 ));
16603 }
16604
16605 #[test]
16606 fn dep_validate_reads_caracteristicas_through_accessor() {
16607 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16608 // linear walk consumes the feature-toggle list through the
16609 // lifted accessor — a well-formed `:caracteristicas` set passes
16610 // (positive control), an empty-string entry surfaces the
16611 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16612 // `Dep::nome`, and a within-list duplicate surfaces the
16613 // [`DepError::CaracteristicaDuplicate`] variant so a future
16614 // regression that detoured the walk through a different byte-
16615 // string list (say a per-scope override projector) would surface
16616 // here at build time. Peer of the sibling
16617 // `dep_validate_reads_fonte_through_accessor` /
16618 // `dep_validate_reads_requirement_through_accessor` composition
16619 // pins on the `:fonte` / `:versao` axes.
16620 // Positive control: two distinct well-formed feature names pass.
16621 Dep {
16622 nome: "caixa-teia".to_string(),
16623 versao: "^0.1".to_string(),
16624 fonte: None,
16625 opcional: false,
16626 caracteristicas: vec!["http".to_string(), "json".to_string()],
16627 }
16628 .validate()
16629 .unwrap();
16630 // Negative control 1: empty-string feature-name entry — the
16631 // accessor still returns `&[""]` and the walk raises the typed
16632 // empty-first carrier.
16633 let err = Dep {
16634 nome: "caixa-teia".to_string(),
16635 versao: "^0.1".to_string(),
16636 fonte: None,
16637 opcional: false,
16638 caracteristicas: vec![String::new()],
16639 }
16640 .validate()
16641 .unwrap_err();
16642 assert!(
16643 matches!(
16644 &err,
16645 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16646 ),
16647 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16648 );
16649 // Negative control 2: within-list duplicate — the accessor's
16650 // slice view carries both entries, and the walk's dedup arm
16651 // raises the typed duplicate carrier quoting the offending
16652 // feature name verbatim.
16653 let err = Dep {
16654 nome: "caixa-teia".to_string(),
16655 versao: "^0.1".to_string(),
16656 fonte: None,
16657 opcional: false,
16658 caracteristicas: vec!["http".to_string(), "http".to_string()],
16659 }
16660 .validate()
16661 .unwrap_err();
16662 assert!(
16663 matches!(
16664 &err,
16665 DepError::CaracteristicaDuplicate {
16666 nome,
16667 caracteristica,
16668 } if nome == "caixa-teia" && caracteristica == "http",
16669 ),
16670 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16671 );
16672 }
16673
16674 // ── Dep::opcional accessor pins ───────────────────────────────────
16675 //
16676 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16677 // equal projection over the default-`false` / explicit-`true`
16678 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16679 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16680 // exercising the accessor's accept-set over every author-surface
16681 // `:fonte` shape × every author-surface `:opcional` shape; and by-
16682 // `Copy` idempotency so the projection stays value-return (no
16683 // silent detour to a fresh `&bool` borrow that would introduce a
16684 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16685 // shape elides). No composition pin — `:opcional` does not
16686 // participate in [`Dep::validate`] (an opcional dep with any bool
16687 // value is validate-accepted; the missing-source arm is a resolver-
16688 // side runtime dispatch, not a build-time refusal), so the axis
16689 // reduces to the value-shape + `Copy` pin pair the peer
16690 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16691 // outer-`Option<Copy>` accessor pins already carry.
16692
16693 #[test]
16694 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16695 // Default-`false` form via the [`Dep::simple`] constructor —
16696 // the accessor projects the `false` bit the default-fill sets.
16697 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16698 // Default-`false` form via the [`Dep::git`] constructor — same
16699 // default fill; the accessor projects `false` regardless of the
16700 // `:fonte` arm.
16701 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16702 // Explicit-`true` form × plain-shorthand `:fonte` — the
16703 // canonical author-surface "this dep may be missing" shape.
16704 let plain_true = Dep {
16705 nome: "caixa-teia".to_string(),
16706 versao: "^0.1".to_string(),
16707 fonte: None,
16708 opcional: true,
16709 caracteristicas: Vec::new(),
16710 };
16711 assert!(plain_true.opcional());
16712 // Explicit-`true` form × explicit git-source — the accessor
16713 // projects the bit verbatim regardless of the `:fonte` arm.
16714 let git_true = Dep {
16715 nome: "caixa-teia".to_string(),
16716 versao: "^0.1".to_string(),
16717 fonte: Some(DepSource::Git {
16718 repo: "github:pleme-io/caixa-teia".to_string(),
16719 tag: Some("v0.1.0".to_string()),
16720 rev: None,
16721 branch: None,
16722 }),
16723 opcional: true,
16724 caracteristicas: Vec::new(),
16725 };
16726 assert!(git_true.opcional());
16727 // Explicit-`true` form × explicit path-source — the dev-only
16728 // local-filesystem arm the [`Dep`] docstring's third fixture
16729 // carries.
16730 let path_true = Dep {
16731 nome: "caixa-teia".to_string(),
16732 versao: "0.1.0".to_string(),
16733 fonte: Some(DepSource::Path {
16734 caminho: "../caixa-teia".to_string(),
16735 }),
16736 opcional: true,
16737 caracteristicas: Vec::new(),
16738 };
16739 assert!(path_true.opcional());
16740 }
16741
16742 #[test]
16743 fn dep_opcional_projects_bool_by_copy() {
16744 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16745 // (`bool: Copy`) — the accessor does not borrow `&self` past
16746 // the call (no lifetime on the return type), and calling the
16747 // accessor twice on the same [`Dep`] must yield discriminant-
16748 // equal values (idempotent, no side effects on `&self`). Peer
16749 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16750 // `max_restarts_projects_option_by_copy` (eba5211) /
16751 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16752 // outer-`Caixa` altitude — extended here to the outer-`Dep`
16753 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16754 // replaces the pointer-equality claim the sibling per-`Dep`
16755 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16756 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16757 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16758 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16759 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16760 // the same discriminant, so the axis reduces to discriminant
16761 // equality).
16762 //
16763 // Pins against a future silent detour that returned a fresh
16764 // `&bool` reference (which would type-check but silently
16765 // introduce a borrow of `&self` past the call, collapsing the
16766 // load-bearing "no lifetime on the return type" `Copy`
16767 // projection the plain-`Copy`-scalar axis's `bool` shape
16768 // carries) or a stale-read side effect that flipped the outer
16769 // discriminant on successive calls.
16770 for opcional in [false, true] {
16771 let d = Dep {
16772 nome: "caixa-teia".to_string(),
16773 versao: "^0.1".to_string(),
16774 fonte: None,
16775 opcional,
16776 caracteristicas: Vec::new(),
16777 };
16778 let first = d.opcional();
16779 let second = d.opcional();
16780 assert_eq!(
16781 first, second,
16782 "Dep::opcional must be idempotent — two successive calls \
16783 on the same &self must return the same bool",
16784 );
16785 assert_eq!(
16786 first, opcional,
16787 "Dep::opcional must return :opcional verbatim by Copy — \
16788 got {first}, expected {opcional}",
16789 );
16790 assert_eq!(
16791 d.opcional(),
16792 d.opcional,
16793 "Dep::opcional accessor and self.opcional field access \
16794 must byte-equal — a bit-flip drift would silently split \
16795 the paired resolver-side drop-vs-error dispatch from \
16796 the storage-side default-fill the [`Dep::simple`] / \
16797 [`Dep::git`] constructor pair carries",
16798 );
16799 }
16800 }
16801
16802 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16803
16804 #[test]
16805 fn sole_pin_returns_none_for_path_source() {
16806 // A path source carries no git-ref, so `sole_pin()` returns
16807 // `None` structurally — the sibling arm every git-fetching
16808 // consumer partitions off before reaching for a git-ref. Pins
16809 // the Path-arm branch of the accessor against a future silent
16810 // detour that treats a `Self::Path` as an unpinned-git source
16811 // and returns the wrong "no pin" signal (e.g. the empty string,
16812 // or a hard-coded `Some("HEAD")` matching the caixa-crd
16813 // path-arm `git_ref` fill).
16814 let s = DepSource::Path {
16815 caminho: "../local-caixa".to_string(),
16816 };
16817 assert_eq!(s.sole_pin(), None);
16818 }
16819
16820 #[test]
16821 fn sole_pin_returns_none_for_unpinned_git_source() {
16822 // The [`DepSource::default_github`] shorthand shape carries no
16823 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16824 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16825 // materializes when the author omits `:fonte` entirely, then
16826 // hands to `fetch_git` which raises `ResolveError::MissingPin`
16827 // on the `None` arm — the accessor's return matches the arm
16828 // the resolver's diagnostic keys off.
16829 let s = DepSource::default_github("pleme-io", "caixa-teia");
16830 assert_eq!(s.sole_pin(), None);
16831 }
16832
16833 #[test]
16834 fn sole_pin_returns_rev_when_only_rev_is_set() {
16835 let s = DepSource::Git {
16836 repo: "github:o/x".into(),
16837 tag: None,
16838 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16839 branch: None,
16840 };
16841 assert_eq!(
16842 s.sole_pin(),
16843 Some("deadbeefcafebabe1234567890abcdef12345678")
16844 );
16845 }
16846
16847 #[test]
16848 fn sole_pin_returns_tag_when_only_tag_is_set() {
16849 let s = DepSource::Git {
16850 repo: "github:o/x".into(),
16851 tag: Some("v0.1.0".into()),
16852 rev: None,
16853 branch: None,
16854 };
16855 assert_eq!(s.sole_pin(), Some("v0.1.0"));
16856 }
16857
16858 #[test]
16859 fn sole_pin_returns_branch_when_only_branch_is_set() {
16860 let s = DepSource::Git {
16861 repo: "github:o/x".into(),
16862 tag: None,
16863 rev: None,
16864 branch: Some("main".into()),
16865 };
16866 assert_eq!(s.sole_pin(), Some("main"));
16867 }
16868
16869 #[test]
16870 fn sole_pin_precedence_rev_beats_tag_and_branch() {
16871 // Precedence: rev > tag > branch. Validate() rejects
16872 // multiple-pin shapes, but the accessor's precedence is defined
16873 // for pre-validate consumers (the resolver's `MissingPin`
16874 // diagnostic path, the caixa-crd round-trip's default `"main"`
16875 // fallback) and as defense-in-depth if the gate is ever
16876 // bypassed. Pins the same precedence caixa-resolver's
16877 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16878 // inline.
16879 let s = DepSource::Git {
16880 repo: "github:o/x".into(),
16881 tag: Some("v1".into()),
16882 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16883 branch: Some("main".into()),
16884 };
16885 assert_eq!(
16886 s.sole_pin(),
16887 Some("deadbeefcafebabe1234567890abcdef12345678")
16888 );
16889 }
16890
16891 #[test]
16892 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16893 let s = DepSource::Git {
16894 repo: "github:o/x".into(),
16895 tag: Some("v1".into()),
16896 rev: None,
16897 branch: Some("main".into()),
16898 };
16899 assert_eq!(s.sole_pin(), Some("v1"));
16900 }
16901
16902 #[test]
16903 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16904 // Fail-before-pass-after byte-parity pin: the substrate accessor
16905 // must return byte-identical to the inline
16906 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16907 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16908 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16909 // time if the accessor's precedence silently drifts from the
16910 // consumer-side cascade — the exact drift this lift converges
16911 // to one substrate primitive to close structurally.
16912 //
16913 // Iterates through the 2^3 = 8 combinations of (tag, rev,
16914 // branch) each-either-`None`-or-`Some`, so every arm of the
16915 // precedence cascade lands under the pin. `validate()` refuses
16916 // the 4 multi-pin combinations, but the accessor's return is
16917 // defined on all 8.
16918 let vals = [Some("R".to_string()), None];
16919 for tag in &vals {
16920 for rev in &vals {
16921 for branch in &vals {
16922 let s = DepSource::Git {
16923 repo: "github:o/x".into(),
16924 tag: tag.clone(),
16925 rev: rev.clone(),
16926 branch: branch.clone(),
16927 };
16928 // The exact inline cascade the two pre-lift
16929 // consumer sites hand-rolled, byte-for-byte.
16930 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16931 assert_eq!(
16932 s.sole_pin(),
16933 expected,
16934 "sole_pin() must byte-equal \
16935 rev.or(tag).or(branch) for \
16936 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16937 a drift would silently split caixa-resolver's \
16938 fetch_git checkout target from caixa-crd's \
16939 dep_into_ref git_ref fill",
16940 );
16941 }
16942 }
16943 }
16944 }
16945
16946 // Fail-before-pass-after pins on the eleven
16947 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16948 // constructors folded from the [`DepSource::validate_caminho`]
16949 // wire-up sites. Each pins the generated ctor's output to the
16950 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16951 // any wrapper-side lowercase / trim / re-order / silent-field-swap
16952 // regression on the two-field `{ nome: nome.to_string(), caminho:
16953 // caminho.to_string() }` construction surfaces here rather than at
16954 // a downstream diagnostic-shape mismatch. Peer of the sibling
16955 // `empty_child_version_ctor_matches_struct_literal_wrap` /
16956 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16957 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16958 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16959 // pins on the peer `SupervisorError` / `AplicacaoError` /
16960 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16961
16962 #[test]
16963 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16964 assert_eq!(
16965 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16966 DepError::FonteCaminhoAbsolute {
16967 nome: "caixa-teia".to_string(),
16968 caminho: "/home/me/work/caixa-teia".to_string(),
16969 },
16970 "generated fonte_caminho_absolute ctor must produce byte-equal \
16971 DepError to the open-coded struct-literal wrap on the same \
16972 (&str, &str) fixture",
16973 );
16974 }
16975
16976 #[test]
16977 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16978 assert_eq!(
16979 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16980 DepError::FonteCaminhoTildeExpansion {
16981 nome: "caixa-teia".to_string(),
16982 caminho: "~/work/caixa-teia".to_string(),
16983 },
16984 );
16985 }
16986
16987 #[test]
16988 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16989 assert_eq!(
16990 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16991 DepError::FonteCaminhoVarExpansion {
16992 nome: "caixa-teia".to_string(),
16993 caminho: "$HOME/work/caixa-teia".to_string(),
16994 },
16995 );
16996 }
16997
16998 #[test]
16999 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17000 assert_eq!(
17001 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17002 DepError::FonteCaminhoLeadingWhitespace {
17003 nome: "caixa-teia".to_string(),
17004 caminho: " ../caixa-teia".to_string(),
17005 },
17006 );
17007 }
17008
17009 #[test]
17010 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17011 assert_eq!(
17012 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17013 DepError::FonteCaminhoLeadingHyphen {
17014 nome: "caixa-teia".to_string(),
17015 caminho: "-rf".to_string(),
17016 },
17017 );
17018 }
17019
17020 #[test]
17021 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17022 assert_eq!(
17023 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17024 DepError::FonteCaminhoBackslash {
17025 nome: "caixa-teia".to_string(),
17026 caminho: "..\\caixa-teia".to_string(),
17027 },
17028 );
17029 }
17030
17031 #[test]
17032 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17033 assert_eq!(
17034 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17035 DepError::FonteCaminhoShellPipe {
17036 nome: "caixa-teia".to_string(),
17037 caminho: "../caixa-teia|evil".to_string(),
17038 },
17039 );
17040 }
17041
17042 #[test]
17043 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17044 assert_eq!(
17045 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17046 DepError::FonteCaminhoShellSemicolon {
17047 nome: "caixa-teia".to_string(),
17048 caminho: "../caixa-teia;evil".to_string(),
17049 },
17050 );
17051 }
17052
17053 #[test]
17054 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17055 assert_eq!(
17056 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17057 DepError::FonteCaminhoShellBackground {
17058 nome: "caixa-teia".to_string(),
17059 caminho: "../caixa-teia&".to_string(),
17060 },
17061 );
17062 }
17063
17064 #[test]
17065 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17066 assert_eq!(
17067 DepError::fonte_caminho_shell_command_substitution(
17068 "caixa-teia",
17069 "../caixa-teia`whoami`",
17070 ),
17071 DepError::FonteCaminhoShellCommandSubstitution {
17072 nome: "caixa-teia".to_string(),
17073 caminho: "../caixa-teia`whoami`".to_string(),
17074 },
17075 );
17076 }
17077
17078 #[test]
17079 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17080 assert_eq!(
17081 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17082 DepError::FonteCaminhoTrailingSlash {
17083 nome: "caixa-teia".to_string(),
17084 caminho: "../caixa-teia/".to_string(),
17085 },
17086 );
17087 }
17088
17089 #[test]
17090 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17091 // Cross-axis pin: sweep the two constructor input axes
17092 // (`nome: &str`, `caminho: &str`) through a non-default fixture
17093 // pair against every generated arm in the
17094 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17095 // / trim / truncate / re-order on the two-field
17096 // `{ nome, caminho }` construction — or a silent field swap
17097 // between the two axes at codegen time — surfaces here rather
17098 // than at a downstream diagnostic-shape mismatch. Peer of the
17099 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17100 // to_string` cross-axis routing pin on the peer
17101 // `SupervisorError` envelope, extended here onto the
17102 // `DepError` `{ nome: String, caminho: String }` envelope so
17103 // every substrate-primitive ctor family in caixa-core
17104 // guarantees each `&str`-field construction routes the
17105 // caller's `&str` verbatim through `.to_string()`.
17106 let nome = "sibling-teia";
17107 let caminho = "../workspace/sibling";
17108 let cases: [(DepError, DepError); 11] = [
17109 (
17110 DepError::fonte_caminho_absolute(nome, caminho),
17111 DepError::FonteCaminhoAbsolute {
17112 nome: nome.to_string(),
17113 caminho: caminho.to_string(),
17114 },
17115 ),
17116 (
17117 DepError::fonte_caminho_tilde_expansion(nome, caminho),
17118 DepError::FonteCaminhoTildeExpansion {
17119 nome: nome.to_string(),
17120 caminho: caminho.to_string(),
17121 },
17122 ),
17123 (
17124 DepError::fonte_caminho_var_expansion(nome, caminho),
17125 DepError::FonteCaminhoVarExpansion {
17126 nome: nome.to_string(),
17127 caminho: caminho.to_string(),
17128 },
17129 ),
17130 (
17131 DepError::fonte_caminho_leading_whitespace(nome, caminho),
17132 DepError::FonteCaminhoLeadingWhitespace {
17133 nome: nome.to_string(),
17134 caminho: caminho.to_string(),
17135 },
17136 ),
17137 (
17138 DepError::fonte_caminho_leading_hyphen(nome, caminho),
17139 DepError::FonteCaminhoLeadingHyphen {
17140 nome: nome.to_string(),
17141 caminho: caminho.to_string(),
17142 },
17143 ),
17144 (
17145 DepError::fonte_caminho_backslash(nome, caminho),
17146 DepError::FonteCaminhoBackslash {
17147 nome: nome.to_string(),
17148 caminho: caminho.to_string(),
17149 },
17150 ),
17151 (
17152 DepError::fonte_caminho_shell_pipe(nome, caminho),
17153 DepError::FonteCaminhoShellPipe {
17154 nome: nome.to_string(),
17155 caminho: caminho.to_string(),
17156 },
17157 ),
17158 (
17159 DepError::fonte_caminho_shell_semicolon(nome, caminho),
17160 DepError::FonteCaminhoShellSemicolon {
17161 nome: nome.to_string(),
17162 caminho: caminho.to_string(),
17163 },
17164 ),
17165 (
17166 DepError::fonte_caminho_shell_background(nome, caminho),
17167 DepError::FonteCaminhoShellBackground {
17168 nome: nome.to_string(),
17169 caminho: caminho.to_string(),
17170 },
17171 ),
17172 (
17173 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17174 DepError::FonteCaminhoShellCommandSubstitution {
17175 nome: nome.to_string(),
17176 caminho: caminho.to_string(),
17177 },
17178 ),
17179 (
17180 DepError::fonte_caminho_trailing_slash(nome, caminho),
17181 DepError::FonteCaminhoTrailingSlash {
17182 nome: nome.to_string(),
17183 caminho: caminho.to_string(),
17184 },
17185 ),
17186 ];
17187 for (via_ctor, via_struct_literal) in cases {
17188 assert_eq!(
17189 via_ctor, via_struct_literal,
17190 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17191 through `.to_string()` in declared field order — a field-swap or \
17192 silent-conversion regression surfaces here rather than at a \
17193 downstream diagnostic-shape mismatch",
17194 );
17195 }
17196 }
17197
17198 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17199 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17200 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17201 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17202 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17203
17204 #[test]
17205 fn versao_empty_ctor_matches_struct_literal_wrap() {
17206 assert_eq!(
17207 DepError::versao_empty("caixa-teia"),
17208 DepError::VersaoEmpty {
17209 nome: "caixa-teia".to_string(),
17210 },
17211 );
17212 }
17213
17214 #[test]
17215 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17216 assert_eq!(
17217 DepError::fonte_repo_empty("caixa-teia"),
17218 DepError::FonteRepoEmpty {
17219 nome: "caixa-teia".to_string(),
17220 },
17221 );
17222 }
17223
17224 #[test]
17225 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17226 assert_eq!(
17227 DepError::fonte_pin_missing("caixa-teia"),
17228 DepError::FontePinMissing {
17229 nome: "caixa-teia".to_string(),
17230 },
17231 );
17232 }
17233
17234 #[test]
17235 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17236 assert_eq!(
17237 DepError::fonte_caminho_empty("caixa-teia"),
17238 DepError::FonteCaminhoEmpty {
17239 nome: "caixa-teia".to_string(),
17240 },
17241 );
17242 }
17243
17244 #[test]
17245 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17246 assert_eq!(
17247 DepError::caracteristica_empty("caixa-teia"),
17248 DepError::CaracteristicaEmpty {
17249 nome: "caixa-teia".to_string(),
17250 },
17251 );
17252 }
17253
17254 #[test]
17255 fn dep_nome_only_ctors_route_nome_through_to_string() {
17256 // Cross-axis routing pin: sweep the single constructor input
17257 // axis (`nome: &str`) through a non-default fixture against
17258 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17259 // any wrapper-side lowercase / trim / truncate at codegen time
17260 // — or a silent field re-name away from the canonical `nome`
17261 // axis on any one variant — surfaces here rather than at a
17262 // downstream diagnostic-shape mismatch. Peer of the sibling
17263 // `fonte_caminho_ctors_route_nome_and_caminho_through_
17264 // to_string` cross-axis routing pin on the same envelope's
17265 // two-slot family (f85f145) and of the peer
17266 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17267 // pin on the `SupervisorError` single-slot family (db09650).
17268 let nome = "sibling-teia";
17269 let cases: [(DepError, DepError); 5] = [
17270 (
17271 DepError::versao_empty(nome),
17272 DepError::VersaoEmpty {
17273 nome: nome.to_string(),
17274 },
17275 ),
17276 (
17277 DepError::fonte_repo_empty(nome),
17278 DepError::FonteRepoEmpty {
17279 nome: nome.to_string(),
17280 },
17281 ),
17282 (
17283 DepError::fonte_pin_missing(nome),
17284 DepError::FontePinMissing {
17285 nome: nome.to_string(),
17286 },
17287 ),
17288 (
17289 DepError::fonte_caminho_empty(nome),
17290 DepError::FonteCaminhoEmpty {
17291 nome: nome.to_string(),
17292 },
17293 ),
17294 (
17295 DepError::caracteristica_empty(nome),
17296 DepError::CaracteristicaEmpty {
17297 nome: nome.to_string(),
17298 },
17299 ),
17300 ];
17301 for (via_ctor, via_struct_literal) in cases {
17302 assert_eq!(
17303 via_ctor, via_struct_literal,
17304 "dep_nome_only_ctors!-generated ctor must route `nome` \
17305 through `.to_string()` onto the canonical `nome` field \
17306 — a field-rename or silent-conversion regression surfaces \
17307 here rather than at a downstream diagnostic-shape mismatch",
17308 );
17309 }
17310 }
17311
17312 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17313 // &'static str }` two-slot envelope on `DepError`, strict
17314 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17315 // same envelope's `{ nome: String }` one-slot shape and of the
17316 // peer `supervisor_caixa_only_ctors!` (db09650) on the
17317 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17318
17319 #[test]
17320 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17321 assert_eq!(
17322 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17323 DepError::DuplicateNome {
17324 nome: "caixa-teia".to_string(),
17325 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17326 },
17327 "generated duplicate_nome ctor must produce byte-equal \
17328 `DepError::DuplicateNome` to the pre-lift struct-literal \
17329 wrap on the same scalar fixtures",
17330 );
17331 }
17332
17333 #[test]
17334 fn dep_is_self_ctor_matches_struct_literal_wrap() {
17335 assert_eq!(
17336 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17337 DepError::DepIsSelf {
17338 nome: "orquestra".to_string(),
17339 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17340 },
17341 "generated dep_is_self ctor must produce byte-equal \
17342 `DepError::DepIsSelf` to the pre-lift struct-literal \
17343 wrap on the same scalar fixtures",
17344 );
17345 }
17346
17347 #[test]
17348 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17349 // Cross-axis routing pin: sweep the two constructor input axes
17350 // (`nome: &str`, `list: &'static str`) through non-default
17351 // fixtures against every generated arm in the
17352 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17353 // lowercase / trim / truncate at codegen time — or a silent
17354 // field re-name away from the canonical `nome` / `list` axes
17355 // on any one variant, or a `list` axis silently rerouted
17356 // through `.to_string()` instead of passed as `&'static str`
17357 // verbatim — surfaces here rather than at a downstream
17358 // diagnostic-shape mismatch. Peer of the sibling
17359 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17360 // (792aa92) on the same envelope's one-slot family, and of the
17361 // peer
17362 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17363 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17364 // two-slot `{ caixa: String, reason: String }` shape.
17365 let nome = "sibling-teia";
17366 let cases: [(DepError, DepError); 4] = [
17367 (
17368 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17369 DepError::DuplicateNome {
17370 nome: nome.to_string(),
17371 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17372 },
17373 ),
17374 (
17375 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17376 DepError::DuplicateNome {
17377 nome: nome.to_string(),
17378 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17379 },
17380 ),
17381 (
17382 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17383 DepError::DepIsSelf {
17384 nome: nome.to_string(),
17385 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17386 },
17387 ),
17388 (
17389 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17390 DepError::DepIsSelf {
17391 nome: nome.to_string(),
17392 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17393 },
17394 ),
17395 ];
17396 for (via_ctor, via_struct_literal) in cases {
17397 assert_eq!(
17398 via_ctor, via_struct_literal,
17399 "dep_nome_list_ctors!-generated ctor must route `nome` \
17400 through `.to_string()` onto the canonical `nome` field \
17401 and pass `list` verbatim onto the canonical `&'static str` \
17402 `list` field — a field-rename, silent-conversion, or \
17403 axis-swap regression surfaces here rather than at a \
17404 downstream diagnostic-shape mismatch",
17405 );
17406 }
17407 }
17408
17409 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17410 // value: String, reason: String }` four-slot envelope on
17411 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17412 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17413 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17414 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
17415 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
17416 // envelope. Single-variant lift closing the last open-coded ctor
17417 // site on the `:fonte (:tipo git …)` value-shape trajectory.
17418
17419 #[test]
17420 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17421 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17422 // ctor: sweep both wire-up-shape arms (the refname-pin arm
17423 // routing `":tag"` / `":branch"` value through
17424 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17425 // routing `":rev"` through [`crate::render::is_git_oid`]) and
17426 // assert byte-equal `PartialEq` against the pre-lift
17427 // struct-literal, so any wrapper-side field-rename /
17428 // silent-conversion regression surfaces here rather than at a
17429 // downstream diagnostic-shape mismatch. Peer of the sibling
17430 // per-envelope byte-equal ctor pins
17431 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17432 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17433 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17434 assert_eq!(
17435 DepError::fonte_pin_shape(
17436 "caixa-teia",
17437 ":tag",
17438 "v0.1.0 ",
17439 "trailing whitespace".to_string(),
17440 ),
17441 DepError::FontePinShape {
17442 nome: "caixa-teia".to_string(),
17443 pin: ":tag".to_string(),
17444 value: "v0.1.0 ".to_string(),
17445 reason: "trailing whitespace".to_string(),
17446 },
17447 "fonte_pin_shape ctor must produce byte-equal \
17448 `DepError::FontePinShape` to the pre-lift struct-literal \
17449 wrap on a refname-pin (`:tag` / `:branch`) fixture",
17450 );
17451 assert_eq!(
17452 DepError::fonte_pin_shape(
17453 "caixa-teia",
17454 ":rev",
17455 "DEADBEEF",
17456 "abbreviated OID rejected".to_string(),
17457 ),
17458 DepError::FontePinShape {
17459 nome: "caixa-teia".to_string(),
17460 pin: ":rev".to_string(),
17461 value: "DEADBEEF".to_string(),
17462 reason: "abbreviated OID rejected".to_string(),
17463 },
17464 "fonte_pin_shape ctor must produce byte-equal \
17465 `DepError::FontePinShape` to the pre-lift struct-literal \
17466 wrap on a hex-OID-pin (`:rev`) fixture",
17467 );
17468 }
17469
17470 #[test]
17471 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17472 // Cross-axis routing pin: sweep every one of the four
17473 // constructor input axes (`nome: &str`, `pin: &str`,
17474 // `value: &str`, `reason: String`) through non-default
17475 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17476 // any wrapper-side lowercase / trim / truncate at codegen time
17477 // — or a silent field re-name / axis-swap on any one of the
17478 // four fields, or a `reason` axis silently routed through
17479 // `.to_string()` instead of forwarded owned — surfaces here
17480 // rather than at a downstream diagnostic-shape mismatch. Peer
17481 // of the sibling
17482 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17483 // (792aa92) and
17484 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17485 // pin (6f5e0cd) on the same envelope's one- and two-slot
17486 // families. Distinct-per-axis fixtures rule out any two-axis
17487 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17488 // etc.) that would still pass a same-fixture-per-axis pin.
17489 let nome = "sibling-teia";
17490 let pin = ":branch";
17491 let value = "feature/bar";
17492 let reason = "embedded space".to_string();
17493 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17494 let via_struct_literal = DepError::FontePinShape {
17495 nome: nome.to_string(),
17496 pin: pin.to_string(),
17497 value: value.to_string(),
17498 reason: reason.clone(),
17499 };
17500 assert_eq!(
17501 via_ctor, via_struct_literal,
17502 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17503 through `.to_string()` onto their canonical fields and \
17504 forward `reason` owned onto the canonical `reason` field \
17505 — a field-rename, silent-conversion, or axis-swap \
17506 regression surfaces here rather than at a downstream \
17507 diagnostic-shape mismatch",
17508 );
17509 let DepError::FontePinShape {
17510 nome: n,
17511 pin: p,
17512 value: v,
17513 reason: r,
17514 } = via_ctor
17515 else {
17516 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17517 };
17518 assert_eq!(n, nome);
17519 assert_eq!(p, pin);
17520 assert_eq!(v, value);
17521 assert_eq!(r, reason);
17522 }
17523
17524 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17525 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17526 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17527 // the same envelope's `{ nome: String, caminho: String }` two-slot
17528 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17529 // same envelope's `{ nome: String }` one-slot shape.
17530
17531 #[test]
17532 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17533 assert_eq!(
17534 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17535 DepError::FonteCaminhoControlChar {
17536 nome: "caixa-teia".to_string(),
17537 caminho: "../caixa-teia\x00foo".to_string(),
17538 byte: 0x00,
17539 },
17540 );
17541 }
17542
17543 #[test]
17544 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17545 assert_eq!(
17546 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17547 DepError::FonteCaminhoShellRedirection {
17548 nome: "caixa-teia".to_string(),
17549 caminho: "../caixa-teia>log".to_string(),
17550 byte: b'>',
17551 },
17552 );
17553 }
17554
17555 #[test]
17556 #[allow(
17557 clippy::too_many_lines,
17558 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17559 byte-classification arm on the {nome,caminho,byte} envelope; \
17560 the linear per-variant repetition is exactly what the sweep \
17561 is pinning — a helper macro would hide the shape the fold is \
17562 keying on"
17563 )]
17564 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17565 // Cross-axis routing pin: sweep the three constructor input axes
17566 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17567 // non-default fixture triple against every generated arm in the
17568 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17569 // lowercase / trim / truncate on the two `&str` axes — a silent
17570 // field swap between `nome` and `caminho`, or a silent
17571 // re-classification of the offending byte — surfaces here rather
17572 // than at a downstream diagnostic-shape mismatch. Peer of the
17573 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17574 // to_string` cross-axis routing pin on the same envelope's
17575 // two-slot family (f85f145) and of the sibling
17576 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17577 // same envelope's one-slot family (792aa92), extended here onto
17578 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17579 // envelope so every substrate-primitive ctor family in
17580 // caixa-core's `DepError` envelope guarantees each field routes
17581 // the caller's value verbatim through `.to_string()` (or byte-
17582 // identity for `byte: u8`) in declared field order.
17583 let nome = "sibling-teia";
17584 let caminho = "../workspace/sibling";
17585 let byte = 0x2A_u8;
17586 let cases: [(DepError, DepError); 12] = [
17587 (
17588 DepError::fonte_caminho_control_char(nome, caminho, byte),
17589 DepError::FonteCaminhoControlChar {
17590 nome: nome.to_string(),
17591 caminho: caminho.to_string(),
17592 byte,
17593 },
17594 ),
17595 (
17596 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17597 DepError::FonteCaminhoShellRedirection {
17598 nome: nome.to_string(),
17599 caminho: caminho.to_string(),
17600 byte,
17601 },
17602 ),
17603 (
17604 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17605 DepError::FonteCaminhoShellGlob {
17606 nome: nome.to_string(),
17607 caminho: caminho.to_string(),
17608 byte,
17609 },
17610 ),
17611 (
17612 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17613 DepError::FonteCaminhoShellSubshellGrouping {
17614 nome: nome.to_string(),
17615 caminho: caminho.to_string(),
17616 byte,
17617 },
17618 ),
17619 (
17620 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17621 DepError::FonteCaminhoShellBraceExpansion {
17622 nome: nome.to_string(),
17623 caminho: caminho.to_string(),
17624 byte,
17625 },
17626 ),
17627 (
17628 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17629 DepError::FonteCaminhoShellBracketExpansion {
17630 nome: nome.to_string(),
17631 caminho: caminho.to_string(),
17632 byte,
17633 },
17634 ),
17635 (
17636 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17637 DepError::FonteCaminhoShellQuoteGrouping {
17638 nome: nome.to_string(),
17639 caminho: caminho.to_string(),
17640 byte,
17641 },
17642 ),
17643 (
17644 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17645 DepError::FonteCaminhoShellComment {
17646 nome: nome.to_string(),
17647 caminho: caminho.to_string(),
17648 byte,
17649 },
17650 ),
17651 (
17652 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17653 DepError::FonteCaminhoUrlPercentEncoding {
17654 nome: nome.to_string(),
17655 caminho: caminho.to_string(),
17656 byte,
17657 },
17658 ),
17659 (
17660 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17661 DepError::FonteCaminhoShellVariableExpansion {
17662 nome: nome.to_string(),
17663 caminho: caminho.to_string(),
17664 byte,
17665 },
17666 ),
17667 (
17668 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17669 DepError::FonteCaminhoShellHistoryExpansion {
17670 nome: nome.to_string(),
17671 caminho: caminho.to_string(),
17672 byte,
17673 },
17674 ),
17675 (
17676 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17677 DepError::FonteCaminhoShellHistorySubstitution {
17678 nome: nome.to_string(),
17679 caminho: caminho.to_string(),
17680 byte,
17681 },
17682 ),
17683 ];
17684 for (via_ctor, via_struct_literal) in cases {
17685 assert_eq!(
17686 via_ctor, via_struct_literal,
17687 "fonte_caminho_byte_ctors!-generated ctor must route \
17688 (nome, caminho, byte) through `.to_string()` / byte-\
17689 identity in declared field order — a field-swap or \
17690 silent-conversion regression surfaces here rather than \
17691 at a downstream diagnostic-shape mismatch",
17692 );
17693 }
17694 }
17695
17696 #[test]
17697 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17698 // Fail-before-pass-after byte-parity pin on the lifted
17699 // `impl AsRef<str> for DepList` — asserts the standard-
17700 // library trait impl and the substrate-primitive
17701 // [`super::DepList::as_str`] `pub const fn` accessor resolve
17702 // to the same `&str` per instance across the two-arm closed
17703 // set, so any future silent detour that routes the impl
17704 // through a divergent projection (a per-arm inline
17705 // `match self { DepList::Prod => ":deps", … }` re-inlining
17706 // that opens a compile-time link to the un-lifted arm-literal,
17707 // a swap onto a second projection axis) trips at caixa-core
17708 // test time under `PartialEq` rather than at a downstream
17709 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17710 // every one of the two arms [`super::DepList::ALL`] carries
17711 // so no arm's projection is covered only by the sibling
17712 // `Display` path. Peer of the sibling
17713 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17714 // (1723611) on the top-level dialect-classification closed-
17715 // set typed enum, and the peer
17716 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17717 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17718 // typed enum — the pins together close the substrate
17719 // primitive's `AsRef<str>` projection axis onto the seventh
17720 // (and last unlifted) closed-set typed enum on the caixa
17721 // surface.
17722 for &list in super::DepList::ALL {
17723 assert_eq!(
17724 <super::DepList as AsRef<str>>::as_ref(&list),
17725 list.as_str(),
17726 "AsRef<str> impl on DepList::{list:?} must byte-equal \
17727 DepList::as_str on the same instance — divergence \
17728 signals a silent detour off the substrate-primitive \
17729 accessor"
17730 );
17731 }
17732 }
17733
17734 #[test]
17735 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17736 // Fail-before-pass-after byte-parity pin on the three-path
17737 // convergence discipline the [`super::DepList`] two-list
17738 // dep-graph closed-set typed enum now carries on the `&str`-
17739 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17740 // newly lifted impl), `format!("{v}")` (the pre-existing
17741 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17742 // primitive `pub const fn` accessor both trait impls delegate
17743 // through) must resolve to the same byte-string on every
17744 // instance across the two-arm closed set. Refuses any future
17745 // divergence between the two trait impls (a stray
17746 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17747 // rather than delegating through the shared accessor; a
17748 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17749 // literal cascade) that would silently split the two
17750 // projection paths of the same closed-set typed enum. Mirrors
17751 // the sibling three-path-convergence discipline the peer
17752 // [`crate::CaixaDialeto`] typed enum carries
17753 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17754 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17755 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17756 // d8136db), the peer [`crate::CaixaKind`] triple
17757 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17758 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17759 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17760 // 16d5c7e).
17761 for &list in super::DepList::ALL {
17762 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17763 let via_display: String = format!("{list}");
17764 let via_accessor: &str = list.as_str();
17765 assert_eq!(via_as_ref, via_accessor);
17766 assert_eq!(via_display, via_accessor);
17767 assert_eq!(via_as_ref, via_display.as_str());
17768 }
17769 }
17770
17771 #[test]
17772 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
17773 // Fail-before-pass-after byte-parity pin on the newly lifted
17774 // `impl TryFrom<&str> for DepList` — asserts the standard-
17775 // library trait impl and the substrate-primitive
17776 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
17777 // to the same two-arm accept-set across every arm the
17778 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
17779 // the sibling
17780 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
17781 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
17782 // and the 12 other substrate-wide trait-idiomatic reverse-
17783 // projection routes-through pins — closes the campaign's
17784 // completeness gap on the two-list dep-graph closed-set enum.
17785 for &list in super::DepList::ALL {
17786 let wire = list.as_str();
17787 assert_eq!(
17788 <super::DepList as TryFrom<&str>>::try_from(wire),
17789 Ok(list),
17790 "TryFrom<&str> impl on DepList must round-trip \
17791 DepList::{list:?}.as_str() = {wire:?} back to \
17792 Ok(DepList::{list:?}) — divergence from \
17793 DepList::from_wire signals a silent detour off the \
17794 substrate-primitive accessor"
17795 );
17796 assert_eq!(
17797 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
17798 super::DepList::from_wire(wire),
17799 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
17800 DepList::from_wire on the same input"
17801 );
17802 }
17803 }
17804
17805 #[test]
17806 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
17807 // Rejection witness on the `impl TryFrom<&str> for DepList` —
17808 // sweeps candidate byte-strings outside the two-arm accept-set
17809 // the sibling [`super::DepList::as_str`] emits (`:deps` /
17810 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
17811 // future accidental widening of the trait impl's accept-set (a
17812 // stray case-fold path, a silent inclusion of a rebrand alias
17813 // like `":packages"`, an English rebrand `":dev-deps"` in
17814 // reverse arm-order that would silently swap the two arms) trips
17815 // at caixa-core test time. Peer of the sibling
17816 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
17817 // (5b828ed) rejection witness.
17818 let rejected: &[&str] = &[
17819 "",
17820 " ",
17821 "\t",
17822 "\n",
17823 ":deps ",
17824 " :deps",
17825 ":DEPS",
17826 ":Deps",
17827 ":Deps-Dev",
17828 ":deps_dev",
17829 ":deps-development",
17830 ":dev-deps",
17831 ":packages",
17832 ":packages-dev",
17833 "deps",
17834 "deps-dev",
17835 "Prod",
17836 "Dev",
17837 "prod",
17838 "dev",
17839 "\":deps\"",
17840 "\":deps-dev\"",
17841 ":deps\n",
17842 ":deps-dev\n",
17843 ];
17844 for &input in rejected {
17845 assert_eq!(
17846 <super::DepList as TryFrom<&str>>::try_from(input),
17847 Err(()),
17848 "TryFrom<&str> impl on DepList must reject unknown \
17849 byte-string {input:?} — divergence from \
17850 DepList::from_wire on the same input signals a silent \
17851 accept-set widening past the two lifted \
17852 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
17853 );
17854 assert_eq!(
17855 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
17856 super::DepList::from_wire(input),
17857 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
17858 DepList::from_wire on the same input — divergence signals \
17859 the two reverse-projection paths have drifted onto \
17860 different accept-sets"
17861 );
17862 }
17863 }
17864
17865 #[test]
17866 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
17867 // Fail-before-pass-after byte-parity pin on the newly lifted
17868 // `impl From<DepList> for &'static str` — asserts the standard-
17869 // library trait impl and the substrate-primitive
17870 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17871 // the same two-arm emit-set across every arm the exhaustive
17872 // [`super::DepList::ALL`] slice enumerates. Materializes the
17873 // `<&'static str as From<DepList>>::from` output in a
17874 // `const`-shape binding to make the `'static` lifetime promise
17875 // a build-time invariant — a future accidental downgrade of
17876 // either arm to a non-`&'static str` (a `String::leak()`-
17877 // produced return, a `Box::leak`-cast) trips at caixa-core
17878 // build time rather than at a downstream `'static`-bound
17879 // consumer. Peer of the sibling
17880 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
17881 // (523157d) and the 13 other substrate-wide forward-projection
17882 // routes-through pins.
17883 const PROD: &str = super::DepList::Prod.as_str();
17884 const DEV: &str = super::DepList::Dev.as_str();
17885 for &list in super::DepList::ALL {
17886 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17887 let via_method: &'static str = list.as_str();
17888 assert_eq!(
17889 via_trait, via_method,
17890 "From<DepList> for &'static str impl must round-trip \
17891 DepList::{list:?} to the same lifted \
17892 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17893 DepList::as_str returns — divergence signals a silent \
17894 detour off the substrate-primitive accessor"
17895 );
17896 let via_into: &'static str = list.into();
17897 assert_eq!(
17898 via_into, via_method,
17899 "Into<&'static str>::into on DepList::{list:?} must \
17900 byte-equal DepList::as_str on the same input — the \
17901 blanket-derived Into shape must resolve to the same \
17902 as_str dispatch as the explicit From impl"
17903 );
17904 }
17905 assert_eq!(
17906 [PROD, DEV],
17907 [
17908 crate::render::DEP_AUTHOR_KEY_DEPS,
17909 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17910 ],
17911 "const-context DepList::as_str must resolve to the two lifted \
17912 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
17913 of either arm to a non-const or non-static byte-string breaks \
17914 the `&'static str`-lifetime promise the paired \
17915 From<DepList> for &'static str impl carries by construction"
17916 );
17917 }
17918
17919 #[test]
17920 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
17921 // Cross-axis partition pin: the paired trait-idiomatic
17922 // `From<DepList> for &'static str` forward projection and the
17923 // method-named [`super::DepList::as_str`] forward projection
17924 // must resolve identically on every arm, locking the two paths
17925 // together so any future detour trips at caixa-core test time.
17926 // Then a round-trip witness: every arm's forward `From` output
17927 // re-parses through the paired trait-idiomatic reverse
17928 // `TryFrom<&str>` back to the original variant, closing the
17929 // two-way `DepList ↔ &'static str` round-trip on the trait-
17930 // idiomatic axis pair, mirroring the pre-existing method-named
17931 // `as_str` + `from_wire` round-trip. Peer of the sibling
17932 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
17933 // (523157d).
17934 for &list in super::DepList::ALL {
17935 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17936 let via_method: &'static str = list.as_str();
17937 assert_eq!(
17938 via_trait, via_method,
17939 "From<DepList> for &'static str and DepList::as_str must \
17940 resolve identically on DepList::{list:?} — divergence \
17941 signals the two forward-projection paths have drifted \
17942 onto different emit-sets"
17943 );
17944 }
17945 for &list in super::DepList::ALL {
17946 let emitted: &'static str = list.into();
17947 let re_parsed: Result<super::DepList, ()> =
17948 <super::DepList as TryFrom<&str>>::try_from(emitted);
17949 assert_eq!(
17950 re_parsed,
17951 Ok(list),
17952 "trait-idiomatic axis pair must round-trip \
17953 DepList::{list:?} through `.into::<&'static str>()` and \
17954 back through `TryFrom<&str>` — a break signals the \
17955 forward-emit and reverse-parse axes have drifted onto \
17956 different vocabularies"
17957 );
17958 }
17959 }
17960
17961 #[test]
17962 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
17963 // Fail-before-pass-after byte-parity pin on the newly lifted
17964 // `impl From<&DepList> for &'static str` — asserts the borrowed-
17965 // input standard-library trait impl and the substrate-primitive
17966 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17967 // the same two-arm emit-set across every arm the exhaustive
17968 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
17969 // does not auto-derive the borrowed-input sibling from a paired
17970 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
17971 // U: From<T>` blanket in `core`), so the borrowed-input axis is
17972 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
17973 // shape over [`super::DepList::ALL`] (whose iterator yields
17974 // `&DepList`, not `DepList`) reaches through this impl and no
17975 // other — the paired owned-input [`From<DepList>`] impl requires
17976 // an explicit `.copied()` / dereference before the trait fires.
17977 // Materializes the `<&'static str as From<&DepList>>::from`
17978 // output in a `const`-shape binding to make the `'static`
17979 // lifetime promise a build-time invariant.
17980 const PROD: &str = super::DepList::Prod.as_str();
17981 const DEV: &str = super::DepList::Dev.as_str();
17982 for list in super::DepList::ALL {
17983 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
17984 let via_method: &'static str = list.as_str();
17985 assert_eq!(
17986 via_trait, via_method,
17987 "From<&DepList> for &'static str impl must round-trip \
17988 &DepList::{list:?} to the same lifted \
17989 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17990 DepList::as_str returns — divergence signals a silent \
17991 detour off the substrate-primitive accessor"
17992 );
17993 let via_into: &'static str = list.into();
17994 assert_eq!(
17995 via_into, via_method,
17996 "Into<&'static str>::into on &DepList::{list:?} must \
17997 byte-equal DepList::as_str on the same input — the \
17998 blanket-derived Into shape must resolve to the same \
17999 as_str dispatch as the explicit From impl"
18000 );
18001 }
18002 assert_eq!(
18003 [PROD, DEV],
18004 [
18005 crate::render::DEP_AUTHOR_KEY_DEPS,
18006 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18007 ],
18008 "const-context DepList::as_str must resolve to the two lifted \
18009 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18010 From<&DepList> for &'static str impl inherits its `'static` \
18011 lifetime promise from the same accessor the owned-input \
18012 sibling routes through"
18013 );
18014 }
18015
18016 #[test]
18017 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18018 // Cross-axis partition pin: the paired trait-idiomatic
18019 // owned-input `From<DepList> for &'static str` (523157d
18020 // campaign-shape) and borrowed-input `From<&DepList> for
18021 // &'static str` (this lift) forward projections must resolve
18022 // identically on every arm, locking the two input-shape paths
18023 // together so any future detour trips at caixa-core test time.
18024 // Then a witness that a `.iter().map(Into::into)` pipe over
18025 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18026 // materializes the two-arm accept-set through the borrowed-
18027 // input axis alone — the exact shape a future M4 admission-
18028 // webhook rejection body composer, a future substrate-wide
18029 // per-arm diagnostic column, or a
18030 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18031 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18032 // through — closing the two-way owned/borrowed input-shape
18033 // symmetry on the forward-projection trait-idiomatic axis.
18034 for &list in super::DepList::ALL {
18035 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18036 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18037 assert_eq!(
18038 owned, borrowed,
18039 "From<DepList> and From<&DepList> for &'static str must \
18040 resolve identically on DepList::{list:?} — divergence \
18041 signals the owned-input and borrowed-input forward-\
18042 projection paths have drifted onto different emit-sets"
18043 );
18044 }
18045 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18046 let via_method: Vec<&'static str> =
18047 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18048 assert_eq!(
18049 via_iter, via_method,
18050 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18051 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18052 input `From<&DepList> for &'static str` axis is what makes \
18053 the `.iter().map(Into::into)` shape route through the \
18054 substrate-primitive `DepList::as_str` accessor rather than \
18055 through a per-call-site `.copied()` / dereference detour"
18056 );
18057 }
18058
18059 #[test]
18060 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18061 // Fail-before-pass-after byte-parity pin on the newly lifted
18062 // `impl From<DepList> for String` — asserts the owned-`String`
18063 // -returning standard-library trait impl and the substrate-
18064 // primitive [`super::DepList::as_str`] `pub const fn` accessor
18065 // resolve to the same two-arm emit-set across every arm the
18066 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18067 // standard library does not carry a blanket
18068 // `impl<T: AsRef<str>> From<T> for String` (nor an
18069 // `impl<T: fmt::Display> From<T> for String`), so the
18070 // owned-`String` forward-projection axis is a distinct trait-
18071 // idiomatic surface that a `let key: String = list.into();`-
18072 // shaped call site reaches through this impl and no other — the
18073 // paired sibling `From<DepList> for &'static str` impl forces
18074 // every owned-`String` call site through an explicit
18075 // `.to_owned()` / `String::from` restatement. Peer of the
18076 // first-mover
18077 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18078 // (7baa18a), the second-peer
18079 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18080 // (7851725), the third-peer
18081 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18082 // (231a18c), and the fourth-peer
18083 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18084 // (88942cd) — extends the trait-idiomatic owned-`String`
18085 // forward-projection axis onto the fifth closed-set fieldless
18086 // typed enum on the caixa surface (the two-list dep-graph axis).
18087 for &variant in super::DepList::ALL {
18088 let via_trait: String = <String as From<super::DepList>>::from(variant);
18089 let via_method: &'static str = variant.as_str();
18090 assert_eq!(
18091 via_trait.as_str(),
18092 via_method,
18093 "From<DepList> for String impl must round-trip \
18094 DepList::{variant:?} to the same lifted \
18095 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18096 DepList::as_str returns — divergence signals a silent \
18097 detour off the substrate-primitive accessor"
18098 );
18099 let via_into: String = variant.into();
18100 assert_eq!(
18101 via_into.as_str(),
18102 via_method,
18103 "Into<String>::into on DepList::{variant:?} must \
18104 byte-equal DepList::as_str on the same input — the \
18105 blanket-derived Into shape must resolve to the same \
18106 as_str dispatch as the explicit From impl"
18107 );
18108 }
18109 }
18110
18111 #[test]
18112 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18113 // Cross-axis partition pin: the paired trait-idiomatic
18114 // owned-`String` `From<DepList> for String` (this lift) and
18115 // owned-`&'static str` `From<DepList> for &'static str`
18116 // (523157d campaign-shape) forward projections must resolve
18117 // identically on every arm, locking the two return-type-shape
18118 // paths together so any future detour trips at caixa-core test
18119 // time. Also byte-parity witness against the sibling
18120 // [`ToString::to_string`] surface routed through
18121 // [`std::fmt::Display`] — the three owned-heap-string paths
18122 // (`.into::<String>()`, `String::from`, `.to_string()`) must
18123 // resolve identically on every arm so a future consumer that
18124 // picks any of the three lands on the same two-arm lifted
18125 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18126 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18127 // Then a `.iter().copied().map(String::from)` pipe witness
18128 // over [`super::DepList::ALL`] that materializes the two-arm
18129 // accept-set through the owned-`String` axis alone — the exact
18130 // shape a future M4 admission-webhook rejection body composer
18131 // or a
18132 // `HashMap::<String, DepList>::from_iter(
18133 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18134 // style owned-key per-list lookup reaches through — closing the
18135 // owned-`String` forward-projection axis's iterator-pipe shape.
18136 // Then a direct round-trip witness through the paired
18137 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18138 // owned-`String`'s [`String::as_str`] borrow that closes the
18139 // two-way `Self → String → Self` round-trip on the trait-
18140 // idiomatic owned-`String` forward + reverse axis pair.
18141 //
18142 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18143 // `From` emit lands on the lowercase Portuguese `as_str`
18144 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18145 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18146 // forcing the round-trip through an intermediate
18147 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18148 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18149 // parse resolve through the same lifted
18150 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18151 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18152 // construction (there is no wire/diagnostic axis split on this
18153 // enum), so the owned-`String` forward axis and the reverse
18154 // axis compose directly — matching the peer
18155 // [`crate::supervisor::RestartStrategy`] /
18156 // [`crate::supervisor::RestartPolicy`] /
18157 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18158 for &list in super::DepList::ALL {
18159 let owned_string: String = <String as From<super::DepList>>::from(list);
18160 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18161 assert_eq!(
18162 owned_string.as_str(),
18163 owned_static,
18164 "From<DepList> for String and From<DepList> for \
18165 &'static str must resolve identically on \
18166 DepList::{list:?} — divergence signals the owned-\
18167 `String` and owned-`&'static str` forward-projection \
18168 return-type-shape paths have drifted onto different \
18169 emit-sets"
18170 );
18171 let via_to_string: String = list.to_string();
18172 assert_eq!(
18173 owned_string, via_to_string,
18174 "From<DepList> for String must byte-equal \
18175 DepList::to_string on DepList::{list:?} — divergence \
18176 signals the trait-idiomatic owned-`String` forward-\
18177 projection axis and the ToString-through-Display axis \
18178 have drifted onto different emit-sets"
18179 );
18180 }
18181 let via_iter: Vec<String> = super::DepList::ALL
18182 .iter()
18183 .copied()
18184 .map(String::from)
18185 .collect();
18186 let via_method: Vec<String> = super::DepList::ALL
18187 .iter()
18188 .map(|l| l.as_str().to_owned())
18189 .collect();
18190 assert_eq!(
18191 via_iter, via_method,
18192 "`.iter().copied().map(String::from)` over DepList::ALL must \
18193 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18194 every arm — the owned-`String` `From<DepList> for String` \
18195 axis is what makes the `String::from` composition route \
18196 through the substrate-primitive `DepList::as_str` accessor \
18197 rather than through a per-call-site `.to_owned()` / \
18198 `String::from(list.as_str())` detour"
18199 );
18200 for &variant in super::DepList::ALL {
18201 let emitted: String = variant.into();
18202 let re_parsed: Result<super::DepList, ()> =
18203 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18204 assert_eq!(
18205 re_parsed,
18206 Ok(variant),
18207 "trait-idiomatic owned-`String` forward-projection + \
18208 reverse-projection axis pair must round-trip \
18209 DepList::{variant:?} through `.into::<String>()` and \
18210 back through `TryFrom<&str>` on the owned-`String`'s \
18211 String::as_str borrow — a break signals the owned-\
18212 `String` forward-emit and reverse-parse axes have \
18213 drifted onto different vocabularies (unlike the peer \
18214 CaixaKind axis pair, DepList's forward emit and \
18215 reverse parse share the same lifted \
18216 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18217 round-trip composes directly)"
18218 );
18219 }
18220 }
18221
18222 #[test]
18223 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18224 // Fail-before-pass-after byte-parity pin on the newly lifted
18225 // `impl From<&DepList> for String` — asserts the borrowed-input
18226 // owned-`String`-returning standard-library trait impl and the
18227 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18228 // accessor resolve to the same two-arm emit-set across every
18229 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18230 // Rust's standard library does not carry a blanket
18231 // `impl<T: AsRef<str>> From<&T> for String` (nor an
18232 // `impl<T: fmt::Display> From<&T> for String`), so the
18233 // borrowed-input owned-`String` forward-projection axis is a
18234 // distinct trait-idiomatic surface that a
18235 // `let key: String = (&list).into();`-shaped call site reaches
18236 // through this impl and no other — the paired sibling
18237 // `From<DepList> for String` impl forces every borrowed-input
18238 // call site through an explicit `Copy` deref
18239 // (`String::from(*list)`) or an `.as_str().to_owned()` /
18240 // `.to_string()` detour. Peer of the first-mover
18241 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18242 // (579385f) and the second-peer
18243 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18244 // (8465740) — extends the trait-idiomatic borrowed-input owned-
18245 // `String` forward-projection axis off the M2 OTP-shape sibling
18246 // axis pair onto the first non-M2 closed-set fieldless typed
18247 // enum peer (the two-list dep-graph axis).
18248 for &variant in super::DepList::ALL {
18249 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18250 let via_method: &'static str = variant.as_str();
18251 assert_eq!(
18252 via_trait.as_str(),
18253 via_method,
18254 "From<&DepList> for String impl must round-trip \
18255 &DepList::{variant:?} to the same lifted \
18256 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18257 DepList::as_str returns — divergence signals a silent \
18258 detour off the substrate-primitive accessor"
18259 );
18260 let via_into: String = (&variant).into();
18261 assert_eq!(
18262 via_into.as_str(),
18263 via_method,
18264 "Into<String>::into on &DepList::{variant:?} must \
18265 byte-equal DepList::as_str on the same input — the \
18266 blanket-derived Into shape must resolve to the same \
18267 as_str dispatch as the explicit From impl"
18268 );
18269 }
18270 }
18271
18272 #[test]
18273 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18274 // Cross-axis partition pin: the newly lifted trait-idiomatic
18275 // borrowed-input owned-`String` `From<&DepList> for String`
18276 // (this lift), the paired owned-input owned-`String`
18277 // `From<DepList> for String` (32b0ee8), the paired borrowed-
18278 // input owned-`&'static str` `From<&DepList> for &'static str`
18279 // (64aa742), and the paired owned-input owned-`&'static str`
18280 // `From<DepList> for &'static str` (3455cbf) — every corner of
18281 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18282 // idiomatic projection family — must resolve identically on
18283 // every arm, locking the four return-shape × input-shape paths
18284 // together so any future detour trips at caixa-core test time.
18285 // Also byte-parity witness against the sibling
18286 // [`ToString::to_string`] surface routed through
18287 // [`std::fmt::Display`] and a direct round-trip witness through
18288 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18289 // the owned-`String`'s [`String::as_str`] borrow that closes
18290 // the two-way `&Self → String → Self` round-trip on the trait-
18291 // idiomatic borrowed-input owned-`String` forward + reverse
18292 // axis pair. Peer of the first-mover
18293 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18294 // (579385f) and the second-peer
18295 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18296 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18297 // String}` 2×2 projection corner on the third substrate-wide
18298 // closed-set fieldless typed enum peer (the two-list dep-graph
18299 // axis, first outside the M2 OTP-shape sibling pair).
18300 //
18301 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18302 // `From` emit lands on the lowercase Portuguese `as_str`
18303 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18304 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18305 // forcing the round-trip through an intermediate
18306 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18307 // [`super::DepList::as_str`] emit and
18308 // [`super::DepList::from_wire`] parse resolve through the same
18309 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18310 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18311 // construction (there is no wire/diagnostic axis split on this
18312 // enum), so the borrowed-input owned-`String` forward axis and
18313 // the reverse axis compose directly — matching the peer
18314 // [`crate::supervisor::RestartStrategy`] /
18315 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18316 // `String` axis pairs.
18317 for &list in super::DepList::ALL {
18318 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18319 let owned_string: String = <String as From<super::DepList>>::from(list);
18320 let borrowed_static: &'static str =
18321 <&'static str as From<&super::DepList>>::from(&list);
18322 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18323 assert_eq!(
18324 borrowed_string, owned_string,
18325 "From<&DepList> for String and From<DepList> for String \
18326 must resolve identically on DepList::{list:?} — \
18327 divergence signals the borrowed-input and owned-input \
18328 owned-`String` forward-projection input-shape paths \
18329 have drifted onto different emit-sets"
18330 );
18331 assert_eq!(
18332 borrowed_string.as_str(),
18333 borrowed_static,
18334 "From<&DepList> for String and From<&DepList> for \
18335 &'static str must resolve identically on \
18336 DepList::{list:?} — divergence signals the borrowed-\
18337 input `&'static str` and owned-`String` return-shape \
18338 paths have drifted onto different emit-sets"
18339 );
18340 assert_eq!(
18341 borrowed_string.as_str(),
18342 owned_static,
18343 "From<&DepList> for String and From<DepList> for \
18344 &'static str must resolve identically on \
18345 DepList::{list:?} — divergence signals a break in the \
18346 diagonal corner of the {{Self, &Self}} × {{&'static \
18347 str, String}} 2×2 trait-idiomatic projection family"
18348 );
18349 let via_to_string: String = list.to_string();
18350 assert_eq!(
18351 borrowed_string, via_to_string,
18352 "From<&DepList> for String must byte-equal \
18353 DepList::to_string on DepList::{list:?} — divergence \
18354 signals the trait-idiomatic borrowed-input owned-\
18355 `String` forward-projection axis and the ToString-\
18356 through-Display axis have drifted onto different \
18357 emit-sets"
18358 );
18359 }
18360 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18361 let via_method: Vec<String> = super::DepList::ALL
18362 .iter()
18363 .map(|l| l.as_str().to_owned())
18364 .collect();
18365 assert_eq!(
18366 via_iter, via_method,
18367 "`.iter().map(String::from)` over DepList::ALL — a call \
18368 site whose iteration axis holds `&DepList` by construction \
18369 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18370 on every arm — the borrowed-input owned-`String` \
18371 `From<&DepList> for String` axis is what makes the \
18372 `String::from` composition route through the substrate-\
18373 primitive `DepList::as_str` accessor without a spurious \
18374 `Copy` deref (which would only be reachable through the \
18375 owned-input `From<DepList> for String` axis by first \
18376 calling `.copied()` on the iterator)"
18377 );
18378 for &variant in super::DepList::ALL {
18379 let emitted: String = (&variant).into();
18380 let re_parsed: Result<super::DepList, ()> =
18381 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18382 assert_eq!(
18383 re_parsed,
18384 Ok(variant),
18385 "trait-idiomatic borrowed-input owned-`String` \
18386 forward-projection + reverse-projection axis pair must \
18387 round-trip &DepList::{variant:?} through \
18388 `.into::<String>()` on the borrowed-input surface and \
18389 back through `TryFrom<&str>` on the owned-`String`'s \
18390 String::as_str borrow — a break signals the \
18391 borrowed-input owned-`String` forward-emit and \
18392 reverse-parse axes have drifted onto different \
18393 vocabularies (unlike the peer CaixaKind axis pair, \
18394 DepList's forward emit and reverse parse share the \
18395 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18396 construction, so the round-trip composes directly)"
18397 );
18398 }
18399 }
18400}
18401
18402#[cfg(test)]
18403mod dep_source_is_variant_tests {
18404 use super::*;
18405
18406 fn all_variants() -> Vec<(DepSource, &'static str)> {
18407 vec![
18408 (
18409 DepSource::Git {
18410 repo: "github:pleme-io/caixa-teia".into(),
18411 tag: Some("v0.1.0".into()),
18412 rev: None,
18413 branch: None,
18414 },
18415 "Git",
18416 ),
18417 (
18418 DepSource::Path {
18419 caminho: "../caixa-teia".into(),
18420 },
18421 "Path",
18422 ),
18423 ]
18424 }
18425
18426 fn predicate_row(s: &DepSource) -> [bool; 2] {
18427 [s.is_git(), s.is_path()]
18428 }
18429
18430 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
18431 // derive-generated per-arm predicate partition — for every variant
18432 // in `all_variants()`, the observed 2-slot predicate row must equal
18433 // a one-hot row with the `true` at exactly the same index as the
18434 // variant's declaration order. Expected rows are generated live
18435 // from the enumeration rather than transcribed by hand, so a
18436 // copy-paste flip that reroutes one arm through the wrong predicate
18437 // lane trips at the identity-diagonal assertion the way every peer
18438 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
18439 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
18440 // / [`crate::upgrade::UpgradeInstruction`] /
18441 // [`crate::aplicacao::PlacementStrategy`] /
18442 // [`crate::aplicacao::RateLimitUnit`] /
18443 // [`crate::aplicacao::WitTarget`] /
18444 // [`crate::render::PathShapeViolation`] partition pin already does.
18445 #[test]
18446 fn dep_source_is_variant_predicates_partition_the_arm_set() {
18447 let variants = all_variants();
18448 for (idx, (variant, name)) in variants.iter().enumerate() {
18449 let observed = predicate_row(variant);
18450 let mut expected = [false; 2];
18451 expected[idx] = true;
18452 assert_eq!(
18453 observed, expected,
18454 "DepSource::{name} at declaration-order slot {idx} must \
18455 satisfy exactly one is_* predicate (its own); observed \
18456 row must equal the one-hot expected row — a drift \
18457 would silently reroute one `:fonte`-arm consumer \
18458 through the wrong predicate lane"
18459 );
18460 }
18461 }
18462
18463 // Byte-parity pin on the two field-agnostic `matches!` shapes the
18464 // per-arm arm-discriminator predicates replace at any future
18465 // consumer site (a `:fonte`-shape-only lint rule that flags path
18466 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
18467 // a future admission-webhook that rejects `:fonte` shapes outside
18468 // the `is_git()` accept-set, a caixa-lacre indexing pass that
18469 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
18470 // Refuses a future accidental split between the derived predicate
18471 // and its `matches!` shape — a hand-rolled shadow impl that
18472 // overrides one path, an accidental rebrand that leaves one
18473 // consumer on the raw `matches!` form — on the two load-bearing
18474 // `:fonte`-arm-discriminator axes every downstream substrate
18475 // consumer of the dep-source axis keys off.
18476 #[test]
18477 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
18478 for (variant, name) in all_variants() {
18479 let via_matches_git = matches!(variant, DepSource::Git { .. });
18480 let via_predicate_git = variant.is_git();
18481 assert_eq!(
18482 via_predicate_git, via_matches_git,
18483 "DepSource::{name}.is_git() must byte-equal \
18484 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
18485 future converged consumer site would silently \
18486 disagree with its pre-lift shape"
18487 );
18488 let via_matches_path = matches!(variant, DepSource::Path { .. });
18489 let via_predicate_path = variant.is_path();
18490 assert_eq!(
18491 via_predicate_path, via_matches_path,
18492 "DepSource::{name}.is_path() must byte-equal \
18493 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
18494 future converged consumer site would silently \
18495 disagree with its pre-lift shape"
18496 );
18497 }
18498 }
18499
18500 // Cross-pin against every constructor path that materializes a
18501 // [`DepSource`] shape today (the [`DepSource::default_github`]
18502 // resolver-side fallback that materializes an unpinned
18503 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
18504 // surface constructor that materializes a pinned `:tag`-carrying
18505 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
18506 // fixture family builds inline). Every constructor's return must
18507 // satisfy the arm-discriminator predicate the constructor's
18508 // variant name matches — a future constructor addition (an
18509 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
18510 // enclosing docstring already names as a trajectory item) surfaces
18511 // as a build-time failure that names the offending drift when its
18512 // return arm doesn't route through the paired predicate.
18513 #[test]
18514 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
18515 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
18516 assert!(
18517 via_default_github.is_git(),
18518 "DepSource::default_github must materialize a Git-arm shape — \
18519 a future constructor that routed through a non-Git arm \
18520 (a registry-fetch pin, a `DepSource::Feira` promotion) \
18521 would silently split the resolver's unpinned-shorthand \
18522 materializer from the sole_pin() precedence cascade"
18523 );
18524 assert!(
18525 !via_default_github.is_path(),
18526 "DepSource::default_github must NOT materialize a Path-arm \
18527 shape — the paired negation pin"
18528 );
18529
18530 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
18531 .fonte
18532 .expect("Dep::git materializes a Some(fonte)");
18533 assert!(
18534 via_dep_git.is_git(),
18535 "Dep::git's `:fonte` materialization must land on the Git \
18536 arm — the author-surface pinned-git constructor's return \
18537 must route through the paired predicate"
18538 );
18539 assert!(!via_dep_git.is_path(), "paired negation pin");
18540
18541 let via_path = DepSource::Path {
18542 caminho: "../caixa-teia".into(),
18543 };
18544 assert!(
18545 via_path.is_path(),
18546 "the dev-mode Path-arm materialization must satisfy is_path()"
18547 );
18548 assert!(!via_path.is_git(), "paired negation pin");
18549 }
18550
18551 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
18552 // String, reason: String }` three-slot envelope on `DepError`,
18553 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
18554 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
18555 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
18556 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
18557 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
18558 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
18559
18560 #[test]
18561 fn versao_invalid_ctor_matches_struct_literal_wrap() {
18562 assert_eq!(
18563 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
18564 DepError::VersaoInvalid {
18565 nome: "caixa-teia".to_string(),
18566 versao: "^0..1".to_string(),
18567 reason: "invalid comparator".to_string(),
18568 },
18569 "versao_invalid ctor must produce byte-equal \
18570 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
18571 );
18572 }
18573
18574 #[test]
18575 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
18576 assert_eq!(
18577 DepError::fonte_repo_shape(
18578 "caixa-teia",
18579 "-upload-pack=evil",
18580 "leading dash rejected".to_string(),
18581 ),
18582 DepError::FonteRepoShape {
18583 nome: "caixa-teia".to_string(),
18584 repo: "-upload-pack=evil".to_string(),
18585 reason: "leading dash rejected".to_string(),
18586 },
18587 "fonte_repo_shape ctor must produce byte-equal \
18588 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
18589 );
18590 }
18591
18592 #[test]
18593 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
18594 assert_eq!(
18595 DepError::caracteristica_invalid(
18596 "caixa-teia",
18597 "bad feature!",
18598 "embedded space rejected".to_string(),
18599 ),
18600 DepError::CaracteristicaInvalid {
18601 nome: "caixa-teia".to_string(),
18602 caracteristica: "bad feature!".to_string(),
18603 reason: "embedded space rejected".to_string(),
18604 },
18605 "caracteristica_invalid ctor must produce byte-equal \
18606 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
18607 );
18608 }
18609
18610 #[test]
18611 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
18612 // Cross-axis routing pin: sweep the three constructor input axes
18613 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
18614 // distinct-per-axis fixtures against every generated arm in the
18615 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
18616 // lowercase / trim / truncate on the two `&str` axes — a silent
18617 // field swap between `nome`, the middle `<axis>` field, and
18618 // `reason`, or a `reason` axis silently rerouted through
18619 // `.to_string()` instead of forwarded owned — surfaces here rather
18620 // than at a downstream diagnostic-shape mismatch. Peer of the
18621 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
18622 // through_to_string` (0e35793) cross-axis routing pin on the same
18623 // envelope's `{ nome, caminho, byte }` three-slot family and of
18624 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
18625 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
18626 // — extended here onto the `{ nome, <axis>: String, reason:
18627 // String }` three-slot envelope so every substrate-primitive ctor
18628 // family in caixa-core's `DepError` envelope guarantees each field
18629 // routes the caller's value verbatim through `.to_string()` (or
18630 // owned-forward for `reason: String`) in declared field order.
18631 // Distinct-per-axis fixtures rule out any two-axis swap
18632 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
18633 // same-fixture-per-axis pin.
18634 let nome = "sibling-teia";
18635 let axis = "distinct-axis-value";
18636 let reason = "distinct rejection sentence".to_string();
18637 assert_eq!(
18638 DepError::versao_invalid(nome, axis, reason.clone()),
18639 DepError::VersaoInvalid {
18640 nome: nome.to_string(),
18641 versao: axis.to_string(),
18642 reason: reason.clone(),
18643 },
18644 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
18645 `reason` → `reason` in declared field order",
18646 );
18647 assert_eq!(
18648 DepError::fonte_repo_shape(nome, axis, reason.clone()),
18649 DepError::FonteRepoShape {
18650 nome: nome.to_string(),
18651 repo: axis.to_string(),
18652 reason: reason.clone(),
18653 },
18654 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
18655 `reason` → `reason` in declared field order",
18656 );
18657 assert_eq!(
18658 DepError::caracteristica_invalid(nome, axis, reason.clone()),
18659 DepError::CaracteristicaInvalid {
18660 nome: nome.to_string(),
18661 caracteristica: axis.to_string(),
18662 reason: reason.clone(),
18663 },
18664 "caracteristica_invalid must route `nome` → `nome`, \
18665 `axis` → `caracteristica`, `reason` → `reason` in declared \
18666 field order",
18667 );
18668 }
18669
18670 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
18671 // two-slot envelope on `DepError`, missing rung between
18672 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
18673 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
18674 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
18675 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
18676 // two-slot `{ nome, list: &'static str }` envelope (same slot
18677 // count, `&'static str` axis instead of owned `String` axis).
18678
18679 #[test]
18680 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
18681 assert_eq!(
18682 DepError::fonte_pin_empty("caixa-teia", ":tag"),
18683 DepError::FontePinEmpty {
18684 nome: "caixa-teia".to_string(),
18685 pin: ":tag".to_string(),
18686 },
18687 "fonte_pin_empty ctor must produce byte-equal \
18688 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
18689 on the same `(&str, &str)` fixture",
18690 );
18691 }
18692
18693 #[test]
18694 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
18695 assert_eq!(
18696 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
18697 DepError::FontePinAmbiguous {
18698 nome: "caixa-teia".to_string(),
18699 pins: ":tag, :rev".to_string(),
18700 },
18701 "fonte_pin_ambiguous ctor must produce byte-equal \
18702 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
18703 wrap on the same `(&str, &str)` fixture",
18704 );
18705 }
18706
18707 #[test]
18708 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
18709 assert_eq!(
18710 DepError::caracteristica_duplicate("caixa-teia", "http"),
18711 DepError::CaracteristicaDuplicate {
18712 nome: "caixa-teia".to_string(),
18713 caracteristica: "http".to_string(),
18714 },
18715 "caracteristica_duplicate ctor must produce byte-equal \
18716 `DepError::CaracteristicaDuplicate` to the pre-lift \
18717 struct-literal wrap on the same `(&str, &str)` fixture",
18718 );
18719 }
18720
18721 #[test]
18722 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
18723 // Owned-`String` routing pin: thread the real
18724 // `set.join(", ")` `String` carrier through the ctor's
18725 // `&str`-parameter Deref coercion, so the ambiguity-arm
18726 // wire-up site's actual `&set.join(", ")` shape stays
18727 // byte-equal to a direct `":tag, :rev"` literal. A future
18728 // parameter-shape change silently dropping the Deref
18729 // coercion route (e.g., a switch to `impl Into<String>`)
18730 // surfaces here rather than at the wire-up's compile
18731 // error far from the ctor definition.
18732 let set: Vec<&'static str> = vec![":tag", ":rev"];
18733 let joined: String = set.join(", ");
18734 assert_eq!(
18735 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
18736 DepError::FontePinAmbiguous {
18737 nome: "caixa-teia".to_string(),
18738 pins: ":tag, :rev".to_string(),
18739 },
18740 "fonte_pin_ambiguous ctor must accept an owned-`String` \
18741 `&set.join(\", \")` carrier via Deref coercion — the exact \
18742 shape the ambiguity-arm wire-up site passes into it",
18743 );
18744 }
18745
18746 #[test]
18747 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
18748 // Cross-axis routing pin: sweep the two constructor input axes
18749 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
18750 // fixtures against every generated arm in the
18751 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
18752 // trim / truncate at codegen time — a silent field swap between
18753 // `nome` and the middle `<axis>` field, or a `<axis>` axis
18754 // silently rerouted through the wrong field on any one variant
18755 // — surfaces here rather than at a downstream diagnostic-shape
18756 // mismatch. Peer of the sibling
18757 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18758 // (6f5e0cd) pin on the same envelope's peer two-slot family
18759 // (`{ nome, list: &'static str }`) and of the sibling
18760 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18761 // (5621f8a) pin on the same envelope's three-slot `{ nome,
18762 // <axis>: String, reason: String }` family — extended here onto
18763 // the `{ nome, <axis>: String }` two-slot envelope so the last
18764 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
18765 // ladder guarantees each field routes the caller's value
18766 // verbatim through `.to_string()` in declared field order.
18767 // Distinct-per-axis fixtures rule out any two-axis swap
18768 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
18769 // per-axis pin.
18770 let nome = "sibling-teia";
18771 let axis = "distinct-axis-value";
18772 assert_eq!(
18773 DepError::fonte_pin_empty(nome, axis),
18774 DepError::FontePinEmpty {
18775 nome: nome.to_string(),
18776 pin: axis.to_string(),
18777 },
18778 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
18779 in declared field order",
18780 );
18781 assert_eq!(
18782 DepError::fonte_pin_ambiguous(nome, axis),
18783 DepError::FontePinAmbiguous {
18784 nome: nome.to_string(),
18785 pins: axis.to_string(),
18786 },
18787 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
18788 in declared field order",
18789 );
18790 assert_eq!(
18791 DepError::caracteristica_duplicate(nome, axis),
18792 DepError::CaracteristicaDuplicate {
18793 nome: nome.to_string(),
18794 caracteristica: axis.to_string(),
18795 },
18796 "caracteristica_duplicate must route `nome` → `nome`, \
18797 `axis` → `caracteristica` in declared field order",
18798 );
18799 }
18800
18801 #[test]
18802 fn nome_invalid_ctor_matches_struct_literal_wrap() {
18803 // Equivalence pin: the ctor produces byte-equal
18804 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
18805 // literal that cloned the offending `:deps :nome` verbatim and
18806 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
18807 // owned `reason` payload at the caller site inside
18808 // [`Dep::validate`]. Guards any future field-addition /
18809 // reordering / accessor-return tweak on the variant. Sibling of
18810 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
18811 // (below) and the sibling three-slot
18812 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18813 // pin on the same envelope's three-slot `{ nome, <axis>: String,
18814 // reason: String }` family.
18815 let nome = "Caixa-Teia";
18816 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
18817 let via_ctor = DepError::nome_invalid(nome, reason.clone());
18818 let via_literal = DepError::NomeInvalid {
18819 nome: nome.to_string(),
18820 reason,
18821 };
18822 assert_eq!(
18823 via_ctor, via_literal,
18824 "nome_invalid(nome, reason) must byte-equal the open-coded \
18825 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
18826 );
18827 assert_eq!(
18828 via_ctor.to_string(),
18829 via_literal.to_string(),
18830 "Display byte-string must byte-equal the open-coded struct-literal"
18831 );
18832 }
18833
18834 #[test]
18835 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
18836 // Boundary-sweep pin on the ctor's two-slot projection: sweep
18837 // the two ctor input axes (`nome: &str`, `reason: String`)
18838 // through distinct-per-axis fixtures against a representative
18839 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
18840 // wrapper-side silent lowercase / trim / truncate at codegen
18841 // time — a silent field swap between `nome` and `reason`, an
18842 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
18843 // divergence on the `reason` axis — surfaces at caixa-core
18844 // build time rather than at a downstream diagnostic consumer
18845 // that reads `err.nome` / `err.reason` back and gets a different
18846 // value than the one it stored. Peer of the sibling
18847 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
18848 // (7f7c950) pin on the same envelope's peer two-slot family
18849 // (`{ nome, <axis>: String }`) — extended here onto the
18850 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
18851 // variant carries. Distinct-per-axis fixtures rule out any
18852 // two-axis swap (`nome` ↔ `reason`) that would still pass a
18853 // same-fixture-per-axis pin. The sweep list carries a mixed
18854 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
18855 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
18856 // over-63-byte) so a future silent per-input normalization
18857 // surfaces on the arm that diverges.
18858 for nome in [
18859 "Caixa-Teia",
18860 "caixa_teia",
18861 "caixa.teia",
18862 "-caixa-teia",
18863 "caixa-teia-",
18864 "caixa/teia",
18865 &"a".repeat(64),
18866 ] {
18867 let reason = crate::render::is_dns_1123_label(nome)
18868 .expect_err("fixture must be a DNS-1123-refused label");
18869 let via_ctor = DepError::nome_invalid(nome, reason.clone());
18870 let DepError::NomeInvalid {
18871 nome: stored_nome,
18872 reason: stored_reason,
18873 } = via_ctor
18874 else {
18875 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
18876 };
18877 assert_eq!(
18878 stored_nome, nome,
18879 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
18880 );
18881 assert_eq!(
18882 stored_reason, reason,
18883 "reason slot must forward the owned `String` verbatim for {nome:?}"
18884 );
18885 }
18886 }
18887
18888 #[test]
18889 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
18890 // End-to-end pin: the sole in-crate wire-up site
18891 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
18892 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
18893 // the ctor's output on the same DNS-1123-refused `:deps :nome`
18894 // fixture, with identical `Display` rendering. A future silent
18895 // de-lift of the wire-up back to the open-coded struct-literal
18896 // trips this test at caixa-core build time rather than at a
18897 // downstream diagnostic consumer far from the wire-up commit.
18898 // Sibling of the peer
18899 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
18900 // pin on the same wire-up — extended here from a `matches!`
18901 // shape check to a byte-identity + Display parity route through
18902 // the ctor.
18903 let d = Dep::simple("Caixa_Teia", "^0.1");
18904 let observed = d.validate().unwrap_err();
18905 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
18906 .expect_err("fixture must be DNS-1123-refused");
18907 let expected = DepError::nome_invalid("Caixa_Teia", reason);
18908 assert_eq!(
18909 observed, expected,
18910 "Dep::validate's DNS-1123 refusal arm must byte-equal \
18911 nome_invalid(nome, reason)"
18912 );
18913 assert_eq!(
18914 observed.to_string(),
18915 expected.to_string(),
18916 "Display byte-string parity"
18917 );
18918 }
18919}