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::NomeInvalid {
2977 nome: self.nome.clone(),
2978 reason,
2979 });
2980 }
2981 // Delegate the empty-first + `parse_requirement` cascade to the
2982 // shared [`crate::render::require_valid_versao_requirement`]
2983 // helper — same two-arm shape the peer
2984 // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2985 // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2986 // :versao` route through, so drift between the three axes'
2987 // accepted requirement sets is structurally impossible and the
2988 // parse-side no-op the empty-first arm closes (semver's empty
2989 // parse yields an implicit `*`) lives in exactly one predicate.
2990 crate::render::require_valid_versao_requirement(
2991 self.versao_requirement(),
2992 || DepError::versao_empty(&self.nome),
2993 |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2994 )?;
2995 if let Some(fonte) = self.fonte() {
2996 fonte.validate(&self.nome)?;
2997 }
2998 self.validate_caracteristicas()?;
2999 Ok(())
3000 }
3001
3002 /// Reject per-entry `:caracteristicas` (feature-flag) values that
3003 /// are operationally meaningless. The `:caracteristicas` slot is
3004 /// a set of feature toggles to enable on the target caixa — same
3005 /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3006 /// two structural footguns close here:
3007 ///
3008 /// - empty-string entry (`(:caracteristicas (""))`): the future
3009 /// caixa-resolver lacre pipeline would consume the empty
3010 /// identifier as a no-op feature enable, silently dropping the
3011 /// author's intent far from the source `caixa.lisp`;
3012 /// - duplicate entry within one dep (`(:caracteristicas ("http"
3013 /// "http"))`): the feature-toggle slot is set-shaped (enabling
3014 /// a feature twice has no additional semantic — there is no
3015 /// `feature × 2`), so two entries naming the same feature are
3016 /// a silent miscount, the same set-not-multiset distinction
3017 /// every peer Vec-keyed-by-name axis already closes
3018 /// ([`crate::SupervisorError::DuplicateChildCaixa`] on
3019 /// `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3020 /// on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3021 /// on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3022 /// on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3023 /// on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3024 /// on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3025 /// / [`crate::UpgradeError::DuplicateStateChange`] /
3026 /// [`crate::UpgradeError::DuplicateCleanup`] on the within-
3027 /// entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3028 /// on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3029 /// immediate-predecessor 359fba5 closed).
3030 ///
3031 /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3032 /// every peer set-not-multiset gate uses; the empty arm fires
3033 /// before the duplicate arm so an entry with both an empty feature
3034 /// *and* a duplicate of some later feature surfaces the empty-
3035 /// shape diagnostic first (the empty-feature axis is the
3036 /// more-actionable defect since the missing-name renders the
3037 /// duplicate-key arm ambiguous: two `""` entries would both report
3038 /// `caracteristica: ""` with no way to distinguish the offending
3039 /// site). Empty-first cascade discipline mirrors every peer per-
3040 /// entry shape + duplicate gate
3041 /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3042 /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3043 /// before `MembroDuplicate`).
3044 ///
3045 /// The per-entry value-shape gate (Cargo-feature-name grammar via
3046 /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3047 /// fires between the empty arm and the duplicate arm — the
3048 /// canonical per-entry-shape-before-cross-entry-uniqueness
3049 /// precedence every peer two-arm + value-shape gate establishes
3050 /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3051 /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3052 /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3053 /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3054 /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3055 /// Until the value-shape arm landed `:caracteristicas` accepted
3056 /// every non-empty distinct string — a structurally invalid
3057 /// feature name (`"http feature"` whitespace, `"+http"` the
3058 /// canonical paste-from-`+optional-feature` doc activation-form
3059 /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3060 /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3061 /// only applies inside list-grammar contexts, `"http,json"`
3062 /// list-separator-belongs-to-the-list-grammar miscomprehension,
3063 /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3064 /// inconsistently across NFC/NFD normalization, the 65-byte
3065 /// paste-from-binary slug) silently passed validate and the
3066 /// failure surfaced at `cargo metadata` time as the
3067 /// `restricted_names::validate_feature_name` parser's rejection,
3068 /// far from the source `caixa.lisp`, with no field naming which
3069 /// `:deps` entry's `:caracteristicas` carried the typo. The
3070 /// lifted predicate makes the Cargo-feature-name-grammar
3071 /// intersection-floor a substrate-level invariant at validate
3072 /// time — same trajectory as the eight peer
3073 /// [`crate::render`] value-shape predicates each typed surface
3074 /// downstream of a structured grammar already follows
3075 /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3076 /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3077 /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3078 /// [`is_nats_subject`](crate::render::is_nats_subject),
3079 /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3080 /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3081 /// [`is_git_oid`](crate::render::is_git_oid),
3082 /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3083 fn validate_caracteristicas(&self) -> Result<(), DepError> {
3084 let mut seen = std::collections::HashSet::new();
3085 for c in self.caracteristicas() {
3086 if c.is_empty() {
3087 return Err(DepError::caracteristica_empty(&self.nome));
3088 }
3089 if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3090 return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3091 }
3092 crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3093 DepError::caracteristica_duplicate(&self.nome, c)
3094 })?;
3095 }
3096 Ok(())
3097 }
3098}
3099
3100/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3101/// `:deps-dev` entry may name the caixa's own `:nome`.
3102///
3103/// A caixa that lists itself as a dep is a degenerate self-edge in the
3104/// lacre closure's dep-graph — the closure is a DAG rooted at the
3105/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3106/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3107/// hands the resolver a node that is its own parent: a one-node cycle
3108/// it either rejects mid-traversal far from the source `caixa.lisp`
3109/// (the resolver detecting infinite recursion on the closure walk) or,
3110/// worse, recurses on until it exhausts its stack. Because every
3111/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3112/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3113/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3114///
3115/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3116/// carries the entries but not the parent `:nome`; mirrors the
3117/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3118/// (ad4abf1) on the `:children :caixa` axis and
3119/// [`crate::aplicacao::validate_no_self_membership`] on the
3120/// `:membros :caixa` axis — the same "an edge from a graph node to
3121/// itself is structurally not a tree/graph edge" discipline, here on
3122/// the third typed-name-graph axis (the dep closure; the supervision
3123/// tree and the Aplicacao membership set were the prior two).
3124///
3125/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3126/// that self-references on both axes surfaces the `:deps` arm first —
3127/// the load-bearing axis the lacre closure resolves at every build,
3128/// peer with the canonical [`Caixa::validate_deps`] walk order
3129/// (`:deps` → `:deps-dev`).
3130///
3131/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3132/// verbatim into the diagnostic so the author can grep their
3133/// `caixa.lisp` for the offending block in one edit — same
3134/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3135/// uses on the cross-list duplicate-name axis.
3136///
3137/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3138/// substrate-blessed shape for referencing the caixa's *own* code, so
3139/// the diagnostic names them as the corrective surface — every
3140/// legitimate "I want to use code from this caixa" authoring intent
3141/// routes through one of those three slots, not a self-dep.
3142pub fn validate_no_self_dep(
3143 deps: &[Dep],
3144 deps_dev: &[Dep],
3145 parent_nome: &str,
3146) -> Result<(), DepError> {
3147 for dep in deps {
3148 if dep.nome() == parent_nome {
3149 return Err(DepError::dep_is_self(
3150 parent_nome,
3151 crate::render::DEP_AUTHOR_KEY_DEPS,
3152 ));
3153 }
3154 }
3155 for dep in deps_dev {
3156 if dep.nome() == parent_nome {
3157 return Err(DepError::dep_is_self(
3158 parent_nome,
3159 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3160 ));
3161 }
3162 }
3163 Ok(())
3164}
3165
3166/// Closed-set typed enum for the two dep-list author-surface axes every
3167/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3168/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3169/// substrate consumer that dispatches on "which of the two dep-lists"
3170/// (the `feira add` mutation head, the future per-cluster dev-closure-
3171/// audit overlay the M4 CR materializer resolves per-CR, the future
3172/// `caixa app graph` per-list dep summary, every future
3173/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3174/// caller reaches for) reads through this enum rather than through a
3175/// bare `&'static str` — the closed-set is expressed at the type layer,
3176/// so a future third dep-list axis (a `:deps-build` build-only closure
3177/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3178/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3179/// compiler enforces exhaustiveness on every consumer's `match` arms.
3180///
3181/// The wire byte-string [`Self::as_str`] returns is the same author-
3182/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3183/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3184/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3185/// &'static str` payload family the substrate already emits routes
3186/// through the same source of truth (an author reading a
3187/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3188/// for the offending `:deps` / `:deps-dev` block in one edit whether
3189/// the diagnostic came from a `Caixa::validate_deps` walk or a
3190/// `Caixa::push_dep` mutation).
3191///
3192/// Same "closed-set typed-enum discriminator with canonical
3193/// projections per axis" discipline the sibling closed-set typed enums
3194/// on the caixa typed surface carry
3195/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3196/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3197/// [`crate::supervisor::RestartStrategy`],
3198/// [`crate::supervisor::RestartPolicy`],
3199/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3200/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3201/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3202/// axis on the top-level manifest surface.
3203#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3204pub enum DepList {
3205 /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3206 /// lacre closure resolves at every build. Wire-format
3207 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3208 Prod,
3209 /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3210 /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3211 /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3212 Dev,
3213}
3214
3215impl DepList {
3216 /// Exhaustive iteration surface for every consumer that reads the
3217 /// full closed-set (the future M4 admission webhook's per-list
3218 /// summary rejection body, any future round-trip pin harness). A
3219 /// future variant addition extends this slice as a single edit and
3220 /// every consumer picks up the new entry by construction — the
3221 /// compiler-checked exhaustiveness on the sibling method `match`
3222 /// arms is the build-time guarantee that no arm forgets to grow.
3223 pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3224
3225 /// Canonical author-surface tag every substrate consumer that
3226 /// names the offending dep-list in a diagnostic reaches for —
3227 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3228 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3229 /// the same `&'static str` payload the sibling
3230 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3231 /// already carry. Routing every dep-list diagnostic through the
3232 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3233 /// literal-carry axis on the two-list dep-graph surface — a
3234 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3235 /// wire-format promotion (a distinct diagnostic form for the
3236 /// `Dev` arm) reaches every consumer through one edit on the
3237 /// canonical constant, not a coordinated rewrite across the
3238 /// substrate's dep-graph consumers.
3239 #[must_use]
3240 pub const fn as_str(self) -> &'static str {
3241 match self {
3242 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3243 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3244 }
3245 }
3246
3247 /// Substrate-canonical reverse projection on the two-list dep-graph
3248 /// axis — parses the author-surface wire tag back to the typed
3249 /// variant, or `None` when `s` is outside the closed-set arm-string
3250 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3251 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3252 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3253 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3254 /// the round-trip migrate through one caixa-core edit on any future
3255 /// list-axis addition.
3256 ///
3257 /// Prior to this lift the substrate carried only the forward
3258 /// `Self → &str` projection on the two-list dep-graph axis (the
3259 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3260 /// through it, the two [`DepError::DuplicateNome`] /
3261 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3262 /// as a `&'static str` `list:` field). Every future consumer that
3263 /// wanted to promote the wire tag back to the typed enum (a future
3264 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3265 /// wire form into the typed enum before dispatching to
3266 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3267 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3268 /// wire re-parse of the per-list diagnostic body, a future
3269 /// [`DepError`] widening that promotes the two `list: &'static str`
3270 /// fields to a typed `list: DepList` carry so downstream consumers
3271 /// dispatch on the enum rather than string-comparing the wire
3272 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3273 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3274 /// compile-time link back to the typed [`DepList`] enum. A future
3275 /// variant addition (a `:build-dep` or `:test-dep` third list once
3276 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3277 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3278 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3279 /// would silently split the wire byte-string the emitter walks from
3280 /// the parser's arm-set — the round-trip would carry the new list
3281 /// through the forward projection but land on the fallback silently
3282 /// at every non-updated reverse parser, far from the arm-addition
3283 /// commit that caused the drift. Lifting the resolver to a typed
3284 /// method on the substrate primitive closes the drift footgun by
3285 /// construction: the parser's accept-set is the same set the
3286 /// [`Self::as_str`] emitter walks (routed through the same lifted
3287 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3288 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3289 /// of the round-trip migrate through one caixa-core edit on any
3290 /// future list-axis addition.
3291 ///
3292 /// Same closed-set-reverse-projection discipline the sibling
3293 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3294 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3295 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3296 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3297 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3298 /// carry on the peer wire-side `str → Self` axes — extended onto
3299 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3300 /// closed-set typed enum on the caixa surface to converge on the
3301 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3302 /// `from_str`) to match the peer shapes verbatim and side-step the
3303 /// derived [`std::str::FromStr`] impls the sibling
3304 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3305 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3306 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3307 /// caller picks the diagnostic form appropriate for its use site —
3308 /// a future `feira dep --list …` arg-parse that surfaces
3309 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3310 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3311 /// path folds `None` onto its per-CR structured refusal body.
3312 #[must_use]
3313 pub fn from_wire(s: &str) -> Option<Self> {
3314 match s {
3315 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3316 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3317 _ => None,
3318 }
3319 }
3320}
3321
3322/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3323/// consumer that formats the axis as user-facing text (a future
3324/// `feira app graph` per-list summary, a future M4 admission-webhook
3325/// rejection body naming the offending list, this crate's own
3326/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3327/// typed [`DepList`]) lands on the same author-surface tag the
3328/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3329/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3330/// as-str-through-Display convergence discipline the sibling
3331/// [`crate::aplicacao::PlacementStrategy`],
3332/// [`crate::aplicacao::RateLimitUnit`],
3333/// [`crate::supervisor::RestartStrategy`],
3334/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3335/// closed-set typed enums carry.
3336impl std::fmt::Display for DepList {
3337 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3338 f.write_str(self.as_str())
3339 }
3340}
3341
3342/// Errors raised by [`Dep::validate`].
3343///
3344/// Mirrors the per-axis error families the other `:versao`-carrying
3345/// typed surfaces expose
3346/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3347/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3348/// [`crate::SupervisorError::EmptyChildVersion`] /
3349/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3350/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3351#[derive(Debug, Error, PartialEq, Eq)]
3352pub enum DepError {
3353 #[error(
3354 ":deps entry has empty :nome (every dep must name a target caixa; \
3355 omit the entry instead of carrying an empty name)"
3356 )]
3357 NomeEmpty,
3358 #[error(
3359 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3360 (the value flows verbatim as the target caixa's `:nome`, the rendered \
3361 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3362 value, and the resolver's checkout-directory leaf — each apiserver-side \
3363 schema rejects non-DNS-1123 names at admission time; use a lowercase \
3364 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3365 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3366 )]
3367 NomeInvalid { nome: String, reason: String },
3368 #[error(
3369 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3370 constraint that resolves through the lacre pipeline)"
3371 )]
3372 VersaoEmpty { nome: String },
3373 #[error(
3374 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3375 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3376 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3377 and `:children :versao` carry; the lacre pipeline resolves all three \
3378 through the same parser)"
3379 )]
3380 VersaoInvalid {
3381 nome: String,
3382 versao: String,
3383 reason: String,
3384 },
3385 #[error(
3386 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3387 (every git source must name a repo — use a `github:org/repo` \
3388 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3389 entire :fonte block to fall back to the default-host resolver \
3390 convention)"
3391 )]
3392 FonteRepoEmpty { nome: String },
3393 #[error(
3394 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3395 invalid value-shape: {reason} (the value flows verbatim into the \
3396 caixa-resolver's `git clone <repo>` subprocess invocation; every \
3397 documented form carries a `:` separator and no whitespace / \
3398 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3399 an `https://host/path` / `ssh://[user@]host/path` / \
3400 `git://host/path` / `file:///path` URL, or the `git@host:path` \
3401 scp-style SSH form)"
3402 )]
3403 FonteRepoShape {
3404 nome: String,
3405 repo: String,
3406 reason: String,
3407 },
3408 #[error(
3409 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3410 (set exactly one of :tag, :rev, or :branch so the resolver \
3411 can pick a reproducible commit; omit the entire :fonte block \
3412 to fall back to the default-host resolver convention, which \
3413 resolves the latest tag matching :versao)"
3414 )]
3415 FontePinMissing { nome: String },
3416 #[error(
3417 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3418 set ({pins}); exactly one of :tag, :rev, or :branch must be \
3419 set so the resolver's checkout target is unambiguous (the \
3420 resolver's silent precedence is :rev > :tag > :branch — if \
3421 you intended one specifically, drop the others)"
3422 )]
3423 FontePinAmbiguous { nome: String, pins: String },
3424 #[error(
3425 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3426 (a set pin must name a non-empty git ref; drop the {pin} key \
3427 entirely to fall through to another pin axis)"
3428 )]
3429 FontePinEmpty { nome: String, pin: String },
3430 #[error(
3431 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3432 value-shape: {reason} (the git porcelain enforces the same shape at \
3433 `git fetch` / `git checkout` time on every pin; use a leaf refname \
3434 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3435 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3436 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3437 prepends at clone time, and avoid abbreviated SHAs which are \
3438 ambiguous across repository history)"
3439 )]
3440 FontePinShape {
3441 nome: String,
3442 pin: String,
3443 value: String,
3444 reason: String,
3445 },
3446 #[error(
3447 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3448 (every path source must name a non-empty filesystem path; \
3449 omit the entire :fonte block to fall back to the default-host \
3450 resolver convention)"
3451 )]
3452 FonteCaminhoEmpty { nome: String },
3453 #[error(
3454 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3455 absolute (the lacre pipeline embeds the value verbatim in its \
3456 per-dep content-address `path:{caminho}` at \
3457 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3458 BLAKE3 closure differ across machines — defeating the \
3459 reproducibility contract that's load-bearing for CSE; express \
3460 the path relative to the caixa.lisp location, e.g. \
3461 \"../caixa-teia\" for a sibling workspace dep)"
3462 )]
3463 FonteCaminhoAbsolute { nome: String, caminho: String },
3464 #[error(
3465 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3466 with `~` (the leading-tilde is a shell-expansion convention, not a \
3467 POSIX path component — `Path::is_absolute` returns false on it, so \
3468 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3469 pipeline embeds the value verbatim in its per-dep content-address \
3470 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3471 caixa-resolver folds it through `Path::join` without `~`-expansion, \
3472 so the build looks for a literal `./{caminho}` subdirectory and \
3473 fails at resolve time far from the source caixa.lisp; even worse, a \
3474 future caixa-resolver pass that *does* expand `~` would silently \
3475 re-open the host-layout-leak the b94fd83 absolute gate closes — \
3476 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3477 runners with different `$HOME` layouts resolve to two distinct paths \
3478 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3479 determinism contract; express the path relative to the caixa.lisp \
3480 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3481 spell out the full relative path explicitly if a workstation-rooted \
3482 dep is genuinely intended)"
3483 )]
3484 FonteCaminhoTildeExpansion { nome: String, caminho: String },
3485 #[error(
3486 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3487 with `$` (the leading-`$` is a shell-variable-expansion convention, \
3488 not a POSIX path component — `Path::is_absolute` returns false on it \
3489 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3490 embeds the value verbatim in its per-dep content-address \
3491 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3492 caixa-resolver folds it through `Path::join` without `$`-expansion, \
3493 so the build looks for a literal `./{caminho}` subdirectory and \
3494 fails at resolve time far from the source caixa.lisp; even worse, a \
3495 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3496 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3497 invites) would silently re-open the host-layout-leak the b94fd83 \
3498 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3499 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3500 layouts resolve to two distinct paths for the byte-identical caixa, \
3501 defeating the THEORY.md §V.2 render-determinism contract; express \
3502 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3503 for a sibling workspace dep, or spell out the full relative path \
3504 explicitly if a workstation-rooted dep is genuinely intended)"
3505 )]
3506 FonteCaminhoVarExpansion { nome: String, caminho: String },
3507 #[error(
3508 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3509 with a space (the leading ASCII space `0x20` is the orthogonal \
3510 paste-from-aligned-doc footgun that silently passes \
3511 `Path::is_absolute` and every prior leading-byte arm — \
3512 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3513 `./ ../caixa-teia` subdirectory the resolver fails to find at \
3514 resolve time with a non-self-locating `No such file or directory` \
3515 error far from the source caixa.lisp; the lacre pipeline embeds \
3516 the value verbatim in its per-dep content-address `path:{caminho}` \
3517 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3518 semantic-identical caixa values (` ../caixa-teia` vs \
3519 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3520 workstations whose authors differ only in paste-from-aligned- \
3521 caixa.lisp-doc whitespace habits — the most insidious failure \
3522 mode the typed slot can carry (no error surfaces; the divergence \
3523 is invisible until two machines compare lacres), defeating the \
3524 THEORY.md §V.2 render-determinism contract. The canonical \
3525 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3526 a multi-entry `:deps` block sits at the same column — an author \
3527 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3528 the rendered alignment into a fresh entry preserves the leading \
3529 whitespace verbatim); peer `:fonte :repo` axis already rejects \
3530 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3531 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3532 `is_chart_description_shape`, `:licenca` via \
3533 `is_spdx_expression_shape`. Drop the leading space; express the \
3534 path as a bare relative single-token like \"../caixa-teia\")"
3535 )]
3536 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3537 #[error(
3538 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3539 with `-` (the canonical CLI-argument-injection footgun on the \
3540 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3541 its per-dep content-address `path:{caminho}` at \
3542 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3543 through `Path::join` looking for a literal `./{caminho}` \
3544 subdirectory. Every downstream subprocess that consumes the resolved \
3545 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3546 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3547 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3548 value as a CLI flag rather than a positional path when the invocation \
3549 does not carry a `--` argument-list terminator between the flag block \
3550 and the path (the common case at every porcelain entry point). The \
3551 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3552 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3553 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3554 CLI-arg-injection vector at every git porcelain entry point that \
3555 consumes a path or URL argument, peer with is_git_repo_url's \
3556 leading-`-` arm on the sibling `:fonte :repo` axis), \
3557 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3558 POSIX `std::path::Path` treats a leading `-` as a literal filename \
3559 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3560 for a literal `./-rf` subdirectory that fails at resolve time with a \
3561 non-self-locating `No such file or directory` error far from the \
3562 source caixa.lisp — but on any downstream shell-out without `--` the \
3563 reinterpretation is silent and the failure mode is arbitrary-\
3564 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3565 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3566 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3567 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3568 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3569 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3570 `:children :caixa`, `:deps :nome`, cluster names); \
3571 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3572 the feira `init` / `add <nome>` positional gate (868c191) rejects \
3573 leading `-` on the CLI positional itself. Express the path as a bare \
3574 relative single-token like \"../caixa-teia\" — the sibling-workspace \
3575 directory name carries no leading-hyphen semantic, and `./` / `../` \
3576 prefixes structurally partition the leading-byte set to safe values.)"
3577 )]
3578 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3579 #[error(
3580 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3581 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3582 every `std::fs` syscall routes the path through `CString::new` which \
3583 fails with `NulError` at resolve time; the lacre pipeline embeds the \
3584 value verbatim in its per-dep content-address `path:{caminho}` at \
3585 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3586 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3587 determinism contract — the canonical paste-from-multiline-doc \
3588 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3589 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3590 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3591 already gates against. Express the path as a relative single-line ASCII \
3592 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3593 )]
3594 FonteCaminhoControlChar {
3595 nome: String,
3596 caminho: String,
3597 byte: u8,
3598 },
3599 #[error(
3600 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3601 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3602 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3603 not the parent's sibling — and the caixa-resolver folds the value through \
3604 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3605 resolve time with a non-self-locating `No such file or directory` error far \
3606 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3607 primary path separator equal to `/`, so byte-identical caixa.lisp values \
3608 resolve to two distinct directories across runner OSes — the lacre pipeline \
3609 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3610 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3611 determinism contract via the cross-host-OS-separator divergence vector. The \
3612 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3613 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3614 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3615 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3616 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3617 \"../caixa-teia\" for a sibling workspace dep)"
3618 )]
3619 FonteCaminhoBackslash { nome: String, caminho: String },
3620 #[error(
3621 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3622 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3623 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3624 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3625 paste-from-shell-pipeline footgun where an author copies a `command > log` \
3626 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3627 as literal path-component bytes, so the resolver folds the value through \
3628 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3629 subdirectory and fails at resolve time with a non-self-locating `No such \
3630 file or directory` error far from the source caixa.lisp. The lacre pipeline \
3631 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3632 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3633 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3634 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3635 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3636 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3637 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3638 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3639 RFC-3986-reserved set. Express the path as a bare relative single-token like \
3640 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3641 redirection semantic.",
3642 ch = *byte as char
3643 )]
3644 FonteCaminhoShellRedirection {
3645 nome: String,
3646 caminho: String,
3647 byte: u8,
3648 },
3649 #[error(
3650 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3651 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3652 `|` as the pipe operator that wires one command's stdout to the next command's \
3653 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3654 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3655 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3656 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3657 treats `|` as a literal path-component byte, so the resolver folds the value \
3658 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3659 subdirectory and fails at resolve time with a non-self-locating `No such file or \
3660 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3661 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3662 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3663 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3664 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3665 subprocess-argument / shell-metachar injection surface every peer single-token-\
3666 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3667 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3668 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3669 workspace directory name carries no shell-pipe semantic."
3670 )]
3671 FonteCaminhoShellPipe { nome: String, caminho: String },
3672 #[error(
3673 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3674 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3675 / nushell — lexes `;` as the sequential-command terminator that fires the next \
3676 command regardless of the prior command's exit status, so `:caminho \
3677 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3678 footgun where an author copies a `cd path; do-thing` chain without trimming \
3679 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3680 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3681 literal path-component byte, so the resolver folds the value through \
3682 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3683 subdirectory and fails at resolve time with a non-self-locating `No such file \
3684 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3685 the value verbatim in its per-dep content-address `path:{caminho}` at \
3686 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3687 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3688 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3689 canonical shell-metachar injection surface every peer single-token-shaped \
3690 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3691 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3692 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3693 workspace directory name carries no shell-command-separator semantic."
3694 )]
3695 FonteCaminhoShellSemicolon { nome: String, caminho: String },
3696 #[error(
3697 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3698 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3699 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3700 terminator detaching the prior command and returning control immediately to \
3701 the prompt, double `&&` as the logical-AND list operator firing the next \
3702 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3703 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3704 sleep 1` background-launch one-liner or a `cd path && make install` build-\
3705 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3706 05c358e closed the sequential-command-separator vector, this arm closes the \
3707 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3708 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3709 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3710 byte lands in the BLAKE3 closure and rides into every shell-spawned \
3711 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3712 future operator-side `nix` spawn) as the canonical shell-metachar injection \
3713 surface every peer single-token-shaped typed slot already closes. The peer \
3714 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3715 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3716 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3717 shell-background / logical-AND semantic."
3718 )]
3719 FonteCaminhoShellBackground { nome: String, caminho: String },
3720 #[error(
3721 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3722 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3723 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3724 wrapper that runs the enclosed command and substitutes its standard-output \
3725 verbatim into the surrounding word, so a backticked `whoami` expands to the \
3726 current user's name and a backticked `cat /etc/passwd` expands to the file's \
3727 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3728 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3729 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3730 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3731 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3732 background / logical-AND vector, this arm closes the orthogonal command-\
3733 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3734 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3735 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3736 value verbatim in its per-dep content-address `path:{caminho}` at \
3737 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3738 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3739 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3740 shell-metachar injection surface every peer single-token-shaped typed slot \
3741 already closes. The peer `:entrada :paths` axis rejects the byte via \
3742 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3743 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3744 directory name carries no shell-command-substitution semantic."
3745 )]
3746 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3747 #[error(
3748 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3749 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3750 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3751 expansion wildcards: `*` matches any sequence of characters in a path component \
3752 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3753 canonical paste-from-shell-listing footgun where an author copies a \
3754 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3755 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3756 `std::path::Path` treats both bytes as literal path-component bytes, so the \
3757 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3758 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3759 locating `No such file or directory` error far from the source caixa.lisp. The \
3760 lacre pipeline embeds the value verbatim in its per-dep content-address \
3761 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3762 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3763 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3764 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3765 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3766 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3767 reserved set. Express the path as a bare relative single-token like \
3768 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3769 / pathname-expansion semantic.",
3770 ch = *byte as char
3771 )]
3772 FonteCaminhoShellGlob {
3773 nome: String,
3774 caminho: String,
3775 byte: u8,
3776 },
3777 #[error(
3778 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3779 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3780 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3781 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3782 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3783 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3784 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3785 arm closes the leading byte of — together the two arms now structurally exclude the \
3786 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3787 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3788 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3789 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3790 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3791 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3792 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3793 self-locating `No such file or directory` error far from the source caixa.lisp. The \
3794 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3795 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3796 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3797 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3798 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3799 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3800 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3801 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3802 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3803 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3804 subshell-grouping semantic.",
3805 ch = *byte as char
3806 )]
3807 FonteCaminhoShellSubshellGrouping {
3808 nome: String,
3809 caminho: String,
3810 byte: u8,
3811 },
3812 #[error(
3813 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3814 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3815 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3816 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3817 comma-separated members and `{{1..10}}` expands to the integer range — the \
3818 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3819 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3820 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3821 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3822 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3823 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3824 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3825 `std::path::Path` treats the byte as a literal path-component byte, so a \
3826 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3827 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3828 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3829 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3830 silently passes every prior arm and the resolver folds the value through \
3831 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3832 resolve time with a non-self-locating `No such file or directory` error far from \
3833 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3834 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3835 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3836 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3837 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3838 expansion / URI-Template-placeholder surface every peer single-token-shaped \
3839 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3840 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3841 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3842 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3843 directory name carries no shell-brace-expansion / URI-Template-placeholder \
3844 semantic; if two siblings actually need pinning, author two separate `:deps` \
3845 entries rather than one brace-expanded `:caminho` value.",
3846 ch = *byte as char
3847 )]
3848 FonteCaminhoShellBraceExpansion {
3849 nome: String,
3850 caminho: String,
3851 byte: u8,
3852 },
3853 #[error(
3854 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3855 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3856 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3857 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3858 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3859 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3860 glob every shell-history block carries; the bracket pair additionally carries the \
3861 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3862 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3863 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3864 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3865 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3866 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3867 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3868 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3869 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3870 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3871 leak) silently passes every prior arm and the resolver folds the value through \
3872 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3873 resolve time with a non-self-locating `No such file or directory` error far from \
3874 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3875 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3876 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3877 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3878 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3879 surface every peer single-token-shaped typed slot already closes. Express the path \
3880 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3881 directory name carries no shell-bracket-expansion / glob-character-class / array-\
3882 literal semantic; if a family of sibling caixas actually needs pinning, author \
3883 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3884 ch = *byte as char
3885 )]
3886 FonteCaminhoShellBracketExpansion {
3887 nome: String,
3888 caminho: String,
3889 byte: u8,
3890 },
3891 #[error(
3892 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3893 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3894 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3895 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3896 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3897 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3898 every path-with-embedded-whitespace paste block carries and the symmetric \
3899 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3900 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3901 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3902 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3903 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3904 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3905 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3906 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3907 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3908 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3909 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3910 production. POSIX `std::path::Path` treats the byte as a literal path-component \
3911 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3912 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3913 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3914 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3915 shape) silently passes every prior arm and the resolver folds the value through \
3916 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3917 resolve time with a non-self-locating `No such file or directory` error far from \
3918 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3919 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3920 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3921 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3922 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3923 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3924 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3925 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3926 `is_git_repo_url`). Express the path as a bare relative single-token like \
3927 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3928 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3929 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3930 quoting on the outer syntactic layer, so an inner quote pair would nest and \
3931 desugar to a broken layer).",
3932 ch = *byte as char
3933 )]
3934 FonteCaminhoShellQuoteGrouping {
3935 nome: String,
3936 caminho: String,
3937 byte: u8,
3938 },
3939 #[error(
3940 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3941 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3942 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3943 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3944 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3945 discarding the byte and everything after it to the end of the physical line \
3946 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
3947 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
3948 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
3949 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
3950 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
3951 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
3952 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
3953 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
3954 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
3955 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
3956 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
3957 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
3958 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
3959 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
3960 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
3961 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
3962 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
3963 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
3964 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
3965 fails at resolve time with a non-self-locating `No such file or directory` \
3966 error far from the source caixa.lisp — while every downstream shell / YAML / \
3967 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
3968 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
3969 scalar disagree with the resolver on which directory the value names. The \
3970 lacre pipeline embeds the value verbatim in its per-dep content-address \
3971 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
3972 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3973 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
3974 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
3975 fragment-delimiter surface every peer single-token-shaped typed slot already \
3976 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
3977 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
3978 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3979 workspace directory name carries no shell-comment / URL-fragment / YAML-\
3980 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
3981 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
3982 and drop any `#fragment` tail entirely (fragment identifiers select \
3983 renderings, not directories, and `:caminho` names a directory).",
3984 ch = *byte as char
3985 )]
3986 FonteCaminhoShellComment {
3987 nome: String,
3988 caminho: String,
3989 byte: u8,
3990 },
3991 #[error(
3992 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
3993 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
3994 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
3995 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
3996 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
3997 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
3998 literally inside a URL value. The canonical paste-from-browser-address-bar \
3999 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4000 encoded README hyperlink / browser address bar / percent-encoded permalink \
4001 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4002 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4003 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4004 `std::path::Path` treats the byte as a literal path-component byte, so \
4005 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4006 resolve time with a non-self-locating `No such file or directory` error far \
4007 from the source caixa.lisp — while every downstream URL parser / shell printf \
4008 builtin / YAML directive parser silently reinterprets the byte to a different \
4009 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4010 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4011 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4012 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4013 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4014 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4015 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4016 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4017 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4018 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4019 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4020 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4021 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4022 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4023 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4024 printf-format-specifier / job-control-specifier surface every peer single-\
4025 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4026 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4027 `is_git_repo_url`). Express the path as a bare relative single-token like \
4028 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4029 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4030 any `%20` percent-encoded-space with a literal space then reject the whole \
4031 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4032 directory name never carries an embedded space in practice); drop any \
4033 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4034 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4035 ch = *byte as char
4036 )]
4037 FonteCaminhoUrlPercentEncoding {
4038 nome: String,
4039 caminho: String,
4040 byte: u8,
4041 },
4042 #[error(
4043 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4044 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4045 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4046 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4047 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4048 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4049 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4050 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4051 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4052 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4053 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4054 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4055 the byte is a first-class parser byte in nearly every config / templating / \
4056 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4057 `std::path::Path` treats the byte as a literal path-component byte, so the \
4058 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4059 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4060 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4061 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4062 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4063 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4064 subdirectory that fails at resolve time with a non-self-locating `No such file \
4065 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4066 the value verbatim in its per-dep content-address `path:{caminho}` at \
4067 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4068 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4069 time lock to two distinct BLAKE3 closures across two workstations whose \
4070 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4071 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4072 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4073 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4074 is the canonical CWE-78 shell-command-injection surface every peer single-\
4075 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4076 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4077 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4078 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4079 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4080 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4081 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4082 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4083 so every position — leading and embedded — is structurally rejected. Substitute \
4084 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4085 time, or express the path as a bare relative single-token like \
4086 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4087 variable-expansion / command-substitution / arithmetic-expansion semantic.",
4088 ch = *byte as char
4089 )]
4090 FonteCaminhoShellVariableExpansion {
4091 nome: String,
4092 caminho: String,
4093 byte: u8,
4094 },
4095 #[error(
4096 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4097 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4098 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4099 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4100 reference §9.3: `!command` re-runs the most recent history entry beginning with \
4101 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4102 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4103 and the substitution fires at every history-expansion-enabled shell context — \
4104 `set -o histexpand` is bash's default for interactive sessions and the layer \
4105 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4106 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4107 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4108 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4109 encodes it inside a query component via the 'special-query percent-encode set' \
4110 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4111 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4112 prefix — the paste-from-source-code idiom where an author copies \
4113 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4114 the string-literal boundary); the canonical English-typography emphasis / \
4115 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4116 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4117 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4118 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4119 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4120 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4121 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4122 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4123 repeat-prior-command paste idiom), the English-typography `:caminho \
4124 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4125 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4126 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4127 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4128 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4129 subdirectory that fails at resolve time with a non-self-locating `No such file \
4130 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4131 the value verbatim in its per-dep content-address `path:{caminho}` at \
4132 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4133 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4134 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4135 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4136 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4137 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4138 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4139 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4140 name carries no shell-history-expansion / bang-operator semantic; drop any \
4141 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4142 idiom; and drop any trailing English-typography exclamation mark that pasted \
4143 from prose.",
4144 ch = *byte as char
4145 )]
4146 FonteCaminhoShellHistoryExpansion {
4147 nome: String,
4148 caminho: String,
4149 byte: u8,
4150 },
4151 #[error(
4152 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4153 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4154 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4155 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4156 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4157 substitution' history operator that rewrites the prior command's `old` string to \
4158 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4159 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4160 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4161 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4162 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4163 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4164 literal value diverges from every downstream `feira tofu` curl-invocation / \
4165 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4166 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4167 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4168 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4169 `std::path::Path` treats `^` as a literal path-component byte, so \
4170 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4171 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4172 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4173 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4174 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4175 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4176 that fails at resolve time with a non-self-locating `No such file or directory` \
4177 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4178 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4179 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4180 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4181 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4182 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4183 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4184 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4185 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4186 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4187 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4188 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4189 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4190 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4191 drop any trailing `^` history-substitution-open fragment.",
4192 ch = *byte as char
4193 )]
4194 FonteCaminhoShellHistorySubstitution {
4195 nome: String,
4196 caminho: String,
4197 byte: u8,
4198 },
4199 #[error(
4200 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4201 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4202 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4203 value verbatim in its per-dep content-address `path:{caminho}` at \
4204 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4205 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4206 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4207 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4208 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4209 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4210 trailing `/`; every `:caminho` value names a sibling-workspace directory \
4211 already, so the trailing separator carries no information. Use \
4212 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4213 )]
4214 FonteCaminhoTrailingSlash { nome: String, caminho: String },
4215 #[error(
4216 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4217 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4218 apply the same set-not-multiset discipline; one package per table), and \
4219 two entries naming the same caixa carry two version constraints / source \
4220 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4221 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4222 silently overwrites the first at the resolver-side `concrete_versao` step, \
4223 and the dropped entry's pin / features never reach the closure — far from \
4224 the source caixa.lisp, with no field naming which `:deps` entry was the \
4225 silent loser. If two version constraints are genuinely needed (the rare \
4226 multi-version closure case the lacre pipeline doesn't yet support), the \
4227 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4228 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4229 )]
4230 DuplicateNome { nome: String, list: &'static str },
4231 #[error(
4232 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4233 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4234 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4235 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4236 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4237 with the canonical kebab-case feature name the target caixa declares."
4238 )]
4239 CaracteristicaEmpty { nome: String },
4240 #[error(
4241 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4242 feature name: {reason} (the value flows verbatim into Cargo's \
4243 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4244 parser enforces the same shape at `cargo metadata` time; use a single-token \
4245 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4246 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4247 an ASCII alphanumeric or `_`)"
4248 )]
4249 CaracteristicaInvalid {
4250 nome: String,
4251 caracteristica: String,
4252 reason: String,
4253 },
4254 #[error(
4255 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4256 every feature-flag list keys its entries by name (Cargo's \
4257 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4258 per feature per dep), and two entries naming the same feature are a redundant \
4259 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4260 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4261 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4262 feature once regardless of declaration count, so the duplicate's pin / position never \
4263 reaches the closure with no field naming the silent loser. One entry per feature per \
4264 dep; if two distinct features are intended, name each verbatim."
4265 )]
4266 CaracteristicaDuplicate {
4267 nome: String,
4268 caracteristica: String,
4269 },
4270 #[error(
4271 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4272 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4273 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4274 rejects mid-traversal far from the source caixa.lisp or recurses on until \
4275 it exhausts its stack). Every :nome is globally-unique substrate identity, \
4276 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4277 *is* the parent itself, not a coincidentally-named peer. Drop the \
4278 self-referential dep entry — to reference code from this caixa, use \
4279 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4280 referencing the caixa's own code surface) instead."
4281 )]
4282 DepIsSelf { nome: String, list: &'static str },
4283}
4284
4285// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4286// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4287// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4288// variant — the paired `{ nome: String, caminho: String }` two-slot family
4289// on [`DepError`], sibling of the peer
4290// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4291// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4292// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4293// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4294// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4295// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4296// `{ de, para, wit, expected }`), and
4297// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4298// variants on `{ de, para, <field>: String, reason: String }`) on the
4299// `AplicacaoError` envelopes, the peer
4300// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4301// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4302// (0419438, 4 variants on `{ caixa, kind, slots }`),
4303// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4304// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4305// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4306// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4307// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4308// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4309// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4310// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4311//
4312// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4313// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4314// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4315// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4316// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4317// CommandSubstitution}` on the four single-byte shell operators; and the
4318// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4319// opened the identical `DepError::FonteCaminho<Variant> { nome:
4320// nome.to_string(), caminho: caminho.to_string() }` four-line
4321// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4322// — the exact "same block re-inlined at every consumer" shape the PRIME
4323// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4324// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4325// families each closed on their sibling envelopes. The eleven variants
4326// share one `{ nome: String, caminho: String }` shape, so the fold routes
4327// each wire-up site through one dispatch per typed variant.
4328//
4329// The macro below generates one `#[must_use]` inherent constructor per
4330// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4331// wire-up site collapses onto one dispatch:
4332// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4333// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4334// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4335// once — inside the macro — rather than at every wire-up site.
4336//
4337// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4338// shapes at the per-byte-classification arms — the
4339// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4340// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4341// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4342// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4343// cluster — carry an additional `byte: u8` naming the offending byte and
4344// so would break the uniform-two-field routing this macro promises. They
4345// instead fold onto the sibling three-field envelope through
4346// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4347// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4348// two-slot family is the `byte: u8` classification the arms carry. The
4349// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4350// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4351// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4352// envelope.
4353//
4354// Every future consumer that wants to construct one of these eleven
4355// variants outside the current in-crate [`DepSource::validate_caminho`]
4356// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4357// at lacre-resolve time re-checking the same value-shape axes the resolver
4358// consumes, a future `feira validate --deps` per-caixa admission verb
4359// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4360// rejecting a `:caminho` value against a cluster-local snapshot) now
4361// reaches each variant through one call rather than re-inlining the
4362// four-line struct-literal in lockstep with the eleven in-crate wire-up
4363// sites.
4364macro_rules! fonte_caminho_ctors {
4365 ($($ctor:ident => $variant:ident),* $(,)?) => {
4366 impl DepError {
4367 $(
4368 #[doc = concat!(
4369 "Construct a [`DepError::",
4370 stringify!($variant),
4371 "`] naming the offending `:deps :nome` + `:fonte ",
4372 "(:tipo path …) :caminho` pair. Folds the uniform ",
4373 "`Self::",
4374 stringify!($variant),
4375 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4376 "two-slot struct-literal onto one substrate primitive so ",
4377 "every [`DepSource::validate_caminho`] wire-up on this ",
4378 "variant reads through one dispatch rather than the ",
4379 "pre-lift four-line open-coded block."
4380 )]
4381 #[must_use]
4382 pub fn $ctor(nome: &str, caminho: &str) -> Self {
4383 Self::$variant {
4384 nome: nome.to_string(),
4385 caminho: caminho.to_string(),
4386 }
4387 }
4388 )*
4389 }
4390 };
4391}
4392
4393fonte_caminho_ctors! {
4394 fonte_caminho_absolute => FonteCaminhoAbsolute,
4395 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4396 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4397 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4398 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4399 fonte_caminho_backslash => FonteCaminhoBackslash,
4400 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4401 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4402 fonte_caminho_shell_background => FonteCaminhoShellBackground,
4403 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4404 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4405}
4406
4407// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4408// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4409// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4410// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4411// three-slot family on [`DepError`], strict sibling of the peer
4412// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4413// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4414// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4415// axis broke its uniform-two-field routing — the exact "future compounding
4416// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4417// here. Third fold family on this `DepError` envelope, sibling of the peer
4418// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4419// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4420// same enum.
4421//
4422// Each of the twelve wire-up sites on this shape (the control-byte arm
4423// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4424// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4425// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4426// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4427// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4428// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4429// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4430// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4431// `FonteCaminhoShellHistoryExpansion` on `!`, and
4432// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4433// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4434// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4435// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4436// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4437// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4438// closed on the sibling two-field envelope of this same enum. The twelve
4439// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4440// the fold routes each wire-up site through one dispatch per typed variant.
4441//
4442// The macro below generates one `#[must_use]` inherent constructor per
4443// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4444// so every wire-up site collapses onto one dispatch:
4445// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4446// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4447// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4448// `byte`) is spelled once — inside the macro — rather than at every wire-up
4449// site.
4450//
4451// Every future consumer that wants to construct one of these twelve
4452// variants outside the current in-crate [`DepSource::validate_caminho`]
4453// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4454// at lacre-resolve time re-checking the same value-shape axes the resolver
4455// consumes, a future `feira validate --deps` per-caixa admission verb
4456// re-checking the `:fonte :caminho` axis against the shell-metachar
4457// classification bytes this cluster catches, a per-lacre overlay resolver
4458// rejecting a `:caminho` value against a cluster-local snapshot) now
4459// reaches each variant through one call rather than re-inlining the
4460// five-line struct-literal in lockstep with the twelve in-crate wire-up
4461// sites.
4462macro_rules! fonte_caminho_byte_ctors {
4463 ($($ctor:ident => $variant:ident),* $(,)?) => {
4464 impl DepError {
4465 $(
4466 #[doc = concat!(
4467 "Construct a [`DepError::",
4468 stringify!($variant),
4469 "`] naming the offending `:deps :nome` + `:fonte ",
4470 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4471 "classification. Folds the uniform `Self::",
4472 stringify!($variant),
4473 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4474 "byte }` three-slot struct-literal onto one substrate ",
4475 "primitive so every [`DepSource::validate_caminho`] wire-up ",
4476 "on this variant reads through one dispatch rather than ",
4477 "the pre-lift five-line open-coded block."
4478 )]
4479 #[must_use]
4480 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4481 Self::$variant {
4482 nome: nome.to_string(),
4483 caminho: caminho.to_string(),
4484 byte,
4485 }
4486 }
4487 )*
4488 }
4489 };
4490}
4491
4492fonte_caminho_byte_ctors! {
4493 fonte_caminho_control_char => FonteCaminhoControlChar,
4494 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4495 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4496 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4497 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4498 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4499 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4500 fonte_caminho_shell_comment => FonteCaminhoShellComment,
4501 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4502 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4503 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4504 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4505}
4506
4507// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4508// single-slot struct-variant wire-up sites scattered across
4509// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4510// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4511// substrate primitive per typed variant — the paired `{ nome: String }`
4512// single-slot family on [`DepError`], sibling of the peer
4513// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4514// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4515// the same enum, and of the peer
4516// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4517// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4518// axis. Second fold family on this `DepError` envelope, and the first on
4519// the single-`{ nome }` shape.
4520//
4521// The five wire-up sites this fold closes each opened the identical
4522// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4523// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4524// local — the exact "same block re-inlined at every consumer" shape the
4525// PRIME DIRECTIVE names as a bug. The five variants share one
4526// `{ nome: String }` shape, so the fold routes each wire-up site through
4527// one dispatch per typed variant.
4528//
4529// The macro below generates one `#[must_use]` inherent constructor per
4530// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4531// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4532// pre-lift struct-literal on the same `&str` fixture. The uniform
4533// one-field construction (`nome.to_string()`) is spelled once — inside
4534// the macro — rather than at every wire-up site. Callers that hold a
4535// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4536// and lets the macro-owned `.to_string()` produce the fresh owning copy
4537// the enum variant needs; the semantics collapse onto the same
4538// `.clone()`-equivalent one this fold replaces at every site.
4539//
4540// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4541// on the same envelope stays on its pre-lift open-coded wire-up shape —
4542// it carries no `nome` field (the offending `:nome` value *is* the empty
4543// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4544// signature this macro promises does not apply. Every future consumer
4545// that wants to construct one of these five variants outside the current
4546// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4547// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4548// re-validator at lacre-resolve time, a future `feira validate --deps`
4549// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4550// these empty-value shapes against a cluster-local snapshot) now reaches
4551// each variant through one call rather than re-inlining the three-line
4552// struct-literal in lockstep with the five in-crate wire-up sites.
4553macro_rules! dep_nome_only_ctors {
4554 ($($ctor:ident => $variant:ident),* $(,)?) => {
4555 impl DepError {
4556 $(
4557 #[doc = concat!(
4558 "Construct a [`DepError::",
4559 stringify!($variant),
4560 "`] naming the offending `:deps :nome`. Folds the ",
4561 "uniform `Self::",
4562 stringify!($variant),
4563 " { nome: nome.to_string() }` one-field ",
4564 "struct-literal onto one substrate primitive so every ",
4565 "in-crate wire-up on this variant reads through one ",
4566 "dispatch rather than the pre-lift three-line ",
4567 "open-coded block."
4568 )]
4569 #[must_use]
4570 pub fn $ctor(nome: &str) -> Self {
4571 Self::$variant { nome: nome.to_string() }
4572 }
4573 )*
4574 }
4575 };
4576}
4577
4578dep_nome_only_ctors! {
4579 versao_empty => VersaoEmpty,
4580 fonte_repo_empty => FonteRepoEmpty,
4581 fonte_pin_missing => FontePinMissing,
4582 fonte_caminho_empty => FonteCaminhoEmpty,
4583 caracteristica_empty => CaracteristicaEmpty,
4584}
4585
4586// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4587// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4588// [`crate::manifest::Caixa::validate_deps`] +
4589// [`validate_no_self_dep`] onto one substrate-primitive family per
4590// typed variant — the `DepError`-side siblings of the peer
4591// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4592// on the `SupervisorError { caixa: String }` one-slot envelope and of
4593// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4594// `DepError { nome: String }` one-slot envelope. The two variants
4595// carry the same `{ nome: String, list: &'static str }` two-slot
4596// shape: the `nome` field names the offending dep the diagnostic
4597// points the author back at, and the `list` field carries the
4598// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4599// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4600// [`validate_deps`] arms, and via the paired
4601// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4602// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4603// canonicals on the [`validate_no_self_dep`] arm) so the author can
4604// grep their caixa.lisp for the offending list block in one edit.
4605//
4606// Each of the four wire-up sites opened the same struct-literal
4607// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4608// two-line block — the exact "same block re-inlined at every
4609// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4610// altitude the peer `DepError` / `SupervisorError` /
4611// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4612// already closed on their sibling envelopes. The two `#[must_use]`
4613// inherent constructors below fold each wire-up onto one dispatch:
4614// `DepError::duplicate_nome(<nome>, <list>)` and
4615// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4616// pre-lift struct-literal on the same scalar fixtures. The `list:
4617// &'static str` parameter (not `impl Into<String>`) preserves the
4618// exact wire tag every consumer already passes verbatim — no
4619// downstream diagnostic reshaping at the lift, matching the peer
4620// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4621// contract each wire-up site already keys off.
4622macro_rules! dep_nome_list_ctors {
4623 ($($ctor:ident => $variant:ident),* $(,)?) => {
4624 impl DepError {
4625 $(
4626 #[doc = concat!(
4627 "Construct a [`DepError::",
4628 stringify!($variant),
4629 "`] naming the offending `:deps :nome` and the ",
4630 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4631 "the diagnostic points the author back at. Folds ",
4632 "the uniform `Self::",
4633 stringify!($variant),
4634 " { nome: nome.to_string(), list }` two-field ",
4635 "struct-literal onto one substrate primitive so ",
4636 "every in-crate wire-up on this variant reads ",
4637 "through one dispatch rather than the pre-lift ",
4638 "open-coded struct-literal block."
4639 )]
4640 #[must_use]
4641 pub fn $ctor(nome: &str, list: &'static str) -> Self {
4642 Self::$variant { nome: nome.to_string(), list }
4643 }
4644 )*
4645 }
4646 };
4647}
4648
4649dep_nome_list_ctors! {
4650 duplicate_nome => DuplicateNome,
4651 dep_is_self => DepIsSelf,
4652}
4653
4654// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4655// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4656// <value>.to_string(), reason }` struct-variant wire-up sites at
4657// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4658// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4659// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4660// primitive family per typed variant — the `DepError`-side siblings of the
4661// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4662// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4663// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4664// the two-slot `{ nome, caminho }` envelope, and
4665// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4666// caminho, byte }` envelope. The three variants share the same
4667// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4668// the `nome` field names the offending dep the diagnostic points the
4669// author back at, the middle `<axis>: String` field carries the offending
4670// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4671// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4672// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4673// field carries the parser-shaped rejection sentence the paired
4674// [`crate::render::require_valid_versao_requirement`] /
4675// [`crate::render::is_git_repo_url`] /
4676// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4677// axis-field name differs across variants (`versao` / `repo` /
4678// `caracteristica`) so the ctor family below takes the axis field name as
4679// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4680// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4681// -> Self` inherent constructor per typed variant that spells the uniform
4682// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4683// `reason` forwarded owned) exactly once. Peer of the sibling
4684// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4685// family on the `AplicacaoError` envelope's mirror-symmetric
4686// `{ <field>: String, reason: String }` two-slot shape — same
4687// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4688// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4689// envelope keys off (every `DepError` variant carries the offending
4690// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4691// offending block in one edit).
4692//
4693// The three wire-up sites this fold closes are:
4694// - [`DepSource::validate`]'s `:repo` value-shape arm
4695// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4696// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4697// rejects the offending URL);
4698// - [`Dep::validate`]'s `:versao` requirement-shape arm
4699// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4700// self.versao_requirement().to_string(), reason }` inside the
4701// [`crate::render::require_valid_versao_requirement`] callback pair);
4702// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4703// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4704// caracteristica: c.clone(), reason })` after
4705// [`crate::render::is_cargo_feature_name`] rejects the offending
4706// feature-name).
4707//
4708// Each opened the identical five-line struct-literal against the same
4709// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4710// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4711// same altitude the peer four already-lifted `DepError` ctor families
4712// closed on their sibling shape-envelopes. The three variant / axis-field
4713// discriminators are the only things that vary between them; the rest of
4714// the struct-literal is a byte-for-byte re-inline.
4715//
4716// Every future consumer wanting to raise one of these three diagnostics
4717// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4718// time re-checking each declared dep against the same requirement +
4719// git-URL + feature-name value-shape cascade, a future `feira validate
4720// --deps` per-caixa admission verb re-running the shape gates on demand,
4721// a per-lacre overlay resolver rejecting an author-supplied dep against a
4722// cluster-local snapshot) now reaches one dispatch rather than re-inlining
4723// the five-line struct-literal in lockstep with the three in-crate
4724// wire-up sites.
4725macro_rules! dep_nome_axis_reason_ctors {
4726 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4727 impl DepError {
4728 $(
4729 #[doc = concat!(
4730 "Construct a [`DepError::",
4731 stringify!($variant),
4732 "`] naming the offending `:deps :nome`, the offending ",
4733 "`:", stringify!($axis), "` axis value, and the ",
4734 "parser-shaped rejection `reason`. Folds the uniform ",
4735 "`Self::",
4736 stringify!($variant),
4737 " { nome: nome.to_string(), ",
4738 stringify!($axis),
4739 ": ",
4740 stringify!($axis),
4741 ".to_string(), reason }` three-field struct-literal ",
4742 "onto one substrate primitive so every in-crate ",
4743 "wire-up on this variant reads through one dispatch ",
4744 "rather than the pre-lift five-line open-coded block. ",
4745 "The `nome: &str` and `",
4746 stringify!($axis),
4747 ": &str` parameters accept `&str` literals and ",
4748 "`&String` (via Deref coercion) so every existing ",
4749 "wire-up threads through the ctor without a ",
4750 "pre-conversion; the `reason: String` parameter takes ",
4751 "an owned `String` (not `impl Into<String>`) matching ",
4752 "the paired `crate::render::*` predicate's ",
4753 "`Result<(), String>` return shape every wire-up ",
4754 "already holds owned at the call site."
4755 )]
4756 #[must_use]
4757 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
4758 Self::$variant {
4759 nome: nome.to_string(),
4760 $axis: $axis.to_string(),
4761 reason,
4762 }
4763 }
4764 )*
4765 }
4766 };
4767}
4768
4769dep_nome_axis_reason_ctors! {
4770 versao_invalid => VersaoInvalid { versao },
4771 fonte_repo_shape => FonteRepoShape { repo },
4772 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
4773}
4774
4775// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
4776// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
4777// <value>.to_string() }` struct-variant wire-up sites at
4778// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
4779// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
4780// per-entry set-not-multiset dedup closure onto one substrate-primitive
4781// family per typed variant — the missing two-slot rung on the
4782// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
4783// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
4784// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
4785// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
4786// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
4787// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
4788// symmetric sibling of the peer
4789// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
4790// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
4791// envelope — same `<axis>: <value>.to_string()` owned-forward payload
4792// shape, `reason` axis removed and `nome`-axis added at the per-dep-
4793// owned altitude the `DepError` envelope keys off (every `DepError`
4794// variant carries the offending `:deps :nome` verbatim so the author
4795// can grep their caixa.lisp for the offending block in one edit). The
4796// three variants share the same `{ nome: String, <axis>: String }`
4797// two-slot shape: the `nome` field names the offending dep the
4798// diagnostic points the author back at, and the middle `<axis>:
4799// String` field carries the offending per-envelope axis value verbatim
4800// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
4801// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
4802// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
4803// The middle axis-field name differs across variants (`pin` / `pins` /
4804// `caracteristica`) so the ctor family below takes the axis field name
4805// as a macro parameter (`$axis:ident`) alongside the ctor + variant
4806// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
4807// Self` inherent constructor per typed variant that spells the
4808// uniform two-field construction (`nome.to_string()` /
4809// `<axis>.to_string()`) exactly once.
4810//
4811// The three wire-up sites this fold closes are:
4812// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
4813// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
4814// pin.to_string() });` inside the `set.len() == 1` branch after the
4815// `is_some_and(String::is_empty)` iterator);
4816// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
4817// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
4818// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
4819// - [`Dep::validate_caracteristicas`]'s per-entry
4820// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
4821// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
4822// [`crate::render::insert_first_seen`]).
4823//
4824// Each opened the identical four-line struct-literal against the same
4825// `(nome, <axis>)` local pair — the exact "same block re-inlined at
4826// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4827// same altitude the peer four already-lifted `DepError` ctor families
4828// closed on their sibling shape-envelopes. The three variant / axis-
4829// field discriminators are the only things that vary between them;
4830// the rest of the struct-literal is a byte-for-byte re-inline.
4831//
4832// Every future consumer wanting to raise one of these three
4833// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
4834// at lacre-resolve time re-checking each declared dep against the
4835// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
4836// set-not-multiset cascade, a future `feira validate --deps` per-
4837// caixa admission verb re-running the shape gates on demand, a
4838// per-lacre overlay resolver rejecting an author-supplied dep against
4839// a cluster-local snapshot the M4 CR materializer projects) now
4840// reaches one dispatch rather than re-inlining the four-line struct-
4841// literal in lockstep with the three in-crate wire-up sites.
4842macro_rules! dep_nome_axis_ctors {
4843 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4844 impl DepError {
4845 $(
4846 #[doc = concat!(
4847 "Construct a [`DepError::",
4848 stringify!($variant),
4849 "`] naming the offending `:deps :nome` and the ",
4850 "offending `:", stringify!($axis), "` axis value. ",
4851 "Folds the uniform `Self::",
4852 stringify!($variant),
4853 " { nome: nome.to_string(), ",
4854 stringify!($axis),
4855 ": ",
4856 stringify!($axis),
4857 ".to_string() }` two-field struct-literal onto one ",
4858 "substrate primitive so every in-crate wire-up on ",
4859 "this variant reads through one dispatch rather than ",
4860 "the pre-lift four-line open-coded block. Both `nome: ",
4861 "&str` and `",
4862 stringify!($axis),
4863 ": &str` parameters accept `&str` literals and ",
4864 "`&String` (via Deref coercion) so every existing ",
4865 "wire-up threads through the ctor without a pre-",
4866 "conversion."
4867 )]
4868 #[must_use]
4869 pub fn $ctor(nome: &str, $axis: &str) -> Self {
4870 Self::$variant {
4871 nome: nome.to_string(),
4872 $axis: $axis.to_string(),
4873 }
4874 }
4875 )*
4876 }
4877 };
4878}
4879
4880dep_nome_axis_ctors! {
4881 fonte_pin_empty => FontePinEmpty { pin },
4882 fonte_pin_ambiguous => FontePinAmbiguous { pins },
4883 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
4884}
4885
4886// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
4887// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
4888// struct-variant wire-up sites at [`DepSource::validate`]'s
4889// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
4890// the `DepError` envelope — the last open-coded ctor site remaining on
4891// the `:fonte (:tipo git …)` value-shape trajectory this envelope
4892// carries, and the single-variant sibling of the peer four already-
4893// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
4894// on the two-slot `{ nome, caminho }` envelope,
4895// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
4896// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
4897// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
4898// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
4899// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
4900// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
4901// `{ …, value: String, reason: String }` payload shape, one axis
4902// removed at the `nome`-only-owner altitude the `DepError` envelope
4903// keys off (no `edge_pair()` de/para pair).
4904//
4905// The two wire-up sites this fold closes are the paired refname-pin
4906// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
4907// pin: pin.to_string(), value: v.clone(), reason }` inside the
4908// `[(":tag", tag), (":branch", branch)]` iterator against
4909// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
4910// (`|| DepError::FontePinShape { nome: nome.to_string(),
4911// pin: ":rev".to_string(), value: v.clone(), reason }` against
4912// [`crate::render::is_git_oid`]) — each opened the identical
4913// `DepError::FontePinShape { … }` six-line struct-literal against the
4914// same `(nome: &str, pin: &str, v: &String, reason: String)` local
4915// tuple, the exact "same block re-inlined at every consumer" shape
4916// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
4917// the only thing that varies between them (`":tag"`/`":branch"` on
4918// the refname arm, `":rev"` on the hex-OID arm); the rest of the
4919// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
4920// route through the same ctor because their `pin` field carries the
4921// author-surface tag verbatim (matching the `FontePinEmpty` /
4922// `FontePinAmbiguous` sibling variants' `pin: String` axis
4923// convention), so the offending author can grep their caixa.lisp for
4924// the offending `:tag "<value>"` / `:branch "<value>"` /
4925// `:rev "<value>"` literal in one edit.
4926//
4927// The single ctor below folds each wire-up onto one dispatch:
4928// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
4929// the pre-lift struct-literal on the same `(&str, &str, &str,
4930// String)` fixture. The uniform four-field construction
4931// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
4932// `reason` forwarded owned) is spelled once here rather than at every
4933// wire-up site. The `reason: String` field takes an owned `String`
4934// (not `impl Into<String>`) matching the two call sites' pre-existing
4935// `let Err(reason) = crate::render::is_git_ref_name(v)` /
4936// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
4937// predicates return `Result<(), String>`, so the caller always holds
4938// an owned `String` at the wire-up site and threading it through the
4939// ctor without a `.into()` shim keeps the routing shape byte-equal to
4940// the pre-lift block. The `value: &str` parameter accepts both `&str`
4941// literals (unused today) and `&String` (from the caller-held
4942// `v: &String` on each arm, via Deref coercion), so every existing
4943// wire-up threads through the ctor without a pre-conversion.
4944//
4945// Every future consumer that wants to construct this variant outside
4946// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
4947// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
4948// re-checking the same value-shape axes the resolver consumes, a
4949// future `feira validate --deps` per-caixa admission verb re-checking
4950// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
4951// resolver rejecting a git-pin value against a cluster-local
4952// snapshot) now reaches this variant through one call rather than
4953// re-inlining the six-line struct-literal in lockstep with the two
4954// in-crate wire-up sites.
4955impl DepError {
4956 /// Construct a [`DepError::FontePinShape`] naming the offending
4957 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
4958 /// axis tag, the offending value, and the parser-shaped `reason`.
4959 /// Folds the uniform
4960 /// `Self::FontePinShape { nome: nome.to_string(),
4961 /// pin: pin.to_string(), value: value.to_string(), reason }`
4962 /// four-field struct-literal onto one substrate primitive so
4963 /// every [`DepSource::validate`] wire-up on this variant reads
4964 /// through one dispatch rather than the pre-lift six-line
4965 /// open-coded block. The `nome` string threads verbatim from
4966 /// [`Dep::nome`] at the call site; the `pin` string carries the
4967 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
4968 /// `value` string carries the offending refname / hex-OID
4969 /// verbatim; and `reason` forwards the owned `String` returned
4970 /// by [`crate::render::is_git_ref_name`] /
4971 /// [`crate::render::is_git_oid`] without a `.into()` shim.
4972 #[must_use]
4973 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
4974 Self::FontePinShape {
4975 nome: nome.to_string(),
4976 pin: pin.to_string(),
4977 value: value.to_string(),
4978 reason,
4979 }
4980 }
4981}
4982
4983#[allow(clippy::trivially_copy_pass_by_ref)]
4984fn is_false(b: &bool) -> bool {
4985 !*b
4986}
4987
4988#[cfg(test)]
4989mod tests {
4990 use super::*;
4991
4992 #[test]
4993 fn registry_dep_is_minimal() {
4994 let d = Dep::simple("caixa-teia", "^0.1");
4995 assert_eq!(d.nome, "caixa-teia");
4996 assert_eq!(d.versao, "^0.1");
4997 assert!(d.fonte.is_none());
4998 assert!(!d.opcional());
4999 assert!(d.caracteristicas().is_empty());
5000 }
5001
5002 #[test]
5003 fn dep_string_scalar_accessor_pair_is_const_fn() {
5004 // Fail-before-pass-after pin on [`Dep::nome`] +
5005 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5006 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5007 // entry's [`String`] storage through the `pub const fn`
5008 // [`String::as_str`] (const-stable since Rust 1.87, well
5009 // within the workspace MSRV) — any future accidental
5010 // downgrade to non-`const` fails the corresponding
5011 // `<name>_via_const_fn` wrapper at caixa-core build time with
5012 // E0015 (`cannot call non-const method`), strictly stronger
5013 // than a runtime `assert!`. Sibling of the peer
5014 // per-M2/M3/universal-axis `String → &str` scalar-accessor
5015 // family pins on the sibling `const`-eval-surface passes
5016 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5017 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5018 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5019 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5020 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5021 // [`crate::aplicacao::Entrada::destination`] at the M3
5022 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5023 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5024 // M2 supervisor-tree axis,
5025 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5026 // M2 upgrade axis, and the per-`:contratos`
5027 // [`crate::aplicacao::WitContract::source`] /
5028 // [`crate::aplicacao::WitContract::destination`] /
5029 // [`crate::aplicacao::WitContract::world_ref`] trio the
5030 // sibling pin at 279823b already anchors).
5031 const fn nome_via_const_fn(d: &Dep) -> &str {
5032 d.nome()
5033 }
5034 const fn versao_via_const_fn(d: &Dep) -> &str {
5035 d.versao_requirement()
5036 }
5037 for (nome, versao) in [
5038 ("caixa-teia", "^0.1"),
5039 ("caixa-mesh", "~0.2.3"),
5040 ("caixa-helm", "*"),
5041 ] {
5042 let d = Dep::simple(nome, versao);
5043 assert_eq!(nome_via_const_fn(&d), d.nome());
5044 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5045 assert_eq!(d.nome(), nome);
5046 assert_eq!(d.versao_requirement(), versao);
5047 }
5048 }
5049
5050 #[test]
5051 fn dep_outer_accessor_family_is_const_fn() {
5052 // Fail-before-pass-after pin on [`Dep::fonte`] +
5053 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5054 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5055 // entry's composite / list storage through a `pub const fn`
5056 // stdlib method (`Option::<DepSource>::as_ref` /
5057 // `Vec::<String>::as_slice`, both const-stable since Rust
5058 // 1.83, well within the workspace MSRV). Any future
5059 // accidental downgrade to non-`const` fails the corresponding
5060 // `<name>_via_const_fn` wrapper at caixa-core build time with
5061 // E0015 (`cannot call non-const method`), strictly stronger
5062 // than a runtime `assert!` and side-stepping the destructor-
5063 // in-const restriction the `Dep` fixture's `String` /
5064 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5065 // direct-`const _: () = assert!(...)` residence.
5066 //
5067 // Peer of the sibling per-`Dep` scalar-accessor pair pin
5068 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5069 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5070 // the `const`-eval-surface discipline onto the composite-
5071 // reference and slice-return arms of the outer-`Dep` accessor
5072 // family, closing the four-slot outer surface (`:nome` +
5073 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5074 // posture. The `:opcional` `bool` arm already carries the
5075 // posture through [`Dep::opcional`]'s prior `pub const fn`
5076 // declaration, so this pin lands the last two unlifted
5077 // outer-`Dep` accessors and closes the family.
5078 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5079 d.fonte()
5080 }
5081 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5082 d.caracteristicas()
5083 }
5084 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5085 let empty = Dep::simple("caixa-teia", "^0.1");
5086 assert!(fonte_via_const_fn(&empty).is_none());
5087 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5088 assert!(caracteristicas_via_const_fn(&empty).is_empty());
5089 assert_eq!(
5090 caracteristicas_via_const_fn(&empty),
5091 empty.caracteristicas()
5092 );
5093 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5094 // still empty.
5095 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5096 assert!(fonte_via_const_fn(&git).is_some());
5097 assert_eq!(fonte_via_const_fn(&git), git.fonte());
5098 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5099 // Populated `:caracteristicas` — exercise the non-empty
5100 // slice-view arm to pin the accessor's borrow shape against
5101 // both a `Vec::new()` empty backing buffer and a populated one.
5102 let mut with_features = Dep::simple("caixa-teia", "^0.1");
5103 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5104 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5105 assert_eq!(
5106 caracteristicas_via_const_fn(&with_features),
5107 with_features.caracteristicas()
5108 );
5109 }
5110
5111 #[test]
5112 fn git_dep_carries_tag() {
5113 let d = Dep::git("t", "*", "github:o/r", "v1");
5114 match d.fonte {
5115 Some(DepSource::Git {
5116 ref repo, ref tag, ..
5117 }) => {
5118 assert_eq!(repo, "github:o/r");
5119 assert_eq!(tag.as_deref(), Some("v1"));
5120 }
5121 _ => panic!("expected Git source"),
5122 }
5123 }
5124
5125 #[test]
5126 fn validate_accepts_simple_dep() {
5127 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5128 }
5129
5130 #[test]
5131 fn validate_rejects_empty_nome() {
5132 // The fail-before-pass-after pin for `:nome ""`: the empty-name
5133 // arm fires first so the per-entry parse-side diagnostic doesn't
5134 // emit a useless `nome: ""` reference.
5135 let mut d = Dep::simple("placeholder", "^0.1");
5136 d.nome = String::new();
5137 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5138 }
5139
5140 #[test]
5141 fn validate_rejects_empty_versao() {
5142 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5143 // semver crate accepts the empty string as a wildcard match),
5144 // so the empty-`:versao` arm is structurally necessary even
5145 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5146 // `EmptyChildVersion` ordering on the other two `:versao` axes.
5147 let mut d = Dep::simple("caixa-teia", "ignored");
5148 d.versao = String::new();
5149 let err = d.validate().unwrap_err();
5150 assert!(
5151 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5152 "got {err:?}"
5153 );
5154 }
5155
5156 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5157
5158 #[test]
5159 fn validate_rejects_nome_with_uppercase() {
5160 // The fail-before-pass-after pin: a non-empty but uppercase
5161 // `:nome` silently passed `validate()` on every pre-gate
5162 // codebase because the prior shape only refused the empty
5163 // string. The DNS-1123 violation surfaced far downstream at
5164 // lacre-resolve time when the *target* caixa's `:nome` failed
5165 // its own gate — far from the `:deps` entry, with a diagnostic
5166 // naming the target rather than the dep entry that referenced
5167 // it. Same fail-before-pass-after fixture pinned for
5168 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5169 // and Caixa `:nome` (6c992f8).
5170 let d = Dep::simple("Caixa-Teia", "^0.1");
5171 let err = d.validate().unwrap_err();
5172 assert!(
5173 matches!(
5174 err,
5175 DepError::NomeInvalid { ref nome, ref reason }
5176 if nome == "Caixa-Teia" && reason.contains("uppercase")
5177 ),
5178 "got {err:?}"
5179 );
5180 }
5181
5182 #[test]
5183 fn validate_rejects_nome_with_underscore() {
5184 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5185 // "I'm thinking of Go module names / Python identifiers" leak.
5186 // Same fixture pinned for the peer caixa-identifier axes.
5187 let d = Dep::simple("caixa_teia", "^0.1");
5188 let err = d.validate().unwrap_err();
5189 assert!(
5190 matches!(
5191 err,
5192 DepError::NomeInvalid { ref nome, ref reason }
5193 if nome == "caixa_teia" && reason.contains('_')
5194 ),
5195 "got {err:?}"
5196 );
5197 }
5198
5199 #[test]
5200 fn validate_rejects_nome_with_dot() {
5201 // A `:deps :nome` is a single DNS-1123 *label*, not a
5202 // subdomain — dots are rejected. The `"caixa.teia"` shape is
5203 // the canonical "I confused the dep name with the FQDN /
5204 // namespace" footgun, distinct from the legitimate
5205 // `:fonte :repo "github:org/caixa-teia"` axis.
5206 let d = Dep::simple("caixa.teia", "^0.1");
5207 let err = d.validate().unwrap_err();
5208 assert!(
5209 matches!(
5210 err,
5211 DepError::NomeInvalid { ref nome, ref reason }
5212 if nome == "caixa.teia" && reason.contains('.')
5213 ),
5214 "got {err:?}"
5215 );
5216 }
5217
5218 #[test]
5219 fn validate_rejects_nome_with_leading_hyphen() {
5220 // RFC 1123 requires alphanumeric at both label boundaries.
5221 // Pinned in parity with the peer DNS-1123 fixtures.
5222 let d = Dep::simple("-caixa-teia", "^0.1");
5223 let err = d.validate().unwrap_err();
5224 assert!(
5225 matches!(
5226 err,
5227 DepError::NomeInvalid { ref nome, ref reason }
5228 if nome == "-caixa-teia" && reason.contains("alphanumeric")
5229 ),
5230 "got {err:?}"
5231 );
5232 }
5233
5234 #[test]
5235 fn validate_rejects_nome_with_trailing_hyphen() {
5236 let d = Dep::simple("caixa-teia-", "^0.1");
5237 let err = d.validate().unwrap_err();
5238 assert!(
5239 matches!(
5240 err,
5241 DepError::NomeInvalid { ref nome, ref reason }
5242 if nome == "caixa-teia-" && reason.contains("alphanumeric")
5243 ),
5244 "got {err:?}"
5245 );
5246 }
5247
5248 #[test]
5249 fn validate_rejects_nome_with_slash() {
5250 // The canonical "I copied the GitHub repo path into `:nome`
5251 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5252 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5253 // the local-name slot. Same fixture pinned for `:membros
5254 // :caixa` (3f9d7a0).
5255 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5256 let err = d.validate().unwrap_err();
5257 assert!(
5258 matches!(
5259 err,
5260 DepError::NomeInvalid { ref nome, ref reason }
5261 if nome == "pleme-io/caixa-teia" && reason.contains('/')
5262 ),
5263 "got {err:?}"
5264 );
5265 }
5266
5267 #[test]
5268 fn validate_rejects_nome_too_long() {
5269 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5270 // Built from a valid character set so the length-bound
5271 // diagnostic surfaces before any per-character check (the
5272 // order pin parallel to the per-character predicates inside
5273 // [`crate::render::is_dns_1123_label`]).
5274 let long = "a".repeat(64);
5275 let d = Dep::simple(&long, "^0.1");
5276 let err = d.validate().unwrap_err();
5277 assert!(
5278 matches!(
5279 err,
5280 DepError::NomeInvalid { ref nome, ref reason }
5281 if nome.len() == 64 && reason.contains("max length of 63")
5282 ),
5283 "got {err:?}"
5284 );
5285 }
5286
5287 #[test]
5288 fn validate_accepts_canonical_nome_labels() {
5289 // Positive-control sweep — every form the K8s apiserver
5290 // accepts as a DNS-1123 label must round-trip through
5291 // validate. Covers a hyphen-bearing label, a numeric-suffix
5292 // label, a leading-digit label, a single-character label, and
5293 // a 63-byte (exactly the cap) label — the same fixture set
5294 // the peer `:membros :caixa` / `:children :caixa` positive
5295 // controls pin.
5296 for nome in [
5297 "caixa-teia",
5298 "caixa-resolver2",
5299 "2nd-tier-cache",
5300 "x",
5301 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5302 ] {
5303 Dep::simple(nome, "^0.1")
5304 .validate()
5305 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5306 }
5307 }
5308
5309 #[test]
5310 fn nome_empty_takes_precedence_over_nome_invalid() {
5311 // Ordering pin: `NomeEmpty` is the more self-locating
5312 // diagnostic on `""` and must lead — `is_dns_1123_label` is
5313 // only reached after the empty-check fires at the call site.
5314 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5315 // (3f9d7a0) on the peer caixa-identifier axis.
5316 let mut d = Dep::simple("placeholder", "^0.1");
5317 d.nome = String::new();
5318 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5319 }
5320
5321 #[test]
5322 fn nome_invalid_fires_before_versao_empty() {
5323 // Ordering pin: a malformed `:nome` fires before any `:versao`
5324 // axis check on the *same* entry — the per-entry shape gates
5325 // run top-to-bottom (nome empty → nome shape → versao empty →
5326 // versao parse → fonte shape), so a one-entry caixa.lisp with
5327 // both wrong sees the name-side diagnostic first (the name is
5328 // the self-locating axis — without a valid name, the parse
5329 // diagnostic can't quote `:nome "<bad>"`). Same ordering
5330 // discipline as `membro_caixa_invalid_fires_before_versao_check`
5331 // (3f9d7a0).
5332 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5333 d.versao = String::new();
5334 let err = d.validate().unwrap_err();
5335 assert!(
5336 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5337 "got {err:?}"
5338 );
5339 }
5340
5341 #[test]
5342 fn nome_invalid_fires_before_versao_invalid() {
5343 // Ordering pin: a malformed `:nome` fires before the `:versao`
5344 // parse-side check on the *same* entry. Pin separately from
5345 // the empty-versao ordering so a future re-ordering surfaces
5346 // here, parallel to the b0c8389 / c4213a4 trajectory.
5347 let d = Dep::simple("Caixa-Teia", "^^0.1");
5348 let err = d.validate().unwrap_err();
5349 assert!(
5350 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5351 "got {err:?}"
5352 );
5353 }
5354
5355 #[test]
5356 fn nome_invalid_fires_before_fonte_invalid() {
5357 // Ordering pin: a malformed `:nome` fires before the `:fonte`
5358 // shape check on the *same* entry. The `:fonte` diagnostic
5359 // names the offending dep's `:nome` verbatim (via
5360 // `DepSource::validate(&self.nome)`), so a non-self-locating
5361 // name would taint the downstream diagnostic too — the gate
5362 // ordering keeps both diagnostics individually self-locating.
5363 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5364 d.fonte = Some(DepSource::Git {
5365 repo: String::new(),
5366 tag: None,
5367 rev: None,
5368 branch: None,
5369 });
5370 let err = d.validate().unwrap_err();
5371 assert!(
5372 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5373 "got {err:?}"
5374 );
5375 }
5376
5377 #[test]
5378 fn nome_invalid_diagnostic_carries_offending_name() {
5379 // The diagnostic-shape pin: the error names the offending
5380 // `:nome` value verbatim so the author can grep their
5381 // caixa.lisp without re-running the build, and carries a
5382 // non-empty `reason` from `is_dns_1123_label` so the
5383 // predicate's own wording flows through to the diagnostic.
5384 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5385 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5386 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5387 // share a structurally-equivalent diagnostic family.
5388 let d = Dep::simple("Caixa_Teia", "^0.1");
5389 let err = d.validate().unwrap_err();
5390 let DepError::NomeInvalid { nome, reason } = err else {
5391 panic!("expected NomeInvalid, got other variant");
5392 };
5393 assert_eq!(nome, "Caixa_Teia");
5394 assert!(
5395 !reason.is_empty(),
5396 "NomeInvalid `reason` must carry the predicate's wording verbatim"
5397 );
5398 }
5399
5400 #[test]
5401 fn validate_rejects_invalid_versao_requirement() {
5402 // The fail-before-pass-after pin: a non-empty but malformed
5403 // requirement (`"^bad-version"`) silently passed every pre-gate
5404 // codebase because `:deps :versao` wasn't validated. The parse
5405 // failure surfaced far downstream at lacre-resolve time with a
5406 // `semver::Error` that didn't name which `:deps` entry carried
5407 // the typo. The new gate moves the check to caixa-build time
5408 // at the source caixa.lisp.
5409 let d = Dep::simple("caixa-teia", "^bad-version");
5410 let err = d.validate().unwrap_err();
5411 assert!(
5412 matches!(
5413 err,
5414 DepError::VersaoInvalid { ref nome, ref versao, .. }
5415 if nome == "caixa-teia" && versao == "^bad-version"
5416 ),
5417 "got {err:?}"
5418 );
5419 }
5420
5421 #[test]
5422 fn validate_rejects_versao_with_double_caret_typo() {
5423 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5424 // Cargo-shaped requirement on first glance but fails the parser
5425 // because semver doesn't accept stacked operators. Pin this
5426 // adjacent-shape footgun explicitly so a future relaxation that
5427 // accepts "looks-canonical-but-isn't" forms surfaces here, in
5428 // parity with the `:membros` / `:children` fixtures.
5429 let d = Dep::simple("caixa-teia", "^^0.1");
5430 let err = d.validate().unwrap_err();
5431 assert!(
5432 matches!(
5433 err,
5434 DepError::VersaoInvalid { ref nome, ref versao, .. }
5435 if nome == "caixa-teia" && versao == "^^0.1"
5436 ),
5437 "got {err:?}"
5438 );
5439 }
5440
5441 #[test]
5442 fn validate_rejects_versao_with_v_prefixed_tag() {
5443 // `"v0.1"` is the canonical "git-tag-shape leaking into the
5444 // semver requirement slot" typo — an author copies the
5445 // publish-side git-tag string verbatim into `:versao`, but
5446 // Cargo's semver parser rejects the leading `v`. Same fixture
5447 // pinned for `:membros :versao` (9888b13) and `:children
5448 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5449 // are *accepted* by the semver crate as an `*` wildcard on the
5450 // patch axis — they're a Cargo-side valid shape, not a typo.)
5451 let d = Dep::simple("caixa-teia", "v0.1");
5452 let err = d.validate().unwrap_err();
5453 assert!(
5454 matches!(
5455 err,
5456 DepError::VersaoInvalid { ref nome, ref versao, .. }
5457 if nome == "caixa-teia" && versao == "v0.1"
5458 ),
5459 "got {err:?}"
5460 );
5461 }
5462
5463 #[test]
5464 fn validate_accepts_canonical_versao_forms() {
5465 // The five Cargo-shaped requirement forms `:membros :versao`
5466 // and `:children :versao` already accept via
5467 // `crate::parse_requirement` must pass the deps gate without
5468 // re-validating at the resolver layer. Pin every leg so a
5469 // future tightening of the canonical set surfaces here as a
5470 // test failure.
5471 for form in [
5472 "^0.1", // caret — minor-range pin (the most common shape)
5473 "~0.1.2", // tilde — patch-range pin
5474 "0.1.0", // exact — single-version pin
5475 "*", // wildcard — explicitly any-version
5476 ">=0.1, <2", // multi-range — comma-separated comparators
5477 ] {
5478 Dep::simple("caixa-teia", form)
5479 .validate()
5480 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5481 }
5482 }
5483
5484 #[test]
5485 fn versao_empty_takes_precedence_over_invalid() {
5486 // Order pin: the existing `VersaoEmpty` diagnostic (which
5487 // doesn't try to parse) fires before the new `VersaoInvalid`
5488 // parse-side diagnostic, so an empty `:versao` keeps its
5489 // narrower error message — `parse_requirement("")` would
5490 // otherwise return `Ok(STAR)` and silently pass, but the empty
5491 // arm catches it first.
5492 let mut d = Dep::simple("caixa-teia", "ignored");
5493 d.versao = String::new();
5494 let err = d.validate().unwrap_err();
5495 assert!(
5496 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5497 "got {err:?}"
5498 );
5499 }
5500
5501 #[test]
5502 fn nome_empty_takes_precedence_over_versao_invalid() {
5503 // Order pin: even when `:versao` is malformed and would raise
5504 // its own diagnostic, `:nome ""` fires first because the
5505 // per-entry parse diagnostic needs a non-empty name to be
5506 // self-locating. Mirrors the
5507 // `membros_validation_runs_before_contratos_membership_check`
5508 // ordering on the typed-graph layer.
5509 let mut d = Dep::simple("placeholder", "^bad");
5510 d.nome = String::new();
5511 let err = d.validate().unwrap_err();
5512 assert_eq!(err, DepError::NomeEmpty);
5513 }
5514
5515 #[test]
5516 fn versao_invalid_diagnostic_carries_offending_versao() {
5517 // The diagnostic-shape pin: the error names the offending
5518 // `:versao` value verbatim so the author can grep their
5519 // caixa.lisp without re-running the build, and carries a
5520 // non-empty `reason` from `semver::VersionReq::parse` so the
5521 // parser's own wording flows through to the diagnostic.
5522 let d = Dep::simple("caixa-teia", "not-a-req");
5523 let err = d.validate().unwrap_err();
5524 let DepError::VersaoInvalid {
5525 nome,
5526 versao,
5527 reason,
5528 } = err
5529 else {
5530 panic!("expected VersaoInvalid, got other variant");
5531 };
5532 assert_eq!(nome, "caixa-teia");
5533 assert_eq!(versao, "not-a-req");
5534 assert!(
5535 !reason.is_empty(),
5536 "VersaoInvalid `reason` must carry the parser's wording verbatim"
5537 );
5538 }
5539
5540 // -- :fonte value-shape gate ------------------------------------------
5541
5542 fn dep_with_fonte(fonte: DepSource) -> Dep {
5543 let mut d = Dep::simple("caixa-teia", "^0.1");
5544 d.fonte = Some(fonte);
5545 d
5546 }
5547
5548 #[test]
5549 fn validate_accepts_git_fonte_with_tag() {
5550 // The positive-control pin on the canonical git source — exactly
5551 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5552 // shape every existing caixa-resolver integration test uses.
5553 let d = dep_with_fonte(DepSource::Git {
5554 repo: "github:pleme-io/caixa-teia".into(),
5555 tag: Some("v0.1.0".into()),
5556 rev: None,
5557 branch: None,
5558 });
5559 d.validate().unwrap();
5560 }
5561
5562 #[test]
5563 fn validate_accepts_git_fonte_with_rev() {
5564 // Each of the three pin axes is independently a valid single-pin
5565 // shape; pin the :rev arm so a future relaxation that only
5566 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5567 // OID — the canonical `git rev-parse HEAD` emission shape the
5568 // `crate::render::is_git_oid` value-shape gate now requires;
5569 // abbreviated OIDs are ambiguous across repo history and
5570 // rejected at this gate (pinned separately by
5571 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5572 let d = dep_with_fonte(DepSource::Git {
5573 repo: "github:pleme-io/caixa-teia".into(),
5574 tag: None,
5575 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5576 branch: None,
5577 });
5578 d.validate().unwrap();
5579 }
5580
5581 #[test]
5582 fn validate_accepts_git_fonte_with_branch() {
5583 // The :branch arm is the third valid single-pin shape — pinned
5584 // separately so the gate-accepts-all-three-pin-axes contract is
5585 // a build-error to relax.
5586 let d = dep_with_fonte(DepSource::Git {
5587 repo: "github:pleme-io/caixa-teia".into(),
5588 tag: None,
5589 rev: None,
5590 branch: Some("main".into()),
5591 });
5592 d.validate().unwrap();
5593 }
5594
5595 #[test]
5596 fn validate_accepts_path_fonte() {
5597 // The positive-control pin on the path source — non-empty
5598 // :caminho, no pin axes (paths have no commit identity). Pinned
5599 // so a future "paths must also pin a rev" tightening surfaces
5600 // here as a structural decision, not a silent break.
5601 let d = dep_with_fonte(DepSource::Path {
5602 caminho: "../caixa-teia".into(),
5603 });
5604 d.validate().unwrap();
5605 }
5606
5607 #[test]
5608 fn validate_rejects_git_fonte_with_empty_repo() {
5609 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5610 // "v1")`: the empty-repo shape silently passed every pre-gate
5611 // codebase because `:fonte` wasn't validated. The git-clone
5612 // failure surfaced far downstream at lacre-resolve time with no
5613 // field naming which `:deps` entry carried the typo. The new
5614 // gate moves the check to caixa-build time at the source
5615 // caixa.lisp.
5616 let d = dep_with_fonte(DepSource::Git {
5617 repo: String::new(),
5618 tag: Some("v0.1.0".into()),
5619 rev: None,
5620 branch: None,
5621 });
5622 let err = d.validate().unwrap_err();
5623 assert!(
5624 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5625 "got {err:?}"
5626 );
5627 }
5628
5629 // -- :repo value-shape gate -------------------------------------------
5630 //
5631 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5632 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5633 // codebase admitted any non-empty string; the new
5634 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5635 // URL intersection-floor at validate time, peer with the three pin
5636 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5637 // `is_git_oid`). Every test in this section is a fail-before /
5638 // pass-after pin on a specific authoring footgun.
5639
5640 #[test]
5641 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5642 // The canonical paste-from-doc footgun on `:repo` — an author
5643 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5644 // a doc paragraph. Until this gate landed the empty-repo arm
5645 // passed (the string isn't empty), the resolver issued
5646 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5647 // surfaced at clone time with a quoting-confused error far from
5648 // the source caixa.lisp. Same paste-from-doc footgun the
5649 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5650 // axis — now closed on the `:repo` URL axis too.
5651 let d = dep_with_fonte(DepSource::Git {
5652 repo: "github:pleme-io/caixa-teia ".into(),
5653 tag: Some("v0.1.0".into()),
5654 rev: None,
5655 branch: None,
5656 });
5657 let err = d.validate().unwrap_err();
5658 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5659 panic!("expected FonteRepoShape, got other variant");
5660 };
5661 assert_eq!(nome, "caixa-teia");
5662 assert_eq!(repo, "github:pleme-io/caixa-teia ");
5663 assert!(
5664 reason.contains("whitespace"),
5665 "reason must surface the whitespace arm, got {reason:?}"
5666 );
5667 }
5668
5669 #[test]
5670 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5671 // The canonical CLI-argument-injection footgun at the `git clone`
5672 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5673 // argv parser read the value as a CLI flag, escaping the
5674 // subprocess argument boundary. The `--` separator workaround
5675 // does not fix the typed slot's accepted set; the gate rejects
5676 // the shape upstream at validate time so the resolver never
5677 // invokes a `git clone -…` subprocess.
5678 let d = dep_with_fonte(DepSource::Git {
5679 repo: "-upload-pack=evil".into(),
5680 tag: Some("v0.1.0".into()),
5681 rev: None,
5682 branch: None,
5683 });
5684 let err = d.validate().unwrap_err();
5685 let DepError::FonteRepoShape { repo, reason, .. } = err else {
5686 panic!("expected FonteRepoShape, got other variant");
5687 };
5688 assert_eq!(repo, "-upload-pack=evil");
5689 assert!(
5690 reason.contains("must not start with `-`"),
5691 "reason must surface the leading-`-` arm, got {reason:?}"
5692 );
5693 }
5694
5695 #[test]
5696 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5697 // The canonical paste-from-multiline-doc footgun — a `:repo`
5698 // string with an embedded `\n` silently breaks git's URL parser
5699 // and is a class of CRLF-injection at the subprocess-argument
5700 // boundary. Caught by the control-char arm (0x0A < 0x20).
5701 let d = dep_with_fonte(DepSource::Git {
5702 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5703 tag: Some("v0.1.0".into()),
5704 rev: None,
5705 branch: None,
5706 });
5707 let err = d.validate().unwrap_err();
5708 let DepError::FonteRepoShape { reason, .. } = err else {
5709 panic!("expected FonteRepoShape, got other variant");
5710 };
5711 assert!(
5712 reason.contains("control character"),
5713 "reason must surface the control-char arm, got {reason:?}"
5714 );
5715 }
5716
5717 #[test]
5718 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5719 // Tab is the sibling whitespace footgun (the canonical
5720 // copy-from-aligned-table paste); pinned separately from the
5721 // space arm so a future relaxation that only catches one
5722 // surfaces here.
5723 let d = dep_with_fonte(DepSource::Git {
5724 repo: "github:pleme-io/caixa-teia\t".into(),
5725 tag: Some("v0.1.0".into()),
5726 rev: None,
5727 branch: None,
5728 });
5729 let err = d.validate().unwrap_err();
5730 assert!(
5731 matches!(
5732 err,
5733 DepError::FonteRepoShape { ref reason, .. }
5734 if reason.contains("whitespace")
5735 ),
5736 "got {err:?}"
5737 );
5738 }
5739
5740 #[test]
5741 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5742 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5743 // non-ASCII silently breaks at git's URL parser and round-trips
5744 // inconsistently across NFC/NFD normalization on APFS /
5745 // case-folding filesystems. Same intersection-floor
5746 // [`is_git_ref_name`] enforces on the refname axes.
5747 let d = dep_with_fonte(DepSource::Git {
5748 repo: "https://github.com/pleme-io/café".into(),
5749 tag: Some("v0.1.0".into()),
5750 rev: None,
5751 branch: None,
5752 });
5753 let err = d.validate().unwrap_err();
5754 assert!(
5755 matches!(
5756 err,
5757 DepError::FonteRepoShape { ref reason, .. }
5758 if reason.contains("non-ASCII")
5759 ),
5760 "got {err:?}"
5761 );
5762 }
5763
5764 #[test]
5765 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5766 // The fail-before-pass-after pin for the canonical paste-from-
5767 // browser-address-bar footgun on `:repo`: an author copies a
5768 // GitHub permalink to a README anchor / line-permalink and
5769 // forgets to trim the `#fragment` tail. Until this arm landed
5770 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5771 // silently passed every prior arm (no whitespace, no control
5772 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5773 // or `:`), libcurl's URL parser stripped the `#readme` tail
5774 // before opening the HTTPS transport, and the lacre embedded
5775 // the value verbatim in its per-dep BLAKE3 closure — two
5776 // authors whose values differ only in their fragment anchor
5777 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5778 // `git clone` but lock to two distinct lacres, defeating the
5779 // THEORY.md §V.2 render-determinism contract. Same value-shape
5780 // axis-floor every peer typed surface enforces; peer `:fonte
5781 // :tag` / `:fonte :branch` already reject the byte-class through
5782 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5783 // URL grammar admitted) and `:entrada :paths` rejects `#` as
5784 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5785 let d = dep_with_fonte(DepSource::Git {
5786 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5787 tag: Some("v0.1.0".into()),
5788 rev: None,
5789 branch: None,
5790 });
5791 let err = d.validate().unwrap_err();
5792 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5793 panic!("expected FonteRepoShape, got other variant");
5794 };
5795 assert_eq!(nome, "caixa-teia");
5796 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5797 assert!(
5798 reason.contains("must not contain `#`"),
5799 "reason must surface the fragment-`#` arm, got {reason:?}"
5800 );
5801 assert!(
5802 reason.contains("fragment"),
5803 "reason must name the URL fragment grammar, got {reason:?}"
5804 );
5805 }
5806
5807 #[test]
5808 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5809 // The symmetric paste-from-Nix-flake-ref footgun — an author
5810 // confuses the Nix flake-reference idiom (`github:foo/
5811 // bar#packageName`, where `#packageName` selects a flake
5812 // output) with the bare git `:repo` shape. The pleme-io
5813 // substrate authors compose flakes downstream of caixa
5814 // (caixa-flake renders a flake.nix), so the cross-idiom leak
5815 // is the canonical near-miss: the author writes the
5816 // flake-ref shape into a git `:repo` slot. Pinned separately
5817 // from the HTTPS-anchor arm so a future relaxation that
5818 // narrows to one URL scheme surfaces here.
5819 let d = dep_with_fonte(DepSource::Git {
5820 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5821 tag: Some("v0.1.0".into()),
5822 rev: None,
5823 branch: None,
5824 });
5825 let err = d.validate().unwrap_err();
5826 let DepError::FonteRepoShape { reason, .. } = err else {
5827 panic!("expected FonteRepoShape, got other variant");
5828 };
5829 assert!(
5830 reason.contains("must not contain `#`"),
5831 "reason must surface the fragment-`#` arm, got {reason:?}"
5832 );
5833 assert!(
5834 reason.contains("Nix flake"),
5835 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5836 );
5837 }
5838
5839 #[test]
5840 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5841 // The fail-before-pass-after pin for the canonical paste-from-
5842 // browser-address-bar footgun on `:repo` (peer with the
5843 // a68f818 fragment-`#` arm on the same axis). An author
5844 // copies a GitHub tab deep-link out of the address bar and
5845 // forgets to trim the `?tab=…` query tail. Until this arm
5846 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5847 // silently passed every prior arm (no whitespace, no control
5848 // chars, no non-ASCII, no `#` fragment, contains a `:`,
5849 // doesn't start with `-` or `:`); GitHub silently ignored
5850 // the `?query` tail and served the same repo regardless;
5851 // the lacre embedded the value verbatim in its per-dep
5852 // BLAKE3 closure — two authors whose values differ only in
5853 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5854 // `?utm_source=twitter`) resolve to the byte-identical
5855 // upstream `git clone` but lock to two distinct lacres,
5856 // defeating the THEORY.md §V.2 render-determinism contract
5857 // on the same axis the `#` fragment arm closes. Same value-
5858 // shape axis-floor every peer typed surface enforces; peer
5859 // `:fonte :tag` / `:fonte :branch` already reject the byte-
5860 // class through `is_git_ref_name`'s alphabet (refspec glob
5861 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5862 // :paths` rejects `?` as the query separator in
5863 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5864 let d = dep_with_fonte(DepSource::Git {
5865 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5866 tag: Some("v0.1.0".into()),
5867 rev: None,
5868 branch: None,
5869 });
5870 let err = d.validate().unwrap_err();
5871 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5872 panic!("expected FonteRepoShape, got other variant");
5873 };
5874 assert_eq!(nome, "caixa-teia");
5875 assert_eq!(
5876 repo,
5877 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5878 );
5879 assert!(
5880 reason.contains("must not contain `?`"),
5881 "reason must surface the query-`?` arm, got {reason:?}"
5882 );
5883 assert!(
5884 reason.contains("query"),
5885 "reason must name the URL query grammar, got {reason:?}"
5886 );
5887 }
5888
5889 #[test]
5890 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
5891 // The symmetric paste-from-social-share footgun — an author
5892 // copies a repo URL out of a Slack unfurl / Twitter share /
5893 // newsletter link / Discord embed and forgets to trim the
5894 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
5895 // campaign-tracker tail. Every major social-share / unfurl /
5896 // newsletter platform appends these UTM parameters; the
5897 // canonical near-miss on the `:repo` axis. Pinned separately
5898 // from the GitHub-tab-deep-link arm so a future relaxation
5899 // that narrows to one query-parameter class surfaces here.
5900 let d = dep_with_fonte(DepSource::Git {
5901 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
5902 .into(),
5903 tag: Some("v0.1.0".into()),
5904 rev: None,
5905 branch: None,
5906 });
5907 let err = d.validate().unwrap_err();
5908 let DepError::FonteRepoShape { reason, .. } = err else {
5909 panic!("expected FonteRepoShape, got other variant");
5910 };
5911 assert!(
5912 reason.contains("must not contain `?`"),
5913 "reason must surface the query-`?` arm, got {reason:?}"
5914 );
5915 assert!(
5916 reason.contains("campaign-tracker"),
5917 "reason must name the campaign-tracker paste footgun, got {reason:?}"
5918 );
5919 }
5920
5921 #[test]
5922 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
5923 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
5924 // both per-byte arms inside the same `for &b in s.as_bytes()`
5925 // loop, so the byte that appears first in the value's byte
5926 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
5927 // (fragment before query — unusual URL-grammar but value-
5928 // disjoint at byte level) carries both `#` and `?`; the `#`
5929 // byte appears first, so the fragment-`#` arm fires, surfacing
5930 // the more self-locating diagnostic on the byte the author
5931 // pasted earliest in the URL. Mirrors the peer cascade
5932 // discipline `fonte_repo_control_char_fires_before_fragment`
5933 // pins on the prior `:repo` byte-class arm.
5934 let d = dep_with_fonte(DepSource::Git {
5935 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
5936 tag: Some("v0.1.0".into()),
5937 rev: None,
5938 branch: None,
5939 });
5940 let err = d.validate().unwrap_err();
5941 let DepError::FonteRepoShape { reason, .. } = err else {
5942 panic!("expected FonteRepoShape, got other variant");
5943 };
5944 assert!(
5945 reason.contains("must not contain `#`"),
5946 "reason must surface the fragment-`#` arm (fires before query-`?` when \
5947 `#` byte appears first in value), got {reason:?}"
5948 );
5949 }
5950
5951 #[test]
5952 fn fonte_repo_control_char_fires_before_fragment() {
5953 // Cascade pin: the control-char arm structurally precedes the
5954 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
5955 // positive on both arms (contains LF and `#`), but the narrower
5956 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
5957 // (`control character`) wins so the author sees the more
5958 // self-locating arm first. Mirrors the peer cascade discipline
5959 // every prior `:repo` byte-class arm establishes.
5960 let d = dep_with_fonte(DepSource::Git {
5961 repo: "github:pleme-io/caixa-teia\n#readme".into(),
5962 tag: Some("v0.1.0".into()),
5963 rev: None,
5964 branch: None,
5965 });
5966 let err = d.validate().unwrap_err();
5967 let DepError::FonteRepoShape { reason, .. } = err else {
5968 panic!("expected FonteRepoShape, got other variant");
5969 };
5970 assert!(
5971 reason.contains("control character"),
5972 "reason must surface the control-char arm, got {reason:?}"
5973 );
5974 }
5975
5976 #[test]
5977 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
5978 // The fail-before-pass-after pin for the canonical Windows-
5979 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
5980 // backslash arm on the sibling `:caminho` path-fonte axis).
5981 // An author pastes a Windows Explorer address-bar / PowerShell
5982 // `Get-Location` output into a `file://` URL slot, producing
5983 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
5984 // value silently passed every prior arm (no whitespace, no
5985 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
5986 // with `-` or `:`); libcurl's URL parser silently translates
5987 // `\` → `/` on some platforms and refuses it on others, so
5988 // the byte rides verbatim into the lacre's per-dep content-
5989 // address but is silently rewritten / rejected at the wire —
5990 // two authors whose `:repo` values differ only in backslash-
5991 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
5992 // resolve to the byte-identical local clone but lock to two
5993 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
5994 // render-determinism contract on the same axis the `#`
5995 // fragment and `?` query arms close. Same value-shape axis-
5996 // floor every peer typed surface enforces; the `:caminho`
5997 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
5998 let d = dep_with_fonte(DepSource::Git {
5999 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6000 tag: Some("v0.1.0".into()),
6001 rev: None,
6002 branch: None,
6003 });
6004 let err = d.validate().unwrap_err();
6005 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6006 panic!("expected FonteRepoShape, got other variant");
6007 };
6008 assert_eq!(nome, "caixa-teia");
6009 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6010 assert!(
6011 reason.contains("must not contain `\\`"),
6012 "reason must surface the backslash-`\\` arm, got {reason:?}"
6013 );
6014 assert!(
6015 reason.contains("Windows"),
6016 "reason must name the Windows-path-confusion footgun, got {reason:?}"
6017 );
6018 }
6019
6020 #[test]
6021 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6022 // The symmetric Win32-shell-mangled-slashes footgun — an author
6023 // copies `https://github.com/foo/bar` into a Win32 shell that
6024 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6025 // separator-coercion bug), pastes the result into a `:repo`
6026 // slot, and produces `https:\\github.com\foo\bar`. Pinned
6027 // separately from the `file://` Explorer-paste arm so a future
6028 // relaxation that narrows to one URL scheme surfaces here.
6029 let d = dep_with_fonte(DepSource::Git {
6030 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6031 tag: Some("v0.1.0".into()),
6032 rev: None,
6033 branch: None,
6034 });
6035 let err = d.validate().unwrap_err();
6036 let DepError::FonteRepoShape { reason, .. } = err else {
6037 panic!("expected FonteRepoShape, got other variant");
6038 };
6039 assert!(
6040 reason.contains("must not contain `\\`"),
6041 "reason must surface the backslash-`\\` arm, got {reason:?}"
6042 );
6043 assert!(
6044 reason.contains("path separator") || reason.contains("path-segment separator"),
6045 "reason must name the URL path-segment separator grammar, got {reason:?}"
6046 );
6047 }
6048
6049 #[test]
6050 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6051 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6052 // are both per-byte arms inside the same `for &b in s.as_bytes()`
6053 // loop, so the byte that appears first in the value's byte order
6054 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6055 // both `#` and `\`; the `#` byte appears first, so the fragment-
6056 // `#` arm fires, surfacing the more self-locating diagnostic on
6057 // the byte the author pasted earliest in the URL. Mirrors the
6058 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6059 // pins on the prior `:repo` byte-class arm.
6060 let d = dep_with_fonte(DepSource::Git {
6061 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6062 tag: Some("v0.1.0".into()),
6063 rev: None,
6064 branch: None,
6065 });
6066 let err = d.validate().unwrap_err();
6067 let DepError::FonteRepoShape { reason, .. } = err else {
6068 panic!("expected FonteRepoShape, got other variant");
6069 };
6070 assert!(
6071 reason.contains("must not contain `#`"),
6072 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6073 `#` byte appears first in value), got {reason:?}"
6074 );
6075 }
6076
6077 #[test]
6078 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6079 // The fail-before-pass-after pin for the canonical URI Template
6080 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6081 // README quick-start snippet / OpenAPI `servers:` URL / Helm
6082 // chart `home:` template that carries unresolved
6083 // `{org}` / `{repo}` placeholders and pastes the raw template
6084 // into the `:repo` slot, expecting the substrate to resolve the
6085 // placeholder downstream. Until this arm landed the value
6086 // silently passed every prior arm (no whitespace, no control
6087 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6088 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6089 // / `%7D` on the wire, so the byte rides verbatim into the
6090 // lacre's per-dep content-address but round-trips inconsistently
6091 // between the lacre's per-dep content-address and the
6092 // resolver's `git clone <repo>` invocation, defeating the
6093 // THEORY.md §V.2 render-determinism contract on the same axis
6094 // the `#` fragment, `?` query, and `\` backslash arms close;
6095 // every git porcelain entry-point additionally fetches a
6096 // nonexistent literal-`{placeholder}`-named path far from the
6097 // source caixa.lisp.
6098 let d = dep_with_fonte(DepSource::Git {
6099 repo: "https://github.com/{org}/caixa-teia".into(),
6100 tag: Some("v0.1.0".into()),
6101 rev: None,
6102 branch: None,
6103 });
6104 let err = d.validate().unwrap_err();
6105 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6106 panic!("expected FonteRepoShape, got other variant");
6107 };
6108 assert_eq!(nome, "caixa-teia");
6109 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6110 assert!(
6111 reason.contains("must not contain `{`"),
6112 "reason must surface the open-brace `{{` arm, got {reason:?}"
6113 );
6114 assert!(
6115 reason.contains("URI Template") || reason.contains("RFC 6570"),
6116 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6117 );
6118 }
6119
6120 #[test]
6121 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6122 // The symmetric Mustache / Handlebars doubled-brace
6123 // substitution-form footgun every CI / IaC templating engine
6124 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6125 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6126 // chart README quick-start snippet emits. Pinned separately
6127 // from the single-`{` `{org}` arm so a future relaxation that
6128 // narrows to one substitution-form surfaces here.
6129 let d = dep_with_fonte(DepSource::Git {
6130 repo: "https://github.com/{{org}}/caixa-teia".into(),
6131 tag: Some("v0.1.0".into()),
6132 rev: None,
6133 branch: None,
6134 });
6135 let err = d.validate().unwrap_err();
6136 let DepError::FonteRepoShape { reason, .. } = err else {
6137 panic!("expected FonteRepoShape, got other variant");
6138 };
6139 assert!(
6140 reason.contains("must not contain `{`"),
6141 "reason must surface the open-brace `{{` arm, got {reason:?}"
6142 );
6143 }
6144
6145 #[test]
6146 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6147 // Asymmetric `}`-only shape — covers the closing-brace-by-
6148 // itself footgun (an author truncated `{org}/{repo}` mid-edit
6149 // and left a trailing `}` from the prior template fragment,
6150 // or pasted a value that included a closing brace from a
6151 // surrounding shell context). Pinned to ensure the predicate
6152 // refuses each brace independently rather than only when both
6153 // appear — a future regression that ANDs the two byte tests
6154 // surfaces here.
6155 let d = dep_with_fonte(DepSource::Git {
6156 repo: "https://github.com/pleme-io/caixa-teia}".into(),
6157 tag: Some("v0.1.0".into()),
6158 rev: None,
6159 branch: None,
6160 });
6161 let err = d.validate().unwrap_err();
6162 let DepError::FonteRepoShape { reason, .. } = err else {
6163 panic!("expected FonteRepoShape, got other variant");
6164 };
6165 assert!(
6166 reason.contains("must not contain `}`"),
6167 "reason must surface the close-brace `}}` arm, got {reason:?}"
6168 );
6169 }
6170
6171 #[test]
6172 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6173 // Cascade pin: the fragment-`#` arm and the template-`{` /
6174 // `}` arm are both per-byte arms inside the same
6175 // `for &b in s.as_bytes()` loop, so the byte that appears
6176 // first in the value's byte order wins. A `:repo
6177 // "https://github.com/p/x#readme{org}"` carries both `#` and
6178 // `{`; the `#` byte appears first, so the fragment-`#` arm
6179 // fires, surfacing the more self-locating diagnostic on the
6180 // byte the author pasted earliest in the URL. Mirrors the
6181 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6182 // pins on the prior `:repo` byte-class arm.
6183 let d = dep_with_fonte(DepSource::Git {
6184 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6185 tag: Some("v0.1.0".into()),
6186 rev: None,
6187 branch: None,
6188 });
6189 let err = d.validate().unwrap_err();
6190 let DepError::FonteRepoShape { reason, .. } = err else {
6191 panic!("expected FonteRepoShape, got other variant");
6192 };
6193 assert!(
6194 reason.contains("must not contain `#`"),
6195 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6196 `#` byte appears first in value), got {reason:?}"
6197 );
6198 }
6199
6200 #[test]
6201 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6202 // The fail-before-pass-after pin for the canonical
6203 // shell-output-redirection footgun on `:repo`: an author
6204 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6205 // / `… >output.txt`) into the `:repo` slot without trimming
6206 // the redirect. Until this arm landed the value silently
6207 // passed every prior arm (no whitespace, no control chars,
6208 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6209 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6210 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6211 // percent-encode set maps `>` → `%3E` on the wire, so the
6212 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6213 // but is silently rewritten or rejected at libcurl's URL-
6214 // parser layer — two authors whose values differ only in
6215 // their redirect tail (`>build.log` vs nothing) resolve to
6216 // the byte-identical upstream `git clone` but lock to two
6217 // distinct lacres, defeating the THEORY.md §V.2 render-
6218 // determinism contract. Peer with the `:caminho` axis's
6219 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6220 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6221 // byte RFC-3986-reserved set on `:entrada :paths`.
6222 let d = dep_with_fonte(DepSource::Git {
6223 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6224 tag: Some("v0.1.0".into()),
6225 rev: None,
6226 branch: None,
6227 });
6228 let err = d.validate().unwrap_err();
6229 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6230 panic!("expected FonteRepoShape, got other variant");
6231 };
6232 assert_eq!(nome, "caixa-teia");
6233 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6234 assert!(
6235 reason.contains("must not contain `>`"),
6236 "reason must surface the output-redirection `>` arm, got {reason:?}"
6237 );
6238 assert!(
6239 reason.contains("redirection") || reason.contains("'delims'"),
6240 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6241 );
6242 }
6243
6244 #[test]
6245 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6246 // The symmetric shell-input-redirection footgun — an author
6247 // pastes a shell-pipeline head (`git clone <input.url` /
6248 // `cat <README.md`) into the `:repo` slot. Pinned separately
6249 // from the `>`-output arm so a future relaxation that only
6250 // catches one of the two redirect bytes surfaces here. Peer
6251 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6252 // arm which closes both `<` and `>` under the same banner.
6253 let d = dep_with_fonte(DepSource::Git {
6254 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6255 tag: Some("v0.1.0".into()),
6256 rev: None,
6257 branch: None,
6258 });
6259 let err = d.validate().unwrap_err();
6260 let DepError::FonteRepoShape { reason, .. } = err else {
6261 panic!("expected FonteRepoShape, got other variant");
6262 };
6263 assert!(
6264 reason.contains("must not contain `<`"),
6265 "reason must surface the input-redirection `<` arm, got {reason:?}"
6266 );
6267 assert!(
6268 reason.contains("RFC 3986") || reason.contains("'unwise'"),
6269 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6270 );
6271 }
6272
6273 #[test]
6274 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6275 // The fail-before-pass-after pin for the canonical
6276 // paste-from-shell-prompt-with-backticked-substitution footgun
6277 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6278 // `:caminho` path-fonte axis). An author pastes a URL whose
6279 // segment carries a backticked command-substitution wrapper
6280 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6281 // from a doc / README quick-start snippet that expected the
6282 // substrate to substitute the value downstream. Until this arm
6283 // landed the value silently passed every prior arm (no
6284 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6285 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6286 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6287 // 'unwise' set and the WHATWG URL spec's fragment percent-
6288 // encode set maps `` ` `` → `%60` on the wire, so the byte
6289 // rides verbatim into the lacre's per-dep BLAKE3 closure but
6290 // is silently rewritten or rejected at libcurl's URL-parser
6291 // layer — two authors whose values differ only in their
6292 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6293 // byte-identical upstream `git clone` but lock to two distinct
6294 // lacres, defeating the THEORY.md §V.2 render-determinism
6295 // contract. Peer with the `:caminho` axis's
6296 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6297 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6298 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6299 let d = dep_with_fonte(DepSource::Git {
6300 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6301 tag: Some("v0.1.0".into()),
6302 rev: None,
6303 branch: None,
6304 });
6305 let err = d.validate().unwrap_err();
6306 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6307 panic!("expected FonteRepoShape, got other variant");
6308 };
6309 assert_eq!(nome, "caixa-teia");
6310 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6311 assert!(
6312 reason.contains("must not contain `` ` ``"),
6313 "reason must surface the backtick command-substitution arm, got {reason:?}"
6314 );
6315 assert!(
6316 reason.contains("command-substitution") || reason.contains("'unwise'"),
6317 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6318 got {reason:?}"
6319 );
6320 }
6321
6322 #[test]
6323 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6324 // Cascade pin: the fragment-`#` arm and the backtick command-
6325 // substitution arm are both per-byte arms inside the same
6326 // `for &b in s.as_bytes()` loop, so the byte that appears first
6327 // in the value's byte order wins. A `:repo
6328 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6329 // and backtick; the `#` byte appears first, so the fragment-
6330 // `#` arm fires, surfacing the more self-locating diagnostic
6331 // on the byte the author pasted earliest in the URL. Mirrors
6332 // the peer cascade discipline
6333 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6334 // pins on the prior `:repo` byte-class arm.
6335 let d = dep_with_fonte(DepSource::Git {
6336 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6337 tag: Some("v0.1.0".into()),
6338 rev: None,
6339 branch: None,
6340 });
6341 let err = d.validate().unwrap_err();
6342 let DepError::FonteRepoShape { reason, .. } = err else {
6343 panic!("expected FonteRepoShape, got other variant");
6344 };
6345 assert!(
6346 reason.contains("must not contain `#`"),
6347 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6348 appears first in value), got {reason:?}"
6349 );
6350 }
6351
6352 #[test]
6353 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6354 // Cascade pin: the shell-redirection `<` / `>` arm and the
6355 // backtick command-substitution arm are both per-byte arms
6356 // inside the same `for &b in s.as_bytes()` loop, so the byte
6357 // that appears first in the value's byte order wins. A `:repo
6358 // "https://github.com/p/x>build.log/`whoami`"` carries both
6359 // `>` and backtick; the `>` byte appears first, so the
6360 // shell-redirection arm fires, surfacing the more self-
6361 // locating diagnostic on the byte the author pasted earliest
6362 // in the URL. Pins the natural-order cascade so a future
6363 // reorder of the per-byte arms surfaces here.
6364 let d = dep_with_fonte(DepSource::Git {
6365 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6366 tag: Some("v0.1.0".into()),
6367 rev: None,
6368 branch: None,
6369 });
6370 let err = d.validate().unwrap_err();
6371 let DepError::FonteRepoShape { reason, .. } = err else {
6372 panic!("expected FonteRepoShape, got other variant");
6373 };
6374 assert!(
6375 reason.contains("must not contain `>`"),
6376 "reason must surface the shell-redirection `>` arm (fires before backtick when \
6377 `>` byte appears first in value), got {reason:?}"
6378 );
6379 }
6380
6381 #[test]
6382 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6383 // Cascade pin: the fragment-`#` arm and the shell-redirection
6384 // `<` / `>` arm are both per-byte arms inside the same
6385 // `for &b in s.as_bytes()` loop, so the byte that appears
6386 // first in the value's byte order wins. A `:repo
6387 // "https://github.com/p/x#readme>build.log"` carries both
6388 // `#` and `>`; the `#` byte appears first, so the fragment-
6389 // `#` arm fires, surfacing the more self-locating diagnostic
6390 // on the byte the author pasted earliest in the URL. Mirrors
6391 // the peer cascade discipline
6392 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6393 // pins on the prior `:repo` byte-class arm.
6394 let d = dep_with_fonte(DepSource::Git {
6395 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6396 tag: Some("v0.1.0".into()),
6397 rev: None,
6398 branch: None,
6399 });
6400 let err = d.validate().unwrap_err();
6401 let DepError::FonteRepoShape { reason, .. } = err else {
6402 panic!("expected FonteRepoShape, got other variant");
6403 };
6404 assert!(
6405 reason.contains("must not contain `#`"),
6406 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6407 `#` byte appears first in value), got {reason:?}"
6408 );
6409 }
6410
6411 #[test]
6412 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6413 // The fail-before-pass-after pin for the canonical
6414 // paste-from-shell-prompt-with-piped-pipeline footgun on
6415 // `:repo` (peer with the 124106f pipe arm on the sibling
6416 // `:caminho` path-fonte axis). An author pastes a shell
6417 // pipeline (`git clone <url> | tee build.log`,
6418 // `git ls-remote <url> | head`) into the `:repo` slot,
6419 // forgetting to trim the `| <consumer>` tail. Until this arm
6420 // landed the value silently passed every prior arm (no
6421 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6422 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6423 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6424 // 'unwise' set and the WHATWG URL spec's fragment percent-
6425 // encode set maps `|` → `%7C` on the wire, so the byte rides
6426 // verbatim into the lacre's per-dep BLAKE3 closure but is
6427 // silently rewritten or rejected at libcurl's URL-parser
6428 // layer — two authors whose values differ only in their pipe
6429 // tail (`|tee build.log` vs nothing) resolve to the byte-
6430 // identical upstream `git clone` but lock to two distinct
6431 // lacres, defeating the THEORY.md §V.2 render-determinism
6432 // contract. Peer with the `:caminho` axis's
6433 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6434 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6435 // RFC-3986-reserved set on `:entrada :paths`.
6436 let d = dep_with_fonte(DepSource::Git {
6437 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6438 tag: Some("v0.1.0".into()),
6439 rev: None,
6440 branch: None,
6441 });
6442 let err = d.validate().unwrap_err();
6443 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6444 panic!("expected FonteRepoShape, got other variant");
6445 };
6446 assert_eq!(nome, "caixa-teia");
6447 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6448 assert!(
6449 reason.contains("must not contain `|`"),
6450 "reason must surface the shell-pipe arm, got {reason:?}"
6451 );
6452 assert!(
6453 reason.contains("pipe") || reason.contains("'unwise'"),
6454 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6455 );
6456 }
6457
6458 #[test]
6459 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6460 // Cascade pin: the fragment-`#` arm and the pipe arm are both
6461 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6462 // so the byte that appears first in the value's byte order
6463 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6464 // both `#` and `|`; the `#` byte appears first, so the
6465 // fragment-`#` arm fires, surfacing the more self-locating
6466 // diagnostic on the byte the author pasted earliest in the
6467 // URL. Mirrors the peer cascade discipline
6468 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6469 // pins on the prior `:repo` byte-class arm.
6470 let d = dep_with_fonte(DepSource::Git {
6471 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".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 fragment-`#` arm (fires before pipe when `#` byte \
6483 appears first in value), got {reason:?}"
6484 );
6485 }
6486
6487 #[test]
6488 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6489 // Cascade pin: the backtick arm and the pipe arm are both per-
6490 // byte arms inside the same `for &b in s.as_bytes()` loop, so
6491 // the byte that appears first in the value's byte order wins.
6492 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6493 // `` ` `` and `|`; the backtick byte appears first, so the
6494 // backtick arm fires, surfacing the more self-locating
6495 // diagnostic on the byte the author pasted earliest in the
6496 // URL. Pins the natural-order cascade so a future reorder of
6497 // the per-byte arms surfaces here.
6498 let d = dep_with_fonte(DepSource::Git {
6499 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6500 tag: Some("v0.1.0".into()),
6501 rev: None,
6502 branch: None,
6503 });
6504 let err = d.validate().unwrap_err();
6505 let DepError::FonteRepoShape { reason, .. } = err else {
6506 panic!("expected FonteRepoShape, got other variant");
6507 };
6508 assert!(
6509 reason.contains("must not contain `` ` ``"),
6510 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6511 appears first in value), got {reason:?}"
6512 );
6513 }
6514
6515 #[test]
6516 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6517 // The fail-before-pass-after pin for the canonical
6518 // paste-from-shell-prompt-with-sequential-command-tail footgun
6519 // on `:repo` (peer with the 05c358e `;` arm on the sibling
6520 // `:caminho` path-fonte axis). An author pastes a shell
6521 // one-liner that chained a cleanup tail after the URL
6522 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6523 // echo done`) into the `:repo` slot, forgetting to trim the
6524 // `; <cmd>` tail. Until this arm landed the value silently
6525 // passed every prior `is_git_repo_url` arm (no whitespace, no
6526 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6527 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6528 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6529 // reserved set and the WHATWG URL spec's fragment percent-
6530 // encode set maps `;` → `%3B` on the wire, so the byte rides
6531 // verbatim into the lacre's per-dep BLAKE3 closure but is
6532 // silently rewritten at libcurl's URL-parser layer — two
6533 // authors whose values differ only in their sequential-command
6534 // tail (`; rm -rf build` vs nothing) resolve to the byte-
6535 // identical upstream `git clone` but lock to two distinct
6536 // lacres, defeating the THEORY.md §V.2 render-determinism
6537 // contract. Peer with the `:caminho` axis's
6538 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6539 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6540 // byte RFC-3986-reserved set on `:entrada :paths`.
6541 let d = dep_with_fonte(DepSource::Git {
6542 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6543 tag: Some("v0.1.0".into()),
6544 rev: None,
6545 branch: None,
6546 });
6547 let err = d.validate().unwrap_err();
6548 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6549 panic!("expected FonteRepoShape, got other variant");
6550 };
6551 assert_eq!(nome, "caixa-teia");
6552 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6553 assert!(
6554 reason.contains("must not contain `;`"),
6555 "reason must surface the shell-command-separator arm, got {reason:?}"
6556 );
6557 assert!(
6558 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6559 "reason must name the shell-command-separator / RFC-3986-sub-delims \
6560 rationale, got {reason:?}"
6561 );
6562 }
6563
6564 #[test]
6565 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6566 // Cascade pin: the fragment-`#` arm and the semicolon arm are
6567 // both per-byte arms inside the same `for &b in s.as_bytes()`
6568 // loop, so the byte that appears first in the value's byte
6569 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6570 // carries both `#` and `;`; the `#` byte appears first, so the
6571 // fragment-`#` arm fires, surfacing the more self-locating
6572 // diagnostic on the byte the author pasted earliest in the URL.
6573 // Mirrors the peer cascade discipline
6574 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6575 // pins on the prior `:repo` byte-class arm.
6576 let d = dep_with_fonte(DepSource::Git {
6577 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6578 tag: Some("v0.1.0".into()),
6579 rev: None,
6580 branch: None,
6581 });
6582 let err = d.validate().unwrap_err();
6583 let DepError::FonteRepoShape { reason, .. } = err else {
6584 panic!("expected FonteRepoShape, got other variant");
6585 };
6586 assert!(
6587 reason.contains("must not contain `#`"),
6588 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6589 byte appears first in value), got {reason:?}"
6590 );
6591 }
6592
6593 #[test]
6594 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6595 // Cascade pin: the pipe arm and the semicolon arm are both
6596 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6597 // so the byte that appears first in the value's byte order
6598 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6599 // both `|` and `;`; the `|` byte appears first, so the
6600 // pipe arm fires, surfacing the more self-locating diagnostic
6601 // on the byte the author pasted earliest in the URL. Pins the
6602 // natural-order cascade so a future reorder of the per-byte
6603 // arms surfaces here.
6604 let d = dep_with_fonte(DepSource::Git {
6605 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6606 tag: Some("v0.1.0".into()),
6607 rev: None,
6608 branch: None,
6609 });
6610 let err = d.validate().unwrap_err();
6611 let DepError::FonteRepoShape { reason, .. } = err else {
6612 panic!("expected FonteRepoShape, got other variant");
6613 };
6614 assert!(
6615 reason.contains("must not contain `|`"),
6616 "reason must surface the pipe arm (fires before semicolon when `|` byte \
6617 appears first in value), got {reason:?}"
6618 );
6619 }
6620
6621 #[test]
6622 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6623 // The fail-before-pass-after pin for the canonical
6624 // paste-from-shell-prompt-with-background-launch-tail footgun
6625 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6626 // `:caminho` path-fonte axis). An author pastes a shell one-
6627 // liner that detached the clone into the background
6628 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6629 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6630 // `&& <cmd>` tail. Until this arm landed the value silently
6631 // passed every prior `is_git_repo_url` arm (no whitespace,
6632 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6633 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6634 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6635 // the 'sub-delims' / reserved set and the WHATWG URL spec's
6636 // fragment percent-encode set maps `&` → `%26` on the wire,
6637 // so the byte rides verbatim into the lacre's per-dep
6638 // BLAKE3 closure but is silently rewritten at libcurl's
6639 // URL-parser layer — two authors whose values differ only
6640 // in their background-launch tail (`& sleep 1` vs nothing)
6641 // resolve to the byte-identical upstream `git clone` but
6642 // lock to two distinct lacres, defeating the THEORY.md
6643 // §V.2 render-determinism contract. Peer with the
6644 // `:caminho` axis's `FonteCaminhoShellBackground` arm
6645 // (e12e4f3) on the sibling path-fonte axis, and
6646 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6647 // reserved set on `:entrada :paths`.
6648 let d = dep_with_fonte(DepSource::Git {
6649 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6650 tag: Some("v0.1.0".into()),
6651 rev: None,
6652 branch: None,
6653 });
6654 let err = d.validate().unwrap_err();
6655 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6656 panic!("expected FonteRepoShape, got other variant");
6657 };
6658 assert_eq!(nome, "caixa-teia");
6659 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6660 assert!(
6661 reason.contains("must not contain `&`"),
6662 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6663 );
6664 assert!(
6665 reason.contains("background-task") || reason.contains("'sub-delims'"),
6666 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6667 got {reason:?}"
6668 );
6669 }
6670
6671 #[test]
6672 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6673 // The fail-before-pass-after pin for the symmetric `&&`
6674 // logical-AND build-chain paste footgun: an author pastes
6675 // a `git clone <url> && cd <repo>` build-chain one-liner
6676 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6677 // is the same `&` byte twice in a row; the per-byte arm
6678 // fires on the first `&` it sees. Pinned separately from
6679 // the single-`&` background-launch shape so a future
6680 // diagnostic-surface change that special-cased the
6681 // doubled-byte form surfaces here.
6682 let d = dep_with_fonte(DepSource::Git {
6683 repo: "github:pleme-io/caixa-teia&&echo".into(),
6684 tag: Some("v0.1.0".into()),
6685 rev: None,
6686 branch: None,
6687 });
6688 let err = d.validate().unwrap_err();
6689 let DepError::FonteRepoShape { reason, .. } = err else {
6690 panic!("expected FonteRepoShape, got other variant");
6691 };
6692 assert!(
6693 reason.contains("must not contain `&`"),
6694 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6695 shape too, got {reason:?}"
6696 );
6697 }
6698
6699 #[test]
6700 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6701 // Cascade pin: the fragment-`#` arm and the background-`&`
6702 // arm are both per-byte arms inside the same `for &b in
6703 // s.as_bytes()` loop, so the byte that appears first in the
6704 // value's byte order wins. A `:repo
6705 // "https://github.com/p/x#readme & sleep"` carries both `#`
6706 // and `&`; the `#` byte appears first, so the fragment-`#`
6707 // arm fires, surfacing the more self-locating diagnostic on
6708 // the byte the author pasted earliest in the URL. Mirrors
6709 // the peer cascade discipline
6710 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6711 // on the prior `:repo` byte-class arm.
6712 let d = dep_with_fonte(DepSource::Git {
6713 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6714 tag: Some("v0.1.0".into()),
6715 rev: None,
6716 branch: None,
6717 });
6718 let err = d.validate().unwrap_err();
6719 let DepError::FonteRepoShape { reason, .. } = err else {
6720 panic!("expected FonteRepoShape, got other variant");
6721 };
6722 assert!(
6723 reason.contains("must not contain `#`"),
6724 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6725 byte appears first in value), got {reason:?}"
6726 );
6727 }
6728
6729 #[test]
6730 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6731 // Cascade pin: the semicolon arm and the background-`&` arm
6732 // are both per-byte arms inside the same `for &b in
6733 // s.as_bytes()` loop, so the byte that appears first in the
6734 // value's byte order wins. A `:repo
6735 // "https://github.com/p/x; rm & sleep"` carries both `;` and
6736 // `&`; the `;` byte appears first, so the semicolon arm
6737 // fires, surfacing the more self-locating diagnostic on the
6738 // byte the author pasted earliest in the URL. Pins the
6739 // natural-order cascade so a future reorder of the per-byte
6740 // arms surfaces here.
6741 let d = dep_with_fonte(DepSource::Git {
6742 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6743 tag: Some("v0.1.0".into()),
6744 rev: None,
6745 branch: None,
6746 });
6747 let err = d.validate().unwrap_err();
6748 let DepError::FonteRepoShape { reason, .. } = err else {
6749 panic!("expected FonteRepoShape, got other variant");
6750 };
6751 assert!(
6752 reason.contains("must not contain `;`"),
6753 "reason must surface the semicolon arm (fires before background-`&` when `;` \
6754 byte appears first in value), got {reason:?}"
6755 );
6756 }
6757
6758 #[test]
6759 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6760 // The fail-before-pass-after pin for the canonical
6761 // paste-from-shell-prompt-with-unsubstituted-variable footgun
6762 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6763 // `:caminho` path-fonte axis). An author pastes a shell one-
6764 // liner that referenced an environment variable
6765 // (`git clone https://github.com/$ORG/x`, `git clone
6766 // github:$USER/repo`) into the `:repo` slot, forgetting to
6767 // substitute the literal value at author time. Until this arm
6768 // landed the value silently passed every prior
6769 // `is_git_repo_url` arm (no whitespace, no control chars, no
6770 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6771 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6772 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6773 // reserved set and the WHATWG URL spec's fragment percent-
6774 // encode set maps `$` → `%24` on the wire, so the byte rides
6775 // verbatim into the lacre's per-dep BLAKE3 closure but is
6776 // silently rewritten at libcurl's URL-parser layer — two
6777 // authors whose values differ only in their `$VAR` /
6778 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6779 // identical upstream `git clone` but lock to two distinct
6780 // lacres, defeating the THEORY.md §V.2 render-determinism
6781 // contract. Beyond determinism, the value is a structural
6782 // host-layout leak: two authors with the same `:repo` slot
6783 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6784 // different upstreams. Peer with the `:caminho` axis's
6785 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6786 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6787 // byte RFC-3986-reserved set on `:entrada :paths`.
6788 let d = dep_with_fonte(DepSource::Git {
6789 repo: "https://github.com/$ORG/caixa-teia".into(),
6790 tag: Some("v0.1.0".into()),
6791 rev: None,
6792 branch: None,
6793 });
6794 let err = d.validate().unwrap_err();
6795 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6796 panic!("expected FonteRepoShape, got other variant");
6797 };
6798 assert_eq!(nome, "caixa-teia");
6799 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6800 assert!(
6801 reason.contains("must not contain `$`"),
6802 "reason must surface the shell-variable-expansion arm, got {reason:?}"
6803 );
6804 assert!(
6805 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6806 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6807 rationale, got {reason:?}"
6808 );
6809 }
6810
6811 #[test]
6812 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6813 // The fail-before-pass-after pin for the symmetric POSIX-
6814 // shell braced `${VAR}` expansion paste footgun: an author
6815 // pastes a CI-manifest line `git clone
6816 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6817 // Actions / GitLab CI / Drone shape) and forgets to
6818 // substitute the literal value. The `${...}` shape is the
6819 // same `$` byte at the leading position of the expansion;
6820 // the per-byte arm fires on the `$`. Pinned separately from
6821 // the bare-`$VAR` shape so a future diagnostic-surface
6822 // change that special-cased the braced form surfaces here.
6823 let d = dep_with_fonte(DepSource::Git {
6824 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6825 tag: Some("v0.1.0".into()),
6826 rev: None,
6827 branch: None,
6828 });
6829 let err = d.validate().unwrap_err();
6830 let DepError::FonteRepoShape { reason, .. } = err else {
6831 panic!("expected FonteRepoShape, got other variant");
6832 };
6833 assert!(
6834 reason.contains("must not contain `$`"),
6835 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6836 shape too, got {reason:?}"
6837 );
6838 }
6839
6840 #[test]
6841 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6842 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6843 // arm are both per-byte arms inside the same `for &b in
6844 // s.as_bytes()` loop, so the byte that appears first in the
6845 // value's byte order wins. A `:repo
6846 // "https://github.com/p/x#readme$HOME"` carries both `#` and
6847 // `$`; the `#` byte appears first, so the fragment-`#` arm
6848 // fires, surfacing the more self-locating diagnostic on the
6849 // byte the author pasted earliest in the URL. Mirrors the
6850 // peer cascade discipline
6851 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6852 // on the prior `:repo` byte-class arm.
6853 let d = dep_with_fonte(DepSource::Git {
6854 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6855 tag: Some("v0.1.0".into()),
6856 rev: None,
6857 branch: None,
6858 });
6859 let err = d.validate().unwrap_err();
6860 let DepError::FonteRepoShape { reason, .. } = err else {
6861 panic!("expected FonteRepoShape, got other variant");
6862 };
6863 assert!(
6864 reason.contains("must not contain `#`"),
6865 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6866 `#` byte appears first in value), got {reason:?}"
6867 );
6868 }
6869
6870 #[test]
6871 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6872 // Cascade pin: the background-`&` arm and the
6873 // var-expansion-`$` arm are both per-byte arms inside the
6874 // same `for &b in s.as_bytes()` loop, so the byte that
6875 // appears first in the value's byte order wins. A `:repo
6876 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6877 // `$`; the `&` byte appears first, so the background arm
6878 // fires, surfacing the more self-locating diagnostic on the
6879 // byte the author pasted earliest in the URL. Pins the
6880 // natural-order cascade so a future reorder of the per-byte
6881 // arms surfaces here — `$` is the most recent byte-class arm,
6882 // so the cascade-pin sweep extends to cover every immediately
6883 // prior byte arm (`#`, `&`) firing first when ordered ahead
6884 // of `$` in the value.
6885 let d = dep_with_fonte(DepSource::Git {
6886 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
6887 tag: Some("v0.1.0".into()),
6888 rev: None,
6889 branch: None,
6890 });
6891 let err = d.validate().unwrap_err();
6892 let DepError::FonteRepoShape { reason, .. } = err else {
6893 panic!("expected FonteRepoShape, got other variant");
6894 };
6895 assert!(
6896 reason.contains("must not contain `&`"),
6897 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
6898 `&` byte appears first in value), got {reason:?}"
6899 );
6900 }
6901
6902 #[test]
6903 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
6904 // The fail-before-pass-after pin for the canonical
6905 // paste-from-shell-prompt glob footgun on `:repo` (peer with
6906 // the cf9034b `*` / `?` arm on the sibling `:caminho`
6907 // path-fonte axis). An author pastes a shell one-liner that
6908 // referenced a glob expansion (`ls
6909 // github.com/pleme-io/caixa-*`, `git clone
6910 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
6911 // to substitute the literal repo name. Until this arm landed
6912 // the `*` byte silently passed every prior `is_git_repo_url`
6913 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
6914 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
6915 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
6916 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
6917 // the WHATWG URL spec's special-query percent-encode set maps
6918 // `*` → `%2A` on the wire, so the byte rides verbatim into
6919 // the lacre's per-dep BLAKE3 closure but is silently
6920 // rewritten at libcurl's URL-parser layer — two authors
6921 // whose values differ only in their asterisk presence
6922 // resolve to the byte-identical upstream `git clone` but
6923 // lock to two distinct lacres, defeating the THEORY.md §V.2
6924 // render-determinism contract. Peer with the `:caminho`
6925 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
6926 // sibling path-fonte axis, and the `is_git_ref_name`
6927 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
6928 // axes.
6929 let d = dep_with_fonte(DepSource::Git {
6930 repo: "https://github.com/pleme-io/caixa-*".into(),
6931 tag: Some("v0.1.0".into()),
6932 rev: None,
6933 branch: None,
6934 });
6935 let err = d.validate().unwrap_err();
6936 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6937 panic!("expected FonteRepoShape, got other variant");
6938 };
6939 assert_eq!(nome, "caixa-teia");
6940 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
6941 assert!(
6942 reason.contains("must not contain `*`"),
6943 "reason must surface the shell-glob arm, got {reason:?}"
6944 );
6945 assert!(
6946 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
6947 "reason must name the shell-glob / pathname-expansion / \
6948 RFC-3986-sub-delims rationale, got {reason:?}"
6949 );
6950 }
6951
6952 #[test]
6953 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
6954 // The fail-before-pass-after pin for the symmetric bash
6955 // `globstar` recursive-glob paste footgun: an author pastes
6956 // a `ls github.com/pleme-io/**/x` (the canonical
6957 // `globstar`-shopt-enabled recursive-listing tail) into the
6958 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
6959 // the per-byte arm fires on the first `*`. Pinned
6960 // separately from the single-`*` shape so a future
6961 // diagnostic-surface change that special-cased the
6962 // double-`*` form surfaces here.
6963 let d = dep_with_fonte(DepSource::Git {
6964 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
6965 tag: Some("v0.1.0".into()),
6966 rev: None,
6967 branch: None,
6968 });
6969 let err = d.validate().unwrap_err();
6970 let DepError::FonteRepoShape { reason, .. } = err else {
6971 panic!("expected FonteRepoShape, got other variant");
6972 };
6973 assert!(
6974 reason.contains("must not contain `*`"),
6975 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
6976 got {reason:?}"
6977 );
6978 }
6979
6980 #[test]
6981 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
6982 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
6983 // both per-byte arms inside the same `for &b in s.as_bytes()`
6984 // loop, so the byte that appears first in the value's byte
6985 // order wins. A `:repo
6986 // "https://github.com/p/x#readme*tail"` carries both `#` and
6987 // `*`; the `#` byte appears first, so the fragment-`#` arm
6988 // fires, surfacing the more self-locating diagnostic on the
6989 // byte the author pasted earliest in the URL. Mirrors the
6990 // peer cascade discipline
6991 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
6992 // on the prior `:repo` byte-class arm.
6993 let d = dep_with_fonte(DepSource::Git {
6994 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
6995 tag: Some("v0.1.0".into()),
6996 rev: None,
6997 branch: None,
6998 });
6999 let err = d.validate().unwrap_err();
7000 let DepError::FonteRepoShape { reason, .. } = err else {
7001 panic!("expected FonteRepoShape, got other variant");
7002 };
7003 assert!(
7004 reason.contains("must not contain `#`"),
7005 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7006 appears first in value), got {reason:?}"
7007 );
7008 }
7009
7010 #[test]
7011 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7012 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7013 // arm are both per-byte arms inside the same `for &b in
7014 // s.as_bytes()` loop, so the byte that appears first in the
7015 // value's byte order wins. A `:repo
7016 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7017 // the `$` byte appears first, so the var-expansion arm
7018 // fires, surfacing the more self-locating diagnostic on the
7019 // byte the author pasted earliest in the URL. Pins the
7020 // natural-order cascade so a future reorder of the per-byte
7021 // arms surfaces here — `*` is the most recent byte-class
7022 // arm, so the cascade-pin sweep extends to cover the
7023 // immediately prior `$` byte arm firing first when ordered
7024 // ahead of `*` in the value.
7025 let d = dep_with_fonte(DepSource::Git {
7026 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7027 tag: Some("v0.1.0".into()),
7028 rev: None,
7029 branch: None,
7030 });
7031 let err = d.validate().unwrap_err();
7032 let DepError::FonteRepoShape { reason, .. } = err else {
7033 panic!("expected FonteRepoShape, got other variant");
7034 };
7035 assert!(
7036 reason.contains("must not contain `$`"),
7037 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7038 byte appears first in value), got {reason:?}"
7039 );
7040 }
7041
7042 #[test]
7043 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7044 // The fail-before-pass-after pin for the canonical paste-from-
7045 // shell-prompt subshell-grouping footgun on `:repo`. An author
7046 // pastes a doc / README snippet carrying a regex-alternation
7047 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7048 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7049 // `:repo` slot, forgetting to substitute one literal org name.
7050 // Until this arm landed the `(` byte silently passed every
7051 // prior `is_git_repo_url` arm (no whitespace, no control
7052 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7053 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7054 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7055 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7056 // URL spec's special-query percent-encode set maps `(` →
7057 // `%28` and `)` → `%29` on the wire, so the byte rides
7058 // verbatim into the lacre's per-dep BLAKE3 closure but is
7059 // silently rewritten at libcurl's URL-parser layer —
7060 // defeating the THEORY.md §V.2 render-determinism contract on
7061 // the same axis the prior twelve byte-class arms close.
7062 let d = dep_with_fonte(DepSource::Git {
7063 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7064 tag: Some("v0.1.0".into()),
7065 rev: None,
7066 branch: None,
7067 });
7068 let err = d.validate().unwrap_err();
7069 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7070 panic!("expected FonteRepoShape, got other variant");
7071 };
7072 assert_eq!(nome, "caixa-teia");
7073 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7074 assert!(
7075 reason.contains("must not contain `(`"),
7076 "reason must surface the subshell-open-paren arm, got {reason:?}"
7077 );
7078 assert!(
7079 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7080 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7081 got {reason:?}"
7082 );
7083 }
7084
7085 #[test]
7086 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7087 // The symmetric arm pin on the closing `)` byte: an author
7088 // pastes a `$(date)` command-substitution wrapper or a
7089 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7090 // Pinned separately from the opening `(` shape so a future
7091 // diagnostic-surface change that only checked one boundary
7092 // surfaces here. The `(` byte appears earlier in the
7093 // canonical regex / subshell wrapper so the per-byte loop
7094 // fires on `(` first; this test exercises a `:repo` value
7095 // carrying only the closing `)` byte (no opening paren) so
7096 // the `)` arm fires directly — pinning the byte-class arm
7097 // independent of order.
7098 let d = dep_with_fonte(DepSource::Git {
7099 repo: "github:pleme-io/caixa-teia)tail".into(),
7100 tag: Some("v0.1.0".into()),
7101 rev: None,
7102 branch: None,
7103 });
7104 let err = d.validate().unwrap_err();
7105 let DepError::FonteRepoShape { reason, .. } = err else {
7106 panic!("expected FonteRepoShape, got other variant");
7107 };
7108 assert!(
7109 reason.contains("must not contain `)`"),
7110 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7111 got {reason:?}"
7112 );
7113 }
7114
7115 #[test]
7116 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7117 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7118 // are both per-byte arms inside the same `for &b in
7119 // s.as_bytes()` loop, so the byte that appears first in the
7120 // value's byte order wins. A `:repo
7121 // "https://github.com/p/x#readme(tail)"` carries both `#` and
7122 // `(`; the `#` byte appears first, so the fragment-`#` arm
7123 // fires, surfacing the more self-locating diagnostic on the
7124 // byte the author pasted earliest in the URL. Mirrors the
7125 // peer cascade discipline
7126 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7127 // on the prior `:repo` byte-class arm.
7128 let d = dep_with_fonte(DepSource::Git {
7129 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7130 tag: Some("v0.1.0".into()),
7131 rev: None,
7132 branch: None,
7133 });
7134 let err = d.validate().unwrap_err();
7135 let DepError::FonteRepoShape { reason, .. } = err else {
7136 panic!("expected FonteRepoShape, got other variant");
7137 };
7138 assert!(
7139 reason.contains("must not contain `#`"),
7140 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7141 byte appears first in value), got {reason:?}"
7142 );
7143 }
7144
7145 #[test]
7146 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7147 // Cascade pin: the glob-`*` arm (the immediate-predecessor
7148 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7149 // per-byte arms inside the same `for &b in s.as_bytes()`
7150 // loop, so the byte that appears first in the value's byte
7151 // order wins. A `:repo
7152 // "https://github.com/p/x-*-(date)"` carries both `*` and
7153 // `(`; the `*` byte appears first, so the glob arm fires,
7154 // surfacing the more self-locating diagnostic on the byte
7155 // the author pasted earliest in the URL. Pins the natural-
7156 // order cascade so a future reorder of the per-byte arms
7157 // surfaces here — `(` is the most recent byte-class arm,
7158 // so the cascade-pin sweep extends to cover the immediately
7159 // prior `*` byte arm firing first when ordered ahead of `(`
7160 // in the value.
7161 let d = dep_with_fonte(DepSource::Git {
7162 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7163 tag: Some("v0.1.0".into()),
7164 rev: None,
7165 branch: None,
7166 });
7167 let err = d.validate().unwrap_err();
7168 let DepError::FonteRepoShape { reason, .. } = err else {
7169 panic!("expected FonteRepoShape, got other variant");
7170 };
7171 assert!(
7172 reason.contains("must not contain `*`"),
7173 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7174 appears first in value), got {reason:?}"
7175 );
7176 }
7177
7178 #[test]
7179 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7180 // The fail-before-pass-after pin for the canonical paste-from-
7181 // doc-shell-quoting footgun on `:repo`. An author copies a
7182 // README quick-start snippet (`$ git clone "https://github.com/
7183 // foo/bar"`) and keeps the surrounding double-quote bytes when
7184 // pasting into the `:repo` slot — the doc wraps the URL in
7185 // double quotes so the shell doesn't re-lex metachars inside,
7186 // but the typed slot is itself a byte-level string parser, not
7187 // a shell context, so the quote bytes ride into the value
7188 // verbatim. Until this arm landed the `"` byte silently passed
7189 // every prior `is_git_repo_url` arm (no whitespace, no control
7190 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7191 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7192 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7193 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7194 // `` ` ``) every URL parser is required to refuse or percent-
7195 // encode, and the WHATWG URL spec's 'C0 control percent-encode
7196 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7197 // into the lacre's per-dep BLAKE3 closure but is silently
7198 // rewritten at libcurl's URL-parser layer, defeating the
7199 // THEORY.md §V.2 render-determinism contract.
7200 let d = dep_with_fonte(DepSource::Git {
7201 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7202 tag: Some("v0.1.0".into()),
7203 rev: None,
7204 branch: None,
7205 });
7206 let err = d.validate().unwrap_err();
7207 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7208 panic!("expected FonteRepoShape, got other variant");
7209 };
7210 assert_eq!(nome, "caixa-teia");
7211 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7212 assert!(
7213 reason.contains("must not contain `\"`"),
7214 "reason must surface the shell-double-quote arm, got {reason:?}"
7215 );
7216 assert!(
7217 reason.contains("double-quote") || reason.contains("'delims'"),
7218 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7219 got {reason:?}"
7220 );
7221 }
7222
7223 #[test]
7224 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7225 // The symmetric stray-quote tail pin: an author pastes only a
7226 // closing `"` from a shell-history line like `git clone
7227 // "https://github.com/foo/bar" && cd …` (the trim went too
7228 // far in one direction but not the other) into the `:repo`
7229 // slot. Pinned separately from the wrapped-quote shape so a
7230 // future diagnostic-surface change that only checked one
7231 // boundary (only leading, only trailing, only paired) surfaces
7232 // here — the per-byte arm fires anywhere `"` appears.
7233 let d = dep_with_fonte(DepSource::Git {
7234 repo: "github:pleme-io/caixa-teia\"".into(),
7235 tag: Some("v0.1.0".into()),
7236 rev: None,
7237 branch: None,
7238 });
7239 let err = d.validate().unwrap_err();
7240 let DepError::FonteRepoShape { reason, .. } = err else {
7241 panic!("expected FonteRepoShape, got other variant");
7242 };
7243 assert!(
7244 reason.contains("must not contain `\"`"),
7245 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7246 got {reason:?}"
7247 );
7248 }
7249
7250 #[test]
7251 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7252 // Cascade pin: the fragment-`#` arm and the double-quote arm
7253 // are both per-byte arms inside the same `for &b in
7254 // s.as_bytes()` loop, so the byte that appears first in the
7255 // value's byte order wins. A `:repo
7256 // "https://github.com/p/x#readme\"tail"` carries both `#` and
7257 // `"`; the `#` byte appears first, so the fragment-`#` arm
7258 // fires, surfacing the more self-locating diagnostic on the
7259 // byte the author pasted earliest in the URL.
7260 let d = dep_with_fonte(DepSource::Git {
7261 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7262 tag: Some("v0.1.0".into()),
7263 rev: None,
7264 branch: None,
7265 });
7266 let err = d.validate().unwrap_err();
7267 let DepError::FonteRepoShape { reason, .. } = err else {
7268 panic!("expected FonteRepoShape, got other variant");
7269 };
7270 assert!(
7271 reason.contains("must not contain `#`"),
7272 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7273 byte appears first in value), got {reason:?}"
7274 );
7275 }
7276
7277 #[test]
7278 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7279 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7280 // byte-class arm, 3b99147) and the double-quote arm are both
7281 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7282 // so the byte that appears first in the value's byte order
7283 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7284 // and `"`; the `(` byte appears first, so the subshell arm
7285 // fires, surfacing the more self-locating diagnostic on the
7286 // byte the author pasted earliest in the URL. Pins the natural-
7287 // order cascade so a future reorder of the per-byte arms
7288 // surfaces here — `"` is the most recent byte-class arm, so
7289 // the cascade-pin sweep extends to cover the immediately prior
7290 // `(` byte arm firing first when ordered ahead of `"` in the
7291 // value.
7292 let d = dep_with_fonte(DepSource::Git {
7293 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7294 tag: Some("v0.1.0".into()),
7295 rev: None,
7296 branch: None,
7297 });
7298 let err = d.validate().unwrap_err();
7299 let DepError::FonteRepoShape { reason, .. } = err else {
7300 panic!("expected FonteRepoShape, got other variant");
7301 };
7302 assert!(
7303 reason.contains("must not contain `(`"),
7304 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7305 byte appears first in value), got {reason:?}"
7306 );
7307 }
7308
7309 #[test]
7310 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7311 // The fail-before-pass-after pin for the canonical paste-from-
7312 // doc-strong-quoting footgun on `:repo`. An author copies a
7313 // security-conscious README quick-start snippet (`$ git clone
7314 // 'https://github.com/foo/bar'`) and keeps the surrounding
7315 // single-quote bytes when pasting into the `:repo` slot — the
7316 // doc strong-quotes the URL so the shell suppresses every form
7317 // of expansion on the bytes inside (no `$`, no backtick, no
7318 // glob, no word-splitting), but the typed slot is itself a
7319 // byte-level string parser, not a shell context, so the quote
7320 // bytes ride into the value verbatim. Until this arm landed the
7321 // `'` byte silently passed every prior `is_git_repo_url` arm
7322 // (no whitespace, no control chars, no non-ASCII, no `#`, no
7323 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7324 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7325 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7326 // set, peer with the `\"` 'delims' double-quote arm and the
7327 // partner ASCII shell-string-delimiter byte every byte-level
7328 // string parser sharing a value-shape with a shell argument
7329 // must refuse on a URL-shaped slot.
7330 let d = dep_with_fonte(DepSource::Git {
7331 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7332 tag: Some("v0.1.0".into()),
7333 rev: None,
7334 branch: None,
7335 });
7336 let err = d.validate().unwrap_err();
7337 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7338 panic!("expected FonteRepoShape, got other variant");
7339 };
7340 assert_eq!(nome, "caixa-teia");
7341 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7342 assert!(
7343 reason.contains("must not contain `'`"),
7344 "reason must surface the shell-single-quote arm, got {reason:?}"
7345 );
7346 assert!(
7347 reason.contains("single-quote") || reason.contains("strong-quote"),
7348 "reason must name the shell-single-quote / strong-quote rationale, \
7349 got {reason:?}"
7350 );
7351 }
7352
7353 #[test]
7354 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7355 // The symmetric English-typography pin: an author writes
7356 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7357 // from-prose idiom every README / commit-message / chat-thread
7358 // reference to a repo carries) expecting the substrate to
7359 // coerce it to a kebab-case slug — but the byte rides into the
7360 // lacre verbatim. Pinned separately from the wrapped-quote
7361 // shape so a future diagnostic-surface change that only checked
7362 // the boundary positions (only leading, only trailing, only
7363 // paired) surfaces here — the per-byte arm fires anywhere `'`
7364 // appears in the value.
7365 let d = dep_with_fonte(DepSource::Git {
7366 repo: "github:pleme-io/repo's-fork".into(),
7367 tag: Some("v0.1.0".into()),
7368 rev: None,
7369 branch: None,
7370 });
7371 let err = d.validate().unwrap_err();
7372 let DepError::FonteRepoShape { reason, .. } = err else {
7373 panic!("expected FonteRepoShape, got other variant");
7374 };
7375 assert!(
7376 reason.contains("must not contain `'`"),
7377 "reason must surface the shell-single-quote arm on the mid-string \
7378 apostrophe shape, got {reason:?}"
7379 );
7380 }
7381
7382 #[test]
7383 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7384 // Cascade pin: the fragment-`#` arm and the single-quote arm
7385 // are both per-byte arms inside the same `for &b in
7386 // s.as_bytes()` loop, so the byte that appears first in the
7387 // value's byte order wins. A `:repo
7388 // "https://github.com/p/x#readme'tail"` carries both `#` and
7389 // `'`; the `#` byte appears first, so the fragment-`#` arm
7390 // fires, surfacing the more self-locating diagnostic on the
7391 // byte the author pasted earliest in the URL.
7392 let d = dep_with_fonte(DepSource::Git {
7393 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7394 tag: Some("v0.1.0".into()),
7395 rev: None,
7396 branch: None,
7397 });
7398 let err = d.validate().unwrap_err();
7399 let DepError::FonteRepoShape { reason, .. } = err else {
7400 panic!("expected FonteRepoShape, got other variant");
7401 };
7402 assert!(
7403 reason.contains("must not contain `#`"),
7404 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7405 byte appears first in value), got {reason:?}"
7406 );
7407 }
7408
7409 #[test]
7410 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7411 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7412 // byte-class arm, 4267d8b) and the single-quote arm are both
7413 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7414 // so the byte that appears first in the value's byte order
7415 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7416 // `'`; the `"` byte appears first, so the double-quote arm
7417 // fires, surfacing the more self-locating diagnostic on the
7418 // byte the author pasted earliest in the URL. Pins the natural-
7419 // order cascade so a future reorder of the per-byte arms
7420 // surfaces here — `'` is the most recent byte-class arm, so
7421 // the cascade-pin sweep extends to cover the immediately prior
7422 // `"` byte arm firing first when ordered ahead of `'` in the
7423 // value.
7424 let d = dep_with_fonte(DepSource::Git {
7425 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7426 tag: Some("v0.1.0".into()),
7427 rev: None,
7428 branch: None,
7429 });
7430 let err = d.validate().unwrap_err();
7431 let DepError::FonteRepoShape { reason, .. } = err else {
7432 panic!("expected FonteRepoShape, got other variant");
7433 };
7434 assert!(
7435 reason.contains("must not contain `\"`"),
7436 "reason must surface the double-quote arm (fires before single-quote when `\"` \
7437 byte appears first in value), got {reason:?}"
7438 );
7439 }
7440
7441 #[test]
7442 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7443 // The fail-before-pass-after pin for the canonical paste-from-
7444 // shell-history footgun on `:repo`. An author copies a `git
7445 // clone <url>!sudo make install` one-liner from a README's
7446 // quick-start snippet, intending the trailing `!sudo` as a
7447 // shell-history-expansion reference but the typed slot is itself
7448 // a byte-level string parser, not a shell context, so the byte
7449 // rides into the value verbatim. Until this arm landed the `!`
7450 // byte silently passed every prior `is_git_repo_url` arm (no
7451 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7452 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7453 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7454 // start with `-` or `:`); bash with the default `histexpand`
7455 // mode rewrites `!command` to the most recent history entry
7456 // beginning with `command`, the canonical RCE-class injection
7457 // vector when the byte rides into a shell argument.
7458 let d = dep_with_fonte(DepSource::Git {
7459 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7460 tag: Some("v0.1.0".into()),
7461 rev: None,
7462 branch: None,
7463 });
7464 let err = d.validate().unwrap_err();
7465 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7466 panic!("expected FonteRepoShape, got other variant");
7467 };
7468 assert_eq!(nome, "caixa-teia");
7469 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7470 assert!(
7471 reason.contains("must not contain `!`"),
7472 "reason must surface the shell-history-expansion arm, got {reason:?}"
7473 );
7474 assert!(
7475 reason.contains("history-expansion") || reason.contains("bang"),
7476 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7477 );
7478 }
7479
7480 #[test]
7481 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7482 // The symmetric `!!` repeat-prior-command pin: an author paste-
7483 // trims a `git clone <url>` retry idiom from shell history that
7484 // expands to the previous command via `!!`. Pinned separately
7485 // from the wrapped `!command` shape so a future diagnostic-
7486 // surface change that only checked the leading or paired-bang
7487 // position surfaces here — the per-byte arm fires anywhere `!`
7488 // appears in the value.
7489 let d = dep_with_fonte(DepSource::Git {
7490 repo: "github:pleme-io/caixa-teia!!".into(),
7491 tag: Some("v0.1.0".into()),
7492 rev: None,
7493 branch: None,
7494 });
7495 let err = d.validate().unwrap_err();
7496 let DepError::FonteRepoShape { reason, .. } = err else {
7497 panic!("expected FonteRepoShape, got other variant");
7498 };
7499 assert!(
7500 reason.contains("must not contain `!`"),
7501 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7502 got {reason:?}"
7503 );
7504 }
7505
7506 #[test]
7507 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7508 // Cascade pin: the fragment-`#` arm and the bang arm are both
7509 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7510 // so the byte that appears first in the value's byte order
7511 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7512 // both `#` and `!`; the `#` byte appears first, so the
7513 // fragment-`#` arm fires, surfacing the more self-locating
7514 // diagnostic on the byte the author pasted earliest in the URL.
7515 let d = dep_with_fonte(DepSource::Git {
7516 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7517 tag: Some("v0.1.0".into()),
7518 rev: None,
7519 branch: None,
7520 });
7521 let err = d.validate().unwrap_err();
7522 let DepError::FonteRepoShape { reason, .. } = err else {
7523 panic!("expected FonteRepoShape, got other variant");
7524 };
7525 assert!(
7526 reason.contains("must not contain `#`"),
7527 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7528 appears first in value), got {reason:?}"
7529 );
7530 }
7531
7532 #[test]
7533 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7534 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7535 // byte-class arm, e7a109f) and the bang arm are both per-byte
7536 // arms inside the same `for &b in s.as_bytes()` loop, so the
7537 // byte that appears first in the value's byte order wins. A
7538 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7539 // `'` byte appears first, so the single-quote arm fires,
7540 // surfacing the more self-locating diagnostic on the byte the
7541 // author pasted earliest in the URL. Pins the natural-order
7542 // cascade so a future reorder of the per-byte arms surfaces
7543 // here — `!` is the most recent byte-class arm, so the
7544 // cascade-pin sweep extends to cover the immediately prior `'`
7545 // byte arm firing first when ordered ahead of `!` in the value.
7546 let d = dep_with_fonte(DepSource::Git {
7547 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7548 tag: Some("v0.1.0".into()),
7549 rev: None,
7550 branch: None,
7551 });
7552 let err = d.validate().unwrap_err();
7553 let DepError::FonteRepoShape { reason, .. } = err else {
7554 panic!("expected FonteRepoShape, got other variant");
7555 };
7556 assert!(
7557 reason.contains("must not contain `'`"),
7558 "reason must surface the single-quote arm (fires before bang when `'` byte \
7559 appears first in value), got {reason:?}"
7560 );
7561 }
7562
7563 #[test]
7564 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7565 // The fail-before-pass-after pin for the canonical
7566 // list-separator-belongs-to-list-grammar footgun on `:repo`.
7567 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7568 // one-liner from a multi-repo bootstrap doc, intending the
7569 // comma to separate multiple repo entries but the typed
7570 // `:repo` slot names *one* repo (the list-separator belongs
7571 // to the `:deps` list grammar, not to the value). Until this
7572 // arm landed the `,` byte silently passed every prior
7573 // `is_git_repo_url` arm (no whitespace, no control chars, no
7574 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7575 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7576 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7577 // `:`); the byte rode into the lacre's per-dep content-
7578 // address and the resolver's `git clone <repo>` subprocess
7579 // invocation, where no host's repo registry resolved the
7580 // comma-bearing slug.
7581 let d = dep_with_fonte(DepSource::Git {
7582 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7583 tag: Some("v0.1.0".into()),
7584 rev: None,
7585 branch: None,
7586 });
7587 let err = d.validate().unwrap_err();
7588 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7589 panic!("expected FonteRepoShape, got other variant");
7590 };
7591 assert_eq!(nome, "caixa-teia");
7592 assert_eq!(
7593 repo,
7594 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7595 );
7596 assert!(
7597 reason.contains("must not contain `,`"),
7598 "reason must surface the list-separator-comma arm, got {reason:?}"
7599 );
7600 assert!(
7601 reason.contains("list-separator") || reason.contains("sub-delims"),
7602 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7603 got {reason:?}"
7604 );
7605 }
7606
7607 #[test]
7608 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7609 // The symmetric trailing-`,` paste-from-prose pin: an author
7610 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7611 // comma every README-prose list-of-projects sentence carries,
7612 // mistakenly retained when the slug is pasted mid-sentence)
7613 // expecting the substrate to coerce it to a kebab-case slug.
7614 // Pinned separately from the wrapped mid-token shape so a
7615 // future diagnostic-surface change that only checked the
7616 // leading or paired-comma position surfaces here — the
7617 // per-byte arm fires anywhere `,` appears in the value.
7618 let d = dep_with_fonte(DepSource::Git {
7619 repo: "github:pleme-io/caixa-feira,".into(),
7620 tag: Some("v0.1.0".into()),
7621 rev: None,
7622 branch: None,
7623 });
7624 let err = d.validate().unwrap_err();
7625 let DepError::FonteRepoShape { reason, .. } = err else {
7626 panic!("expected FonteRepoShape, got other variant");
7627 };
7628 assert!(
7629 reason.contains("must not contain `,`"),
7630 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7631 got {reason:?}"
7632 );
7633 }
7634
7635 #[test]
7636 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7637 // Cascade pin: the fragment-`#` arm and the comma arm are
7638 // both per-byte arms inside the same `for &b in s.as_bytes()`
7639 // loop, so the byte that appears first in the value's byte
7640 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7641 // carries both `#` and `,`; the `#` byte appears first, so
7642 // the fragment-`#` arm fires, surfacing the more self-
7643 // locating diagnostic on the byte the author pasted earliest
7644 // in the URL.
7645 let d = dep_with_fonte(DepSource::Git {
7646 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7647 tag: Some("v0.1.0".into()),
7648 rev: None,
7649 branch: None,
7650 });
7651 let err = d.validate().unwrap_err();
7652 let DepError::FonteRepoShape { reason, .. } = err else {
7653 panic!("expected FonteRepoShape, got other variant");
7654 };
7655 assert!(
7656 reason.contains("must not contain `#`"),
7657 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7658 appears first in value), got {reason:?}"
7659 );
7660 }
7661
7662 #[test]
7663 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7664 // Cascade pin: the bang-`!` arm (the immediate-predecessor
7665 // byte-class arm, 7d53c68) and the comma arm are both
7666 // per-byte arms inside the same `for &b in s.as_bytes()`
7667 // loop, so the byte that appears first in the value's byte
7668 // order wins. A `:repo "github:p/x!mid,tail"` carries both
7669 // `!` and `,`; the `!` byte appears first, so the bang arm
7670 // fires, surfacing the more self-locating diagnostic on the
7671 // byte the author pasted earliest in the URL. Pins the
7672 // natural-order cascade so a future reorder of the per-byte
7673 // arms surfaces here — `,` is the most recent byte-class
7674 // arm, so the cascade-pin sweep extends to cover the
7675 // immediately prior `!` byte arm firing first when ordered
7676 // ahead of `,` in the value.
7677 let d = dep_with_fonte(DepSource::Git {
7678 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7679 tag: Some("v0.1.0".into()),
7680 rev: None,
7681 branch: None,
7682 });
7683 let err = d.validate().unwrap_err();
7684 let DepError::FonteRepoShape { reason, .. } = err else {
7685 panic!("expected FonteRepoShape, got other variant");
7686 };
7687 assert!(
7688 reason.contains("must not contain `!`"),
7689 "reason must surface the bang arm (fires before comma when `!` byte \
7690 appears first in value), got {reason:?}"
7691 );
7692 }
7693
7694 #[test]
7695 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7696 // The fail-before-pass-after pin for the canonical
7697 // shell-env-var-assignment-belongs-to-shell-grammar footgun
7698 // on `:repo`. An author copies
7699 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7700 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7701 // git clone <url>`, etc. — the canonical
7702 // git-troubleshooting README idiom for a one-shot env-var
7703 // scoped to the `git clone` invocation) from a shell-prompt
7704 // one-liner, intending the `KEY=VALUE` prefix as a shell-
7705 // grammar env-var assignment but the typed `:repo` slot is
7706 // a value parser, not a shell context, so the bytes ride
7707 // into the value verbatim. Until this arm landed the `=`
7708 // byte silently passed every prior `is_git_repo_url` arm
7709 // (no whitespace, no control chars, no non-ASCII, no `#`,
7710 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7711 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7712 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7713 // the byte rode into the lacre's per-dep content-address
7714 // and the resolver's `git clone <repo>` subprocess
7715 // invocation, where the upstream host's git porcelain
7716 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7717 // path that no host's repo registry resolves.
7718 let d = dep_with_fonte(DepSource::Git {
7719 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7720 tag: Some("v0.1.0".into()),
7721 rev: None,
7722 branch: None,
7723 });
7724 let err = d.validate().unwrap_err();
7725 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7726 panic!("expected FonteRepoShape, got other variant");
7727 };
7728 assert_eq!(nome, "caixa-teia");
7729 assert_eq!(
7730 repo,
7731 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7732 );
7733 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7734 // appears before the ` ` byte at position 21, so the `=`
7735 // arm fires (not the whitespace arm) — both arms guard
7736 // the slot, but the per-byte for-loop scans left-to-right
7737 // and the first matching byte wins.
7738 assert!(
7739 reason.contains("must not contain `=`"),
7740 "reason must surface the equals-`=` arm on the env-var-assignment \
7741 paste shape, got {reason:?}"
7742 );
7743 assert!(
7744 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7745 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7746 );
7747 }
7748
7749 #[test]
7750 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7751 // The symmetric paste-from-gitconfig pin: an author copies
7752 // `url=https://github.com/p/x` from `git config --get-all
7753 // remote.origin.url` output, a `.gitconfig` `[remote
7754 // "origin"] url = https://…` ini-stanza paste, or a
7755 // `git config remote.origin.url <value>` doc snippet,
7756 // intending the `url=` prefix as the ini-key but the typed
7757 // `:repo` slot is a URL value parser, not a gitconfig
7758 // grammar. With no leading whitespace and no earlier-arm
7759 // bytes in the value, the `=` arm itself fires (rather
7760 // than cascading to the whitespace arm as in the env-var
7761 // paste shape). Pinned separately so a future diagnostic-
7762 // surface change that only checked the whitespace-leading
7763 // shape surfaces here — the per-byte arm fires anywhere
7764 // `=` appears in the value.
7765 let d = dep_with_fonte(DepSource::Git {
7766 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7767 tag: Some("v0.1.0".into()),
7768 rev: None,
7769 branch: None,
7770 });
7771 let err = d.validate().unwrap_err();
7772 let DepError::FonteRepoShape { reason, .. } = err else {
7773 panic!("expected FonteRepoShape, got other variant");
7774 };
7775 assert!(
7776 reason.contains("must not contain `=`"),
7777 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7778 paste shape, got {reason:?}"
7779 );
7780 assert!(
7781 reason.contains("key-value-separator") || reason.contains("sub-delims"),
7782 "reason must name the key-value-separator / RFC-3986-sub-delims \
7783 rationale, got {reason:?}"
7784 );
7785 }
7786
7787 #[test]
7788 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7789 // Cascade pin: the fragment-`#` arm and the `=` arm are
7790 // both per-byte arms inside the same `for &b in s.as_bytes()`
7791 // loop, so the byte that appears first in the value's byte
7792 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7793 // carries both `#` and `=`; the `#` byte appears first, so
7794 // the fragment-`#` arm fires, surfacing the more self-
7795 // locating diagnostic on the byte the author pasted earliest
7796 // in the URL.
7797 let d = dep_with_fonte(DepSource::Git {
7798 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7799 tag: Some("v0.1.0".into()),
7800 rev: None,
7801 branch: None,
7802 });
7803 let err = d.validate().unwrap_err();
7804 let DepError::FonteRepoShape { reason, .. } = err else {
7805 panic!("expected FonteRepoShape, got other variant");
7806 };
7807 assert!(
7808 reason.contains("must not contain `#`"),
7809 "reason must surface the fragment-`#` arm (fires before equals when \
7810 `#` byte appears first in value), got {reason:?}"
7811 );
7812 }
7813
7814 #[test]
7815 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7816 // Cascade pin: the comma-`,` arm (the immediate-predecessor
7817 // byte-class arm, 775b80e) and the `=` arm are both per-byte
7818 // arms inside the same `for &b in s.as_bytes()` loop, so
7819 // the byte that appears first in the value's byte order
7820 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7821 // and `=`; the `,` byte appears first, so the comma arm
7822 // fires, surfacing the more self-locating diagnostic on
7823 // the byte the author pasted earliest in the URL. Pins the
7824 // natural-order cascade so a future reorder of the per-byte
7825 // arms surfaces here — `=` is the most recent byte-class
7826 // arm, so the cascade-pin sweep extends to cover the
7827 // immediately prior `,` byte arm firing first when ordered
7828 // ahead of `=` in the value.
7829 let d = dep_with_fonte(DepSource::Git {
7830 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7831 tag: Some("v0.1.0".into()),
7832 rev: None,
7833 branch: None,
7834 });
7835 let err = d.validate().unwrap_err();
7836 let DepError::FonteRepoShape { reason, .. } = err else {
7837 panic!("expected FonteRepoShape, got other variant");
7838 };
7839 assert!(
7840 reason.contains("must not contain `,`"),
7841 "reason must surface the comma arm (fires before equals when `,` byte \
7842 appears first in value), got {reason:?}"
7843 );
7844 }
7845
7846 #[test]
7847 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7848 // The fail-before-pass-after pin for the canonical paste-from-
7849 // browser-address-bar percent-encoded-space footgun on `:repo`.
7850 // An author copies `https://github.com/p/x%20test` from a
7851 // browser address bar (or a percent-encoded README hyperlink,
7852 // or a `curl --data-urlencode` shell-pipeline output)
7853 // intending `%20` as the URL encoding of a literal space; the
7854 // typed `:repo` slot already rejects the literal space byte
7855 // (the whitespace arm at the top of `is_git_repo_url`), so an
7856 // author trying to express "I really meant a space" reaches
7857 // for percent-encoding. Until this arm landed the `%` byte
7858 // silently passed every prior `is_git_repo_url` arm and rode
7859 // verbatim into the lacre's per-dep content-address — but
7860 // libcurl re-percent-encodes `%` to `%25` on the wire (since
7861 // `%` is reserved as the escape-sequence lead-in), so the
7862 // wire request becomes `https://github.com/p/x%2520test`, a
7863 // path the lacre's content-address never names. The classic
7864 // render-determinism violation on the encoding-mechanism axis
7865 // itself.
7866 let d = dep_with_fonte(DepSource::Git {
7867 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7868 tag: Some("v0.1.0".into()),
7869 rev: None,
7870 branch: None,
7871 });
7872 let err = d.validate().unwrap_err();
7873 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7874 panic!("expected FonteRepoShape, got other variant");
7875 };
7876 assert_eq!(nome, "caixa-teia");
7877 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7878 assert!(
7879 reason.contains("must not contain `%`"),
7880 "reason must surface the percent-`%` arm on the percent-encoded-space \
7881 paste shape, got {reason:?}"
7882 );
7883 assert!(
7884 reason.contains("percent-encoding") || reason.contains("%25"),
7885 "reason must name the percent-encoding / `%25` re-encoding rationale, \
7886 got {reason:?}"
7887 );
7888 }
7889
7890 #[test]
7891 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
7892 // The symmetric over-encoded-path-separator pin: an author
7893 // writes `:repo "https://github.com/p%2Fx"` intending the
7894 // `%2F` as the URL encoding of `/` (the canonical
7895 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
7896 // footgun every API client library and OAuth redirect-URI
7897 // documentation surfaces — the `/` is the URL-path-separator
7898 // and some templates percent-encode it to escape interpretation
7899 // as a path separator). The GitHub Smart-HTTP transport
7900 // resolves the URL's path-segment grammar before the
7901 // percent-decoding pass, so the value identifies a different
7902 // resource on the wire than the literal-`/` form the lacre's
7903 // content-address must agree with — two authors whose `:repo`
7904 // values differ only in their `/` vs `%2F` presence lock to
7905 // two distinct BLAKE3 closures for the byte-identical upstream
7906 // `git clone`. Pinned separately so a future diagnostic
7907 // surface that only catches the `%20` shape surfaces here too.
7908 let d = dep_with_fonte(DepSource::Git {
7909 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
7910 tag: Some("v0.1.0".into()),
7911 rev: None,
7912 branch: None,
7913 });
7914 let err = d.validate().unwrap_err();
7915 let DepError::FonteRepoShape { reason, .. } = err else {
7916 panic!("expected FonteRepoShape, got other variant");
7917 };
7918 assert!(
7919 reason.contains("must not contain `%`"),
7920 "reason must surface the percent-`%` arm on the over-encoded-path \
7921 shape, got {reason:?}"
7922 );
7923 assert!(
7924 reason.contains("render-determinism") || reason.contains("BLAKE3"),
7925 "reason must name the render-determinism / BLAKE3-closure rationale, \
7926 got {reason:?}"
7927 );
7928 }
7929
7930 #[test]
7931 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
7932 // Cascade pin: the fragment-`#` arm and the `%` arm are both
7933 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7934 // so the byte that appears first in the value's byte order
7935 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
7936 // both `#` and `%`; the `#` byte appears first, so the
7937 // fragment-`#` arm fires, surfacing the more self-locating
7938 // diagnostic on the byte the author pasted earliest in the URL.
7939 let d = dep_with_fonte(DepSource::Git {
7940 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
7941 tag: Some("v0.1.0".into()),
7942 rev: None,
7943 branch: None,
7944 });
7945 let err = d.validate().unwrap_err();
7946 let DepError::FonteRepoShape { reason, .. } = err else {
7947 panic!("expected FonteRepoShape, got other variant");
7948 };
7949 assert!(
7950 reason.contains("must not contain `#`"),
7951 "reason must surface the fragment-`#` arm (fires before percent when \
7952 `#` byte appears first in value), got {reason:?}"
7953 );
7954 }
7955
7956 #[test]
7957 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
7958 // Cascade pin: the equals-`=` arm (the immediate-predecessor
7959 // byte-class arm, acf99af) and the `%` arm are both per-byte
7960 // arms inside the same `for &b in s.as_bytes()` loop, so the
7961 // byte that appears first in the value's byte order wins.
7962 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
7963 // the `=` byte appears first, so the equals arm fires,
7964 // surfacing the more self-locating diagnostic on the byte the
7965 // author pasted earliest in the URL. Pins the natural-order
7966 // cascade so a future reorder of the per-byte arms surfaces
7967 // here — `%` is the most recent byte-class arm, so the
7968 // cascade-pin sweep extends to cover the immediately prior
7969 // `=` byte arm firing first when ordered ahead of `%` in the
7970 // value.
7971 let d = dep_with_fonte(DepSource::Git {
7972 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
7973 tag: Some("v0.1.0".into()),
7974 rev: None,
7975 branch: None,
7976 });
7977 let err = d.validate().unwrap_err();
7978 let DepError::FonteRepoShape { reason, .. } = err else {
7979 panic!("expected FonteRepoShape, got other variant");
7980 };
7981 assert!(
7982 reason.contains("must not contain `=`"),
7983 "reason must surface the equals arm (fires before percent when `=` byte \
7984 appears first in value), got {reason:?}"
7985 );
7986 }
7987
7988 #[test]
7989 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
7990 // The fail-before-pass-after pin for the canonical paste-from-
7991 // shell-history footgun on `:repo`. An author copies a
7992 // `git clone <url>` line from their terminal followed by a
7993 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
7994 // history shorthand (the `^old^new^` form re-runs the prior
7995 // history entry with the first `old` substituted by `new`,
7996 // bash's default behavior on interactive sessions with
7997 // `set -o histexpand`), forgetting to trim the trailing
7998 // `^...^...` shell-history fragment from the URL value. The
7999 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8000 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8001 // classes), the WHATWG URL spec's 'fragment percent-encode
8002 // set' maps `^` → `%5E` on the wire, so the byte rides
8003 // verbatim into the lacre's per-dep content-address but
8004 // libcurl re-encodes it to `%5E` at `git clone` time — the
8005 // classic render-determinism violation on the same axis the
8006 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8007 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8008 // `#` arms close.
8009 let d = dep_with_fonte(DepSource::Git {
8010 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8011 tag: Some("v0.1.0".into()),
8012 rev: None,
8013 branch: None,
8014 });
8015 let err = d.validate().unwrap_err();
8016 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8017 panic!("expected FonteRepoShape, got other variant");
8018 };
8019 assert_eq!(nome, "caixa-teia");
8020 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8021 assert!(
8022 reason.contains("must not contain `^`"),
8023 "reason must surface the caret-`^` arm on the paste-from-shell-history \
8024 shape, got {reason:?}"
8025 );
8026 assert!(
8027 reason.contains("history-substitution") || reason.contains("%5E"),
8028 "reason must name the shell-history-substitution / `%5E` wire-encoding \
8029 rationale, got {reason:?}"
8030 );
8031 }
8032
8033 #[test]
8034 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8035 // The symmetric paste-from-doc-grep-pipeline footgun: an
8036 // author writes `:repo "github:p/^archived"` after copying a
8037 // `grep '^archived'` regex-anchor / negation idiom from a
8038 // doc / README quick-listing snippet, expecting the substrate
8039 // to coerce it to a literal repo name. The byte rides
8040 // verbatim into the lacre's per-dep content-address and
8041 // diverges from the byte-identical literal `archived` form
8042 // every other author authored — the canonical render-
8043 // determinism violation pin on the second footgun shape the
8044 // caret-`^` arm closes.
8045 let d = dep_with_fonte(DepSource::Git {
8046 repo: "github:pleme-io/^archived".into(),
8047 tag: Some("v0.1.0".into()),
8048 rev: None,
8049 branch: None,
8050 });
8051 let err = d.validate().unwrap_err();
8052 let DepError::FonteRepoShape { reason, .. } = err else {
8053 panic!("expected FonteRepoShape, got other variant");
8054 };
8055 assert!(
8056 reason.contains("must not contain `^`"),
8057 "reason must surface the caret-`^` arm on the regex-anchor shape, \
8058 got {reason:?}"
8059 );
8060 assert!(
8061 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8062 "reason must name the render-determinism / BLAKE3-closure rationale, \
8063 got {reason:?}"
8064 );
8065 }
8066
8067 #[test]
8068 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8069 // Cascade pin: the `%` arm (the immediate-predecessor byte-
8070 // class arm, a323db8) and the `^` arm are both per-byte arms
8071 // inside the same `for &b in s.as_bytes()` loop, so the byte
8072 // that appears first in the value's byte order wins. A
8073 // `:repo "https://github.com/p/x%20mid^tail"` carries both
8074 // `%` and `^`; the `%` byte appears first, so the percent
8075 // arm fires, surfacing the more self-locating diagnostic on
8076 // the byte the author pasted earliest in the URL. Pins the
8077 // natural-order cascade so a future reorder of the per-byte
8078 // arms surfaces here — `^` is the most recent byte-class arm,
8079 // so the cascade-pin sweep extends to cover the immediately
8080 // prior `%` byte arm firing first when ordered ahead of `^`
8081 // in the value.
8082 let d = dep_with_fonte(DepSource::Git {
8083 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8084 tag: Some("v0.1.0".into()),
8085 rev: None,
8086 branch: None,
8087 });
8088 let err = d.validate().unwrap_err();
8089 let DepError::FonteRepoShape { reason, .. } = err else {
8090 panic!("expected FonteRepoShape, got other variant");
8091 };
8092 assert!(
8093 reason.contains("must not contain `%`"),
8094 "reason must surface the percent arm (fires before caret when `%` byte \
8095 appears first in value), got {reason:?}"
8096 );
8097 }
8098
8099 #[test]
8100 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8101 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8102 // (no `github:` prefix, no scheme). Every documented form
8103 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8104 // `file://`, or `git@host:path`); a bare `org/repo` is
8105 // ambiguous (`git clone` reads as a relative filesystem path
8106 // rather than the GitHub-shorthand expansion the author
8107 // probably intended) and the gate rejects the shape upstream.
8108 let d = dep_with_fonte(DepSource::Git {
8109 repo: "pleme-io/caixa-teia".into(),
8110 tag: Some("v0.1.0".into()),
8111 rev: None,
8112 branch: None,
8113 });
8114 let err = d.validate().unwrap_err();
8115 let DepError::FonteRepoShape { reason, .. } = err else {
8116 panic!("expected FonteRepoShape, got other variant");
8117 };
8118 assert!(
8119 reason.contains("must contain a `:`"),
8120 "reason must surface the missing-`:` arm, got {reason:?}"
8121 );
8122 assert!(
8123 reason.contains("github:"),
8124 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8125 );
8126 }
8127
8128 #[test]
8129 fn validate_rejects_git_fonte_with_repo_leading_colon() {
8130 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8131 // scheme that no git porcelain entry-point accepts. Pinned
8132 // separately from the missing-`:` arm because a value with a
8133 // leading `:` does technically contain a `:` separator; the
8134 // shape gate rejects on a dedicated arm so the diagnostic
8135 // names the specific footgun.
8136 let d = dep_with_fonte(DepSource::Git {
8137 repo: ":pleme-io/caixa-teia".into(),
8138 tag: Some("v0.1.0".into()),
8139 rev: None,
8140 branch: None,
8141 });
8142 let err = d.validate().unwrap_err();
8143 let DepError::FonteRepoShape { reason, .. } = err else {
8144 panic!("expected FonteRepoShape, got other variant");
8145 };
8146 assert!(
8147 reason.contains("must not start with `:`"),
8148 "reason must surface the leading-`:` arm, got {reason:?}"
8149 );
8150 }
8151
8152 #[test]
8153 fn validate_rejects_git_fonte_with_repo_too_long() {
8154 // The cap arm — a `:repo` value longer than
8155 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8156 // structurally untenable on every realistic landing site (the
8157 // resolver's `git clone` invocation, the future M4 CR
8158 // materializer's per-dep `repo:` axis); a value of that length
8159 // is almost certainly a paste-from-binary slug.
8160 let too_long = format!(
8161 "github:pleme-io/{}",
8162 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8163 );
8164 let d = dep_with_fonte(DepSource::Git {
8165 repo: too_long.clone(),
8166 tag: Some("v0.1.0".into()),
8167 rev: None,
8168 branch: None,
8169 });
8170 let err = d.validate().unwrap_err();
8171 let DepError::FonteRepoShape { reason, .. } = err else {
8172 panic!("expected FonteRepoShape, got other variant");
8173 };
8174 assert!(
8175 reason.contains("2048"),
8176 "reason must name the cap, got {reason:?}"
8177 );
8178 }
8179
8180 #[test]
8181 fn validate_accepts_canonical_git_fonte_repo_shapes() {
8182 // The positive-control sweep: every documented author shape on
8183 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8184 // must pass the value-shape gate. Pinned so a future tightening
8185 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8186 // here as a structural decision. Each form is exercised with the
8187 // same canonical `:tag` pin so only the `:repo` axis varies.
8188 for repo in [
8189 // The pleme-io registry-shorthand convention — `github:org/repo`.
8190 "github:pleme-io/caixa-teia",
8191 // Other host-aliased shorthands (the resolver's pluggable
8192 // host-prefix table).
8193 "gitlab:pleme-io/caixa-teia",
8194 "codeberg:pleme-io/caixa-teia",
8195 "sourcehut:~pleme-io/caixa-teia",
8196 // Full HTTPS URL with and without `.git` suffix.
8197 "https://github.com/pleme-io/caixa-teia",
8198 "https://github.com/pleme-io/caixa-teia.git",
8199 // HTTP (rare; dev / mirror).
8200 "http://example.com/pleme-io/caixa-teia.git",
8201 // SSH URL.
8202 "ssh://git@github.com/pleme-io/caixa-teia.git",
8203 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8204 // Scp-style SSH — the canonical `git@host:path` short form.
8205 "git@github.com:pleme-io/caixa-teia.git",
8206 "git@git.example.com:team/private.git",
8207 // Anonymous git protocol.
8208 "git://git.example.com/pleme-io/caixa-teia.git",
8209 // Local file URL (dev path).
8210 "file:///tmp/caixa-teia",
8211 ] {
8212 let d = dep_with_fonte(DepSource::Git {
8213 repo: repo.into(),
8214 tag: Some("v0.1.0".into()),
8215 rev: None,
8216 branch: None,
8217 });
8218 d.validate()
8219 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8220 }
8221 }
8222
8223 #[test]
8224 fn fonte_repo_empty_takes_precedence_over_shape() {
8225 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8226 // diagnostic; doesn't try to parse the URL shape) fires before
8227 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8228 // keeps its narrower error message. Mirrors
8229 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8230 // on the ordering layer.
8231 let d = dep_with_fonte(DepSource::Git {
8232 repo: String::new(),
8233 tag: Some("v0.1.0".into()),
8234 rev: None,
8235 branch: None,
8236 });
8237 let err = d.validate().unwrap_err();
8238 assert!(
8239 matches!(err, DepError::FonteRepoEmpty { .. }),
8240 "got {err:?}"
8241 );
8242 }
8243
8244 #[test]
8245 fn fonte_repo_shape_fires_before_pin_missing() {
8246 // Order pin: a malformed `:repo` value on a dep with no pin set
8247 // surfaces the `:repo` shape diagnostic (the more self-locating
8248 // axis — the `:repo` is the load-bearing identity of the source;
8249 // a missing pin is downstream from "do we even know the repo")
8250 // rather than collapsing onto the pin-missing diagnostic. The
8251 // shape gate runs inline before the pin enumeration in
8252 // `DepSource::validate`.
8253 let d = dep_with_fonte(DepSource::Git {
8254 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8255 tag: None,
8256 rev: None,
8257 branch: None,
8258 });
8259 let err = d.validate().unwrap_err();
8260 assert!(
8261 matches!(err, DepError::FonteRepoShape { .. }),
8262 "got {err:?}"
8263 );
8264 }
8265
8266 #[test]
8267 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8268 // The diagnostic-shape pin: the error names the offending
8269 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8270 // so the author can grep their caixa.lisp without re-running
8271 // the build. Mirrors the diagnostic-shape sweep on every prior
8272 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8273 let d = dep_with_fonte(DepSource::Git {
8274 repo: "pleme-io/caixa-teia".into(),
8275 tag: Some("v0.1.0".into()),
8276 rev: None,
8277 branch: None,
8278 });
8279 let err = d.validate().unwrap_err();
8280 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8281 panic!("expected FonteRepoShape, got other variant");
8282 };
8283 assert_eq!(nome, "caixa-teia");
8284 assert_eq!(repo, "pleme-io/caixa-teia");
8285 assert!(
8286 !reason.is_empty(),
8287 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8288 );
8289 }
8290
8291 #[test]
8292 fn validate_rejects_git_fonte_with_no_pin() {
8293 // The fail-before-pass-after pin for the canonical
8294 // `(:tipo git :repo "github:pleme-io/x")` shape with no
8295 // :tag/:rev/:branch — until this gate landed the resolver's
8296 // ResolveError::MissingPin surfaced at fetch time, far from the
8297 // source caixa.lisp. The new gate moves the check to validate
8298 // time and names the offending dep.
8299 let d = dep_with_fonte(DepSource::Git {
8300 repo: "github:pleme-io/caixa-teia".into(),
8301 tag: None,
8302 rev: None,
8303 branch: None,
8304 });
8305 let err = d.validate().unwrap_err();
8306 assert!(
8307 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8308 "got {err:?}"
8309 );
8310 }
8311
8312 #[test]
8313 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8314 // The canonical "pin drift" footgun: an author writes
8315 // `:tag "v1"` and later adds `:branch "main"` without removing
8316 // the :tag, and the resolver silently picks :tag (precedence
8317 // :rev > :tag > :branch). The :branch was dropped with no
8318 // diagnostic. The gate now rejects multi-pin shapes so the
8319 // author makes the precedence explicit at the source.
8320 let d = dep_with_fonte(DepSource::Git {
8321 repo: "github:pleme-io/caixa-teia".into(),
8322 tag: Some("v0.1.0".into()),
8323 rev: None,
8324 branch: Some("main".into()),
8325 });
8326 let err = d.validate().unwrap_err();
8327 let DepError::FontePinAmbiguous { nome, pins } = err else {
8328 panic!("expected FontePinAmbiguous");
8329 };
8330 assert_eq!(nome, "caixa-teia");
8331 assert!(pins.contains(":tag"));
8332 assert!(pins.contains(":branch"));
8333 assert!(!pins.contains(":rev"));
8334 }
8335
8336 #[test]
8337 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8338 // Sibling arm of the pin-drift footgun: :tag + :rev set
8339 // simultaneously. Pinned separately so a future relaxation
8340 // that only catches the (:tag, :branch) pair surfaces here.
8341 let d = dep_with_fonte(DepSource::Git {
8342 repo: "github:pleme-io/caixa-teia".into(),
8343 tag: Some("v0.1.0".into()),
8344 rev: Some("c0ffee".into()),
8345 branch: None,
8346 });
8347 let err = d.validate().unwrap_err();
8348 let DepError::FontePinAmbiguous { nome, pins } = err else {
8349 panic!("expected FontePinAmbiguous");
8350 };
8351 assert_eq!(nome, "caixa-teia");
8352 assert!(pins.contains(":tag"));
8353 assert!(pins.contains(":rev"));
8354 }
8355
8356 #[test]
8357 fn validate_rejects_git_fonte_with_all_three_pins() {
8358 // The maximal ambiguity case — every pin axis set. Pinned so a
8359 // future relaxation that only catches pairs surfaces here. The
8360 // diagnostic must enumerate every offending axis so the author
8361 // sees the full set, not just the first match.
8362 let d = dep_with_fonte(DepSource::Git {
8363 repo: "github:pleme-io/caixa-teia".into(),
8364 tag: Some("v0.1.0".into()),
8365 rev: Some("c0ffee".into()),
8366 branch: Some("main".into()),
8367 });
8368 let err = d.validate().unwrap_err();
8369 let DepError::FontePinAmbiguous { nome, pins } = err else {
8370 panic!("expected FontePinAmbiguous");
8371 };
8372 assert_eq!(nome, "caixa-teia");
8373 assert!(pins.contains(":tag"));
8374 assert!(pins.contains(":rev"));
8375 assert!(pins.contains(":branch"));
8376 }
8377
8378 #[test]
8379 fn validate_rejects_git_fonte_with_empty_tag_pin() {
8380 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8381 // inner string is empty. Distinct from FontePinMissing (where
8382 // every axis is None) — pinned separately so a future
8383 // tightening collapsing them surfaces here as a structural
8384 // decision.
8385 let d = dep_with_fonte(DepSource::Git {
8386 repo: "github:pleme-io/caixa-teia".into(),
8387 tag: Some(String::new()),
8388 rev: None,
8389 branch: None,
8390 });
8391 let err = d.validate().unwrap_err();
8392 let DepError::FontePinEmpty { nome, pin } = err else {
8393 panic!("expected FontePinEmpty");
8394 };
8395 assert_eq!(nome, "caixa-teia");
8396 assert_eq!(pin, ":tag");
8397 }
8398
8399 #[test]
8400 fn validate_rejects_git_fonte_with_empty_rev_pin() {
8401 // Sibling arm — the empty-pin diagnostic names which axis
8402 // carries the empty value, so the author's grep target is
8403 // unambiguous.
8404 let d = dep_with_fonte(DepSource::Git {
8405 repo: "github:pleme-io/caixa-teia".into(),
8406 tag: None,
8407 rev: Some(String::new()),
8408 branch: None,
8409 });
8410 let err = d.validate().unwrap_err();
8411 let DepError::FontePinEmpty { nome, pin } = err else {
8412 panic!("expected FontePinEmpty");
8413 };
8414 assert_eq!(nome, "caixa-teia");
8415 assert_eq!(pin, ":rev");
8416 }
8417
8418 #[test]
8419 fn validate_rejects_path_fonte_with_empty_caminho() {
8420 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8421 // until this gate landed the resolver's
8422 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8423 // fetch time — not actionable. The new gate moves the check to
8424 // validate time and names the offending dep.
8425 let d = dep_with_fonte(DepSource::Path {
8426 caminho: String::new(),
8427 });
8428 let err = d.validate().unwrap_err();
8429 assert!(
8430 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8431 "got {err:?}"
8432 );
8433 }
8434
8435 #[test]
8436 fn validate_rejects_path_fonte_with_absolute_caminho() {
8437 // The fail-before-pass-after pin for the absolute-`:caminho`
8438 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8439 // Until this gate landed an absolute `:caminho` silently
8440 // passed validate; the lacre pipeline embedded the
8441 // host-specific filesystem path verbatim in its
8442 // content-address (`conteudo: format!("path:{caminho}")`,
8443 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8444 // differed per machine — the build succeeded but two CI
8445 // runners with different `${HOME}` layouts emitted two
8446 // distinct lacres for the byte-identical caixa, silently
8447 // breaking the THEORY.md §V.2 render-determinism contract
8448 // far from the source caixa.lisp. The new gate moves the
8449 // check to validate time and names the offending dep +
8450 // caminho verbatim.
8451 let d = dep_with_fonte(DepSource::Path {
8452 caminho: "/home/me/work/caixa-teia".into(),
8453 });
8454 let err = d.validate().unwrap_err();
8455 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8456 panic!("expected FonteCaminhoAbsolute, got other variant");
8457 };
8458 assert_eq!(nome, "caixa-teia");
8459 assert_eq!(caminho, "/home/me/work/caixa-teia");
8460 }
8461
8462 #[test]
8463 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8464 // The canonical sibling-workspace dep form
8465 // (`:caminho "../caixa-teia"`) remains accepted. The
8466 // absolute-path gate above is specifically narrower than the
8467 // shared [`crate::render::is_sandboxed_relative_path`]
8468 // predicate (which additionally forbids `..` traversal): a
8469 // local-path dep's canonical author surface is the in-tree
8470 // sibling-workspace path, so a full sandboxed-relative-path
8471 // lift would structurally reject every legitimate path-fonte
8472 // dep. Pinned so a future tightening to the full predicate
8473 // surfaces here as a structural decision, not a silent break.
8474 let d = dep_with_fonte(DepSource::Path {
8475 caminho: "../caixa-teia".into(),
8476 });
8477 d.validate().unwrap();
8478 }
8479
8480 #[test]
8481 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8482 // A multi-segment relative `:caminho`
8483 // (`"vendor/forks/caixa-teia"`) remains accepted — the
8484 // absolute-path gate brackets the host-layout-leaking shape
8485 // at the leading-`/` boundary only; every relative shape past
8486 // the empty arm continues to pass. Pinned alongside the
8487 // `..`-traversal positive control so a future tightening
8488 // surfaces the full set of legitimate relative forms here
8489 // rather than at a downstream consumer.
8490 let d = dep_with_fonte(DepSource::Path {
8491 caminho: "vendor/forks/caixa-teia".into(),
8492 });
8493 d.validate().unwrap();
8494 }
8495
8496 #[test]
8497 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8498 // The fail-before-pass-after pin for the tilde-expansion
8499 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8500 // Until this gate landed the b94fd83 absolute arm let `~/foo`
8501 // through (`Path::is_absolute` returns false on a leading `~`
8502 // — the tilde is a shell-expansion convention, not a POSIX
8503 // path component), so the lacre embedded the value verbatim
8504 // and the resolver folded it through `Path::join` without
8505 // expansion, looking for a literal `./~/work/caixa-teia`
8506 // subdirectory and failing at resolve time with a
8507 // `No such file or directory` error far from the source
8508 // caixa.lisp. The new gate moves the check to validate time
8509 // and names the offending dep + caminho verbatim.
8510 let d = dep_with_fonte(DepSource::Path {
8511 caminho: "~/work/caixa-teia".into(),
8512 });
8513 let err = d.validate().unwrap_err();
8514 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8515 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8516 };
8517 assert_eq!(nome, "caixa-teia");
8518 assert_eq!(caminho, "~/work/caixa-teia");
8519 }
8520
8521 #[test]
8522 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8523 // The bare `~` form (canonical "I meant `$HOME` and forgot
8524 // the rest"): both the leading-tilde arm catches it and the
8525 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8526 // sweeps through the same arm. Pinned both to ensure the
8527 // gate doesn't narrow to `~/` only.
8528 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8529 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8530 let err = d.validate().unwrap_err();
8531 assert!(
8532 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8533 "{s:?} → {err:?}",
8534 );
8535 }
8536 }
8537
8538 #[test]
8539 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8540 // The leading-`~` is the canonical shell-expansion footgun —
8541 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8542 // backup-file-suffix idiom) is a legitimate POSIX path byte
8543 // with no shell-expansion semantic at the leading position.
8544 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8545 // sweep that would break every legitimate-shape backup-file
8546 // path.
8547 let d = dep_with_fonte(DepSource::Path {
8548 caminho: "../foo~bar/caixa-teia".into(),
8549 });
8550 d.validate().unwrap();
8551 }
8552
8553 #[test]
8554 fn fonte_caminho_empty_fires_before_tilde_expansion() {
8555 // Cascade pin: the empty arm structurally precedes the
8556 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8557 // pin establishes the precedence at the diagnostic-shape
8558 // level should a future codec round-trip ever produce a
8559 // probe-as-both value. Mirrors the peer
8560 // `fonte_repo_empty_fires_before_pin_missing` cascade
8561 // discipline.
8562 let d = dep_with_fonte(DepSource::Path {
8563 caminho: String::new(),
8564 });
8565 let err = d.validate().unwrap_err();
8566 assert!(
8567 matches!(err, DepError::FonteCaminhoEmpty { .. }),
8568 "got {err:?}",
8569 );
8570 }
8571
8572 #[test]
8573 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8574 // Diagnostic-shape pin (peer with
8575 // `validate_rejects_path_fonte_with_absolute_caminho`'s
8576 // payload assertion): the error's Display surfaces both the
8577 // offending `:nome` and the offending `:caminho` verbatim
8578 // so a `feira lint` run can render the diagnostic without
8579 // re-parsing.
8580 let d = dep_with_fonte(DepSource::Path {
8581 caminho: "~alice/dev/caixa-teia".into(),
8582 });
8583 let rendered = d.validate().unwrap_err().to_string();
8584 assert!(
8585 rendered.contains("caixa-teia"),
8586 "diagnostic must name the offending dep: {rendered}",
8587 );
8588 assert!(
8589 rendered.contains("~alice/dev/caixa-teia"),
8590 "diagnostic must quote the offending caminho: {rendered}",
8591 );
8592 assert!(
8593 rendered.contains('~'),
8594 "diagnostic must reference the tilde footgun: {rendered}",
8595 );
8596 }
8597
8598 #[test]
8599 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8600 // The fail-before-pass-after pin for the shell-variable-
8601 // expansion `:caminho` shape: `(:tipo path :caminho
8602 // "$HOME/work/caixa-teia")`. Until this gate landed the
8603 // b94fd83 absolute arm + the a5c248e tilde arm both let
8604 // `$HOME/foo` through (`Path::is_absolute` returns false on
8605 // a leading `$` — the `$` is a shell convention, not a POSIX
8606 // path component; `starts_with('~')` returns false too), so
8607 // the lacre embedded the value verbatim and the resolver
8608 // folded it through `Path::join` without `$`-expansion,
8609 // looking for a literal `./$HOME/work/caixa-teia`
8610 // subdirectory and failing at resolve time with a
8611 // `No such file or directory` error far from the source
8612 // caixa.lisp. The new gate moves the check to validate time
8613 // and names the offending dep + caminho verbatim.
8614 let d = dep_with_fonte(DepSource::Path {
8615 caminho: "$HOME/work/caixa-teia".into(),
8616 });
8617 let err = d.validate().unwrap_err();
8618 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8619 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8620 };
8621 assert_eq!(nome, "caixa-teia");
8622 assert_eq!(caminho, "$HOME/work/caixa-teia");
8623 }
8624
8625 #[test]
8626 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8627 // Sweep over every leading-`$` shape: the `${VAR}`-braced
8628 // form (canonical "paste-from-CI-manifest" footgun every
8629 // GitHub Actions / GitLab CI / Drone manifest carries on
8630 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8631 // canonical "I'm referencing a per-user config dir"),
8632 // and the bare `$` (canonical "I meant `$HOME` and forgot
8633 // the rest"). All shapes route through the same gate's
8634 // byte check. Pinned so the gate doesn't narrow to a
8635 // single shape (e.g. `$HOME/` only).
8636 for s in [
8637 "${HOME}/work/caixa-teia",
8638 "${WORKSPACE}/caixa-teia",
8639 "$XDG_CONFIG_HOME/caixa",
8640 "$",
8641 ] {
8642 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8643 let err = d.validate().unwrap_err();
8644 assert!(
8645 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8646 "{s:?} → {err:?}",
8647 );
8648 }
8649 }
8650
8651 #[test]
8652 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8653 // The `$` byte is the canonical shell-variable-expansion /
8654 // command-substitution / arithmetic-expansion sentinel and
8655 // is rejected at *every* position on the `:caminho` axis: the
8656 // leading arm surfaces `FonteCaminhoVarExpansion`, the
8657 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8658 // (6620f39). Pinned so a future arm doesn't narrow the gate
8659 // back to the leading position and re-open the paste-from-
8660 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8661 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8662 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8663 // the lacre content-address (`path:{caminho}`,
8664 // caixa-resolver/src/resolve.rs:189).
8665 let d = dep_with_fonte(DepSource::Path {
8666 caminho: "../foo$bar/caixa-teia".into(),
8667 });
8668 let err = d.validate().unwrap_err();
8669 assert!(
8670 matches!(
8671 err,
8672 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8673 ),
8674 "got {err:?}",
8675 );
8676 }
8677
8678 #[test]
8679 fn fonte_caminho_tilde_fires_before_var_expansion() {
8680 // Cascade pin: the tilde arm structurally precedes the var
8681 // arm (the bytes `~` and `$` don't overlap at the leading
8682 // position), but the pin establishes the precedence at the
8683 // diagnostic-shape level should a future codec round-trip
8684 // ever produce a probe-as-both value. Mirrors the peer
8685 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8686 // discipline on the immediate-predecessor arm.
8687 let d = dep_with_fonte(DepSource::Path {
8688 caminho: "~/work/caixa-teia".into(),
8689 });
8690 let err = d.validate().unwrap_err();
8691 assert!(
8692 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8693 "got {err:?}",
8694 );
8695 }
8696
8697 #[test]
8698 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8699 // Diagnostic-shape pin (peer with
8700 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8701 // payload assertion on the immediate-predecessor arm): the
8702 // error's Display surfaces both the offending `:nome` and
8703 // the offending `:caminho` verbatim plus the `$` footgun
8704 // character itself so a `feira lint` run can render the
8705 // diagnostic without re-parsing.
8706 let d = dep_with_fonte(DepSource::Path {
8707 caminho: "${WORKSPACE}/caixa-teia".into(),
8708 });
8709 let rendered = d.validate().unwrap_err().to_string();
8710 assert!(
8711 rendered.contains("caixa-teia"),
8712 "diagnostic must name the offending dep: {rendered}",
8713 );
8714 assert!(
8715 rendered.contains("${WORKSPACE}/caixa-teia"),
8716 "diagnostic must quote the offending caminho: {rendered}",
8717 );
8718 assert!(
8719 rendered.contains('$'),
8720 "diagnostic must reference the dollar footgun: {rendered}",
8721 );
8722 }
8723
8724 #[test]
8725 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8726 // The fail-before-pass-after pin for the load-bearing NUL byte:
8727 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8728 // routes the path through `CString::new` which fails with
8729 // `NulError`); until this gate landed a `:caminho
8730 // "../caixa\0teia"` silently passed validate, the lacre
8731 // pipeline embedded the value verbatim, and the failure
8732 // surfaced at the resolver's `Path::join` → `CString::new`
8733 // boundary with a non-self-locating `NulError` far from the
8734 // source caixa.lisp. The new gate moves the check to validate
8735 // time and names the offending dep + caminho + offending byte
8736 // verbatim.
8737 let d = dep_with_fonte(DepSource::Path {
8738 caminho: "../caixa\0teia".into(),
8739 });
8740 let err = d.validate().unwrap_err();
8741 let DepError::FonteCaminhoControlChar {
8742 nome,
8743 caminho,
8744 byte,
8745 } = err
8746 else {
8747 panic!("expected FonteCaminhoControlChar, got {err:?}");
8748 };
8749 assert_eq!(nome, "caixa-teia");
8750 assert_eq!(caminho, "../caixa\0teia");
8751 assert_eq!(byte, 0x00);
8752 }
8753
8754 #[test]
8755 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8756 // The canonical paste-from-multiline-doc footgun on `:caminho`
8757 // — author copies `"../caixa-teia\n"` (trailing newline) out
8758 // of a multi-line code-fence or, worse, a `:caminho
8759 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8760 // injection sibling on the path axis the `is_git_repo_url`
8761 // control-char arm already closes on `:repo`). Pinned
8762 // separately from the NUL arm so a future relaxation that
8763 // catches one but not the other surfaces here.
8764 let d = dep_with_fonte(DepSource::Path {
8765 caminho: "../caixa-teia\n".into(),
8766 });
8767 let err = d.validate().unwrap_err();
8768 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8769 panic!("expected FonteCaminhoControlChar, got {err:?}");
8770 };
8771 assert_eq!(byte, 0x0A);
8772 }
8773
8774 #[test]
8775 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8776 // The CRLF sibling of the LF arm — Windows-line-ending
8777 // paste-from-multiline-doc on a `\r\n`-terminated buffer
8778 // leaves a stray `\r` mid-string after the LF strip. Pinned
8779 // separately from the LF arm so a future relaxation that
8780 // only catches LF surfaces here.
8781 let d = dep_with_fonte(DepSource::Path {
8782 caminho: "../caixa-teia\r".into(),
8783 });
8784 let err = d.validate().unwrap_err();
8785 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8786 panic!("expected FonteCaminhoControlChar, got {err:?}");
8787 };
8788 assert_eq!(byte, 0x0D);
8789 }
8790
8791 #[test]
8792 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8793 // The canonical paste-from-aligned-table footgun — a `\t`
8794 // mid-`:caminho` is invisible in most editors but rides
8795 // through the lacre's content-address verbatim, so two
8796 // paste-from-distinct-tables (one editor strips tabs, one
8797 // preserves them) yield divergent lacres for the byte-
8798 // identical-looking caixa. Pinned separately from the
8799 // whitespace-shaped LF/CR arms so a future relaxation that
8800 // narrows to line-terminator-only surfaces here.
8801 let d = dep_with_fonte(DepSource::Path {
8802 caminho: "../caixa\tteia".into(),
8803 });
8804 let err = d.validate().unwrap_err();
8805 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8806 panic!("expected FonteCaminhoControlChar, got {err:?}");
8807 };
8808 assert_eq!(byte, 0x09);
8809 }
8810
8811 #[test]
8812 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8813 // The DEL byte (`0x7F`) closes the upper-end paste-from-
8814 // binary-blob footgun — the gate's contract is `b < 0x20 ||
8815 // b == 0x7F`, matching the `is_git_repo_url` /
8816 // `is_git_ref_name` predicates' control-char arms. Pinned
8817 // separately from the lower-range arms so a future narrowing
8818 // to `< 0x20` only surfaces here.
8819 let d = dep_with_fonte(DepSource::Path {
8820 caminho: "../caixa\x7fteia".into(),
8821 });
8822 let err = d.validate().unwrap_err();
8823 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8824 panic!("expected FonteCaminhoControlChar, got {err:?}");
8825 };
8826 assert_eq!(byte, 0x7F);
8827 }
8828
8829 #[test]
8830 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8831 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8832 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8833 // are opaque byte sequences and UTF-8 multi-byte sequences
8834 // are a legitimate filename shape (the `café-teia/foo` idiom).
8835 // Pinned so the gate doesn't widen to a full ASCII-only sweep
8836 // that would break every legitimate-shape UTF-8 path.
8837 let d = dep_with_fonte(DepSource::Path {
8838 caminho: "../café-teia/foo".into(),
8839 });
8840 d.validate().unwrap();
8841 }
8842
8843 #[test]
8844 fn fonte_caminho_var_fires_before_control_char() {
8845 // Cascade pin: the var-expansion arm structurally precedes the
8846 // control-char arm. A value like `"$\n"` probes positive on
8847 // both arms (`starts_with('$')` and contains LF), but the
8848 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8849 // wins so the author sees the more self-locating shell-
8850 // expansion arm first. Mirrors the
8851 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8852 // discipline on the immediate-predecessor arm.
8853 let d = dep_with_fonte(DepSource::Path {
8854 caminho: "$HOME\n".into(),
8855 });
8856 let err = d.validate().unwrap_err();
8857 assert!(
8858 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8859 "got {err:?}",
8860 );
8861 }
8862
8863 #[test]
8864 fn validate_rejects_path_fonte_with_leading_space_caminho() {
8865 // The fail-before-pass-after pin for the leading ASCII space
8866 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8867 // Until this gate landed the b94fd83 absolute arm + the a5c248e
8868 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8869 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8870 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8871 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8872 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8873 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8874 // are caught, but the most common whitespace `0x20` space is
8875 // not). The lacre embedded the value verbatim and the resolver
8876 // folded it through `Path::join` looking for a literal `./ ../
8877 // caixa-teia` subdirectory and failing at resolve time with a
8878 // non-self-locating `No such file or directory` error far from
8879 // the source caixa.lisp. The new gate moves the check to
8880 // validate time and names the offending dep + caminho verbatim.
8881 let d = dep_with_fonte(DepSource::Path {
8882 caminho: " ../caixa-teia".into(),
8883 });
8884 let err = d.validate().unwrap_err();
8885 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
8886 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
8887 };
8888 assert_eq!(nome, "caixa-teia");
8889 assert_eq!(caminho, " ../caixa-teia");
8890 }
8891
8892 #[test]
8893 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
8894 // The aligned-doc paste footgun sweep: more than one leading
8895 // space (`" ../caixa-teia"` — the canonical "I selected the
8896 // aligned column from a four-`:fonte`-entry `:deps` block"
8897 // paste) routes through the same gate's `starts_with(' ')`
8898 // byte check. Pinned so the gate doesn't narrow to a
8899 // single-space prefix.
8900 let d = dep_with_fonte(DepSource::Path {
8901 caminho: " ../caixa-teia".into(),
8902 });
8903 let err = d.validate().unwrap_err();
8904 assert!(
8905 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8906 "got {err:?}",
8907 );
8908 }
8909
8910 #[test]
8911 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
8912 // The leading-space is the canonical paste-from-aligned-doc
8913 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
8914 // canonical "I have a directory with a space in its name"
8915 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
8916 // legitimate path with no whitespace-leak semantic at the
8917 // non-leading position. Pinned so the gate doesn't widen to a
8918 // full no-space-anywhere sweep that would break every
8919 // legitimate-shape space-in-filename path.
8920 let d = dep_with_fonte(DepSource::Path {
8921 caminho: "../my dir/caixa-teia".into(),
8922 });
8923 d.validate().unwrap();
8924 }
8925
8926 #[test]
8927 fn fonte_caminho_var_fires_before_leading_whitespace() {
8928 // Cascade pin: the var-expansion arm structurally precedes the
8929 // leading-whitespace arm. A value like `"$ "` would probe positive
8930 // on var (`starts_with('$')`) but the leading-byte arms walk
8931 // left-to-right so the var arm fires on the leading `$` before
8932 // the leading-whitespace arm probes. Mirrors the
8933 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8934 // discipline on the immediate-predecessor arms.
8935 let d = dep_with_fonte(DepSource::Path {
8936 caminho: "$VAR".into(),
8937 });
8938 let err = d.validate().unwrap_err();
8939 assert!(
8940 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8941 "got {err:?}",
8942 );
8943 }
8944
8945 #[test]
8946 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
8947 // Cascade pin: the leading-whitespace arm structurally precedes
8948 // the control-char arm. A value like `" ../foo\n"` probes
8949 // positive on both (starts with space AND contains LF), but
8950 // the narrower leading-byte diagnostic
8951 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
8952 // more self-locating paste-from-aligned-doc arm first. Mirrors
8953 // the `fonte_caminho_var_fires_before_control_char` cascade
8954 // discipline on the immediate-predecessor arm.
8955 let d = dep_with_fonte(DepSource::Path {
8956 caminho: " ../foo\n".into(),
8957 });
8958 let err = d.validate().unwrap_err();
8959 assert!(
8960 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
8961 "got {err:?}",
8962 );
8963 }
8964
8965 #[test]
8966 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
8967 // Diagnostic-shape pin (peer with
8968 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
8969 // payload assertion on the immediate-predecessor arm): the
8970 // error's Display surfaces both the offending `:nome` and the
8971 // offending `:caminho` verbatim, so a `feira lint` run can
8972 // render the diagnostic without re-parsing and the author can
8973 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
8974 // one edit.
8975 let d = dep_with_fonte(DepSource::Path {
8976 caminho: " ../caixa-teia".into(),
8977 });
8978 let rendered = d.validate().unwrap_err().to_string();
8979 assert!(
8980 rendered.contains("caixa-teia"),
8981 "diagnostic must name the offending dep: {rendered}",
8982 );
8983 assert!(
8984 rendered.contains(" ../caixa-teia"),
8985 "diagnostic must quote the offending caminho: {rendered}",
8986 );
8987 assert!(
8988 rendered.contains("space"),
8989 "diagnostic must name the space footgun: {rendered}",
8990 );
8991 }
8992
8993 #[test]
8994 fn fonte_caminho_absolute_fires_before_control_char() {
8995 // Cascade pin on the sibling leading-byte arm: a leading `/`
8996 // value with embedded control byte (`"/etc/passwd\n"`) routes
8997 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
8998 // — the host-layout-leak diagnostic is the load-bearing axis,
8999 // the control byte is the secondary observation. Same precedence
9000 // logic on every prior leading-byte arm.
9001 let d = dep_with_fonte(DepSource::Path {
9002 caminho: "/etc/passwd\n".into(),
9003 });
9004 let err = d.validate().unwrap_err();
9005 assert!(
9006 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9007 "got {err:?}",
9008 );
9009 }
9010
9011 #[test]
9012 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9013 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9014 // injection `:caminho` shape sweep. Until this gate landed
9015 // every prior leading-byte arm passed a leading-`-` value
9016 // through: `Path::is_absolute` returns false on `-` (the
9017 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9018 // `starts_with('$')` / `starts_with(' ')` all return false,
9019 // and `0x2D` sits outside the control-byte set. The lacre
9020 // embedded the value verbatim and the resolver folded it
9021 // through `Path::join` looking for a literal `./-rf` /
9022 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9023 // `Path::join` time is non-self-locating but harmless, while
9024 // the failure at every downstream `git -C {caminho}` /
9025 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9026 // is arbitrary-CLI-arg-injection because none of those
9027 // porcelains carry a `--` argument-list terminator between
9028 // the flag block and the path argument. The new arm moves the
9029 // rejection to `Caixa::from_lisp` boundary time and names
9030 // the offending dep + caminho verbatim.
9031 //
9032 // Sweep spans the canonical CLI-arg-injection shapes matching
9033 // the peer sweep on the sibling `is_git_ref_name` /
9034 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9035 // `find -rf` reinterpretation vector), `-C` (the `git -C`
9036 // change-directory-config-injection paste), long-flag
9037 // `--upload-pack=cat /etc/passwd` (the canonical
9038 // arbitrary-command-execution vector on every git porcelain
9039 // entry point), git-config-injection `--config=core.merge=ours`,
9040 // and the degenerate single-byte `-` value.
9041 for caminho in [
9042 "-rf",
9043 "-C",
9044 "--upload-pack=cat /etc/passwd",
9045 "--config=core.merge=ours",
9046 "-",
9047 ] {
9048 let d = dep_with_fonte(DepSource::Path {
9049 caminho: caminho.into(),
9050 });
9051 let err = d.validate().unwrap_err();
9052 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9053 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9054 };
9055 assert_eq!(nome, "caixa-teia");
9056 assert_eq!(got, caminho);
9057 }
9058 }
9059
9060 #[test]
9061 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9062 // The leading-`-` is the canonical CLI-arg-injection footgun
9063 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9064 // canonical kebab-separator-between-alphanumeric-segments
9065 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9066 // — a mid-path segment starting with `-`, still a legitimate
9067 // POSIX filename byte at that non-leading position because the
9068 // subprocess reads the whole `{caminho}` value as one positional
9069 // argument, so only the very first byte of the composite path
9070 // string is at the CLI-arg-injection boundary) is a legitimate
9071 // path with no CLI-flag-reinterpretation semantic at the non-
9072 // leading position of the top-level value. Pinned so the gate
9073 // doesn't widen to a full no-`-`-anywhere sweep that would
9074 // break every legitimate-shape kebab-in-filename path (i.e.
9075 // essentially every sibling-workspace caixa dep).
9076 for caminho in [
9077 "../caixa-teia",
9078 "../caixa-teia/-hidden",
9079 "./my-lib",
9080 "../foo-bar/baz",
9081 ] {
9082 let d = dep_with_fonte(DepSource::Path {
9083 caminho: caminho.into(),
9084 });
9085 d.validate()
9086 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9087 }
9088 }
9089
9090 #[test]
9091 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9092 // Cascade pin: the leading-whitespace arm structurally precedes
9093 // the leading-hyphen arm. A value like `" -rf"` probes positive
9094 // on both (leading space AND, one byte in, a `-` — though the
9095 // leading-hyphen arm probes only the very first byte so it
9096 // wouldn't fire on this value; the pin instead documents the
9097 // arm order on the more common "leading space then a hyphen"
9098 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9099 // The narrower leading-space diagnostic (the paste-from-aligned-
9100 // doc footgun) wins so the author sees the more self-locating
9101 // whitespace arm first. Mirrors the
9102 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9103 // discipline on the immediate-predecessor arm.
9104 let d = dep_with_fonte(DepSource::Path {
9105 caminho: " -rf".into(),
9106 });
9107 let err = d.validate().unwrap_err();
9108 assert!(
9109 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9110 "got {err:?}",
9111 );
9112 }
9113
9114 #[test]
9115 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9116 // Cascade pin: the leading-hyphen arm structurally precedes
9117 // the control-char arm. A value like `"-rf\n"` probes positive
9118 // on both (starts with `-` AND contains LF), but the narrower
9119 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9120 // the author sees the more self-locating CLI-arg-injection arm
9121 // first. Mirrors the
9122 // `fonte_caminho_leading_whitespace_fires_before_control_char`
9123 // cascade discipline on the immediate-predecessor arm.
9124 let d = dep_with_fonte(DepSource::Path {
9125 caminho: "-rf\n".into(),
9126 });
9127 let err = d.validate().unwrap_err();
9128 assert!(
9129 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9130 "got {err:?}",
9131 );
9132 }
9133
9134 #[test]
9135 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9136 // Diagnostic-shape pin (peer with
9137 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9138 // payload assertion on the immediate-predecessor arm): the
9139 // error's Display surfaces both the offending `:nome` and the
9140 // offending `:caminho` verbatim plus the CLI-argument-injection
9141 // vocabulary, so a `feira lint` run can render the diagnostic
9142 // without re-parsing and the author can grep their caixa.lisp
9143 // for `:caminho "<value>"` and fix it in one edit.
9144 let d = dep_with_fonte(DepSource::Path {
9145 caminho: "--upload-pack=cat /etc/passwd".into(),
9146 });
9147 let rendered = d.validate().unwrap_err().to_string();
9148 assert!(
9149 rendered.contains("caixa-teia"),
9150 "diagnostic must name the offending dep: {rendered}",
9151 );
9152 assert!(
9153 rendered.contains("--upload-pack=cat /etc/passwd"),
9154 "diagnostic must quote the offending caminho: {rendered}",
9155 );
9156 assert!(
9157 rendered.contains("CLI-argument-injection"),
9158 "diagnostic must name the CLI-argument-injection vector: {rendered}",
9159 );
9160 assert!(
9161 rendered.contains("`-`"),
9162 "diagnostic must name the offending byte: {rendered}",
9163 );
9164 }
9165
9166 #[test]
9167 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9168 // Diagnostic-shape pin (peer with
9169 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9170 // payload assertion on the immediate-predecessor arm): the
9171 // error's Display surfaces the offending `:nome`, the
9172 // offending `:caminho` verbatim, and the offending byte in
9173 // hex form (`0x09` for tab) so a `feira lint` run can render
9174 // the diagnostic without re-parsing.
9175 let d = dep_with_fonte(DepSource::Path {
9176 caminho: "../caixa\tteia".into(),
9177 });
9178 let rendered = d.validate().unwrap_err().to_string();
9179 assert!(
9180 rendered.contains("caixa-teia"),
9181 "diagnostic must name the offending dep: {rendered}",
9182 );
9183 assert!(
9184 rendered.contains("../caixa\tteia"),
9185 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9186 );
9187 assert!(
9188 rendered.contains("0x09"),
9189 "diagnostic must name the offending byte in hex: {rendered:?}",
9190 );
9191 }
9192
9193 #[test]
9194 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9195 // The fail-before-pass-after pin for the canonical Windows-
9196 // path-separator paste footgun: an author who pastes a path
9197 // from Windows-Explorer's `Copy as path`, PowerShell's
9198 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9199 // produces `..\caixa-teia`-shape values that silently passed
9200 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9201 // false; `\` is neither a leading-byte sentinel nor a
9202 // control byte). On POSIX resolvers the value rides through
9203 // `Path::join` as a literal directory name and fails at
9204 // resolve time with `No such file or directory`; on Windows
9205 // resolvers the value resolves to the parent's sibling — two
9206 // distinct directories for the byte-identical caixa.lisp.
9207 // The new arm moves the rejection to validate time and names
9208 // the offending dep + caminho verbatim.
9209 let d = dep_with_fonte(DepSource::Path {
9210 caminho: "..\\caixa-teia".into(),
9211 });
9212 let err = d.validate().unwrap_err();
9213 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9214 panic!("expected FonteCaminhoBackslash, got {err:?}");
9215 };
9216 assert_eq!(nome, "caixa-teia");
9217 assert_eq!(caminho, "..\\caixa-teia");
9218 }
9219
9220 #[test]
9221 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9222 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9223 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9224 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9225 // false (POSIX absolute paths start with `/`, drive letters
9226 // are not a POSIX concept), so the b94fd83 absolute arm
9227 // doesn't fire; the value contains `\` bytes that this arm
9228 // now catches with the more self-locating Windows-path-
9229 // separator diagnostic. Pinned separately from the bare
9230 // `..\caixa-teia` shape so a future arm that targets only
9231 // leading-`..\` doesn't regress the drive-letter coverage.
9232 let d = dep_with_fonte(DepSource::Path {
9233 caminho: "C:\\work\\caixa-teia".into(),
9234 });
9235 let err = d.validate().unwrap_err();
9236 assert!(
9237 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9238 "got {err:?}",
9239 );
9240 }
9241
9242 #[test]
9243 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9244 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9245 // PowerShell tab-completion-on-a-directory append). Pinned
9246 // separately from the embedded-`\` shape so the gate's
9247 // contract is "any `\` anywhere", not "any `\` not at end".
9248 let d = dep_with_fonte(DepSource::Path {
9249 caminho: "..\\caixa-teia\\".into(),
9250 });
9251 let err = d.validate().unwrap_err();
9252 assert!(
9253 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9254 "got {err:?}",
9255 );
9256 }
9257
9258 #[test]
9259 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9260 // The positive-control pin: the gate targets `\` only,
9261 // never `/`. The canonical relative POSIX path
9262 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9263 // so legitimate nested-directory deps aren't broken. Pinned
9264 // so the gate doesn't accidentally widen to a "no path
9265 // separators at all" sweep.
9266 let d = dep_with_fonte(DepSource::Path {
9267 caminho: "../caixa-teia/foo/bar".into(),
9268 });
9269 d.validate().unwrap();
9270 }
9271
9272 #[test]
9273 fn fonte_caminho_control_char_fires_before_backslash() {
9274 // Cascade pin: the control-char arm structurally precedes the
9275 // backslash arm. A value like `"..\caixa\0teia"` probes
9276 // positive on both (`\` byte + NUL byte), but the control-
9277 // char diagnostic wins so the author sees the more self-
9278 // locating POSIX-syscall-rejected-byte diagnostic first
9279 // (NUL outright breaks `CString::new` at every `std::fs`
9280 // syscall boundary; the `\` divergence is the cross-OS-
9281 // separator axis). Mirrors the
9282 // `fonte_caminho_var_fires_before_control_char` cascade
9283 // discipline on the immediate-predecessor arm.
9284 let d = dep_with_fonte(DepSource::Path {
9285 caminho: "..\\caixa\0teia".into(),
9286 });
9287 let err = d.validate().unwrap_err();
9288 assert!(
9289 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9290 "got {err:?}",
9291 );
9292 }
9293
9294 #[test]
9295 fn fonte_caminho_absolute_fires_before_backslash() {
9296 // Cascade pin on the load-bearing leading-byte arm: a leading
9297 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9298 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9299 // — the host-layout-leak diagnostic is the load-bearing
9300 // axis, the `\` byte is the secondary observation. Same
9301 // precedence logic as every prior leading-byte arm.
9302 let d = dep_with_fonte(DepSource::Path {
9303 caminho: "/etc/passwd\\foo".into(),
9304 });
9305 let err = d.validate().unwrap_err();
9306 assert!(
9307 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9308 "got {err:?}",
9309 );
9310 }
9311
9312 #[test]
9313 fn fonte_caminho_var_fires_before_backslash() {
9314 // Cascade pin on the var-expansion arm: a leading-`$` value
9315 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9316 // PowerShell-env-var paste-from-CI-manifest footgun) routes
9317 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9318 // The shell-expansion diagnostic is the more self-locating
9319 // axis since both the leading `$` and the embedded `\`
9320 // are Windows-shell artifacts but the `$` is the root-cause
9321 // surface (an author who removes the `$` is likely to leave
9322 // the `\` too).
9323 let d = dep_with_fonte(DepSource::Path {
9324 caminho: "$WORKSPACE\\caixa-teia".into(),
9325 });
9326 let err = d.validate().unwrap_err();
9327 assert!(
9328 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9329 "got {err:?}",
9330 );
9331 }
9332
9333 #[test]
9334 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9335 // Diagnostic-shape pin (peer with the prior
9336 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9337 // on every preceding arm): the error's Display surfaces the
9338 // offending `:nome` and the offending `:caminho` verbatim
9339 // so a `feira lint` run can render the diagnostic without
9340 // re-parsing.
9341 let d = dep_with_fonte(DepSource::Path {
9342 caminho: "..\\caixa-teia".into(),
9343 });
9344 let rendered = d.validate().unwrap_err().to_string();
9345 assert!(
9346 rendered.contains("caixa-teia"),
9347 "diagnostic must name the offending dep: {rendered}",
9348 );
9349 assert!(
9350 rendered.contains("..\\caixa-teia"),
9351 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9352 );
9353 assert!(
9354 rendered.contains('\\'),
9355 "diagnostic must reference the backslash footgun: {rendered:?}",
9356 );
9357 }
9358
9359 #[test]
9360 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9361 // The fail-before-pass-after pin for the canonical trailing-`/`
9362 // paste footgun: an author who shell-tab-completes a sibling
9363 // directory (every interactive shell — bash/zsh/fish/nushell —
9364 // appends `/` on tab-completing a directory) produces
9365 // `"../caixa-teia/"`-shape values that silently passed every
9366 // prior arm (the leading byte is `.`, no control bytes, no
9367 // backslash). `Path::join` resolves both shapes to the same
9368 // directory at the resolver, but the lacre embeds the value
9369 // verbatim and the BLAKE3 closures diverge across two
9370 // workstations whose authors differ only in tab-completion
9371 // habits.
9372 let d = dep_with_fonte(DepSource::Path {
9373 caminho: "../caixa-teia/".into(),
9374 });
9375 let err = d.validate().unwrap_err();
9376 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9377 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9378 };
9379 assert_eq!(nome, "caixa-teia");
9380 assert_eq!(caminho, "../caixa-teia/");
9381 }
9382
9383 #[test]
9384 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9385 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9386 // directory and tab-completed it" footgun). Pinned separately
9387 // from the canonical `"../caixa-teia/"` shape so the gate's
9388 // contract is "any trailing `/`", not "trailing `/` after a leaf
9389 // name".
9390 let d = dep_with_fonte(DepSource::Path {
9391 caminho: "./".into(),
9392 });
9393 let err = d.validate().unwrap_err();
9394 assert!(
9395 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9396 "got {err:?}",
9397 );
9398 }
9399
9400 #[test]
9401 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9402 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9403 // that double-templated `${VAR}/` over an already-`/`-suffixed
9404 // path" footgun). The gate fires on the last byte being `/`
9405 // regardless of how many `/` precede it; the arm contract is
9406 // "the value ends with `/`", structurally.
9407 let d = dep_with_fonte(DepSource::Path {
9408 caminho: "../caixa-teia//".into(),
9409 });
9410 let err = d.validate().unwrap_err();
9411 assert!(
9412 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9413 "got {err:?}",
9414 );
9415 }
9416
9417 #[test]
9418 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9419 // The `"../"` shape (the canonical "I want the parent" tab-
9420 // completion footgun on a bare `..` path). Pinned separately so
9421 // the gate doesn't accidentally narrow to "trailing `/` only on
9422 // multi-segment paths".
9423 let d = dep_with_fonte(DepSource::Path {
9424 caminho: "../".into(),
9425 });
9426 let err = d.validate().unwrap_err();
9427 assert!(
9428 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9429 "got {err:?}",
9430 );
9431 }
9432
9433 #[test]
9434 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9435 // The positive-control pin: the gate targets the trailing byte
9436 // only, never internal `/` separators. The canonical nested
9437 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9438 // to validate cleanly so legitimate deeply-nested deps aren't
9439 // broken. Pinned so the gate doesn't accidentally widen to a
9440 // "no `/` separators anywhere" sweep that would defeat the
9441 // entire path-fonte author surface.
9442 let d = dep_with_fonte(DepSource::Path {
9443 caminho: "../caixa-teia/foo/bar".into(),
9444 });
9445 d.validate().unwrap();
9446 }
9447
9448 #[test]
9449 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9450 // The positive-control pin on the degenerate single-`.` shape
9451 // (the canonical "the caixa.lisp's own directory" idiom). The
9452 // gate fires on the trailing byte being `/`, not on the path
9453 // being short, so `"."` (one byte, not `/`) must continue to
9454 // validate cleanly.
9455 let d = dep_with_fonte(DepSource::Path {
9456 caminho: ".".into(),
9457 });
9458 d.validate().unwrap();
9459 }
9460
9461 #[test]
9462 fn fonte_caminho_control_char_fires_before_trailing_slash() {
9463 // Cascade pin: the control-char arm structurally precedes the
9464 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9465 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9466 // (control bytes are the paste-from-multiline-doc footgun the
9467 // d624c8d arm already closes). Mirrors the
9468 // `fonte_caminho_control_char_fires_before_backslash` cascade
9469 // discipline on the immediate-predecessor arm.
9470 let d = dep_with_fonte(DepSource::Path {
9471 caminho: "../foo\n/".into(),
9472 });
9473 let err = d.validate().unwrap_err();
9474 assert!(
9475 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9476 "got {err:?}",
9477 );
9478 }
9479
9480 #[test]
9481 fn fonte_caminho_backslash_fires_before_trailing_slash() {
9482 // Cascade pin on the backslash arm: a value like `"..\foo/"`
9483 // ends in `/` but the embedded `\` is the load-bearing
9484 // diagnostic (the cross-host-OS-separator divergence vector
9485 // the 3a4e1d7 arm closes). Same precedence logic as the prior
9486 // narrower-diagnostic-first cascade.
9487 let d = dep_with_fonte(DepSource::Path {
9488 caminho: "..\\caixa-teia/".into(),
9489 });
9490 let err = d.validate().unwrap_err();
9491 assert!(
9492 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9493 "got {err:?}",
9494 );
9495 }
9496
9497 #[test]
9498 fn fonte_caminho_absolute_fires_before_trailing_slash() {
9499 // Cascade pin on the load-bearing leading-byte arm: a leading
9500 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9501 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9502 // — the host-layout-leak diagnostic is the load-bearing axis,
9503 // the trailing `/` is the secondary observation. Same
9504 // precedence logic as every prior leading-byte arm.
9505 let d = dep_with_fonte(DepSource::Path {
9506 caminho: "/etc/passwd/".into(),
9507 });
9508 let err = d.validate().unwrap_err();
9509 assert!(
9510 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9511 "got {err:?}",
9512 );
9513 }
9514
9515 #[test]
9516 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9517 // Diagnostic-shape pin (peer with the prior
9518 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9519 // every preceding arm): the error's Display surfaces the
9520 // offending `:nome` and the offending `:caminho` verbatim so a
9521 // `feira lint` run can render the diagnostic without re-parsing.
9522 let d = dep_with_fonte(DepSource::Path {
9523 caminho: "../caixa-teia/".into(),
9524 });
9525 let rendered = d.validate().unwrap_err().to_string();
9526 assert!(
9527 rendered.contains("caixa-teia"),
9528 "diagnostic must name the offending dep: {rendered}",
9529 );
9530 assert!(
9531 rendered.contains("../caixa-teia/"),
9532 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9533 );
9534 assert!(
9535 rendered.contains("trailing"),
9536 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9537 );
9538 }
9539
9540 // -- :caminho shell-redirection metacharacter arm -----------------------
9541
9542 #[test]
9543 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9544 // The fail-before-pass-after pin for the canonical output-redirection
9545 // paste footgun: an author copies a shell pipeline tail
9546 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9547 // line including the `> build.log` redirect" idiom) and silently
9548 // passed every prior arm (`Path::is_absolute` false on `..`, no
9549 // control bytes, no backslash, doesn't end in `/`). The lacre
9550 // embedded the value verbatim, the resolver folded it through
9551 // `Path::join` looking for a literal `./../caixa-teia>build.log`
9552 // subdirectory, and the failure surfaced at resolve time with a
9553 // non-self-locating `No such file or directory` error. The new arm
9554 // moves the rejection to validate time and names the offending dep
9555 // + caminho + byte verbatim.
9556 let d = dep_with_fonte(DepSource::Path {
9557 caminho: "../caixa-teia>build.log".into(),
9558 });
9559 let err = d.validate().unwrap_err();
9560 let DepError::FonteCaminhoShellRedirection {
9561 nome,
9562 caminho,
9563 byte,
9564 } = err
9565 else {
9566 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9567 };
9568 assert_eq!(nome, "caixa-teia");
9569 assert_eq!(caminho, "../caixa-teia>build.log");
9570 assert_eq!(byte, b'>');
9571 }
9572
9573 #[test]
9574 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9575 // The symmetric input-redirection paste shape
9576 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9577 // `command < input.lisp` line from a tatara-lisp REPL log"
9578 // idiom). Pinned separately from the `>` shape so the gate's
9579 // contract is "any `<` or `>` anywhere", not single-byte coverage.
9580 let d = dep_with_fonte(DepSource::Path {
9581 caminho: "../caixa-teia<input.lisp".into(),
9582 });
9583 let err = d.validate().unwrap_err();
9584 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9585 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9586 };
9587 assert_eq!(byte, b'<');
9588 }
9589
9590 #[test]
9591 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9592 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9593 // "I forgot the source side of the redirect" idiom). Pinned
9594 // separately from the embedded-byte shapes so the gate covers
9595 // every position, not only mid-path.
9596 let d = dep_with_fonte(DepSource::Path {
9597 caminho: ">../caixa-teia".into(),
9598 });
9599 let err = d.validate().unwrap_err();
9600 assert!(
9601 matches!(
9602 err,
9603 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9604 ),
9605 "got {err:?}",
9606 );
9607 }
9608
9609 #[test]
9610 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9611 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9612 // the canonical "I copied a `>>` append redirect" idiom). The arm
9613 // fires on the first `>` encountered; pinned so a future arm that
9614 // tries to distinguish `>` from `>>` doesn't break the broader
9615 // contract.
9616 let d = dep_with_fonte(DepSource::Path {
9617 caminho: "../caixa-teia>>build.log".into(),
9618 });
9619 let err = d.validate().unwrap_err();
9620 assert!(
9621 matches!(
9622 err,
9623 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9624 ),
9625 "got {err:?}",
9626 );
9627 }
9628
9629 #[test]
9630 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9631 // The positive-control pin: the gate targets only `<` / `>`,
9632 // never adjacent printable ASCII or POSIX-valid bytes. The
9633 // canonical relative POSIX path (`"../caixa-teia"`) and a
9634 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9635 // continue to validate cleanly so the gate doesn't widen to a
9636 // "no printable punctuation anywhere" sweep that would defeat
9637 // the entire path-fonte author surface.
9638 let d = dep_with_fonte(DepSource::Path {
9639 caminho: "../caixa-teia/foo/bar".into(),
9640 });
9641 d.validate().unwrap();
9642 }
9643
9644 #[test]
9645 fn fonte_caminho_backslash_fires_before_shell_redirection() {
9646 // Cascade pin on the immediate-predecessor arm: a value carrying
9647 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9648 // canonical "I pasted a Windows-shell command with output
9649 // redirect" footgun) routes through `FonteCaminhoBackslash` not
9650 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9651 // divergence is the load-bearing axis (an author who removes
9652 // the `\` is the root-cause edit; the `>` falls away in the
9653 // same edit since it's downstream of the Windows-shell
9654 // convention).
9655 let d = dep_with_fonte(DepSource::Path {
9656 caminho: "..\\caixa-teia>build.log".into(),
9657 });
9658 let err = d.validate().unwrap_err();
9659 assert!(
9660 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9661 "got {err:?}",
9662 );
9663 }
9664
9665 #[test]
9666 fn fonte_caminho_control_char_fires_before_shell_redirection() {
9667 // Cascade pin on the embedded-control-byte arm: a value carrying
9668 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9669 // canonical paste-from-multiline-doc footgun where a newline
9670 // landed mid-caminho) routes through `FonteCaminhoControlChar`
9671 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9672 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9673 // load-bearing axis on every value that probes positive for
9674 // both — mirrors the cascade discipline on every prior arm.
9675 let d = dep_with_fonte(DepSource::Path {
9676 caminho: "../foo\n>bar".into(),
9677 });
9678 let err = d.validate().unwrap_err();
9679 assert!(
9680 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9681 "got {err:?}",
9682 );
9683 }
9684
9685 #[test]
9686 fn fonte_caminho_absolute_fires_before_shell_redirection() {
9687 // Cascade pin on the load-bearing leading-byte arm: a leading
9688 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9689 // routes through `FonteCaminhoAbsolute` not
9690 // `FonteCaminhoShellRedirection` — the host-layout-leak
9691 // diagnostic is the load-bearing axis, the `>` byte is the
9692 // secondary observation. Same precedence logic as every prior
9693 // leading-byte arm.
9694 let d = dep_with_fonte(DepSource::Path {
9695 caminho: "/etc/passwd>out".into(),
9696 });
9697 let err = d.validate().unwrap_err();
9698 assert!(
9699 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9700 "got {err:?}",
9701 );
9702 }
9703
9704 #[test]
9705 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9706 // Cascade pin on the immediate-successor arm: a value carrying
9707 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9708 // canonical "I tab-completed a path that already had a
9709 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9710 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9711 // the more semantic-locating axis (an author who removes the
9712 // `<` / `>` typically also drops the trailing separator since
9713 // both are paste-from-shell artifacts).
9714 let d = dep_with_fonte(DepSource::Path {
9715 caminho: "../foo></".into(),
9716 });
9717 let err = d.validate().unwrap_err();
9718 assert!(
9719 matches!(
9720 err,
9721 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9722 ),
9723 "got {err:?}",
9724 );
9725 }
9726
9727 #[test]
9728 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9729 // Diagnostic-shape pin (peer with
9730 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9731 // payload assertion on the closest peer arm that also carries a
9732 // `byte` field): the error's Display surfaces the offending
9733 // `:nome`, the offending `:caminho` verbatim, and the offending
9734 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9735 // run can render the diagnostic without re-parsing.
9736 let d = dep_with_fonte(DepSource::Path {
9737 caminho: "../caixa-teia>build.log".into(),
9738 });
9739 let rendered = d.validate().unwrap_err().to_string();
9740 assert!(
9741 rendered.contains("caixa-teia"),
9742 "diagnostic must name the offending dep: {rendered}",
9743 );
9744 assert!(
9745 rendered.contains("../caixa-teia>build.log"),
9746 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9747 );
9748 assert!(
9749 rendered.contains("0x3e"),
9750 "diagnostic must name the offending byte in hex: {rendered:?}",
9751 );
9752 assert!(
9753 rendered.contains("redirection"),
9754 "diagnostic must name the shell-redirection footgun: {rendered:?}",
9755 );
9756 }
9757
9758 // -- :caminho shell-pipe metacharacter arm ----------------------------
9759
9760 #[test]
9761 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9762 // The fail-before-pass-after pin for the canonical shell-pipe
9763 // paste footgun: an author copies a shell-history line
9764 // (`"../caixa-teia | grep foo"` — the canonical "I selected
9765 // the whole `ls dir | grep` line out of zsh history") and
9766 // silently passed every prior arm (`Path::is_absolute` false
9767 // on `..`, no control bytes, no backslash, no `<` / `>`,
9768 // doesn't end in `/`). The lacre embedded the value verbatim,
9769 // the resolver folded it through `Path::join` looking for a
9770 // literal `./../caixa-teia | grep foo` subdirectory, and the
9771 // failure surfaced at resolve time with a non-self-locating
9772 // `No such file or directory` error. The new arm moves the
9773 // rejection to validate time and names the offending dep +
9774 // caminho verbatim.
9775 let d = dep_with_fonte(DepSource::Path {
9776 caminho: "../caixa-teia | grep foo".into(),
9777 });
9778 let err = d.validate().unwrap_err();
9779 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9780 panic!("expected FonteCaminhoShellPipe, got {err:?}");
9781 };
9782 assert_eq!(nome, "caixa-teia");
9783 assert_eq!(caminho, "../caixa-teia | grep foo");
9784 }
9785
9786 #[test]
9787 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9788 // Leading-position `|` shape (`"|../caixa-teia"` — the
9789 // degenerate "I forgot the source side of the pipe" idiom).
9790 // Pinned separately from the embedded-byte shape so the gate
9791 // covers every position, not only mid-path.
9792 let d = dep_with_fonte(DepSource::Path {
9793 caminho: "|../caixa-teia".into(),
9794 });
9795 let err = d.validate().unwrap_err();
9796 assert!(
9797 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9798 "got {err:?}",
9799 );
9800 }
9801
9802 #[test]
9803 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9804 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9805 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9806 // idiom). The arm fires on the first `|` encountered; pinned
9807 // so a future arm that tries to distinguish `|` from `||`
9808 // doesn't break the broader contract.
9809 let d = dep_with_fonte(DepSource::Path {
9810 caminho: "../caixa-teia||fallback".into(),
9811 });
9812 let err = d.validate().unwrap_err();
9813 assert!(
9814 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9815 "got {err:?}",
9816 );
9817 }
9818
9819 #[test]
9820 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9821 // The positive-control pin: the gate targets only `|`, never
9822 // adjacent printable ASCII or POSIX-valid bytes. The canonical
9823 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9824 // pathed variant with adjacent printable punctuation
9825 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9826 // cleanly so the gate doesn't widen to a "no printable
9827 // punctuation anywhere" sweep that would defeat the entire
9828 // path-fonte author surface.
9829 let d = dep_with_fonte(DepSource::Path {
9830 caminho: "../caixa-teia/sub-dir.v2".into(),
9831 });
9832 d.validate().unwrap();
9833 }
9834
9835 #[test]
9836 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9837 // Cascade pin on the immediate-predecessor arm: a value carrying
9838 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9839 // canonical "I pasted a `cmd < input | tee` pipeline tail"
9840 // footgun) routes through `FonteCaminhoShellRedirection` not
9841 // `FonteCaminhoShellPipe`. The input/output redirection
9842 // metachar carries the more self-locating `byte: u8` payload
9843 // (it names which of `<` or `>` triggered), so the prior arm
9844 // wins on every probe-as-both value — same cascade discipline
9845 // every prior `:caminho` arm establishes.
9846 let d = dep_with_fonte(DepSource::Path {
9847 caminho: "../caixa-teia<input|tee".into(),
9848 });
9849 let err = d.validate().unwrap_err();
9850 assert!(
9851 matches!(
9852 err,
9853 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9854 ),
9855 "got {err:?}",
9856 );
9857 }
9858
9859 #[test]
9860 fn fonte_caminho_backslash_fires_before_shell_pipe() {
9861 // Cascade pin on the upstream backslash arm: a value carrying
9862 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9863 // "I pasted a Windows-shell command with pipe to tee"
9864 // footgun) routes through `FonteCaminhoBackslash` not
9865 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9866 // divergence is the load-bearing axis on every probe-as-both
9867 // value (an author who removes the `\` is the root-cause edit;
9868 // the `|` falls away in the same edit since it's downstream of
9869 // the Windows-shell convention).
9870 let d = dep_with_fonte(DepSource::Path {
9871 caminho: "..\\caixa-teia|tee".into(),
9872 });
9873 let err = d.validate().unwrap_err();
9874 assert!(
9875 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9876 "got {err:?}",
9877 );
9878 }
9879
9880 #[test]
9881 fn fonte_caminho_control_char_fires_before_shell_pipe() {
9882 // Cascade pin on the embedded-control-byte arm: a value
9883 // carrying both a control byte and `|` (`"../foo\n|bar"` —
9884 // the canonical paste-from-multiline-doc footgun where a
9885 // newline landed mid-caminho) routes through
9886 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
9887 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
9888 // diagnostic is the load-bearing axis on every value that
9889 // probes positive for both — mirrors the cascade discipline
9890 // on every prior arm.
9891 let d = dep_with_fonte(DepSource::Path {
9892 caminho: "../foo\n|bar".into(),
9893 });
9894 let err = d.validate().unwrap_err();
9895 assert!(
9896 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9897 "got {err:?}",
9898 );
9899 }
9900
9901 #[test]
9902 fn fonte_caminho_absolute_fires_before_shell_pipe() {
9903 // Cascade pin on the load-bearing leading-byte arm: a leading
9904 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
9905 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
9906 // — the host-layout-leak diagnostic is the load-bearing axis,
9907 // the `|` byte is the secondary observation. Same precedence
9908 // logic as every prior leading-byte arm.
9909 let d = dep_with_fonte(DepSource::Path {
9910 caminho: "/etc/passwd|tee".into(),
9911 });
9912 let err = d.validate().unwrap_err();
9913 assert!(
9914 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9915 "got {err:?}",
9916 );
9917 }
9918
9919 #[test]
9920 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
9921 // Cascade pin on the immediate-successor arm: a value carrying
9922 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
9923 // "I tab-completed a path that already had a pipeline tail"
9924 // footgun) routes through `FonteCaminhoShellPipe` not
9925 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9926 // the more semantic-locating axis (an author who removes the
9927 // `|` typically also drops the trailing separator since both
9928 // are paste-from-shell artifacts).
9929 let d = dep_with_fonte(DepSource::Path {
9930 caminho: "../foo|tee/".into(),
9931 });
9932 let err = d.validate().unwrap_err();
9933 assert!(
9934 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9935 "got {err:?}",
9936 );
9937 }
9938
9939 #[test]
9940 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
9941 // Diagnostic-shape pin (peer with
9942 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
9943 // on the closest single-byte peer arm): the error's Display
9944 // surfaces the offending `:nome` and the offending `:caminho`
9945 // verbatim, and names the shell-pipe footgun explicitly so a
9946 // `feira lint` run can render the diagnostic without
9947 // re-parsing.
9948 let d = dep_with_fonte(DepSource::Path {
9949 caminho: "../caixa-teia | grep foo".into(),
9950 });
9951 let rendered = d.validate().unwrap_err().to_string();
9952 assert!(
9953 rendered.contains("caixa-teia"),
9954 "diagnostic must name the offending dep: {rendered}",
9955 );
9956 assert!(
9957 rendered.contains("../caixa-teia | grep foo"),
9958 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9959 );
9960 assert!(
9961 rendered.contains('|'),
9962 "diagnostic must reference the pipe footgun: {rendered:?}",
9963 );
9964 assert!(
9965 rendered.contains("pipe"),
9966 "diagnostic must name the shell-pipe footgun: {rendered:?}",
9967 );
9968 }
9969
9970 // -- :caminho shell-command-separator metacharacter arm ---------------
9971
9972 #[test]
9973 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
9974 // The fail-before-pass-after pin for the canonical shell-command-
9975 // separator paste footgun: an author copies a shell one-liner
9976 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
9977 // whole `cd path; do-thing` chain out of a shell-history block")
9978 // and silently passed every prior arm (`Path::is_absolute` false
9979 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
9980 // doesn't end in `/`). The lacre embedded the value verbatim, the
9981 // resolver folded it through `Path::join` looking for a literal
9982 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
9983 // surfaced at resolve time with a non-self-locating `No such file
9984 // or directory` error. The new arm moves the rejection to validate
9985 // time and names the offending dep + caminho verbatim.
9986 let d = dep_with_fonte(DepSource::Path {
9987 caminho: "../caixa-teia; rm -rf build".into(),
9988 });
9989 let err = d.validate().unwrap_err();
9990 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
9991 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
9992 };
9993 assert_eq!(nome, "caixa-teia");
9994 assert_eq!(caminho, "../caixa-teia; rm -rf build");
9995 }
9996
9997 #[test]
9998 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
9999 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10000 // "I forgot the prior command side of the separator" idiom).
10001 // Pinned separately from the embedded-byte shape so the gate
10002 // covers every position, not only mid-path.
10003 let d = dep_with_fonte(DepSource::Path {
10004 caminho: ";../caixa-teia".into(),
10005 });
10006 let err = d.validate().unwrap_err();
10007 assert!(
10008 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10009 "got {err:?}",
10010 );
10011 }
10012
10013 #[test]
10014 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10015 // The POSIX `case` arm `;;` terminator shape
10016 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10017 // arm tail" idiom). The arm fires on the first `;` encountered;
10018 // pinned so a future arm that tries to distinguish `;` from `;;`
10019 // doesn't break the broader contract.
10020 let d = dep_with_fonte(DepSource::Path {
10021 caminho: "../caixa-teia;;next".into(),
10022 });
10023 let err = d.validate().unwrap_err();
10024 assert!(
10025 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10026 "got {err:?}",
10027 );
10028 }
10029
10030 #[test]
10031 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10032 // The positive-control pin: the gate targets only `;`, never
10033 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10034 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10035 // pathed variant with adjacent printable punctuation
10036 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10037 // cleanly so the gate doesn't widen to a "no printable
10038 // punctuation anywhere" sweep that would defeat the entire
10039 // path-fonte author surface.
10040 let d = dep_with_fonte(DepSource::Path {
10041 caminho: "../caixa-teia/sub-dir.v2".into(),
10042 });
10043 d.validate().unwrap();
10044 }
10045
10046 #[test]
10047 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10048 // Cascade pin on the immediate-predecessor arm: a value carrying
10049 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10050 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10051 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10052 // pipeline-tail paste is the load-bearing root-cause edit on
10053 // every probe-as-both value (an author who removes the `|`
10054 // typically also drops the trailing `; cleanup` since both are
10055 // the same paste-from-shell-history artifact) — same cascade
10056 // discipline every prior `:caminho` arm establishes.
10057 let d = dep_with_fonte(DepSource::Path {
10058 caminho: "../caixa-teia | tee; rm".into(),
10059 });
10060 let err = d.validate().unwrap_err();
10061 assert!(
10062 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10063 "got {err:?}",
10064 );
10065 }
10066
10067 #[test]
10068 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10069 // Cascade pin on the upstream shell-redirection arm: a value
10070 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10071 // the canonical "I pasted a `cmd > log; cleanup` chain"
10072 // footgun) routes through `FonteCaminhoShellRedirection` not
10073 // `FonteCaminhoShellSemicolon`. The input/output redirection
10074 // metachar carries the more self-locating `byte: u8` payload
10075 // (it names which of `<` or `>` triggered), so the prior arm
10076 // wins on every probe-as-both value.
10077 let d = dep_with_fonte(DepSource::Path {
10078 caminho: "../caixa-teia>log; rm".into(),
10079 });
10080 let err = d.validate().unwrap_err();
10081 assert!(
10082 matches!(
10083 err,
10084 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10085 ),
10086 "got {err:?}",
10087 );
10088 }
10089
10090 #[test]
10091 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10092 // Cascade pin on the upstream backslash arm: a value carrying
10093 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10094 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10095 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10096 // The cross-host-OS-separator divergence is the load-bearing axis
10097 // on every probe-as-both value (an author who removes the `\` is
10098 // the root-cause edit; the `;` falls away in the same edit since
10099 // it's downstream of the Windows-shell convention).
10100 let d = dep_with_fonte(DepSource::Path {
10101 caminho: "..\\caixa-teia;rm".into(),
10102 });
10103 let err = d.validate().unwrap_err();
10104 assert!(
10105 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10106 "got {err:?}",
10107 );
10108 }
10109
10110 #[test]
10111 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10112 // Cascade pin on the embedded-control-byte arm: a value carrying
10113 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10114 // paste-from-multiline-doc footgun where a newline landed mid-
10115 // caminho) routes through `FonteCaminhoControlChar` not
10116 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10117 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10118 // on every value that probes positive for both — mirrors the
10119 // cascade discipline on every prior arm.
10120 let d = dep_with_fonte(DepSource::Path {
10121 caminho: "../foo\n;bar".into(),
10122 });
10123 let err = d.validate().unwrap_err();
10124 assert!(
10125 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10126 "got {err:?}",
10127 );
10128 }
10129
10130 #[test]
10131 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10132 // Cascade pin on the load-bearing leading-byte arm: a leading
10133 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10134 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10135 // — the host-layout-leak diagnostic is the load-bearing axis,
10136 // the `;` byte is the secondary observation. Same precedence
10137 // logic as every prior leading-byte arm.
10138 let d = dep_with_fonte(DepSource::Path {
10139 caminho: "/etc/passwd;rm".into(),
10140 });
10141 let err = d.validate().unwrap_err();
10142 assert!(
10143 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10144 "got {err:?}",
10145 );
10146 }
10147
10148 #[test]
10149 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10150 // Cascade pin on the immediate-successor arm: a value carrying
10151 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10152 // "I tab-completed a path that already had a `; cleanup` tail"
10153 // footgun) routes through `FonteCaminhoShellSemicolon` not
10154 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10155 // the more semantic-locating axis (an author who removes the
10156 // `;` typically also drops the trailing separator since both
10157 // are paste-from-shell artifacts).
10158 let d = dep_with_fonte(DepSource::Path {
10159 caminho: "../foo;rm/".into(),
10160 });
10161 let err = d.validate().unwrap_err();
10162 assert!(
10163 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10164 "got {err:?}",
10165 );
10166 }
10167
10168 #[test]
10169 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10170 // Diagnostic-shape pin (peer with
10171 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10172 // on the closest single-byte peer arm): the error's Display
10173 // surfaces the offending `:nome` and the offending `:caminho`
10174 // verbatim, and names the shell-command-separator footgun
10175 // explicitly so a `feira lint` run can render the diagnostic
10176 // without re-parsing.
10177 let d = dep_with_fonte(DepSource::Path {
10178 caminho: "../caixa-teia; rm -rf build".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; rm -rf build"),
10187 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10188 );
10189 assert!(
10190 rendered.contains(';'),
10191 "diagnostic must reference the semicolon footgun: {rendered:?}",
10192 );
10193 assert!(
10194 rendered.contains("command-separator"),
10195 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10196 );
10197 }
10198
10199 #[test]
10200 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10201 // The fail-before-pass-after pin for the canonical shell-
10202 // background-task paste footgun: an author copies a shell one-
10203 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10204 // the whole `cd path & sleep 1` background-launch out of a
10205 // shell-history block") and silently passed every prior arm
10206 // (`Path::is_absolute` false on `..`, no control bytes, no
10207 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10208 // The lacre embedded the value verbatim, the resolver folded it
10209 // through `Path::join` looking for a literal `./../caixa-teia &
10210 // sleep 1` subdirectory, and the failure surfaced at resolve
10211 // time with a non-self-locating `No such file or directory`
10212 // error. The new arm moves the rejection to validate time and
10213 // names the offending dep + caminho verbatim.
10214 let d = dep_with_fonte(DepSource::Path {
10215 caminho: "../caixa-teia & sleep 1".into(),
10216 });
10217 let err = d.validate().unwrap_err();
10218 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10219 panic!("expected FonteCaminhoShellBackground, got {err:?}");
10220 };
10221 assert_eq!(nome, "caixa-teia");
10222 assert_eq!(caminho, "../caixa-teia & sleep 1");
10223 }
10224
10225 #[test]
10226 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10227 // Leading-position `&` shape (`"&../caixa-teia"` — the
10228 // degenerate "I forgot the prior command side of the
10229 // background terminator" idiom). Pinned separately from the
10230 // embedded-byte shape so the gate covers every position, not
10231 // only mid-path.
10232 let d = dep_with_fonte(DepSource::Path {
10233 caminho: "&../caixa-teia".into(),
10234 });
10235 let err = d.validate().unwrap_err();
10236 assert!(
10237 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10238 "got {err:?}",
10239 );
10240 }
10241
10242 #[test]
10243 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10244 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10245 // canonical "I copied a `cd path && make` build chain" idiom
10246 // every Makefile / shell-script wraps). The arm fires on the
10247 // first `&` encountered; pinned so a future arm that tries to
10248 // distinguish `&` from `&&` doesn't break the broader contract.
10249 let d = dep_with_fonte(DepSource::Path {
10250 caminho: "../caixa-teia && make".into(),
10251 });
10252 let err = d.validate().unwrap_err();
10253 assert!(
10254 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10255 "got {err:?}",
10256 );
10257 }
10258
10259 #[test]
10260 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10261 // The positive-control pin: the gate targets only `&`, never
10262 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10263 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10264 // pathed variant with adjacent printable punctuation
10265 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10266 // cleanly so the gate doesn't widen to a "no printable
10267 // punctuation anywhere" sweep that would defeat the entire
10268 // path-fonte author surface.
10269 let d = dep_with_fonte(DepSource::Path {
10270 caminho: "../caixa-teia/sub-dir.v2".into(),
10271 });
10272 d.validate().unwrap();
10273 }
10274
10275 #[test]
10276 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10277 // Cascade pin on the immediate-predecessor arm: a value carrying
10278 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10279 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10280 // routes through `FonteCaminhoShellSemicolon` not
10281 // `FonteCaminhoShellBackground`. The sequential-command-
10282 // separator paste is the more common shell-history paste idiom
10283 // on every probe-as-both value (an author who removes the `;`
10284 // typically also drops the trailing `& sleep` since both are
10285 // paste-from-shell-history artifacts) — same cascade discipline
10286 // every prior `:caminho` arm establishes.
10287 let d = dep_with_fonte(DepSource::Path {
10288 caminho: "../caixa-teia; rm & sleep".into(),
10289 });
10290 let err = d.validate().unwrap_err();
10291 assert!(
10292 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10293 "got {err:?}",
10294 );
10295 }
10296
10297 #[test]
10298 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10299 // Cascade pin on the upstream shell-pipe arm: a value carrying
10300 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10301 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10302 // chain" footgun) routes through `FonteCaminhoShellPipe` not
10303 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10304 // load-bearing root-cause edit on every probe-as-both value.
10305 let d = dep_with_fonte(DepSource::Path {
10306 caminho: "../caixa-teia | tee & sleep".into(),
10307 });
10308 let err = d.validate().unwrap_err();
10309 assert!(
10310 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10311 "got {err:?}",
10312 );
10313 }
10314
10315 #[test]
10316 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10317 // Cascade pin on the upstream shell-redirection arm: a value
10318 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10319 // the canonical "I pasted a `cmd > log & sleep` background-
10320 // redirect chain" footgun) routes through
10321 // `FonteCaminhoShellRedirection` not
10322 // `FonteCaminhoShellBackground`. The input/output redirection
10323 // metachar carries the more self-locating `byte: u8` payload
10324 // (it names which of `<` or `>` triggered), so the prior arm
10325 // wins on every probe-as-both value.
10326 let d = dep_with_fonte(DepSource::Path {
10327 caminho: "../caixa-teia>log & sleep".into(),
10328 });
10329 let err = d.validate().unwrap_err();
10330 assert!(
10331 matches!(
10332 err,
10333 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10334 ),
10335 "got {err:?}",
10336 );
10337 }
10338
10339 #[test]
10340 fn fonte_caminho_backslash_fires_before_shell_background() {
10341 // Cascade pin on the upstream backslash arm: a value carrying
10342 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10343 // "I pasted a Windows-shell `cd ..\path & sleep` background-
10344 // launch chain") routes through `FonteCaminhoBackslash` not
10345 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10346 // divergence is the load-bearing axis on every probe-as-both
10347 // value (an author who removes the `\` is the root-cause edit;
10348 // the `&` falls away in the same edit since it's downstream of
10349 // the Windows-shell convention).
10350 let d = dep_with_fonte(DepSource::Path {
10351 caminho: "..\\caixa-teia & sleep".into(),
10352 });
10353 let err = d.validate().unwrap_err();
10354 assert!(
10355 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10356 "got {err:?}",
10357 );
10358 }
10359
10360 #[test]
10361 fn fonte_caminho_control_char_fires_before_shell_background() {
10362 // Cascade pin on the embedded-control-byte arm: a value
10363 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10364 // the canonical paste-from-multiline-doc footgun where a
10365 // newline landed mid-caminho) routes through
10366 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10367 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10368 // diagnostic is the load-bearing axis on every value that
10369 // probes positive for both — mirrors the cascade discipline on
10370 // every prior arm.
10371 let d = dep_with_fonte(DepSource::Path {
10372 caminho: "../foo\n&sleep".into(),
10373 });
10374 let err = d.validate().unwrap_err();
10375 assert!(
10376 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10377 "got {err:?}",
10378 );
10379 }
10380
10381 #[test]
10382 fn fonte_caminho_absolute_fires_before_shell_background() {
10383 // Cascade pin on the load-bearing leading-byte arm: a leading
10384 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10385 // through `FonteCaminhoAbsolute` not
10386 // `FonteCaminhoShellBackground` — the host-layout-leak
10387 // diagnostic is the load-bearing axis, the `&` byte is the
10388 // secondary observation. Same precedence logic as every prior
10389 // leading-byte arm.
10390 let d = dep_with_fonte(DepSource::Path {
10391 caminho: "/etc/passwd & sleep".into(),
10392 });
10393 let err = d.validate().unwrap_err();
10394 assert!(
10395 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10396 "got {err:?}",
10397 );
10398 }
10399
10400 #[test]
10401 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10402 // Cascade pin on the immediate-successor arm: a value carrying
10403 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10404 // canonical "I tab-completed a path that already had a `&
10405 // sleep` background-launch tail" footgun) routes through
10406 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10407 // The embedded shell-metachar is the more semantic-locating
10408 // axis (an author who removes the `&` typically also drops
10409 // the trailing separator since both are paste-from-shell
10410 // artifacts).
10411 let d = dep_with_fonte(DepSource::Path {
10412 caminho: "../foo&sleep/".into(),
10413 });
10414 let err = d.validate().unwrap_err();
10415 assert!(
10416 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10417 "got {err:?}",
10418 );
10419 }
10420
10421 #[test]
10422 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10423 // Diagnostic-shape pin (peer with
10424 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10425 // on the closest single-byte peer arm): the error's Display
10426 // surfaces the offending `:nome` and the offending `:caminho`
10427 // verbatim, and names the shell-background / logical-AND
10428 // footgun explicitly so a `feira lint` run can render the
10429 // diagnostic without re-parsing.
10430 let d = dep_with_fonte(DepSource::Path {
10431 caminho: "../caixa-teia & sleep 1".into(),
10432 });
10433 let rendered = d.validate().unwrap_err().to_string();
10434 assert!(
10435 rendered.contains("caixa-teia"),
10436 "diagnostic must name the offending dep: {rendered}",
10437 );
10438 assert!(
10439 rendered.contains("../caixa-teia & sleep 1"),
10440 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10441 );
10442 assert!(
10443 rendered.contains('&'),
10444 "diagnostic must reference the ampersand footgun: {rendered:?}",
10445 );
10446 assert!(
10447 rendered.contains("background") || rendered.contains("list-AND"),
10448 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10449 );
10450 }
10451
10452 #[test]
10453 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10454 // The fail-before-pass-after pin for the canonical shell-
10455 // command-substitution paste footgun: an author copies a
10456 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10457 // — the canonical "I pasted a path that included a `pwd`
10458 // / `whoami` / `date` legacy command-substitution expansion
10459 // out of a shell-history block") and silently passed every
10460 // prior arm (`Path::is_absolute` false on `..`, no control
10461 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10462 // end in `/`). The lacre embedded the value verbatim, the
10463 // resolver folded it through `Path::join` looking for a
10464 // literal `./../caixa-teia/`whoami`` subdirectory, and the
10465 // failure surfaced at resolve time with a non-self-locating
10466 // `No such file or directory` error. The new arm moves the
10467 // rejection to validate time and names the offending dep +
10468 // caminho verbatim.
10469 let d = dep_with_fonte(DepSource::Path {
10470 caminho: "../caixa-teia/`whoami`".into(),
10471 });
10472 let err = d.validate().unwrap_err();
10473 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10474 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10475 };
10476 assert_eq!(nome, "caixa-teia");
10477 assert_eq!(caminho, "../caixa-teia/`whoami`");
10478 }
10479
10480 #[test]
10481 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10482 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10483 // the canonical `<backtick>pwd<backtick>/path` working-
10484 // directory expansion shape every shell-side path-composition
10485 // idiom carries). Pinned separately from the embedded-byte
10486 // shape so the gate covers every position, not only mid-path.
10487 let d = dep_with_fonte(DepSource::Path {
10488 caminho: "`pwd`/caixa-teia".into(),
10489 });
10490 let err = d.validate().unwrap_err();
10491 assert!(
10492 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10493 "got {err:?}",
10494 );
10495 }
10496
10497 #[test]
10498 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10499 // Trailing-position backtick shape (`"../caixa-teia`"` — the
10500 // degenerate "I selected an unbalanced backtick out of a
10501 // shell-history block" idiom that probes for the cascade's
10502 // last-byte handling). The trailing-`/` arm fires only on
10503 // last-byte `/`; an unbalanced trailing backtick must route
10504 // through this arm regardless of position.
10505 let d = dep_with_fonte(DepSource::Path {
10506 caminho: "../caixa-teia`".into(),
10507 });
10508 let err = d.validate().unwrap_err();
10509 assert!(
10510 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10511 "got {err:?}",
10512 );
10513 }
10514
10515 #[test]
10516 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10517 // The canonical balanced-pair shape (``"../<backtick>cat
10518 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10519 // command-injection paste idiom every shell-side hardening
10520 // guide enumerates first). The arm fires on the first
10521 // backtick encountered; pinned so a future arm that tries to
10522 // distinguish the opening from the closing byte doesn't break
10523 // the broader contract.
10524 let d = dep_with_fonte(DepSource::Path {
10525 caminho: "../`cat /etc/passwd`".into(),
10526 });
10527 let err = d.validate().unwrap_err();
10528 assert!(
10529 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10530 "got {err:?}",
10531 );
10532 }
10533
10534 #[test]
10535 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10536 // The positive-control pin: the gate targets only the
10537 // backtick byte, never adjacent printable ASCII or POSIX-
10538 // valid bytes. The canonical relative POSIX path
10539 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10540 // adjacent printable punctuation
10541 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10542 // cleanly so the gate doesn't widen to a "no printable
10543 // punctuation anywhere" sweep that would defeat the entire
10544 // path-fonte author surface.
10545 let d = dep_with_fonte(DepSource::Path {
10546 caminho: "../caixa-teia/sub-dir.v2".into(),
10547 });
10548 d.validate().unwrap();
10549 }
10550
10551 #[test]
10552 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10553 // Cascade pin on the immediate-predecessor arm: a value
10554 // carrying both `&` and a backtick (``"../caixa-teia &
10555 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10556 // `cmd & <backtick>sleep N<backtick>` background-launch +
10557 // command-substitution chain" footgun) routes through
10558 // `FonteCaminhoShellBackground` not
10559 // `FonteCaminhoShellCommandSubstitution`. The background-
10560 // launch tail is the more common shell-history paste idiom
10561 // on every probe-as-both value — same cascade discipline
10562 // every prior `:caminho` arm establishes.
10563 let d = dep_with_fonte(DepSource::Path {
10564 caminho: "../caixa-teia & `sleep 1`".into(),
10565 });
10566 let err = d.validate().unwrap_err();
10567 assert!(
10568 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10569 "got {err:?}",
10570 );
10571 }
10572
10573 #[test]
10574 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10575 // Cascade pin on the upstream shell-semicolon arm: a value
10576 // carrying both `;` and a backtick (``"../caixa-teia;
10577 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10578 // `cmd; <backtick>follow-up<backtick>` sequential-chain
10579 // footgun) routes through `FonteCaminhoShellSemicolon` not
10580 // `FonteCaminhoShellCommandSubstitution`. The sequential-
10581 // command-separator paste is the load-bearing root-cause
10582 // edit on every probe-as-both value.
10583 let d = dep_with_fonte(DepSource::Path {
10584 caminho: "../caixa-teia; `whoami`".into(),
10585 });
10586 let err = d.validate().unwrap_err();
10587 assert!(
10588 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10589 "got {err:?}",
10590 );
10591 }
10592
10593 #[test]
10594 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10595 // Cascade pin on the upstream shell-pipe arm: a value
10596 // carrying both `|` and a backtick (``"../caixa-teia |
10597 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10598 // command-substitution paste idiom) routes through
10599 // `FonteCaminhoShellPipe` not
10600 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10601 // paste is the load-bearing root-cause edit on every
10602 // probe-as-both value.
10603 let d = dep_with_fonte(DepSource::Path {
10604 caminho: "../caixa-teia | `tee log`".into(),
10605 });
10606 let err = d.validate().unwrap_err();
10607 assert!(
10608 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10609 "got {err:?}",
10610 );
10611 }
10612
10613 #[test]
10614 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10615 // Cascade pin on the upstream shell-redirection arm: a value
10616 // carrying both `>` and a backtick (``"../caixa-teia>log
10617 // <backtick>date<backtick>"`` — the canonical "I pasted a
10618 // `cmd > log <backtick>date<backtick>` redirect-plus-
10619 // substitution chain" footgun) routes through
10620 // `FonteCaminhoShellRedirection` not
10621 // `FonteCaminhoShellCommandSubstitution`. The input/output
10622 // redirection metachar carries the more self-locating `byte`
10623 // payload (it names which of `<` or `>` triggered), so the
10624 // prior arm wins on every probe-as-both value.
10625 let d = dep_with_fonte(DepSource::Path {
10626 caminho: "../caixa-teia>log `date`".into(),
10627 });
10628 let err = d.validate().unwrap_err();
10629 assert!(
10630 matches!(
10631 err,
10632 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10633 ),
10634 "got {err:?}",
10635 );
10636 }
10637
10638 #[test]
10639 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10640 // Cascade pin on the upstream backslash arm: a value
10641 // carrying both `\` and a backtick (``"..\caixa-teia
10642 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10643 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10644 // chain") routes through `FonteCaminhoBackslash` not
10645 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10646 // separator divergence is the load-bearing axis on every
10647 // probe-as-both value (an author who removes the `\` is the
10648 // root-cause edit; the backtick falls away in the same edit
10649 // since it's downstream of the Windows-shell convention).
10650 let d = dep_with_fonte(DepSource::Path {
10651 caminho: "..\\caixa-teia `whoami`".into(),
10652 });
10653 let err = d.validate().unwrap_err();
10654 assert!(
10655 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10656 "got {err:?}",
10657 );
10658 }
10659
10660 #[test]
10661 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10662 // Cascade pin on the embedded-control-byte arm: a value
10663 // carrying both a control byte and a backtick (`"../foo\n
10664 // `whoami`"` — the canonical paste-from-multiline-doc
10665 // footgun where a newline landed mid-caminho between two
10666 // paste fragments) routes through `FonteCaminhoControlChar`
10667 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10668 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10669 // is the load-bearing axis on every value that probes
10670 // positive for both — mirrors the cascade discipline on
10671 // every prior arm.
10672 let d = dep_with_fonte(DepSource::Path {
10673 caminho: "../foo\n`whoami`".into(),
10674 });
10675 let err = d.validate().unwrap_err();
10676 assert!(
10677 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10678 "got {err:?}",
10679 );
10680 }
10681
10682 #[test]
10683 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10684 // Cascade pin on the load-bearing leading-byte arm: a
10685 // leading `/` value with embedded backtick (``"/etc/passwd
10686 // <backtick>whoami<backtick>"``) routes through
10687 // `FonteCaminhoAbsolute` not
10688 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10689 // leak diagnostic is the load-bearing axis, the backtick
10690 // byte is the secondary observation. Same precedence logic
10691 // as every prior leading-byte arm.
10692 let d = dep_with_fonte(DepSource::Path {
10693 caminho: "/etc/passwd `whoami`".into(),
10694 });
10695 let err = d.validate().unwrap_err();
10696 assert!(
10697 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10698 "got {err:?}",
10699 );
10700 }
10701
10702 #[test]
10703 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10704 // Cascade pin on the immediate-successor arm: a value
10705 // carrying both a backtick and a trailing `/`
10706 // (``"../`whoami`/"`` — the canonical "I tab-completed a
10707 // path that already had a backticked `whoami` substitution
10708 // tail" footgun) routes through
10709 // `FonteCaminhoShellCommandSubstitution` not
10710 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10711 // is the more semantic-locating axis (an author who removes
10712 // the backtick typically also drops the trailing separator
10713 // since both are paste-from-shell artifacts).
10714 let d = dep_with_fonte(DepSource::Path {
10715 caminho: "../`whoami`/".into(),
10716 });
10717 let err = d.validate().unwrap_err();
10718 assert!(
10719 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10720 "got {err:?}",
10721 );
10722 }
10723
10724 #[test]
10725 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10726 // Diagnostic-shape pin (peer with
10727 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10728 // on the closest single-byte peer arm): the error's Display
10729 // surfaces the offending `:nome` and the offending `:caminho`
10730 // verbatim, and names the shell-command-substitution footgun
10731 // explicitly so a `feira lint` run can render the diagnostic
10732 // without re-parsing.
10733 let d = dep_with_fonte(DepSource::Path {
10734 caminho: "../caixa-teia/`whoami`".into(),
10735 });
10736 let rendered = d.validate().unwrap_err().to_string();
10737 assert!(
10738 rendered.contains("caixa-teia"),
10739 "diagnostic must name the offending dep: {rendered}",
10740 );
10741 assert!(
10742 rendered.contains("../caixa-teia/`whoami`"),
10743 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10744 );
10745 assert!(
10746 rendered.contains('`'),
10747 "diagnostic must reference the backtick footgun: {rendered:?}",
10748 );
10749 assert!(
10750 rendered.contains("command-substitution"),
10751 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10752 );
10753 }
10754
10755 #[test]
10756 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10757 // The fail-before-pass-after pin for the canonical pathname-
10758 // expansion paste footgun: an author copies an `ls
10759 // ../caixa-teia/*` shell-listing tail into the `:caminho`
10760 // slot and silently passes every prior arm
10761 // (`Path::is_absolute` false on `..`, no control bytes, no
10762 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10763 // doesn't end in `/`). The lacre embedded the value
10764 // verbatim, the resolver folded it through `Path::join`
10765 // looking for a literal `./../caixa-teia/*` subdirectory,
10766 // and the failure surfaced at resolve time with a non-self-
10767 // locating `No such file or directory` error. The new arm
10768 // moves the rejection to validate time and names the
10769 // offending dep + caminho + byte verbatim.
10770 let d = dep_with_fonte(DepSource::Path {
10771 caminho: "../caixa-teia/*".into(),
10772 });
10773 let err = d.validate().unwrap_err();
10774 let DepError::FonteCaminhoShellGlob {
10775 nome,
10776 caminho,
10777 byte,
10778 } = err
10779 else {
10780 panic!("expected FonteCaminhoShellGlob, got {err:?}");
10781 };
10782 assert_eq!(nome, "caixa-teia");
10783 assert_eq!(caminho, "../caixa-teia/*");
10784 assert_eq!(byte, b'*');
10785 }
10786
10787 #[test]
10788 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10789 // The symmetric single-char-wildcard paste shape
10790 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10791 // out of shell history" idiom). Pinned separately from the
10792 // `*` shape so the gate's contract is "any `*` or `?`
10793 // anywhere", not single-byte coverage.
10794 let d = dep_with_fonte(DepSource::Path {
10795 caminho: "../foo?".into(),
10796 });
10797 let err = d.validate().unwrap_err();
10798 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10799 panic!("expected FonteCaminhoShellGlob, got {err:?}");
10800 };
10801 assert_eq!(byte, b'?');
10802 }
10803
10804 #[test]
10805 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10806 // Leading-position `*` shape (`"*/caixa-teia"` — the
10807 // degenerate "I selected only the wildcard prefix out of a
10808 // shell-glob expression" idiom). Pinned separately from the
10809 // embedded-byte shapes so the gate covers every position,
10810 // not only mid-path.
10811 let d = dep_with_fonte(DepSource::Path {
10812 caminho: "*/caixa-teia".into(),
10813 });
10814 let err = d.validate().unwrap_err();
10815 assert!(
10816 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10817 "got {err:?}",
10818 );
10819 }
10820
10821 #[test]
10822 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10823 // The bash/zsh `globstar` recursive-glob shape
10824 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10825 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10826 // The arm fires on the first `*` encountered; pinned so a
10827 // future arm that tries to distinguish single `*` from
10828 // double `**` doesn't break the broader contract.
10829 let d = dep_with_fonte(DepSource::Path {
10830 caminho: "../caixa-teia/**/foo".into(),
10831 });
10832 let err = d.validate().unwrap_err();
10833 assert!(
10834 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10835 "got {err:?}",
10836 );
10837 }
10838
10839 #[test]
10840 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10841 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10842 // — the "I selected `*.lisp` to mean every Lisp source file
10843 // in the dep root" footgun the prior arms structurally
10844 // cannot catch since `.` is a POSIX-valid path-component
10845 // byte). Pinned so the gate's contract covers the most
10846 // idiomatic glob-paste shape every author meets first.
10847 let d = dep_with_fonte(DepSource::Path {
10848 caminho: "../caixa-teia/*.lisp".into(),
10849 });
10850 let err = d.validate().unwrap_err();
10851 assert!(
10852 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10853 "got {err:?}",
10854 );
10855 }
10856
10857 #[test]
10858 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10859 // The positive-control pin: the gate targets only `*` /
10860 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10861 // The canonical relative POSIX path (`"../caixa-teia"`) and
10862 // a nested deeply-pathed variant with adjacent printable
10863 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10864 // to validate cleanly so the gate doesn't widen to a "no
10865 // printable punctuation anywhere" sweep that would defeat
10866 // the entire path-fonte author surface.
10867 let d = dep_with_fonte(DepSource::Path {
10868 caminho: "../caixa-teia/sub-dir.v2".into(),
10869 });
10870 d.validate().unwrap();
10871 }
10872
10873 #[test]
10874 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10875 // Cascade pin on the immediate-predecessor arm: a value
10876 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10877 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10878 // command-substitution + glob chain") routes through
10879 // `FonteCaminhoShellCommandSubstitution` not
10880 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
10881 // injection vector is the load-bearing root-cause edit on
10882 // every probe-as-both value — same cascade discipline every
10883 // prior `:caminho` arm establishes.
10884 let d = dep_with_fonte(DepSource::Path {
10885 caminho: "../`whoami`/*".into(),
10886 });
10887 let err = d.validate().unwrap_err();
10888 assert!(
10889 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10890 "got {err:?}",
10891 );
10892 }
10893
10894 #[test]
10895 fn fonte_caminho_shell_background_fires_before_shell_glob() {
10896 // Cascade pin on the upstream shell-background arm: a value
10897 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
10898 // canonical "I pasted a `cmd & ls /*` background + glob
10899 // chain" footgun) routes through `FonteCaminhoShellBackground`
10900 // not `FonteCaminhoShellGlob`. The background-launch tail is
10901 // the load-bearing root-cause edit on every probe-as-both
10902 // value.
10903 let d = dep_with_fonte(DepSource::Path {
10904 caminho: "../caixa-teia & ls /*".into(),
10905 });
10906 let err = d.validate().unwrap_err();
10907 assert!(
10908 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10909 "got {err:?}",
10910 );
10911 }
10912
10913 #[test]
10914 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
10915 // Cascade pin on the upstream shell-semicolon arm: a value
10916 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
10917 // canonical sequential-cleanup + glob paste idiom) routes
10918 // through `FonteCaminhoShellSemicolon` not
10919 // `FonteCaminhoShellGlob`. The sequential-command-separator
10920 // paste is the load-bearing root-cause edit on every
10921 // probe-as-both value.
10922 let d = dep_with_fonte(DepSource::Path {
10923 caminho: "../caixa-teia; rm *".into(),
10924 });
10925 let err = d.validate().unwrap_err();
10926 assert!(
10927 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10928 "got {err:?}",
10929 );
10930 }
10931
10932 #[test]
10933 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
10934 // Cascade pin on the upstream shell-pipe arm: a value
10935 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
10936 // canonical pipeline-to-glob paste idiom) routes through
10937 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
10938 // pipeline-tail paste is the load-bearing root-cause edit
10939 // on every probe-as-both value.
10940 let d = dep_with_fonte(DepSource::Path {
10941 caminho: "../caixa-teia | ls *".into(),
10942 });
10943 let err = d.validate().unwrap_err();
10944 assert!(
10945 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10946 "got {err:?}",
10947 );
10948 }
10949
10950 #[test]
10951 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
10952 // Cascade pin on the upstream shell-redirection arm: a value
10953 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
10954 // canonical "I pasted a `cmd > log *` redirect-plus-glob
10955 // chain" footgun) routes through
10956 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
10957 // The input/output redirection metachar carries the more
10958 // self-locating `byte` payload (it names which of `<` or `>`
10959 // triggered), so the prior arm wins on every probe-as-both
10960 // value.
10961 let d = dep_with_fonte(DepSource::Path {
10962 caminho: "../caixa-teia>log *".into(),
10963 });
10964 let err = d.validate().unwrap_err();
10965 assert!(
10966 matches!(
10967 err,
10968 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10969 ),
10970 "got {err:?}",
10971 );
10972 }
10973
10974 #[test]
10975 fn fonte_caminho_backslash_fires_before_shell_glob() {
10976 // Cascade pin on the upstream backslash arm: a value
10977 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
10978 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
10979 // expression" footgun) routes through
10980 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
10981 // cross-host-OS-separator divergence is the load-bearing
10982 // axis on every probe-as-both value (an author who removes
10983 // the `\` is the root-cause edit; the `*` falls away in the
10984 // same edit since it's downstream of the Windows-shell
10985 // convention).
10986 let d = dep_with_fonte(DepSource::Path {
10987 caminho: "..\\caixa-teia\\*".into(),
10988 });
10989 let err = d.validate().unwrap_err();
10990 assert!(
10991 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10992 "got {err:?}",
10993 );
10994 }
10995
10996 #[test]
10997 fn fonte_caminho_control_char_fires_before_shell_glob() {
10998 // Cascade pin on the embedded-control-byte arm: a value
10999 // carrying both a control byte and `*` (`"../foo\n*"` — the
11000 // canonical paste-from-multiline-doc footgun where a
11001 // newline landed mid-caminho between two paste fragments)
11002 // routes through `FonteCaminhoControlChar` not
11003 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11004 // NUL-`CString::new`-fail diagnostic is the load-bearing
11005 // axis on every value that probes positive for both —
11006 // mirrors the cascade discipline on every prior arm.
11007 let d = dep_with_fonte(DepSource::Path {
11008 caminho: "../foo\n*".into(),
11009 });
11010 let err = d.validate().unwrap_err();
11011 assert!(
11012 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11013 "got {err:?}",
11014 );
11015 }
11016
11017 #[test]
11018 fn fonte_caminho_absolute_fires_before_shell_glob() {
11019 // Cascade pin on the load-bearing leading-byte arm: a
11020 // leading `/` value with embedded `*` (`"/etc/*"`) routes
11021 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11022 // — the host-layout-leak diagnostic is the load-bearing
11023 // axis, the glob byte is the secondary observation. Same
11024 // precedence logic as every prior leading-byte arm.
11025 let d = dep_with_fonte(DepSource::Path {
11026 caminho: "/etc/*".into(),
11027 });
11028 let err = d.validate().unwrap_err();
11029 assert!(
11030 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11031 "got {err:?}",
11032 );
11033 }
11034
11035 #[test]
11036 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11037 // Cascade pin on the immediate-successor arm: a value
11038 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11039 // canonical "I tab-completed a path that already had a
11040 // glob-expansion tail" footgun) routes through
11041 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11042 // The embedded shell-metachar is the more semantic-locating
11043 // axis (an author who removes the `*` typically also drops
11044 // the trailing separator since both are paste-from-shell
11045 // artifacts).
11046 let d = dep_with_fonte(DepSource::Path {
11047 caminho: "../foo*/".into(),
11048 });
11049 let err = d.validate().unwrap_err();
11050 assert!(
11051 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11052 "got {err:?}",
11053 );
11054 }
11055
11056 #[test]
11057 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11058 // Diagnostic-shape pin (peer with
11059 // `fonte_caminho_shell_redirection_diagnostic_*` on the
11060 // closest two-byte peer arm): the error's Display surfaces
11061 // the offending `:nome`, the offending `:caminho` verbatim,
11062 // the offending byte's hex / character form, and names the
11063 // shell-glob / pathname-expansion footgun explicitly so a
11064 // `feira lint` run can render the diagnostic without
11065 // re-parsing.
11066 let d = dep_with_fonte(DepSource::Path {
11067 caminho: "../caixa-teia/*.lisp".into(),
11068 });
11069 let rendered = d.validate().unwrap_err().to_string();
11070 assert!(
11071 rendered.contains("caixa-teia"),
11072 "diagnostic must name the offending dep: {rendered}",
11073 );
11074 assert!(
11075 rendered.contains("../caixa-teia/*.lisp"),
11076 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11077 );
11078 assert!(
11079 rendered.contains("0x2a"),
11080 "diagnostic must surface the offending byte hex: {rendered:?}",
11081 );
11082 assert!(
11083 rendered.contains("glob"),
11084 "diagnostic must name the shell-glob footgun: {rendered:?}",
11085 );
11086 assert!(
11087 rendered.contains("pathname-expansion"),
11088 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11089 );
11090 }
11091
11092 #[test]
11093 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11094 // The fail-before-pass-after pin for the canonical modern-Bourne
11095 // command-substitution paste footgun: an author copies a
11096 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11097 // `$(<cmd>)` expansion would land the current date as a
11098 // subdirectory name and silently passed every prior arm
11099 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11100 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11101 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11102 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11103 // sits mid-path). The lacre embedded the value verbatim, the
11104 // resolver folded it through `Path::join` looking for a literal
11105 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11106 // surfaced at resolve time with a non-self-locating `No such
11107 // file or directory` error. The new arm moves the rejection to
11108 // validate time and names the offending dep + caminho + byte
11109 // verbatim. The arm fires on the first `(` encountered (the
11110 // opening byte of `$(date)`).
11111 let d = dep_with_fonte(DepSource::Path {
11112 caminho: "../caixa-teia/$(date)/build".into(),
11113 });
11114 let err = d.validate().unwrap_err();
11115 let DepError::FonteCaminhoShellSubshellGrouping {
11116 nome,
11117 caminho,
11118 byte,
11119 } = err
11120 else {
11121 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11122 };
11123 assert_eq!(nome, "caixa-teia");
11124 assert_eq!(caminho, "../caixa-teia/$(date)/build");
11125 assert_eq!(byte, b'(');
11126 }
11127
11128 #[test]
11129 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11130 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11131 // the degenerate "I selected an unbalanced closing paren out of
11132 // a shell-history block" idiom that probes for the cascade's
11133 // last-byte handling on a value carrying only the closing byte).
11134 // Pinned separately from the open-paren shape so the gate's
11135 // contract is "any `(` or `)` anywhere", not single-byte
11136 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11137 // caminho_carrying_question_glob` shape on the immediate-
11138 // predecessor `FonteCaminhoShellGlob` arm.
11139 let d = dep_with_fonte(DepSource::Path {
11140 caminho: "../caixa-teia)".into(),
11141 });
11142 let err = d.validate().unwrap_err();
11143 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11144 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11145 };
11146 assert_eq!(byte, b')');
11147 }
11148
11149 #[test]
11150 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11151 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11152 // canonical "I selected a `(cd foo)` subshell-grouping prefix
11153 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11154 // Pinned separately from the embedded-byte shape so the gate
11155 // covers every position, not only mid-path.
11156 let d = dep_with_fonte(DepSource::Path {
11157 caminho: "(cd foo)/caixa-teia".into(),
11158 });
11159 let err = d.validate().unwrap_err();
11160 assert!(
11161 matches!(
11162 err,
11163 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11164 ),
11165 "got {err:?}",
11166 );
11167 }
11168
11169 #[test]
11170 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11171 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11172 // — the canonical "I copied a `(pwd)` working-directory-probe
11173 // subshell-grouping idiom every shell-history block carries"
11174 // footgun). The value carries no other cascade-preceding
11175 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11176 // `*` / `?`) so the arm fires on the first `(` encountered;
11177 // pinned so a future arm that tries to distinguish the
11178 // opening from the closing byte doesn't break the broader
11179 // contract. Mirrors the peer
11180 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11181 // backtick_pair` shape on the upstream `FonteCaminhoShell\
11182 // CommandSubstitution` arm.
11183 let d = dep_with_fonte(DepSource::Path {
11184 caminho: "../(pwd)/caixa-teia".into(),
11185 });
11186 let err = d.validate().unwrap_err();
11187 assert!(
11188 matches!(
11189 err,
11190 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11191 ),
11192 "got {err:?}",
11193 );
11194 }
11195
11196 #[test]
11197 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11198 // The positive-control pin: the gate targets only `(` / `)`,
11199 // never adjacent printable ASCII or POSIX-valid bytes. The
11200 // canonical relative POSIX path (`"../caixa-teia"`) and a
11201 // nested deeply-pathed variant with adjacent printable
11202 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11203 // validate cleanly so the gate doesn't widen to a "no printable
11204 // punctuation anywhere" sweep that would defeat the entire
11205 // path-fonte author surface.
11206 let d = dep_with_fonte(DepSource::Path {
11207 caminho: "../caixa-teia/sub-dir.v2".into(),
11208 });
11209 d.validate().unwrap();
11210 }
11211
11212 #[test]
11213 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11214 // Cascade pin on the immediate-predecessor arm: a value
11215 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11216 // canonical "I pasted a glob expansion followed by a
11217 // subshell-grouping tail" footgun) routes through
11218 // `FonteCaminhoShellGlob` not
11219 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11220 // shape is the more common shell-history paste idiom on every
11221 // probe-as-both value — same cascade discipline every prior
11222 // `:caminho` arm establishes.
11223 let d = dep_with_fonte(DepSource::Path {
11224 caminho: "../caixa-teia/*(date)".into(),
11225 });
11226 let err = d.validate().unwrap_err();
11227 assert!(
11228 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11229 "got {err:?}",
11230 );
11231 }
11232
11233 #[test]
11234 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11235 // Cascade pin on the upstream shell-command-substitution arm: a
11236 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11237 // — the canonical "I pasted a legacy-backtick + modern-paren
11238 // command-substitution chain" footgun) routes through
11239 // `FonteCaminhoShellCommandSubstitution` not
11240 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11241 // command-injection vector is the load-bearing root-cause edit
11242 // on every probe-as-both value.
11243 let d = dep_with_fonte(DepSource::Path {
11244 caminho: "../`whoami`/$(date)".into(),
11245 });
11246 let err = d.validate().unwrap_err();
11247 assert!(
11248 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11249 "got {err:?}",
11250 );
11251 }
11252
11253 #[test]
11254 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11255 // Cascade pin on the upstream shell-background arm: a value
11256 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11257 // the canonical "I pasted a `cmd & (cd foo)` background-launch
11258 // + subshell-grouping chain" footgun) routes through
11259 // `FonteCaminhoShellBackground` not
11260 // `FonteCaminhoShellSubshellGrouping`. The background-launch
11261 // tail is the load-bearing root-cause edit on every probe-as-
11262 // both value.
11263 let d = dep_with_fonte(DepSource::Path {
11264 caminho: "../caixa-teia & (cd foo)".into(),
11265 });
11266 let err = d.validate().unwrap_err();
11267 assert!(
11268 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11269 "got {err:?}",
11270 );
11271 }
11272
11273 #[test]
11274 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11275 // Cascade pin on the upstream shell-semicolon arm: a value
11276 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11277 // the canonical sequential-cleanup + subshell-grouping paste
11278 // idiom) routes through `FonteCaminhoShellSemicolon` not
11279 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11280 // separator paste is the load-bearing root-cause edit on
11281 // every probe-as-both value.
11282 let d = dep_with_fonte(DepSource::Path {
11283 caminho: "../caixa-teia; (cd foo)".into(),
11284 });
11285 let err = d.validate().unwrap_err();
11286 assert!(
11287 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11288 "got {err:?}",
11289 );
11290 }
11291
11292 #[test]
11293 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11294 // Cascade pin on the upstream shell-pipe arm: a value carrying
11295 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11296 // canonical pipeline-to-subshell-grouping paste idiom) routes
11297 // through `FonteCaminhoShellPipe` not
11298 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11299 // is the load-bearing root-cause edit on every probe-as-both
11300 // value.
11301 let d = dep_with_fonte(DepSource::Path {
11302 caminho: "../caixa-teia | (tee log)".into(),
11303 });
11304 let err = d.validate().unwrap_err();
11305 assert!(
11306 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11307 "got {err:?}",
11308 );
11309 }
11310
11311 #[test]
11312 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11313 // Cascade pin on the upstream shell-redirection arm: a value
11314 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11315 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11316 // plus-subshell-grouping chain" footgun) routes through
11317 // `FonteCaminhoShellRedirection` not
11318 // `FonteCaminhoShellSubshellGrouping`. The input/output
11319 // redirection metachar carries the more self-locating `byte`
11320 // payload (it names which of `<` or `>` triggered), so the
11321 // prior arm wins on every probe-as-both value.
11322 let d = dep_with_fonte(DepSource::Path {
11323 caminho: "../caixa-teia>log (cd foo)".into(),
11324 });
11325 let err = d.validate().unwrap_err();
11326 assert!(
11327 matches!(
11328 err,
11329 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11330 ),
11331 "got {err:?}",
11332 );
11333 }
11334
11335 #[test]
11336 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11337 // Cascade pin on the upstream backslash arm: a value carrying
11338 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11339 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11340 // through `FonteCaminhoBackslash` not
11341 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11342 // separator divergence is the load-bearing axis on every
11343 // probe-as-both value (an author who removes the `\` is the
11344 // root-cause edit; the `(` falls away in the same edit since
11345 // it's downstream of the Windows-shell convention).
11346 let d = dep_with_fonte(DepSource::Path {
11347 caminho: "..\\caixa-teia\\(cd foo)".into(),
11348 });
11349 let err = d.validate().unwrap_err();
11350 assert!(
11351 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11352 "got {err:?}",
11353 );
11354 }
11355
11356 #[test]
11357 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11358 // Cascade pin on the embedded-control-byte arm: a value
11359 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11360 // the canonical paste-from-multiline-doc footgun where a
11361 // newline landed mid-caminho between two paste fragments)
11362 // routes through `FonteCaminhoControlChar` not
11363 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11364 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11365 // load-bearing axis on every value that probes positive for
11366 // both — mirrors the cascade discipline on every prior arm.
11367 let d = dep_with_fonte(DepSource::Path {
11368 caminho: "../foo\n(cd bar)".into(),
11369 });
11370 let err = d.validate().unwrap_err();
11371 assert!(
11372 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11373 "got {err:?}",
11374 );
11375 }
11376
11377 #[test]
11378 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11379 // Cascade pin on the load-bearing leading-byte arm: a leading
11380 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11381 // through `FonteCaminhoAbsolute` not
11382 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11383 // diagnostic is the load-bearing axis, the subshell-grouping
11384 // byte is the secondary observation. Same precedence logic as
11385 // every prior leading-byte arm.
11386 let d = dep_with_fonte(DepSource::Path {
11387 caminho: "/etc/(cd foo)".into(),
11388 });
11389 let err = d.validate().unwrap_err();
11390 assert!(
11391 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11392 "got {err:?}",
11393 );
11394 }
11395
11396 #[test]
11397 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11398 // Cascade pin on the upstream leading-`$` var-expansion arm: a
11399 // value carrying both a leading `$` and a `(` (`"$(date)/\
11400 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11401 // command-substitution at the head of a sibling-workspace
11402 // path" footgun) routes through `FonteCaminhoVarExpansion` not
11403 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11404 // shell-variable-expansion is the more self-locating diagnostic
11405 // on values that probe as both — same load-bearing-leading-
11406 // byte cascade discipline every prior `:caminho` arm
11407 // establishes. Closing both halves of `$(<cmd>)` structurally
11408 // (leading `$` here, trailing `)` on the new arm) excludes the
11409 // entire modern Bourne command-substitution surface from the
11410 // typed `:caminho` accepted set; the cascade preserves the
11411 // narrower leading-byte diagnostic on values that probe both
11412 // halves at the canonical leading position.
11413 let d = dep_with_fonte(DepSource::Path {
11414 caminho: "$(date)/caixa-teia".into(),
11415 });
11416 let err = d.validate().unwrap_err();
11417 assert!(
11418 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11419 "got {err:?}",
11420 );
11421 }
11422
11423 #[test]
11424 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11425 // Cascade pin on the immediate-successor arm: a value carrying
11426 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11427 // "I tab-completed a path that already had a subshell-grouping
11428 // expansion tail" footgun) routes through
11429 // `FonteCaminhoShellSubshellGrouping` not
11430 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11431 // the more semantic-locating axis (an author who removes the
11432 // `(` typically also drops the trailing separator since both
11433 // are paste-from-shell artifacts).
11434 let d = dep_with_fonte(DepSource::Path {
11435 caminho: "../(cd foo)/".into(),
11436 });
11437 let err = d.validate().unwrap_err();
11438 assert!(
11439 matches!(
11440 err,
11441 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11442 ),
11443 "got {err:?}",
11444 );
11445 }
11446
11447 #[test]
11448 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11449 // Diagnostic-shape pin (peer with
11450 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11451 // on the closest two-byte peer arm): the error's Display
11452 // surfaces the offending `:nome`, the offending `:caminho`
11453 // verbatim, the offending byte's hex / character form, and
11454 // names the shell-subshell-grouping footgun explicitly so a
11455 // `feira lint` run can render the diagnostic without re-
11456 // parsing.
11457 let d = dep_with_fonte(DepSource::Path {
11458 caminho: "../caixa-teia/$(date)/build".into(),
11459 });
11460 let rendered = d.validate().unwrap_err().to_string();
11461 assert!(
11462 rendered.contains("caixa-teia"),
11463 "diagnostic must name the offending dep: {rendered}",
11464 );
11465 assert!(
11466 rendered.contains("../caixa-teia/$(date)/build"),
11467 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11468 );
11469 assert!(
11470 rendered.contains("0x28"),
11471 "diagnostic must surface the offending byte hex: {rendered:?}",
11472 );
11473 assert!(
11474 rendered.contains("subshell-grouping"),
11475 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11476 );
11477 assert!(
11478 rendered.contains("command-substitution"),
11479 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11480 {rendered:?}",
11481 );
11482 }
11483
11484 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11485 //
11486 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11487 // `)`) byte-pair arm: the same per-byte cascade with the same
11488 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11489 // `}` brace-expansion / URI-Template placeholder axis. The peer
11490 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11491 // byte pair on the sibling `:fonte :repo` axis under the same
11492 // banner.
11493
11494 #[test]
11495 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11496 // The fail-before-pass-after pin for the canonical paste-from-
11497 // shell-history brace-expansion footgun: an author copies a
11498 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11499 // liner whose `{a,b}` brace expansion fans across two siblings
11500 // and silently passed every prior arm (`Path::is_absolute`
11501 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11502 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11503 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11504 // `FonteCaminhoVarExpansion` arm doesn't fire because the
11505 // value starts with `..` not `$`). The lacre embedded the
11506 // value verbatim, the resolver folded it through `Path::join`
11507 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11508 // subdirectory, and the failure surfaced at resolve time with
11509 // a non-self-locating `No such file or directory` error. The
11510 // new arm moves the rejection to validate time and names the
11511 // offending dep + caminho + byte verbatim. The arm fires on
11512 // the first `{` encountered.
11513 let d = dep_with_fonte(DepSource::Path {
11514 caminho: "../{caixa-teia,caixa-helm}/build".into(),
11515 });
11516 let err = d.validate().unwrap_err();
11517 let DepError::FonteCaminhoShellBraceExpansion {
11518 nome,
11519 caminho,
11520 byte,
11521 } = err
11522 else {
11523 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11524 };
11525 assert_eq!(nome, "caixa-teia");
11526 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11527 assert_eq!(byte, b'{');
11528 }
11529
11530 #[test]
11531 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11532 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11533 // the degenerate "I selected an unbalanced closing brace out
11534 // of a shell-history block" idiom that probes for the
11535 // cascade's last-byte handling on a value carrying only the
11536 // closing byte). Pinned separately from the open-brace shape
11537 // so the gate's contract is "any `{` or `}` anywhere", not
11538 // single-byte coverage. Mirrors the peer
11539 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11540 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11541 // arm.
11542 let d = dep_with_fonte(DepSource::Path {
11543 caminho: "../caixa-teia}".into(),
11544 });
11545 let err = d.validate().unwrap_err();
11546 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11547 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11548 };
11549 assert_eq!(byte, b'}');
11550 }
11551
11552 #[test]
11553 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11554 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11555 // — the canonical "I selected a `{a,b}` brace-expansion prefix
11556 // out of a shell-history one-liner" idiom). Pinned separately
11557 // from the embedded-byte shape so the gate covers every
11558 // position, not only mid-path.
11559 let d = dep_with_fonte(DepSource::Path {
11560 caminho: "{caixa-teia,caixa-helm}/build".into(),
11561 });
11562 let err = d.validate().unwrap_err();
11563 assert!(
11564 matches!(
11565 err,
11566 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11567 ),
11568 "got {err:?}",
11569 );
11570 }
11571
11572 #[test]
11573 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11574 // The canonical URI-Template / Mustache / Helm doubled-brace
11575 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11576 // "I copied a `https://github.com/{{org}}/caixa-teia` README
11577 // quick-start / OpenAPI spec / Helm chart `home:` template
11578 // and forgot to substitute the placeholder" footgun). The arm
11579 // fires on the first `{` encountered; pinned so the gate's
11580 // coverage extends from the bare-brace shell-history shape to
11581 // the doubled-brace URI-Template / templating-engine shape.
11582 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11583 // sibling `:fonte :repo` axis.
11584 let d = dep_with_fonte(DepSource::Path {
11585 caminho: "../{{org}}/caixa-teia".into(),
11586 });
11587 let err = d.validate().unwrap_err();
11588 assert!(
11589 matches!(
11590 err,
11591 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11592 ),
11593 "got {err:?}",
11594 );
11595 }
11596
11597 #[test]
11598 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11599 // The canonical bash brace-range-expansion shape (`"../caixa-
11600 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11601 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11602 // sequence-range form to the `{a,b,c}` comma-separated form).
11603 // The arm fires on the first `{` encountered; pinned so the
11604 // gate's coverage extends from the comma-separated form to
11605 // the integer-range form.
11606 let d = dep_with_fonte(DepSource::Path {
11607 caminho: "../caixa-v{1..10}".into(),
11608 });
11609 let err = d.validate().unwrap_err();
11610 assert!(
11611 matches!(
11612 err,
11613 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11614 ),
11615 "got {err:?}",
11616 );
11617 }
11618
11619 #[test]
11620 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11621 // The positive-control pin: the gate targets only `{` / `}`,
11622 // never adjacent printable ASCII or POSIX-valid bytes. The
11623 // canonical relative POSIX path (`"../caixa-teia"`) and a
11624 // nested deeply-pathed variant with adjacent printable
11625 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11626 // validate cleanly so the gate doesn't widen to a "no
11627 // printable punctuation anywhere" sweep that would defeat
11628 // the entire path-fonte author surface. Peer with
11629 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11630 // on the immediate-predecessor arm.
11631 let d = dep_with_fonte(DepSource::Path {
11632 caminho: "../caixa-teia/sub-dir.v2".into(),
11633 });
11634 d.validate().unwrap();
11635 }
11636
11637 #[test]
11638 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11639 // Cascade pin on the immediate-predecessor arm: a value
11640 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11641 // canonical "I pasted a subshell-grouping followed by a
11642 // brace-expansion tail" footgun) routes through
11643 // `FonteCaminhoShellSubshellGrouping` not
11644 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11645 // shape is the more semantic-locating axis on every probe-
11646 // as-both value because it closes both halves of the modern
11647 // Bourne `$(<cmd>)` command-substitution surface — same
11648 // cascade discipline every prior `:caminho` arm establishes.
11649 let d = dep_with_fonte(DepSource::Path {
11650 caminho: "../(cd foo)/{a,b}".into(),
11651 });
11652 let err = d.validate().unwrap_err();
11653 assert!(
11654 matches!(
11655 err,
11656 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11657 ),
11658 "got {err:?}",
11659 );
11660 }
11661
11662 #[test]
11663 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11664 // Cascade pin on the upstream shell-glob arm: a value carrying
11665 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11666 // "I pasted a glob expansion followed by a brace-expansion
11667 // tail" footgun) routes through `FonteCaminhoShellGlob` not
11668 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11669 // shape is the load-bearing root-cause edit on every
11670 // probe-as-both value.
11671 let d = dep_with_fonte(DepSource::Path {
11672 caminho: "../caixa-teia/*{a,b}".into(),
11673 });
11674 let err = d.validate().unwrap_err();
11675 assert!(
11676 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11677 "got {err:?}",
11678 );
11679 }
11680
11681 #[test]
11682 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11683 // Cascade pin on the upstream shell-command-substitution arm:
11684 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11685 // — the canonical "I pasted a legacy-backtick command-
11686 // substitution followed by a brace-expansion fan-out" footgun)
11687 // routes through `FonteCaminhoShellCommandSubstitution` not
11688 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11689 // command-injection vector is the load-bearing root-cause
11690 // edit on every probe-as-both value.
11691 let d = dep_with_fonte(DepSource::Path {
11692 caminho: "../`whoami`/{a,b}".into(),
11693 });
11694 let err = d.validate().unwrap_err();
11695 assert!(
11696 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11697 "got {err:?}",
11698 );
11699 }
11700
11701 #[test]
11702 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11703 // Cascade pin on the upstream shell-background arm: a value
11704 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11705 // canonical "I pasted a `cmd & {fork-fan}` background-launch
11706 // + brace-expansion chain" footgun) routes through
11707 // `FonteCaminhoShellBackground` not
11708 // `FonteCaminhoShellBraceExpansion`. The background-launch
11709 // tail is the load-bearing root-cause edit on every
11710 // probe-as-both value.
11711 let d = dep_with_fonte(DepSource::Path {
11712 caminho: "../caixa-teia & {a,b}".into(),
11713 });
11714 let err = d.validate().unwrap_err();
11715 assert!(
11716 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11717 "got {err:?}",
11718 );
11719 }
11720
11721 #[test]
11722 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11723 // Cascade pin on the upstream shell-semicolon arm: a value
11724 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11725 // canonical sequential-cleanup + brace-expansion paste
11726 // idiom) routes through `FonteCaminhoShellSemicolon` not
11727 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11728 // separator paste is the load-bearing root-cause edit on
11729 // every probe-as-both value.
11730 let d = dep_with_fonte(DepSource::Path {
11731 caminho: "../caixa-teia; {a,b}".into(),
11732 });
11733 let err = d.validate().unwrap_err();
11734 assert!(
11735 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11736 "got {err:?}",
11737 );
11738 }
11739
11740 #[test]
11741 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11742 // Cascade pin on the upstream shell-pipe arm: a value
11743 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11744 // — the canonical pipeline-to-brace-expansion paste idiom)
11745 // routes through `FonteCaminhoShellPipe` not
11746 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11747 // is the load-bearing root-cause edit on every probe-as-
11748 // both value.
11749 let d = dep_with_fonte(DepSource::Path {
11750 caminho: "../caixa-teia | {tee,cat}".into(),
11751 });
11752 let err = d.validate().unwrap_err();
11753 assert!(
11754 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11755 "got {err:?}",
11756 );
11757 }
11758
11759 #[test]
11760 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11761 // Cascade pin on the upstream shell-redirection arm: a value
11762 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11763 // the canonical "I pasted a `cmd > log {a,b}` redirect-
11764 // plus-brace-expansion chain" footgun) routes through
11765 // `FonteCaminhoShellRedirection` not
11766 // `FonteCaminhoShellBraceExpansion`. The input/output
11767 // redirection metachar carries the more self-locating
11768 // `byte` payload, so the prior arm wins on every probe-
11769 // as-both value.
11770 let d = dep_with_fonte(DepSource::Path {
11771 caminho: "../caixa-teia>log {a,b}".into(),
11772 });
11773 let err = d.validate().unwrap_err();
11774 assert!(
11775 matches!(
11776 err,
11777 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11778 ),
11779 "got {err:?}",
11780 );
11781 }
11782
11783 #[test]
11784 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11785 // Cascade pin on the upstream backslash arm: a value
11786 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11787 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11788 // chain") routes through `FonteCaminhoBackslash` not
11789 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11790 // separator divergence is the load-bearing axis on every
11791 // probe-as-both value.
11792 let d = dep_with_fonte(DepSource::Path {
11793 caminho: "..\\caixa-teia\\{a,b}".into(),
11794 });
11795 let err = d.validate().unwrap_err();
11796 assert!(
11797 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11798 "got {err:?}",
11799 );
11800 }
11801
11802 #[test]
11803 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11804 // Cascade pin on the embedded-control-byte arm: a value
11805 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11806 // the canonical paste-from-multiline-doc footgun where a
11807 // newline landed mid-caminho between two paste fragments)
11808 // routes through `FonteCaminhoControlChar` not
11809 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11810 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11811 // load-bearing axis on every value that probes positive for
11812 // both — mirrors the cascade discipline on every prior arm.
11813 let d = dep_with_fonte(DepSource::Path {
11814 caminho: "../foo\n{a,b}".into(),
11815 });
11816 let err = d.validate().unwrap_err();
11817 assert!(
11818 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11819 "got {err:?}",
11820 );
11821 }
11822
11823 #[test]
11824 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11825 // Cascade pin on the load-bearing leading-byte arm: a
11826 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11827 // routes through `FonteCaminhoAbsolute` not
11828 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11829 // diagnostic is the load-bearing axis, the brace-expansion
11830 // byte is the secondary observation. Same precedence logic
11831 // as every prior leading-byte arm.
11832 let d = dep_with_fonte(DepSource::Path {
11833 caminho: "/etc/{a,b}".into(),
11834 });
11835 let err = d.validate().unwrap_err();
11836 assert!(
11837 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11838 "got {err:?}",
11839 );
11840 }
11841
11842 #[test]
11843 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11844 // Cascade pin on the upstream leading-`$` var-expansion
11845 // arm: a value carrying both a leading `$` and a `{`
11846 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11847 // `${ORG}` shell-variable + curly-brace expansion at the
11848 // head of a sibling-workspace path" footgun) routes through
11849 // `FonteCaminhoVarExpansion` not
11850 // `FonteCaminhoShellBraceExpansion`. The leading-byte
11851 // shell-variable-expansion is the more self-locating
11852 // diagnostic on values that probe as both — same
11853 // load-bearing-leading-byte cascade discipline every prior
11854 // `:caminho` arm establishes.
11855 let d = dep_with_fonte(DepSource::Path {
11856 caminho: "${ORG}/caixa-teia".into(),
11857 });
11858 let err = d.validate().unwrap_err();
11859 assert!(
11860 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11861 "got {err:?}",
11862 );
11863 }
11864
11865 #[test]
11866 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11867 // Cascade pin on the immediate-successor arm: a value
11868 // carrying both `{` and a trailing `/`
11869 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11870 // tab-completed a path that already had a brace-expansion
11871 // expansion tail" footgun) routes through
11872 // `FonteCaminhoShellBraceExpansion` not
11873 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11874 // is the more semantic-locating axis (an author who removes
11875 // the `{` typically also drops the trailing separator since
11876 // both are paste-from-shell artifacts).
11877 let d = dep_with_fonte(DepSource::Path {
11878 caminho: "../{caixa-teia,caixa-helm}/".into(),
11879 });
11880 let err = d.validate().unwrap_err();
11881 assert!(
11882 matches!(
11883 err,
11884 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11885 ),
11886 "got {err:?}",
11887 );
11888 }
11889
11890 #[test]
11891 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
11892 // Diagnostic-shape pin (peer with
11893 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
11894 // on the closest two-byte peer arm): the error's Display
11895 // surfaces the offending `:nome`, the offending `:caminho`
11896 // verbatim, the offending byte's hex / character form, and
11897 // names the shell-brace-expansion / URI-Template footgun
11898 // explicitly so a `feira lint` run can render the diagnostic
11899 // without re-parsing.
11900 let d = dep_with_fonte(DepSource::Path {
11901 caminho: "../{caixa-teia,caixa-helm}/build".into(),
11902 });
11903 let rendered = d.validate().unwrap_err().to_string();
11904 assert!(
11905 rendered.contains("caixa-teia"),
11906 "diagnostic must name the offending dep: {rendered}",
11907 );
11908 assert!(
11909 rendered.contains("../{caixa-teia,caixa-helm}/build"),
11910 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11911 );
11912 assert!(
11913 rendered.contains("0x7b"),
11914 "diagnostic must surface the offending byte hex: {rendered:?}",
11915 );
11916 assert!(
11917 rendered.contains("brace-expansion"),
11918 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
11919 );
11920 assert!(
11921 rendered.contains("URI Template"),
11922 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
11923 {rendered:?}",
11924 );
11925 }
11926
11927 #[test]
11928 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
11929 // The canonical paste-from-shell-history bracket-glob /
11930 // character-class footgun: an author copies a
11931 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
11932 // `[a-z]` POSIX glob character-class matches every lowercase-
11933 // ASCII-suffix sibling caixa directory and silently passed
11934 // every prior arm (`Path::is_absolute` false on `..`, no
11935 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
11936 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
11937 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
11938 // `FonteCaminhoVarExpansion` arm doesn't fire because the
11939 // value starts with `..` not `$`). The lacre embedded the
11940 // value verbatim, the resolver folded it through
11941 // `Path::join` looking for a literal `./../caixa-[a-z]/
11942 // build` subdirectory, and the failure surfaced at resolve
11943 // time with a non-self-locating `No such file or directory`
11944 // error. The new arm moves the rejection to validate time
11945 // and names the offending dep + caminho + byte verbatim.
11946 // The arm fires on the first `[` encountered.
11947 let d = dep_with_fonte(DepSource::Path {
11948 caminho: "../caixa-[a-z]/build".into(),
11949 });
11950 let err = d.validate().unwrap_err();
11951 let DepError::FonteCaminhoShellBracketExpansion {
11952 nome,
11953 caminho,
11954 byte,
11955 } = err
11956 else {
11957 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11958 };
11959 assert_eq!(nome, "caixa-teia");
11960 assert_eq!(caminho, "../caixa-[a-z]/build");
11961 assert_eq!(byte, b'[');
11962 }
11963
11964 #[test]
11965 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
11966 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
11967 // — the degenerate "I selected an unbalanced closing bracket
11968 // out of a glob character-class block" idiom that probes for
11969 // the cascade's last-byte handling on a value carrying only
11970 // the closing byte). Pinned separately from the open-bracket
11971 // shape so the gate's contract is "any `[` or `]` anywhere",
11972 // not single-byte coverage. Mirrors the peer
11973 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
11974 // shape on the immediate-predecessor
11975 // `FonteCaminhoShellBraceExpansion` arm.
11976 let d = dep_with_fonte(DepSource::Path {
11977 caminho: "../caixa-teia]".into(),
11978 });
11979 let err = d.validate().unwrap_err();
11980 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
11981 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
11982 };
11983 assert_eq!(byte, b']');
11984 }
11985
11986 #[test]
11987 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
11988 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
11989 // canonical "I selected a `[caixa-teia]` TOML-table-header /
11990 // glob-character-class prefix out of an aligned config /
11991 // shell-history one-liner" idiom). Pinned separately from
11992 // the embedded-byte shape so the gate covers every position,
11993 // not only mid-path.
11994 let d = dep_with_fonte(DepSource::Path {
11995 caminho: "[caixa-teia]/build".into(),
11996 });
11997 let err = d.validate().unwrap_err();
11998 assert!(
11999 matches!(
12000 err,
12001 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12002 ),
12003 "got {err:?}",
12004 );
12005 }
12006
12007 #[test]
12008 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12009 // The canonical TOML inline-array / YAML flow-sequence
12010 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12011 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12012 // inline-array out of a sibling-Cargo manifest" cross-idiom
12013 // leak; the symmetric YAML flow-sequence form `paths: [/a,
12014 // /b]` paste-from-values.yaml shape carries the same
12015 // bracket pair). The arm fires on the first `[` encountered;
12016 // pinned so the gate's coverage extends from the bare-
12017 // bracket glob-character-class shape to the TOML / YAML /
12018 // JSON array-literal shape.
12019 let d = dep_with_fonte(DepSource::Path {
12020 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12021 });
12022 let err = d.validate().unwrap_err();
12023 assert!(
12024 matches!(
12025 err,
12026 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12027 ),
12028 "got {err:?}",
12029 );
12030 }
12031
12032 #[test]
12033 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12034 // The canonical POSIX `test` / `[` builtin command paste
12035 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12036 // script conditional every paste-from-shell-script idiom
12037 // carries; bash's `[[ <expr> ]]` extended-test grammar
12038 // would surface the same byte pair). The arm fires on the
12039 // first `[` encountered; pinned so the gate's coverage
12040 // extends from the embedded-glob-character-class shape to
12041 // the leading-`test`-builtin / extended-test form.
12042 let d = dep_with_fonte(DepSource::Path {
12043 caminho: "../[ -d caixa-teia ]".into(),
12044 });
12045 let err = d.validate().unwrap_err();
12046 assert!(
12047 matches!(
12048 err,
12049 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12050 ),
12051 "got {err:?}",
12052 );
12053 }
12054
12055 #[test]
12056 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12057 // The positive-control pin: the gate targets only `[` /
12058 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12059 // The canonical relative POSIX path (`"../caixa-teia"`) and
12060 // a nested deeply-pathed variant with adjacent printable
12061 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12062 // to validate cleanly so the gate doesn't widen to a "no
12063 // printable punctuation anywhere" sweep that would defeat
12064 // the entire path-fonte author surface. Peer with
12065 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12066 // on the immediate-predecessor arm.
12067 let d = dep_with_fonte(DepSource::Path {
12068 caminho: "../caixa-teia/sub-dir.v2".into(),
12069 });
12070 d.validate().unwrap();
12071 }
12072
12073 #[test]
12074 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12075 // Cascade pin on the immediate-predecessor arm: a value
12076 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12077 // canonical "I pasted a brace-expansion fan followed by a
12078 // glob-character-class tail" footgun) routes through
12079 // `FonteCaminhoShellBraceExpansion` not
12080 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12081 // fan is the load-bearing root-cause edit on every
12082 // probe-as-both value because the bracket-class tail
12083 // typically rides on a prior brace-expansion expansion;
12084 // same cascade discipline every prior `:caminho` arm
12085 // establishes.
12086 let d = dep_with_fonte(DepSource::Path {
12087 caminho: "../{a,b}[ch]".into(),
12088 });
12089 let err = d.validate().unwrap_err();
12090 assert!(
12091 matches!(
12092 err,
12093 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12094 ),
12095 "got {err:?}",
12096 );
12097 }
12098
12099 #[test]
12100 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12101 // Cascade pin on the upstream shell-subshell-grouping arm:
12102 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12103 // the canonical "I pasted a subshell-grouping followed by
12104 // a glob-character-class tail" footgun) routes through
12105 // `FonteCaminhoShellSubshellGrouping` not
12106 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12107 // `$(<cmd>)` command-substitution boundary is the load-
12108 // bearing axis on every probe-as-both value.
12109 let d = dep_with_fonte(DepSource::Path {
12110 caminho: "../(cd foo)/[ch]".into(),
12111 });
12112 let err = d.validate().unwrap_err();
12113 assert!(
12114 matches!(
12115 err,
12116 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12117 ),
12118 "got {err:?}",
12119 );
12120 }
12121
12122 #[test]
12123 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12124 // Cascade pin on the upstream shell-glob arm: a value
12125 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12126 // canonical "I pasted a `*.[ch]` C-source-file glob whose
12127 // unbounded `*` precedes the bracket character-class"
12128 // footgun) routes through `FonteCaminhoShellGlob` not
12129 // `FonteCaminhoShellBracketExpansion`. The unbounded
12130 // pathname-expansion sentinel is the load-bearing root-
12131 // cause edit on every probe-as-both value — the unbounded
12132 // `*` carries the more aggressive expansion vector than
12133 // the bounded `[ch]` class, so the prior arm wins.
12134 let d = dep_with_fonte(DepSource::Path {
12135 caminho: "../caixa-teia/*[ch]".into(),
12136 });
12137 let err = d.validate().unwrap_err();
12138 assert!(
12139 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12140 "got {err:?}",
12141 );
12142 }
12143
12144 #[test]
12145 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12146 // Cascade pin on the upstream shell-command-substitution
12147 // arm: a value carrying both a backtick and `[`
12148 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12149 // legacy-backtick command-substitution followed by a
12150 // glob-character-class tail" footgun) routes through
12151 // `FonteCaminhoShellCommandSubstitution` not
12152 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12153 // command-injection vector is the load-bearing root-cause
12154 // edit on every probe-as-both value.
12155 let d = dep_with_fonte(DepSource::Path {
12156 caminho: "../`whoami`/[ch]".into(),
12157 });
12158 let err = d.validate().unwrap_err();
12159 assert!(
12160 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12161 "got {err:?}",
12162 );
12163 }
12164
12165 #[test]
12166 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12167 // Cascade pin on the upstream shell-background arm: a
12168 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12169 // — the canonical "I pasted a `cmd & [glob]` background-
12170 // launch + bracket-class chain" footgun) routes through
12171 // `FonteCaminhoShellBackground` not
12172 // `FonteCaminhoShellBracketExpansion`. The background-
12173 // launch tail is the load-bearing root-cause edit on
12174 // every probe-as-both value.
12175 let d = dep_with_fonte(DepSource::Path {
12176 caminho: "../caixa-teia & [ch]".into(),
12177 });
12178 let err = d.validate().unwrap_err();
12179 assert!(
12180 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12181 "got {err:?}",
12182 );
12183 }
12184
12185 #[test]
12186 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12187 // Cascade pin on the upstream shell-semicolon arm: a value
12188 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12189 // canonical sequential-cleanup + bracket-class paste
12190 // idiom) routes through `FonteCaminhoShellSemicolon` not
12191 // `FonteCaminhoShellBracketExpansion`. The sequential-
12192 // command-separator paste is the load-bearing root-cause
12193 // edit on every probe-as-both value.
12194 let d = dep_with_fonte(DepSource::Path {
12195 caminho: "../caixa-teia; [ch]".into(),
12196 });
12197 let err = d.validate().unwrap_err();
12198 assert!(
12199 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12200 "got {err:?}",
12201 );
12202 }
12203
12204 #[test]
12205 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12206 // Cascade pin on the upstream shell-pipe arm: a value
12207 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12208 // the canonical pipeline-to-bracket-class paste idiom)
12209 // routes through `FonteCaminhoShellPipe` not
12210 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12211 // paste is the load-bearing root-cause edit on every
12212 // probe-as-both value.
12213 let d = dep_with_fonte(DepSource::Path {
12214 caminho: "../caixa-teia | [tee]".into(),
12215 });
12216 let err = d.validate().unwrap_err();
12217 assert!(
12218 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12219 "got {err:?}",
12220 );
12221 }
12222
12223 #[test]
12224 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12225 // Cascade pin on the upstream shell-redirection arm: a
12226 // value carrying both `>` and `[` (`"../caixa-teia>log
12227 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12228 // redirect-plus-bracket chain" footgun) routes through
12229 // `FonteCaminhoShellRedirection` not
12230 // `FonteCaminhoShellBracketExpansion`. The input/output
12231 // redirection metachar carries the more self-locating
12232 // `byte` payload, so the prior arm wins on every
12233 // probe-as-both value.
12234 let d = dep_with_fonte(DepSource::Path {
12235 caminho: "../caixa-teia>log [ch]".into(),
12236 });
12237 let err = d.validate().unwrap_err();
12238 assert!(
12239 matches!(
12240 err,
12241 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12242 ),
12243 "got {err:?}",
12244 );
12245 }
12246
12247 #[test]
12248 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12249 // Cascade pin on the upstream backslash arm: a value
12250 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12251 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12252 // chain") routes through `FonteCaminhoBackslash` not
12253 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12254 // separator divergence is the load-bearing axis on every
12255 // probe-as-both value.
12256 let d = dep_with_fonte(DepSource::Path {
12257 caminho: "..\\caixa-teia\\[ch]".into(),
12258 });
12259 let err = d.validate().unwrap_err();
12260 assert!(
12261 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12262 "got {err:?}",
12263 );
12264 }
12265
12266 #[test]
12267 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12268 // Cascade pin on the embedded-control-byte arm: a value
12269 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12270 // the canonical paste-from-multiline-doc footgun where a
12271 // newline landed mid-caminho between two paste fragments)
12272 // routes through `FonteCaminhoControlChar` not
12273 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12274 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12275 // the load-bearing axis on every value that probes
12276 // positive for both — mirrors the cascade discipline on
12277 // every prior arm.
12278 let d = dep_with_fonte(DepSource::Path {
12279 caminho: "../foo\n[ch]".into(),
12280 });
12281 let err = d.validate().unwrap_err();
12282 assert!(
12283 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12284 "got {err:?}",
12285 );
12286 }
12287
12288 #[test]
12289 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12290 // Cascade pin on the load-bearing leading-byte arm: a
12291 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12292 // routes through `FonteCaminhoAbsolute` not
12293 // `FonteCaminhoShellBracketExpansion` — the host-layout-
12294 // leak diagnostic is the load-bearing axis, the bracket-
12295 // expansion byte is the secondary observation. Same
12296 // precedence logic as every prior leading-byte arm.
12297 let d = dep_with_fonte(DepSource::Path {
12298 caminho: "/etc/[ch]".into(),
12299 });
12300 let err = d.validate().unwrap_err();
12301 assert!(
12302 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12303 "got {err:?}",
12304 );
12305 }
12306
12307 #[test]
12308 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12309 // Cascade pin on the upstream leading-`$` var-expansion
12310 // arm: a value carrying both a leading `$` and a `[`
12311 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12312 // variable + bracket-class at the head of a sibling-
12313 // workspace path" footgun) routes through
12314 // `FonteCaminhoVarExpansion` not
12315 // `FonteCaminhoShellBracketExpansion`. The leading-byte
12316 // shell-variable-expansion is the more self-locating
12317 // diagnostic on values that probe as both — same
12318 // load-bearing-leading-byte cascade discipline every
12319 // prior `:caminho` arm establishes.
12320 let d = dep_with_fonte(DepSource::Path {
12321 caminho: "$DIR/[ch]".into(),
12322 });
12323 let err = d.validate().unwrap_err();
12324 assert!(
12325 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12326 "got {err:?}",
12327 );
12328 }
12329
12330 #[test]
12331 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12332 // Cascade pin on the immediate-successor arm: a value
12333 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12334 // the canonical "I tab-completed a path that already had
12335 // a bracket-glob-character-class expansion tail" footgun)
12336 // routes through `FonteCaminhoShellBracketExpansion` not
12337 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12338 // is the more semantic-locating axis (an author who
12339 // removes the `[` typically also drops the trailing
12340 // separator since both are paste-from-shell artifacts).
12341 let d = dep_with_fonte(DepSource::Path {
12342 caminho: "../[a-z]/".into(),
12343 });
12344 let err = d.validate().unwrap_err();
12345 assert!(
12346 matches!(
12347 err,
12348 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12349 ),
12350 "got {err:?}",
12351 );
12352 }
12353
12354 #[test]
12355 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12356 // Diagnostic-shape pin (peer with
12357 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12358 // on the closest two-byte peer arm): the error's Display
12359 // surfaces the offending `:nome`, the offending `:caminho`
12360 // verbatim, the offending byte's hex / character form, and
12361 // names the shell-bracket-expansion / glob-character-class
12362 // footgun explicitly so a `feira lint` run can render the
12363 // diagnostic without re-parsing.
12364 let d = dep_with_fonte(DepSource::Path {
12365 caminho: "../caixa-[a-z]/build".into(),
12366 });
12367 let rendered = d.validate().unwrap_err().to_string();
12368 assert!(
12369 rendered.contains("caixa-teia"),
12370 "diagnostic must name the offending dep: {rendered}",
12371 );
12372 assert!(
12373 rendered.contains("../caixa-[a-z]/build"),
12374 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12375 );
12376 assert!(
12377 rendered.contains("0x5b"),
12378 "diagnostic must surface the offending byte hex: {rendered:?}",
12379 );
12380 assert!(
12381 rendered.contains("bracket-expansion"),
12382 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12383 );
12384 assert!(
12385 rendered.contains("glob-character-class"),
12386 "diagnostic must reference the POSIX glob-character-class vocabulary: \
12387 {rendered:?}",
12388 );
12389 }
12390
12391 #[test]
12392 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12393 // The canonical paste-from-shell-history strong-quoted
12394 // sibling-workspace-path footgun: an author copies a
12395 // `cd '../caixa-teia'` shell-history one-liner whose strong-
12396 // quoting preserved the path across a whitespace paste
12397 // boundary and silently passed every prior arm
12398 // (`Path::is_absolute` false on `'..`, no control bytes, no
12399 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12400 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12401 // doesn't end in `/`; the leading-`$` f4efe9c
12402 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12403 // value starts with `'` not `$`). The lacre embedded the
12404 // value verbatim, the resolver folded it through
12405 // `Path::join` looking for a literal `./'../caixa-teia'`
12406 // subdirectory, and the failure surfaced at resolve time
12407 // with a non-self-locating `No such file or directory`
12408 // error. The new arm moves the rejection to validate time
12409 // and names the offending dep + caminho + byte verbatim.
12410 // The arm fires on the first `'` encountered.
12411 let d = dep_with_fonte(DepSource::Path {
12412 caminho: "'../caixa-teia'".into(),
12413 });
12414 let err = d.validate().unwrap_err();
12415 let DepError::FonteCaminhoShellQuoteGrouping {
12416 nome,
12417 caminho,
12418 byte,
12419 } = err
12420 else {
12421 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12422 };
12423 assert_eq!(nome, "caixa-teia");
12424 assert_eq!(caminho, "'../caixa-teia'");
12425 assert_eq!(byte, b'\'');
12426 }
12427
12428 #[test]
12429 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12430 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12431 // — the canonical paste-from-JSON-config / paste-from-YAML-
12432 // flow-scalar / paste-from-TOML-basic-string / paste-from-
12433 // tatara-lisp-string-literal cross-idiom leak). Pinned
12434 // separately from the single-quote shape so the gate's
12435 // contract is "any `'` or `\"` anywhere", not single-byte
12436 // coverage. Mirrors the peer
12437 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12438 // shape on the immediate-predecessor
12439 // `FonteCaminhoShellBracketExpansion` arm.
12440 let d = dep_with_fonte(DepSource::Path {
12441 caminho: "\"../caixa-teia\"".into(),
12442 });
12443 let err = d.validate().unwrap_err();
12444 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12445 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12446 };
12447 assert_eq!(byte, b'"');
12448 }
12449
12450 #[test]
12451 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12452 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12453 // canonical "I pasted a JSON key-value pair fragment into
12454 // the middle of the path" idiom). Pinned separately from
12455 // the leading-byte shape so the gate covers every position,
12456 // not only leading.
12457 let d = dep_with_fonte(DepSource::Path {
12458 caminho: "../\"caixa-teia\"".into(),
12459 });
12460 let err = d.validate().unwrap_err();
12461 assert!(
12462 matches!(
12463 err,
12464 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12465 ),
12466 "got {err:?}",
12467 );
12468 }
12469
12470 #[test]
12471 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12472 // The canonical YAML double-quoted flow-scalar cross-idiom
12473 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12474 // `path: \"...\"` YAML flow-scalar entry out of an aligned
12475 // values.yaml / K8s manifest and dropped it verbatim into
12476 // the `:caminho` slot including the `path: ` key prefix"
12477 // paste-idiom). The arm fires on the first `"` encountered;
12478 // pinned so the gate's coverage extends from the bare-quote
12479 // paste shape to the aligned-YAML-manifest cross-idiom-leak
12480 // shape.
12481 let d = dep_with_fonte(DepSource::Path {
12482 caminho: "path: \"../caixa-teia\"".into(),
12483 });
12484 let err = d.validate().unwrap_err();
12485 assert!(
12486 matches!(
12487 err,
12488 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12489 ),
12490 "got {err:?}",
12491 );
12492 }
12493
12494 #[test]
12495 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12496 // The positive-control pin: the gate targets only `'` /
12497 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12498 // The canonical relative POSIX path (`"../caixa-teia"`) and
12499 // a nested deeply-pathed variant with adjacent printable
12500 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12501 // to validate cleanly so the gate doesn't widen to a "no
12502 // printable punctuation anywhere" sweep that would defeat
12503 // the entire path-fonte author surface. Peer with
12504 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12505 // on the immediate-predecessor arm.
12506 let d = dep_with_fonte(DepSource::Path {
12507 caminho: "../caixa-teia/sub-dir.v2".into(),
12508 });
12509 d.validate().unwrap();
12510 }
12511
12512 #[test]
12513 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12514 // Cascade pin on the immediate-predecessor arm: a value
12515 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12516 // "I pasted a glob-character-class followed by a strong-
12517 // quoted literal tail" footgun) routes through
12518 // `FonteCaminhoShellBracketExpansion` not
12519 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12520 // expansion is the load-bearing root-cause edit on every
12521 // probe-as-both value; same cascade discipline every prior
12522 // `:caminho` arm establishes.
12523 let d = dep_with_fonte(DepSource::Path {
12524 caminho: "../[a-z]'x'".into(),
12525 });
12526 let err = d.validate().unwrap_err();
12527 assert!(
12528 matches!(
12529 err,
12530 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12531 ),
12532 "got {err:?}",
12533 );
12534 }
12535
12536 #[test]
12537 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12538 // Cascade pin on the upstream shell-brace-expansion arm: a
12539 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12540 // canonical "I pasted a brace-expansion fan followed by a
12541 // strong-quoted literal tail" footgun) routes through
12542 // `FonteCaminhoShellBraceExpansion` not
12543 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12544 // is the load-bearing root-cause edit on every probe-as-
12545 // both value.
12546 let d = dep_with_fonte(DepSource::Path {
12547 caminho: "../{a,b}'x'".into(),
12548 });
12549 let err = d.validate().unwrap_err();
12550 assert!(
12551 matches!(
12552 err,
12553 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12554 ),
12555 "got {err:?}",
12556 );
12557 }
12558
12559 #[test]
12560 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12561 // Cascade pin on the upstream shell-subshell-grouping arm:
12562 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12563 // the canonical "I pasted a subshell-grouping followed by
12564 // a strong-quoted literal tail" footgun) routes through
12565 // `FonteCaminhoShellSubshellGrouping` not
12566 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12567 // `$(<cmd>)` command-substitution boundary is the load-
12568 // bearing axis on every probe-as-both value.
12569 let d = dep_with_fonte(DepSource::Path {
12570 caminho: "../(cd foo)/'x'".into(),
12571 });
12572 let err = d.validate().unwrap_err();
12573 assert!(
12574 matches!(
12575 err,
12576 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12577 ),
12578 "got {err:?}",
12579 );
12580 }
12581
12582 #[test]
12583 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12584 // Cascade pin on the upstream shell-glob arm: a value
12585 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12586 // canonical "I pasted a `*` unbounded pathname-expansion
12587 // followed by a strong-quoted literal tail" footgun) routes
12588 // through `FonteCaminhoShellGlob` not
12589 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12590 // expansion sentinel is the load-bearing root-cause edit
12591 // on every probe-as-both value.
12592 let d = dep_with_fonte(DepSource::Path {
12593 caminho: "../caixa-teia/*'x'".into(),
12594 });
12595 let err = d.validate().unwrap_err();
12596 assert!(
12597 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12598 "got {err:?}",
12599 );
12600 }
12601
12602 #[test]
12603 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12604 // Cascade pin on the upstream shell-command-substitution
12605 // arm: a value carrying both a backtick and `'`
12606 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12607 // legacy-backtick command-substitution followed by a
12608 // strong-quoted literal tail" footgun) routes through
12609 // `FonteCaminhoShellCommandSubstitution` not
12610 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12611 // command-injection vector is the load-bearing root-cause
12612 // edit on every probe-as-both value.
12613 let d = dep_with_fonte(DepSource::Path {
12614 caminho: "../`whoami`/'x'".into(),
12615 });
12616 let err = d.validate().unwrap_err();
12617 assert!(
12618 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12619 "got {err:?}",
12620 );
12621 }
12622
12623 #[test]
12624 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12625 // Cascade pin on the upstream shell-background arm: a value
12626 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12627 // canonical "I pasted a `cmd & 'literal'` background-launch
12628 // + quote chain" footgun) routes through
12629 // `FonteCaminhoShellBackground` not
12630 // `FonteCaminhoShellQuoteGrouping`. The background-launch
12631 // tail is the load-bearing root-cause edit on every
12632 // probe-as-both value.
12633 let d = dep_with_fonte(DepSource::Path {
12634 caminho: "../caixa-teia & 'x'".into(),
12635 });
12636 let err = d.validate().unwrap_err();
12637 assert!(
12638 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12639 "got {err:?}",
12640 );
12641 }
12642
12643 #[test]
12644 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12645 // Cascade pin on the upstream shell-semicolon arm: a value
12646 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12647 // canonical sequential-cleanup + quote paste idiom) routes
12648 // through `FonteCaminhoShellSemicolon` not
12649 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12650 // separator paste is the load-bearing root-cause edit on
12651 // every probe-as-both value.
12652 let d = dep_with_fonte(DepSource::Path {
12653 caminho: "../caixa-teia; 'x'".into(),
12654 });
12655 let err = d.validate().unwrap_err();
12656 assert!(
12657 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12658 "got {err:?}",
12659 );
12660 }
12661
12662 #[test]
12663 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12664 // Cascade pin on the upstream shell-pipe arm: a value
12665 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12666 // canonical pipeline-to-quoted-literal paste idiom) routes
12667 // through `FonteCaminhoShellPipe` not
12668 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12669 // is the load-bearing root-cause edit on every probe-as-
12670 // both value.
12671 let d = dep_with_fonte(DepSource::Path {
12672 caminho: "../caixa-teia | 'x'".into(),
12673 });
12674 let err = d.validate().unwrap_err();
12675 assert!(
12676 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12677 "got {err:?}",
12678 );
12679 }
12680
12681 #[test]
12682 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12683 // Cascade pin on the upstream shell-redirection arm: a
12684 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12685 // — the canonical "I pasted a `cmd > log 'literal'`
12686 // redirect-plus-quote chain" footgun) routes through
12687 // `FonteCaminhoShellRedirection` not
12688 // `FonteCaminhoShellQuoteGrouping`. The input/output
12689 // redirection metachar carries the more self-locating
12690 // `byte` payload, so the prior arm wins on every probe-as-
12691 // both value.
12692 let d = dep_with_fonte(DepSource::Path {
12693 caminho: "../caixa-teia>log 'x'".into(),
12694 });
12695 let err = d.validate().unwrap_err();
12696 assert!(
12697 matches!(
12698 err,
12699 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12700 ),
12701 "got {err:?}",
12702 );
12703 }
12704
12705 #[test]
12706 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12707 // Cascade pin on the upstream backslash arm: a value
12708 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12709 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12710 // chain" footgun) routes through `FonteCaminhoBackslash`
12711 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12712 // separator divergence is the load-bearing axis on every
12713 // probe-as-both value.
12714 let d = dep_with_fonte(DepSource::Path {
12715 caminho: "..\\caixa-teia\\'x'".into(),
12716 });
12717 let err = d.validate().unwrap_err();
12718 assert!(
12719 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12720 "got {err:?}",
12721 );
12722 }
12723
12724 #[test]
12725 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12726 // Cascade pin on the embedded-control-byte arm: a value
12727 // carrying both a control byte and `'` (`"../foo\n'x'"` —
12728 // the canonical paste-from-multiline-doc footgun where a
12729 // newline landed mid-caminho between two paste fragments)
12730 // routes through `FonteCaminhoControlChar` not
12731 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12732 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12733 // the load-bearing axis on every value that probes
12734 // positive for both — mirrors the cascade discipline on
12735 // every prior arm.
12736 let d = dep_with_fonte(DepSource::Path {
12737 caminho: "../foo\n'x'".into(),
12738 });
12739 let err = d.validate().unwrap_err();
12740 assert!(
12741 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12742 "got {err:?}",
12743 );
12744 }
12745
12746 #[test]
12747 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12748 // Cascade pin on the load-bearing leading-byte arm: a
12749 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12750 // through `FonteCaminhoAbsolute` not
12751 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12752 // diagnostic is the load-bearing axis, the quote byte is
12753 // the secondary observation. Same precedence logic as every
12754 // prior leading-byte arm.
12755 let d = dep_with_fonte(DepSource::Path {
12756 caminho: "/etc/'x'".into(),
12757 });
12758 let err = d.validate().unwrap_err();
12759 assert!(
12760 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12761 "got {err:?}",
12762 );
12763 }
12764
12765 #[test]
12766 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12767 // Cascade pin on the upstream leading-`$` var-expansion
12768 // arm: a value carrying both a leading `$` and a `'`
12769 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12770 // variable + quoted literal at the head of a sibling-
12771 // workspace path" footgun) routes through
12772 // `FonteCaminhoVarExpansion` not
12773 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12774 // shell-variable-expansion is the more self-locating
12775 // diagnostic on values that probe as both — same
12776 // load-bearing-leading-byte cascade discipline every
12777 // prior `:caminho` arm establishes.
12778 let d = dep_with_fonte(DepSource::Path {
12779 caminho: "$DIR/'x'".into(),
12780 });
12781 let err = d.validate().unwrap_err();
12782 assert!(
12783 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12784 "got {err:?}",
12785 );
12786 }
12787
12788 #[test]
12789 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12790 // Cascade pin on the immediate-successor arm: a value
12791 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12792 // — the canonical "I tab-completed a path whose strong-
12793 // quoted body already carried the quoting from a shell-
12794 // history paste" footgun) routes through
12795 // `FonteCaminhoShellQuoteGrouping` not
12796 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12797 // is the more semantic-locating axis (an author who removes
12798 // the `'` typically also drops the trailing separator since
12799 // both are paste-from-shell artifacts).
12800 let d = dep_with_fonte(DepSource::Path {
12801 caminho: "../'caixa-teia'/".into(),
12802 });
12803 let err = d.validate().unwrap_err();
12804 assert!(
12805 matches!(
12806 err,
12807 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12808 ),
12809 "got {err:?}",
12810 );
12811 }
12812
12813 #[test]
12814 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12815 // Diagnostic-shape pin (peer with
12816 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12817 // on the closest two-byte peer arm): the error's Display
12818 // surfaces the offending `:nome`, the offending `:caminho`
12819 // verbatim, the offending byte's hex / character form, and
12820 // names the shell-quote-grouping / cross-config-DSL-string-
12821 // literal-delimiter footgun explicitly so a `feira lint`
12822 // run can render the diagnostic without re-parsing.
12823 let d = dep_with_fonte(DepSource::Path {
12824 caminho: "'../caixa-teia'".into(),
12825 });
12826 let rendered = d.validate().unwrap_err().to_string();
12827 assert!(
12828 rendered.contains("caixa-teia"),
12829 "diagnostic must name the offending dep: {rendered}",
12830 );
12831 assert!(
12832 rendered.contains("'../caixa-teia'"),
12833 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12834 );
12835 assert!(
12836 rendered.contains("0x27"),
12837 "diagnostic must surface the offending byte hex: {rendered:?}",
12838 );
12839 assert!(
12840 rendered.contains("quote-grouping"),
12841 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12842 );
12843 assert!(
12844 rendered.contains("string-literal"),
12845 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12846 vocabulary: {rendered:?}",
12847 );
12848 }
12849
12850 #[test]
12851 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12852 // The canonical paste-from-shell-history-with-trailing-
12853 // annotation footgun: an author pastes a `cd ../caixa-teia
12854 // # legacy sibling` shell-history one-liner whose unquoted `#`
12855 // comment-lead separates the path from an inline annotation.
12856 // The POSIX shell trims the annotation to `../caixa-teia`
12857 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12858 // `Path::is_absolute` returns false on `..`, `#` is neither
12859 // a leading-byte sentinel nor a control byte nor `\` nor
12860 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12861 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12862 // `"`, and the value's last byte isn't `/` — so the value
12863 // silently passed every prior arm. The resolver folded the
12864 // value through `Path::join` looking for a literal
12865 // `./../caixa-teia # legacy sibling` subdirectory and the
12866 // failure surfaced at resolve time with a non-self-locating
12867 // `No such file or directory` error. The new arm moves the
12868 // rejection to validate time and names the offending dep +
12869 // caminho + byte verbatim.
12870 let d = dep_with_fonte(DepSource::Path {
12871 caminho: "../caixa-teia # legacy sibling".into(),
12872 });
12873 let err = d.validate().unwrap_err();
12874 let DepError::FonteCaminhoShellComment {
12875 nome,
12876 caminho,
12877 byte,
12878 } = err
12879 else {
12880 panic!("expected FonteCaminhoShellComment, got {err:?}");
12881 };
12882 assert_eq!(nome, "caixa-teia");
12883 assert_eq!(caminho, "../caixa-teia # legacy sibling");
12884 assert_eq!(byte, b'#');
12885 }
12886
12887 #[test]
12888 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
12889 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
12890 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
12891 // canonical "I copied a `path: ../caixa-teia # pin` YAML
12892 // scalar-plus-comment entry out of an aligned values.yaml and
12893 // dropped it verbatim into the `:caminho` slot" paste-idiom).
12894 // Pinned separately from the shell-history shape so the
12895 // gate's coverage extends from the single-space `#` shape to
12896 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
12897 // requires the `#` to be preceded by whitespace to lex as a
12898 // comment (bare `foo#bar` is a single scalar); the double-
12899 // space paste from an aligned manifest is the canonical
12900 // shape.
12901 let d = dep_with_fonte(DepSource::Path {
12902 caminho: "../caixa-teia # pin".into(),
12903 });
12904 let err = d.validate().unwrap_err();
12905 assert!(
12906 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12907 "got {err:?}",
12908 );
12909 }
12910
12911 #[test]
12912 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
12913 // The URL-fragment-identifier paste shape
12914 // (`"../caixa-teia#readme"` — the canonical
12915 // paste-from-browser-address-bar permalink shape where the
12916 // browser preserved the `#anchor` tail on the copy). Pinned
12917 // separately from the whitespace-separated shell / YAML
12918 // comment shapes so the gate covers the unpadded RFC 3986
12919 // §3.5 fragment-delimiter position too, not only positions
12920 // preceded by unquoted whitespace. Peer with the immediate-
12921 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
12922 // (a68f818) which closes the same byte under the same URL-
12923 // fragment-identifier banner.
12924 let d = dep_with_fonte(DepSource::Path {
12925 caminho: "../caixa-teia#readme".into(),
12926 });
12927 let err = d.validate().unwrap_err();
12928 assert!(
12929 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12930 "got {err:?}",
12931 );
12932 }
12933
12934 #[test]
12935 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
12936 // Leading-position `#` shape (`"#../caixa-teia"` — the
12937 // "I copied a shell-comment-out entry from a commented-out
12938 // dep row" footgun). Pinned separately from the embedded
12939 // shapes so the gate covers every position, not only
12940 // whitespace-preceded / mid-value.
12941 let d = dep_with_fonte(DepSource::Path {
12942 caminho: "#../caixa-teia".into(),
12943 });
12944 let err = d.validate().unwrap_err();
12945 assert!(
12946 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
12947 "got {err:?}",
12948 );
12949 }
12950
12951 #[test]
12952 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
12953 // The positive-control pin: the gate targets only `#`,
12954 // never adjacent printable ASCII or POSIX-valid bytes. The
12955 // canonical relative POSIX path (`"../caixa-teia"`) and a
12956 // nested deeply-pathed variant with adjacent printable
12957 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12958 // to validate cleanly so the gate doesn't widen to a "no
12959 // printable punctuation anywhere" sweep that would defeat
12960 // the entire path-fonte author surface. Peer with
12961 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
12962 // on the immediate-predecessor arm.
12963 let d = dep_with_fonte(DepSource::Path {
12964 caminho: "../caixa-teia/sub-dir.v2".into(),
12965 });
12966 d.validate().unwrap();
12967 }
12968
12969 #[test]
12970 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
12971 // Cascade pin on the immediate-predecessor arm: a value
12972 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
12973 // "I pasted a strong-quoted literal followed by a URL-
12974 // fragment permalink tail" footgun) routes through
12975 // `FonteCaminhoShellQuoteGrouping` not
12976 // `FonteCaminhoShellComment`. The shell-string-literal-
12977 // delimiter is the load-bearing root-cause edit on every
12978 // probe-as-both value; same cascade discipline every prior
12979 // `:caminho` arm establishes.
12980 let d = dep_with_fonte(DepSource::Path {
12981 caminho: "../'x'#pin".into(),
12982 });
12983 let err = d.validate().unwrap_err();
12984 assert!(
12985 matches!(
12986 err,
12987 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12988 ),
12989 "got {err:?}",
12990 );
12991 }
12992
12993 #[test]
12994 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
12995 // Cascade pin on the upstream shell-bracket-expansion arm:
12996 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
12997 // canonical "I pasted a glob-character-class followed by a
12998 // URL-fragment tail" footgun) routes through
12999 // `FonteCaminhoShellBracketExpansion` not
13000 // `FonteCaminhoShellComment`. The glob-character-class
13001 // expansion is the load-bearing root-cause edit on every
13002 // probe-as-both value.
13003 let d = dep_with_fonte(DepSource::Path {
13004 caminho: "../[a-z]#pin".into(),
13005 });
13006 let err = d.validate().unwrap_err();
13007 assert!(
13008 matches!(
13009 err,
13010 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13011 ),
13012 "got {err:?}",
13013 );
13014 }
13015
13016 #[test]
13017 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13018 // Cascade pin on the upstream shell-brace-expansion arm: a
13019 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13020 // canonical "I pasted a brace-expansion fan followed by a
13021 // URL-fragment tail" footgun) routes through
13022 // `FonteCaminhoShellBraceExpansion` not
13023 // `FonteCaminhoShellComment`. The brace-expansion fan is the
13024 // load-bearing root-cause edit on every probe-as-both value.
13025 let d = dep_with_fonte(DepSource::Path {
13026 caminho: "../{a,b}#pin".into(),
13027 });
13028 let err = d.validate().unwrap_err();
13029 assert!(
13030 matches!(
13031 err,
13032 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13033 ),
13034 "got {err:?}",
13035 );
13036 }
13037
13038 #[test]
13039 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13040 // Cascade pin on the upstream shell-subshell-grouping arm:
13041 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13042 // the canonical "I pasted a subshell-grouping followed by a
13043 // URL-fragment tail" footgun) routes through
13044 // `FonteCaminhoShellSubshellGrouping` not
13045 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13046 // command-substitution boundary is the load-bearing axis on
13047 // every probe-as-both value.
13048 let d = dep_with_fonte(DepSource::Path {
13049 caminho: "../(cd foo)#pin".into(),
13050 });
13051 let err = d.validate().unwrap_err();
13052 assert!(
13053 matches!(
13054 err,
13055 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13056 ),
13057 "got {err:?}",
13058 );
13059 }
13060
13061 #[test]
13062 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13063 // Cascade pin on the upstream shell-glob arm: a value
13064 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13065 // canonical "I pasted a `*` unbounded pathname-expansion
13066 // followed by a URL-fragment tail" footgun) routes through
13067 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13068 // The unbounded pathname-expansion sentinel is the load-
13069 // bearing root-cause edit on every probe-as-both value.
13070 let d = dep_with_fonte(DepSource::Path {
13071 caminho: "../caixa-teia/*#pin".into(),
13072 });
13073 let err = d.validate().unwrap_err();
13074 assert!(
13075 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13076 "got {err:?}",
13077 );
13078 }
13079
13080 #[test]
13081 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13082 // Cascade pin on the upstream shell-command-substitution
13083 // arm: a value carrying both a backtick and `#`
13084 // (``"../`whoami`#pin"`` — the canonical "I pasted a
13085 // legacy-backtick command-substitution followed by a URL-
13086 // fragment tail" footgun) routes through
13087 // `FonteCaminhoShellCommandSubstitution` not
13088 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13089 // injection vector is the load-bearing root-cause edit on
13090 // every probe-as-both value.
13091 let d = dep_with_fonte(DepSource::Path {
13092 caminho: "../`whoami`#pin".into(),
13093 });
13094 let err = d.validate().unwrap_err();
13095 assert!(
13096 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13097 "got {err:?}",
13098 );
13099 }
13100
13101 #[test]
13102 fn fonte_caminho_shell_background_fires_before_shell_comment() {
13103 // Cascade pin on the upstream shell-background arm: a value
13104 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13105 // the canonical "I pasted a `cmd &` background-launch
13106 // followed by a URL-fragment tail" footgun) routes through
13107 // `FonteCaminhoShellBackground` not
13108 // `FonteCaminhoShellComment`. The background-launch tail is
13109 // the load-bearing root-cause edit on every probe-as-both
13110 // value.
13111 let d = dep_with_fonte(DepSource::Path {
13112 caminho: "../caixa-teia&pin#tail".into(),
13113 });
13114 let err = d.validate().unwrap_err();
13115 assert!(
13116 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13117 "got {err:?}",
13118 );
13119 }
13120
13121 #[test]
13122 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13123 // Cascade pin on the upstream shell-semicolon arm: a value
13124 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13125 // the canonical sequential-cleanup + URL-fragment paste
13126 // idiom) routes through `FonteCaminhoShellSemicolon` not
13127 // `FonteCaminhoShellComment`. The sequential-command-
13128 // separator paste is the load-bearing root-cause edit on
13129 // every probe-as-both value.
13130 let d = dep_with_fonte(DepSource::Path {
13131 caminho: "../caixa-teia;pin#tail".into(),
13132 });
13133 let err = d.validate().unwrap_err();
13134 assert!(
13135 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13136 "got {err:?}",
13137 );
13138 }
13139
13140 #[test]
13141 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13142 // Cascade pin on the upstream shell-pipe arm: a value
13143 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13144 // the canonical pipeline-to-URL-fragment paste idiom) routes
13145 // through `FonteCaminhoShellPipe` not
13146 // `FonteCaminhoShellComment`. The pipeline-tail paste is
13147 // the load-bearing root-cause edit on every probe-as-both
13148 // value.
13149 let d = dep_with_fonte(DepSource::Path {
13150 caminho: "../caixa-teia|pin#tail".into(),
13151 });
13152 let err = d.validate().unwrap_err();
13153 assert!(
13154 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13155 "got {err:?}",
13156 );
13157 }
13158
13159 #[test]
13160 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13161 // Cascade pin on the upstream shell-redirection arm: a
13162 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13163 // — the canonical "I pasted a `cmd > log` redirect followed
13164 // by a URL-fragment tail" footgun) routes through
13165 // `FonteCaminhoShellRedirection` not
13166 // `FonteCaminhoShellComment`. The input/output redirection
13167 // metachar carries the more self-locating `byte` payload,
13168 // so the prior arm wins on every probe-as-both value.
13169 let d = dep_with_fonte(DepSource::Path {
13170 caminho: "../caixa-teia>log#pin".into(),
13171 });
13172 let err = d.validate().unwrap_err();
13173 assert!(
13174 matches!(
13175 err,
13176 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13177 ),
13178 "got {err:?}",
13179 );
13180 }
13181
13182 #[test]
13183 fn fonte_caminho_backslash_fires_before_shell_comment() {
13184 // Cascade pin on the upstream backslash arm: a value
13185 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13186 // canonical "I pasted a Windows-shell path followed by a
13187 // URL-fragment tail" footgun) routes through
13188 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13189 // The cross-host-OS-separator divergence is the load-
13190 // bearing axis on every probe-as-both value.
13191 let d = dep_with_fonte(DepSource::Path {
13192 caminho: "..\\caixa-teia#pin".into(),
13193 });
13194 let err = d.validate().unwrap_err();
13195 assert!(
13196 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13197 "got {err:?}",
13198 );
13199 }
13200
13201 #[test]
13202 fn fonte_caminho_control_char_fires_before_shell_comment() {
13203 // Cascade pin on the embedded-control-byte arm: a value
13204 // carrying both a control byte and `#` (`"../foo\n#pin"` —
13205 // the canonical paste-from-multiline-doc footgun where a
13206 // newline landed mid-caminho between the path and an
13207 // annotation) routes through `FonteCaminhoControlChar` not
13208 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13209 // byte diagnostic is the load-bearing axis on every value
13210 // that probes positive for both — mirrors the cascade
13211 // discipline on every prior arm.
13212 let d = dep_with_fonte(DepSource::Path {
13213 caminho: "../foo\n#pin".into(),
13214 });
13215 let err = d.validate().unwrap_err();
13216 assert!(
13217 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13218 "got {err:?}",
13219 );
13220 }
13221
13222 #[test]
13223 fn fonte_caminho_absolute_fires_before_shell_comment() {
13224 // Cascade pin on the load-bearing leading-byte arm: a
13225 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13226 // routes through `FonteCaminhoAbsolute` not
13227 // `FonteCaminhoShellComment` — the host-layout-leak
13228 // diagnostic is the load-bearing axis, the fragment byte is
13229 // the secondary observation. Same precedence logic as every
13230 // prior leading-byte arm.
13231 let d = dep_with_fonte(DepSource::Path {
13232 caminho: "/etc/foo#pin".into(),
13233 });
13234 let err = d.validate().unwrap_err();
13235 assert!(
13236 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13237 "got {err:?}",
13238 );
13239 }
13240
13241 #[test]
13242 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13243 // Cascade pin on the upstream leading-`$` var-expansion
13244 // arm: a value carrying both a leading `$` and a `#`
13245 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13246 // shell-variable at the head of a sibling-workspace path
13247 // followed by a URL-fragment tail" footgun) routes through
13248 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13249 // The leading-byte shell-variable-expansion is the more
13250 // self-locating diagnostic on values that probe as both.
13251 let d = dep_with_fonte(DepSource::Path {
13252 caminho: "$DIR/foo#pin".into(),
13253 });
13254 let err = d.validate().unwrap_err();
13255 assert!(
13256 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13257 "got {err:?}",
13258 );
13259 }
13260
13261 #[test]
13262 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13263 // Cascade pin on the immediate-successor arm: a value
13264 // carrying both `#` and a trailing `/`
13265 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13266 // a URL-fragment-carrying path" footgun) routes through
13267 // `FonteCaminhoShellComment` not
13268 // `FonteCaminhoTrailingSlash`. The embedded fragment /
13269 // comment-lead byte is the more semantic-locating axis (an
13270 // author who removes the `#pin` fragment typically also
13271 // drops the trailing separator since both are paste-from-
13272 // URL / paste-from-shell-tab-completion artifacts).
13273 let d = dep_with_fonte(DepSource::Path {
13274 caminho: "../caixa-teia#pin/".into(),
13275 });
13276 let err = d.validate().unwrap_err();
13277 assert!(
13278 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13279 "got {err:?}",
13280 );
13281 }
13282
13283 #[test]
13284 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13285 // Diagnostic-shape pin (peer with
13286 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13287 // on the immediate-predecessor arm): the error's Display
13288 // surfaces the offending `:nome`, the offending `:caminho`
13289 // verbatim, the offending byte's hex / character form, and
13290 // names the shell-comment / URL-fragment-identifier /
13291 // YAML-comment cross-config-DSL footgun explicitly so a
13292 // `feira lint` run can render the diagnostic without
13293 // re-parsing.
13294 let d = dep_with_fonte(DepSource::Path {
13295 caminho: "../caixa-teia#readme".into(),
13296 });
13297 let rendered = d.validate().unwrap_err().to_string();
13298 assert!(
13299 rendered.contains("caixa-teia"),
13300 "diagnostic must name the offending dep: {rendered}",
13301 );
13302 assert!(
13303 rendered.contains("../caixa-teia#readme"),
13304 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13305 );
13306 assert!(
13307 rendered.contains("0x23"),
13308 "diagnostic must surface the offending byte hex: {rendered:?}",
13309 );
13310 assert!(
13311 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13312 "diagnostic must name the shell-comment footgun: {rendered:?}",
13313 );
13314 assert!(
13315 rendered.contains("fragment") || rendered.contains("URL-fragment"),
13316 "diagnostic must reference the URL-fragment-identifier vocabulary: \
13317 {rendered:?}",
13318 );
13319 }
13320
13321 #[test]
13322 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13323 // The canonical paste-from-browser-address-bar percent-
13324 // encoded-space footgun: an author copies `../caixa%20teia`
13325 // out of a URL-encoded README hyperlink / browser address
13326 // bar / percent-encoded permalink expecting `%20` to decode
13327 // to a literal space at the filesystem layer. POSIX
13328 // `std::path::Path` treats `%` as a literal path-component
13329 // byte, so `Path::join` looks for a literal
13330 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13331 // returns false on `..`, `%` is neither a leading-byte
13332 // sentinel nor a control byte nor `\` nor `<` / `>` nor
13333 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13334 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13335 // and the value's last byte isn't `/` — so the value
13336 // silently passed every prior arm. The new arm moves the
13337 // rejection to validate time and names the offending dep +
13338 // caminho + byte verbatim.
13339 let d = dep_with_fonte(DepSource::Path {
13340 caminho: "../caixa%20teia".into(),
13341 });
13342 let err = d.validate().unwrap_err();
13343 let DepError::FonteCaminhoUrlPercentEncoding {
13344 nome,
13345 caminho,
13346 byte,
13347 } = err
13348 else {
13349 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13350 };
13351 assert_eq!(nome, "caixa-teia");
13352 assert_eq!(caminho, "../caixa%20teia");
13353 assert_eq!(byte, b'%');
13354 }
13355
13356 #[test]
13357 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13358 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13359 // intending the `%2F` as the URL encoding of `/`) locks a
13360 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13361 // the byte-identical `path:../caixa/teia` form. Pinned
13362 // separately from the space-encoded shape so the gate's
13363 // coverage extends past the single canonical `%20` example
13364 // to any two-hex-digit percent-encoded sequence.
13365 let d = dep_with_fonte(DepSource::Path {
13366 caminho: "../caixa%2Fteia".into(),
13367 });
13368 let err = d.validate().unwrap_err();
13369 assert!(
13370 matches!(
13371 err,
13372 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13373 ),
13374 "got {err:?}",
13375 );
13376 }
13377
13378 #[test]
13379 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13380 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13381 // where `%` isn't followed by two hex digits) — every
13382 // WHATWG-conformant URL parser rejects the value at parse
13383 // time per RFC 3986 §2.1, but the byte would silently ride
13384 // into the lacre before the resolver subprocess crosses the
13385 // URL-parser boundary. Pinned separately from the well-
13386 // formed `%HH` shapes so the gate covers every percent-
13387 // occurrence, not only strictly-conformant escapes.
13388 let d = dep_with_fonte(DepSource::Path {
13389 caminho: "../caixa-teia%foo".into(),
13390 });
13391 let err = d.validate().unwrap_err();
13392 assert!(
13393 matches!(
13394 err,
13395 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13396 ),
13397 "got {err:?}",
13398 );
13399 }
13400
13401 #[test]
13402 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13403 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13404 // — the canonical paste-from-top-of-doc YAML directive
13405 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13406 // separately from embedded shapes so the gate covers the
13407 // leading-position `%` too, not only mid-value occurrences.
13408 let d = dep_with_fonte(DepSource::Path {
13409 caminho: "%YAML/../caixa-teia".into(),
13410 });
13411 let err = d.validate().unwrap_err();
13412 assert!(
13413 matches!(
13414 err,
13415 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13416 ),
13417 "got {err:?}",
13418 );
13419 }
13420
13421 #[test]
13422 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13423 // The printf-format-specifier paste shape
13424 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13425 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13426 // 134 format-string-injection vector). Pinned separately
13427 // from the URL-encoding shapes so the gate's rationale
13428 // extends past the RFC 3986 axis to the C / POSIX printf
13429 // format-directive-lead axis.
13430 let d = dep_with_fonte(DepSource::Path {
13431 caminho: "../caixa-%s-teia".into(),
13432 });
13433 let err = d.validate().unwrap_err();
13434 assert!(
13435 matches!(
13436 err,
13437 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13438 ),
13439 "got {err:?}",
13440 );
13441 }
13442
13443 #[test]
13444 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13445 // The positive-control pin: the gate targets only `%`,
13446 // never adjacent printable ASCII or POSIX-valid bytes. The
13447 // canonical relative POSIX path (`"../caixa-teia"`) and a
13448 // nested deeply-pathed variant with adjacent printable
13449 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13450 // to validate cleanly so the gate doesn't widen to a "no
13451 // printable punctuation anywhere" sweep that would defeat
13452 // the entire path-fonte author surface. Peer with
13453 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13454 // on the immediate-predecessor arm.
13455 let d = dep_with_fonte(DepSource::Path {
13456 caminho: "../caixa-teia/sub-dir.v2".into(),
13457 });
13458 d.validate().unwrap();
13459 }
13460
13461 #[test]
13462 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13463 // Cascade pin on the immediate-predecessor arm: a value
13464 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13465 // canonical "I pasted a URL-fragment permalink followed by a
13466 // percent-encoded space tail" footgun) routes through
13467 // `FonteCaminhoShellComment` not
13468 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13469 // identifier is the load-bearing downstream-truncation edit
13470 // on every probe-as-both value; same cascade discipline
13471 // every prior `:caminho` arm establishes.
13472 let d = dep_with_fonte(DepSource::Path {
13473 caminho: "../caixa-teia#pin%20".into(),
13474 });
13475 let err = d.validate().unwrap_err();
13476 assert!(
13477 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13478 "got {err:?}",
13479 );
13480 }
13481
13482 #[test]
13483 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13484 // Cascade pin on the upstream shell-quote-grouping arm: a
13485 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13486 // canonical "I pasted a strong-quoted literal followed by
13487 // a percent-encoded space" footgun) routes through
13488 // `FonteCaminhoShellQuoteGrouping` not
13489 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13490 // literal-delimiter is the load-bearing root-cause edit on
13491 // every probe-as-both value.
13492 let d = dep_with_fonte(DepSource::Path {
13493 caminho: "../'x'%20teia".into(),
13494 });
13495 let err = d.validate().unwrap_err();
13496 assert!(
13497 matches!(
13498 err,
13499 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13500 ),
13501 "got {err:?}",
13502 );
13503 }
13504
13505 #[test]
13506 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13507 // Cascade pin on the upstream backslash arm: a value
13508 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13509 // canonical "I pasted a Windows-shell path followed by a
13510 // percent-encoded space" footgun) routes through
13511 // `FonteCaminhoBackslash` not
13512 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13513 // separator divergence is the load-bearing root-cause edit
13514 // on every probe-as-both value.
13515 let d = dep_with_fonte(DepSource::Path {
13516 caminho: "..\\caixa%20teia".into(),
13517 });
13518 let err = d.validate().unwrap_err();
13519 assert!(
13520 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13521 "got {err:?}",
13522 );
13523 }
13524
13525 #[test]
13526 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13527 // Cascade pin on the upstream control-char arm: a value
13528 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13529 // the canonical "I pasted a paste-from-binary-blob path
13530 // followed by a percent-encoded space" footgun) routes
13531 // through `FonteCaminhoControlChar` not
13532 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13533 // rejected byte is the load-bearing root-cause edit on
13534 // every probe-as-both value.
13535 let d = dep_with_fonte(DepSource::Path {
13536 caminho: "../caixa\0%20teia".into(),
13537 });
13538 let err = d.validate().unwrap_err();
13539 assert!(
13540 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13541 "got {err:?}",
13542 );
13543 }
13544
13545 #[test]
13546 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13547 // Cascade pin on the upstream absolute-path arm: a value
13548 // that's both absolute and carries `%` (`"/etc/passwd%20"`
13549 // — the canonical "I pasted an absolute path with a
13550 // percent-encoded space tail" footgun) routes through
13551 // `FonteCaminhoAbsolute` not
13552 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13553 // the load-bearing root-cause edit on every probe-as-both
13554 // value.
13555 let d = dep_with_fonte(DepSource::Path {
13556 caminho: "/etc/passwd%20".into(),
13557 });
13558 let err = d.validate().unwrap_err();
13559 assert!(
13560 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13561 "got {err:?}",
13562 );
13563 }
13564
13565 #[test]
13566 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13567 // Cascade pin on the upstream var-expansion arm: a value
13568 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13569 // — the canonical "I pasted a `$HOME`-rooted path with a
13570 // percent-encoded space" footgun) routes through
13571 // `FonteCaminhoVarExpansion` not
13572 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13573 // expansion is the load-bearing root-cause edit on every
13574 // probe-as-both value.
13575 let d = dep_with_fonte(DepSource::Path {
13576 caminho: "$HOME/caixa%20teia".into(),
13577 });
13578 let err = d.validate().unwrap_err();
13579 assert!(
13580 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13581 "got {err:?}",
13582 );
13583 }
13584
13585 #[test]
13586 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13587 // Cascade pin on the immediate-successor arm: a value
13588 // carrying both `%` and a trailing `/`
13589 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13590 // percent-encoded-space-carrying path" footgun) routes
13591 // through `FonteCaminhoUrlPercentEncoding` not
13592 // `FonteCaminhoTrailingSlash`. The embedded percent-
13593 // encoding-escape byte is the more semantic-locating axis
13594 // (an author who decodes the `%20` to a literal space is
13595 // likely to also tab-strip the trailing separator since
13596 // both are paste-from-URL / paste-from-shell-tab-completion
13597 // artifacts).
13598 let d = dep_with_fonte(DepSource::Path {
13599 caminho: "../caixa%20teia/".into(),
13600 });
13601 let err = d.validate().unwrap_err();
13602 assert!(
13603 matches!(
13604 err,
13605 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13606 ),
13607 "got {err:?}",
13608 );
13609 }
13610
13611 #[test]
13612 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13613 // Diagnostic-shape pin (peer with
13614 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13615 // on the immediate-predecessor arm): the error's Display
13616 // surfaces the offending `:nome`, the offending `:caminho`
13617 // verbatim, the offending byte's hex / character form, and
13618 // names the URL-percent-encoding-escape / printf-format-
13619 // specifier footgun explicitly so a `feira lint` run can
13620 // render the diagnostic without re-parsing.
13621 let d = dep_with_fonte(DepSource::Path {
13622 caminho: "../caixa%20teia".into(),
13623 });
13624 let rendered = d.validate().unwrap_err().to_string();
13625 assert!(
13626 rendered.contains("caixa-teia"),
13627 "diagnostic must name the offending dep: {rendered}",
13628 );
13629 assert!(
13630 rendered.contains("../caixa%20teia"),
13631 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13632 );
13633 assert!(
13634 rendered.contains("0x25"),
13635 "diagnostic must surface the offending byte hex: {rendered:?}",
13636 );
13637 assert!(
13638 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13639 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13640 );
13641 assert!(
13642 rendered.contains("printf") || rendered.contains("format-specifier"),
13643 "diagnostic must reference the printf-format-specifier vocabulary: \
13644 {rendered:?}",
13645 );
13646 }
13647
13648 #[test]
13649 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13650 // The canonical embedded-`$` shell-variable-expansion paste
13651 // shape (`"../foo$HOME/bar"` — an author copies a partially-
13652 // substituted shell one-liner where the leading segment is a
13653 // literal `../foo` while the mid segment carries the un-
13654 // substituted `$HOME` template). The leading-`$` position is
13655 // already gated by the f4efe9c leading-byte arm which routes
13656 // through `FonteCaminhoVarExpansion`; this arm closes the
13657 // last positional gap on `$` — every position on the axis is
13658 // structurally rejected.
13659 let d = dep_with_fonte(DepSource::Path {
13660 caminho: "../foo$HOME/bar".into(),
13661 });
13662 let err = d.validate().unwrap_err();
13663 let DepError::FonteCaminhoShellVariableExpansion {
13664 nome,
13665 caminho,
13666 byte,
13667 } = err
13668 else {
13669 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13670 };
13671 assert_eq!(nome, "caixa-teia");
13672 assert_eq!(caminho, "../foo$HOME/bar");
13673 assert_eq!(byte, b'$');
13674 }
13675
13676 #[test]
13677 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13678 // The symmetric braced-CI-manifest paste shape
13679 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13680 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13681 // footgun). Pinned separately from the bare-`$VAR` shape so
13682 // the gate covers both POSIX shell §2.6 Parameter Expansion
13683 // syntactic forms, not only the unbraced variant. The
13684 // embedded `{` byte in `${...}` is also caught by the 598b770
13685 // shell-brace-expansion arm but that arm fires earlier in
13686 // the cascade — the `$` arm's coverage extends to `${...}`
13687 // structurally, so the diagnostic asserted here is the
13688 // brace-expansion one (which is a valid outcome; the point
13689 // of the pin is that the value never survives validation).
13690 let d = dep_with_fonte(DepSource::Path {
13691 caminho: "../foo${WORKSPACE}/bar".into(),
13692 });
13693 let err = d.validate().unwrap_err();
13694 assert!(
13695 matches!(
13696 err,
13697 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13698 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13699 ),
13700 "got {err:?}",
13701 );
13702 }
13703
13704 #[test]
13705 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13706 // The paste-from-shell-prompt command-substitution idiom
13707 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13708 // `$VAR` shape so the gate's rationale extends to POSIX shell
13709 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13710 // legacy `` `<cmd>` `` form is already closed by the c370458
13711 // backtick arm). The embedded `(` byte in `$(...)` is also
13712 // caught structurally by the 0633c91 shell-subshell-grouping
13713 // arm which fires earlier in the cascade — the diagnostic
13714 // asserted here is either outcome, since both structurally
13715 // reject the value; the point of the pin is that the value
13716 // never survives validation.
13717 let d = dep_with_fonte(DepSource::Path {
13718 caminho: "../foo$(whoami)/bar".into(),
13719 });
13720 let err = d.validate().unwrap_err();
13721 assert!(
13722 matches!(
13723 err,
13724 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13725 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13726 ),
13727 "got {err:?}",
13728 );
13729 }
13730
13731 #[test]
13732 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13733 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13734 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13735 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13736 // idiom copied into a caminho template). None of the prior
13737 // shell-metachar arms cover this shape (`1` is a bare digit;
13738 // no `(` / `{` / letter follows the `$`), so the arm is the
13739 // sole gate on the shape.
13740 let d = dep_with_fonte(DepSource::Path {
13741 caminho: "../foo$1/bar".into(),
13742 });
13743 let err = d.validate().unwrap_err();
13744 assert!(
13745 matches!(
13746 err,
13747 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13748 ),
13749 "got {err:?}",
13750 );
13751 }
13752
13753 #[test]
13754 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13755 // The positive-control pin (peer with
13756 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13757 // on the immediate-predecessor arm): the gate targets only
13758 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13759 // A relative POSIX path carrying dashes / dots / slashes /
13760 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13761 // validate cleanly so the gate doesn't widen to a "no
13762 // printable punctuation anywhere" sweep that would defeat
13763 // the entire path-fonte author surface.
13764 let d = dep_with_fonte(DepSource::Path {
13765 caminho: "../caixa-teia/sub-dir.v2".into(),
13766 });
13767 d.validate().unwrap();
13768 }
13769
13770 #[test]
13771 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13772 // Cascade pin on the leading-`$` sibling arm at line 540: a
13773 // value starting with `$` and carrying an embedded `$` too
13774 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13775 // fully-templated CI path with two un-substituted variables")
13776 // routes through `FonteCaminhoVarExpansion` not
13777 // `FonteCaminhoShellVariableExpansion`. The leading-byte
13778 // host-layout-leak is the load-bearing self-locating axis
13779 // (the leading position dominates the semantic-locating
13780 // rationale on every probe-as-both value); the embedded
13781 // arm's positional-agnostic sweep catches only values whose
13782 // leading byte doesn't route through the earlier leading-
13783 // byte arms.
13784 let d = dep_with_fonte(DepSource::Path {
13785 caminho: "$HOME/foo$WORKSPACE/bar".into(),
13786 });
13787 let err = d.validate().unwrap_err();
13788 assert!(
13789 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13790 "got {err:?}",
13791 );
13792 }
13793
13794 #[test]
13795 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13796 // Cascade pin on the immediate-predecessor arm: a value
13797 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13798 // — the canonical "I pasted a percent-encoded space adjacent
13799 // to a `$HOME` template") routes through
13800 // `FonteCaminhoUrlPercentEncoding` not
13801 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13802 // encoding-escape byte is the more semantic-locating axis
13803 // (the paste-from-browser-address-bar shape is the load-
13804 // bearing self-locating edit); same cascade discipline every
13805 // prior `:caminho` arm establishes.
13806 let d = dep_with_fonte(DepSource::Path {
13807 caminho: "../foo%20$HOME/bar".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 fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13821 // Cascade pin on the immediate-successor arm: a value
13822 // carrying both embedded `$` and a trailing `/`
13823 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13824 // `$HOME`-template-carrying path") routes through
13825 // `FonteCaminhoShellVariableExpansion` not
13826 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13827 // expansion byte is the more semantic-locating axis on
13828 // probe-as-both values (an author who substitutes the
13829 // `$HOME` template with a literal value is likely to also
13830 // tab-strip the trailing separator).
13831 let d = dep_with_fonte(DepSource::Path {
13832 caminho: "../foo$HOME/bar/".into(),
13833 });
13834 let err = d.validate().unwrap_err();
13835 assert!(
13836 matches!(
13837 err,
13838 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13839 ),
13840 "got {err:?}",
13841 );
13842 }
13843
13844 #[test]
13845 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13846 // Diagnostic-shape pin (peer with
13847 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13848 // on the immediate-predecessor arm): the error's Display
13849 // surfaces the offending `:nome`, the offending `:caminho`
13850 // verbatim, the offending byte's hex / character form, and
13851 // names the shell-variable-expansion / command-substitution
13852 // footgun explicitly so a `feira lint` run can render the
13853 // diagnostic without re-parsing.
13854 let d = dep_with_fonte(DepSource::Path {
13855 caminho: "../foo$HOME/bar".into(),
13856 });
13857 let rendered = d.validate().unwrap_err().to_string();
13858 assert!(
13859 rendered.contains("caixa-teia"),
13860 "diagnostic must name the offending dep: {rendered}",
13861 );
13862 assert!(
13863 rendered.contains("../foo$HOME/bar"),
13864 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13865 );
13866 assert!(
13867 rendered.contains("0x24"),
13868 "diagnostic must surface the offending byte hex: {rendered:?}",
13869 );
13870 assert!(
13871 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13872 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13873 );
13874 assert!(
13875 rendered.contains("command-substitution") || rendered.contains("command substitution"),
13876 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13877 );
13878 }
13879
13880 #[test]
13881 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
13882 // The fail-before-pass-after pin for the canonical paste-from-
13883 // shell-history footgun on `:caminho`. An author copies a `cd
13884 // ../caixa-teia && !sudo make install` one-liner from a quick-
13885 // start README, intending the trailing `!sudo` as a shell-
13886 // history-expansion reference but the typed slot is itself a
13887 // byte-level string parser, not a shell context, so the byte
13888 // rides into the value verbatim. Until this arm landed the `!`
13889 // byte silently passed every prior `:caminho` cascade arm
13890 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
13891 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
13892 // `#` / `%` / `$`); bash with the default `histexpand` mode
13893 // rewrites `!command` to the most recent history entry
13894 // beginning with `command`, the canonical RCE-class injection
13895 // vector when the byte rides into a shell argument executed
13896 // under `bash -i` (the operator-notebook interactive shell).
13897 let d = dep_with_fonte(DepSource::Path {
13898 caminho: "../caixa-teia!sudo".into(),
13899 });
13900 let err = d.validate().unwrap_err();
13901 let DepError::FonteCaminhoShellHistoryExpansion {
13902 nome,
13903 caminho,
13904 byte,
13905 } = err
13906 else {
13907 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
13908 };
13909 assert_eq!(nome, "caixa-teia");
13910 assert_eq!(caminho, "../caixa-teia!sudo");
13911 assert_eq!(byte, b'!');
13912 }
13913
13914 #[test]
13915 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
13916 // The symmetric `!!` repeat-prior-command paste idiom (peer with
13917 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
13918 // on `is_git_repo_url`). Pinned separately from the wrapped
13919 // `!command` shape so a future diagnostic-surface change that
13920 // only checked the leading or paired-bang position surfaces
13921 // here — the per-byte arm fires anywhere `!` appears in the
13922 // value, including at consecutive positions in the middle.
13923 let d = dep_with_fonte(DepSource::Path {
13924 caminho: "../foo!!/bar".into(),
13925 });
13926 let err = d.validate().unwrap_err();
13927 assert!(
13928 matches!(
13929 err,
13930 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13931 ),
13932 "got {err:?}",
13933 );
13934 }
13935
13936 #[test]
13937 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
13938 // The English-typography enthusiasm-form paste-from-prose
13939 // idiom: an author writes `:caminho "../caixa-teia!"`
13940 // expecting the substrate to coerce it to a kebab-case slug.
13941 // Pinned separately from the `!<word>` shell-history shape so
13942 // the gate's rationale extends to the paste-from-prose surface
13943 // (the same rationale the peer `is_git_repo_url` bang arm at
13944 // 7d53c68 covers). None of the prior shell-metachar arms cover
13945 // this shape (no `!<word>` reference and no `!!` repeat), so
13946 // the arm is the sole gate on the shape.
13947 let d = dep_with_fonte(DepSource::Path {
13948 caminho: "../caixa-teia!".into(),
13949 });
13950 let err = d.validate().unwrap_err();
13951 assert!(
13952 matches!(
13953 err,
13954 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
13955 ),
13956 "got {err:?}",
13957 );
13958 }
13959
13960 #[test]
13961 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
13962 // The positive-control pin (peer with
13963 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
13964 // on the immediate-predecessor arm): the gate targets only
13965 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
13966 // A relative POSIX path carrying dashes / dots / slashes /
13967 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13968 // validate cleanly so the gate doesn't widen to a "no
13969 // printable punctuation anywhere" sweep that would defeat
13970 // the entire path-fonte author surface.
13971 let d = dep_with_fonte(DepSource::Path {
13972 caminho: "../caixa-teia/sub-dir.v2".into(),
13973 });
13974 d.validate().unwrap();
13975 }
13976
13977 #[test]
13978 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
13979 // Cascade pin on the immediate-predecessor arm: a value
13980 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
13981 // — the canonical "I pasted a `$HOME`-templated path adjacent
13982 // to a trailing `!sudo` history-expansion") routes through
13983 // `FonteCaminhoShellVariableExpansion` not
13984 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
13985 // expansion byte is the more semantic-locating axis on
13986 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
13987 // template shape is the load-bearing self-locating edit);
13988 // same cascade discipline every prior `:caminho` arm
13989 // establishes.
13990 let d = dep_with_fonte(DepSource::Path {
13991 caminho: "../foo$HOME/bar!sudo".into(),
13992 });
13993 let err = d.validate().unwrap_err();
13994 assert!(
13995 matches!(
13996 err,
13997 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13998 ),
13999 "got {err:?}",
14000 );
14001 }
14002
14003 #[test]
14004 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14005 // Cascade pin on the immediate-successor arm: a value carrying
14006 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14007 // — the canonical "I tab-completed a `!sudo`-carrying path")
14008 // routes through `FonteCaminhoShellHistoryExpansion` not
14009 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14010 // expansion byte is the more semantic-locating axis on probe-
14011 // as-both values (an author who removes the `!sudo` history
14012 // reference is likely to also tab-strip the trailing separator).
14013 let d = dep_with_fonte(DepSource::Path {
14014 caminho: "../caixa-teia!sudo/".into(),
14015 });
14016 let err = d.validate().unwrap_err();
14017 assert!(
14018 matches!(
14019 err,
14020 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14021 ),
14022 "got {err:?}",
14023 );
14024 }
14025
14026 #[test]
14027 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14028 // Diagnostic-shape pin (peer with
14029 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14030 // on the immediate-predecessor arm): the error's Display
14031 // surfaces the offending `:nome`, the offending `:caminho`
14032 // verbatim, the offending byte's hex / character form, and
14033 // names the shell-history-expansion / bang-operator footgun
14034 // explicitly so a `feira lint` run can render the diagnostic
14035 // without re-parsing.
14036 let d = dep_with_fonte(DepSource::Path {
14037 caminho: "../caixa-teia!sudo".into(),
14038 });
14039 let rendered = d.validate().unwrap_err().to_string();
14040 assert!(
14041 rendered.contains("caixa-teia"),
14042 "diagnostic must name the offending dep: {rendered}",
14043 );
14044 assert!(
14045 rendered.contains("../caixa-teia!sudo"),
14046 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14047 );
14048 assert!(
14049 rendered.contains("0x21"),
14050 "diagnostic must surface the offending byte hex: {rendered:?}",
14051 );
14052 assert!(
14053 rendered.contains("history-expansion") || rendered.contains("history expansion"),
14054 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14055 );
14056 assert!(
14057 rendered.contains("bang"),
14058 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14059 );
14060 }
14061
14062 #[test]
14063 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14064 // The fail-before-pass-after pin for the canonical paste-from-
14065 // shell-history-quick-substitution footgun on `:caminho`. An
14066 // author copies a `git clone <bad-url>` line from their terminal,
14067 // corrects it via bash's `^bad^good` quick-substitution history
14068 // operator (bash reference §9.3, `set -o histexpand` mode's
14069 // default for interactive sessions), and pastes the trailing
14070 // `^bad^good` substitution fragment into a `:caminho` value
14071 // without trimming the leading `git clone` prefix — the byte
14072 // rides into the manifest verbatim. Until this arm landed the
14073 // `^` byte silently passed every prior `:caminho` cascade arm
14074 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14075 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14076 // `%` / `$` / `!`); bash with the default `histexpand` mode
14077 // rewrites the prior command's `bad` string to `good` and re-
14078 // executes it, the paired-operator half of the `set -o
14079 // histexpand` feature the peer `!` arm already closes the prefix
14080 // half of. The peer `is_git_repo_url` axis rejects the byte at
14081 // 49e142f under the same shell-history-substitution / RFC-3986-
14082 // unwise banner.
14083 let d = dep_with_fonte(DepSource::Path {
14084 caminho: "../foo^bad^good".into(),
14085 });
14086 let err = d.validate().unwrap_err();
14087 let DepError::FonteCaminhoShellHistorySubstitution {
14088 nome,
14089 caminho,
14090 byte,
14091 } = err
14092 else {
14093 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14094 };
14095 assert_eq!(nome, "caixa-teia");
14096 assert_eq!(caminho, "../foo^bad^good");
14097 assert_eq!(byte, b'^');
14098 }
14099
14100 #[test]
14101 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14102 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14103 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14104 // on `is_git_repo_url`). An author copies a `grep '^archived'`
14105 // regex-anchor / negation idiom from a doc snippet and the byte
14106 // rides in verbatim. Pinned separately from the `^old^new^`
14107 // quick-substitution shape so a future diagnostic-surface change
14108 // that only checked the paired-caret history-substitution
14109 // position surfaces here — the per-byte arm fires anywhere `^`
14110 // appears in the value, including at a solitary leading-of-
14111 // segment position.
14112 let d = dep_with_fonte(DepSource::Path {
14113 caminho: "../foo/^archived".into(),
14114 });
14115 let err = d.validate().unwrap_err();
14116 assert!(
14117 matches!(
14118 err,
14119 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14120 ),
14121 "got {err:?}",
14122 );
14123 }
14124
14125 #[test]
14126 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14127 // The trailing-`^` history-substitution-open shape — an author
14128 // starts typing a `^bad^good` quick-substitution but pastes only
14129 // the leading `^` sentinel before context-switching (a bash-
14130 // reference §9.3 valid histexpand prefix on its own — even a
14131 // solitary `^` on the prior command's whole re-execution shape).
14132 // Pinned separately from the `^old^new^` full-form and the leading-
14133 // of-segment `^archived` regex-anchor shape so the gate's
14134 // rationale extends to the paste-from-shell-history-with-only-
14135 // the-first-byte-selected surface. None of the prior shell-
14136 // metachar arms cover this shape.
14137 let d = dep_with_fonte(DepSource::Path {
14138 caminho: "../caixa-teia^".into(),
14139 });
14140 let err = d.validate().unwrap_err();
14141 assert!(
14142 matches!(
14143 err,
14144 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14145 ),
14146 "got {err:?}",
14147 );
14148 }
14149
14150 #[test]
14151 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14152 // The positive-control pin (peer with
14153 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14154 // on the immediate-predecessor arm): the gate targets only
14155 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14156 // A relative POSIX path carrying dashes / dots / slashes /
14157 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14158 // continue to validate cleanly so the gate doesn't widen to
14159 // a "no printable punctuation anywhere" sweep that would
14160 // defeat the entire path-fonte author surface.
14161 let d = dep_with_fonte(DepSource::Path {
14162 caminho: "../caixa-teia/sub_v2.rc".into(),
14163 });
14164 d.validate().unwrap();
14165 }
14166
14167 #[test]
14168 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14169 // Cascade pin on the immediate-predecessor arm: a value carrying
14170 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14171 // canonical "I pasted a `!sudo` history-reference next to a
14172 // `^bad^good` quick-substitution") routes through
14173 // `FonteCaminhoShellHistoryExpansion` not
14174 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14175 // the more semantic-locating axis on probe-as-both values (an
14176 // author who removes the `!sudo` reference is likely to also
14177 // strip the paired `^` substitution fragment); same cascade
14178 // discipline every prior `:caminho` arm establishes.
14179 let d = dep_with_fonte(DepSource::Path {
14180 caminho: "../foo!sudo^bad^good".into(),
14181 });
14182 let err = d.validate().unwrap_err();
14183 assert!(
14184 matches!(
14185 err,
14186 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14187 ),
14188 "got {err:?}",
14189 );
14190 }
14191
14192 #[test]
14193 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14194 // Cascade pin on the immediate-successor arm: a value carrying
14195 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14196 // the canonical "I tab-completed a `^bad^good`-carrying path")
14197 // routes through `FonteCaminhoShellHistorySubstitution` not
14198 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14199 // substitution byte is the more semantic-locating axis on probe-
14200 // as-both values (an author who removes the `^bad^good`
14201 // substitution fragment is likely to also tab-strip the trailing
14202 // separator).
14203 let d = dep_with_fonte(DepSource::Path {
14204 caminho: "../foo^bad^good/".into(),
14205 });
14206 let err = d.validate().unwrap_err();
14207 assert!(
14208 matches!(
14209 err,
14210 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14211 ),
14212 "got {err:?}",
14213 );
14214 }
14215
14216 #[test]
14217 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14218 {
14219 // Diagnostic-shape pin (peer with
14220 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14221 // on the immediate-predecessor arm): the error's Display
14222 // surfaces the offending `:nome`, the offending `:caminho`
14223 // verbatim, the offending byte's hex form, and names the
14224 // shell-history-substitution / RFC-3986-'unwise' / regex-
14225 // negation footgun explicitly so a `feira lint` run can render
14226 // the diagnostic without re-parsing.
14227 let d = dep_with_fonte(DepSource::Path {
14228 caminho: "../foo^bad^good".into(),
14229 });
14230 let rendered = d.validate().unwrap_err().to_string();
14231 assert!(
14232 rendered.contains("caixa-teia"),
14233 "diagnostic must name the offending dep: {rendered}",
14234 );
14235 assert!(
14236 rendered.contains("../foo^bad^good"),
14237 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14238 );
14239 assert!(
14240 rendered.contains("0x5e") || rendered.contains("0x5E"),
14241 "diagnostic must surface the offending byte hex: {rendered:?}",
14242 );
14243 assert!(
14244 rendered.contains("history-substitution") || rendered.contains("history substitution"),
14245 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14246 );
14247 assert!(
14248 rendered.contains("unwise"),
14249 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14250 );
14251 }
14252
14253 #[test]
14254 fn fonte_repo_empty_fires_before_pin_missing() {
14255 // Order pin: empty `:repo` is the more self-locating diagnostic
14256 // (every git source needs a repo; the pin discussion is
14257 // secondary), so it fires before the pin-missing arm even when
14258 // both are violated. Mirrors the
14259 // `nome_empty_takes_precedence_over_versao_invalid` ordering
14260 // discipline on the per-entry layer.
14261 let d = dep_with_fonte(DepSource::Git {
14262 repo: String::new(),
14263 tag: None,
14264 rev: None,
14265 branch: None,
14266 });
14267 let err = d.validate().unwrap_err();
14268 assert!(
14269 matches!(err, DepError::FonteRepoEmpty { .. }),
14270 "got {err:?}"
14271 );
14272 }
14273
14274 #[test]
14275 fn fonte_pin_missing_fires_before_pin_empty() {
14276 // Order pin: a fully-None pin set is structurally distinct from
14277 // a Some(empty) pin — the first surfaces as FontePinMissing
14278 // (no axis chosen), the second as FontePinEmpty (axis chosen
14279 // but value blank). Pin the disjoint relationship so a future
14280 // unification collapses to one variant only as a structural
14281 // decision.
14282 let d = dep_with_fonte(DepSource::Git {
14283 repo: "github:pleme-io/caixa-teia".into(),
14284 tag: None,
14285 rev: None,
14286 branch: None,
14287 });
14288 assert!(matches!(
14289 d.validate().unwrap_err(),
14290 DepError::FontePinMissing { .. }
14291 ));
14292 }
14293
14294 #[test]
14295 fn nome_empty_takes_precedence_over_fonte_invalid() {
14296 // Order pin: a per-entry diagnostic without a non-empty :nome
14297 // can't be self-locating, so :nome "" fires first even when
14298 // :fonte is also malformed. Mirrors
14299 // `nome_empty_takes_precedence_over_versao_invalid` on the
14300 // adjacent axis.
14301 let mut d = dep_with_fonte(DepSource::Git {
14302 repo: String::new(),
14303 tag: None,
14304 rev: None,
14305 branch: None,
14306 });
14307 d.nome = String::new();
14308 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14309 }
14310
14311 #[test]
14312 fn versao_invalid_takes_precedence_over_fonte_invalid() {
14313 // Order pin: the :versao parse-side diagnostic is narrower than
14314 // the :fonte shape diagnostic — a malformed :versao always names
14315 // the parser's reason, which is more actionable than the
14316 // :fonte gate's "the pins are wrong" wording. Pin the ordering
14317 // so a re-ordering surfaces here.
14318 let mut d = dep_with_fonte(DepSource::Git {
14319 repo: String::new(),
14320 tag: None,
14321 rev: None,
14322 branch: None,
14323 });
14324 d.versao = "v0.1".into();
14325 let err = d.validate().unwrap_err();
14326 assert!(
14327 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14328 "got {err:?}"
14329 );
14330 }
14331
14332 #[test]
14333 fn fonte_invalid_diagnostic_carries_offending_nome() {
14334 // The diagnostic-shape pin: every :fonte error variant names
14335 // the offending dep's :nome verbatim, so the author can grep
14336 // caixa.lisp for the `:nome "<n>"` block and fix it in one
14337 // edit. Cover all seven variants so a future variant addition
14338 // forces a parallel diagnostic-shape decision.
14339 for (case, fonte) in [
14340 (
14341 "repo-empty",
14342 DepSource::Git {
14343 repo: String::new(),
14344 tag: Some("v1".into()),
14345 rev: None,
14346 branch: None,
14347 },
14348 ),
14349 (
14350 "repo-shape",
14351 DepSource::Git {
14352 repo: "github:p/x ".into(),
14353 tag: Some("v1".into()),
14354 rev: None,
14355 branch: None,
14356 },
14357 ),
14358 (
14359 "pin-missing",
14360 DepSource::Git {
14361 repo: "github:p/x".into(),
14362 tag: None,
14363 rev: None,
14364 branch: None,
14365 },
14366 ),
14367 (
14368 "pin-ambiguous",
14369 DepSource::Git {
14370 repo: "github:p/x".into(),
14371 tag: Some("v1".into()),
14372 rev: None,
14373 branch: Some("main".into()),
14374 },
14375 ),
14376 (
14377 "pin-empty",
14378 DepSource::Git {
14379 repo: "github:p/x".into(),
14380 tag: Some(String::new()),
14381 rev: None,
14382 branch: None,
14383 },
14384 ),
14385 (
14386 "caminho-empty",
14387 DepSource::Path {
14388 caminho: String::new(),
14389 },
14390 ),
14391 (
14392 "caminho-absolute",
14393 DepSource::Path {
14394 caminho: "/home/me/work/caixa-teia".into(),
14395 },
14396 ),
14397 ] {
14398 let d = dep_with_fonte(fonte);
14399 let msg = d
14400 .validate()
14401 .expect_err(&format!("{case}: expected fonte error"))
14402 .to_string();
14403 assert!(
14404 msg.contains("\"caixa-teia\""),
14405 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14406 );
14407 }
14408 }
14409
14410 // -- :tag / :branch value-shape gate ----------------------------------
14411
14412 #[test]
14413 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14414 // The canonical paste-from-doc footgun on `:tag` — author
14415 // copies `"v0.1.0 "` (trailing space) out of a release-notes
14416 // paragraph. Until this gate landed the empty-pin arm passed
14417 // (the string isn't empty), the resolver issued
14418 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14419 // surfaced at clone time with a quoting-confused git error
14420 // far from the source caixa.lisp. The new gate moves the
14421 // check to caixa-build time and names the offending dep +
14422 // pin + value verbatim.
14423 let d = dep_with_fonte(DepSource::Git {
14424 repo: "github:pleme-io/caixa-teia".into(),
14425 tag: Some("v0.1.0 ".into()),
14426 rev: None,
14427 branch: None,
14428 });
14429 let err = d.validate().unwrap_err();
14430 let DepError::FontePinShape {
14431 nome,
14432 pin,
14433 value,
14434 reason,
14435 } = err
14436 else {
14437 panic!("expected FontePinShape, got other variant");
14438 };
14439 assert_eq!(nome, "caixa-teia");
14440 assert_eq!(pin, ":tag");
14441 assert_eq!(value, "v0.1.0 ");
14442 assert!(
14443 reason.contains("whitespace"),
14444 "reason must surface the whitespace arm, got {reason:?}"
14445 );
14446 }
14447
14448 #[test]
14449 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14450 // The `.lock` suffix is git's atomic-rename guard for
14451 // in-flight ref updates — a refname ending in `.lock` is
14452 // unwritable on disk. Pinned separately from the whitespace
14453 // arm so a future relaxation that admits one but not the
14454 // other surfaces here.
14455 let d = dep_with_fonte(DepSource::Git {
14456 repo: "github:pleme-io/caixa-teia".into(),
14457 tag: Some("v0.1.0.lock".into()),
14458 rev: None,
14459 branch: None,
14460 });
14461 let err = d.validate().unwrap_err();
14462 let DepError::FontePinShape {
14463 pin, value, reason, ..
14464 } = err
14465 else {
14466 panic!("expected FontePinShape, got other variant");
14467 };
14468 assert_eq!(pin, ":tag");
14469 assert_eq!(value, "v0.1.0.lock");
14470 assert!(
14471 reason.contains(".lock"),
14472 "reason must surface the .lock arm, got {reason:?}"
14473 );
14474 }
14475
14476 #[test]
14477 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14478 // The canonical "branch name with spaces" footgun (`feature
14479 // foo`, `release branch`) — git's refname parser rejects raw
14480 // whitespace, and the failure surfaces at `git checkout
14481 // 'feature foo'` time with a quoting-confused error far from
14482 // the source caixa.lisp. Pinned on the `:branch` axis so the
14483 // gate-applies-to-both-:tag-and-:branch contract is a build-
14484 // error to relax.
14485 let d = dep_with_fonte(DepSource::Git {
14486 repo: "github:pleme-io/caixa-teia".into(),
14487 tag: None,
14488 rev: None,
14489 branch: Some("feature/foo bar".into()),
14490 });
14491 let err = d.validate().unwrap_err();
14492 let DepError::FontePinShape {
14493 pin, value, reason, ..
14494 } = err
14495 else {
14496 panic!("expected FontePinShape, got other variant");
14497 };
14498 assert_eq!(pin, ":branch");
14499 assert_eq!(value, "feature/foo bar");
14500 assert!(
14501 reason.contains("whitespace"),
14502 "reason must surface the whitespace arm, got {reason:?}"
14503 );
14504 }
14505
14506 #[test]
14507 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14508 // The `refs/heads/main` shape — the canonical "I copied the
14509 // fully-qualified ref out of `git show-ref` instead of the
14510 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14511 // at clone time, so this resolves to a literal ref named
14512 // `refs/heads/refs/heads/main` on disk; the silent double-
14513 // prefix is the load-bearing reason to gate at validate.
14514 // The diagnostic must enumerate the leaf the author probably
14515 // meant (`"main"`) so the fix is one edit.
14516 let d = dep_with_fonte(DepSource::Git {
14517 repo: "github:pleme-io/caixa-teia".into(),
14518 tag: None,
14519 rev: None,
14520 branch: Some("refs/heads/main".into()),
14521 });
14522 let err = d.validate().unwrap_err();
14523 let DepError::FontePinShape {
14524 pin, value, reason, ..
14525 } = err
14526 else {
14527 panic!("expected FontePinShape, got other variant");
14528 };
14529 assert_eq!(pin, ":branch");
14530 assert_eq!(value, "refs/heads/main");
14531 assert!(
14532 reason.contains("fully-qualified"),
14533 "reason must surface the qualified-prefix arm, got {reason:?}"
14534 );
14535 assert!(
14536 reason.contains("\"main\""),
14537 "reason must quote the leaf the author probably meant, got {reason:?}"
14538 );
14539 }
14540
14541 #[test]
14542 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14543 // Sibling arm of the qualified-prefix gate on the `:tag`
14544 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14545 // footgun). Pinned separately so a future relaxation that
14546 // only catches the `:branch` arm surfaces here.
14547 let d = dep_with_fonte(DepSource::Git {
14548 repo: "github:pleme-io/caixa-teia".into(),
14549 tag: Some("refs/tags/v0.1.0".into()),
14550 rev: None,
14551 branch: None,
14552 });
14553 let err = d.validate().unwrap_err();
14554 let DepError::FontePinShape {
14555 pin, value, reason, ..
14556 } = err
14557 else {
14558 panic!("expected FontePinShape, got other variant");
14559 };
14560 assert_eq!(pin, ":tag");
14561 assert_eq!(value, "refs/tags/v0.1.0");
14562 assert!(
14563 reason.contains("fully-qualified"),
14564 "reason must surface the qualified-prefix arm, got {reason:?}"
14565 );
14566 assert!(
14567 reason.contains("\"v0.1.0\""),
14568 "reason must quote the leaf the author probably meant, got {reason:?}"
14569 );
14570 }
14571
14572 #[test]
14573 fn validate_rejects_git_fonte_with_branch_named_at() {
14574 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14575 // unsourceable. Pinned so a future relaxation that admits
14576 // any single-character refname surfaces here.
14577 let d = dep_with_fonte(DepSource::Git {
14578 repo: "github:pleme-io/caixa-teia".into(),
14579 tag: None,
14580 rev: None,
14581 branch: Some("@".into()),
14582 });
14583 let err = d.validate().unwrap_err();
14584 let DepError::FontePinShape { pin, value, .. } = err else {
14585 panic!("expected FontePinShape, got other variant");
14586 };
14587 assert_eq!(pin, ":branch");
14588 assert_eq!(value, "@");
14589 }
14590
14591 #[test]
14592 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14593 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14594 // a `:tag "../escape"` (path-traversal-shaped slug) silently
14595 // passes parse and surfaces as a refname-parse error or, on
14596 // older git, a literal `../escape` checkout that escapes the
14597 // refs/ directory tree. Pinned separately from the
14598 // qualified-prefix arm so a future relaxation that catches
14599 // one but not the other surfaces here.
14600 let d = dep_with_fonte(DepSource::Git {
14601 repo: "github:pleme-io/caixa-teia".into(),
14602 tag: Some("../escape".into()),
14603 rev: None,
14604 branch: None,
14605 });
14606 let err = d.validate().unwrap_err();
14607 let DepError::FontePinShape { pin, value, .. } = err else {
14608 panic!("expected FontePinShape, got other variant");
14609 };
14610 assert_eq!(pin, ":tag");
14611 assert_eq!(value, "../escape");
14612 }
14613
14614 #[test]
14615 fn validate_accepts_git_fonte_with_hierarchical_branch() {
14616 // The positive-control pin: hierarchical refnames with one or
14617 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14618 // canonical idiom) round-trip through the gate. Pinned
14619 // separately from the leaf-`"main"` positive control so a
14620 // future tightening that rejects all multi-component refnames
14621 // surfaces here.
14622 let d = dep_with_fonte(DepSource::Git {
14623 repo: "github:pleme-io/caixa-teia".into(),
14624 tag: None,
14625 rev: None,
14626 branch: Some("feature/checkout-rewrite".into()),
14627 });
14628 d.validate().unwrap();
14629 }
14630
14631 #[test]
14632 fn validate_accepts_git_fonte_with_prerelease_tag() {
14633 // The positive-control pin: semver pre-release shape
14634 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14635 // (only consecutive `..` and trailing `.` are rejected), the
14636 // mid-component hyphen is allowed. Pinned separately from
14637 // the bare-`"v0.1.0"` positive control so a future tightening
14638 // that rejects pre-release tags surfaces here.
14639 let d = dep_with_fonte(DepSource::Git {
14640 repo: "github:pleme-io/caixa-teia".into(),
14641 tag: Some("v0.1.0-alpha.1".into()),
14642 rev: None,
14643 branch: None,
14644 });
14645 d.validate().unwrap();
14646 }
14647
14648 #[test]
14649 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14650 // The `:rev` axis is routed through `crate::render::is_git_oid`
14651 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14652 // value with refname-shape punctuation (here, a `:` mid-string
14653 // — would be a refname violation under `is_git_ref_name` too)
14654 // is rejected at the OID-shape gate. The two predicates
14655 // partition the `:fonte` pin axes structurally: an `:rev` value
14656 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14657 // *still* rejected here because every refname character outside
14658 // `[0-9a-f]` fails the OID gate. Same shape as
14659 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14660 // on the refname-shaped axes — the diagnostic names the
14661 // offending dep + pin + value verbatim. The flip-from-accept
14662 // case the prior `:tag`/`:branch` gate left as a "future axis"
14663 // (e70d213) — now landed.
14664 let d = dep_with_fonte(DepSource::Git {
14665 repo: "github:pleme-io/caixa-teia".into(),
14666 tag: None,
14667 rev: Some("c0ffee:notarefname".into()),
14668 branch: None,
14669 });
14670 let err = d.validate().unwrap_err();
14671 let DepError::FontePinShape {
14672 nome,
14673 pin,
14674 value,
14675 reason,
14676 } = err
14677 else {
14678 panic!("expected FontePinShape, got other variant");
14679 };
14680 assert_eq!(nome, "caixa-teia");
14681 assert_eq!(pin, ":rev");
14682 assert_eq!(value, "c0ffee:notarefname");
14683 assert!(
14684 !reason.is_empty(),
14685 "FontePinShape `reason` must carry the predicate's wording verbatim"
14686 );
14687 }
14688
14689 #[test]
14690 fn validate_accepts_git_fonte_with_rev_full_sha1() {
14691 // The positive-control pin on the SHA-1 OID width: exactly 40
14692 // lowercase hex characters — the canonical `git rev-parse HEAD`
14693 // emission on a SHA-1-hashed repository (the default on every
14694 // pre-2.42 git and the canonical pleme-io substrate hash).
14695 // Pinned separately from the SHA-256 positive control so a
14696 // future tightening that only admits one width surfaces here.
14697 let d = dep_with_fonte(DepSource::Git {
14698 repo: "github:pleme-io/caixa-teia".into(),
14699 tag: None,
14700 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14701 branch: None,
14702 });
14703 d.validate().unwrap();
14704 }
14705
14706 #[test]
14707 fn validate_accepts_git_fonte_with_rev_full_sha256() {
14708 // The positive-control pin on the SHA-256 OID width: exactly
14709 // 64 lowercase hex characters — `git`'s
14710 // `extensions.objectFormat = sha256` emission (GA since Git
14711 // 2.42 / Oct 2023). The substrate admits either canonical
14712 // width so an `:rev` authored against a SHA-256-hashed
14713 // upstream round-trips through the gate without per-repo
14714 // configuration. Pinned separately from the SHA-1 positive
14715 // control so a future tightening that drops one width surfaces
14716 // here as a structural decision.
14717 let d = dep_with_fonte(DepSource::Git {
14718 repo: "github:pleme-io/caixa-teia".into(),
14719 tag: None,
14720 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14721 branch: None,
14722 });
14723 d.validate().unwrap();
14724 }
14725
14726 #[test]
14727 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14728 // The canonical `git log --short` / `git rev-parse --short HEAD`
14729 // paste-from-release-notes footgun: a 7-char prefix (git's
14730 // default `core.abbrev`) silently passes string emptiness
14731 // checks and resolves to one commit today, but becomes ambiguous
14732 // tomorrow as the repo grows. Until this gate landed the empty-
14733 // pin arm passed (the string isn't empty) and the resolver
14734 // accepted the prefix through git's separate prefix-lookup pass
14735 // — defeating the reproducibility contract `:rev` carries vs.
14736 // `:tag` / `:branch`. The new gate moves the check to caixa-
14737 // build time and names the offending dep + pin + value verbatim.
14738 let d = dep_with_fonte(DepSource::Git {
14739 repo: "github:pleme-io/caixa-teia".into(),
14740 tag: None,
14741 rev: Some("c0ffee0".into()),
14742 branch: None,
14743 });
14744 let err = d.validate().unwrap_err();
14745 let DepError::FontePinShape {
14746 pin, value, reason, ..
14747 } = err
14748 else {
14749 panic!("expected FontePinShape, got other variant");
14750 };
14751 assert_eq!(pin, ":rev");
14752 assert_eq!(value, "c0ffee0");
14753 assert!(
14754 reason.contains("abbreviated") || reason.contains("ambiguous"),
14755 "reason must surface the abbreviation arm, got {reason:?}"
14756 );
14757 }
14758
14759 #[test]
14760 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14761 // The canonical "I pasted the SHA in uppercase" footgun: `git
14762 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14763 // bearing `:rev` round-trips inconsistently across the
14764 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14765 // equality-check pipeline and fails the lacre's content-
14766 // addressing probe with a confusing case-only diff. Pinned
14767 // separately from the non-hex arm so a future relaxation that
14768 // admits one but not the other surfaces here.
14769 let d = dep_with_fonte(DepSource::Git {
14770 repo: "github:pleme-io/caixa-teia".into(),
14771 tag: None,
14772 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14773 branch: None,
14774 });
14775 let err = d.validate().unwrap_err();
14776 let DepError::FontePinShape {
14777 pin, value, reason, ..
14778 } = err
14779 else {
14780 panic!("expected FontePinShape, got other variant");
14781 };
14782 assert_eq!(pin, ":rev");
14783 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14784 assert!(
14785 reason.contains("uppercase"),
14786 "reason must surface the uppercase arm, got {reason:?}"
14787 );
14788 }
14789
14790 #[test]
14791 fn validate_rejects_git_fonte_with_rev_refname_value() {
14792 // The cross-axis mis-slot footgun: `:rev "main"` — the author
14793 // conflated `:rev` (hex commit ID, immutable) and `:branch`
14794 // (mutable ref pointing at whatever HEAD is today). Until this
14795 // gate landed the resolver silently dispatched on the value
14796 // shape ("`main` doesn't look like a SHA, fall back to
14797 // refname"), defeating the `:rev` reproducibility contract.
14798 // The new gate rejects every non-hex value on the `:rev` axis,
14799 // so the `:rev`/`:branch` boundary is structurally enforced —
14800 // a refname in the `:rev` slot is a build error, not a
14801 // resolver-time silent reinterpretation.
14802 let d = dep_with_fonte(DepSource::Git {
14803 repo: "github:pleme-io/caixa-teia".into(),
14804 tag: None,
14805 rev: Some("main".into()),
14806 branch: None,
14807 });
14808 let err = d.validate().unwrap_err();
14809 let DepError::FontePinShape {
14810 pin, value, reason, ..
14811 } = err
14812 else {
14813 panic!("expected FontePinShape, got other variant");
14814 };
14815 assert_eq!(pin, ":rev");
14816 assert_eq!(value, "main");
14817 // 4 chars `main` fails the length arm before the character arm,
14818 // so the diagnostic surfaces the abbreviation wording (same
14819 // path the `c0ffee0` 7-char fixture lands on); the structural
14820 // assertion is just that the `:rev "main"` value is rejected.
14821 assert!(
14822 !reason.is_empty(),
14823 "FontePinShape reason must be non-empty for refname-shaped :rev"
14824 );
14825 }
14826
14827 #[test]
14828 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14829 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14830 // conflated `:rev` and `:tag`. Pinned separately from the
14831 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14832 // that catches one but not the other surfaces here. The
14833 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14834 // assertion is just that the cross-axis mis-slot is a build
14835 // error, regardless of which sub-arm surfaces the diagnostic
14836 // (`is_git_oid` rejects at the first violation; longer
14837 // tag-shape values would hit the non-hex arm instead).
14838 let d = dep_with_fonte(DepSource::Git {
14839 repo: "github:pleme-io/caixa-teia".into(),
14840 tag: None,
14841 rev: Some("v0.1.0".into()),
14842 branch: None,
14843 });
14844 let err = d.validate().unwrap_err();
14845 let DepError::FontePinShape {
14846 pin, value, reason, ..
14847 } = err
14848 else {
14849 panic!("expected FontePinShape, got other variant");
14850 };
14851 assert_eq!(pin, ":rev");
14852 assert_eq!(value, "v0.1.0");
14853 assert!(
14854 !reason.is_empty(),
14855 "FontePinShape reason must be non-empty for tag-shaped :rev"
14856 );
14857 }
14858
14859 #[test]
14860 fn validate_rejects_git_fonte_with_rev_too_long() {
14861 // Boundary case on the upper end: 41 hex chars — one past the
14862 // SHA-1 width, well below the SHA-256 width. Pin so a future
14863 // relaxation that admits "long enough to be a SHA" without
14864 // matching either canonical width surfaces here. The diagnostic
14865 // names the offending length verbatim so the author's grep
14866 // target is unambiguous (either trim one char or paste the
14867 // full SHA-256).
14868 let too_long: String = "0".repeat(41);
14869 let d = dep_with_fonte(DepSource::Git {
14870 repo: "github:pleme-io/caixa-teia".into(),
14871 tag: None,
14872 rev: Some(too_long.clone()),
14873 branch: None,
14874 });
14875 let err = d.validate().unwrap_err();
14876 let DepError::FontePinShape {
14877 pin, value, reason, ..
14878 } = err
14879 else {
14880 panic!("expected FontePinShape, got other variant");
14881 };
14882 assert_eq!(pin, ":rev");
14883 assert_eq!(value, too_long);
14884 assert!(
14885 reason.contains("41"),
14886 "reason must surface the offending length verbatim, got {reason:?}"
14887 );
14888 }
14889
14890 #[test]
14891 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
14892 // The canonical paste-from-doc footgun on `:rev` — author
14893 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
14894 // commit-message paragraph. Until this gate landed the empty-
14895 // pin arm passed (the string isn't empty), the resolver issued
14896 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
14897 // clone time with a quoting-confused git error far from the
14898 // source caixa.lisp. The new gate moves the check to caixa-
14899 // build time. Length is 41 (40 hex + space) so the length arm
14900 // fires first — pinned separately from the pure-length arm to
14901 // ensure the diagnostic surfaces *some* parser wording, not
14902 // silently pass through.
14903 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
14904 let d = dep_with_fonte(DepSource::Git {
14905 repo: "github:pleme-io/caixa-teia".into(),
14906 tag: None,
14907 rev: Some(with_space.clone()),
14908 branch: None,
14909 });
14910 let err = d.validate().unwrap_err();
14911 let DepError::FontePinShape {
14912 pin, value, reason, ..
14913 } = err
14914 else {
14915 panic!("expected FontePinShape, got other variant");
14916 };
14917 assert_eq!(pin, ":rev");
14918 assert_eq!(value, with_space);
14919 assert!(
14920 !reason.is_empty(),
14921 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
14922 );
14923 }
14924
14925 #[test]
14926 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
14927 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
14928 // variant on this axis names the offending dep's `:nome` + the
14929 // `:rev` axis + the offending value verbatim, so the author's
14930 // grep target is the literal `:rev "<value>"` block in
14931 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
14932 // carries_offending_nome_pin_value` test on the refname-shaped
14933 // (`:tag` / `:branch`) axes.
14934 let d = dep_with_fonte(DepSource::Git {
14935 repo: "github:p/x".into(),
14936 tag: None,
14937 rev: Some("not-a-sha".into()),
14938 branch: None,
14939 });
14940 let msg = d
14941 .validate()
14942 .expect_err(":rev: expected FontePinShape")
14943 .to_string();
14944 assert!(
14945 msg.contains("\"caixa-teia\""),
14946 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14947 );
14948 assert!(
14949 msg.contains(":rev"),
14950 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
14951 );
14952 assert!(
14953 msg.contains("not-a-sha"),
14954 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
14955 );
14956 }
14957
14958 #[test]
14959 fn fonte_pin_empty_fires_before_pin_shape() {
14960 // Order pin: a `Some("")` `:tag` is the more self-locating
14961 // diagnostic (the author chose an axis but left it blank;
14962 // grep is unambiguous), so it fires before the shape gate
14963 // even when both arms would match. Pinned so a future
14964 // reordering surfaces here. Mirrors the
14965 // `fonte_repo_empty_fires_before_pin_missing` ordering
14966 // discipline on the peer per-axis arms.
14967 let d = dep_with_fonte(DepSource::Git {
14968 repo: "github:pleme-io/caixa-teia".into(),
14969 tag: Some(String::new()),
14970 rev: None,
14971 branch: None,
14972 });
14973 assert!(matches!(
14974 d.validate().unwrap_err(),
14975 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
14976 ));
14977 }
14978
14979 #[test]
14980 fn fonte_pin_shape_fires_after_repo_empty() {
14981 // Order pin: `:repo ""` is the more self-locating axis
14982 // (every git source needs a repo; the per-pin shape gate is
14983 // secondary), so the repo-empty arm fires before the
14984 // per-pin shape arm even when both are violated. Pinned so
14985 // a future reordering surfaces here. Mirrors
14986 // `fonte_repo_empty_fires_before_pin_missing` on the
14987 // adjacent axis pair.
14988 let d = dep_with_fonte(DepSource::Git {
14989 repo: String::new(),
14990 tag: Some("v0.1.0 ".into()),
14991 rev: None,
14992 branch: None,
14993 });
14994 assert!(matches!(
14995 d.validate().unwrap_err(),
14996 DepError::FonteRepoEmpty { .. }
14997 ));
14998 }
14999
15000 #[test]
15001 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15002 // Diagnostic-shape pin across both refname-shaped axes
15003 // (`:tag` + `:branch`): every `FontePinShape` variant names
15004 // the offending dep's `:nome` + the offending pin axis + the
15005 // offending value verbatim, so the author's grep target is
15006 // unambiguous (the literal `:tag "<value>"` / `:branch
15007 // "<value>"` lands in caixa.lisp with quotes). Cover both
15008 // pin axes so a future variant addition forces a parallel
15009 // diagnostic-shape decision.
15010 for (pin_label, fonte) in [
15011 (
15012 ":tag",
15013 DepSource::Git {
15014 repo: "github:p/x".into(),
15015 tag: Some("v0.1.0~1".into()),
15016 rev: None,
15017 branch: None,
15018 },
15019 ),
15020 (
15021 ":branch",
15022 DepSource::Git {
15023 repo: "github:p/x".into(),
15024 tag: None,
15025 rev: None,
15026 branch: Some("feature/foo*".into()),
15027 },
15028 ),
15029 ] {
15030 let d = dep_with_fonte(fonte);
15031 let msg = d
15032 .validate()
15033 .expect_err(&format!("{pin_label}: expected FontePinShape"))
15034 .to_string();
15035 assert!(
15036 msg.contains("\"caixa-teia\""),
15037 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15038 );
15039 assert!(
15040 msg.contains(pin_label),
15041 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15042 );
15043 }
15044 }
15045
15046 #[test]
15047 fn git_source_json_round_trip() {
15048 let src = DepSource::Git {
15049 repo: "github:pleme-io/caixa-teia".into(),
15050 tag: Some("v0.1.0".into()),
15051 rev: None,
15052 branch: None,
15053 };
15054 let s = serde_json::to_string(&src).unwrap();
15055 assert!(s.contains(&format!(
15056 r#""{tipo}":"{git}""#,
15057 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15058 git = crate::render::DEP_SOURCE_TIPO_GIT,
15059 )));
15060 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15061 assert!(s.contains(r#""tag":"v0.1.0""#));
15062 assert!(!s.contains("rev"));
15063 assert!(!s.contains("branch"));
15064 let round: DepSource = serde_json::from_str(&s).unwrap();
15065 assert_eq!(round, src);
15066 }
15067
15068 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15069 //
15070 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15071 // attribute on [`DepSource`] pins three load-bearing byte-sequences
15072 // that flow into every serialized `Dep.fonte` block: the outer
15073 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15074 // the two admitted variant-tag values `"git"` / `"path"` the
15075 // `rename_all = "lowercase"` attribute pins as the discriminator's
15076 // closed-set arms. The three pin tests below round-trip a
15077 // fully-populated variant of each arm through
15078 // [`serde_json::to_value`] and assert each canonical byte-sequence
15079 // appears at its axis — pins a hypothetical future
15080 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15081 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15082 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15083 // at build time rather than at fetch time when the resolver's
15084 // `Dep.fonte` dispatch silently fails to match on the drifted
15085 // discriminator. Same "serialize-and-check" discipline the peer
15086 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15087 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15088 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15089 // family in caixa-core lacking a lifted peer.
15090
15091 #[test]
15092 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15093 // Fail-before-pass-after: a future `tag = "type"` at the derive
15094 // attribute would serialize under `"type":"git"`, and this test
15095 // would trip because `"tipo"` no longer appears at the emitted
15096 // discriminator key. A future `rename_all = "kebab-case"` /
15097 // `"snake_case"` (both no-ops on `Git` since it lacks internal
15098 // word boundaries) is caught by the sibling
15099 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15100 // pin below (Path has no internal boundary either but the pair
15101 // catches any per-arm inconsistency). A future variant rename
15102 // `Git` → `Repository` would emit `"tipo":"repository"` and
15103 // trip this pin.
15104 let src = DepSource::Git {
15105 repo: "github:pleme-io/caixa-teia".into(),
15106 tag: Some("v0.1.0".into()),
15107 rev: None,
15108 branch: None,
15109 };
15110 let json = serde_json::to_value(&src).unwrap();
15111 let obj = json.as_object().expect("Git serializes as a JSON object");
15112 assert_eq!(
15113 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15114 .and_then(serde_json::Value::as_str),
15115 Some(crate::render::DEP_SOURCE_TIPO_GIT),
15116 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15117 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15118 detected in {json}"
15119 );
15120 }
15121
15122 #[test]
15123 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15124 // Fail-before-pass-after: a future variant rename `Path` →
15125 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15126 // this pin. A per-consumer disambiguation as the `defcaixa`
15127 // macro stabilizes ("caminho" → "path" for English-uniformity)
15128 // is scoped to the inner field key, not the discriminator; this
15129 // pin is orthogonal to that and catches only the outer
15130 // discriminator drift.
15131 let src = DepSource::Path {
15132 caminho: "../caixa-teia".into(),
15133 };
15134 let json = serde_json::to_value(&src).unwrap();
15135 let obj = json.as_object().expect("Path serializes as a JSON object");
15136 assert_eq!(
15137 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15138 .and_then(serde_json::Value::as_str),
15139 Some(crate::render::DEP_SOURCE_TIPO_PATH),
15140 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15141 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15142 detected in {json}"
15143 );
15144 }
15145
15146 #[test]
15147 fn dep_source_key_consts_are_pairwise_distinct() {
15148 // Cross-axis collapse detector: a hypothetical future edit that
15149 // accidentally set two of the three consts to the same byte
15150 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15151 // pass every per-arm serialize pin above but silently collapse
15152 // the discriminator's closed-set arms onto one another; this pin
15153 // catches the collapse at build time.
15154 assert_ne!(
15155 crate::render::DEP_SOURCE_KEY_TIPO,
15156 crate::render::DEP_SOURCE_TIPO_GIT,
15157 );
15158 assert_ne!(
15159 crate::render::DEP_SOURCE_KEY_TIPO,
15160 crate::render::DEP_SOURCE_TIPO_PATH,
15161 );
15162 assert_ne!(
15163 crate::render::DEP_SOURCE_TIPO_GIT,
15164 crate::render::DEP_SOURCE_TIPO_PATH,
15165 );
15166 }
15167
15168 #[test]
15169 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15170 // Shape pin against `rename_all` drift: the two variant-tag
15171 // consts must be ASCII-lowercase-only to match the
15172 // `rename_all = "lowercase"` attribute the derive uses; a future
15173 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15174 // would emit `"GIT"` / `"Git"` instead and trip this pin.
15175 for (label, s) in [
15176 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15177 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15178 ] {
15179 assert!(!s.is_empty(), "{label} must not be empty");
15180 assert!(
15181 s.bytes().all(|b| b.is_ascii_lowercase()),
15182 "{label} must be ASCII-lowercase-only (matching \
15183 rename_all = \"lowercase\"), got {s:?}",
15184 );
15185 }
15186 }
15187
15188 // ── per-entry :caracteristicas set-not-multiset gate ────────────
15189 //
15190 // Every Vec-keyed-by-name authoring surface on the typed Caixa
15191 // surface that identifies its entries by a name field now uniformly
15192 // closes the set-not-multiset discipline at build time (cite
15193 // `validate_caracteristicas`'s peer-axis enumeration). The
15194 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15195 // set-shaped (a feature is either enabled or not — there is no
15196 // `feature × 2` semantic), so two entries naming the same feature
15197 // are a redundant declaration the caixa-resolver's lacre pipeline
15198 // would silently dedup at resolve time. The empty-feature arm
15199 // closes the parallel "operationally-meaningless value" axis on
15200 // the same slot. Same linear-walk + `HashSet` + first-collision
15201 // shape every peer set gate uses; same empty-first cascade every
15202 // peer per-entry shape + duplicate gate uses (the empty-feature
15203 // axis is the more-actionable defect since two `""` entries would
15204 // both report `caracteristica: ""` under a duplicate-first
15205 // ordering, with no way to distinguish the offending site).
15206
15207 fn dep_with_features(features: &[&str]) -> Dep {
15208 Dep {
15209 nome: "caixa-teia".into(),
15210 versao: "^0.1".into(),
15211 fonte: None,
15212 opcional: false,
15213 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15214 }
15215 }
15216
15217 #[test]
15218 fn validate_rejects_empty_caracteristica() {
15219 // Fail-before-pass-after pin: every pre-gate codebase accepted
15220 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15221 // imposed no per-entry shape contract), the dep validated, and
15222 // the empty feature would have reached the future caixa-resolver
15223 // lacre pipeline as a no-op feature enable — silently dropping
15224 // the author's intent far from the source `caixa.lisp`. The new
15225 // gate surfaces the structural defect at the typed-validate
15226 // surface with a self-locating diagnostic naming the offending
15227 // dep's `:nome`.
15228 let d = dep_with_features(&[""]);
15229 assert!(
15230 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15231 "expected CaracteristicaEmpty, got {:?}",
15232 d.validate(),
15233 );
15234 }
15235
15236 #[test]
15237 fn validate_rejects_duplicate_caracteristica() {
15238 // Fail-before-pass-after pin on the set-not-multiset arm: the
15239 // feature-toggle slot is set-shaped, so `(:caracteristicas
15240 // ("http" "http"))` is a redundant declaration the lacre
15241 // pipeline dedupes silently at resolve time. The diagnostic
15242 // names the offending dep + the colliding feature verbatim so
15243 // the author can grep their caixa.lisp for `:caracteristicas`
15244 // and fix it in one edit. First-collision determinism is
15245 // pinned separately below.
15246 let d = dep_with_features(&["http", "http"]);
15247 assert!(
15248 matches!(
15249 d.validate().unwrap_err(),
15250 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15251 if nome == "caixa-teia" && caracteristica == "http"
15252 ),
15253 "expected CaracteristicaDuplicate, got {:?}",
15254 d.validate(),
15255 );
15256 }
15257
15258 #[test]
15259 fn validate_accepts_distinct_caracteristicas() {
15260 // The canonical authoring shape — every feature distinct — must
15261 // remain a clean pass (positive control sweep). Covers the
15262 // canonical kebab-case feature names a target caixa typically
15263 // declares.
15264 dep_with_features(&["http", "json", "tls"])
15265 .validate()
15266 .unwrap();
15267 }
15268
15269 #[test]
15270 fn validate_accepts_single_caracteristica() {
15271 // Single-element list is the minimum non-empty shape; passes
15272 // the gate as the identity of the duplicate check (no second
15273 // entry to collide with).
15274 dep_with_features(&["http"]).validate().unwrap();
15275 }
15276
15277 #[test]
15278 fn validate_accepts_empty_caracteristicas_list() {
15279 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15280 // produces `caracteristicas: Vec::new()`; the empty list is
15281 // the gate's empty-set identity and passes vacuously. Pin
15282 // this so a future tightening that requires ≥1 feature
15283 // surfaces here as a test failure rather than a silent
15284 // contract narrowing.
15285 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15286 assert!(dep_with_features(&[]).validate().is_ok());
15287 }
15288
15289 #[test]
15290 fn validate_caracteristica_empty_fires_before_duplicate() {
15291 // Empty-first cascade: an entry with an empty feature *and*
15292 // duplicate entries surfaces the empty diagnostic first. The
15293 // empty-feature axis is the more-actionable defect since
15294 // `caracteristica: ""` is unambiguous; under duplicate-first
15295 // ordering the diagnostic could report the empty string from
15296 // either of two empty entries with no way to distinguish.
15297 // Mirrors the peer empty-before-duplicate ordering
15298 // discipline every per-entry shape + duplicate gate establishes
15299 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15300 // `DuplicateChildCaixa`, `validate_membros`'s
15301 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15302 let d = dep_with_features(&["", "http", "http"]);
15303 assert!(matches!(
15304 d.validate().unwrap_err(),
15305 DepError::CaracteristicaEmpty { .. }
15306 ));
15307 }
15308
15309 #[test]
15310 fn validate_caracteristica_duplicate_first_collision_determinism() {
15311 // Three matching entries: the second occurrence surfaces the
15312 // diagnostic (the second is the first *collision* — the first
15313 // entry is the establishing one, not a duplicate). Mirrors
15314 // every peer first-collision posture
15315 // (`SupervisorError::DuplicateChildCaixa` reports the second
15316 // collision, `AplicacaoError::MembroDuplicate` reports the
15317 // second, `DepError::DuplicateNome` reports the second).
15318 // Pinning this so a future shortcut that flips to last-
15319 // collision (or non-deterministic) surfaces here.
15320 let d = dep_with_features(&["http", "http", "http"]);
15321 assert!(matches!(
15322 d.validate().unwrap_err(),
15323 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15324 ));
15325 }
15326
15327 #[test]
15328 fn validate_per_entry_shape_fires_before_caracteristicas() {
15329 // Per-entry shape precedence: a dep with a malformed `:nome`
15330 // (uppercase) AND duplicate `:caracteristicas` surfaces the
15331 // narrower `NomeInvalid` diagnostic first, not the set-gate
15332 // diagnostic. The `:nome` is the self-locating axis (every
15333 // diagnostic from the caracteristicas gate quotes the
15334 // offending dep's `:nome` to anchor the grep target —
15335 // surfacing the malformed name first keeps that anchor
15336 // valid). Same precedence shape every peer per-entry-shape
15337 // arm establishes against its peer set-gate
15338 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15339 // on the cross-entry `:nome` axis).
15340 let d = Dep {
15341 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15342 versao: "^0.1".into(),
15343 fonte: None,
15344 opcional: false,
15345 caracteristicas: vec!["http".into(), "http".into()],
15346 };
15347 assert!(matches!(
15348 d.validate().unwrap_err(),
15349 DepError::NomeInvalid { .. }
15350 ));
15351 }
15352
15353 // ── per-entry :caracteristicas value-shape gate ──────────────────
15354 //
15355 // Until this gate landed `:caracteristicas` only refused the empty
15356 // string and cross-entry duplicates: a non-empty distinct but
15357 // structurally invalid feature name silently passed validate and the
15358 // failure surfaced at `cargo metadata` time as Cargo's
15359 // `restricted_names::validate_feature_name` parser rejection, far from
15360 // the source `caixa.lisp` with no field naming which `:deps` entry's
15361 // `:caracteristicas` carried the typo. The lifted predicate makes the
15362 // Cargo-feature-name-grammar intersection-floor a substrate-level
15363 // invariant at validate time. Same trajectory as the eight peer
15364 // value-shape predicates each typed surface downstream of a structured
15365 // grammar already follows.
15366
15367 #[test]
15368 fn validate_rejects_caracteristica_with_leading_plus() {
15369 // Fail-before-pass-after pin on the canonical Cargo
15370 // `+<feature>` activation-form-in-feature-name-slot footgun.
15371 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15372 // `+optional-feature` as an enablement of a previously-disabled
15373 // feature; pasting that activation form into `:caracteristicas`
15374 // (which names the feature itself) silently passed pre-gate and
15375 // failed at `cargo metadata` parse time.
15376 let d = dep_with_features(&["+http"]);
15377 let err = d.validate().unwrap_err();
15378 assert!(
15379 matches!(
15380 err,
15381 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15382 if nome == "caixa-teia" && caracteristica == "+http"
15383 ),
15384 "expected CaracteristicaInvalid, got {err:?}"
15385 );
15386 }
15387
15388 #[test]
15389 fn validate_rejects_caracteristica_with_leading_hyphen() {
15390 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15391 // is a legitimate continuation character (kebab-case feature
15392 // names like `runtime-tokio` pass) but Cargo rejects it at the
15393 // start; the structural defect — and its CLI-argument-injection
15394 // adjacency at any downstream Cargo subprocess invocation — is
15395 // closed at validate time, not at `cargo metadata` time.
15396 let d = dep_with_features(&["-json"]);
15397 let err = d.validate().unwrap_err();
15398 assert!(
15399 matches!(
15400 err,
15401 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15402 ),
15403 "expected CaracteristicaInvalid, got {err:?}"
15404 );
15405 }
15406
15407 #[test]
15408 fn validate_rejects_caracteristica_with_leading_dot() {
15409 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15410 // a legitimate continuation character (version-suffix shapes
15411 // like `feat.v2` pass) but the leading-dot form is the
15412 // canonical dotted-version-suffix-as-feature-name confusion.
15413 let d = dep_with_features(&[".feat"]);
15414 let err = d.validate().unwrap_err();
15415 assert!(matches!(
15416 err,
15417 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15418 ));
15419 }
15420
15421 #[test]
15422 fn validate_rejects_caracteristica_with_whitespace() {
15423 // Fail-before-pass-after pin on the embedded-whitespace footgun:
15424 // a feature name with a space inside is structurally a multi-
15425 // token blob (the canonical paste-from-doc footgun, or an
15426 // accidental `"http server"` where the author meant
15427 // `"http-server"`).
15428 let d = dep_with_features(&["http feature"]);
15429 let err = d.validate().unwrap_err();
15430 assert!(matches!(
15431 err,
15432 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15433 ));
15434 }
15435
15436 #[test]
15437 fn validate_rejects_caracteristica_with_comma() {
15438 // Fail-before-pass-after pin on the embedded-comma footgun:
15439 // the list-separator-belongs-to-the-list-grammar
15440 // miscomprehension where the author writes
15441 // `:caracteristicas ("http,json")` intending two features but
15442 // the `Vec<String>` field consumes the bare token as one entry.
15443 let d = dep_with_features(&["http,json"]);
15444 let err = d.validate().unwrap_err();
15445 assert!(matches!(
15446 err,
15447 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15448 ));
15449 }
15450
15451 #[test]
15452 fn validate_rejects_caracteristica_with_slash() {
15453 // Fail-before-pass-after pin on the embedded-slash footgun:
15454 // Cargo's `dep/feat` namespaced-dep syntax applies inside
15455 // `[dependencies.<dep>.features]` list entries that already
15456 // name the parent dep (so the syntax says "enable feature
15457 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15458 // per-dep already (a sibling slot on the `Dep` itself), so the
15459 // segment separator within an entry must be `-`, `_`, `+`,
15460 // or `.`. The diagnostic remediation points at the canonical
15461 // Cargo namespaced-dep discipline.
15462 let d = dep_with_features(&["http/json"]);
15463 let err = d.validate().unwrap_err();
15464 assert!(matches!(
15465 err,
15466 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15467 ));
15468 }
15469
15470 #[test]
15471 fn validate_rejects_caracteristica_with_non_ascii() {
15472 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15473 // byte footgun: NFC-vs-NFD normalization across filesystems
15474 // silently rewrites the feature-key, breaking the lacre's
15475 // content-addressing invariant. Pinned at a canonical
15476 // smart-quote-paste shape (`café`) where the raw `é` byte is the
15477 // documented APFS round-trip break.
15478 let d = dep_with_features(&["caf\u{e9}"]);
15479 let err = d.validate().unwrap_err();
15480 assert!(matches!(
15481 err,
15482 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15483 ));
15484 }
15485
15486 #[test]
15487 fn validate_rejects_caracteristica_with_control_character() {
15488 // Fail-before-pass-after pin on the embedded-control-character
15489 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15490 // feature name is the canonical paste-from-multiline-doc
15491 // footgun the predicate's reason wording specifically calls out.
15492 let d = dep_with_features(&["http\njson"]);
15493 let err = d.validate().unwrap_err();
15494 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15495 }
15496
15497 #[test]
15498 fn validate_accepts_canonical_caracteristicas_shapes() {
15499 // Positive control sweep: every canonical Cargo feature name
15500 // shape the pleme-io ecosystem uses must still pass. Mirrors
15501 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15502 // sweep — drift between either landing site and the predicate's
15503 // accepted set is a build error visible at this pair of tests,
15504 // not a per-renderer "this passed validate but failed at
15505 // cargo metadata time" surprise on the next acceptance.
15506 for s in [
15507 "http",
15508 "json",
15509 "derive",
15510 "serde_json",
15511 "runtime-tokio",
15512 "tokio.full",
15513 "v0.1",
15514 "http+json",
15515 "_internal",
15516 "__private",
15517 "default",
15518 "rt-multi-thread",
15519 "feat.v2",
15520 ] {
15521 let d = dep_with_features(&[s]);
15522 d.validate().unwrap_or_else(|e| {
15523 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15524 });
15525 }
15526 }
15527
15528 #[test]
15529 fn validate_caracteristica_empty_fires_before_invalid() {
15530 // Cascade precedence pin: an entry list with both an empty
15531 // feature AND an invalid-shape feature surfaces the
15532 // `CaracteristicaEmpty` arm first (the empty value carries no
15533 // self-locating data — `caracteristica: ""` is the diagnostic
15534 // with no way to anchor a grep target — so closing the empty
15535 // axis first preserves the per-entry-shape diagnostic's
15536 // self-locating discipline). Same empty-first cascade every
15537 // peer per-entry shape gate establishes
15538 // (`SupervisorSpec::validate`'s `EmptyChildName` before
15539 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15540 // before `MembroCaixaInvalid`).
15541 let d = dep_with_features(&["", "+http"]);
15542 assert!(matches!(
15543 d.validate().unwrap_err(),
15544 DepError::CaracteristicaEmpty { .. }
15545 ));
15546 }
15547
15548 #[test]
15549 fn validate_caracteristica_invalid_fires_before_duplicate() {
15550 // Per-entry-shape precedence pin: an entry list with the same
15551 // invalid feature shape declared twice surfaces the
15552 // `CaracteristicaInvalid` diagnostic on the first entry, not
15553 // the `CaracteristicaDuplicate` on the second collision. The
15554 // per-entry shape gate fires before the cross-entry set gate
15555 // — same precedence shape every peer two-arm-plus-set gate
15556 // establishes (`SupervisorSpec::validate`'s
15557 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15558 // `validate_membros`'s `MembroCaixaInvalid` before
15559 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15560 // cross-list `DuplicateNome`).
15561 let d = dep_with_features(&["+http", "+http"]);
15562 assert!(matches!(
15563 d.validate().unwrap_err(),
15564 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15565 ));
15566 }
15567
15568 #[test]
15569 fn validate_rejects_caracteristica_at_65_byte_boundary() {
15570 // Boundary pin on the 64-byte cap — both the boundary-accepting
15571 // case and the boundary-exceeding case in one place, so a
15572 // future cap shift surfaces both arms simultaneously, mirroring
15573 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15574 // predicate-level pin at the dep-axis landing site.
15575 let max_ok = "a".repeat(64);
15576 dep_with_features(&[&max_ok])
15577 .validate()
15578 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15579 let too_long = "a".repeat(65);
15580 let d = dep_with_features(&[&too_long]);
15581 assert!(matches!(
15582 d.validate().unwrap_err(),
15583 DepError::CaracteristicaInvalid { .. }
15584 ));
15585 }
15586
15587 // ── self-dep cross-slot gate ─────────────────────────────────────
15588
15589 #[test]
15590 fn validate_no_self_dep_rejects_self_in_deps() {
15591 // A caixa whose `:deps` lists its own `:nome` is a one-node
15592 // cycle in the lacre closure's dep-graph traversal — rejected,
15593 // naming the parent and the offending list tag.
15594 let deps = vec![
15595 Dep::simple("caixa-teia", "^0.1"),
15596 Dep::simple("orquestra", "^0.1"),
15597 ];
15598 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15599 assert!(
15600 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15601 "got {err:?}"
15602 );
15603 }
15604
15605 #[test]
15606 fn validate_no_self_dep_rejects_self_in_deps_dev() {
15607 // Same gate on the `:deps-dev` axis — neither dep list is a
15608 // second-class citizen on the self-edge invariant.
15609 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15610 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15611 assert!(
15612 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15613 "got {err:?}"
15614 );
15615 }
15616
15617 #[test]
15618 fn validate_no_self_dep_deps_fires_before_deps_dev() {
15619 // Walk order pin: a caixa that self-references on both lists
15620 // surfaces the `:deps` arm first — the load-bearing axis the
15621 // lacre closure resolves at every build. Mirrors the canonical
15622 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15623 let deps = vec![Dep::simple("orquestra", "^0.1")];
15624 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15625 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15626 assert!(
15627 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15628 "got {err:?}"
15629 );
15630 }
15631
15632 #[test]
15633 fn validate_no_self_dep_accepts_distinct_names() {
15634 // Positive control: every dep names a distinct caixa. The
15635 // canonical author surface — peer of
15636 // [`validate_no_self_supervision_accepts_distinct_children`].
15637 let deps = vec![
15638 Dep::simple("caixa-teia", "^0.1"),
15639 Dep::simple("caixa-arch", "^0.1"),
15640 ];
15641 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15642 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15643 }
15644
15645 #[test]
15646 fn validate_no_self_dep_empty_lists_pass() {
15647 // A caixa with no declared deps has nothing to self-reference —
15648 // the gate is vacuously satisfied. Peer of
15649 // [`validate_no_self_supervision_empty_children_is_ok`].
15650 validate_no_self_dep(&[], &[], "orquestra").unwrap();
15651 }
15652
15653 #[test]
15654 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15655 // Diagnostic-shape pin (peer with
15656 // [`validate_no_self_supervision`]'s diagnostic): the error's
15657 // Display surfaces both the offending list tag and the
15658 // parent's `:nome` verbatim, so the author can grep their
15659 // caixa.lisp for the offending block in one edit. Names
15660 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15661 // surface — every legitimate "I want to use code from this
15662 // caixa" intent routes through one of those three slots.
15663 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15664 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15665 .unwrap_err()
15666 .to_string();
15667 assert!(
15668 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15669 "diagnostic must name the offending list tag: {rendered}",
15670 );
15671 assert!(
15672 rendered.contains("orquestra"),
15673 "diagnostic must quote the parent caixa name: {rendered}",
15674 );
15675 assert!(
15676 rendered.contains(":bibliotecas"),
15677 "diagnostic must point at the corrective code-surface slot: {rendered}",
15678 );
15679 }
15680
15681 #[test]
15682 fn validate_no_self_dep_accepts_coincidental_substring_match() {
15683 // Identity is exact-string equality, not substring — a dep
15684 // named `"orquestra-helper"` is a distinct caixa even when the
15685 // parent is `"orquestra"`. Pin the exact-match discipline so a
15686 // future relaxation that uses `contains` surfaces here, peer
15687 // with the supervision-tree and Aplicacao-membership gates
15688 // which all use exact-string equality on the typed identity.
15689 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15690 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15691 }
15692
15693 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15694
15695 #[test]
15696 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15697 // Scalar-value pin: the two author-facing kebab-case labels the
15698 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15699 // the two-list dep-graph slot axis, one arm per typed slot.
15700 // Mirrors the peer scalar-value pin the sibling
15701 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15702 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15703 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15704 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15705 // (882f498) M3 top-level author-labels, and
15706 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15707 // Supervisor top-level author-labels carry, so every kind-scoped
15708 // typed-slot-family axis routes through one canonical per-arm
15709 // declaration.
15710 //
15711 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15712 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15713 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15714 // for symmetry) lands as an edit to exactly one const, and
15715 // every consumer that reaches for the label picks it up at
15716 // build time rather than at runtime as a downstream mismatch on
15717 // a `DepError::DuplicateNome { list: … }` diagnostic far from
15718 // the rename's commit.
15719 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15720 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15721 }
15722
15723 #[test]
15724 fn dep_author_key_consts_are_pairwise_distinct() {
15725 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15726 // must not collapse onto one byte-string. A future copy-paste
15727 // slip that renamed both consts to the same value (or a rebrand
15728 // that dropped the `-dev` suffix from one but not the other)
15729 // would leave every `DepError::DuplicateNome { list: … }`
15730 // diagnostic naming an unattributable list — the linter would
15731 // route the author to the wrong caixa.lisp block, or the
15732 // cross-list precedence gate
15733 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15734 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15735 // duplicate. Peer of the sibling
15736 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15737 // other top-level kind-scoped slot-family axes carry
15738 // (implicitly held by their different byte-values today).
15739 assert_ne!(
15740 crate::render::DEP_AUTHOR_KEY_DEPS,
15741 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15742 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15743 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15744 self-locates the offending block in the author's caixa.lisp",
15745 );
15746 }
15747
15748 #[test]
15749 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15750 // Production-through-const pin: the two per-arm list tags
15751 // [`validate_no_self_dep`] threads onto the `list:` field of a
15752 // returned [`DepError::DepIsSelf`] route through the lifted
15753 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15754 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15755 // the walker (a rename that reaches one arm but not the const,
15756 // or vice versa) surfaces here at build time rather than at
15757 // runtime as a `feira lint` diagnostic naming the wrong list
15758 // tag. Mirror of the peer
15759 // [`crate::Caixa::declared_servico_slots`] production tagger
15760 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15761 // onto the two-list dep-graph gate.
15762 let deps = vec![Dep::simple("orquestra", "^0.1")];
15763 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15764 let DepError::DepIsSelf { list, .. } = err else {
15765 panic!("expected DepIsSelf from :deps walk");
15766 };
15767 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15768
15769 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15770 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15771 let DepError::DepIsSelf { list, .. } = err else {
15772 panic!("expected DepIsSelf from :deps-dev walk");
15773 };
15774 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15775 }
15776
15777 // ── Dep::nome accessor pins ───────────────────────────────────────
15778 //
15779 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15780 // projection over the plain-shorthand / explicit-git / explicit-path
15781 // fixture triad the [`Dep`] docstring lists (so the accessor's
15782 // accept-set is exercised across every author-surface `:fonte`
15783 // shape); by-borrow pointer identity so the projection stays
15784 // zero-copy at every consumer site; and validate-composition through
15785 // the [`validate_no_self_dep`] cross-slot gate reading its
15786 // parent-name equality check through the lifted accessor rather than
15787 // the raw field.
15788
15789 #[test]
15790 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15791 // Plain-shorthand form (`:fonte None`).
15792 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15793 // Explicit git-source form with a tag pin — same accessor path.
15794 assert_eq!(
15795 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15796 "caixa-teia",
15797 );
15798 // Explicit path-source form.
15799 assert_eq!(
15800 Dep {
15801 nome: "caixa-teia".to_string(),
15802 versao: "0.1.0".to_string(),
15803 fonte: Some(DepSource::Path {
15804 caminho: "../caixa-teia".to_string(),
15805 }),
15806 opcional: false,
15807 caracteristicas: Vec::new(),
15808 }
15809 .nome(),
15810 "caixa-teia",
15811 );
15812 // The empty-string `:nome` sentinel (which [`Dep::validate`]
15813 // refuses through the [`DepError::NomeEmpty`] arm) still round-
15814 // trips as an empty `&str` through the accessor — the accessor is
15815 // a projection, not a gate; the gate is [`Dep::validate`].
15816 assert_eq!(Dep::simple("", "^0.1").nome(), "");
15817 }
15818
15819 #[test]
15820 fn dep_nome_is_by_borrow_pointer_identity() {
15821 // Zero-copy pin: the accessor must borrow into the field's own
15822 // storage, not clone. If a future rewrite regresses to
15823 // `self.nome.clone().leak()` or an owned-buffer shape, the two
15824 // pointers diverge and this pin fails at build time.
15825 let d = Dep::simple("caixa-teia", "^0.1");
15826 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15827 }
15828
15829 // ── Dep::versao_requirement accessor pins ─────────────────────────
15830 //
15831 // Three coherence pins on the lifted `Dep::versao_requirement`
15832 // accessor: byte-equal projection over the plain-shorthand /
15833 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15834 // lists plus the empty-sentinel that round-trips as `""` (the accessor
15835 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15836 // borrow pointer identity so the projection stays zero-copy at every
15837 // consumer site; and validate-composition through the
15838 // [`crate::render::require_valid_versao_requirement`] cascade reading
15839 // its requirement-shape check through the lifted accessor rather than
15840 // the raw field.
15841 #[test]
15842 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15843 // Plain-shorthand form (`:fonte None`).
15844 assert_eq!(
15845 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15846 "^0.1",
15847 );
15848 // Explicit git-source form with a tag pin — same accessor path.
15849 assert_eq!(
15850 Dep::git(
15851 "caixa-teia",
15852 "~0.1.2",
15853 "github:pleme-io/caixa-teia",
15854 "v0.1.0"
15855 )
15856 .versao_requirement(),
15857 "~0.1.2",
15858 );
15859 // Explicit path-source form.
15860 assert_eq!(
15861 Dep {
15862 nome: "caixa-teia".to_string(),
15863 versao: "0.1.0".to_string(),
15864 fonte: Some(DepSource::Path {
15865 caminho: "../caixa-teia".to_string(),
15866 }),
15867 opcional: false,
15868 caracteristicas: Vec::new(),
15869 }
15870 .versao_requirement(),
15871 "0.1.0",
15872 );
15873 // The wildcard requirement (`"*"`) — the shorthand
15874 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15875 // verbatim through the accessor as `"*"`, same byte-shape the
15876 // author wrote.
15877 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15878 // The empty-string `:versao` sentinel (which [`Dep::validate`]
15879 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15880 // trips as an empty `&str` through the accessor — the accessor is
15881 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
15882 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
15883 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
15884 }
15885
15886 #[test]
15887 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
15888 // Zero-copy pin: the accessor must borrow into the field's own
15889 // storage, not clone. If a future rewrite regresses to
15890 // `self.versao.clone().leak()` or an owned-buffer shape, the two
15891 // pointers diverge and this pin fails at build time. Peer of the
15892 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
15893 // discipline extended onto the requirement-carrying axis.
15894 let d = Dep::simple("caixa-teia", "^0.1");
15895 assert!(std::ptr::eq(
15896 d.versao_requirement().as_ptr(),
15897 d.versao.as_ptr(),
15898 ));
15899 }
15900
15901 #[test]
15902 fn dep_validate_reads_requirement_through_accessor() {
15903 // Composition pin: the [`Dep::validate`]
15904 // [`crate::render::require_valid_versao_requirement`] cascade
15905 // consumes the requirement string through the lifted accessor —
15906 // both the requirement-gate input and the
15907 // [`DepError::VersaoInvalid`] error-body carrier route through
15908 // `self.versao_requirement()`. A valid requirement passes
15909 // (positive control); a malformed-but-non-empty requirement fails
15910 // and the diagnostic quotes the offending byte-string verbatim
15911 // (same shape the accessor projects), so a future regression that
15912 // detoured the requirement carrier through a different byte-
15913 // string (say the parsed `VersionReq`'s `Display`, or a
15914 // normalized rewrite) would surface here at build time. The
15915 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
15916 // ahead of the parse arm, pinning the empty-first cascade the
15917 // accessor's `""` sentinel round-trip acknowledges.
15918 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15919 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
15920 assert!(
15921 matches!(
15922 &err,
15923 DepError::VersaoInvalid {
15924 nome,
15925 versao,
15926 ..
15927 } if nome == "caixa-teia" && versao == "v0.1",
15928 ),
15929 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
15930 );
15931 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
15932 assert!(
15933 matches!(
15934 &err,
15935 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
15936 ),
15937 "expected VersaoEmpty from the empty-first arm, got {err:?}",
15938 );
15939 }
15940
15941 // ── Dep::fonte accessor pins ──────────────────────────────────────
15942 //
15943 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
15944 // equal projection over the plain-shorthand (`:fonte None`) /
15945 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
15946 // docstring lists (so the accessor's accept-set is exercised across
15947 // every author-surface `:fonte` shape and both `DepSource` variants);
15948 // pointer identity so the borrowed reference points into the field's
15949 // own `Option<DepSource>` storage (not a cloned side-buffer); and
15950 // validate-composition through the [`Dep::validate`] gate reading
15951 // its per-`:fonte` [`DepSource::validate`] delegation through the
15952 // lifted accessor rather than the raw `if let Some(ref fonte) =
15953 // self.fonte` bracket.
15954
15955 #[test]
15956 fn dep_fonte_returns_declared_source_across_shapes() {
15957 // Plain-shorthand form — `:fonte` omitted, accessor projects
15958 // the `None` partition the resolver-side default-fill treats
15959 // as "resolve through `github:<default-org>/<nome>`".
15960 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
15961 // Explicit git-source form with a tag pin — same accessor path.
15962 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
15963 match git.fonte() {
15964 Some(DepSource::Git {
15965 repo,
15966 tag,
15967 rev,
15968 branch,
15969 }) => {
15970 assert_eq!(repo, "github:pleme-io/caixa-teia");
15971 assert_eq!(tag.as_deref(), Some("v0.1.0"));
15972 assert!(rev.is_none());
15973 assert!(branch.is_none());
15974 }
15975 other => panic!("expected explicit git :fonte, got {other:?}"),
15976 }
15977 // Explicit path-source form — the dev-only local-filesystem
15978 // arm the [`Dep`] docstring's third fixture carries.
15979 let path = Dep {
15980 nome: "caixa-teia".to_string(),
15981 versao: "0.1.0".to_string(),
15982 fonte: Some(DepSource::Path {
15983 caminho: "../caixa-teia".to_string(),
15984 }),
15985 opcional: false,
15986 caracteristicas: Vec::new(),
15987 };
15988 match path.fonte() {
15989 Some(DepSource::Path { caminho }) => {
15990 assert_eq!(caminho, "../caixa-teia");
15991 }
15992 other => panic!("expected explicit path :fonte, got {other:?}"),
15993 }
15994 }
15995
15996 #[test]
15997 fn dep_fonte_is_by_borrow_pointer_identity() {
15998 // Zero-copy pin: the accessor must borrow into the field's own
15999 // `Option<DepSource>` storage, not clone into a side buffer. If
16000 // a future rewrite regresses to `self.fonte.clone()` or an
16001 // owned-buffer shape, the two pointers diverge and this pin
16002 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16003 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16004 // identity pins — same by-borrow discipline extended onto the
16005 // outer-`Dep` `Option<&Composite>` composite-reference axis.
16006 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16007 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16008 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16009 assert!(std::ptr::eq(accessed, raw));
16010 }
16011
16012 #[test]
16013 fn dep_validate_reads_fonte_through_accessor() {
16014 // Composition pin: [`Dep::validate`]'s per-`:fonte`
16015 // [`DepSource::validate`] delegation consumes the typed slot
16016 // through the lifted accessor — an author-omitted `:fonte`
16017 // still passes the outer gate (positive control), an explicit
16018 // well-formed git source with exactly one pin passes, and a
16019 // malformed git source (empty `:repo`) surfaces the
16020 // [`DepError::FonteRepoEmpty`] variant quoting the offending
16021 // dep's `:nome` verbatim so a future regression that detoured
16022 // the `:fonte` delegation through a different path (say a
16023 // per-scope override projector) would surface here at build
16024 // time. Peer of the sibling
16025 // `dep_validate_reads_requirement_through_accessor` composition
16026 // pin on the `:versao` axis.
16027 // Positive control 1: no `:fonte` at all.
16028 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16029 // Positive control 2: well-formed git source.
16030 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16031 .validate()
16032 .unwrap();
16033 // Negative control: empty `:repo` — the accessor still returns
16034 // `Some(&DepSource::Git { repo: "", … })` and the delegated
16035 // `DepSource::validate` gate raises the typed carrier.
16036 let bad = Dep {
16037 nome: "caixa-teia".to_string(),
16038 versao: "^0.1".to_string(),
16039 fonte: Some(DepSource::Git {
16040 repo: String::new(),
16041 tag: Some("v0.1.0".to_string()),
16042 rev: None,
16043 branch: None,
16044 }),
16045 opcional: false,
16046 caracteristicas: Vec::new(),
16047 };
16048 let err = bad.validate().unwrap_err();
16049 assert!(
16050 matches!(
16051 &err,
16052 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16053 ),
16054 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16055 );
16056 }
16057
16058 #[test]
16059 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16060 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16061 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16062 // own `:nome` through the lifted accessor rather than the raw
16063 // field. Fails-before-passes-after: with the accessor lifted the
16064 // gate reads its equality check through `dep.nome() ==
16065 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16066 // the diagnostic still names the offending list tag as expected.
16067 let deps = vec![Dep::simple("orquestra", "^0.1")];
16068 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16069 assert!(matches!(
16070 err,
16071 DepError::DepIsSelf {
16072 ref nome,
16073 list,
16074 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16075 ));
16076 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16077 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16078 assert!(matches!(
16079 err,
16080 DepError::DepIsSelf {
16081 ref nome,
16082 list,
16083 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16084 ));
16085 // A non-matching `:nome` passes through the accessor gate.
16086 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16087 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16088 }
16089
16090 // ── Dep::caracteristicas accessor pins ────────────────────────────
16091 //
16092 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16093 // byte-equal projection over the default-empty / single-entry /
16094 // multi-entry fixture triad (so the accessor's accept-set is
16095 // exercised across every author-surface `:caracteristicas` shape,
16096 // matching the peer sibling family's fixture-triad discipline); by-
16097 // borrow pointer identity so the projection stays zero-copy at every
16098 // consumer site; and validate-composition through the
16099 // [`Dep::validate_caracteristicas`] gate reading its per-entry
16100 // linear walk through the lifted accessor rather than the raw
16101 // `for c in &self.caracteristicas` bracket.
16102
16103 #[test]
16104 fn dep_caracteristicas_returns_declared_features_across_shapes() {
16105 // Default-empty form — the [`Dep::simple`] constructor's
16106 // `Vec::new()` fill; the accessor projects the empty slice
16107 // verbatim (no `None` collapse).
16108 assert!(
16109 Dep::simple("caixa-teia", "^0.1")
16110 .caracteristicas()
16111 .is_empty(),
16112 );
16113 // Single-entry form — the canonical Cargo-shaped one-feature
16114 // enable ([`crate::render::is_cargo_feature_name`] accepts the
16115 // `"http"` byte-string as a valid feature name).
16116 let one = Dep {
16117 nome: "caixa-teia".to_string(),
16118 versao: "^0.1".to_string(),
16119 fonte: None,
16120 opcional: false,
16121 caracteristicas: vec!["http".to_string()],
16122 };
16123 assert_eq!(one.caracteristicas(), &["http".to_string()]);
16124 // Multi-entry form — the substrate's set-shaped multi-feature
16125 // enable, exercising the accessor over a length-two slice with
16126 // no duplicate collapse.
16127 let two = Dep {
16128 nome: "caixa-teia".to_string(),
16129 versao: "^0.1".to_string(),
16130 fonte: None,
16131 opcional: false,
16132 caracteristicas: vec!["http".to_string(), "json".to_string()],
16133 };
16134 assert_eq!(
16135 two.caracteristicas(),
16136 &["http".to_string(), "json".to_string()],
16137 );
16138 }
16139
16140 #[test]
16141 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16142 // Zero-copy pin: the accessor must borrow into the field's own
16143 // `Vec<String>` storage, not clone into a side buffer. If a
16144 // future rewrite regresses to `self.caracteristicas.clone()` or
16145 // an owned-buffer shape, the two pointers diverge and this pin
16146 // fails at build time. Peer of the sibling per-`Dep`
16147 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16148 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16149 // borrow discipline extended onto the outer-`Dep` `&[String]`
16150 // slice-projection axis.
16151 let d = Dep {
16152 nome: "caixa-teia".to_string(),
16153 versao: "^0.1".to_string(),
16154 fonte: None,
16155 opcional: false,
16156 caracteristicas: vec!["http".to_string(), "json".to_string()],
16157 };
16158 assert!(std::ptr::eq(
16159 d.caracteristicas().as_ptr(),
16160 d.caracteristicas.as_ptr(),
16161 ));
16162 }
16163
16164 #[test]
16165 fn dep_validate_reads_caracteristicas_through_accessor() {
16166 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16167 // linear walk consumes the feature-toggle list through the
16168 // lifted accessor — a well-formed `:caracteristicas` set passes
16169 // (positive control), an empty-string entry surfaces the
16170 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16171 // `Dep::nome`, and a within-list duplicate surfaces the
16172 // [`DepError::CaracteristicaDuplicate`] variant so a future
16173 // regression that detoured the walk through a different byte-
16174 // string list (say a per-scope override projector) would surface
16175 // here at build time. Peer of the sibling
16176 // `dep_validate_reads_fonte_through_accessor` /
16177 // `dep_validate_reads_requirement_through_accessor` composition
16178 // pins on the `:fonte` / `:versao` axes.
16179 // Positive control: two distinct well-formed feature names pass.
16180 Dep {
16181 nome: "caixa-teia".to_string(),
16182 versao: "^0.1".to_string(),
16183 fonte: None,
16184 opcional: false,
16185 caracteristicas: vec!["http".to_string(), "json".to_string()],
16186 }
16187 .validate()
16188 .unwrap();
16189 // Negative control 1: empty-string feature-name entry — the
16190 // accessor still returns `&[""]` and the walk raises the typed
16191 // empty-first carrier.
16192 let err = Dep {
16193 nome: "caixa-teia".to_string(),
16194 versao: "^0.1".to_string(),
16195 fonte: None,
16196 opcional: false,
16197 caracteristicas: vec![String::new()],
16198 }
16199 .validate()
16200 .unwrap_err();
16201 assert!(
16202 matches!(
16203 &err,
16204 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16205 ),
16206 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16207 );
16208 // Negative control 2: within-list duplicate — the accessor's
16209 // slice view carries both entries, and the walk's dedup arm
16210 // raises the typed duplicate carrier quoting the offending
16211 // feature name verbatim.
16212 let err = Dep {
16213 nome: "caixa-teia".to_string(),
16214 versao: "^0.1".to_string(),
16215 fonte: None,
16216 opcional: false,
16217 caracteristicas: vec!["http".to_string(), "http".to_string()],
16218 }
16219 .validate()
16220 .unwrap_err();
16221 assert!(
16222 matches!(
16223 &err,
16224 DepError::CaracteristicaDuplicate {
16225 nome,
16226 caracteristica,
16227 } if nome == "caixa-teia" && caracteristica == "http",
16228 ),
16229 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16230 );
16231 }
16232
16233 // ── Dep::opcional accessor pins ───────────────────────────────────
16234 //
16235 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16236 // equal projection over the default-`false` / explicit-`true`
16237 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16238 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16239 // exercising the accessor's accept-set over every author-surface
16240 // `:fonte` shape × every author-surface `:opcional` shape; and by-
16241 // `Copy` idempotency so the projection stays value-return (no
16242 // silent detour to a fresh `&bool` borrow that would introduce a
16243 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16244 // shape elides). No composition pin — `:opcional` does not
16245 // participate in [`Dep::validate`] (an opcional dep with any bool
16246 // value is validate-accepted; the missing-source arm is a resolver-
16247 // side runtime dispatch, not a build-time refusal), so the axis
16248 // reduces to the value-shape + `Copy` pin pair the peer
16249 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16250 // outer-`Option<Copy>` accessor pins already carry.
16251
16252 #[test]
16253 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16254 // Default-`false` form via the [`Dep::simple`] constructor —
16255 // the accessor projects the `false` bit the default-fill sets.
16256 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16257 // Default-`false` form via the [`Dep::git`] constructor — same
16258 // default fill; the accessor projects `false` regardless of the
16259 // `:fonte` arm.
16260 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16261 // Explicit-`true` form × plain-shorthand `:fonte` — the
16262 // canonical author-surface "this dep may be missing" shape.
16263 let plain_true = Dep {
16264 nome: "caixa-teia".to_string(),
16265 versao: "^0.1".to_string(),
16266 fonte: None,
16267 opcional: true,
16268 caracteristicas: Vec::new(),
16269 };
16270 assert!(plain_true.opcional());
16271 // Explicit-`true` form × explicit git-source — the accessor
16272 // projects the bit verbatim regardless of the `:fonte` arm.
16273 let git_true = Dep {
16274 nome: "caixa-teia".to_string(),
16275 versao: "^0.1".to_string(),
16276 fonte: Some(DepSource::Git {
16277 repo: "github:pleme-io/caixa-teia".to_string(),
16278 tag: Some("v0.1.0".to_string()),
16279 rev: None,
16280 branch: None,
16281 }),
16282 opcional: true,
16283 caracteristicas: Vec::new(),
16284 };
16285 assert!(git_true.opcional());
16286 // Explicit-`true` form × explicit path-source — the dev-only
16287 // local-filesystem arm the [`Dep`] docstring's third fixture
16288 // carries.
16289 let path_true = Dep {
16290 nome: "caixa-teia".to_string(),
16291 versao: "0.1.0".to_string(),
16292 fonte: Some(DepSource::Path {
16293 caminho: "../caixa-teia".to_string(),
16294 }),
16295 opcional: true,
16296 caracteristicas: Vec::new(),
16297 };
16298 assert!(path_true.opcional());
16299 }
16300
16301 #[test]
16302 fn dep_opcional_projects_bool_by_copy() {
16303 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16304 // (`bool: Copy`) — the accessor does not borrow `&self` past
16305 // the call (no lifetime on the return type), and calling the
16306 // accessor twice on the same [`Dep`] must yield discriminant-
16307 // equal values (idempotent, no side effects on `&self`). Peer
16308 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16309 // `max_restarts_projects_option_by_copy` (eba5211) /
16310 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16311 // outer-`Caixa` altitude — extended here to the outer-`Dep`
16312 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16313 // replaces the pointer-equality claim the sibling per-`Dep`
16314 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16315 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16316 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16317 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16318 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16319 // the same discriminant, so the axis reduces to discriminant
16320 // equality).
16321 //
16322 // Pins against a future silent detour that returned a fresh
16323 // `&bool` reference (which would type-check but silently
16324 // introduce a borrow of `&self` past the call, collapsing the
16325 // load-bearing "no lifetime on the return type" `Copy`
16326 // projection the plain-`Copy`-scalar axis's `bool` shape
16327 // carries) or a stale-read side effect that flipped the outer
16328 // discriminant on successive calls.
16329 for opcional in [false, true] {
16330 let d = Dep {
16331 nome: "caixa-teia".to_string(),
16332 versao: "^0.1".to_string(),
16333 fonte: None,
16334 opcional,
16335 caracteristicas: Vec::new(),
16336 };
16337 let first = d.opcional();
16338 let second = d.opcional();
16339 assert_eq!(
16340 first, second,
16341 "Dep::opcional must be idempotent — two successive calls \
16342 on the same &self must return the same bool",
16343 );
16344 assert_eq!(
16345 first, opcional,
16346 "Dep::opcional must return :opcional verbatim by Copy — \
16347 got {first}, expected {opcional}",
16348 );
16349 assert_eq!(
16350 d.opcional(),
16351 d.opcional,
16352 "Dep::opcional accessor and self.opcional field access \
16353 must byte-equal — a bit-flip drift would silently split \
16354 the paired resolver-side drop-vs-error dispatch from \
16355 the storage-side default-fill the [`Dep::simple`] / \
16356 [`Dep::git`] constructor pair carries",
16357 );
16358 }
16359 }
16360
16361 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16362
16363 #[test]
16364 fn sole_pin_returns_none_for_path_source() {
16365 // A path source carries no git-ref, so `sole_pin()` returns
16366 // `None` structurally — the sibling arm every git-fetching
16367 // consumer partitions off before reaching for a git-ref. Pins
16368 // the Path-arm branch of the accessor against a future silent
16369 // detour that treats a `Self::Path` as an unpinned-git source
16370 // and returns the wrong "no pin" signal (e.g. the empty string,
16371 // or a hard-coded `Some("HEAD")` matching the caixa-crd
16372 // path-arm `git_ref` fill).
16373 let s = DepSource::Path {
16374 caminho: "../local-caixa".to_string(),
16375 };
16376 assert_eq!(s.sole_pin(), None);
16377 }
16378
16379 #[test]
16380 fn sole_pin_returns_none_for_unpinned_git_source() {
16381 // The [`DepSource::default_github`] shorthand shape carries no
16382 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16383 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16384 // materializes when the author omits `:fonte` entirely, then
16385 // hands to `fetch_git` which raises `ResolveError::MissingPin`
16386 // on the `None` arm — the accessor's return matches the arm
16387 // the resolver's diagnostic keys off.
16388 let s = DepSource::default_github("pleme-io", "caixa-teia");
16389 assert_eq!(s.sole_pin(), None);
16390 }
16391
16392 #[test]
16393 fn sole_pin_returns_rev_when_only_rev_is_set() {
16394 let s = DepSource::Git {
16395 repo: "github:o/x".into(),
16396 tag: None,
16397 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16398 branch: None,
16399 };
16400 assert_eq!(
16401 s.sole_pin(),
16402 Some("deadbeefcafebabe1234567890abcdef12345678")
16403 );
16404 }
16405
16406 #[test]
16407 fn sole_pin_returns_tag_when_only_tag_is_set() {
16408 let s = DepSource::Git {
16409 repo: "github:o/x".into(),
16410 tag: Some("v0.1.0".into()),
16411 rev: None,
16412 branch: None,
16413 };
16414 assert_eq!(s.sole_pin(), Some("v0.1.0"));
16415 }
16416
16417 #[test]
16418 fn sole_pin_returns_branch_when_only_branch_is_set() {
16419 let s = DepSource::Git {
16420 repo: "github:o/x".into(),
16421 tag: None,
16422 rev: None,
16423 branch: Some("main".into()),
16424 };
16425 assert_eq!(s.sole_pin(), Some("main"));
16426 }
16427
16428 #[test]
16429 fn sole_pin_precedence_rev_beats_tag_and_branch() {
16430 // Precedence: rev > tag > branch. Validate() rejects
16431 // multiple-pin shapes, but the accessor's precedence is defined
16432 // for pre-validate consumers (the resolver's `MissingPin`
16433 // diagnostic path, the caixa-crd round-trip's default `"main"`
16434 // fallback) and as defense-in-depth if the gate is ever
16435 // bypassed. Pins the same precedence caixa-resolver's
16436 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16437 // inline.
16438 let s = DepSource::Git {
16439 repo: "github:o/x".into(),
16440 tag: Some("v1".into()),
16441 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16442 branch: Some("main".into()),
16443 };
16444 assert_eq!(
16445 s.sole_pin(),
16446 Some("deadbeefcafebabe1234567890abcdef12345678")
16447 );
16448 }
16449
16450 #[test]
16451 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16452 let s = DepSource::Git {
16453 repo: "github:o/x".into(),
16454 tag: Some("v1".into()),
16455 rev: None,
16456 branch: Some("main".into()),
16457 };
16458 assert_eq!(s.sole_pin(), Some("v1"));
16459 }
16460
16461 #[test]
16462 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16463 // Fail-before-pass-after byte-parity pin: the substrate accessor
16464 // must return byte-identical to the inline
16465 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16466 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16467 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16468 // time if the accessor's precedence silently drifts from the
16469 // consumer-side cascade — the exact drift this lift converges
16470 // to one substrate primitive to close structurally.
16471 //
16472 // Iterates through the 2^3 = 8 combinations of (tag, rev,
16473 // branch) each-either-`None`-or-`Some`, so every arm of the
16474 // precedence cascade lands under the pin. `validate()` refuses
16475 // the 4 multi-pin combinations, but the accessor's return is
16476 // defined on all 8.
16477 let vals = [Some("R".to_string()), None];
16478 for tag in &vals {
16479 for rev in &vals {
16480 for branch in &vals {
16481 let s = DepSource::Git {
16482 repo: "github:o/x".into(),
16483 tag: tag.clone(),
16484 rev: rev.clone(),
16485 branch: branch.clone(),
16486 };
16487 // The exact inline cascade the two pre-lift
16488 // consumer sites hand-rolled, byte-for-byte.
16489 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16490 assert_eq!(
16491 s.sole_pin(),
16492 expected,
16493 "sole_pin() must byte-equal \
16494 rev.or(tag).or(branch) for \
16495 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16496 a drift would silently split caixa-resolver's \
16497 fetch_git checkout target from caixa-crd's \
16498 dep_into_ref git_ref fill",
16499 );
16500 }
16501 }
16502 }
16503 }
16504
16505 // Fail-before-pass-after pins on the eleven
16506 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16507 // constructors folded from the [`DepSource::validate_caminho`]
16508 // wire-up sites. Each pins the generated ctor's output to the
16509 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16510 // any wrapper-side lowercase / trim / re-order / silent-field-swap
16511 // regression on the two-field `{ nome: nome.to_string(), caminho:
16512 // caminho.to_string() }` construction surfaces here rather than at
16513 // a downstream diagnostic-shape mismatch. Peer of the sibling
16514 // `empty_child_version_ctor_matches_struct_literal_wrap` /
16515 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16516 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16517 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16518 // pins on the peer `SupervisorError` / `AplicacaoError` /
16519 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16520
16521 #[test]
16522 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16523 assert_eq!(
16524 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16525 DepError::FonteCaminhoAbsolute {
16526 nome: "caixa-teia".to_string(),
16527 caminho: "/home/me/work/caixa-teia".to_string(),
16528 },
16529 "generated fonte_caminho_absolute ctor must produce byte-equal \
16530 DepError to the open-coded struct-literal wrap on the same \
16531 (&str, &str) fixture",
16532 );
16533 }
16534
16535 #[test]
16536 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16537 assert_eq!(
16538 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16539 DepError::FonteCaminhoTildeExpansion {
16540 nome: "caixa-teia".to_string(),
16541 caminho: "~/work/caixa-teia".to_string(),
16542 },
16543 );
16544 }
16545
16546 #[test]
16547 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16548 assert_eq!(
16549 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16550 DepError::FonteCaminhoVarExpansion {
16551 nome: "caixa-teia".to_string(),
16552 caminho: "$HOME/work/caixa-teia".to_string(),
16553 },
16554 );
16555 }
16556
16557 #[test]
16558 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16559 assert_eq!(
16560 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16561 DepError::FonteCaminhoLeadingWhitespace {
16562 nome: "caixa-teia".to_string(),
16563 caminho: " ../caixa-teia".to_string(),
16564 },
16565 );
16566 }
16567
16568 #[test]
16569 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16570 assert_eq!(
16571 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16572 DepError::FonteCaminhoLeadingHyphen {
16573 nome: "caixa-teia".to_string(),
16574 caminho: "-rf".to_string(),
16575 },
16576 );
16577 }
16578
16579 #[test]
16580 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16581 assert_eq!(
16582 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16583 DepError::FonteCaminhoBackslash {
16584 nome: "caixa-teia".to_string(),
16585 caminho: "..\\caixa-teia".to_string(),
16586 },
16587 );
16588 }
16589
16590 #[test]
16591 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16592 assert_eq!(
16593 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16594 DepError::FonteCaminhoShellPipe {
16595 nome: "caixa-teia".to_string(),
16596 caminho: "../caixa-teia|evil".to_string(),
16597 },
16598 );
16599 }
16600
16601 #[test]
16602 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16603 assert_eq!(
16604 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16605 DepError::FonteCaminhoShellSemicolon {
16606 nome: "caixa-teia".to_string(),
16607 caminho: "../caixa-teia;evil".to_string(),
16608 },
16609 );
16610 }
16611
16612 #[test]
16613 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16614 assert_eq!(
16615 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16616 DepError::FonteCaminhoShellBackground {
16617 nome: "caixa-teia".to_string(),
16618 caminho: "../caixa-teia&".to_string(),
16619 },
16620 );
16621 }
16622
16623 #[test]
16624 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16625 assert_eq!(
16626 DepError::fonte_caminho_shell_command_substitution(
16627 "caixa-teia",
16628 "../caixa-teia`whoami`",
16629 ),
16630 DepError::FonteCaminhoShellCommandSubstitution {
16631 nome: "caixa-teia".to_string(),
16632 caminho: "../caixa-teia`whoami`".to_string(),
16633 },
16634 );
16635 }
16636
16637 #[test]
16638 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16639 assert_eq!(
16640 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16641 DepError::FonteCaminhoTrailingSlash {
16642 nome: "caixa-teia".to_string(),
16643 caminho: "../caixa-teia/".to_string(),
16644 },
16645 );
16646 }
16647
16648 #[test]
16649 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16650 // Cross-axis pin: sweep the two constructor input axes
16651 // (`nome: &str`, `caminho: &str`) through a non-default fixture
16652 // pair against every generated arm in the
16653 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16654 // / trim / truncate / re-order on the two-field
16655 // `{ nome, caminho }` construction — or a silent field swap
16656 // between the two axes at codegen time — surfaces here rather
16657 // than at a downstream diagnostic-shape mismatch. Peer of the
16658 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16659 // to_string` cross-axis routing pin on the peer
16660 // `SupervisorError` envelope, extended here onto the
16661 // `DepError` `{ nome: String, caminho: String }` envelope so
16662 // every substrate-primitive ctor family in caixa-core
16663 // guarantees each `&str`-field construction routes the
16664 // caller's `&str` verbatim through `.to_string()`.
16665 let nome = "sibling-teia";
16666 let caminho = "../workspace/sibling";
16667 let cases: [(DepError, DepError); 11] = [
16668 (
16669 DepError::fonte_caminho_absolute(nome, caminho),
16670 DepError::FonteCaminhoAbsolute {
16671 nome: nome.to_string(),
16672 caminho: caminho.to_string(),
16673 },
16674 ),
16675 (
16676 DepError::fonte_caminho_tilde_expansion(nome, caminho),
16677 DepError::FonteCaminhoTildeExpansion {
16678 nome: nome.to_string(),
16679 caminho: caminho.to_string(),
16680 },
16681 ),
16682 (
16683 DepError::fonte_caminho_var_expansion(nome, caminho),
16684 DepError::FonteCaminhoVarExpansion {
16685 nome: nome.to_string(),
16686 caminho: caminho.to_string(),
16687 },
16688 ),
16689 (
16690 DepError::fonte_caminho_leading_whitespace(nome, caminho),
16691 DepError::FonteCaminhoLeadingWhitespace {
16692 nome: nome.to_string(),
16693 caminho: caminho.to_string(),
16694 },
16695 ),
16696 (
16697 DepError::fonte_caminho_leading_hyphen(nome, caminho),
16698 DepError::FonteCaminhoLeadingHyphen {
16699 nome: nome.to_string(),
16700 caminho: caminho.to_string(),
16701 },
16702 ),
16703 (
16704 DepError::fonte_caminho_backslash(nome, caminho),
16705 DepError::FonteCaminhoBackslash {
16706 nome: nome.to_string(),
16707 caminho: caminho.to_string(),
16708 },
16709 ),
16710 (
16711 DepError::fonte_caminho_shell_pipe(nome, caminho),
16712 DepError::FonteCaminhoShellPipe {
16713 nome: nome.to_string(),
16714 caminho: caminho.to_string(),
16715 },
16716 ),
16717 (
16718 DepError::fonte_caminho_shell_semicolon(nome, caminho),
16719 DepError::FonteCaminhoShellSemicolon {
16720 nome: nome.to_string(),
16721 caminho: caminho.to_string(),
16722 },
16723 ),
16724 (
16725 DepError::fonte_caminho_shell_background(nome, caminho),
16726 DepError::FonteCaminhoShellBackground {
16727 nome: nome.to_string(),
16728 caminho: caminho.to_string(),
16729 },
16730 ),
16731 (
16732 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16733 DepError::FonteCaminhoShellCommandSubstitution {
16734 nome: nome.to_string(),
16735 caminho: caminho.to_string(),
16736 },
16737 ),
16738 (
16739 DepError::fonte_caminho_trailing_slash(nome, caminho),
16740 DepError::FonteCaminhoTrailingSlash {
16741 nome: nome.to_string(),
16742 caminho: caminho.to_string(),
16743 },
16744 ),
16745 ];
16746 for (via_ctor, via_struct_literal) in cases {
16747 assert_eq!(
16748 via_ctor, via_struct_literal,
16749 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16750 through `.to_string()` in declared field order — a field-swap or \
16751 silent-conversion regression surfaces here rather than at a \
16752 downstream diagnostic-shape mismatch",
16753 );
16754 }
16755 }
16756
16757 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16758 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16759 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16760 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16761 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16762
16763 #[test]
16764 fn versao_empty_ctor_matches_struct_literal_wrap() {
16765 assert_eq!(
16766 DepError::versao_empty("caixa-teia"),
16767 DepError::VersaoEmpty {
16768 nome: "caixa-teia".to_string(),
16769 },
16770 );
16771 }
16772
16773 #[test]
16774 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16775 assert_eq!(
16776 DepError::fonte_repo_empty("caixa-teia"),
16777 DepError::FonteRepoEmpty {
16778 nome: "caixa-teia".to_string(),
16779 },
16780 );
16781 }
16782
16783 #[test]
16784 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16785 assert_eq!(
16786 DepError::fonte_pin_missing("caixa-teia"),
16787 DepError::FontePinMissing {
16788 nome: "caixa-teia".to_string(),
16789 },
16790 );
16791 }
16792
16793 #[test]
16794 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16795 assert_eq!(
16796 DepError::fonte_caminho_empty("caixa-teia"),
16797 DepError::FonteCaminhoEmpty {
16798 nome: "caixa-teia".to_string(),
16799 },
16800 );
16801 }
16802
16803 #[test]
16804 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16805 assert_eq!(
16806 DepError::caracteristica_empty("caixa-teia"),
16807 DepError::CaracteristicaEmpty {
16808 nome: "caixa-teia".to_string(),
16809 },
16810 );
16811 }
16812
16813 #[test]
16814 fn dep_nome_only_ctors_route_nome_through_to_string() {
16815 // Cross-axis routing pin: sweep the single constructor input
16816 // axis (`nome: &str`) through a non-default fixture against
16817 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16818 // any wrapper-side lowercase / trim / truncate at codegen time
16819 // — or a silent field re-name away from the canonical `nome`
16820 // axis on any one variant — surfaces here rather than at a
16821 // downstream diagnostic-shape mismatch. Peer of the sibling
16822 // `fonte_caminho_ctors_route_nome_and_caminho_through_
16823 // to_string` cross-axis routing pin on the same envelope's
16824 // two-slot family (f85f145) and of the peer
16825 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16826 // pin on the `SupervisorError` single-slot family (db09650).
16827 let nome = "sibling-teia";
16828 let cases: [(DepError, DepError); 5] = [
16829 (
16830 DepError::versao_empty(nome),
16831 DepError::VersaoEmpty {
16832 nome: nome.to_string(),
16833 },
16834 ),
16835 (
16836 DepError::fonte_repo_empty(nome),
16837 DepError::FonteRepoEmpty {
16838 nome: nome.to_string(),
16839 },
16840 ),
16841 (
16842 DepError::fonte_pin_missing(nome),
16843 DepError::FontePinMissing {
16844 nome: nome.to_string(),
16845 },
16846 ),
16847 (
16848 DepError::fonte_caminho_empty(nome),
16849 DepError::FonteCaminhoEmpty {
16850 nome: nome.to_string(),
16851 },
16852 ),
16853 (
16854 DepError::caracteristica_empty(nome),
16855 DepError::CaracteristicaEmpty {
16856 nome: nome.to_string(),
16857 },
16858 ),
16859 ];
16860 for (via_ctor, via_struct_literal) in cases {
16861 assert_eq!(
16862 via_ctor, via_struct_literal,
16863 "dep_nome_only_ctors!-generated ctor must route `nome` \
16864 through `.to_string()` onto the canonical `nome` field \
16865 — a field-rename or silent-conversion regression surfaces \
16866 here rather than at a downstream diagnostic-shape mismatch",
16867 );
16868 }
16869 }
16870
16871 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
16872 // &'static str }` two-slot envelope on `DepError`, strict
16873 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
16874 // same envelope's `{ nome: String }` one-slot shape and of the
16875 // peer `supervisor_caixa_only_ctors!` (db09650) on the
16876 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
16877
16878 #[test]
16879 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
16880 assert_eq!(
16881 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
16882 DepError::DuplicateNome {
16883 nome: "caixa-teia".to_string(),
16884 list: crate::render::DEP_AUTHOR_KEY_DEPS,
16885 },
16886 "generated duplicate_nome ctor must produce byte-equal \
16887 `DepError::DuplicateNome` to the pre-lift struct-literal \
16888 wrap on the same scalar fixtures",
16889 );
16890 }
16891
16892 #[test]
16893 fn dep_is_self_ctor_matches_struct_literal_wrap() {
16894 assert_eq!(
16895 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16896 DepError::DepIsSelf {
16897 nome: "orquestra".to_string(),
16898 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16899 },
16900 "generated dep_is_self ctor must produce byte-equal \
16901 `DepError::DepIsSelf` to the pre-lift struct-literal \
16902 wrap on the same scalar fixtures",
16903 );
16904 }
16905
16906 #[test]
16907 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
16908 // Cross-axis routing pin: sweep the two constructor input axes
16909 // (`nome: &str`, `list: &'static str`) through non-default
16910 // fixtures against every generated arm in the
16911 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
16912 // lowercase / trim / truncate at codegen time — or a silent
16913 // field re-name away from the canonical `nome` / `list` axes
16914 // on any one variant, or a `list` axis silently rerouted
16915 // through `.to_string()` instead of passed as `&'static str`
16916 // verbatim — surfaces here rather than at a downstream
16917 // diagnostic-shape mismatch. Peer of the sibling
16918 // `dep_nome_only_ctors_route_nome_through_to_string` pin
16919 // (792aa92) on the same envelope's one-slot family, and of the
16920 // peer
16921 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
16922 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
16923 // two-slot `{ caixa: String, reason: String }` shape.
16924 let nome = "sibling-teia";
16925 let cases: [(DepError, DepError); 4] = [
16926 (
16927 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16928 DepError::DuplicateNome {
16929 nome: nome.to_string(),
16930 list: crate::render::DEP_AUTHOR_KEY_DEPS,
16931 },
16932 ),
16933 (
16934 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16935 DepError::DuplicateNome {
16936 nome: nome.to_string(),
16937 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16938 },
16939 ),
16940 (
16941 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
16942 DepError::DepIsSelf {
16943 nome: nome.to_string(),
16944 list: crate::render::DEP_AUTHOR_KEY_DEPS,
16945 },
16946 ),
16947 (
16948 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16949 DepError::DepIsSelf {
16950 nome: nome.to_string(),
16951 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16952 },
16953 ),
16954 ];
16955 for (via_ctor, via_struct_literal) in cases {
16956 assert_eq!(
16957 via_ctor, via_struct_literal,
16958 "dep_nome_list_ctors!-generated ctor must route `nome` \
16959 through `.to_string()` onto the canonical `nome` field \
16960 and pass `list` verbatim onto the canonical `&'static str` \
16961 `list` field — a field-rename, silent-conversion, or \
16962 axis-swap regression surfaces here rather than at a \
16963 downstream diagnostic-shape mismatch",
16964 );
16965 }
16966 }
16967
16968 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
16969 // value: String, reason: String }` four-slot envelope on
16970 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
16971 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
16972 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
16973 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
16974 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
16975 // envelope. Single-variant lift closing the last open-coded ctor
16976 // site on the `:fonte (:tipo git …)` value-shape trajectory.
16977
16978 #[test]
16979 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
16980 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
16981 // ctor: sweep both wire-up-shape arms (the refname-pin arm
16982 // routing `":tag"` / `":branch"` value through
16983 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
16984 // routing `":rev"` through [`crate::render::is_git_oid`]) and
16985 // assert byte-equal `PartialEq` against the pre-lift
16986 // struct-literal, so any wrapper-side field-rename /
16987 // silent-conversion regression surfaces here rather than at a
16988 // downstream diagnostic-shape mismatch. Peer of the sibling
16989 // per-envelope byte-equal ctor pins
16990 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
16991 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
16992 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
16993 assert_eq!(
16994 DepError::fonte_pin_shape(
16995 "caixa-teia",
16996 ":tag",
16997 "v0.1.0 ",
16998 "trailing whitespace".to_string(),
16999 ),
17000 DepError::FontePinShape {
17001 nome: "caixa-teia".to_string(),
17002 pin: ":tag".to_string(),
17003 value: "v0.1.0 ".to_string(),
17004 reason: "trailing whitespace".to_string(),
17005 },
17006 "fonte_pin_shape ctor must produce byte-equal \
17007 `DepError::FontePinShape` to the pre-lift struct-literal \
17008 wrap on a refname-pin (`:tag` / `:branch`) fixture",
17009 );
17010 assert_eq!(
17011 DepError::fonte_pin_shape(
17012 "caixa-teia",
17013 ":rev",
17014 "DEADBEEF",
17015 "abbreviated OID rejected".to_string(),
17016 ),
17017 DepError::FontePinShape {
17018 nome: "caixa-teia".to_string(),
17019 pin: ":rev".to_string(),
17020 value: "DEADBEEF".to_string(),
17021 reason: "abbreviated OID rejected".to_string(),
17022 },
17023 "fonte_pin_shape ctor must produce byte-equal \
17024 `DepError::FontePinShape` to the pre-lift struct-literal \
17025 wrap on a hex-OID-pin (`:rev`) fixture",
17026 );
17027 }
17028
17029 #[test]
17030 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17031 // Cross-axis routing pin: sweep every one of the four
17032 // constructor input axes (`nome: &str`, `pin: &str`,
17033 // `value: &str`, `reason: String`) through non-default
17034 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17035 // any wrapper-side lowercase / trim / truncate at codegen time
17036 // — or a silent field re-name / axis-swap on any one of the
17037 // four fields, or a `reason` axis silently routed through
17038 // `.to_string()` instead of forwarded owned — surfaces here
17039 // rather than at a downstream diagnostic-shape mismatch. Peer
17040 // of the sibling
17041 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17042 // (792aa92) and
17043 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17044 // pin (6f5e0cd) on the same envelope's one- and two-slot
17045 // families. Distinct-per-axis fixtures rule out any two-axis
17046 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17047 // etc.) that would still pass a same-fixture-per-axis pin.
17048 let nome = "sibling-teia";
17049 let pin = ":branch";
17050 let value = "feature/bar";
17051 let reason = "embedded space".to_string();
17052 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17053 let via_struct_literal = DepError::FontePinShape {
17054 nome: nome.to_string(),
17055 pin: pin.to_string(),
17056 value: value.to_string(),
17057 reason: reason.clone(),
17058 };
17059 assert_eq!(
17060 via_ctor, via_struct_literal,
17061 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17062 through `.to_string()` onto their canonical fields and \
17063 forward `reason` owned onto the canonical `reason` field \
17064 — a field-rename, silent-conversion, or axis-swap \
17065 regression surfaces here rather than at a downstream \
17066 diagnostic-shape mismatch",
17067 );
17068 let DepError::FontePinShape {
17069 nome: n,
17070 pin: p,
17071 value: v,
17072 reason: r,
17073 } = via_ctor
17074 else {
17075 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17076 };
17077 assert_eq!(n, nome);
17078 assert_eq!(p, pin);
17079 assert_eq!(v, value);
17080 assert_eq!(r, reason);
17081 }
17082
17083 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17084 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17085 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17086 // the same envelope's `{ nome: String, caminho: String }` two-slot
17087 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17088 // same envelope's `{ nome: String }` one-slot shape.
17089
17090 #[test]
17091 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17092 assert_eq!(
17093 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17094 DepError::FonteCaminhoControlChar {
17095 nome: "caixa-teia".to_string(),
17096 caminho: "../caixa-teia\x00foo".to_string(),
17097 byte: 0x00,
17098 },
17099 );
17100 }
17101
17102 #[test]
17103 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17104 assert_eq!(
17105 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17106 DepError::FonteCaminhoShellRedirection {
17107 nome: "caixa-teia".to_string(),
17108 caminho: "../caixa-teia>log".to_string(),
17109 byte: b'>',
17110 },
17111 );
17112 }
17113
17114 #[test]
17115 #[allow(
17116 clippy::too_many_lines,
17117 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17118 byte-classification arm on the {nome,caminho,byte} envelope; \
17119 the linear per-variant repetition is exactly what the sweep \
17120 is pinning — a helper macro would hide the shape the fold is \
17121 keying on"
17122 )]
17123 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17124 // Cross-axis routing pin: sweep the three constructor input axes
17125 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17126 // non-default fixture triple against every generated arm in the
17127 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17128 // lowercase / trim / truncate on the two `&str` axes — a silent
17129 // field swap between `nome` and `caminho`, or a silent
17130 // re-classification of the offending byte — surfaces here rather
17131 // than at a downstream diagnostic-shape mismatch. Peer of the
17132 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17133 // to_string` cross-axis routing pin on the same envelope's
17134 // two-slot family (f85f145) and of the sibling
17135 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17136 // same envelope's one-slot family (792aa92), extended here onto
17137 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17138 // envelope so every substrate-primitive ctor family in
17139 // caixa-core's `DepError` envelope guarantees each field routes
17140 // the caller's value verbatim through `.to_string()` (or byte-
17141 // identity for `byte: u8`) in declared field order.
17142 let nome = "sibling-teia";
17143 let caminho = "../workspace/sibling";
17144 let byte = 0x2A_u8;
17145 let cases: [(DepError, DepError); 12] = [
17146 (
17147 DepError::fonte_caminho_control_char(nome, caminho, byte),
17148 DepError::FonteCaminhoControlChar {
17149 nome: nome.to_string(),
17150 caminho: caminho.to_string(),
17151 byte,
17152 },
17153 ),
17154 (
17155 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17156 DepError::FonteCaminhoShellRedirection {
17157 nome: nome.to_string(),
17158 caminho: caminho.to_string(),
17159 byte,
17160 },
17161 ),
17162 (
17163 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17164 DepError::FonteCaminhoShellGlob {
17165 nome: nome.to_string(),
17166 caminho: caminho.to_string(),
17167 byte,
17168 },
17169 ),
17170 (
17171 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17172 DepError::FonteCaminhoShellSubshellGrouping {
17173 nome: nome.to_string(),
17174 caminho: caminho.to_string(),
17175 byte,
17176 },
17177 ),
17178 (
17179 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17180 DepError::FonteCaminhoShellBraceExpansion {
17181 nome: nome.to_string(),
17182 caminho: caminho.to_string(),
17183 byte,
17184 },
17185 ),
17186 (
17187 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17188 DepError::FonteCaminhoShellBracketExpansion {
17189 nome: nome.to_string(),
17190 caminho: caminho.to_string(),
17191 byte,
17192 },
17193 ),
17194 (
17195 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17196 DepError::FonteCaminhoShellQuoteGrouping {
17197 nome: nome.to_string(),
17198 caminho: caminho.to_string(),
17199 byte,
17200 },
17201 ),
17202 (
17203 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17204 DepError::FonteCaminhoShellComment {
17205 nome: nome.to_string(),
17206 caminho: caminho.to_string(),
17207 byte,
17208 },
17209 ),
17210 (
17211 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17212 DepError::FonteCaminhoUrlPercentEncoding {
17213 nome: nome.to_string(),
17214 caminho: caminho.to_string(),
17215 byte,
17216 },
17217 ),
17218 (
17219 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17220 DepError::FonteCaminhoShellVariableExpansion {
17221 nome: nome.to_string(),
17222 caminho: caminho.to_string(),
17223 byte,
17224 },
17225 ),
17226 (
17227 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17228 DepError::FonteCaminhoShellHistoryExpansion {
17229 nome: nome.to_string(),
17230 caminho: caminho.to_string(),
17231 byte,
17232 },
17233 ),
17234 (
17235 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17236 DepError::FonteCaminhoShellHistorySubstitution {
17237 nome: nome.to_string(),
17238 caminho: caminho.to_string(),
17239 byte,
17240 },
17241 ),
17242 ];
17243 for (via_ctor, via_struct_literal) in cases {
17244 assert_eq!(
17245 via_ctor, via_struct_literal,
17246 "fonte_caminho_byte_ctors!-generated ctor must route \
17247 (nome, caminho, byte) through `.to_string()` / byte-\
17248 identity in declared field order — a field-swap or \
17249 silent-conversion regression surfaces here rather than \
17250 at a downstream diagnostic-shape mismatch",
17251 );
17252 }
17253 }
17254}
17255
17256#[cfg(test)]
17257mod dep_source_is_variant_tests {
17258 use super::*;
17259
17260 fn all_variants() -> Vec<(DepSource, &'static str)> {
17261 vec![
17262 (
17263 DepSource::Git {
17264 repo: "github:pleme-io/caixa-teia".into(),
17265 tag: Some("v0.1.0".into()),
17266 rev: None,
17267 branch: None,
17268 },
17269 "Git",
17270 ),
17271 (
17272 DepSource::Path {
17273 caminho: "../caixa-teia".into(),
17274 },
17275 "Path",
17276 ),
17277 ]
17278 }
17279
17280 fn predicate_row(s: &DepSource) -> [bool; 2] {
17281 [s.is_git(), s.is_path()]
17282 }
17283
17284 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17285 // derive-generated per-arm predicate partition — for every variant
17286 // in `all_variants()`, the observed 2-slot predicate row must equal
17287 // a one-hot row with the `true` at exactly the same index as the
17288 // variant's declaration order. Expected rows are generated live
17289 // from the enumeration rather than transcribed by hand, so a
17290 // copy-paste flip that reroutes one arm through the wrong predicate
17291 // lane trips at the identity-diagonal assertion the way every peer
17292 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17293 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17294 // / [`crate::upgrade::UpgradeInstruction`] /
17295 // [`crate::aplicacao::PlacementStrategy`] /
17296 // [`crate::aplicacao::RateLimitUnit`] /
17297 // [`crate::aplicacao::WitTarget`] /
17298 // [`crate::render::PathShapeViolation`] partition pin already does.
17299 #[test]
17300 fn dep_source_is_variant_predicates_partition_the_arm_set() {
17301 let variants = all_variants();
17302 for (idx, (variant, name)) in variants.iter().enumerate() {
17303 let observed = predicate_row(variant);
17304 let mut expected = [false; 2];
17305 expected[idx] = true;
17306 assert_eq!(
17307 observed, expected,
17308 "DepSource::{name} at declaration-order slot {idx} must \
17309 satisfy exactly one is_* predicate (its own); observed \
17310 row must equal the one-hot expected row — a drift \
17311 would silently reroute one `:fonte`-arm consumer \
17312 through the wrong predicate lane"
17313 );
17314 }
17315 }
17316
17317 // Byte-parity pin on the two field-agnostic `matches!` shapes the
17318 // per-arm arm-discriminator predicates replace at any future
17319 // consumer site (a `:fonte`-shape-only lint rule that flags path
17320 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17321 // a future admission-webhook that rejects `:fonte` shapes outside
17322 // the `is_git()` accept-set, a caixa-lacre indexing pass that
17323 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17324 // Refuses a future accidental split between the derived predicate
17325 // and its `matches!` shape — a hand-rolled shadow impl that
17326 // overrides one path, an accidental rebrand that leaves one
17327 // consumer on the raw `matches!` form — on the two load-bearing
17328 // `:fonte`-arm-discriminator axes every downstream substrate
17329 // consumer of the dep-source axis keys off.
17330 #[test]
17331 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17332 for (variant, name) in all_variants() {
17333 let via_matches_git = matches!(variant, DepSource::Git { .. });
17334 let via_predicate_git = variant.is_git();
17335 assert_eq!(
17336 via_predicate_git, via_matches_git,
17337 "DepSource::{name}.is_git() must byte-equal \
17338 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17339 future converged consumer site would silently \
17340 disagree with its pre-lift shape"
17341 );
17342 let via_matches_path = matches!(variant, DepSource::Path { .. });
17343 let via_predicate_path = variant.is_path();
17344 assert_eq!(
17345 via_predicate_path, via_matches_path,
17346 "DepSource::{name}.is_path() must byte-equal \
17347 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17348 future converged consumer site would silently \
17349 disagree with its pre-lift shape"
17350 );
17351 }
17352 }
17353
17354 // Cross-pin against every constructor path that materializes a
17355 // [`DepSource`] shape today (the [`DepSource::default_github`]
17356 // resolver-side fallback that materializes an unpinned
17357 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17358 // surface constructor that materializes a pinned `:tag`-carrying
17359 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17360 // fixture family builds inline). Every constructor's return must
17361 // satisfy the arm-discriminator predicate the constructor's
17362 // variant name matches — a future constructor addition (an
17363 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17364 // enclosing docstring already names as a trajectory item) surfaces
17365 // as a build-time failure that names the offending drift when its
17366 // return arm doesn't route through the paired predicate.
17367 #[test]
17368 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
17369 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
17370 assert!(
17371 via_default_github.is_git(),
17372 "DepSource::default_github must materialize a Git-arm shape — \
17373 a future constructor that routed through a non-Git arm \
17374 (a registry-fetch pin, a `DepSource::Feira` promotion) \
17375 would silently split the resolver's unpinned-shorthand \
17376 materializer from the sole_pin() precedence cascade"
17377 );
17378 assert!(
17379 !via_default_github.is_path(),
17380 "DepSource::default_github must NOT materialize a Path-arm \
17381 shape — the paired negation pin"
17382 );
17383
17384 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17385 .fonte
17386 .expect("Dep::git materializes a Some(fonte)");
17387 assert!(
17388 via_dep_git.is_git(),
17389 "Dep::git's `:fonte` materialization must land on the Git \
17390 arm — the author-surface pinned-git constructor's return \
17391 must route through the paired predicate"
17392 );
17393 assert!(!via_dep_git.is_path(), "paired negation pin");
17394
17395 let via_path = DepSource::Path {
17396 caminho: "../caixa-teia".into(),
17397 };
17398 assert!(
17399 via_path.is_path(),
17400 "the dev-mode Path-arm materialization must satisfy is_path()"
17401 );
17402 assert!(!via_path.is_git(), "paired negation pin");
17403 }
17404
17405 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
17406 // String, reason: String }` three-slot envelope on `DepError`,
17407 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
17408 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
17409 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
17410 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
17411 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
17412 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
17413
17414 #[test]
17415 fn versao_invalid_ctor_matches_struct_literal_wrap() {
17416 assert_eq!(
17417 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
17418 DepError::VersaoInvalid {
17419 nome: "caixa-teia".to_string(),
17420 versao: "^0..1".to_string(),
17421 reason: "invalid comparator".to_string(),
17422 },
17423 "versao_invalid ctor must produce byte-equal \
17424 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
17425 );
17426 }
17427
17428 #[test]
17429 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
17430 assert_eq!(
17431 DepError::fonte_repo_shape(
17432 "caixa-teia",
17433 "-upload-pack=evil",
17434 "leading dash rejected".to_string(),
17435 ),
17436 DepError::FonteRepoShape {
17437 nome: "caixa-teia".to_string(),
17438 repo: "-upload-pack=evil".to_string(),
17439 reason: "leading dash rejected".to_string(),
17440 },
17441 "fonte_repo_shape ctor must produce byte-equal \
17442 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
17443 );
17444 }
17445
17446 #[test]
17447 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
17448 assert_eq!(
17449 DepError::caracteristica_invalid(
17450 "caixa-teia",
17451 "bad feature!",
17452 "embedded space rejected".to_string(),
17453 ),
17454 DepError::CaracteristicaInvalid {
17455 nome: "caixa-teia".to_string(),
17456 caracteristica: "bad feature!".to_string(),
17457 reason: "embedded space rejected".to_string(),
17458 },
17459 "caracteristica_invalid ctor must produce byte-equal \
17460 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
17461 );
17462 }
17463
17464 #[test]
17465 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
17466 // Cross-axis routing pin: sweep the three constructor input axes
17467 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
17468 // distinct-per-axis fixtures against every generated arm in the
17469 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
17470 // lowercase / trim / truncate on the two `&str` axes — a silent
17471 // field swap between `nome`, the middle `<axis>` field, and
17472 // `reason`, or a `reason` axis silently rerouted through
17473 // `.to_string()` instead of forwarded owned — surfaces here rather
17474 // than at a downstream diagnostic-shape mismatch. Peer of the
17475 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
17476 // through_to_string` (0e35793) cross-axis routing pin on the same
17477 // envelope's `{ nome, caminho, byte }` three-slot family and of
17478 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
17479 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
17480 // — extended here onto the `{ nome, <axis>: String, reason:
17481 // String }` three-slot envelope so every substrate-primitive ctor
17482 // family in caixa-core's `DepError` envelope guarantees each field
17483 // routes the caller's value verbatim through `.to_string()` (or
17484 // owned-forward for `reason: String`) in declared field order.
17485 // Distinct-per-axis fixtures rule out any two-axis swap
17486 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
17487 // same-fixture-per-axis pin.
17488 let nome = "sibling-teia";
17489 let axis = "distinct-axis-value";
17490 let reason = "distinct rejection sentence".to_string();
17491 assert_eq!(
17492 DepError::versao_invalid(nome, axis, reason.clone()),
17493 DepError::VersaoInvalid {
17494 nome: nome.to_string(),
17495 versao: axis.to_string(),
17496 reason: reason.clone(),
17497 },
17498 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
17499 `reason` → `reason` in declared field order",
17500 );
17501 assert_eq!(
17502 DepError::fonte_repo_shape(nome, axis, reason.clone()),
17503 DepError::FonteRepoShape {
17504 nome: nome.to_string(),
17505 repo: axis.to_string(),
17506 reason: reason.clone(),
17507 },
17508 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
17509 `reason` → `reason` in declared field order",
17510 );
17511 assert_eq!(
17512 DepError::caracteristica_invalid(nome, axis, reason.clone()),
17513 DepError::CaracteristicaInvalid {
17514 nome: nome.to_string(),
17515 caracteristica: axis.to_string(),
17516 reason: reason.clone(),
17517 },
17518 "caracteristica_invalid must route `nome` → `nome`, \
17519 `axis` → `caracteristica`, `reason` → `reason` in declared \
17520 field order",
17521 );
17522 }
17523
17524 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
17525 // two-slot envelope on `DepError`, missing rung between
17526 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
17527 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
17528 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
17529 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
17530 // two-slot `{ nome, list: &'static str }` envelope (same slot
17531 // count, `&'static str` axis instead of owned `String` axis).
17532
17533 #[test]
17534 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
17535 assert_eq!(
17536 DepError::fonte_pin_empty("caixa-teia", ":tag"),
17537 DepError::FontePinEmpty {
17538 nome: "caixa-teia".to_string(),
17539 pin: ":tag".to_string(),
17540 },
17541 "fonte_pin_empty ctor must produce byte-equal \
17542 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
17543 on the same `(&str, &str)` fixture",
17544 );
17545 }
17546
17547 #[test]
17548 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
17549 assert_eq!(
17550 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
17551 DepError::FontePinAmbiguous {
17552 nome: "caixa-teia".to_string(),
17553 pins: ":tag, :rev".to_string(),
17554 },
17555 "fonte_pin_ambiguous ctor must produce byte-equal \
17556 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
17557 wrap on the same `(&str, &str)` fixture",
17558 );
17559 }
17560
17561 #[test]
17562 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
17563 assert_eq!(
17564 DepError::caracteristica_duplicate("caixa-teia", "http"),
17565 DepError::CaracteristicaDuplicate {
17566 nome: "caixa-teia".to_string(),
17567 caracteristica: "http".to_string(),
17568 },
17569 "caracteristica_duplicate ctor must produce byte-equal \
17570 `DepError::CaracteristicaDuplicate` to the pre-lift \
17571 struct-literal wrap on the same `(&str, &str)` fixture",
17572 );
17573 }
17574
17575 #[test]
17576 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
17577 // Owned-`String` routing pin: thread the real
17578 // `set.join(", ")` `String` carrier through the ctor's
17579 // `&str`-parameter Deref coercion, so the ambiguity-arm
17580 // wire-up site's actual `&set.join(", ")` shape stays
17581 // byte-equal to a direct `":tag, :rev"` literal. A future
17582 // parameter-shape change silently dropping the Deref
17583 // coercion route (e.g., a switch to `impl Into<String>`)
17584 // surfaces here rather than at the wire-up's compile
17585 // error far from the ctor definition.
17586 let set: Vec<&'static str> = vec![":tag", ":rev"];
17587 let joined: String = set.join(", ");
17588 assert_eq!(
17589 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
17590 DepError::FontePinAmbiguous {
17591 nome: "caixa-teia".to_string(),
17592 pins: ":tag, :rev".to_string(),
17593 },
17594 "fonte_pin_ambiguous ctor must accept an owned-`String` \
17595 `&set.join(\", \")` carrier via Deref coercion — the exact \
17596 shape the ambiguity-arm wire-up site passes into it",
17597 );
17598 }
17599
17600 #[test]
17601 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
17602 // Cross-axis routing pin: sweep the two constructor input axes
17603 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
17604 // fixtures against every generated arm in the
17605 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
17606 // trim / truncate at codegen time — a silent field swap between
17607 // `nome` and the middle `<axis>` field, or a `<axis>` axis
17608 // silently rerouted through the wrong field on any one variant
17609 // — surfaces here rather than at a downstream diagnostic-shape
17610 // mismatch. Peer of the sibling
17611 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17612 // (6f5e0cd) pin on the same envelope's peer two-slot family
17613 // (`{ nome, list: &'static str }`) and of the sibling
17614 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
17615 // (5621f8a) pin on the same envelope's three-slot `{ nome,
17616 // <axis>: String, reason: String }` family — extended here onto
17617 // the `{ nome, <axis>: String }` two-slot envelope so the last
17618 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
17619 // ladder guarantees each field routes the caller's value
17620 // verbatim through `.to_string()` in declared field order.
17621 // Distinct-per-axis fixtures rule out any two-axis swap
17622 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
17623 // per-axis pin.
17624 let nome = "sibling-teia";
17625 let axis = "distinct-axis-value";
17626 assert_eq!(
17627 DepError::fonte_pin_empty(nome, axis),
17628 DepError::FontePinEmpty {
17629 nome: nome.to_string(),
17630 pin: axis.to_string(),
17631 },
17632 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
17633 in declared field order",
17634 );
17635 assert_eq!(
17636 DepError::fonte_pin_ambiguous(nome, axis),
17637 DepError::FontePinAmbiguous {
17638 nome: nome.to_string(),
17639 pins: axis.to_string(),
17640 },
17641 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
17642 in declared field order",
17643 );
17644 assert_eq!(
17645 DepError::caracteristica_duplicate(nome, axis),
17646 DepError::CaracteristicaDuplicate {
17647 nome: nome.to_string(),
17648 caracteristica: axis.to_string(),
17649 },
17650 "caracteristica_duplicate must route `nome` → `nome`, \
17651 `axis` → `caracteristica` in declared field order",
17652 );
17653 }
17654}