caixa_core/dep.rs
1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17/// :versao "^0.1"
18/// :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22/// :versao "*"
23/// :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27/// :versao "0.1.0"
28/// :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33 /// Caixa name — must match the target caixa's `:nome`.
34 pub nome: String,
35
36 /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37 pub versao: String,
38
39 /// Where to fetch the caixa from. Defaults to the feira registry.
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub fonte: Option<DepSource>,
42
43 /// If true, a missing `:fonte` is not a build failure.
44 #[serde(default, skip_serializing_if = "is_false")]
45 pub opcional: bool,
46
47 /// Feature flags to enable on the target caixa.
48 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81 /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82 /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83 /// or any git-ssh URL.
84 Git {
85 repo: String,
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 tag: Option<String>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 rev: Option<String>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 branch: Option<String>,
92 },
93 /// Local filesystem path — dev only; cannot be published.
94 Path { caminho: String },
95}
96
97impl DepSource {
98 /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99 ///
100 /// This is the resolver-side fallback for `dep.fonte: None`, not an
101 /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102 /// all `None`) and is therefore rejected by [`Self::validate`]. The
103 /// resolver fills the pin in at fetch time from the resolved commit;
104 /// authors never serialize this shape as a `Dep::fonte` value.
105 #[must_use]
106 pub fn default_github(org: &str, nome: &str) -> Self {
107 Self::Git {
108 repo: format!("github:{org}/{nome}"),
109 tag: None,
110 rev: None,
111 branch: None,
112 }
113 }
114
115 /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116 /// every consumer that reads "which single git ref does this source
117 /// resolve to?" keys off — returns the author-declared `:tag` /
118 /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119 /// borrowed from the typed slot's own `Option<String>` storage; `None`
120 /// on [`Self::Path`] (a path source carries no git-ref) and on a
121 /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122 /// `None` (the [`Self::default_github`] shorthand shape the resolver
123 /// materializes when the author omits `:fonte` — rejected by
124 /// [`Self::validate`], but the accessor's return is defined on this
125 /// arm too so pre-validate consumers reach for the same typed dispatch
126 /// as post-validate ones).
127 ///
128 /// **Precedence: rev > tag > branch.** The canonical precedence every
129 /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130 /// per-fetch `git checkout <ref>` reads through the same
131 /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132 /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133 /// through the same cascade at caixa-crd/src/conversion.rs. The
134 /// [`Self::validate`] gate enforces "exactly one pin set" — under
135 /// that invariant every accepted [`Self::Git`] carries exactly one
136 /// non-`None` pin and the precedence is unobservable, but the
137 /// precedence remains defined for pre-validate consumers (the
138 /// resolver's `MissingPin` diagnostic path, the caixa-crd
139 /// round-trip's default `"main"` fallback the author never sees a
140 /// diagnostic on) and defense-in-depth for a hypothetical future
141 /// state where multiple pins survive the gate. The precedence is
142 /// **rev before tag** because `:rev` (a git commit OID) is the
143 /// reproducibility-strongest identifier — an OID resolves to exactly
144 /// one commit regardless of which refname points at it, whereas
145 /// `:tag` and `:branch` are refnames the remote can silently move
146 /// (a tag re-push, a branch head advance); the resolver's freeze
147 /// step at fetch time promotes the resolved commit to `:rev` for
148 /// exactly this reason. **Tag before branch** because `:tag` is
149 /// conventionally immutable (a release tag) whereas `:branch` is
150 /// conventionally mutable (a tracking ref) — a caixa carrying both
151 /// a release tag and a tracking branch reads as "prefer the release
152 /// pin, fall through to the tracking pin only if the release is
153 /// missing". The cascade order also matches the byte-order every
154 /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155 /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156 /// [`Self::validate`]'s `pins` array).
157 ///
158 /// Prior to this lift the "sole set pin" projection sat twice in the
159 /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160 /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161 /// { … })?;`) and at caixa-crd's `dep_into_ref`
162 /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163 /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164 /// of the same precedence cascade with no compile-time link back to
165 /// the typed slot. A future extension of the pin axis to a richer
166 /// author surface (a `:commit` pin peer of `:rev` once the substrate
167 /// grows a signed-commit-verification pin, a `:ref` pin the M4
168 /// substrate operator resolves per-cluster ahead of fetch, a
169 /// promotion of the plain `Option<String>` pins to a typed
170 /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171 /// once the sibling [`crate::render::is_git_oid`] /
172 /// [`crate::render::is_git_ref_name`] gates land as typed
173 /// constructors) would have had to be threaded through both
174 /// open-coded copies in lockstep or the resolver's `git checkout`
175 /// target would silently disagree with the CRD's `git_ref` fill —
176 /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177 /// "v1"))` would ship with the resolver checking out `deadbeef`
178 /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179 /// lacre closure disagreeing with the emitted K8s CR the operator
180 /// reads. Lifting the resolution to a typed method on the substrate
181 /// primitive means both downstream consumers reach for exactly one
182 /// typed dispatch — the resolver's accept-set migrates as a unit on
183 /// any future pin-axis addition.
184 ///
185 /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186 /// `Option<&DepSource>` composite-reference accessor on the outer-
187 /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188 /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189 /// git-fetching consumer runs after the outer `:fonte` slot resolves
190 /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191 /// substrate primitive, thin projections at each consumer" discipline
192 /// the outer accessor family already carries.
193 #[must_use]
194 pub fn sole_pin(&self) -> Option<&str> {
195 match self {
196 Self::Git {
197 tag, rev, branch, ..
198 } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199 Self::Path { .. } => None,
200 }
201 }
202
203 /// Validate the `:fonte` value-shape: every author-surface
204 /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205 /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206 /// value; every `:fonte (:tipo path …)` must carry a non-empty
207 /// `:caminho`.
208 ///
209 /// Called from [`Dep::validate`] with the dep's `:nome` so every
210 /// diagnostic carries the offending entry verbatim — same
211 /// self-locating shape the `:deps :versao` (2420c44),
212 /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213 /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214 /// (3f9d7a0) gates already expose.
215 ///
216 /// Until this gate landed `:fonte` was the only `:deps`-related
217 /// typed surface still untyped past `Caixa::from_lisp`:
218 /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219 /// passed parse and surfaced as a git-clone failure at
220 /// lacre-resolve time, far from the source caixa.lisp.
221 /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222 /// passed parse and surfaced as the resolver's
223 /// [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224 /// at fetch time, again far from the source caixa.lisp; lifting
225 /// to validate-time gives the author the same diagnostic at the
226 /// edit site.
227 /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228 /// pins set — passed parse and the resolver silently picked
229 /// `:rev > :tag > :branch`, ignoring the other pins with no
230 /// diagnostic; the author had no way to know their `:branch`
231 /// was dropped. This is the canonical "pin drift" footgun.
232 /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233 /// passed parse and surfaced as `git checkout ""` at fetch time.
234 /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235 /// parse and surfaced as
236 /// [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237 /// with `path: PathBuf("")` — not actionable.
238 ///
239 /// Each rejected shape maps to a typed
240 /// [`DepError::Fonte*`] variant that names the offending
241 /// dep's `:nome` and the specific axis, so the author can grep
242 /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243 /// one edit.
244 pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245 match self {
246 Self::Git {
247 repo,
248 tag,
249 rev,
250 branch,
251 } => {
252 if repo.is_empty() {
253 return Err(DepError::fonte_repo_empty(nome));
254 }
255 // The `:repo` value flows verbatim into the caixa-resolver's
256 // `git clone <repo>` subprocess invocation. Until this gate
257 // landed `:repo` was the last untyped `:fonte`-related axis
258 // past the empty arm: a malformed-but-non-empty repo URL
259 // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260 // `":repo "-upload-pack=evil""` leading `-` — the canonical
261 // CLI-argument-injection vector at the `git clone` boundary;
262 // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263 // reads as a relative filesystem path rather than the
264 // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265 // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266 // silently passed validate and the failure surfaced at
267 // lacre-resolve time with a porcelain-quoting-confused error
268 // far from the source caixa.lisp. The lifted predicate makes
269 // the git-porcelain-URL intersection-floor a substrate-level
270 // invariant at validate time, peer with the three pin axes
271 // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272 // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273 // — every `:fonte (:tipo git …)` past validate is now
274 // structurally accept-shaped on every axis the resolver
275 // consumes (the `:repo` URL the `git clone` invokes against,
276 // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277 // accepts, the `:rev` commit OID the lacre's content-
278 // addressing equality probe resolves), closing the
279 // `:fonte` slot's value-shape trajectory end-to-end.
280 if let Err(reason) = crate::render::is_git_repo_url(repo) {
281 return Err(DepError::fonte_repo_shape(nome, repo, reason));
282 }
283 let pins: [(&'static str, Option<&String>); 3] = [
284 (":tag", tag.as_ref()),
285 (":rev", rev.as_ref()),
286 (":branch", branch.as_ref()),
287 ];
288 let set: Vec<&'static str> =
289 pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290 match set.len() {
291 0 => {
292 return Err(DepError::fonte_pin_missing(nome));
293 }
294 1 => {
295 for (pin, value) in pins {
296 if value.is_some_and(String::is_empty) {
297 return Err(DepError::fonte_pin_empty(nome, pin));
298 }
299 }
300 }
301 _ => {
302 return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303 }
304 }
305 // Per-pin value-shape gate. The refname-shaped axes
306 // (`:tag` + `:branch`) route through
307 // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308 // `:rev` axis routes through
309 // [`crate::render::is_git_oid`]. The two predicates
310 // partition the `:fonte` pin axes structurally — refname
311 // vs. hex commit — so a cross-axis mis-slot (the
312 // canonical "I conflated `:rev` and `:branch`" footgun:
313 // `:rev "main"` defeating the reproducibility contract,
314 // `:tag "deadbeef…"` mis-slotting a SHA into the
315 // refname-shaped axis) lands at the offending axis's
316 // predicate, not at lacre-resolve `git fetch` /
317 // `git checkout` time. Their valid sets intersect at
318 // the empty set: every refname is rejected by
319 // `is_git_oid`, every OID is rejected by
320 // `is_git_ref_name`, structurally.
321 //
322 // Until this gate landed `:tag` / `:branch` were the
323 // refname-shaped axes still untyped past the empty-pin
324 // arm: a malformed-but-non-empty refname
325 // (`:tag "v0.1.0 "` trailing space — the canonical
326 // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327 // with git's atomic-rename guard suffix; `:tag "../escape"`
328 // path-traversal via consecutive dots; `:branch "main "`
329 // trailing space; `:branch "feature/foo bar"` embedded
330 // space; `:branch "@"` the literal HEAD alias;
331 // `:branch "refs/heads/main"` the fully-qualified ref
332 // copied from `git show-ref` output that resolves to
333 // a literal ref named `refs/heads/refs/heads/main` on
334 // disk) silently passed validate; the `:rev` axis was
335 // the last `:fonte`-related axis still untyped past the
336 // empty-pin arm: a malformed-but-non-empty hex-OID
337 // (`:rev "main"` conflating with `:branch` — the
338 // reproducibility-contract leak; `:rev "v0.1.0"`
339 // conflating with `:tag` — the same mis-slot on the
340 // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341 // 6-char prefix that's ambiguous across repo history;
342 // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343 // inconsistently against `git rev-parse HEAD`'s
344 // lowercase emission) silently passed validate and the
345 // failure surfaced at lacre-resolve `git fetch` /
346 // `git checkout` time with a quoting-confused error
347 // far from the source caixa.lisp, with no field naming
348 // which `:deps` entry carried the typo. Lifting both
349 // gates to caixa-build time matches the value-shape
350 // trajectory the peer typed axes already follow
351 // (c4213a4 typed WitContract endpoint/subject/slot;
352 // eb3456d :entrada :paths; c7d05ec :entrada :host;
353 // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354 // 63e18a0 :contratos :subject; 2f4316e :contratos
355 // :slot; e70d213 :fonte :tag + :branch) — the typed
356 // slot's valid set matches its downstream consumer's
357 // accepted set (here, the git porcelain's refname /
358 // commit-OID grammars at `git fetch` / `git checkout`
359 // time), structurally. Same diagnostic shape every
360 // per-axis value-shape lift already exposes
361 // (`*Invalid { axis, reason }`); the `value:` field
362 // carries the offending refname / OID verbatim so the
363 // author can grep their caixa.lisp for the
364 // `:tag "<value>"` / `:branch "<value>"` /
365 // `:rev "<value>"` literal and fix it in one edit.
366 for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367 if let Some(v) = value
368 && let Err(reason) = crate::render::is_git_ref_name(v)
369 {
370 return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371 }
372 }
373 if let Some(v) = rev.as_ref()
374 && let Err(reason) = crate::render::is_git_oid(v)
375 {
376 return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377 }
378 Ok(())
379 }
380 Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381 }
382 }
383
384 /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385 /// `:caminho` axis. Walks the leading-byte cascade closed by the
386 /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387 /// orthogonal embedded-control-byte arm (d624c8d) covering
388 /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389 /// embedded-`\` Windows-path-separator arm closing the
390 /// cross-host-OS-separator divergence vector on the same
391 /// THEORY.md §V.2 render-determinism axis.
392 ///
393 /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394 /// per-arm cascade now spans nine diagnostic shapes — every new
395 /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396 /// a future glob-metachar `*` / `?` arm) lands here rather than
397 /// re-inflating `Self::validate`. The
398 /// function stays a thin per-arm linear walk for one reason: each
399 /// arm's diagnostic carries a distinct typed [`DepError`] variant
400 /// rather than a parser-shaped `reason` string, so collapsing the
401 /// cascade onto a generic [`crate::render`] predicate would regress
402 /// the per-arm self-locating diagnostic that `feira lint` consumers
403 /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404 /// [`crate::render::is_git_repo_url`], etc.) lives on the
405 /// reason-string-shaped axes; the `:caminho` axis keeps its
406 /// per-arm variant shape.
407 #[allow(
408 clippy::too_many_lines,
409 reason = "the per-arm cascade is structurally flat by design — every \
410 `:caminho` arm carries its own typed [`DepError`] variant + \
411 per-arm Why comment, so collapsing the cascade onto a generic \
412 [`crate::render`] predicate would regress the per-arm self-locating \
413 diagnostic the `feira lint` consumer surface depends on"
414 )]
415 fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416 if caminho.is_empty() {
417 return Err(DepError::fonte_caminho_empty(nome));
418 }
419 // Reproducibility gate on the `:fonte (:tipo path …)`
420 // `:caminho` axis. The lacre pipeline embeds the value
421 // verbatim in its per-dep content-address
422 // (`conteudo: format!("path:{caminho}")`,
423 // caixa-resolver/src/resolve.rs:189) and that string
424 // folds into the BLAKE3 closure the lacre keys every
425 // downstream consumer (the substrate's reproducibility
426 // contract, CAIXA-SDLC §III.2 — the lacre is the
427 // build's content-addressed identity, peer of the Nix
428 // store path) against. Until this gate landed an
429 // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430 // canonical "I dragged the folder out of Finder into
431 // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432 // the macOS path-layout peer; the
433 // `${WORKSPACE}/caixa-teia` shell-expanded literal
434 // pasted from a CI manifest) silently passed validate
435 // and the failure surfaced *as a successful build with
436 // a divergent lacre*: the BLAKE3 closure on Alice's
437 // workstation differed from the closure on Bob's
438 // workstation, two CI runners with different
439 // `${HOME}` layouts emitted two distinct
440 // content-addresses for the byte-identical caixa, and
441 // the substrate's "the lacre is the build's identity"
442 // contract silently broke far from the source
443 // caixa.lisp — the most insidious failure mode the
444 // typed slot can carry (no error surfaces; the
445 // divergence is invisible until two machines compare
446 // lacres). The same THEORY.md §V.2 render-determinism
447 // discipline `is_sandboxed_relative_path` already
448 // applies on the M2 typed path-slots
449 // (`:behavior :on-*`, `:upgrade-from :state-change
450 // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451 // narrowed to the absolute-vs-relative axis only:
452 // `:fonte :caminho`'s canonical author-surface form is
453 // the `..`-traversing sibling-workspace path
454 // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455 // full `is_sandboxed_relative_path` lift would
456 // structurally reject every legitimate path-fonte
457 // dep. The narrower
458 // `std::path::Path::is_absolute` cut admits the
459 // sibling-workspace form while still rejecting the
460 // host-layout-leaking absolute shape — the
461 // reproducibility contract bites at exactly the
462 // absolute boundary, and that's the axis the
463 // substrate-level invariant is meant to hold. Same
464 // diagnostic shape every per-axis value-shape lift on
465 // the surrounding [`DepError::Fonte*`] cluster carries
466 // (the offending `:nome` + offending `:caminho`
467 // quoted verbatim so the author can grep their
468 // caixa.lisp for the `:caminho "<value>"` literal and
469 // fix it in one edit). The empty arm strictly
470 // precedes this arm so the blank-string footgun
471 // surfaces the more self-locating
472 // `FonteCaminhoEmpty` diagnostic (the empty string
473 // is not absolute under `Path::new("").is_absolute()`
474 // so the precedence is a no-op at value level — the
475 // pin matters only at the diagnostic-shape level if
476 // a future codec round-trip ever produces an empty
477 // string that probes as absolute).
478 if std::path::Path::new(caminho).is_absolute() {
479 return Err(DepError::fonte_caminho_absolute(nome, caminho));
480 }
481 // Reproducibility gate's tilde-expansion arm. The b94fd83
482 // `FonteCaminhoAbsolute` closes the leading-`/`
483 // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484 // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485 // doc footgun) silently passed both the empty arm and
486 // the absolute arm because `Path::new("~").is_absolute()`
487 // returns `false` — `~` is a shell-expansion convention,
488 // not a POSIX path component, so `std::path::Path` treats
489 // it as a literal directory-name segment. The lacre
490 // pipeline then embedded the value verbatim
491 // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492 // failure mode forked per consumer:
493 //
494 // - The caixa-resolver's `Path` arm folds `:caminho`
495 // through `Path::new(caminho).join(<file>)` without
496 // `~`-expansion, so the build looked for a literal
497 // `./~/work/caixa-teia` subdirectory and failed at
498 // resolve time with a `No such file or directory`
499 // error far from the source caixa.lisp (the lacre
500 // itself, though, was already byte-identical across
501 // machines — every machine emitted the same
502 // `path:~/work/caixa-teia` content-address).
503 // - A future caixa-resolver pass that *does* expand `~`
504 // (the canonical shell-convention idiom every
505 // resolver eventually reaches for once an author
506 // reports the literal-`~`-directory bug) would re-
507 // introduce the host-layout-leak the b94fd83 absolute
508 // gate closes: Alice's `~` expands to `/home/alice`,
509 // Bob's to `/home/bob`, two CI runners with different
510 // `$HOME` layouts resolve to two distinct paths for
511 // the byte-identical caixa, and the substrate's
512 // "the lacre is the build's identity" contract
513 // silently breaks far from the source caixa.lisp.
514 //
515 // Closing the gate at `DepSource::validate` (here at the
516 // canonical caixa-build-time boundary, peer with the
517 // absolute arm above) refuses both failure modes
518 // structurally: the typed accepted set excludes every
519 // `~`-prefixed authoring shape, so the resolver is
520 // free to grow `~`-expansion (or any other convention-
521 // expansion the substrate adopts) without re-opening
522 // the host-layout-leak at the typed boundary. Same
523 // diagnostic shape every per-axis value-shape gate on
524 // the surrounding [`DepError::Fonte*`] cluster carries
525 // (the offending `:nome` + offending `:caminho` quoted
526 // verbatim so the author can grep their caixa.lisp for
527 // the `:caminho "<value>"` literal and fix it in one
528 // edit).
529 //
530 // The cascade preserves narrower-diagnostic-first
531 // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532 // → `FonteCaminhoTildeExpansion`. The empty arm
533 // structurally precedes both (the bytes "" / "~" don't
534 // overlap), and the absolute arm structurally precedes
535 // the tilde arm (an absolute path can't start with `~`
536 // since absolute paths start with `/`; the bytes "/" /
537 // "~" don't overlap either). Both arms are
538 // value-disjoint, so the precedence is a no-op at value
539 // level — the pin matters only at the diagnostic-shape
540 // level if a future codec round-trip ever produces a
541 // value that probes as both absolute and tilde-prefixed.
542 if caminho.starts_with('~') {
543 return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544 }
545 // Reproducibility gate's shell-variable-expansion arm.
546 // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547 // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548 // closes the leading-`~` shell-home-expansion shape; the
549 // leading-`$` is the sibling shell-variable-expansion shape
550 // — same host-layout-leaking semantic, different syntactic
551 // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552 // canonical paste-from-`echo $HOME`-doc footgun) and the
553 // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554 // the canonical paste-from-CI-manifest footgun every
555 // GitHub Actions / GitLab CI / Drone manifest carries)
556 // silently passed every prior arm because
557 // `Path::is_absolute` returns false on `$` (the `$` is a
558 // shell convention, not a POSIX path component, so
559 // `std::path::Path` treats it as a literal directory-name
560 // segment) and the tilde arm's `starts_with('~')` doesn't
561 // fire.
562 //
563 // Same per-consumer failure-fork the tilde arm closes:
564 //
565 // - The caixa-resolver's `Path` arm folds `:caminho`
566 // through `Path::new(caminho).join(<file>)` without
567 // `$`-expansion, so the build looks for a literal
568 // `./$HOME/work/caixa-teia` subdirectory and fails at
569 // resolve time with a `No such file or directory`
570 // error far from the source caixa.lisp.
571 // - A future caixa-resolver pass that *does* expand
572 // `$VAR` (the shell-convention idiom every resolver
573 // eventually reaches for once an author reports the
574 // literal-`$HOME`-directory bug, especially for CI's
575 // `${WORKSPACE}` idiom) would re-introduce the host-
576 // layout-leak the b94fd83 absolute gate closes:
577 // Alice's `$HOME` expands to `/home/alice`, Bob's to
578 // `/home/bob`, two CI runners with different
579 // `${WORKSPACE}` layouts resolve to two distinct
580 // paths for the byte-identical caixa, and the
581 // substrate's "the lacre is the build's identity"
582 // contract silently breaks far from the source
583 // caixa.lisp.
584 //
585 // Closing the gate at `DepSource::validate` (here at the
586 // canonical caixa-build-time boundary, peer with the
587 // absolute + tilde arms above) refuses both failure modes
588 // structurally. Same diagnostic shape every per-axis
589 // value-shape gate on the surrounding [`DepError::Fonte*`]
590 // cluster carries (the offending `:nome` + offending
591 // `:caminho` quoted verbatim).
592 //
593 // The cascade preserves narrower-diagnostic-first ordering:
594 // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595 // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596 // The empty arm structurally precedes all three subsequent
597 // arms; the absolute arm structurally precedes both the
598 // tilde and the var arms (absolute paths start with `/`,
599 // the bytes `/` / `~` / `$` don't overlap at the leading
600 // position); the tilde arm structurally precedes the var
601 // arm (`~` and `$` don't overlap at the leading position).
602 // Every pair is value-disjoint, so the precedence is a
603 // no-op at value level — the pin matters only at the
604 // diagnostic-shape level if a future codec round-trip ever
605 // produces a probe-as-both value.
606 //
607 // The gate covers every leading-`$` shape: the canonical
608 // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609 // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610 // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611 // GitHub Actions / GitLab CI / Drone paste footgun), the
612 // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613 // (degenerate "I meant `$HOME` and forgot the rest"). All
614 // shapes route through the same `caminho.starts_with('$')`
615 // byte check.
616 if caminho.starts_with('$') {
617 return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618 }
619 // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620 // f4efe9c arms closed the leading-byte host-layout-leak shapes
621 // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622 // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623 // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624 // *except* the ASCII space byte `0x20`). The bare ASCII space at
625 // the leading position is the orthogonal paste-from-aligned-doc
626 // shape that silently passed every prior arm: `Path::is_absolute`
627 // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628 // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629 // the value's last byte is not `/`, so the canonical
630 // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631 // form in a multi-entry `:deps` block sits at the same column —
632 // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633 // it from the rendered alignment into a fresh entry preserves the
634 // leading whitespace verbatim) silently rendered as a path with
635 // a leading-space directory component the resolver folds through
636 // `Path::join` looking for a literal `./ ../caixa-teia`
637 // subdirectory that fails at resolve time with a non-self-
638 // locating `No such file or directory` error.
639 //
640 // The lacre pipeline's reproducibility contract bites
641 // strictly at this byte: `path:" ../caixa-teia"` and
642 // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643 // (`conteudo: format!("path:{caminho}")`,
644 // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645 // semantic-identical caixa, and the substrate's "the lacre is
646 // the build's identity" contract (CAIXA-SDLC §III.2) silently
647 // breaks across two workstations whose authors differ only in
648 // paste-from-aligned-doc whitespace habits — the most insidious
649 // failure mode the typed slot can carry (no error surfaces; the
650 // divergence is invisible until two machines compare lacres).
651 //
652 // The arm fires AFTER the absolute / tilde / var leading-byte
653 // arms (each names the more self-locating shell-convention
654 // diagnostic on values that probe as that arm's leading-byte
655 // sentinel followed by a leading space — e.g.
656 // `:caminho "/ /foo"` surfaces `FonteCaminhoAbsolute` because
657 // the leading byte is `/`, not space) and BEFORE the
658 // embedded-control-byte arm (a leading-space value with an
659 // embedded control byte surfaces the broader leading-space
660 // diagnostic because the cascade walks leading-byte arms first
661 // — peer with how `FonteCaminhoAbsolute` precedes
662 // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663 //
664 // The peer single-token-shaped axes already reject leading
665 // whitespace on the same paste-from-aligned-doc contract:
666 // [`crate::render::is_git_repo_url`] rejects leading whitespace
667 // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668 // leading whitespace on `:fonte :tag`/`:branch`,
669 // [`crate::render::is_chart_description_shape`] rejects leading
670 // whitespace on `:descricao`,
671 // [`crate::render::is_spdx_expression_shape`] rejects leading
672 // whitespace on `:licenca`. Closing the same byte on
673 // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674 // space anywhere in a typed string slot" invariant structurally
675 // consistent across every value-shape-gated typed surface (the
676 // `:caminho` axis was the last typed string surface still
677 // admitting a leading space byte).
678 if caminho.starts_with(' ') {
679 return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680 }
681 // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682 // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683 // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684 // this arm closes the orthogonal leading-`-` axis on the same
685 // subprocess-argument-boundary the peer `is_git_repo_url` arm
686 // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687 // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688 // `:fonte :tag` / `:branch`) already reject.
689 //
690 // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691 // content-address (`conteudo: format!("path:{caminho}")`,
692 // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693 // value through `Path::join` looking for a literal `./{caminho}`
694 // subdirectory. Every downstream subprocess that consumes the
695 // resolved path — a `git -C {caminho} <verb>` invocation, a
696 // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697 // future operator-side `nix build --path {caminho}` spawn, an
698 // `xargs` / `find {caminho}` / `stat {caminho}` /
699 // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700 // as a CLI flag rather than a positional path when the
701 // subprocess invocation does not carry a `--` argument-list
702 // terminator between the flag block and the path argument. The
703 // canonical footguns:
704 //
705 // - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706 // `find -rf` reinterpretation; the byte the peer
707 // `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708 // example paste-idiom carries as its first token).
709 // - `:caminho "-C"` — `git -C` config-injection paste
710 // (`git -C -C` reinterprets the second `-C` as another
711 // `--change-directory` flag rather than the path
712 // argument; the canonical `git -C <path>` porcelain
713 // idiom every multi-repo workspace tool carries).
714 // - `:caminho "--upload-pack=cat /etc/passwd"` — the
715 // canonical long-flag CLI-arg-injection vector at every
716 // git porcelain entry point (`git clone`, `git fetch`,
717 // `git ls-remote`) that consumes a path or URL
718 // argument; peer with `is_git_repo_url`'s leading-`-`
719 // arm (render.rs:2037) on the sibling `:fonte :repo`
720 // axis, which the arm's diagnostic explicitly cites.
721 // - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722 // override paste-idiom (paste-from-`git -c foo=bar`
723 // shell-history footgun that reinterprets the value as
724 // a `[foo] bar` config injection on every git porcelain
725 // entry point).
726 //
727 // POSIX `std::path::Path` treats a leading `-` as a literal
728 // filename byte, so the resolver folds `-rf` through `Path::join`
729 // and looks for a literal `./-rf` subdirectory — the failure
730 // surfaces at resolve time with a non-self-locating `No such
731 // file or directory` error far from the source caixa.lisp, and
732 // the value rides through the lacre content-address into every
733 // downstream shell-spawned subprocess. On any consumer that
734 // shells out without the `--` terminator (the common case at
735 // every porcelain entry-point) the reinterpretation is silent
736 // and the failure mode is arbitrary-argument-injection.
737 //
738 // The arm fires AFTER the absolute / tilde / var / leading-space
739 // leading-byte arms (each names the more self-locating shell-
740 // convention diagnostic on values that probe as that arm's
741 // leading-byte sentinel — the byte sets are pairwise disjoint at
742 // the leading position, so the precedence pin is a no-op at
743 // value level, but the ordering keeps every leading-byte arm's
744 // diagnostic-shape stable) and BEFORE the embedded-control-byte
745 // arm (a leading-`-` value with an embedded control byte
746 // surfaces the narrower leading-`-` diagnostic because the
747 // cascade walks leading-byte arms first — peer with how
748 // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749 // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750 // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751 //
752 // The peer single-token-shaped axes already reject leading `-`
753 // on the same CLI-arg-injection contract:
754 // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755 // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756 // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757 // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758 // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759 // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760 // [`crate::render::is_cargo_feature_name`] rejects it on
761 // `:caracteristicas`, and the feira `init` / `add <nome>`
762 // positional gate (868c191) rejects it on the CLI positional
763 // itself. Closing the same byte on `:fonte :caminho` makes the
764 // substrate-wide "no leading `-` anywhere in a typed single-
765 // token string slot routed through a subprocess argument"
766 // invariant structurally consistent across every value-shape-
767 // gated typed surface (the `:caminho` axis was the last typed
768 // string surface still admitting a leading `-` byte).
769 if caminho.starts_with('-') {
770 return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771 }
772 // Reproducibility gate's embedded-control-byte arm. The
773 // b94fd83 + a5c248e + f4efe9c arms closed the three
774 // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775 // this arm closes the orthogonal embedded-control-byte
776 // axis — any ASCII control byte (`0x00..=0x1F` plus
777 // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778 // shape every peer single-token-typed-slot value-shape
779 // predicate the surrounding [`crate::render`] cluster
780 // gates against (the lifted `is_git_repo_url` arm on
781 // `:fonte :repo`, the `is_git_ref_name` arm on
782 // `:tag`/`:branch`, the `is_chart_description_shape` /
783 // `is_chart_maintainer_name_shape` /
784 // `is_chart_keyword_shape` arms on the
785 // Helm-chart-shaped axes); now consistent on the
786 // `:caminho` axis too.
787 //
788 // Until this gate landed any embedded control byte
789 // silently passed validate, the lacre pipeline embedded
790 // the value verbatim in its per-dep content-address
791 // (`conteudo: format!("path:{caminho}")`,
792 // caixa-resolver/src/resolve.rs:189), and the failure
793 // forked per byte and per consumer:
794 //
795 // - NUL (`0x00`) the canonical "POSIX paths cannot
796 // contain a NUL byte" shape: every `std::fs` syscall
797 // routes the path through `CString::new`, which
798 // fails with `NulError` on the first NUL byte; the
799 // build would surface a `NulError` at resolve time
800 // far from the source caixa.lisp.
801 // - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802 // multiline-doc footgun: a `:caminho
803 // "../caixa-teia\nrm -rf /"` value (paste landed mid-
804 // `:caminho` block from a multi-line code-fence)
805 // silently round-trips through `Path::join` but the
806 // embedded newline class is a sibling of the CRLF-at-
807 // subprocess-argument injection vector
808 // `is_git_repo_url` already closes on `:repo`.
809 // - Tab (`0x09`) the canonical paste-from-aligned-table
810 // footgun: the tab is invisible in most editors, and
811 // the lacre embeds the value verbatim so two
812 // paste-from-distinct-tables yield divergent lacres
813 // across host editors that strip vs preserve tabs.
814 // - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815 // paste-from-binary-blob shape every peer single-
816 // token-shaped slot rejects under the same
817 // `b < 0x20 || b == 0x7F` predicate.
818 //
819 // Mirrors the cascade discipline every prior `:caminho`
820 // arm establishes: `FonteCaminhoEmpty` →
821 // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822 // → `FonteCaminhoVarExpansion` →
823 // `FonteCaminhoLeadingWhitespace` →
824 // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825 // The six leading-byte arms structurally precede the
826 // embedded-byte arm because the leading-byte shapes are
827 // the more self-locating diagnostic on values that probe
828 // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829 // narrower `FonteCaminhoAbsolute` rather than the broader
830 // embedded-control-byte arm); the precedence pin matters
831 // at the diagnostic-shape level even though the empty /
832 // absolute / tilde / var arms are value-disjoint from a
833 // bare control byte (which would itself be a leading
834 // byte under the empty / absolute / tilde / var arms'
835 // leading-position semantics, but those arms guard the
836 // specific shell-convention characters `/` / `~` / `$`
837 // — a leading `0x01` byte falls through to this arm).
838 for &b in caminho.as_bytes() {
839 if b < 0x20 || b == 0x7F {
840 return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841 }
842 }
843 // Reproducibility gate's Windows-path-separator arm. The four
844 // leading-byte arms (`/` / `~` / `$`) and the embedded-
845 // control-byte arm close the host-layout-leaking + paste-from-
846 // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847 // the orthogonal cross-host-OS-separator shape — same render-
848 // determinism axis, different semantic mechanism. POSIX
849 // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850 // inside a single path component (so `..\caixa-teia` is one
851 // directory named literally `..\caixa-teia`, sibling of `.`
852 // and `..`); Windows [`std::path::Path`] treats `\` as a
853 // primary path separator equal to `/` (so `..\caixa-teia` is
854 // the parent's sibling directory `caixa-teia`). The lacre
855 // pipeline embeds the value verbatim in its per-dep content-
856 // address (`conteudo: format!("path:{caminho}")`, caixa-
857 // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858 // values resolve to two distinct directories across runner
859 // OSes — the same THEORY.md §V.2 render-determinism contract
860 // the absolute / tilde / var arms protect, here against the
861 // cross-host-OS-separator divergence vector. Even on POSIX-
862 // only resolvers (the canonical pleme-io substrate posture),
863 // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864 // PowerShell `Get-Location` paste-idiom footgun) silently
865 // passes every prior arm because `Path::is_absolute` returns
866 // false on `..` and `\` is neither a leading-byte sentinel
867 // nor a control byte, then the resolver folds the value
868 // through `Path::new(caminho).join(<file>)` looking for a
869 // literal `./..\caixa-teia` subdirectory and fails at
870 // resolve time with a non-self-locating `No such file or
871 // directory` error far from the source caixa.lisp.
872 //
873 // The peer single-token-shaped axes on the same git-CLI /
874 // path-CLI consumer cluster already reject `\` under the same
875 // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876 // line 1441 (`"must not contain \\ … the canonical Windows-
877 // path-leak footgun; use / for hierarchical refs"`) gates
878 // `:fonte :tag` / `:fonte :branch` against the same byte,
879 // and [`crate::render::is_gateway_api_http_path`] line 506
880 // includes `\` in the eleven-byte RFC-3986-reserved rejection
881 // set on `:entrada :paths`. Closing the same byte on `:fonte
882 // :caminho` makes the substrate-wide "no Windows path
883 // separator anywhere in a typed string slot" invariant
884 // structurally consistent across every path-shaped typed
885 // surface (the `:caminho` axis was the last typed string
886 // surface still admitting `\`).
887 //
888 // The arm fires AFTER the control-char arm because the
889 // control-char diagnostic is the more self-locating axis on
890 // values that probe as both (`"..\caixa\0teia"` carries both
891 // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892 // rejected byte, so `FonteCaminhoControlChar` wins). Same
893 // narrower-diagnostic-first cascade discipline every prior
894 // arm establishes. A pure-`\` value
895 // (`"..\caixa-teia"` with no control bytes) falls through
896 // every prior arm and lands here.
897 for &b in caminho.as_bytes() {
898 if b == b'\\' {
899 return Err(DepError::fonte_caminho_backslash(nome, caminho));
900 }
901 }
902 // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903 // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904 // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905 // paste-from-shell-prompt footgun class, different syntactic surface.
906 // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907 // single path component (so `../caixa-teia>output` is one directory
908 // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909 // but every interactive shell (bash / zsh / fish / nushell) lexes
910 // `<` / `>` as input / output redirection operators — a `:caminho
911 // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912 // pipeline that wrote build output and forgot to trim the redirect"
913 // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914 // redirection paste idiom) silently passes every prior arm because
915 // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916 // byte sentinels nor control bytes nor `\`, and the value's last byte
917 // isn't `/`. The resolver folds the value through
918 // `Path::new(caminho).join(<file>)` looking for a literal
919 // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920 // with a non-self-locating `No such file or directory` error far
921 // from the source caixa.lisp.
922 //
923 // The lacre pipeline embeds the value verbatim in its per-dep
924 // content-address (`conteudo: format!("path:{caminho}")`,
925 // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926 // the BLAKE3 closure and rides downstream as part of the build's
927 // identity. The bytes carry a second class of hazard the prior
928 // separator-shaped arms don't: every typed-string slot whose value
929 // ever flows verbatim into a shell-spawned subprocess (the caixa-
930 // resolver's `git clone` invocation, a future `feira tofu` shell-
931 // out, a future operator-side `nix flake check` spawn) is the
932 // canonical CRLF-at-subprocess-argument / shell-metachar injection
933 // surface that every peer single-token-shaped typed slot already
934 // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935 // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936 // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937 // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938 // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939 // shell-metachar-injection banner. The `:caminho` axis was the last
940 // typed string surface still admitting these two bytes; this arm
941 // closes the gap so the substrate-wide "no shell-redirection
942 // metacharacter anywhere in a typed string slot" invariant is now
943 // structurally consistent across every path-shaped typed surface.
944 //
945 // The arm fires AFTER the control-char arm + backslash arm because
946 // both prior arms carry more self-locating diagnostics on values
947 // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948 // cross-OS-separator divergence is the load-bearing axis, so the
949 // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950 // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951 // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952 // because the embedded redirection byte is the more semantic-
953 // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954 // but the load-bearing diagnostic is the embedded `<` shell-
955 // redirection — the trailing `/` is the secondary observation, and
956 // an author who removes the `<` is likely to also tab-strip the
957 // trailing separator).
958 for &b in caminho.as_bytes() {
959 if b == b'<' || b == b'>' {
960 return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961 }
962 }
963 // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964 // arm closes the `<` / `>` input/output redirection sentinels; `|`
965 // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966 // shell-prompt footgun class, different syntactic surface. POSIX
967 // `std::path::Path` treats `|` as a literal path-component byte (so
968 // `../caixa-teia|tee` is one directory named literally
969 // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970 // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971 // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972 // `ls ../caixa-teia | grep` line out of a shell-history block and
973 // forgot to trim the pipeline tail" footgun) or `:caminho
974 // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975 // circuit OR line" idiom) silently passes every prior arm because
976 // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977 // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978 // value's last byte isn't `/`. The resolver folds the value through
979 // `Path::new(caminho).join(<file>)` looking for a literal
980 // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981 // with a non-self-locating `No such file or directory` error far
982 // from the source caixa.lisp.
983 //
984 // The lacre pipeline embeds the value verbatim in its per-dep
985 // content-address (`conteudo: format!("path:{caminho}")`,
986 // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987 // BLAKE3 closure and rides downstream as part of the build's identity
988 // into every shell-spawned subprocess (the caixa-resolver's `git
989 // clone` invocation, a future `feira tofu` shell-out, a future
990 // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991 // subprocess-argument / shell-metachar injection surface every peer
992 // single-token-shaped typed slot already closes. The peer path-shaped
993 // axis [`crate::render::is_gateway_api_http_path`]
994 // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996 // axis was the last typed path-string surface still admitting this
997 // byte; this arm closes the gap so the substrate-wide "no shell-
998 // composition metacharacter anywhere in a typed string slot that
999 // flows verbatim into a shell-spawned subprocess" invariant extends
1000 // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001 // `:caminho` axis.
1002 //
1003 // The arm fires AFTER the shell-redirection arm because the prior
1004 // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005 // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006 // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007 // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008 // cascade discipline every prior `:caminho` arm establishes). The arm
1009 // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010 // the more semantic-locating axis on probe-as-both values
1011 // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012 // embedded `|` shell-pipe — the trailing `/` is the secondary
1013 // observation, and an author who removes the `|` is likely to also
1014 // tab-strip the trailing separator).
1015 for &b in caminho.as_bytes() {
1016 if b == b'|' {
1017 return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018 }
1019 }
1020 // Reproducibility gate's shell-command-separator arm. The 124106f
1021 // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022 // shell-command-separator sentinel — same paste-from-shell-prompt
1023 // footgun class, different syntactic surface. POSIX `std::path::Path`
1024 // treats `;` as a literal path-component byte (so
1025 // `../caixa-teia;rm -rf /` is one directory named literally
1026 // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027 // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028 // sequential-command terminator that fires the next command
1029 // regardless of the prior command's exit status — a `:caminho
1030 // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031 // one-liner that chained a cleanup tail after the directory name"
1032 // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033 // POSIX `case` arm's `;;` terminator into the middle of a path"
1034 // idiom) silently passes every prior arm because `Path::is_absolute`
1035 // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036 // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037 // byte isn't `/`. The resolver folds the value through
1038 // `Path::new(caminho).join(<file>)` looking for a literal
1039 // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040 // time with a non-self-locating `No such file or directory` error far
1041 // from the source caixa.lisp.
1042 //
1043 // The lacre pipeline embeds the value verbatim in its per-dep
1044 // content-address (`conteudo: format!("path:{caminho}")`,
1045 // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046 // BLAKE3 closure and rides downstream as part of the build's identity
1047 // into every shell-spawned subprocess (the caixa-resolver's `git
1048 // clone` invocation, a future `feira tofu` shell-out, a future
1049 // operator-side `nix flake check` spawn) as the canonical
1050 // shell-metachar injection surface every peer single-token-shaped
1051 // typed slot already closes. The peer path-shaped axis
1052 // [`crate::render::is_gateway_api_http_path`]
1053 // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055 // axis was the last typed path-string surface still admitting this
1056 // byte; this arm closes the gap so the substrate-wide "no shell-
1057 // composition metacharacter anywhere in a typed string slot that
1058 // flows verbatim into a shell-spawned subprocess" invariant extends
1059 // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060 // `:caminho` axis.
1061 //
1062 // The arm fires AFTER the shell-pipe arm because the prior arm's
1063 // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064 // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065 // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066 // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067 // cascade discipline every prior `:caminho` arm establishes). The arm
1068 // fires BEFORE the trailing-`/` arm because the embedded
1069 // command-separator byte is the more semantic-locating axis on
1070 // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071 // load-bearing diagnostic is the embedded `;` shell-command-
1072 // separator — the trailing `/` is the secondary observation, and an
1073 // author who removes the `;` is likely to also tab-strip the trailing
1074 // separator).
1075 for &b in caminho.as_bytes() {
1076 if b == b';' {
1077 return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078 }
1079 }
1080 // Reproducibility gate's shell-background / logical-AND arm. The
1081 // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082 // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083 // — same paste-from-shell-prompt footgun class, different
1084 // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085 // literal path-component byte (so `../caixa-teia & sleep 1` is
1086 // one directory named literally `../caixa-teia & sleep 1`,
1087 // sibling of `.` and `..`), but every interactive shell
1088 // (bash / zsh / fish / nushell) lexes `&` two ways:
1089 //
1090 // - Single `&` as the background-task terminator that detaches
1091 // the prior command into the background and returns control
1092 // to the prompt immediately (the canonical `cmd &` idiom
1093 // every long-running pipeline uses);
1094 // - Double `&&` as the logical-AND list operator that fires
1095 // the next command only if the prior command succeeded (the
1096 // canonical `make && make install` idiom every build script
1097 // carries).
1098 //
1099 // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100 // pasted a `cd path & sleep 1` background-launch into the
1101 // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102 // (the symmetric "I copied a `cd path && make` build chain"
1103 // idiom) silently passes every prior arm because
1104 // `Path::is_absolute` returns false on `..`, `&` is neither a
1105 // leading-byte sentinel nor a control byte nor `\` nor
1106 // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107 // The resolver folds the value through
1108 // `Path::new(caminho).join(<file>)` looking for a literal
1109 // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110 // time with a non-self-locating `No such file or directory`
1111 // error far from the source caixa.lisp.
1112 //
1113 // The lacre pipeline embeds the value verbatim in its per-dep
1114 // content-address (`conteudo: format!("path:{caminho}")`,
1115 // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116 // the BLAKE3 closure and rides downstream as part of the build's
1117 // identity into every shell-spawned subprocess (the
1118 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119 // shell-out, a future operator-side `nix flake check` spawn) as
1120 // the canonical shell-metachar injection surface every peer
1121 // single-token-shaped typed slot already closes. The peer
1122 // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123 // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125 // `:caminho` axis was the last typed path-string surface still
1126 // admitting this byte; this arm closes the gap so the
1127 // substrate-wide "no shell-composition metacharacter anywhere
1128 // in a typed string slot that flows verbatim into a
1129 // shell-spawned subprocess" invariant extends from
1130 // shell-command-separator (`;`) to shell-background /
1131 // logical-AND (`&`) on the `:caminho` axis.
1132 //
1133 // The arm fires AFTER the shell-command-separator arm because
1134 // the prior arm's `cmd-a; cmd-b` shape is the more common
1135 // shell-history paste idiom on values that probe as both
1136 // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137 // command-separator-tail paste is the load-bearing root-cause
1138 // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139 // discipline every prior `:caminho` arm establishes). The arm
1140 // fires BEFORE the trailing-`/` arm because the embedded
1141 // background / list-AND byte is the more semantic-locating axis
1142 // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143 // load-bearing diagnostic is the embedded `&` shell-background
1144 // / logical-AND metachar — the trailing `/` is the secondary
1145 // observation, and an author who removes the `&` is likely to
1146 // also tab-strip the trailing separator).
1147 for &b in caminho.as_bytes() {
1148 if b == b'&' {
1149 return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150 }
1151 }
1152 // Reproducibility gate's shell-command-substitution arm. The
1153 // e12e4f3 shell-background / logical-AND arm closes the `&`
1154 // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155 // command-substitution sentinel — every POSIX shell (sh /
1156 // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157 // the canonical legacy wrapper that runs the enclosed command
1158 // and substitutes its standard-output verbatim into the
1159 // surrounding word (a `whoami` wrapped in backticks expands
1160 // to the current user's name; a `cat /etc/passwd` wrapped in
1161 // backticks expands to the file's contents — the canonical
1162 // CWE-78 shell-command-injection vector every shell-side
1163 // hardening guide enumerates first). POSIX
1164 // `std::path::Path` treats backtick as a literal path-
1165 // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166 // is one directory named literally that, sibling of `.` and
1167 // `..`).
1168 //
1169 // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170 // canonical "I pasted a shell one-liner carrying a backticked
1171 // `whoami` command-substitution expansion into the `:caminho`
1172 // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173 // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174 // path` working-directory expansion") silently passes every
1175 // prior arm because `Path::is_absolute` returns false on
1176 // `..`, the backtick byte is neither a leading-byte sentinel
1177 // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178 // modern `$()` form at leading position only; backtick is
1179 // the orthogonal legacy form) nor a control byte nor `\` nor
1180 // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181 // byte isn't `/`. The resolver folds the value through
1182 // `Path::new(caminho).join(<file>)` looking for a literal
1183 // subdirectory whose name embeds the backticked token and
1184 // fails at resolve time with a non-self-locating `No such
1185 // file or directory` error far from the source caixa.lisp.
1186 //
1187 // The lacre pipeline embeds the value verbatim in its per-
1188 // dep content-address (`conteudo: format!("path:{caminho}")`,
1189 // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190 // lands in the BLAKE3 closure and rides downstream as part
1191 // of the build's identity into every shell-spawned
1192 // subprocess (the caixa-resolver's `git clone` invocation, a
1193 // future `feira tofu` shell-out, a future operator-side
1194 // `nix flake check` spawn) as the canonical shell-metachar
1195 // injection surface every peer single-token-shaped typed
1196 // slot already closes. The peer path-shaped axis
1197 // [`crate::render::is_gateway_api_http_path`]
1198 // (caixa-core/src/render.rs:506) rejects backtick as part of
1199 // its eleven-byte RFC-3986-reserved set on `:entrada
1200 // :paths`. The `:caminho` axis was the last typed path-
1201 // string surface still admitting this byte; this arm closes
1202 // the gap so the substrate-wide "no shell-composition
1203 // metacharacter anywhere in a typed string slot that flows
1204 // verbatim into a shell-spawned subprocess" invariant
1205 // extends from shell-background / logical-AND (`&`) to
1206 // shell-command-substitution (backtick) on the `:caminho`
1207 // axis.
1208 //
1209 // The arm fires AFTER the shell-background arm because the
1210 // prior arm's `cmd & sleep` shape is the more common shell-
1211 // history paste idiom on values that probe as both (a
1212 // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213 // both `&` and a backtick — the background-launch tail is
1214 // the load-bearing root-cause edit, so
1215 // `FonteCaminhoShellBackground` wins; same cascade
1216 // discipline every prior `:caminho` arm establishes). The
1217 // arm fires BEFORE the trailing-`/` arm because the
1218 // embedded command-substitution byte is the more semantic-
1219 // locating axis on probe-as-both values (a
1220 // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221 // load-bearing diagnostic is the embedded backtick shell-
1222 // command-substitution metachar — the trailing `/` is the
1223 // secondary observation, and an author who removes the
1224 // backtick is likely to also tab-strip the trailing
1225 // separator).
1226 for &b in caminho.as_bytes() {
1227 if b == b'`' {
1228 return Err(DepError::fonte_caminho_shell_command_substitution(
1229 nome, caminho,
1230 ));
1231 }
1232 }
1233 // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234 // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235 // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236 // paste-from-shell-prompt footgun class, different syntactic surface.
1237 // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238 // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239 // sequence of characters in a path component (including the empty
1240 // sequence), `?` matches exactly one character. POSIX
1241 // `std::path::Path` treats both bytes as literal path-component bytes
1242 // (so `../caixa-teia/*.lisp` is one directory named literally
1243 // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244 //
1245 // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246 // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247 // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248 // `rm foo?` single-char-wildcard removal idiom") silently passes
1249 // every prior arm because `Path::is_absolute` returns false on `..`,
1250 // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251 // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252 // value's last byte isn't `/`. The resolver folds the value through
1253 // `Path::new(caminho).join(<file>)` looking for a literal
1254 // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255 // non-self-locating `No such file or directory` error far from the
1256 // source caixa.lisp.
1257 //
1258 // The lacre pipeline embeds the value verbatim in its per-dep
1259 // content-address (`conteudo: format!("path:{caminho}")`,
1260 // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261 // the BLAKE3 closure and rides downstream as part of the build's
1262 // identity into every shell-spawned subprocess (the caixa-resolver's
1263 // `git clone` invocation, a future `feira tofu` shell-out, a future
1264 // operator-side `nix flake check` spawn) as the canonical
1265 // shell-metachar / pathname-expansion surface every peer
1266 // single-token-shaped typed slot already closes. The peer path-shaped
1267 // axis [`crate::render::is_gateway_api_http_path`]
1268 // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270 // `:caminho` axis was the last typed path-string surface still
1271 // admitting these two bytes; this arm closes the gap so the
1272 // substrate-wide "no shell-composition / glob-expansion
1273 // metacharacter anywhere in a typed string slot that flows verbatim
1274 // into a shell-spawned subprocess" invariant extends from
1275 // shell-command-substitution (backtick) to glob-expansion
1276 // (`*` / `?`) on the `:caminho` axis.
1277 //
1278 // The arm fires AFTER the backtick arm because the prior arm's
1279 // CWE-78 shell-command-injection vector is the load-bearing
1280 // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281 // carries both backtick and `*` — the command-substitution paste
1282 // is the load-bearing root-cause edit, so
1283 // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284 // discipline every prior `:caminho` arm establishes). The arm
1285 // fires BEFORE the trailing-`/` arm because the embedded glob
1286 // byte is the more semantic-locating axis on probe-as-both values
1287 // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288 // embedded `*` glob metachar — the trailing `/` is the secondary
1289 // observation, and an author who removes the `*` is likely to
1290 // also tab-strip the trailing separator).
1291 for &b in caminho.as_bytes() {
1292 if b == b'*' || b == b'?' {
1293 return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294 }
1295 }
1296 // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297 // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298 // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299 // grouping sentinels — same paste-from-shell-prompt footgun class,
1300 // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301 // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302 // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303 // shell with a fresh environment scope (the canonical sandboxing
1304 // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305 // to scope a `cd` to one subshell without disturbing the parent's
1306 // working directory), and `$(<cmd>)` is the modern Bourne
1307 // command-substitution shape the upstream f4efe9c
1308 // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309 // the closing `)` byte completes that substitution shape and must
1310 // be refused on the same axis (peer with the
1311 // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312 // same byte-pair on the sibling `:fonte :repo` axis under the
1313 // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314 // POSIX `std::path::Path` treats both bytes as literal path-
1315 // component bytes (so `../caixa-teia/(date)` is one directory
1316 // named literally `../caixa-teia/(date)`, sibling of `.` and
1317 // `..`).
1318 //
1319 // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320 // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321 // liner whose modern command-substitution expansion lands the
1322 // current date as a subdirectory name" footgun) or `:caminho
1323 // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324 // `(cd foo && pwd)` subshell-grouping working-directory probe
1325 // idiom") silently passes every prior arm because
1326 // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327 // neither leading-byte sentinels nor control bytes nor `\` nor
1328 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329 // and the value's last byte isn't `/`. The resolver folds the
1330 // value through `Path::new(caminho).join(<file>)` looking for a
1331 // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332 // at resolve time with a non-self-locating `No such file or
1333 // directory` error far from the source caixa.lisp.
1334 //
1335 // The lacre pipeline embeds the value verbatim in its per-dep
1336 // content-address (`conteudo: format!("path:{caminho}")`,
1337 // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338 // in the BLAKE3 closure and rides downstream as part of the
1339 // build's identity into every shell-spawned subprocess (the
1340 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341 // shell-out, a future operator-side `nix flake check` spawn) as
1342 // the canonical shell-metachar / subshell-grouping surface every
1343 // peer single-token-shaped typed slot already closes. The peer
1344 // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345 // rejects the same byte pair on `:fonte :repo` under the same
1346 // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347 // `:caminho` axis was the last typed path-string surface still
1348 // admitting these two bytes;
1349 // this arm closes the gap so the substrate-wide "no shell-
1350 // composition metacharacter anywhere in a typed string slot that
1351 // flows verbatim into a shell-spawned subprocess" invariant
1352 // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353 // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354 // leading-`$` arm, the typed `:caminho` accepted set now
1355 // structurally excludes the entire modern Bourne
1356 // command-substitution surface — leading `$` closes the
1357 // leading byte of every `$(<cmd>)` shape, this arm closes the
1358 // trailing `)` boundary.
1359 //
1360 // The arm fires AFTER the shell-glob arm because the prior arm's
1361 // `*` / `?` pathname-expansion shape is the more common shell-
1362 // history paste idiom on values that probe as both
1363 // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364 // glob-paste-tail is the load-bearing root-cause edit, so
1365 // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366 // prior `:caminho` arm establishes). The arm fires BEFORE the
1367 // trailing-`/` arm because the embedded subshell-grouping byte
1368 // is the more semantic-locating axis on probe-as-both values
1369 // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370 // is the embedded `(` shell-subshell-grouping metachar — the
1371 // trailing `/` is the secondary observation, and an author who
1372 // removes the `(` is likely to also tab-strip the trailing
1373 // separator).
1374 for &b in caminho.as_bytes() {
1375 if b == b'(' || b == b')' {
1376 return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377 nome, caminho, b,
1378 ));
1379 }
1380 }
1381 // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382 // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383 // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384 // URI-Template-placeholder byte pair — same paste-from-shell-
1385 // prompt + paste-from-templated-doc footgun class, different
1386 // syntactic surface. Every POSIX-derived shell that implements
1387 // brace expansion (bash / zsh / ksh / fish; the canonical
1388 // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389 // `cp file{,.bak}` idiom every shell-history block carries)
1390 // expands `{a,b,c}` to the cross-product of its comma-separated
1391 // members and `{1..10}` to the integer range; RFC 6570 reserves
1392 // the matched pair for URI Template placeholders (the canonical
1393 // `https://{host}/{org}/{repo}` substitution shape every
1394 // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395 // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396 // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397 // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398 // shape) emit. POSIX `std::path::Path` treats both bytes as
1399 // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400 // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401 // sibling of `.` and `..`).
1402 //
1403 // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404 // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405 // expansion one-liner that fans across two siblings" footgun)
1406 // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407 // a `{{org}}` Mustache / Helm template placeholder out of a
1408 // README quick-start and forgot to substitute") silently passes
1409 // every prior arm because `Path::is_absolute` returns false on
1410 // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411 // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412 // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413 // byte isn't `/`. The resolver folds the value through
1414 // `Path::new(caminho).join(<file>)` looking for a literal
1415 // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416 // at resolve time with a non-self-locating `No such file or
1417 // directory` error far from the source caixa.lisp.
1418 //
1419 // The lacre pipeline embeds the value verbatim in its per-dep
1420 // content-address (`conteudo: format!("path:{caminho}")`,
1421 // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422 // lands in the BLAKE3 closure and rides downstream as part of
1423 // the build's identity into every shell-spawned subprocess
1424 // (the caixa-resolver's `git clone` invocation, a future
1425 // `feira tofu` shell-out, a future operator-side `nix flake
1426 // check` spawn) as the canonical shell-metachar / brace-
1427 // expansion surface every peer single-token-shaped typed
1428 // slot already closes. The peer git-source axis
1429 // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430 // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431 // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432 // shell-brace-expansion banner. The `:caminho` axis was the last
1433 // typed path-string surface still admitting these two bytes;
1434 // this arm closes the gap so the substrate-wide "no shell-
1435 // composition metacharacter anywhere in a typed string slot
1436 // that flows verbatim into a shell-spawned subprocess"
1437 // invariant extends from shell-subshell-grouping (`(` / `)`)
1438 // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439 // and the typed `:caminho` accepted set now also structurally
1440 // excludes the URI Template / templating-engine placeholder
1441 // surface that would silently round-trip through any
1442 // downstream IaC templating-engine layer.
1443 //
1444 // The arm fires AFTER the shell-subshell-grouping arm because
1445 // the prior arm's `(` / `)` shape is the more semantic-locating
1446 // axis on values that probe as both (`"../{cd foo}(date)"`
1447 // carries both `{` and `(` — the parenthesis-pair is the
1448 // load-bearing modern-Bourne-command-substitution surface the
1449 // prior arm closes; same cascade discipline every prior
1450 // `:caminho` arm establishes). The arm fires BEFORE the
1451 // trailing-`/` arm because the embedded brace-expansion byte
1452 // is the more semantic-locating axis on probe-as-both values
1453 // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454 // load-bearing diagnostic is the embedded `{` brace-expansion
1455 // metachar — the trailing `/` is the secondary observation,
1456 // and an author who removes the `{` is likely to also tab-
1457 // strip the trailing separator).
1458 for &b in caminho.as_bytes() {
1459 if b == b'{' || b == b'}' {
1460 return Err(DepError::fonte_caminho_shell_brace_expansion(
1461 nome, caminho, b,
1462 ));
1463 }
1464 }
1465 // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466 // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467 // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468 // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469 // footgun class, different syntactic surface. Every POSIX shell
1470 // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471 // bracket pair as the glob character-class operator: `[abc]`
1472 // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473 // ASCII letter; `[^x]` negates (the canonical
1474 // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475 // lowercase-sibling glob every shell-history block carries —
1476 // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477 // closing the unbounded pathname-expansion sentinels). The
1478 // bracket pair additionally carries the POSIX `test` /
1479 // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480 // the canonical idiom every shell-script conditional uses) and
1481 // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482 // bracket pair is the TOML inline-array delimiter
1483 // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484 // manifest cross-idiom-leak vector), the YAML flow-sequence
1485 // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486 // values.yaml cross-idiom leak), the JSON array delimiter,
1487 // and the POSIX-ERE / PCRE bracket-expression / character-
1488 // class anchor (the canonical paste-from-regex-doc shape).
1489 // POSIX `std::path::Path` treats both bytes as literal path-
1490 // component bytes (so `../[caixa-teia]` is one directory
1491 // named literally `../[caixa-teia]`, sibling of `.` and
1492 // `..`).
1493 //
1494 // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495 // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496 // one-liner that matches every lowercase-sibling-suffix
1497 // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498 // build"` (the symmetric "I pasted a TOML inline-array /
1499 // YAML flow-sequence shape out of an aligned manifest"
1500 // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501 // `*.[ch]` C-source character-class paste-from-shell-history
1502 // shape) silently passes every prior arm because
1503 // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504 // neither leading-byte sentinels nor control bytes nor `\`
1505 // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506 // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507 // last byte isn't `/`. The resolver folds the value through
1508 // `Path::new(caminho).join(<file>)` looking for a literal
1509 // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510 // time with a non-self-locating `No such file or directory`
1511 // error far from the source caixa.lisp.
1512 //
1513 // The lacre pipeline embeds the value verbatim in its per-dep
1514 // content-address (`conteudo: format!("path:{caminho}")`,
1515 // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516 // lands in the BLAKE3 closure and rides downstream as part of
1517 // the build's identity into every shell-spawned subprocess
1518 // (the caixa-resolver's `git clone` invocation, a future
1519 // `feira tofu` shell-out, a future operator-side `nix flake
1520 // check` spawn) as the canonical shell-metachar / glob-
1521 // character-class / TOML-array surface every peer single-
1522 // token-shaped typed slot already closes. The `:caminho` axis
1523 // was the last typed path-string surface still admitting
1524 // these two bytes; this arm closes the gap so the substrate-
1525 // wide "no shell-composition metacharacter anywhere in a
1526 // typed string slot that flows verbatim into a shell-spawned
1527 // subprocess" invariant extends from shell-brace-expansion
1528 // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529 // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530 // the typed `:caminho` accepted set now structurally excludes
1531 // the entire POSIX pathname-expansion / glob surface —
1532 // unbounded glob (`*` / `?`) AND bounded character-class
1533 // (`[abc]` / `[a-z]`).
1534 //
1535 // The arm fires AFTER the shell-brace-expansion arm because
1536 // the prior arm's `{` / `}` shape is the more semantic-
1537 // locating axis on values that probe as both
1538 // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539 // expansion fan is the load-bearing root-cause edit, so
1540 // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541 // discipline every prior `:caminho` arm establishes). The arm
1542 // fires BEFORE the trailing-`/` arm because the embedded
1543 // bracket-expansion byte is the more semantic-locating axis
1544 // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545 // load-bearing diagnostic is the embedded `[` glob-character-
1546 // class metachar — the trailing `/` is the secondary
1547 // observation, and an author who removes the `[` is likely
1548 // to also tab-strip the trailing separator).
1549 for &b in caminho.as_bytes() {
1550 if b == b'[' || b == b']' {
1551 return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552 nome, caminho, b,
1553 ));
1554 }
1555 }
1556 // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557 // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558 // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559 // delimiter pair — same paste-from-shell-prompt footgun class,
1560 // different syntactic surface. Every POSIX shell (sh / bash /
1561 // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562 // string-literal quoting operator: `'…'` is the strong
1563 // (no-expansion) single-quoted string and `"…"` is the weak
1564 // (variable-/command-substitution-preserving) double-quoted
1565 // string — the canonical `cd '../caixa-teia'` shell-history
1566 // idiom every path-with-embedded-whitespace paste block carries,
1567 // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568 // shape. Beyond shell, the two bytes carry the JSON string-literal
1569 // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570 // config cross-idiom-leak vector), the YAML double-quoted +
1571 // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572 // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573 // manifest cross-idiom leak), the TOML basic + literal string
1574 // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575 // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576 // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577 // — the canonical "I copied the entire `:caminho "..."` slot
1578 // rather than just the string body" author-surface footgun),
1579 // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580 // excludes both bytes from the `unreserved / pct-encoded /
1581 // sub-delims / ":" / "@"` `pchar` production. POSIX
1582 // `std::path::Path` treats both bytes as literal path-component
1583 // bytes (so `../"caixa-teia"` is one directory named literally
1584 // `../"caixa-teia"`, sibling of `.` and `..`).
1585 //
1586 // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587 // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588 // quoting preserved the sibling-workspace path verbatim across
1589 // the whitespace paste boundary" footgun), `:caminho
1590 // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591 // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592 // string / paste-from-tatara-lisp string-literal cross-idiom-
1593 // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594 // quote "I pasted a JSON key-value pair fragment into the
1595 // middle of the path" idiom) silently passes every prior arm
1596 // because `Path::is_absolute` returns false on `..` / `'` /
1597 // `"`, `'` / `"` are neither leading-byte sentinels nor
1598 // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599 // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600 // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601 // folds the value through `Path::new(caminho).join(<file>)`
1602 // looking for a literal `./'../caixa-teia'` subdirectory and
1603 // fails at resolve time with a non-self-locating `No such file
1604 // or directory` error far from the source caixa.lisp.
1605 //
1606 // The lacre pipeline embeds the value verbatim in its per-dep
1607 // content-address (`conteudo: format!("path:{caminho}")`,
1608 // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609 // lands in the BLAKE3 closure and rides downstream as part of
1610 // the build's identity into every shell-spawned subprocess
1611 // (the caixa-resolver's `git clone` invocation, a future
1612 // `feira tofu` shell-out, a future operator-side `nix flake
1613 // check` spawn) as the canonical shell-metachar / string-
1614 // literal-delimiter surface every peer single-token-shaped
1615 // typed slot already closes. The peer `:fonte :repo` axis
1616 // closes both bytes under the same shell-quote-grouping /
1617 // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618 // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619 // `:caminho` axis was the last typed path-string surface
1620 // still admitting these two bytes; this arm closes the gap
1621 // so the substrate-wide "no shell-composition metacharacter
1622 // anywhere in a typed string slot that flows verbatim into a
1623 // shell-spawned subprocess" invariant extends from shell-
1624 // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625 // / `"`) on the `:caminho` axis. Together with the peer
1626 // JSON / YAML / TOML string-literal delimiters closing at
1627 // this arm and the 598b770 `{` / `}` brace-expansion arm
1628 // closing the templating-engine-placeholder boundary, the
1629 // typed `:caminho` accepted set now structurally excludes
1630 // the entire cross-config-DSL string-literal / templating
1631 // paste-from-aligned-manifest cross-idiom-leak surface that
1632 // would silently round-trip through any downstream JSON /
1633 // YAML / TOML / HCL / tatara-lisp parsing layer.
1634 //
1635 // The arm fires AFTER the shell-bracket-expansion arm because
1636 // the prior arm's `[` / `]` shape is the more semantic-
1637 // locating axis on values that probe as both (`"../[a-z]'x'"`
1638 // carries both `[` and `'` — the glob-character-class
1639 // expansion is the load-bearing root-cause edit, so
1640 // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641 // discipline every prior `:caminho` arm establishes). The arm
1642 // fires BEFORE the trailing-`/` arm because the embedded
1643 // quote-grouping byte is the more semantic-locating axis on
1644 // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645 // the load-bearing diagnostic is the embedded `'` shell-
1646 // string-literal metachar — the trailing `/` is the secondary
1647 // observation, and an author who removes the `'` is likely to
1648 // also tab-strip the trailing separator).
1649 for &b in caminho.as_bytes() {
1650 if b == b'\'' || b == b'"' {
1651 return Err(DepError::fonte_caminho_shell_quote_grouping(
1652 nome, caminho, b,
1653 ));
1654 }
1655 }
1656 // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657 // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658 // the orthogonal "byte at which four distinct downstream parsers all
1659 // truncate the value at the first occurrence" surface, and no prior arm
1660 // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661 // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662 // of a word (or after unquoted whitespace) as the comment-lead: from
1663 // that byte to the end of the physical line is a comment discarded
1664 // before command parsing (`cd ../caixa-teia # legacy sibling` — the
1665 // canonical paste-from-shell-history-with-trailing-annotation shape
1666 // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667 // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668 // at any position preceded by whitespace or at line-start (`path:
1669 // ../caixa-teia # pin` — the canonical paste-from-values.yaml /
1670 // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671 // treats `;` as the comment-lead but a growing number of consumer
1672 // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673 // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674 // the comment-lead too — the pair extends the cross-config-DSL
1675 // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676 // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677 // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678 // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679 // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680 // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681 // `#` selects a flake output — the same axis the peer
1682 // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683 // surface at a68f818 with the same downstream-drops-the-tail
1684 // rationale).
1685 //
1686 // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687 // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688 // paste-from-shell-history-with-trailing-annotation footgun),
1689 // `:caminho "../caixa-teia # pin"` (the symmetric YAML flow-scalar
1690 // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691 // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692 // silently passes every prior arm because `Path::is_absolute` returns
1693 // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694 // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695 // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696 // and the value's last byte isn't `/`. The resolver folds the value
1697 // through `Path::new(caminho).join(<file>)` looking for a literal
1698 // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699 // resolve time with a non-self-locating `No such file or directory`
1700 // error far from the source caixa.lisp — while every downstream
1701 // shell / YAML / URL parser silently truncates the value at the `#`
1702 // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703 // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704 // an emitted YAML `path:` scalar disagree with the resolver on which
1705 // directory the value names. Two workstations whose downstream
1706 // shell / YAML / URL parsing layers differ in unquoted-`#`
1707 // recognition emit divergent build artifacts for the byte-identical
1708 // caixa.lisp value.
1709 //
1710 // The lacre pipeline embeds the value verbatim in its per-dep
1711 // content-address (`conteudo: format!("path:{caminho}")`,
1712 // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713 // closure and rides downstream as part of the build's identity into
1714 // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715 // invocation, a future `feira tofu` shell-out, a future operator-side
1716 // `nix flake check` spawn) as the canonical shell-metachar /
1717 // comment-lead / URL-fragment-delimiter surface every peer
1718 // single-token-shaped typed slot already closes. The peer `:fonte
1719 // :repo` axis closes the byte under the URL-fragment-identifier
1720 // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721 // the last typed path-string surface still admitting the byte. This
1722 // arm closes the gap so the substrate-wide "no shell-composition
1723 // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724 // typed string slot that flows verbatim into a shell-spawned
1725 // subprocess or downstream YAML / URL parser" invariant extends from
1726 // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727 // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728 // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729 // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730 // templating-engine-placeholder boundary, the typed `:caminho`
1731 // accepted set now structurally excludes the entire
1732 // paste-with-trailing-annotation / paste-from-URL-permalink /
1733 // paste-from-YAML-comment cross-idiom-leak surface that would
1734 // silently round-trip through any downstream shell / YAML / URL /
1735 // dotenv / gitconfig / HCL parsing layer to a different value than
1736 // the resolver's `Path::join` sees.
1737 //
1738 // The arm fires AFTER the shell-quote-grouping arm because the prior
1739 // arm's `'` / `"` shape is the more semantic-locating axis on values
1740 // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741 // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742 // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743 // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744 // trailing-`/` arm because the embedded comment-lead / fragment-
1745 // delimiter byte is the more semantic-locating axis on probe-as-both
1746 // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747 // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748 // observation, and an author who removes the `#pin` fragment is
1749 // likely to also tab-strip the trailing separator).
1750 for &b in caminho.as_bytes() {
1751 if b == b'#' {
1752 return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753 }
1754 }
1755 // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756 // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757 // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758 // byte — the mandatory encoding mechanism for every byte outside the
1759 // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760 // itself must be percent-encoded as `%25` to appear literally inside
1761 // a URL value. The byte carries three distinct render-determinism
1762 // hazards on the `:caminho` axis, no prior arm has covered it, and
1763 // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764 // already closes the same byte under the same URL-percent-encoding
1765 // banner — the `:caminho` axis was the last typed path-string surface
1766 // still admitting the byte.
1767 //
1768 // First, the paste-from-browser-address-bar percent-encoded-space
1769 // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770 // README hyperlink / a browser address bar / a percent-encoded
1771 // permalink expecting `%20` to decode to a literal space at the
1772 // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773 // literal path-component byte, so `Path::join` looks for a literal
1774 // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775 // non-self-locating `No such file or directory` error far from the
1776 // source caixa.lisp — while the author's mental model was
1777 // `../caixa teia`, the decoded shape. Two authors whose only
1778 // difference is percent-encoding presence resolve to two distinct
1779 // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780 // for what they intended as the byte-identical sibling-workspace
1781 // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782 // content-address (`conteudo: format!("path:{caminho}")`,
1783 // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784 // downstream into the BLAKE3 closure and locks the substrate's
1785 // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786 // to the wrong encoding — the same THEORY.md §V.2 render-
1787 // determinism vector every prior `:caminho` arm protects.
1788 //
1789 // Second, the printf-format-specifier lead footgun: `%` is the C /
1790 // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791 // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792 // shell-diagnostic one-liner carries) and the printf builtin is
1793 // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794 // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795 // value flowing into any future `feira` verb that shells out with a
1796 // printf-formatted path template silently gets reinterpreted as a
1797 // format-directive rather than a literal byte — the canonical
1798 // CWE-134 format-string-injection vector.
1799 //
1800 // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801 // ksh reserve `%N` at word-start as the job-control specifier —
1802 // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803 // "the most recent job whose command started with `foo`". A future
1804 // `feira` verb that invokes `kill %1` on a caminho-scoped
1805 // subprocess would silently redirect the signal to a wrong target.
1806 //
1807 // Beyond the three shell-side hazards, `%` is a first-class parser
1808 // byte in three cross-config-DSL layers the substrate's paste-idiom
1809 // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810 // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811 // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812 // YAML directive block silently trips the YAML directive parser on
1813 // any downstream emitted YAML manifest); Prometheus / Grafana
1814 // template syntax uses `%(var)s` as the substitution lead; and Nix
1815 // interpolation uses `${var}` (not `%`) but Envsubst /
1816 // Kubernetes / OpenShift template layers use `%VAR%` as the
1817 // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818 // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819 //
1820 // The three malformed-`%HH` classes documented on the peer
1821 // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822 //
1823 // - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824 // where `%` isn't followed by two hex digits) — every WHATWG-
1825 // conformant URL parser rejects the value at parse time per
1826 // RFC 3986 §2.1, but the byte rides into the lacre before
1827 // the resolver subprocess crosses the URL-parser boundary.
1828 // - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829 // intending the `%2F` as the URL encoding of `/`) locks a
1830 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831 // the byte-identical `path:../caixa/teia` form.
1832 // - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833 // already itself an encoded `%`, so the intent was likely a
1834 // literal `%20` that survived one round-trip through a
1835 // URL-encoder that shouldn't have run) locks a triply-
1836 // divergent closure across the encoded / once-decoded /
1837 // twice-decoded chain.
1838 //
1839 // POSIX `std::path::Path` treats the byte as a literal path-
1840 // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841 // paste-from-browser-address-bar percent-encoded-space footgun),
1842 // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843 // directive-block cross-idiom leak), or `:caminho
1844 // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845 // shell-diagnostic-one-liner shape) silently passes every prior arm
1846 // because `Path::is_absolute` returns false on `..`, `%` is neither
1847 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850 // value's last byte isn't `/`. The resolver folds the value through
1851 // `Path::new(caminho).join(<file>)` looking for a literal
1852 // subdirectory named `../caixa%20teia` and fails at resolve time
1853 // with a non-self-locating `No such file or directory` error far
1854 // from the source caixa.lisp — while every downstream URL parser /
1855 // shell printf builtin / YAML directive parser silently
1856 // reinterprets the byte to a different value than the resolver's
1857 // `Path::join` sees. Two workstations whose downstream URL / shell
1858 // / YAML layers differ in `%HH` recognition emit divergent build
1859 // artifacts for the byte-identical caixa.lisp value.
1860 //
1861 // The lacre pipeline embeds the value verbatim in its per-dep
1862 // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863 // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864 // closure and rides into every shell-spawned subprocess (the
1865 // resolver's `git clone`, a future `feira tofu` shell-out, a
1866 // future operator-side `nix flake check` spawn) as the canonical
1867 // URL-percent-encoding-escape / printf-format-specifier / bash-
1868 // job-control-specifier surface every peer single-token-shaped
1869 // typed slot already closes. This arm closes the gap so the
1870 // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871 // specifier / job-control-specifier / YAML-directive-lead byte
1872 // anywhere in a typed string slot that flows verbatim into a
1873 // shell-spawned subprocess or downstream URL / printf / YAML
1874 // parser" invariant extends from shell-comment / URL-fragment
1875 // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876 // `:caminho` axis.
1877 //
1878 // The arm fires AFTER the shell-comment arm because the prior
1879 // arm's `#` shape is the more semantic-locating axis on values
1880 // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881 // and `#` — the URL-fragment-identifier is the load-bearing
1882 // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883 // same cascade discipline every prior `:caminho` arm establishes).
1884 // The arm fires BEFORE the trailing-`/` arm because the embedded
1885 // percent-encoding-escape byte is the more semantic-locating axis
1886 // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887 // the load-bearing diagnostic is the embedded `%` percent-
1888 // encoding-escape — the trailing `/` is the secondary observation,
1889 // and an author who decodes the `%20` to a literal space is
1890 // likely to also tab-strip the trailing separator).
1891 for &b in caminho.as_bytes() {
1892 if b == b'%' {
1893 return Err(DepError::fonte_caminho_url_percent_encoding(
1894 nome, caminho, b,
1895 ));
1896 }
1897 }
1898 // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899 // command-substitution / arithmetic-expansion arm. The f4efe9c
1900 // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901 // through `FonteCaminhoVarExpansion` under the leading-byte-
1902 // sentinel host-layout-leak banner (peer with the b94fd83
1903 // absolute / a5c248e tilde leading-byte arms), but the arm
1904 // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905 // (embedded `$HOME` in a nested path segment — the canonical
1906 // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907 // an author copies a partially-substituted shell one-liner and
1908 // the leading segment is a literal `../foo` while the mid
1909 // segment carries the un-substituted `$HOME` template), a
1910 // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911 // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912 // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913 // (the paste-from-shell-prompt command-substitution idiom), or
1914 // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915 // idiom) silently passes every prior arm because
1916 // `Path::is_absolute` returns false on `..`, `$` is neither a
1917 // leading-byte sentinel (the f4efe9c arm fires only at position
1918 // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919 // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920 // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921 // value's last byte isn't `/`. Note that `$(...)` command-
1922 // substitution and `$((...))` arithmetic-expansion each carry
1923 // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924 // arm catches structurally at the earlier `(` position — but
1925 // an author who reaches for the sh-brace-substitution
1926 // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927 // which no prior arm covers. This arm closes the last
1928 // positional gap on the `$` byte on the `:caminho` axis so
1929 // every position — leading (`FonteCaminhoVarExpansion`) and
1930 // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931 // structurally rejected.
1932 //
1933 // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934 // ash / fish / nushell) lexes `$` as the variable-expansion /
1935 // command-substitution / arithmetic-expansion operator per
1936 // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937 // Expansion) expands a named variable, `${<name>}` (Parameter
1938 // Expansion braced form) does the same with an explicit token
1939 // boundary, `$(<cmd>)` (Command Substitution modern form,
1940 // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941 // already closes) runs a subshell and substitutes its stdout,
1942 // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943 // arithmetic expression. Every form is a host-layout /
1944 // environment-state / shell-subprocess-side-effect leak when
1945 // the byte lands in a value the resolver passes to a shell-
1946 // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947 // the Nix `${var}` string-interpolation lead (the paste-from-
1948 // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949 // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950 // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951 // variable lead (the paste-from-`Makefile` shape), the
1952 // JavaScript / TypeScript template-literal `${expr}` interp
1953 // lead (the paste-from-JS-template-string idiom in a
1954 // multi-lang-monorepo where a `path` attribute gets copied out
1955 // of a `package.json` script or a Vite config), the envsubst /
1956 // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957 // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958 // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959 // from-`.php`-config footgun), the Perl scalar-variable lead
1960 // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961 // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962 // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963 // cross-idiom paste-footgun surface is broader than any single
1964 // shell layer — `$` is a first-class parser byte in nearly
1965 // every config / templating / build-system DSL the substrate's
1966 // paste-idiom surface routinely crosses. The peer `:fonte
1967 // :repo` axis closes the byte under the shell-variable-
1968 // expansion / URL-sub-delim banner (b9d187c `$` on
1969 // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970 // axes close `$` as part of `is_git_ref_name`'s printable-
1971 // ASCII-restricted grammar (`git check-ref-format` rejects the
1972 // byte outright), and the peer `:entrada :paths` axis closes
1973 // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974 // reserved set. The `:caminho` axis was the last typed path-
1975 // string surface still admitting `$` at positions other than 0.
1976 //
1977 // POSIX `std::path::Path` treats `$` as a literal path-
1978 // component byte, so `:caminho "../foo$HOME/bar"` silently
1979 // routes through `Path::new(caminho).join(<file>)` looking for
1980 // a literal `./{caminho}` subdirectory that fails at resolve
1981 // time with a non-self-locating `No such file or directory`
1982 // error far from the source caixa.lisp. But every downstream
1983 // shell / envsubst / Nix / Make / K8s-template parser silently
1984 // reinterprets the byte to a different value than the
1985 // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986 // to a `cd '{caminho}'` command line, a `nix flake check`
1987 // invocation on an emitted YAML `path:` scalar folded through
1988 // envsubst, or a `helm template` invocation with a
1989 // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990 // template all disagree with the resolver on which directory
1991 // the value names. Two workstations whose downstream shell /
1992 // envsubst / Nix / Make / K8s-template parsing layers differ
1993 // in `$VAR` recognition (or, worse, expand the byte against
1994 // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995 // `$HOME=/home/bob`) emit divergent build artifacts for the
1996 // byte-identical caixa.lisp value. Even in the case where the
1997 // resolver strictly does NOT expand `$VAR` (the current
1998 // implementation) the divergence still bites at the lacre-
1999 // identity axis: the lacre pipeline embeds the value verbatim
2000 // in its per-dep content-address (`conteudo:
2001 // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002 // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003 // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004 // one author would have produced by substituting the literal
2005 // value at author time, defeating the THEORY.md §V.2 render-
2006 // determinism contract on the same axis every prior `:caminho`
2007 // arm protects.
2008 //
2009 // Beyond the render-determinism / host-layout-leak vectors,
2010 // `$` at any position in a value flowing verbatim into a
2011 // shell-spawned subprocess is the canonical CWE-78 shell-
2012 // command-injection surface every peer single-token-shaped
2013 // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014 // that rides into a future `feira tofu` shell-out as `cd
2015 // '../foo$(whoami)/bar'` gets substituted by the shell at
2016 // subprocess-argument-expansion time even inside single quotes
2017 // in fewer positions than one might expect (the substitution
2018 // fires only outside single-quoting per POSIX §2.2.2, but
2019 // eval-style wrappers and `sh -c` layers that route the value
2020 // through re-parsing round-trip the substitution — the same
2021 // vector the c370458 backtick arm closes at the sibling
2022 // command-substitution-legacy-form surface). Every future
2023 // `feira` verb that shells out with a `caminho`-formatted
2024 // subprocess argument silently inherits this substitution
2025 // vector unless the typed slot's accepted set structurally
2026 // excludes the byte.
2027 //
2028 // Frontier inspiration: OTP's `gen_server` return-value grammar
2029 // rejects mid-tuple shell-metachar bytes by construction —
2030 // `{noreply, State}` never carries a raw `$` because the
2031 // Erlang term type system has no notion of "string that gets
2032 // shelled out"; caixa's typed slots inherit the same
2033 // structural discipline (types-are-theorems, the compounding
2034 // mandate's leverage-point-1) by refusing values that would
2035 // silently reinterpret at any downstream layer. Peer with
2036 // Unison's content-addressed code (no ambient environment —
2037 // every reference is a hash, no `$VAR` substitution possible)
2038 // and Pony's capabilities (a path capability that carries a
2039 // `$` would be ill-typed at the reference layer).
2040 //
2041 // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042 // e3558fa `%` arm) because a value carrying both `%` and `$`
2043 // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044 // encoded space next to a `$HOME` template") surfaces the
2045 // narrower URL-encoding diagnostic first — the paste-from-
2046 // browser-address-bar shape is the load-bearing self-locating
2047 // edit on every probe-as-both value; same cascade discipline
2048 // every prior `:caminho` arm establishes (a323db8 % before
2049 // this arm, this arm before trailing-`/`). The arm fires
2050 // BEFORE the trailing-`/` arm because the embedded shell-
2051 // variable-expansion byte is the more semantic-locating axis
2052 // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053 // but the load-bearing diagnostic is the embedded `$` — the
2054 // trailing `/` is the secondary observation, and an author
2055 // who substitutes the `$HOME` template with a literal value is
2056 // likely to also tab-strip the trailing separator).
2057 for &b in caminho.as_bytes() {
2058 if b == b'$' {
2059 return Err(DepError::fonte_caminho_shell_variable_expansion(
2060 nome, caminho, b,
2061 ));
2062 }
2063 }
2064 // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065 // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066 // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067 // orthogonal POSIX shell-history-expansion sentinel every interactive
2068 // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069 // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070 // re-runs the most recent history entry beginning with `command`,
2071 // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072 // last word of the prior command, `!:N` substitutes the Nth word,
2073 // `^old^new` rewrites the prior command's `old` to `new` (the
2074 // canonical set of `set -o histexpand` operators bash's default
2075 // interactive session enables). Beyond the shell-history layer,
2076 // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077 // admits the byte inside a path segment, but every WHATWG-conformant
2078 // special-scheme URL parser percent-encodes it inside a query
2079 // component via the 'special-query percent-encode set' the peer
2080 // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081 // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082 // (logical-negation prefix — the paste-from-source-code idiom where
2083 // an author copies `!path.exists()` out of a Rust snippet and the
2084 // trailing punctuation crosses the string-literal boundary); the
2085 // canonical English-typography emphasis / exclamation mark (the
2086 // paste-from-prose enthusiasm-form idiom where an author writes
2087 // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088 // to a kebab-case slug); and the Nix flake-ref import-attribute
2089 // `import ./foo.nix { … }` sibling operator surface.
2090 //
2091 // POSIX `std::path::Path` treats `!` as a literal path-component
2092 // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093 // from-shell-history footgun where the author copies a `cd
2094 // ../caixa-teia && !sudo make install` one-liner from a quick-
2095 // start README and the trailing `!sudo` rides in verbatim as a
2096 // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097 // `!!` repeat-prior-command paste idiom), a `:caminho
2098 // "../caixa-teia!"` (the English-typography enthusiasm-form
2099 // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100 // last-word-substitution shape) silently pass every prior arm
2101 // because `Path::is_absolute` returns false on `..`, `!` is neither
2102 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105 // and the value's last byte isn't `/`. The resolver folds the value
2106 // through `Path::new(caminho).join(<file>)` looking for a literal
2107 // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108 // with a non-self-locating `No such file or directory` error far
2109 // from the source caixa.lisp — while every downstream interactive
2110 // shell with `set -o histexpand` reinterprets the byte as the
2111 // history-expansion prefix, and the failure mode forks per
2112 // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113 // line executed under `bash -i` (the operator-notebook interactive
2114 // shell) substitutes the `!sudo` reference to the most recent
2115 // history entry starting with `sudo`, silently invoking whatever
2116 // privileged command that entry named.
2117 //
2118 // The lacre pipeline embeds the value verbatim in its per-dep
2119 // content-address (`conteudo: format!("path:{caminho}")`,
2120 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121 // BLAKE3 closure and rides into every shell-spawned subprocess
2122 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123 // a future operator-side `nix flake check` spawn) as the
2124 // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125 // every peer single-token-shaped typed slot already closes. The
2126 // peer `:fonte :repo` axis closes the byte under the same shell-
2127 // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128 // `is_git_repo_url`); the `:caminho` axis was the last typed
2129 // path-string surface still admitting the byte. This arm closes
2130 // the gap so the substrate-wide "no shell-composition
2131 // metacharacter / history-expansion sentinel anywhere in a typed
2132 // string slot that flows verbatim into a shell-spawned subprocess"
2133 // invariant extends from shell-variable-expansion (`$`) to shell-
2134 // history-expansion (`!`) on the `:caminho` axis. Together with
2135 // the peer c370458 backtick command-substitution-legacy-form arm
2136 // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137 // sibling `:repo` axis, the typed `:caminho` accepted set now
2138 // structurally excludes every byte the POSIX shell §2.6 Word
2139 // Expansions section, §2.3 Token Recognition step 6, and every
2140 // history-expansion / brace-expansion / pathname-expansion /
2141 // parameter-expansion / command-substitution / arithmetic-
2142 // expansion operator lexes as a first-class parser byte.
2143 //
2144 // Frontier inspiration: Unison's content-addressed code (no
2145 // ambient environment — every reference is a hash, no `!<num>`
2146 // history-index substitution possible; the caixa substrate's
2147 // lacre discipline arrives at the same guarantee by refusing
2148 // bytes at manifest-parse time that would reinterpret against
2149 // ambient shell history state); Pony's capabilities (a path
2150 // capability that carries a `!` would be ill-typed at the
2151 // reference layer).
2152 //
2153 // The arm fires AFTER the shell-variable-expansion arm because a
2154 // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155 // canonical "I pasted a `$HOME`-templated path adjacent to a
2156 // trailing `!sudo` history-expansion") surfaces the narrower
2157 // shell-variable-expansion diagnostic first — the paste-from-CI-
2158 // manifest-with-`$VAR`-template shape is the load-bearing self-
2159 // locating edit on every probe-as-both value; same cascade
2160 // discipline every prior `:caminho` arm establishes. The arm
2161 // fires BEFORE the trailing-`/` arm because the embedded shell-
2162 // history-expansion byte is the more semantic-locating axis on
2163 // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164 // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165 // is the secondary observation, and an author who removes the
2166 // `!sudo` history reference is likely to also tab-strip the
2167 // trailing separator).
2168 for &b in caminho.as_bytes() {
2169 if b == b'!' {
2170 return Err(DepError::fonte_caminho_shell_history_expansion(
2171 nome, caminho, b,
2172 ));
2173 }
2174 }
2175 // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176 // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177 // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178 // (`0x5E`) is the paired-operator half of the same bash-reference
2179 // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180 // form (POSIX bash rewrites the prior command's `old` string to
2181 // `new` and re-executes it, the canonical typo-correction one-
2182 // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183 // trailing substitution fragment verbatim into a `:caminho` value
2184 // when the author trims only the leading `git clone` prefix). The
2185 // peer `:fonte :repo` axis closes the byte under the same
2186 // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187 // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188 // path-string surface still admitting the byte after 6a04767
2189 // landed the `!` arm.
2190 //
2191 // Beyond bash history-substitution, `^` carries five distinct
2192 // downstream-reinterpretation surfaces the typed slot's accepted
2193 // set must structurally exclude:
2194 //
2195 // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196 // layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197 // required to percent-encode-or-refuse at the wire boundary.
2198 // The WHATWG URL spec's 'fragment percent-encode set' maps
2199 // `^` → `%5E` at the query / fragment component transition;
2200 // libcurl silently percent-encodes the byte on the wire, so a
2201 // `:caminho "../foo^bar"` value the resolver's `Path::join`
2202 // sees as a literal `./../foo^bar` subdirectory diverges from
2203 // the byte-transformed `%5E` shape any downstream `feira tofu`
2204 // curl-invocation or artifact-registry-fetch would emit — the
2205 // canonical wire-boundary divergence vector the peer
2206 // `{`, `}`, `|`, `\` `:caminho` arms already close (
2207 // `FonteCaminhoShellBraceExpansion` at 598b770,
2208 // `FonteCaminhoShellPipe` at the pipe arm,
2209 // `FonteCaminhoBackslash` at the backslash arm).
2210 // 2. **Regex character-class negation prefix `[^abc]`** — the
2211 // canonical paste-from-doc-regex-pipeline footgun where an
2212 // author copies a `grep '[^abc]'` idiom from a docs quick-
2213 // listing and the character-class negation byte rides in
2214 // verbatim.
2215 // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216 // JavaScript / Nix / Go — the paste-from-source-code idiom
2217 // where an author copies an `x ^ y`-shaped expression out of
2218 // a source snippet and the operator crosses the string-
2219 // literal boundary.
2220 // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221 // escapes the next character in a `cmd.exe` batch context (a
2222 // peer of the backslash arm's Windows-separator-leak vector).
2223 // A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224 // file footgun reinterprets at every `cmd.exe`-spawned
2225 // subprocess (the resolver's future Windows-runner shell-out,
2226 // the operator's WinRM path, a future PowerShell-embedded
2227 // invocation).
2228 // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229 // paste-from-typeset-doc footgun where a mathematical
2230 // superscript notation (`x^2` / `M^T`) leaks from prose.
2231 //
2232 // POSIX `std::path::Path` treats `^` as a literal path-component
2233 // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234 // substitution), `:caminho "../foo^"` (trailing history-
2235 // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236 // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237 // arm at 986963b fires first on this shape), or `:caminho
2238 // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239 // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240 // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241 // / `"` / `#` / `%` / `$` / `!`) and route through
2242 // `Path::new(caminho).join(<file>)` looking for a literal
2243 // `./{caminho}` subdirectory that fails at resolve time with a
2244 // non-self-locating `No such file or directory` error far from
2245 // the source caixa.lisp — while every downstream shell / curl /
2246 // regex / `cmd.exe` layer reinterprets the byte to its own
2247 // semantic.
2248 //
2249 // The lacre pipeline embeds the value verbatim in its per-dep
2250 // content-address (`conteudo: format!("path:{caminho}")`,
2251 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252 // BLAKE3 closure and rides into every shell-spawned subprocess
2253 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254 // a future operator-side `nix flake check` spawn) as the
2255 // canonical shell-history-substitution / RFC-3986-unwise /
2256 // regex-negation surface every peer single-token-shaped typed
2257 // slot already closes. This arm together with the immediate-
2258 // predecessor `!` arm (6a04767) closes the full `set -o
2259 // histexpand` operator surface on the `:caminho` axis — the
2260 // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261 // quick-substitution form via `^` — so the substrate-wide "no
2262 // shell-history operator anywhere in a typed string slot that
2263 // flows verbatim into a shell-spawned subprocess" invariant
2264 // extends from the `!` prefix half to the `^` quick-substitution
2265 // half. Every peer bash-history operator now fails at manifest-
2266 // parse time with a self-locating diagnostic naming the offending
2267 // caixa.lisp rather than at resolve-time as a `Path::join`-
2268 // derived `No such file or directory` (harmless but non-self-
2269 // locating) or worse riding into a downstream `bash -i` context
2270 // that reinterprets the byte-pair against ambient history state.
2271 //
2272 // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273 // "Quick substitution. Repeat the previous command, replacing
2274 // string1 with string2." + RFC 3986 §2 'unwise' set
2275 // ("characters that gateways and other transport agents are
2276 // known to sometimes modify") + Pony's capabilities (a path
2277 // capability that carries a `^` would be ill-typed at the
2278 // reference layer, matching the same structural discipline the
2279 // sibling `!` history-expansion arm inherits from Unison's
2280 // content-addressed no-ambient-history discipline).
2281 //
2282 // The arm fires AFTER the shell-history-expansion `!` arm because
2283 // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284 // the canonical "I pasted a `!sudo` history-reference next to a
2285 // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286 // form `!` diagnostic first — the `!` form is the load-bearing
2287 // self-locating edit on every probe-as-both value (an author who
2288 // removes the `!sudo` reference is likely to also strip the
2289 // paired `^` substitution fragment); same cascade discipline
2290 // every prior `:caminho` arm establishes. The arm fires BEFORE
2291 // the trailing-`/` arm because the embedded shell-history-
2292 // substitution byte is the more semantic-locating axis on
2293 // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294 // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295 // is the secondary observation, and an author who removes the
2296 // `^bar` substitution fragment is likely to also tab-strip the
2297 // trailing separator).
2298 for &b in caminho.as_bytes() {
2299 if b == b'^' {
2300 return Err(DepError::fonte_caminho_shell_history_substitution(
2301 nome, caminho, b,
2302 ));
2303 }
2304 }
2305 // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306 // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307 // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308 // backslash arm closes the cross-host-OS-separator vector. The
2309 // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310 // footgun — `Path::join("../caixa-teia")` and
2311 // `Path::join("../caixa-teia/")` resolve to the same directory
2312 // (POSIX path-component-walk treats trailing `/` as a no-op for
2313 // directory targets, which `:caminho` always names — the sibling-
2314 // workspace dep root is structurally a directory). The lacre
2315 // pipeline embeds the value verbatim in its per-dep content-address
2316 // (`conteudo: format!("path:{caminho}")`,
2317 // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318 // semantic-meaning yields two distinct BLAKE3 closures depending on
2319 // whether the author shell-tab-completed the path (every interactive
2320 // shell appends `/` on tab-completing a directory, idiomatic in
2321 // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322 // shells emits without trailing `/`, but `realpath -e -m` on a
2323 // directory with trailing `/` preserves it), or copied a Cargo
2324 // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325 // (Cargo accepts both shapes and folds them the same way). Two
2326 // workstations whose authors differ only in tab-completion habits
2327 // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328 // and the substrate's "the lacre is the build's identity" contract
2329 // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330 //
2331 // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332 // arm protects, here against the trailing-separator divergence
2333 // vector: every typed slot's accepted set excludes byte-divergent
2334 // values that round-trip to the same downstream semantic. The peer
2335 // path-shaped axes already reject trailing separators on the same
2336 // contract: [`crate::render::is_gateway_api_http_path`] gates
2337 // `:entrada :paths` against any non-canonical normalization, and
2338 // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339 // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340 // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341 // whose canonical form would re-introduce determinism divergence.
2342 //
2343 // The arm fires last in the cascade because every prior arm carries
2344 // a more self-locating diagnostic on values that probe as both
2345 // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346 // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347 // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348 // the load-bearing diagnostic is the absolute host-layout-leak —
2349 // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350 // but the load-bearing diagnostic is the Windows-separator cross-
2351 // OS divergence — the backslash arm wins). The arm covers every
2352 // shape where the last byte is `/` regardless of length, including
2353 // the degenerate single-`/` (which the absolute arm catches first)
2354 // and the consecutive-`//` (where every prior arm passes on the
2355 // bytes other than the trailing `/`).
2356 if caminho.as_bytes().last() == Some(&b'/') {
2357 return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358 }
2359 Ok(())
2360 }
2361}
2362
2363impl Dep {
2364 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365 /// accessor every consumer of the dep-graph identity axis keys off —
2366 /// returns the author-declared `:nome` byte-string verbatim as a
2367 /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368 ///
2369 /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370 /// label that names the target caixa (validated by [`Self::validate`]
2371 /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372 /// same accept-set the peer caixa-identifier axes carry — top-level
2373 /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374 /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375 /// downstream consumer that fans on the dep's name-identity keys off
2376 /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377 /// [`crate::render::insert_first_seen`] dedup key + the paired
2378 /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379 /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380 /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381 /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382 /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383 /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384 /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385 /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386 /// every `caixa-resolver` `ResolveError::MissingPath` /
2387 /// `ResolveError::MissingPin` carrier that names the offending dep
2388 /// (`resolve.rs:177,206`), each resolved
2389 /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390 /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391 /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392 ///
2393 /// Prior to this lift the `.nome` byte-string was read inline at every
2394 /// production site — the [`crate::Caixa::validate_deps`] paired
2395 /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396 /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397 /// parent-equality checks, and every caixa-resolver / caixa-feira
2398 /// site enumerated above — open-coded field-accesses that expressed
2399 /// no compile-time link back to the typed slot. A future extension of
2400 /// the `:deps :nome` axis to a richer author surface (a per-scope
2401 /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402 /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403 /// namespace-qualified rewrite the future M4 lacre-federation layer
2404 /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405 /// to a richer scoped-identifier newtype once cross-registry federation
2406 /// lands) would have had to be threaded through every open-coded copy
2407 /// in lockstep or two consumers would silently disagree on which caixa
2408 /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409 /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410 /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411 /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412 /// requeue-suppression seen-set, one build-time diagnostic
2413 /// disagreeing with the run-time closure the substrate's lacre
2414 /// pipeline actually materializes. Lifting the resolution rule to a
2415 /// typed method on the substrate primitive means every downstream
2416 /// consumer of the caixa's per-`:deps` identity surface reaches for
2417 /// exactly one typed dispatch — the resolver's accept-set migrates as
2418 /// a unit on any future axis addition.
2419 ///
2420 /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421 /// `&str`-return required-scalar projection pattern the sibling
2422 /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423 /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424 /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425 /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426 /// accessors — same "one typed dispatch on the substrate primitive,
2427 /// thin projections at each consumer" discipline extended onto the
2428 /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429 /// remaining unlifted caixa-name-referencing accessor family in the
2430 /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431 /// term the field's docstring already reaches for ("Caixa name — must
2432 /// match the target caixa's `:nome`") and the peer caixa-identity
2433 /// accessor family the substrate already carries.
2434 #[must_use]
2435 pub const fn nome(&self) -> &str {
2436 self.nome.as_str()
2437 }
2438
2439 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440 /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441 /// the dep-graph version-pin axis keys off — returns the author-
2442 /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443 /// borrowed from the typed slot's own [`String`] storage.
2444 ///
2445 /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446 /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447 /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448 /// entry-point consumes — same accept-set the peer requirement-
2449 /// carrying axes carry (per-`:membros`
2450 /// [`crate::Membro::versao_requirement`], per-`:children`
2451 /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452 /// through the shared
2453 /// [`crate::render::require_valid_versao_requirement`] cascade in
2454 /// [`Self::validate`]. Every downstream consumer that fans on the
2455 /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456 /// `require_valid_versao_requirement` gate + the paired
2457 /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458 /// requirement-shape rejection, the `feira lock` stub-resolver's
2459 /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460 /// `conteudo` hash-input interpolation and the paired
2461 /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462 /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463 ///
2464 /// Prior to this lift the `.versao` byte-string was read inline at
2465 /// every production site — the [`Self::validate`] paired
2466 /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467 /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468 /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469 /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470 /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471 /// same shapes — open-coded field-accesses that expressed no
2472 /// compile-time link back to the typed slot. A future extension of
2473 /// the `:deps :versao` axis to a richer author surface (a per-scope
2474 /// version-lock overlay the resolver folds through the
2475 /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476 /// docstring already acknowledges, a per-cluster canary-version
2477 /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478 /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479 /// once cross-registry federation lands) would have had to be
2480 /// threaded through every open-coded copy in lockstep or two
2481 /// consumers would silently disagree on which release constraint a
2482 /// given dep resolves to — the [`Self::validate`] requirement-gate
2483 /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484 /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485 /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486 /// content-addressed hash the substrate's fetch pipeline actually
2487 /// materializes, one build-time diagnostic disagreeing with the
2488 /// run-time closure. Lifting the resolution rule to a typed method
2489 /// on the substrate primitive means every downstream consumer of
2490 /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491 /// one typed dispatch — the resolver's accept-set migrates as a
2492 /// unit on any future axis addition.
2493 ///
2494 /// Second accessor on the outer `Dep` type — folds on the outer-
2495 /// `Dep` `&str`-return required-scalar projection pattern the
2496 /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497 /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498 /// (a40b0e3) / per-`:children`
2499 /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500 /// family) member/child version-pin accessors — the three
2501 /// requirement-carrying axes (`Dep::versao_requirement` on the
2502 /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503 /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504 /// Supervisor side) now share one accessor discipline for the
2505 /// shared substrate concept "another caixa referenced by a
2506 /// Cargo-shaped semver requirement". The pair
2507 /// `(nome(), versao_requirement())` jointly projects the
2508 /// `(nome, versao)` field pair every dep-graph consumer that fans
2509 /// on per-dep identity + version pin keys off. Named
2510 /// `versao_requirement()` rather than `versao()` because the field's
2511 /// storage-side `.versao` label is already the author-surface term
2512 /// (`:versao`); the accessor's name carries the semantic role — the
2513 /// semver *requirement* string the shared
2514 /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515 /// raw field access and a typed dispatch read differently at every
2516 /// consumer site. Matches the peer
2517 /// [`crate::Membro::versao_requirement`] /
2518 /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519 /// discipline verbatim.
2520 #[must_use]
2521 pub const fn versao_requirement(&self) -> &str {
2522 self.versao.as_str()
2523 }
2524
2525 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526 /// Zig-store-model per-dep source-tuple optional-composite-reference
2527 /// accessor every consumer of the dep-graph fetch-source axis keys
2528 /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529 /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530 /// own `Option<DepSource>` storage, with `None` naming the "author
2531 /// omitted `:fonte`" shorthand every resolver-side default-fill
2532 /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533 /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534 /// the [`Dep::fonte`] field docstring already documents) treats as
2535 /// the "resolve through the configured default host / org
2536 /// (`github:<default-org>/<nome>`)" partition.
2537 ///
2538 /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539 /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540 /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541 /// rev, branch }` for the git-clone arm every published caixa
2542 /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543 /// local-filesystem arm every unpublishable in-tree checkout
2544 /// resolves through. Every downstream consumer that fans on the
2545 /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546 /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547 /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548 /// diagnostics through the [`DepError::Fonte*`] carrier family
2549 /// naming the offending `Dep::nome`), the caixa-crd conversion
2550 /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551 /// `{repo, git_ref}` pair the K8s-CR side consumes
2552 /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553 /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554 /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555 /// concrete `DepSource` at run time.
2556 ///
2557 /// Prior to this lift the `.fonte` typed slot was read inline at
2558 /// every production site — the [`Self::validate`]
2559 /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560 /// gate delegates through, the caixa-crd `dep_into_ref`
2561 /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562 /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563 /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564 /// coded field-accesses that expressed no compile-time link back to
2565 /// the typed slot. A future extension of the `:deps :fonte` axis
2566 /// to a richer author surface (a per-scope source-override table
2567 /// the resolver folds through the `~/.config/caixa/config.yaml`
2568 /// entry the [`Dep`] docstring already acknowledges, a per-org
2569 /// mirror-fallback list the future M4 lacre-federation resolver
2570 /// consults ahead of the `default_github` fallback, a promotion of
2571 /// the plain `Option<DepSource>` to a richer
2572 /// `{primary, mirrors, integrity}` triple once cross-registry
2573 /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574 /// M4 lacre gate binds against ahead of the git-fetch) would have
2575 /// had to be threaded through every open-coded copy in lockstep or
2576 /// two consumers would silently disagree on which fetch source a
2577 /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578 /// gate reading the author-declared source while the caixa-crd
2579 /// projector read a per-scope-override-resolved source would
2580 /// silently split the build-time refusal from the CR the
2581 /// substrate's admission pipeline actually materializes, one
2582 /// build-time diagnostic disagreeing with the run-time closure.
2583 /// Lifting the resolution rule to a typed method on the substrate
2584 /// primitive means every downstream consumer of the caixa's per-
2585 /// `:deps` fetch-source surface reaches for exactly one typed
2586 /// dispatch — the resolver's accept-set migrates as a unit on any
2587 /// future axis addition.
2588 ///
2589 /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590 /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591 /// reference projection pattern the sibling per-`Dep` `:opcional`
2592 /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593 /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594 /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595 /// `Option<&Composite>` composite-reference sub-family the
2596 /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597 /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598 /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599 /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600 /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601 /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602 /// accessor already carries — extends that "one typed dispatch on
2603 /// the substrate primitive, thin projections at each consumer"
2604 /// discipline onto the third outer typed-slot altitude that carries
2605 /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606 /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607 /// copy or clone) because every downstream consumer of the fonte
2608 /// composite treats it as a read-only per-arm dispatch source — the
2609 /// reference-view is the narrowest borrow that supports every
2610 /// present + roadmapped consumer (per-arm match projection at the
2611 /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612 /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613 /// `default_github` fill applies" partition every resolver
2614 /// consults, `.cloned()`-on-demand for the two resolver-side
2615 /// default-fill call sites that require an owned `DepSource` for
2616 /// `Option::unwrap_or_else`) without cloning the composite through
2617 /// every consumer's fast path. The `Option` half of the return-type
2618 /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619 /// side default applies" partition (not a default composite the
2620 /// downstream must reject on emptiness) — the accessor projects the
2621 /// raw `Option<DepSource>` slot's presence bit through the
2622 /// reference-return unchanged. Named `fonte()` to match the storage
2623 /// field's name verbatim and the tatara-lisp author-surface term
2624 /// (`:fonte`) the field's own docstring already carries.
2625 ///
2626 /// Declared `pub const fn` — the body projects through
2627 /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628 /// well within the workspace MSRV, so every downstream `const`-
2629 /// context consumer of the per-`Dep` `:fonte` composite-reference
2630 /// accessor reaches through the same typed dispatch on the
2631 /// substrate primitive at const-eval time as at runtime. The
2632 /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633 /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634 /// that forwards through each lifted accessor) locks the posture
2635 /// load-bearing at caixa-core build time — any future accidental
2636 /// downgrade to non-`const` fails the wrapper with E0015
2637 /// (`cannot call non-const method`), strictly stronger than a
2638 /// runtime `assert!` and side-stepping the destructor-in-const
2639 /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640 /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641 /// `WitContract` pre-projection accessor family's `const`-eval-
2642 /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643 /// accessor family's parallel pass (231a968) — same "one canonical
2644 /// dispatch per axis, `const`-eval posture pinned at the substrate
2645 /// primitive, thin projections at each consumer" discipline
2646 /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647 ///
2648 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649 #[must_use]
2650 pub const fn fonte(&self) -> Option<&DepSource> {
2651 self.fonte.as_ref()
2652 }
2653
2654 /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655 /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656 /// every consumer of the dep-graph feature-flag axis keys off —
2657 /// returns the author-declared `:caracteristicas` feature-name list
2658 /// verbatim as a `&[String]` slice-view over the same backing buffer
2659 /// the raw `self.caracteristicas.as_slice()` field access borrows
2660 /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661 /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662 /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663 /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664 /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665 /// — possibly empty — and the returned `&[String]` degenerates to
2666 /// an empty slice on that arm without any silent `None` collapse).
2667 ///
2668 /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669 /// carries the set-shaped feature-toggle list the substrate walks
2670 /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671 /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672 /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673 /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674 /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675 /// walk, empty-first / value-shape-second / duplicate-third
2676 /// precedence via the peer per-axis two-arm cascade discipline every
2677 /// substrate-blessed Vec-keyed-by-name slot already follows).
2678 /// Every downstream consumer that fans on the dep's feature-toggle
2679 /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680 /// per-entry linear walk that gates each feature-name byte-string
2681 /// through the empty / value-shape / duplicate arms (raising the
2682 /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683 /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684 /// offending `Dep::nome`), and every future
2685 /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686 /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687 /// future caixa-resolver per-dep feature-projection walk that folds
2688 /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689 /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690 /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691 /// features slice the K8s-CR admission gate consumes, the future
2692 /// per-cluster feature-overlay the M4 lacre-federation resolver
2693 /// composes ahead of the substrate-wide feature-name accept-set).
2694 ///
2695 /// Prior to this lift the `.caracteristicas` byte-string list was
2696 /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697 /// &self.caracteristicas` walk — the only in-crate consumer of the
2698 /// raw field beyond the per-`Dep` constructor pair
2699 /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700 /// round-trip / per-test fixture-mutation paths — an open-coded
2701 /// field-access that expressed no compile-time link back to the
2702 /// typed slot. A future extension of the `:caracteristicas` axis to
2703 /// a richer author surface (a per-scope feature-overlay the resolver
2704 /// folds through the `~/.config/caixa/config.yaml` entry the
2705 /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706 /// activation overlay the future M4 lacre-federation layer applies
2707 /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708 /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709 /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710 /// docstring anticipates lands) would have had to be threaded
2711 /// through every open-coded copy in lockstep or two consumers
2712 /// would silently disagree on which feature closure a given dep
2713 /// activates — the [`Self::validate_caracteristicas`] gate walking
2714 /// the author-declared list while a downstream caixa-resolver
2715 /// consumer walked a per-scope-override-resolved list would
2716 /// silently split the build-time refusal from the lacre closure
2717 /// the substrate's fetch pipeline actually materializes, one
2718 /// build-time diagnostic disagreeing with the run-time closure.
2719 /// Lifting the resolution rule to a typed method on the substrate
2720 /// primitive means every downstream consumer of the caixa's per-
2721 /// `:deps` feature-toggle surface reaches for exactly one typed
2722 /// dispatch — the resolver's accept-set migrates as a unit on any
2723 /// future axis addition.
2724 ///
2725 /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726 /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727 /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728 /// future outer scalar lift folds on and closes the outer-`Dep`
2729 /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731 /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732 /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733 /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734 /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735 /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736 /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737 /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738 /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739 /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740 /// altitude — extends the "one typed dispatch on the substrate
2741 /// primitive, thin projections at each consumer" discipline onto the
2742 /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743 /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744 /// because every downstream consumer of the feature-toggle list
2745 /// treats it as a read-only sequence — the slice-view is the
2746 /// narrowest borrow that supports every present + roadmapped
2747 /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748 /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749 /// the typed view reaches for (the storage-side `Vec` remains
2750 /// reachable through the `pub caracteristicas` field for the
2751 /// mutation-carrying serde round-trip and per-test fixture-mutation
2752 /// paths). Named `caracteristicas()` to match the storage field's
2753 /// name verbatim and the tatara-lisp author-surface term
2754 /// (`:caracteristicas`) the field's own docstring already carries.
2755 ///
2756 /// Declared `pub const fn` — the body projects through
2757 /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758 /// well within the workspace MSRV, so every downstream `const`-
2759 /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760 /// accessor reaches through the same typed dispatch on the
2761 /// substrate primitive at const-eval time as at runtime. Pinned
2762 /// load-bearing by the paired
2763 /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764 /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765 /// the full pin-shape rationale.
2766 ///
2767 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768 #[must_use]
2769 pub const fn caracteristicas(&self) -> &[String] {
2770 self.caracteristicas.as_slice()
2771 }
2772
2773 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774 /// missing-source-tolerance flag scalar accessor every consumer of
2775 /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776 /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777 /// typed slot's own `bool` storage (no borrow of `&self` past the
2778 /// call; the `Copy`-return arm matches the peer
2779 /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780 /// projected sibling discipline the outer flat-spread family
2781 /// already carries). Default-`false` (`#[serde(default,
2782 /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783 /// `Dep` past parse definitionally carries a `bool` — `false` when
2784 /// the author omits `:opcional` — and the returned value degenerates
2785 /// to `false` on that arm without any silent `None` collapse).
2786 ///
2787 /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788 /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789 /// missing-source arm as a soft-fail rather than a build refusal"
2790 /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791 /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792 /// dropped from the resolved dep-graph rather than tripping the
2793 /// build-refusal edge that a mandatory `:opcional false` entry
2794 /// would). Every downstream consumer that fans on the dep's
2795 /// missing-source-tolerance keys off this accessor: the future
2796 /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797 /// dispatch on the opcional bit ahead of the lacre closure
2798 /// materialization), the future caixa-crd per-`spec.deps`
2799 /// `optional` boolean the K8s-CR admission gate consumes on the
2800 /// per-dep partition, and the future feira / caixa-resolver /
2801 /// caixa-crd feature-projection walk that folds the opcional bit
2802 /// into the resolved feature-closure the future M4 lacre-federation
2803 /// layer emits.
2804 ///
2805 /// Prior to this lift the `.opcional` `bool` slot was read inline
2806 /// at the sole in-crate consumer site — the tests-module
2807 /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808 /// pinning the [`Self::simple`] constructor's default-`false` fill
2809 /// (the only in-crate read of the raw field beyond the per-`Dep`
2810 /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811 /// serde round-trip / per-test fixture-mutation paths) — an open-
2812 /// coded field-access that expressed no compile-time link back to
2813 /// the typed slot. A future extension of the `:opcional` axis to a
2814 /// richer author surface (a per-scope opcional-override the resolver
2815 /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816 /// docstring already acknowledges, a per-cluster opcional-override
2817 /// the future M4 lacre-federation layer applies per-CR, a promotion
2818 /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819 /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820 /// roadmap lands) would have had to be threaded through every open-
2821 /// coded copy in lockstep or two consumers would silently disagree
2822 /// on which missing-source arm a given dep resolves to — the
2823 /// [`Self::simple`] constructor's default-`false` fill reading
2824 /// verbatim while a downstream caixa-resolver consumer read a per-
2825 /// scope-override-resolved bit would silently split the build-time
2826 /// arm from the lacre closure the substrate's fetch pipeline
2827 /// actually materializes, one build-time diagnostic disagreeing
2828 /// with the run-time closure. Lifting the resolution rule to a
2829 /// typed method on the substrate primitive means every downstream
2830 /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831 /// reaches for exactly one typed dispatch — the resolver's accept-
2832 /// set migrates as a unit on any future axis addition.
2833 ///
2834 /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835 /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837 /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838 /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839 /// `:caracteristicas`) now routes through exactly one typed
2840 /// dispatch on the substrate primitive. First outer-`Dep`
2841 /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842 /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843 /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844 /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845 /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846 /// already carries — extends the "one typed dispatch on the
2847 /// substrate primitive, thin projections at each consumer"
2848 /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849 /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850 /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851 /// every downstream consumer treats it as a plain discriminant
2852 /// value — the by-value return is the narrowest return-shape that
2853 /// supports every present + roadmapped consumer (`.then(…)` early
2854 /// return on the resolver-side drop-vs-error partition, direct
2855 /// bool composition with a per-scope-override projector, plain
2856 /// `if dep.opcional() { … }` early return at every future admission
2857 /// gate) without leaking the storage field's `bool`-in-`&self`
2858 /// lifetime the by-value return elides. Marked `pub const fn` so
2859 /// the accessor is `const`-callable — same discipline the peer
2860 /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861 /// accessor carries. Named `opcional()` to match the storage
2862 /// field's name verbatim and the tatara-lisp author-surface term
2863 /// (`:opcional`) the field's own docstring already carries.
2864 #[must_use]
2865 pub const fn opcional(&self) -> bool {
2866 self.opcional
2867 }
2868
2869 /// Build a minimal registry-sourced dep.
2870 #[must_use]
2871 pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872 Self {
2873 nome: nome.into(),
2874 versao: versao.into(),
2875 fonte: None,
2876 opcional: false,
2877 caracteristicas: Vec::new(),
2878 }
2879 }
2880
2881 /// Build a Git-sourced dep (tag-based).
2882 #[must_use]
2883 pub fn git(
2884 nome: impl Into<String>,
2885 versao: impl Into<String>,
2886 repo: impl Into<String>,
2887 tag: impl Into<String>,
2888 ) -> Self {
2889 Self {
2890 nome: nome.into(),
2891 versao: versao.into(),
2892 fonte: Some(DepSource::Git {
2893 repo: repo.into(),
2894 tag: Some(tag.into()),
2895 rev: None,
2896 branch: None,
2897 }),
2898 opcional: false,
2899 caracteristicas: Vec::new(),
2900 }
2901 }
2902
2903 /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904 /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905 /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906 /// semver requirement.
2907 ///
2908 /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909 /// is the same Cargo-shaped requirement string `:membros :versao`
2910 /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911 /// and `:children :versao` (validated at
2912 /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913 /// the lacre pipeline resolves all three axes through the same
2914 /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915 /// `:deps :versao` was the last `:versao` axis untyped past
2916 /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917 /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918 /// leaking-into-:versao `"v0.1"` typo, the accidental
2919 /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920 /// surfaced at lacre-resolve time, far from the source
2921 /// caixa.lisp, with no field naming which `:deps` entry carried
2922 /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923 /// the offending entry's `:nome` + the offending `:versao`
2924 /// verbatim + the parser's own wording in `reason`, so the
2925 /// author's grep target is unambiguous.
2926 ///
2927 /// The author surface for `:deps :nome` is the same DNS-1123 label
2928 /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929 /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930 /// `:membros :caixa` (validated at
2931 /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932 /// `:children :caixa` (validated at
2933 /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934 /// :nome` value flows verbatim through the lacre pipeline as the
2935 /// target caixa's `:nome` (which the gate at the *target* side now
2936 /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937 /// `lareira-<nome>` Helm chart name segment, the per-dep
2938 /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939 /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940 /// this gate landed `:deps :nome` was the fourth and last
2941 /// DNS-1123-shaped caixa-identifier axis still untyped past
2942 /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943 /// Teia"` uppercase — the canonical "I copied the README header"
2944 /// typo; `"caixa_teia"` underscore — the Go module / Python
2945 /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946 /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947 /// silently passed parse and surfaced at lacre-resolve time when
2948 /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949 /// — far from the source `:deps` entry, with a diagnostic naming
2950 /// the *target's* `:nome` rather than the dep entry that referenced
2951 /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952 /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953 /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954 /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955 /// so every downstream consumer (caixa-resolver's lacre fetch,
2956 /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957 /// fan-out emitter) reaches for the name knowing the value is
2958 /// apiserver-valid without re-validating.
2959 ///
2960 /// Empty checks fire first (narrower diagnostic), parse last —
2961 /// same ordering discipline as
2962 /// [`crate::AplicacaoSpec::validate_membros`] and
2963 /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964 /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965 /// structurally necessary even with the parse arm in place. The
2966 /// `:nome` shape gate runs after the `:nome` empty gate and before
2967 /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968 /// sees the name-side diagnostic first (the name is the
2969 /// self-locating axis — without it, the parse diagnostic can't
2970 /// quote `:nome "<bad>"`).
2971 pub fn validate(&self) -> Result<(), DepError> {
2972 if self.nome.is_empty() {
2973 return Err(DepError::NomeEmpty);
2974 }
2975 if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976 return Err(DepError::nome_invalid(&self.nome, reason));
2977 }
2978 // Delegate the empty-first + `parse_requirement` cascade to the
2979 // shared [`crate::render::require_valid_versao_requirement`]
2980 // helper — same two-arm shape the peer
2981 // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982 // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983 // :versao` route through, so drift between the three axes'
2984 // accepted requirement sets is structurally impossible and the
2985 // parse-side no-op the empty-first arm closes (semver's empty
2986 // parse yields an implicit `*`) lives in exactly one predicate.
2987 crate::render::require_valid_versao_requirement(
2988 self.versao_requirement(),
2989 || DepError::versao_empty(&self.nome),
2990 |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991 )?;
2992 if let Some(fonte) = self.fonte() {
2993 fonte.validate(&self.nome)?;
2994 }
2995 self.validate_caracteristicas()?;
2996 Ok(())
2997 }
2998
2999 /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000 /// are operationally meaningless. The `:caracteristicas` slot is
3001 /// a set of feature toggles to enable on the target caixa — same
3002 /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003 /// two structural footguns close here:
3004 ///
3005 /// - empty-string entry (`(:caracteristicas (""))`): the future
3006 /// caixa-resolver lacre pipeline would consume the empty
3007 /// identifier as a no-op feature enable, silently dropping the
3008 /// author's intent far from the source `caixa.lisp`;
3009 /// - duplicate entry within one dep (`(:caracteristicas ("http"
3010 /// "http"))`): the feature-toggle slot is set-shaped (enabling
3011 /// a feature twice has no additional semantic — there is no
3012 /// `feature × 2`), so two entries naming the same feature are
3013 /// a silent miscount, the same set-not-multiset distinction
3014 /// every peer Vec-keyed-by-name axis already closes
3015 /// ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016 /// `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017 /// on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018 /// on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019 /// on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020 /// on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021 /// on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022 /// / [`crate::UpgradeError::DuplicateStateChange`] /
3023 /// [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024 /// entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025 /// on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026 /// immediate-predecessor 359fba5 closed).
3027 ///
3028 /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029 /// every peer set-not-multiset gate uses; the empty arm fires
3030 /// before the duplicate arm so an entry with both an empty feature
3031 /// *and* a duplicate of some later feature surfaces the empty-
3032 /// shape diagnostic first (the empty-feature axis is the
3033 /// more-actionable defect since the missing-name renders the
3034 /// duplicate-key arm ambiguous: two `""` entries would both report
3035 /// `caracteristica: ""` with no way to distinguish the offending
3036 /// site). Empty-first cascade discipline mirrors every peer per-
3037 /// entry shape + duplicate gate
3038 /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039 /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040 /// before `MembroDuplicate`).
3041 ///
3042 /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043 /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044 /// fires between the empty arm and the duplicate arm — the
3045 /// canonical per-entry-shape-before-cross-entry-uniqueness
3046 /// precedence every peer two-arm + value-shape gate establishes
3047 /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048 /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049 /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050 /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051 /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052 /// Until the value-shape arm landed `:caracteristicas` accepted
3053 /// every non-empty distinct string — a structurally invalid
3054 /// feature name (`"http feature"` whitespace, `"+http"` the
3055 /// canonical paste-from-`+optional-feature` doc activation-form
3056 /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057 /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058 /// only applies inside list-grammar contexts, `"http,json"`
3059 /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060 /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061 /// inconsistently across NFC/NFD normalization, the 65-byte
3062 /// paste-from-binary slug) silently passed validate and the
3063 /// failure surfaced at `cargo metadata` time as the
3064 /// `restricted_names::validate_feature_name` parser's rejection,
3065 /// far from the source `caixa.lisp`, with no field naming which
3066 /// `:deps` entry's `:caracteristicas` carried the typo. The
3067 /// lifted predicate makes the Cargo-feature-name-grammar
3068 /// intersection-floor a substrate-level invariant at validate
3069 /// time — same trajectory as the eight peer
3070 /// [`crate::render`] value-shape predicates each typed surface
3071 /// downstream of a structured grammar already follows
3072 /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073 /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074 /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075 /// [`is_nats_subject`](crate::render::is_nats_subject),
3076 /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077 /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078 /// [`is_git_oid`](crate::render::is_git_oid),
3079 /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080 fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081 let mut seen = std::collections::HashSet::new();
3082 for c in self.caracteristicas() {
3083 if c.is_empty() {
3084 return Err(DepError::caracteristica_empty(&self.nome));
3085 }
3086 if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087 return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088 }
3089 crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090 DepError::caracteristica_duplicate(&self.nome, c)
3091 })?;
3092 }
3093 Ok(())
3094 }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140 deps: &[Dep],
3141 deps_dev: &[Dep],
3142 parent_nome: &str,
3143) -> Result<(), DepError> {
3144 for dep in deps {
3145 if dep.nome() == parent_nome {
3146 return Err(DepError::dep_is_self(
3147 parent_nome,
3148 crate::render::DEP_AUTHOR_KEY_DEPS,
3149 ));
3150 }
3151 }
3152 for dep in deps_dev {
3153 if dep.nome() == parent_nome {
3154 return Err(DepError::dep_is_self(
3155 parent_nome,
3156 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157 ));
3158 }
3159 }
3160 Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202 /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203 /// lacre closure resolves at every build. Wire-format
3204 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205 Prod,
3206 /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207 /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208 /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209 Dev,
3210}
3211
3212impl DepList {
3213 /// Exhaustive iteration surface for every consumer that reads the
3214 /// full closed-set (the future M4 admission webhook's per-list
3215 /// summary rejection body, any future round-trip pin harness). A
3216 /// future variant addition extends this slice as a single edit and
3217 /// every consumer picks up the new entry by construction — the
3218 /// compiler-checked exhaustiveness on the sibling method `match`
3219 /// arms is the build-time guarantee that no arm forgets to grow.
3220 pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222 /// Canonical author-surface tag every substrate consumer that
3223 /// names the offending dep-list in a diagnostic reaches for —
3224 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226 /// the same `&'static str` payload the sibling
3227 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228 /// already carry. Routing every dep-list diagnostic through the
3229 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230 /// literal-carry axis on the two-list dep-graph surface — a
3231 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232 /// wire-format promotion (a distinct diagnostic form for the
3233 /// `Dev` arm) reaches every consumer through one edit on the
3234 /// canonical constant, not a coordinated rewrite across the
3235 /// substrate's dep-graph consumers.
3236 #[must_use]
3237 pub const fn as_str(self) -> &'static str {
3238 match self {
3239 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241 }
3242 }
3243
3244 /// Substrate-canonical reverse projection on the two-list dep-graph
3245 /// axis — parses the author-surface wire tag back to the typed
3246 /// variant, or `None` when `s` is outside the closed-set arm-string
3247 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251 /// the round-trip migrate through one caixa-core edit on any future
3252 /// list-axis addition.
3253 ///
3254 /// Prior to this lift the substrate carried only the forward
3255 /// `Self → &str` projection on the two-list dep-graph axis (the
3256 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257 /// through it, the two [`DepError::DuplicateNome`] /
3258 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259 /// as a `&'static str` `list:` field). Every future consumer that
3260 /// wanted to promote the wire tag back to the typed enum (a future
3261 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262 /// wire form into the typed enum before dispatching to
3263 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265 /// wire re-parse of the per-list diagnostic body, a future
3266 /// [`DepError`] widening that promotes the two `list: &'static str`
3267 /// fields to a typed `list: DepList` carry so downstream consumers
3268 /// dispatch on the enum rather than string-comparing the wire
3269 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271 /// compile-time link back to the typed [`DepList`] enum. A future
3272 /// variant addition (a `:build-dep` or `:test-dep` third list once
3273 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276 /// would silently split the wire byte-string the emitter walks from
3277 /// the parser's arm-set — the round-trip would carry the new list
3278 /// through the forward projection but land on the fallback silently
3279 /// at every non-updated reverse parser, far from the arm-addition
3280 /// commit that caused the drift. Lifting the resolver to a typed
3281 /// method on the substrate primitive closes the drift footgun by
3282 /// construction: the parser's accept-set is the same set the
3283 /// [`Self::as_str`] emitter walks (routed through the same lifted
3284 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286 /// of the round-trip migrate through one caixa-core edit on any
3287 /// future list-axis addition.
3288 ///
3289 /// Same closed-set-reverse-projection discipline the sibling
3290 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295 /// carry on the peer wire-side `str → Self` axes — extended onto
3296 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297 /// closed-set typed enum on the caixa surface to converge on the
3298 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299 /// `from_str`) to match the peer shapes verbatim and side-step the
3300 /// derived [`std::str::FromStr`] impls the sibling
3301 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304 /// caller picks the diagnostic form appropriate for its use site —
3305 /// a future `feira dep --list …` arg-parse that surfaces
3306 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308 /// path folds `None` onto its per-CR structured refusal body.
3309 #[must_use]
3310 pub fn from_wire(s: &str) -> Option<Self> {
3311 match s {
3312 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314 _ => None,
3315 }
3316 }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335 f.write_str(self.as_str())
3336 }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391 fn as_ref(&self) -> &str {
3392 self.as_str()
3393 }
3394}
3395
3396/// Errors raised by [`Dep::validate`].
3397///
3398/// Mirrors the per-axis error families the other `:versao`-carrying
3399/// typed surfaces expose
3400/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3401/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3402/// [`crate::SupervisorError::EmptyChildVersion`] /
3403/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3404/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3405#[derive(Debug, Error, PartialEq, Eq)]
3406pub enum DepError {
3407 #[error(
3408 ":deps entry has empty :nome (every dep must name a target caixa; \
3409 omit the entry instead of carrying an empty name)"
3410 )]
3411 NomeEmpty,
3412 #[error(
3413 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3414 (the value flows verbatim as the target caixa's `:nome`, the rendered \
3415 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3416 value, and the resolver's checkout-directory leaf — each apiserver-side \
3417 schema rejects non-DNS-1123 names at admission time; use a lowercase \
3418 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3419 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3420 )]
3421 NomeInvalid { nome: String, reason: String },
3422 #[error(
3423 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3424 constraint that resolves through the lacre pipeline)"
3425 )]
3426 VersaoEmpty { nome: String },
3427 #[error(
3428 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3429 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3430 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3431 and `:children :versao` carry; the lacre pipeline resolves all three \
3432 through the same parser)"
3433 )]
3434 VersaoInvalid {
3435 nome: String,
3436 versao: String,
3437 reason: String,
3438 },
3439 #[error(
3440 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3441 (every git source must name a repo — use a `github:org/repo` \
3442 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3443 entire :fonte block to fall back to the default-host resolver \
3444 convention)"
3445 )]
3446 FonteRepoEmpty { nome: String },
3447 #[error(
3448 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3449 invalid value-shape: {reason} (the value flows verbatim into the \
3450 caixa-resolver's `git clone <repo>` subprocess invocation; every \
3451 documented form carries a `:` separator and no whitespace / \
3452 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3453 an `https://host/path` / `ssh://[user@]host/path` / \
3454 `git://host/path` / `file:///path` URL, or the `git@host:path` \
3455 scp-style SSH form)"
3456 )]
3457 FonteRepoShape {
3458 nome: String,
3459 repo: String,
3460 reason: String,
3461 },
3462 #[error(
3463 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3464 (set exactly one of :tag, :rev, or :branch so the resolver \
3465 can pick a reproducible commit; omit the entire :fonte block \
3466 to fall back to the default-host resolver convention, which \
3467 resolves the latest tag matching :versao)"
3468 )]
3469 FontePinMissing { nome: String },
3470 #[error(
3471 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3472 set ({pins}); exactly one of :tag, :rev, or :branch must be \
3473 set so the resolver's checkout target is unambiguous (the \
3474 resolver's silent precedence is :rev > :tag > :branch — if \
3475 you intended one specifically, drop the others)"
3476 )]
3477 FontePinAmbiguous { nome: String, pins: String },
3478 #[error(
3479 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3480 (a set pin must name a non-empty git ref; drop the {pin} key \
3481 entirely to fall through to another pin axis)"
3482 )]
3483 FontePinEmpty { nome: String, pin: String },
3484 #[error(
3485 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3486 value-shape: {reason} (the git porcelain enforces the same shape at \
3487 `git fetch` / `git checkout` time on every pin; use a leaf refname \
3488 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3489 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3490 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3491 prepends at clone time, and avoid abbreviated SHAs which are \
3492 ambiguous across repository history)"
3493 )]
3494 FontePinShape {
3495 nome: String,
3496 pin: String,
3497 value: String,
3498 reason: String,
3499 },
3500 #[error(
3501 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3502 (every path source must name a non-empty filesystem path; \
3503 omit the entire :fonte block to fall back to the default-host \
3504 resolver convention)"
3505 )]
3506 FonteCaminhoEmpty { nome: String },
3507 #[error(
3508 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3509 absolute (the lacre pipeline embeds the value verbatim in its \
3510 per-dep content-address `path:{caminho}` at \
3511 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3512 BLAKE3 closure differ across machines — defeating the \
3513 reproducibility contract that's load-bearing for CSE; express \
3514 the path relative to the caixa.lisp location, e.g. \
3515 \"../caixa-teia\" for a sibling workspace dep)"
3516 )]
3517 FonteCaminhoAbsolute { nome: String, caminho: String },
3518 #[error(
3519 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3520 with `~` (the leading-tilde is a shell-expansion convention, not a \
3521 POSIX path component — `Path::is_absolute` returns false on it, so \
3522 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3523 pipeline embeds the value verbatim in its per-dep content-address \
3524 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3525 caixa-resolver folds it through `Path::join` without `~`-expansion, \
3526 so the build looks for a literal `./{caminho}` subdirectory and \
3527 fails at resolve time far from the source caixa.lisp; even worse, a \
3528 future caixa-resolver pass that *does* expand `~` would silently \
3529 re-open the host-layout-leak the b94fd83 absolute gate closes — \
3530 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3531 runners with different `$HOME` layouts resolve to two distinct paths \
3532 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3533 determinism contract; express the path relative to the caixa.lisp \
3534 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3535 spell out the full relative path explicitly if a workstation-rooted \
3536 dep is genuinely intended)"
3537 )]
3538 FonteCaminhoTildeExpansion { nome: String, caminho: String },
3539 #[error(
3540 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3541 with `$` (the leading-`$` is a shell-variable-expansion convention, \
3542 not a POSIX path component — `Path::is_absolute` returns false on it \
3543 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3544 embeds the value verbatim in its per-dep content-address \
3545 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3546 caixa-resolver folds it through `Path::join` without `$`-expansion, \
3547 so the build looks for a literal `./{caminho}` subdirectory and \
3548 fails at resolve time far from the source caixa.lisp; even worse, a \
3549 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3550 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3551 invites) would silently re-open the host-layout-leak the b94fd83 \
3552 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3553 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3554 layouts resolve to two distinct paths for the byte-identical caixa, \
3555 defeating the THEORY.md §V.2 render-determinism contract; express \
3556 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3557 for a sibling workspace dep, or spell out the full relative path \
3558 explicitly if a workstation-rooted dep is genuinely intended)"
3559 )]
3560 FonteCaminhoVarExpansion { nome: String, caminho: String },
3561 #[error(
3562 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3563 with a space (the leading ASCII space `0x20` is the orthogonal \
3564 paste-from-aligned-doc footgun that silently passes \
3565 `Path::is_absolute` and every prior leading-byte arm — \
3566 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3567 `./ ../caixa-teia` subdirectory the resolver fails to find at \
3568 resolve time with a non-self-locating `No such file or directory` \
3569 error far from the source caixa.lisp; the lacre pipeline embeds \
3570 the value verbatim in its per-dep content-address `path:{caminho}` \
3571 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3572 semantic-identical caixa values (` ../caixa-teia` vs \
3573 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3574 workstations whose authors differ only in paste-from-aligned- \
3575 caixa.lisp-doc whitespace habits — the most insidious failure \
3576 mode the typed slot can carry (no error surfaces; the divergence \
3577 is invisible until two machines compare lacres), defeating the \
3578 THEORY.md §V.2 render-determinism contract. The canonical \
3579 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3580 a multi-entry `:deps` block sits at the same column — an author \
3581 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3582 the rendered alignment into a fresh entry preserves the leading \
3583 whitespace verbatim); peer `:fonte :repo` axis already rejects \
3584 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3585 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3586 `is_chart_description_shape`, `:licenca` via \
3587 `is_spdx_expression_shape`. Drop the leading space; express the \
3588 path as a bare relative single-token like \"../caixa-teia\")"
3589 )]
3590 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3591 #[error(
3592 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3593 with `-` (the canonical CLI-argument-injection footgun on the \
3594 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3595 its per-dep content-address `path:{caminho}` at \
3596 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3597 through `Path::join` looking for a literal `./{caminho}` \
3598 subdirectory. Every downstream subprocess that consumes the resolved \
3599 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3600 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3601 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3602 value as a CLI flag rather than a positional path when the invocation \
3603 does not carry a `--` argument-list terminator between the flag block \
3604 and the path (the common case at every porcelain entry point). The \
3605 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3606 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3607 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3608 CLI-arg-injection vector at every git porcelain entry point that \
3609 consumes a path or URL argument, peer with is_git_repo_url's \
3610 leading-`-` arm on the sibling `:fonte :repo` axis), \
3611 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3612 POSIX `std::path::Path` treats a leading `-` as a literal filename \
3613 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3614 for a literal `./-rf` subdirectory that fails at resolve time with a \
3615 non-self-locating `No such file or directory` error far from the \
3616 source caixa.lisp — but on any downstream shell-out without `--` the \
3617 reinterpretation is silent and the failure mode is arbitrary-\
3618 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3619 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3620 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3621 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3622 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3623 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3624 `:children :caixa`, `:deps :nome`, cluster names); \
3625 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3626 the feira `init` / `add <nome>` positional gate (868c191) rejects \
3627 leading `-` on the CLI positional itself. Express the path as a bare \
3628 relative single-token like \"../caixa-teia\" — the sibling-workspace \
3629 directory name carries no leading-hyphen semantic, and `./` / `../` \
3630 prefixes structurally partition the leading-byte set to safe values.)"
3631 )]
3632 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3633 #[error(
3634 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3635 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3636 every `std::fs` syscall routes the path through `CString::new` which \
3637 fails with `NulError` at resolve time; the lacre pipeline embeds the \
3638 value verbatim in its per-dep content-address `path:{caminho}` at \
3639 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3640 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3641 determinism contract — the canonical paste-from-multiline-doc \
3642 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3643 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3644 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3645 already gates against. Express the path as a relative single-line ASCII \
3646 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3647 )]
3648 FonteCaminhoControlChar {
3649 nome: String,
3650 caminho: String,
3651 byte: u8,
3652 },
3653 #[error(
3654 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3655 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3656 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3657 not the parent's sibling — and the caixa-resolver folds the value through \
3658 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3659 resolve time with a non-self-locating `No such file or directory` error far \
3660 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3661 primary path separator equal to `/`, so byte-identical caixa.lisp values \
3662 resolve to two distinct directories across runner OSes — the lacre pipeline \
3663 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3664 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3665 determinism contract via the cross-host-OS-separator divergence vector. The \
3666 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3667 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3668 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3669 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3670 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3671 \"../caixa-teia\" for a sibling workspace dep)"
3672 )]
3673 FonteCaminhoBackslash { nome: String, caminho: String },
3674 #[error(
3675 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3676 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3677 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3678 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3679 paste-from-shell-pipeline footgun where an author copies a `command > log` \
3680 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3681 as literal path-component bytes, 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 \
3684 file or directory` error far from the source caixa.lisp. The lacre pipeline \
3685 embeds 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 \
3687 and 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 CRLF-at-subprocess-argument / shell-metachar injection surface every \
3690 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3691 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3692 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3693 RFC-3986-reserved set. Express the path as a bare relative single-token like \
3694 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3695 redirection semantic.",
3696 ch = *byte as char
3697 )]
3698 FonteCaminhoShellRedirection {
3699 nome: String,
3700 caminho: String,
3701 byte: u8,
3702 },
3703 #[error(
3704 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3705 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3706 `|` as the pipe operator that wires one command's stdout to the next command's \
3707 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3708 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3709 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3710 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3711 treats `|` as a literal path-component byte, so the resolver folds the value \
3712 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3713 subdirectory and fails at resolve time with a non-self-locating `No such file or \
3714 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3715 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3716 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3717 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3718 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3719 subprocess-argument / shell-metachar injection surface every peer single-token-\
3720 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3721 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3722 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3723 workspace directory name carries no shell-pipe semantic."
3724 )]
3725 FonteCaminhoShellPipe { nome: String, caminho: String },
3726 #[error(
3727 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3728 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3729 / nushell — lexes `;` as the sequential-command terminator that fires the next \
3730 command regardless of the prior command's exit status, so `:caminho \
3731 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3732 footgun where an author copies a `cd path; do-thing` chain without trimming \
3733 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3734 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3735 literal path-component byte, so the resolver folds the value through \
3736 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3737 subdirectory and fails at resolve time with a non-self-locating `No such file \
3738 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3739 the value verbatim in its per-dep content-address `path:{caminho}` at \
3740 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3741 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3742 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3743 canonical shell-metachar injection surface every peer single-token-shaped \
3744 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3745 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3746 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3747 workspace directory name carries no shell-command-separator semantic."
3748 )]
3749 FonteCaminhoShellSemicolon { nome: String, caminho: String },
3750 #[error(
3751 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3752 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3753 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3754 terminator detaching the prior command and returning control immediately to \
3755 the prompt, double `&&` as the logical-AND list operator firing the next \
3756 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3757 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3758 sleep 1` background-launch one-liner or a `cd path && make install` build-\
3759 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3760 05c358e closed the sequential-command-separator vector, this arm closes the \
3761 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3762 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3763 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3764 byte lands in the BLAKE3 closure and rides into every shell-spawned \
3765 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3766 future operator-side `nix` spawn) as the canonical shell-metachar injection \
3767 surface every peer single-token-shaped typed slot already closes. The peer \
3768 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3769 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3770 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3771 shell-background / logical-AND semantic."
3772 )]
3773 FonteCaminhoShellBackground { nome: String, caminho: String },
3774 #[error(
3775 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3776 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3777 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3778 wrapper that runs the enclosed command and substitutes its standard-output \
3779 verbatim into the surrounding word, so a backticked `whoami` expands to the \
3780 current user's name and a backticked `cat /etc/passwd` expands to the file's \
3781 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3782 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3783 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3784 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3785 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3786 background / logical-AND vector, this arm closes the orthogonal command-\
3787 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3788 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3789 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3790 value verbatim in its per-dep content-address `path:{caminho}` at \
3791 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3792 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3793 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3794 shell-metachar injection surface every peer single-token-shaped typed slot \
3795 already closes. The peer `:entrada :paths` axis rejects the byte via \
3796 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3797 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3798 directory name carries no shell-command-substitution semantic."
3799 )]
3800 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3801 #[error(
3802 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3803 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3804 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3805 expansion wildcards: `*` matches any sequence of characters in a path component \
3806 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3807 canonical paste-from-shell-listing footgun where an author copies a \
3808 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3809 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3810 `std::path::Path` treats both bytes as literal path-component bytes, so the \
3811 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3812 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3813 locating `No such file or directory` error far from the source caixa.lisp. The \
3814 lacre pipeline embeds the value verbatim in its per-dep content-address \
3815 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3816 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3817 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3818 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3819 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3820 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3821 reserved set. Express the path as a bare relative single-token like \
3822 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3823 / pathname-expansion semantic.",
3824 ch = *byte as char
3825 )]
3826 FonteCaminhoShellGlob {
3827 nome: String,
3828 caminho: String,
3829 byte: u8,
3830 },
3831 #[error(
3832 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3833 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3834 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3835 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3836 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3837 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3838 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3839 arm closes the leading byte of — together the two arms now structurally exclude the \
3840 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3841 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3842 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3843 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3844 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3845 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3846 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3847 self-locating `No such file or directory` error far from the source caixa.lisp. The \
3848 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3849 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3850 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3851 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3852 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
3853 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
3854 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
3855 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
3856 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
3857 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3858 subshell-grouping semantic.",
3859 ch = *byte as char
3860 )]
3861 FonteCaminhoShellSubshellGrouping {
3862 nome: String,
3863 caminho: String,
3864 byte: u8,
3865 },
3866 #[error(
3867 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3868 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
3869 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
3870 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
3871 comma-separated members and `{{1..10}}` expands to the integer range — the \
3872 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
3873 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
3874 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
3875 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
3876 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
3877 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
3878 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
3879 `std::path::Path` treats the byte as a literal path-component byte, so a \
3880 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
3881 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
3882 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
3883 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
3884 silently passes every prior arm and the resolver folds the value through \
3885 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3886 resolve time with a non-self-locating `No such file or directory` error far from \
3887 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
3888 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
3889 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
3890 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3891 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
3892 expansion / URI-Template-placeholder surface every peer single-token-shaped \
3893 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
3894 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
3895 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
3896 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3897 directory name carries no shell-brace-expansion / URI-Template-placeholder \
3898 semantic; if two siblings actually need pinning, author two separate `:deps` \
3899 entries rather than one brace-expanded `:caminho` value.",
3900 ch = *byte as char
3901 )]
3902 FonteCaminhoShellBraceExpansion {
3903 nome: String,
3904 caminho: String,
3905 byte: u8,
3906 },
3907 #[error(
3908 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3909 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
3910 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
3911 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
3912 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
3913 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
3914 glob every shell-history block carries; the bracket pair additionally carries the \
3915 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
3916 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
3917 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
3918 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
3919 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
3920 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
3921 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3922 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
3923 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
3924 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
3925 leak) silently passes every prior arm and the resolver folds the value through \
3926 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3927 resolve time with a non-self-locating `No such file or directory` error far from \
3928 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3929 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3930 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3931 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3932 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
3933 surface every peer single-token-shaped typed slot already closes. Express the path \
3934 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3935 directory name carries no shell-bracket-expansion / glob-character-class / array-\
3936 literal semantic; if a family of sibling caixas actually needs pinning, author \
3937 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
3938 ch = *byte as char
3939 )]
3940 FonteCaminhoShellBracketExpansion {
3941 nome: String,
3942 caminho: String,
3943 byte: u8,
3944 },
3945 #[error(
3946 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3947 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
3948 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3949 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
3950 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
3951 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
3952 every path-with-embedded-whitespace paste block carries and the symmetric \
3953 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
3954 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
3955 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
3956 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
3957 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
3958 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
3959 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
3960 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
3961 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
3962 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
3963 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
3964 production. POSIX `std::path::Path` treats the byte as a literal path-component \
3965 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
3966 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
3967 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
3968 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
3969 shape) silently passes every prior arm and the resolver folds the value through \
3970 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
3971 resolve time with a non-self-locating `No such file or directory` error far from \
3972 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
3973 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
3974 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
3975 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
3976 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
3977 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
3978 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
3979 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
3980 `is_git_repo_url`). Express the path as a bare relative single-token like \
3981 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
3982 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
3983 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
3984 quoting on the outer syntactic layer, so an inner quote pair would nest and \
3985 desugar to a broken layer).",
3986 ch = *byte as char
3987 )]
3988 FonteCaminhoShellQuoteGrouping {
3989 nome: String,
3990 caminho: String,
3991 byte: u8,
3992 },
3993 #[error(
3994 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3995 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
3996 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
3997 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
3998 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
3999 discarding the byte and everything after it to the end of the physical line \
4000 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
4001 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4002 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4003 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
4004 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4005 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4006 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4007 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4008 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4009 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4010 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4011 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4012 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4013 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4014 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
4015 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4016 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4017 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4018 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4019 fails at resolve time with a non-self-locating `No such file or directory` \
4020 error far from the source caixa.lisp — while every downstream shell / YAML / \
4021 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4022 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4023 scalar disagree with the resolver on which directory the value names. The \
4024 lacre pipeline embeds the value verbatim in its per-dep content-address \
4025 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4026 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4027 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4028 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4029 fragment-delimiter surface every peer single-token-shaped typed slot already \
4030 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4031 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4032 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4033 workspace directory name carries no shell-comment / URL-fragment / YAML-\
4034 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4035 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4036 and drop any `#fragment` tail entirely (fragment identifiers select \
4037 renderings, not directories, and `:caminho` names a directory).",
4038 ch = *byte as char
4039 )]
4040 FonteCaminhoShellComment {
4041 nome: String,
4042 caminho: String,
4043 byte: u8,
4044 },
4045 #[error(
4046 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4047 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4048 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4049 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4050 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4051 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4052 literally inside a URL value. The canonical paste-from-browser-address-bar \
4053 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4054 encoded README hyperlink / browser address bar / percent-encoded permalink \
4055 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4056 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4057 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4058 `std::path::Path` treats the byte as a literal path-component byte, so \
4059 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4060 resolve time with a non-self-locating `No such file or directory` error far \
4061 from the source caixa.lisp — while every downstream URL parser / shell printf \
4062 builtin / YAML directive parser silently reinterprets the byte to a different \
4063 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4064 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4065 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4066 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4067 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4068 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4069 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4070 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4071 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4072 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4073 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4074 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4075 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4076 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4077 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4078 printf-format-specifier / job-control-specifier surface every peer single-\
4079 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4080 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4081 `is_git_repo_url`). Express the path as a bare relative single-token like \
4082 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4083 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4084 any `%20` percent-encoded-space with a literal space then reject the whole \
4085 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4086 directory name never carries an embedded space in practice); drop any \
4087 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4088 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4089 ch = *byte as char
4090 )]
4091 FonteCaminhoUrlPercentEncoding {
4092 nome: String,
4093 caminho: String,
4094 byte: u8,
4095 },
4096 #[error(
4097 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4098 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4099 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4100 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4101 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4102 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4103 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4104 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4105 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4106 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4107 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4108 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4109 the byte is a first-class parser byte in nearly every config / templating / \
4110 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4111 `std::path::Path` treats the byte as a literal path-component byte, so the \
4112 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4113 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4114 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4115 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4116 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4117 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4118 subdirectory that fails at resolve time with a non-self-locating `No such file \
4119 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4120 the value verbatim in its per-dep content-address `path:{caminho}` at \
4121 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4122 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4123 time lock to two distinct BLAKE3 closures across two workstations whose \
4124 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4125 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4126 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4127 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4128 is the canonical CWE-78 shell-command-injection surface every peer single-\
4129 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4130 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4131 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4132 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4133 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4134 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4135 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4136 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4137 so every position — leading and embedded — is structurally rejected. Substitute \
4138 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4139 time, or express the path as a bare relative single-token like \
4140 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4141 variable-expansion / command-substitution / arithmetic-expansion semantic.",
4142 ch = *byte as char
4143 )]
4144 FonteCaminhoShellVariableExpansion {
4145 nome: String,
4146 caminho: String,
4147 byte: u8,
4148 },
4149 #[error(
4150 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4151 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4152 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4153 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4154 reference §9.3: `!command` re-runs the most recent history entry beginning with \
4155 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4156 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4157 and the substitution fires at every history-expansion-enabled shell context — \
4158 `set -o histexpand` is bash's default for interactive sessions and the layer \
4159 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4160 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4161 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4162 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4163 encodes it inside a query component via the 'special-query percent-encode set' \
4164 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4165 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4166 prefix — the paste-from-source-code idiom where an author copies \
4167 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4168 the string-literal boundary); the canonical English-typography emphasis / \
4169 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4170 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4171 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4172 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4173 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4174 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4175 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4176 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4177 repeat-prior-command paste idiom), the English-typography `:caminho \
4178 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4179 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4180 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4181 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4182 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4183 subdirectory that fails at resolve time with a non-self-locating `No such file \
4184 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4185 the value verbatim in its per-dep content-address `path:{caminho}` at \
4186 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4187 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4188 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4189 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4190 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4191 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4192 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4193 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4194 name carries no shell-history-expansion / bang-operator semantic; drop any \
4195 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4196 idiom; and drop any trailing English-typography exclamation mark that pasted \
4197 from prose.",
4198 ch = *byte as char
4199 )]
4200 FonteCaminhoShellHistoryExpansion {
4201 nome: String,
4202 caminho: String,
4203 byte: u8,
4204 },
4205 #[error(
4206 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4207 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4208 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4209 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4210 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4211 substitution' history operator that rewrites the prior command's `old` string to \
4212 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4213 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4214 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4215 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4216 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4217 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4218 literal value diverges from every downstream `feira tofu` curl-invocation / \
4219 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4220 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4221 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4222 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4223 `std::path::Path` treats `^` as a literal path-component byte, so \
4224 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4225 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4226 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4227 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4228 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4229 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4230 that fails at resolve time with a non-self-locating `No such file or directory` \
4231 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4232 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4233 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4234 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4235 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4236 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4237 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4238 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4239 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4240 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4241 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4242 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4243 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4244 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4245 drop any trailing `^` history-substitution-open fragment.",
4246 ch = *byte as char
4247 )]
4248 FonteCaminhoShellHistorySubstitution {
4249 nome: String,
4250 caminho: String,
4251 byte: u8,
4252 },
4253 #[error(
4254 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4255 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4256 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4257 value verbatim in its per-dep content-address `path:{caminho}` at \
4258 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4259 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4260 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4261 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4262 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4263 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4264 trailing `/`; every `:caminho` value names a sibling-workspace directory \
4265 already, so the trailing separator carries no information. Use \
4266 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4267 )]
4268 FonteCaminhoTrailingSlash { nome: String, caminho: String },
4269 #[error(
4270 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4271 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4272 apply the same set-not-multiset discipline; one package per table), and \
4273 two entries naming the same caixa carry two version constraints / source \
4274 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4275 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4276 silently overwrites the first at the resolver-side `concrete_versao` step, \
4277 and the dropped entry's pin / features never reach the closure — far from \
4278 the source caixa.lisp, with no field naming which `:deps` entry was the \
4279 silent loser. If two version constraints are genuinely needed (the rare \
4280 multi-version closure case the lacre pipeline doesn't yet support), the \
4281 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4282 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4283 )]
4284 DuplicateNome { nome: String, list: &'static str },
4285 #[error(
4286 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4287 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4288 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4289 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4290 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4291 with the canonical kebab-case feature name the target caixa declares."
4292 )]
4293 CaracteristicaEmpty { nome: String },
4294 #[error(
4295 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4296 feature name: {reason} (the value flows verbatim into Cargo's \
4297 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4298 parser enforces the same shape at `cargo metadata` time; use a single-token \
4299 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4300 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4301 an ASCII alphanumeric or `_`)"
4302 )]
4303 CaracteristicaInvalid {
4304 nome: String,
4305 caracteristica: String,
4306 reason: String,
4307 },
4308 #[error(
4309 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4310 every feature-flag list keys its entries by name (Cargo's \
4311 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4312 per feature per dep), and two entries naming the same feature are a redundant \
4313 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4314 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4315 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4316 feature once regardless of declaration count, so the duplicate's pin / position never \
4317 reaches the closure with no field naming the silent loser. One entry per feature per \
4318 dep; if two distinct features are intended, name each verbatim."
4319 )]
4320 CaracteristicaDuplicate {
4321 nome: String,
4322 caracteristica: String,
4323 },
4324 #[error(
4325 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4326 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4327 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4328 rejects mid-traversal far from the source caixa.lisp or recurses on until \
4329 it exhausts its stack). Every :nome is globally-unique substrate identity, \
4330 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4331 *is* the parent itself, not a coincidentally-named peer. Drop the \
4332 self-referential dep entry — to reference code from this caixa, use \
4333 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4334 referencing the caixa's own code surface) instead."
4335 )]
4336 DepIsSelf { nome: String, list: &'static str },
4337}
4338
4339// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4340// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4341// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4342// variant — the paired `{ nome: String, caminho: String }` two-slot family
4343// on [`DepError`], sibling of the peer
4344// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4345// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4346// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4347// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4348// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4349// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4350// `{ de, para, wit, expected }`), and
4351// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4352// variants on `{ de, para, <field>: String, reason: String }`) on the
4353// `AplicacaoError` envelopes, the peer
4354// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4355// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4356// (0419438, 4 variants on `{ caixa, kind, slots }`),
4357// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4358// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4359// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4360// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4361// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4362// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4363// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4364// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4365//
4366// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4367// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4368// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4369// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4370// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4371// CommandSubstitution}` on the four single-byte shell operators; and the
4372// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4373// opened the identical `DepError::FonteCaminho<Variant> { nome:
4374// nome.to_string(), caminho: caminho.to_string() }` four-line
4375// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4376// — the exact "same block re-inlined at every consumer" shape the PRIME
4377// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4378// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4379// families each closed on their sibling envelopes. The eleven variants
4380// share one `{ nome: String, caminho: String }` shape, so the fold routes
4381// each wire-up site through one dispatch per typed variant.
4382//
4383// The macro below generates one `#[must_use]` inherent constructor per
4384// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4385// wire-up site collapses onto one dispatch:
4386// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4387// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4388// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4389// once — inside the macro — rather than at every wire-up site.
4390//
4391// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4392// shapes at the per-byte-classification arms — the
4393// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4394// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4395// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4396// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4397// cluster — carry an additional `byte: u8` naming the offending byte and
4398// so would break the uniform-two-field routing this macro promises. They
4399// instead fold onto the sibling three-field envelope through
4400// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4401// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4402// two-slot family is the `byte: u8` classification the arms carry. The
4403// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4404// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4405// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4406// envelope.
4407//
4408// Every future consumer that wants to construct one of these eleven
4409// variants outside the current in-crate [`DepSource::validate_caminho`]
4410// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4411// at lacre-resolve time re-checking the same value-shape axes the resolver
4412// consumes, a future `feira validate --deps` per-caixa admission verb
4413// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4414// rejecting a `:caminho` value against a cluster-local snapshot) now
4415// reaches each variant through one call rather than re-inlining the
4416// four-line struct-literal in lockstep with the eleven in-crate wire-up
4417// sites.
4418macro_rules! fonte_caminho_ctors {
4419 ($($ctor:ident => $variant:ident),* $(,)?) => {
4420 impl DepError {
4421 $(
4422 #[doc = concat!(
4423 "Construct a [`DepError::",
4424 stringify!($variant),
4425 "`] naming the offending `:deps :nome` + `:fonte ",
4426 "(:tipo path …) :caminho` pair. Folds the uniform ",
4427 "`Self::",
4428 stringify!($variant),
4429 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4430 "two-slot struct-literal onto one substrate primitive so ",
4431 "every [`DepSource::validate_caminho`] wire-up on this ",
4432 "variant reads through one dispatch rather than the ",
4433 "pre-lift four-line open-coded block."
4434 )]
4435 #[must_use]
4436 pub fn $ctor(nome: &str, caminho: &str) -> Self {
4437 Self::$variant {
4438 nome: nome.to_string(),
4439 caminho: caminho.to_string(),
4440 }
4441 }
4442 )*
4443 }
4444 };
4445}
4446
4447fonte_caminho_ctors! {
4448 fonte_caminho_absolute => FonteCaminhoAbsolute,
4449 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4450 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4451 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4452 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4453 fonte_caminho_backslash => FonteCaminhoBackslash,
4454 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4455 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4456 fonte_caminho_shell_background => FonteCaminhoShellBackground,
4457 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4458 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4459}
4460
4461// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4462// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4463// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4464// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4465// three-slot family on [`DepError`], strict sibling of the peer
4466// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4467// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4468// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4469// axis broke its uniform-two-field routing — the exact "future compounding
4470// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4471// here. Third fold family on this `DepError` envelope, sibling of the peer
4472// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4473// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4474// same enum.
4475//
4476// Each of the twelve wire-up sites on this shape (the control-byte arm
4477// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4478// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4479// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4480// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4481// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4482// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4483// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4484// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4485// `FonteCaminhoShellHistoryExpansion` on `!`, and
4486// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4487// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4488// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4489// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4490// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4491// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4492// closed on the sibling two-field envelope of this same enum. The twelve
4493// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4494// the fold routes each wire-up site through one dispatch per typed variant.
4495//
4496// The macro below generates one `#[must_use]` inherent constructor per
4497// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4498// so every wire-up site collapses onto one dispatch:
4499// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4500// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4501// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4502// `byte`) is spelled once — inside the macro — rather than at every wire-up
4503// site.
4504//
4505// Every future consumer that wants to construct one of these twelve
4506// variants outside the current in-crate [`DepSource::validate_caminho`]
4507// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4508// at lacre-resolve time re-checking the same value-shape axes the resolver
4509// consumes, a future `feira validate --deps` per-caixa admission verb
4510// re-checking the `:fonte :caminho` axis against the shell-metachar
4511// classification bytes this cluster catches, a per-lacre overlay resolver
4512// rejecting a `:caminho` value against a cluster-local snapshot) now
4513// reaches each variant through one call rather than re-inlining the
4514// five-line struct-literal in lockstep with the twelve in-crate wire-up
4515// sites.
4516macro_rules! fonte_caminho_byte_ctors {
4517 ($($ctor:ident => $variant:ident),* $(,)?) => {
4518 impl DepError {
4519 $(
4520 #[doc = concat!(
4521 "Construct a [`DepError::",
4522 stringify!($variant),
4523 "`] naming the offending `:deps :nome` + `:fonte ",
4524 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4525 "classification. Folds the uniform `Self::",
4526 stringify!($variant),
4527 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4528 "byte }` three-slot struct-literal onto one substrate ",
4529 "primitive so every [`DepSource::validate_caminho`] wire-up ",
4530 "on this variant reads through one dispatch rather than ",
4531 "the pre-lift five-line open-coded block."
4532 )]
4533 #[must_use]
4534 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4535 Self::$variant {
4536 nome: nome.to_string(),
4537 caminho: caminho.to_string(),
4538 byte,
4539 }
4540 }
4541 )*
4542 }
4543 };
4544}
4545
4546fonte_caminho_byte_ctors! {
4547 fonte_caminho_control_char => FonteCaminhoControlChar,
4548 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4549 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4550 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4551 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4552 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4553 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4554 fonte_caminho_shell_comment => FonteCaminhoShellComment,
4555 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4556 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4557 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4558 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4559}
4560
4561// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4562// single-slot struct-variant wire-up sites scattered across
4563// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4564// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4565// substrate primitive per typed variant — the paired `{ nome: String }`
4566// single-slot family on [`DepError`], sibling of the peer
4567// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4568// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4569// the same enum, and of the peer
4570// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4571// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4572// axis. Second fold family on this `DepError` envelope, and the first on
4573// the single-`{ nome }` shape.
4574//
4575// The five wire-up sites this fold closes each opened the identical
4576// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4577// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4578// local — the exact "same block re-inlined at every consumer" shape the
4579// PRIME DIRECTIVE names as a bug. The five variants share one
4580// `{ nome: String }` shape, so the fold routes each wire-up site through
4581// one dispatch per typed variant.
4582//
4583// The macro below generates one `#[must_use]` inherent constructor per
4584// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4585// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4586// pre-lift struct-literal on the same `&str` fixture. The uniform
4587// one-field construction (`nome.to_string()`) is spelled once — inside
4588// the macro — rather than at every wire-up site. Callers that hold a
4589// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4590// and lets the macro-owned `.to_string()` produce the fresh owning copy
4591// the enum variant needs; the semantics collapse onto the same
4592// `.clone()`-equivalent one this fold replaces at every site.
4593//
4594// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4595// on the same envelope stays on its pre-lift open-coded wire-up shape —
4596// it carries no `nome` field (the offending `:nome` value *is* the empty
4597// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4598// signature this macro promises does not apply. Every future consumer
4599// that wants to construct one of these five variants outside the current
4600// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4601// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4602// re-validator at lacre-resolve time, a future `feira validate --deps`
4603// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4604// these empty-value shapes against a cluster-local snapshot) now reaches
4605// each variant through one call rather than re-inlining the three-line
4606// struct-literal in lockstep with the five in-crate wire-up sites.
4607macro_rules! dep_nome_only_ctors {
4608 ($($ctor:ident => $variant:ident),* $(,)?) => {
4609 impl DepError {
4610 $(
4611 #[doc = concat!(
4612 "Construct a [`DepError::",
4613 stringify!($variant),
4614 "`] naming the offending `:deps :nome`. Folds the ",
4615 "uniform `Self::",
4616 stringify!($variant),
4617 " { nome: nome.to_string() }` one-field ",
4618 "struct-literal onto one substrate primitive so every ",
4619 "in-crate wire-up on this variant reads through one ",
4620 "dispatch rather than the pre-lift three-line ",
4621 "open-coded block."
4622 )]
4623 #[must_use]
4624 pub fn $ctor(nome: &str) -> Self {
4625 Self::$variant { nome: nome.to_string() }
4626 }
4627 )*
4628 }
4629 };
4630}
4631
4632dep_nome_only_ctors! {
4633 versao_empty => VersaoEmpty,
4634 fonte_repo_empty => FonteRepoEmpty,
4635 fonte_pin_missing => FontePinMissing,
4636 fonte_caminho_empty => FonteCaminhoEmpty,
4637 caracteristica_empty => CaracteristicaEmpty,
4638}
4639
4640// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4641// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4642// [`crate::manifest::Caixa::validate_deps`] +
4643// [`validate_no_self_dep`] onto one substrate-primitive family per
4644// typed variant — the `DepError`-side siblings of the peer
4645// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4646// on the `SupervisorError { caixa: String }` one-slot envelope and of
4647// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4648// `DepError { nome: String }` one-slot envelope. The two variants
4649// carry the same `{ nome: String, list: &'static str }` two-slot
4650// shape: the `nome` field names the offending dep the diagnostic
4651// points the author back at, and the `list` field carries the
4652// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4653// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4654// [`validate_deps`] arms, and via the paired
4655// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4656// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4657// canonicals on the [`validate_no_self_dep`] arm) so the author can
4658// grep their caixa.lisp for the offending list block in one edit.
4659//
4660// Each of the four wire-up sites opened the same struct-literal
4661// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4662// two-line block — the exact "same block re-inlined at every
4663// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4664// altitude the peer `DepError` / `SupervisorError` /
4665// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4666// already closed on their sibling envelopes. The two `#[must_use]`
4667// inherent constructors below fold each wire-up onto one dispatch:
4668// `DepError::duplicate_nome(<nome>, <list>)` and
4669// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4670// pre-lift struct-literal on the same scalar fixtures. The `list:
4671// &'static str` parameter (not `impl Into<String>`) preserves the
4672// exact wire tag every consumer already passes verbatim — no
4673// downstream diagnostic reshaping at the lift, matching the peer
4674// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4675// contract each wire-up site already keys off.
4676macro_rules! dep_nome_list_ctors {
4677 ($($ctor:ident => $variant:ident),* $(,)?) => {
4678 impl DepError {
4679 $(
4680 #[doc = concat!(
4681 "Construct a [`DepError::",
4682 stringify!($variant),
4683 "`] naming the offending `:deps :nome` and the ",
4684 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4685 "the diagnostic points the author back at. Folds ",
4686 "the uniform `Self::",
4687 stringify!($variant),
4688 " { nome: nome.to_string(), list }` two-field ",
4689 "struct-literal onto one substrate primitive so ",
4690 "every in-crate wire-up on this variant reads ",
4691 "through one dispatch rather than the pre-lift ",
4692 "open-coded struct-literal block."
4693 )]
4694 #[must_use]
4695 pub fn $ctor(nome: &str, list: &'static str) -> Self {
4696 Self::$variant { nome: nome.to_string(), list }
4697 }
4698 )*
4699 }
4700 };
4701}
4702
4703dep_nome_list_ctors! {
4704 duplicate_nome => DuplicateNome,
4705 dep_is_self => DepIsSelf,
4706}
4707
4708// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4709// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4710// <value>.to_string(), reason }` struct-variant wire-up sites at
4711// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4712// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4713// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4714// primitive family per typed variant — the `DepError`-side siblings of the
4715// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4716// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4717// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4718// the two-slot `{ nome, caminho }` envelope, and
4719// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4720// caminho, byte }` envelope. The three variants share the same
4721// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4722// the `nome` field names the offending dep the diagnostic points the
4723// author back at, the middle `<axis>: String` field carries the offending
4724// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4725// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4726// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4727// field carries the parser-shaped rejection sentence the paired
4728// [`crate::render::require_valid_versao_requirement`] /
4729// [`crate::render::is_git_repo_url`] /
4730// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4731// axis-field name differs across variants (`versao` / `repo` /
4732// `caracteristica`) so the ctor family below takes the axis field name as
4733// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4734// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4735// -> Self` inherent constructor per typed variant that spells the uniform
4736// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4737// `reason` forwarded owned) exactly once. Peer of the sibling
4738// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4739// family on the `AplicacaoError` envelope's mirror-symmetric
4740// `{ <field>: String, reason: String }` two-slot shape — same
4741// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4742// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4743// envelope keys off (every `DepError` variant carries the offending
4744// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4745// offending block in one edit).
4746//
4747// The three wire-up sites this fold closes are:
4748// - [`DepSource::validate`]'s `:repo` value-shape arm
4749// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4750// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4751// rejects the offending URL);
4752// - [`Dep::validate`]'s `:versao` requirement-shape arm
4753// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4754// self.versao_requirement().to_string(), reason }` inside the
4755// [`crate::render::require_valid_versao_requirement`] callback pair);
4756// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4757// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4758// caracteristica: c.clone(), reason })` after
4759// [`crate::render::is_cargo_feature_name`] rejects the offending
4760// feature-name).
4761//
4762// Each opened the identical five-line struct-literal against the same
4763// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4764// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4765// same altitude the peer four already-lifted `DepError` ctor families
4766// closed on their sibling shape-envelopes. The three variant / axis-field
4767// discriminators are the only things that vary between them; the rest of
4768// the struct-literal is a byte-for-byte re-inline.
4769//
4770// Every future consumer wanting to raise one of these three diagnostics
4771// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4772// time re-checking each declared dep against the same requirement +
4773// git-URL + feature-name value-shape cascade, a future `feira validate
4774// --deps` per-caixa admission verb re-running the shape gates on demand,
4775// a per-lacre overlay resolver rejecting an author-supplied dep against a
4776// cluster-local snapshot) now reaches one dispatch rather than re-inlining
4777// the five-line struct-literal in lockstep with the three in-crate
4778// wire-up sites.
4779macro_rules! dep_nome_axis_reason_ctors {
4780 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4781 impl DepError {
4782 $(
4783 #[doc = concat!(
4784 "Construct a [`DepError::",
4785 stringify!($variant),
4786 "`] naming the offending `:deps :nome`, the offending ",
4787 "`:", stringify!($axis), "` axis value, and the ",
4788 "parser-shaped rejection `reason`. Folds the uniform ",
4789 "`Self::",
4790 stringify!($variant),
4791 " { nome: nome.to_string(), ",
4792 stringify!($axis),
4793 ": ",
4794 stringify!($axis),
4795 ".to_string(), reason }` three-field struct-literal ",
4796 "onto one substrate primitive so every in-crate ",
4797 "wire-up on this variant reads through one dispatch ",
4798 "rather than the pre-lift five-line open-coded block. ",
4799 "The `nome: &str` and `",
4800 stringify!($axis),
4801 ": &str` parameters accept `&str` literals and ",
4802 "`&String` (via Deref coercion) so every existing ",
4803 "wire-up threads through the ctor without a ",
4804 "pre-conversion; the `reason: String` parameter takes ",
4805 "an owned `String` (not `impl Into<String>`) matching ",
4806 "the paired `crate::render::*` predicate's ",
4807 "`Result<(), String>` return shape every wire-up ",
4808 "already holds owned at the call site."
4809 )]
4810 #[must_use]
4811 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
4812 Self::$variant {
4813 nome: nome.to_string(),
4814 $axis: $axis.to_string(),
4815 reason,
4816 }
4817 }
4818 )*
4819 }
4820 };
4821}
4822
4823dep_nome_axis_reason_ctors! {
4824 versao_invalid => VersaoInvalid { versao },
4825 fonte_repo_shape => FonteRepoShape { repo },
4826 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
4827}
4828
4829// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
4830// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
4831// <value>.to_string() }` struct-variant wire-up sites at
4832// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
4833// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
4834// per-entry set-not-multiset dedup closure onto one substrate-primitive
4835// family per typed variant — the missing two-slot rung on the
4836// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
4837// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
4838// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
4839// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
4840// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
4841// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
4842// symmetric sibling of the peer
4843// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
4844// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
4845// envelope — same `<axis>: <value>.to_string()` owned-forward payload
4846// shape, `reason` axis removed and `nome`-axis added at the per-dep-
4847// owned altitude the `DepError` envelope keys off (every `DepError`
4848// variant carries the offending `:deps :nome` verbatim so the author
4849// can grep their caixa.lisp for the offending block in one edit). The
4850// three variants share the same `{ nome: String, <axis>: String }`
4851// two-slot shape: the `nome` field names the offending dep the
4852// diagnostic points the author back at, and the middle `<axis>:
4853// String` field carries the offending per-envelope axis value verbatim
4854// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
4855// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
4856// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
4857// The middle axis-field name differs across variants (`pin` / `pins` /
4858// `caracteristica`) so the ctor family below takes the axis field name
4859// as a macro parameter (`$axis:ident`) alongside the ctor + variant
4860// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
4861// Self` inherent constructor per typed variant that spells the
4862// uniform two-field construction (`nome.to_string()` /
4863// `<axis>.to_string()`) exactly once.
4864//
4865// The three wire-up sites this fold closes are:
4866// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
4867// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
4868// pin.to_string() });` inside the `set.len() == 1` branch after the
4869// `is_some_and(String::is_empty)` iterator);
4870// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
4871// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
4872// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
4873// - [`Dep::validate_caracteristicas`]'s per-entry
4874// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
4875// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
4876// [`crate::render::insert_first_seen`]).
4877//
4878// Each opened the identical four-line struct-literal against the same
4879// `(nome, <axis>)` local pair — the exact "same block re-inlined at
4880// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4881// same altitude the peer four already-lifted `DepError` ctor families
4882// closed on their sibling shape-envelopes. The three variant / axis-
4883// field discriminators are the only things that vary between them;
4884// the rest of the struct-literal is a byte-for-byte re-inline.
4885//
4886// Every future consumer wanting to raise one of these three
4887// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
4888// at lacre-resolve time re-checking each declared dep against the
4889// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
4890// set-not-multiset cascade, a future `feira validate --deps` per-
4891// caixa admission verb re-running the shape gates on demand, a
4892// per-lacre overlay resolver rejecting an author-supplied dep against
4893// a cluster-local snapshot the M4 CR materializer projects) now
4894// reaches one dispatch rather than re-inlining the four-line struct-
4895// literal in lockstep with the three in-crate wire-up sites.
4896macro_rules! dep_nome_axis_ctors {
4897 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4898 impl DepError {
4899 $(
4900 #[doc = concat!(
4901 "Construct a [`DepError::",
4902 stringify!($variant),
4903 "`] naming the offending `:deps :nome` and the ",
4904 "offending `:", stringify!($axis), "` axis value. ",
4905 "Folds the uniform `Self::",
4906 stringify!($variant),
4907 " { nome: nome.to_string(), ",
4908 stringify!($axis),
4909 ": ",
4910 stringify!($axis),
4911 ".to_string() }` two-field struct-literal onto one ",
4912 "substrate primitive so every in-crate wire-up on ",
4913 "this variant reads through one dispatch rather than ",
4914 "the pre-lift four-line open-coded block. Both `nome: ",
4915 "&str` and `",
4916 stringify!($axis),
4917 ": &str` parameters accept `&str` literals and ",
4918 "`&String` (via Deref coercion) so every existing ",
4919 "wire-up threads through the ctor without a pre-",
4920 "conversion."
4921 )]
4922 #[must_use]
4923 pub fn $ctor(nome: &str, $axis: &str) -> Self {
4924 Self::$variant {
4925 nome: nome.to_string(),
4926 $axis: $axis.to_string(),
4927 }
4928 }
4929 )*
4930 }
4931 };
4932}
4933
4934dep_nome_axis_ctors! {
4935 fonte_pin_empty => FontePinEmpty { pin },
4936 fonte_pin_ambiguous => FontePinAmbiguous { pins },
4937 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
4938}
4939
4940// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
4941// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
4942// struct-variant wire-up sites at [`DepSource::validate`]'s
4943// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
4944// the `DepError` envelope — the last open-coded ctor site remaining on
4945// the `:fonte (:tipo git …)` value-shape trajectory this envelope
4946// carries, and the single-variant sibling of the peer four already-
4947// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
4948// on the two-slot `{ nome, caminho }` envelope,
4949// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
4950// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
4951// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
4952// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
4953// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
4954// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
4955// `{ …, value: String, reason: String }` payload shape, one axis
4956// removed at the `nome`-only-owner altitude the `DepError` envelope
4957// keys off (no `edge_pair()` de/para pair).
4958//
4959// The two wire-up sites this fold closes are the paired refname-pin
4960// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
4961// pin: pin.to_string(), value: v.clone(), reason }` inside the
4962// `[(":tag", tag), (":branch", branch)]` iterator against
4963// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
4964// (`|| DepError::FontePinShape { nome: nome.to_string(),
4965// pin: ":rev".to_string(), value: v.clone(), reason }` against
4966// [`crate::render::is_git_oid`]) — each opened the identical
4967// `DepError::FontePinShape { … }` six-line struct-literal against the
4968// same `(nome: &str, pin: &str, v: &String, reason: String)` local
4969// tuple, the exact "same block re-inlined at every consumer" shape
4970// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
4971// the only thing that varies between them (`":tag"`/`":branch"` on
4972// the refname arm, `":rev"` on the hex-OID arm); the rest of the
4973// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
4974// route through the same ctor because their `pin` field carries the
4975// author-surface tag verbatim (matching the `FontePinEmpty` /
4976// `FontePinAmbiguous` sibling variants' `pin: String` axis
4977// convention), so the offending author can grep their caixa.lisp for
4978// the offending `:tag "<value>"` / `:branch "<value>"` /
4979// `:rev "<value>"` literal in one edit.
4980//
4981// The single ctor below folds each wire-up onto one dispatch:
4982// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
4983// the pre-lift struct-literal on the same `(&str, &str, &str,
4984// String)` fixture. The uniform four-field construction
4985// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
4986// `reason` forwarded owned) is spelled once here rather than at every
4987// wire-up site. The `reason: String` field takes an owned `String`
4988// (not `impl Into<String>`) matching the two call sites' pre-existing
4989// `let Err(reason) = crate::render::is_git_ref_name(v)` /
4990// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
4991// predicates return `Result<(), String>`, so the caller always holds
4992// an owned `String` at the wire-up site and threading it through the
4993// ctor without a `.into()` shim keeps the routing shape byte-equal to
4994// the pre-lift block. The `value: &str` parameter accepts both `&str`
4995// literals (unused today) and `&String` (from the caller-held
4996// `v: &String` on each arm, via Deref coercion), so every existing
4997// wire-up threads through the ctor without a pre-conversion.
4998//
4999// Every future consumer that wants to construct this variant outside
5000// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5001// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5002// re-checking the same value-shape axes the resolver consumes, a
5003// future `feira validate --deps` per-caixa admission verb re-checking
5004// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5005// resolver rejecting a git-pin value against a cluster-local
5006// snapshot) now reaches this variant through one call rather than
5007// re-inlining the six-line struct-literal in lockstep with the two
5008// in-crate wire-up sites.
5009impl DepError {
5010 /// Construct a [`DepError::FontePinShape`] naming the offending
5011 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5012 /// axis tag, the offending value, and the parser-shaped `reason`.
5013 /// Folds the uniform
5014 /// `Self::FontePinShape { nome: nome.to_string(),
5015 /// pin: pin.to_string(), value: value.to_string(), reason }`
5016 /// four-field struct-literal onto one substrate primitive so
5017 /// every [`DepSource::validate`] wire-up on this variant reads
5018 /// through one dispatch rather than the pre-lift six-line
5019 /// open-coded block. The `nome` string threads verbatim from
5020 /// [`Dep::nome`] at the call site; the `pin` string carries the
5021 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5022 /// `value` string carries the offending refname / hex-OID
5023 /// verbatim; and `reason` forwards the owned `String` returned
5024 /// by [`crate::render::is_git_ref_name`] /
5025 /// [`crate::render::is_git_oid`] without a `.into()` shim.
5026 #[must_use]
5027 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5028 Self::FontePinShape {
5029 nome: nome.to_string(),
5030 pin: pin.to_string(),
5031 value: value.to_string(),
5032 reason,
5033 }
5034 }
5035
5036 /// Construct a [`DepError::NomeInvalid`] naming the offending
5037 /// `:deps :nome` byte-string and the parser-shaped rejection
5038 /// `reason` returned by [`crate::render::is_dns_1123_label`].
5039 ///
5040 /// Folds the uniform
5041 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5042 /// struct-literal onto one substrate primitive so every wire-up on
5043 /// this variant reads through one dispatch rather than the pre-lift
5044 /// four-line open-coded `DepError::NomeInvalid { nome:
5045 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5046 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5047 /// ctor-family ladder (`{ nome }` one-slot →
5048 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5049 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5050 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5051 /// `{ nome, <axis>: String, reason: String }` three-slot →
5052 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5053 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5054 /// — the sole variant on the envelope carrying the
5055 /// `{ nome: String, reason: String }` two-slot shape without a
5056 /// middle axis, matching the peer
5057 /// [`crate::manifest::ManifestError::NomeInvalid`] +
5058 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5059 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5060 /// four-axis DNS-1123 caixa-identifier diagnostic family the
5061 /// existing `nome_invalid_diagnostic_carries_offending_name` test
5062 /// pins on this envelope.
5063 ///
5064 /// The `nome: &str` parameter accepts `&str` literals and `&String`
5065 /// (via Deref coercion) so the sole in-crate wire-up threads through
5066 /// the ctor without a pre-conversion; the `reason: String`
5067 /// parameter takes an owned `String` (not `impl Into<String>`)
5068 /// matching the [`crate::render::is_dns_1123_label`] predicate's
5069 /// `Result<(), String>` return shape the sole wire-up site already
5070 /// holds owned at the call site, keeping the routing byte-equal to
5071 /// the pre-lift block. Same owned-`String`-forward `reason` payload
5072 /// discipline as the sibling three-slot family
5073 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5074 /// and the four-slot [`DepError::fonte_pin_shape`] on
5075 /// `{ nome, pin, value, reason }`.
5076 ///
5077 /// Every future consumer that raises the same diagnostic outside
5078 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5079 /// re-validator at lacre-resolve time re-checking each declared
5080 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5081 /// side schema uses (the `:nome` value flows verbatim as the target
5082 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5083 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5084 /// checkout-directory leaf), a future `feira validate --deps`
5085 /// per-caixa admission verb re-running the shape gate on demand, a
5086 /// per-lacre overlay resolver rejecting an author-supplied dep's
5087 /// `:nome` against a cluster-local snapshot the M4 CR materializer
5088 /// projects, a future authoring-surface widening the field into a
5089 /// `(String, Vec<Suggestion>)` pair carrying a
5090 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5091 /// variant through one call rather than re-inlining the four-line
5092 /// struct-literal in lockstep with the one in-crate wire-up site.
5093 #[must_use]
5094 pub fn nome_invalid(nome: &str, reason: String) -> Self {
5095 Self::NomeInvalid {
5096 nome: nome.to_string(),
5097 reason,
5098 }
5099 }
5100}
5101
5102#[allow(clippy::trivially_copy_pass_by_ref)]
5103fn is_false(b: &bool) -> bool {
5104 !*b
5105}
5106
5107#[cfg(test)]
5108mod tests {
5109 use super::*;
5110
5111 #[test]
5112 fn registry_dep_is_minimal() {
5113 let d = Dep::simple("caixa-teia", "^0.1");
5114 assert_eq!(d.nome, "caixa-teia");
5115 assert_eq!(d.versao, "^0.1");
5116 assert!(d.fonte.is_none());
5117 assert!(!d.opcional());
5118 assert!(d.caracteristicas().is_empty());
5119 }
5120
5121 #[test]
5122 fn dep_string_scalar_accessor_pair_is_const_fn() {
5123 // Fail-before-pass-after pin on [`Dep::nome`] +
5124 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5125 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5126 // entry's [`String`] storage through the `pub const fn`
5127 // [`String::as_str`] (const-stable since Rust 1.87, well
5128 // within the workspace MSRV) — any future accidental
5129 // downgrade to non-`const` fails the corresponding
5130 // `<name>_via_const_fn` wrapper at caixa-core build time with
5131 // E0015 (`cannot call non-const method`), strictly stronger
5132 // than a runtime `assert!`. Sibling of the peer
5133 // per-M2/M3/universal-axis `String → &str` scalar-accessor
5134 // family pins on the sibling `const`-eval-surface passes
5135 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5136 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5137 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5138 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5139 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5140 // [`crate::aplicacao::Entrada::destination`] at the M3
5141 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5142 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5143 // M2 supervisor-tree axis,
5144 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5145 // M2 upgrade axis, and the per-`:contratos`
5146 // [`crate::aplicacao::WitContract::source`] /
5147 // [`crate::aplicacao::WitContract::destination`] /
5148 // [`crate::aplicacao::WitContract::world_ref`] trio the
5149 // sibling pin at 279823b already anchors).
5150 const fn nome_via_const_fn(d: &Dep) -> &str {
5151 d.nome()
5152 }
5153 const fn versao_via_const_fn(d: &Dep) -> &str {
5154 d.versao_requirement()
5155 }
5156 for (nome, versao) in [
5157 ("caixa-teia", "^0.1"),
5158 ("caixa-mesh", "~0.2.3"),
5159 ("caixa-helm", "*"),
5160 ] {
5161 let d = Dep::simple(nome, versao);
5162 assert_eq!(nome_via_const_fn(&d), d.nome());
5163 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5164 assert_eq!(d.nome(), nome);
5165 assert_eq!(d.versao_requirement(), versao);
5166 }
5167 }
5168
5169 #[test]
5170 fn dep_outer_accessor_family_is_const_fn() {
5171 // Fail-before-pass-after pin on [`Dep::fonte`] +
5172 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5173 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5174 // entry's composite / list storage through a `pub const fn`
5175 // stdlib method (`Option::<DepSource>::as_ref` /
5176 // `Vec::<String>::as_slice`, both const-stable since Rust
5177 // 1.83, well within the workspace MSRV). Any future
5178 // accidental downgrade to non-`const` fails the corresponding
5179 // `<name>_via_const_fn` wrapper at caixa-core build time with
5180 // E0015 (`cannot call non-const method`), strictly stronger
5181 // than a runtime `assert!` and side-stepping the destructor-
5182 // in-const restriction the `Dep` fixture's `String` /
5183 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5184 // direct-`const _: () = assert!(...)` residence.
5185 //
5186 // Peer of the sibling per-`Dep` scalar-accessor pair pin
5187 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5188 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5189 // the `const`-eval-surface discipline onto the composite-
5190 // reference and slice-return arms of the outer-`Dep` accessor
5191 // family, closing the four-slot outer surface (`:nome` +
5192 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5193 // posture. The `:opcional` `bool` arm already carries the
5194 // posture through [`Dep::opcional`]'s prior `pub const fn`
5195 // declaration, so this pin lands the last two unlifted
5196 // outer-`Dep` accessors and closes the family.
5197 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5198 d.fonte()
5199 }
5200 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5201 d.caracteristicas()
5202 }
5203 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5204 let empty = Dep::simple("caixa-teia", "^0.1");
5205 assert!(fonte_via_const_fn(&empty).is_none());
5206 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5207 assert!(caracteristicas_via_const_fn(&empty).is_empty());
5208 assert_eq!(
5209 caracteristicas_via_const_fn(&empty),
5210 empty.caracteristicas()
5211 );
5212 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5213 // still empty.
5214 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5215 assert!(fonte_via_const_fn(&git).is_some());
5216 assert_eq!(fonte_via_const_fn(&git), git.fonte());
5217 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5218 // Populated `:caracteristicas` — exercise the non-empty
5219 // slice-view arm to pin the accessor's borrow shape against
5220 // both a `Vec::new()` empty backing buffer and a populated one.
5221 let mut with_features = Dep::simple("caixa-teia", "^0.1");
5222 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5223 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5224 assert_eq!(
5225 caracteristicas_via_const_fn(&with_features),
5226 with_features.caracteristicas()
5227 );
5228 }
5229
5230 #[test]
5231 fn git_dep_carries_tag() {
5232 let d = Dep::git("t", "*", "github:o/r", "v1");
5233 match d.fonte {
5234 Some(DepSource::Git {
5235 ref repo, ref tag, ..
5236 }) => {
5237 assert_eq!(repo, "github:o/r");
5238 assert_eq!(tag.as_deref(), Some("v1"));
5239 }
5240 _ => panic!("expected Git source"),
5241 }
5242 }
5243
5244 #[test]
5245 fn validate_accepts_simple_dep() {
5246 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5247 }
5248
5249 #[test]
5250 fn validate_rejects_empty_nome() {
5251 // The fail-before-pass-after pin for `:nome ""`: the empty-name
5252 // arm fires first so the per-entry parse-side diagnostic doesn't
5253 // emit a useless `nome: ""` reference.
5254 let mut d = Dep::simple("placeholder", "^0.1");
5255 d.nome = String::new();
5256 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5257 }
5258
5259 #[test]
5260 fn validate_rejects_empty_versao() {
5261 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5262 // semver crate accepts the empty string as a wildcard match),
5263 // so the empty-`:versao` arm is structurally necessary even
5264 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5265 // `EmptyChildVersion` ordering on the other two `:versao` axes.
5266 let mut d = Dep::simple("caixa-teia", "ignored");
5267 d.versao = String::new();
5268 let err = d.validate().unwrap_err();
5269 assert!(
5270 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5271 "got {err:?}"
5272 );
5273 }
5274
5275 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5276
5277 #[test]
5278 fn validate_rejects_nome_with_uppercase() {
5279 // The fail-before-pass-after pin: a non-empty but uppercase
5280 // `:nome` silently passed `validate()` on every pre-gate
5281 // codebase because the prior shape only refused the empty
5282 // string. The DNS-1123 violation surfaced far downstream at
5283 // lacre-resolve time when the *target* caixa's `:nome` failed
5284 // its own gate — far from the `:deps` entry, with a diagnostic
5285 // naming the target rather than the dep entry that referenced
5286 // it. Same fail-before-pass-after fixture pinned for
5287 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5288 // and Caixa `:nome` (6c992f8).
5289 let d = Dep::simple("Caixa-Teia", "^0.1");
5290 let err = d.validate().unwrap_err();
5291 assert!(
5292 matches!(
5293 err,
5294 DepError::NomeInvalid { ref nome, ref reason }
5295 if nome == "Caixa-Teia" && reason.contains("uppercase")
5296 ),
5297 "got {err:?}"
5298 );
5299 }
5300
5301 #[test]
5302 fn validate_rejects_nome_with_underscore() {
5303 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5304 // "I'm thinking of Go module names / Python identifiers" leak.
5305 // Same fixture pinned for the peer caixa-identifier axes.
5306 let d = Dep::simple("caixa_teia", "^0.1");
5307 let err = d.validate().unwrap_err();
5308 assert!(
5309 matches!(
5310 err,
5311 DepError::NomeInvalid { ref nome, ref reason }
5312 if nome == "caixa_teia" && reason.contains('_')
5313 ),
5314 "got {err:?}"
5315 );
5316 }
5317
5318 #[test]
5319 fn validate_rejects_nome_with_dot() {
5320 // A `:deps :nome` is a single DNS-1123 *label*, not a
5321 // subdomain — dots are rejected. The `"caixa.teia"` shape is
5322 // the canonical "I confused the dep name with the FQDN /
5323 // namespace" footgun, distinct from the legitimate
5324 // `:fonte :repo "github:org/caixa-teia"` axis.
5325 let d = Dep::simple("caixa.teia", "^0.1");
5326 let err = d.validate().unwrap_err();
5327 assert!(
5328 matches!(
5329 err,
5330 DepError::NomeInvalid { ref nome, ref reason }
5331 if nome == "caixa.teia" && reason.contains('.')
5332 ),
5333 "got {err:?}"
5334 );
5335 }
5336
5337 #[test]
5338 fn validate_rejects_nome_with_leading_hyphen() {
5339 // RFC 1123 requires alphanumeric at both label boundaries.
5340 // Pinned in parity with the peer DNS-1123 fixtures.
5341 let d = Dep::simple("-caixa-teia", "^0.1");
5342 let err = d.validate().unwrap_err();
5343 assert!(
5344 matches!(
5345 err,
5346 DepError::NomeInvalid { ref nome, ref reason }
5347 if nome == "-caixa-teia" && reason.contains("alphanumeric")
5348 ),
5349 "got {err:?}"
5350 );
5351 }
5352
5353 #[test]
5354 fn validate_rejects_nome_with_trailing_hyphen() {
5355 let d = Dep::simple("caixa-teia-", "^0.1");
5356 let err = d.validate().unwrap_err();
5357 assert!(
5358 matches!(
5359 err,
5360 DepError::NomeInvalid { ref nome, ref reason }
5361 if nome == "caixa-teia-" && reason.contains("alphanumeric")
5362 ),
5363 "got {err:?}"
5364 );
5365 }
5366
5367 #[test]
5368 fn validate_rejects_nome_with_slash() {
5369 // The canonical "I copied the GitHub repo path into `:nome`
5370 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5371 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5372 // the local-name slot. Same fixture pinned for `:membros
5373 // :caixa` (3f9d7a0).
5374 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5375 let err = d.validate().unwrap_err();
5376 assert!(
5377 matches!(
5378 err,
5379 DepError::NomeInvalid { ref nome, ref reason }
5380 if nome == "pleme-io/caixa-teia" && reason.contains('/')
5381 ),
5382 "got {err:?}"
5383 );
5384 }
5385
5386 #[test]
5387 fn validate_rejects_nome_too_long() {
5388 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5389 // Built from a valid character set so the length-bound
5390 // diagnostic surfaces before any per-character check (the
5391 // order pin parallel to the per-character predicates inside
5392 // [`crate::render::is_dns_1123_label`]).
5393 let long = "a".repeat(64);
5394 let d = Dep::simple(&long, "^0.1");
5395 let err = d.validate().unwrap_err();
5396 assert!(
5397 matches!(
5398 err,
5399 DepError::NomeInvalid { ref nome, ref reason }
5400 if nome.len() == 64 && reason.contains("max length of 63")
5401 ),
5402 "got {err:?}"
5403 );
5404 }
5405
5406 #[test]
5407 fn validate_accepts_canonical_nome_labels() {
5408 // Positive-control sweep — every form the K8s apiserver
5409 // accepts as a DNS-1123 label must round-trip through
5410 // validate. Covers a hyphen-bearing label, a numeric-suffix
5411 // label, a leading-digit label, a single-character label, and
5412 // a 63-byte (exactly the cap) label — the same fixture set
5413 // the peer `:membros :caixa` / `:children :caixa` positive
5414 // controls pin.
5415 for nome in [
5416 "caixa-teia",
5417 "caixa-resolver2",
5418 "2nd-tier-cache",
5419 "x",
5420 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5421 ] {
5422 Dep::simple(nome, "^0.1")
5423 .validate()
5424 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5425 }
5426 }
5427
5428 #[test]
5429 fn nome_empty_takes_precedence_over_nome_invalid() {
5430 // Ordering pin: `NomeEmpty` is the more self-locating
5431 // diagnostic on `""` and must lead — `is_dns_1123_label` is
5432 // only reached after the empty-check fires at the call site.
5433 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5434 // (3f9d7a0) on the peer caixa-identifier axis.
5435 let mut d = Dep::simple("placeholder", "^0.1");
5436 d.nome = String::new();
5437 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5438 }
5439
5440 #[test]
5441 fn nome_invalid_fires_before_versao_empty() {
5442 // Ordering pin: a malformed `:nome` fires before any `:versao`
5443 // axis check on the *same* entry — the per-entry shape gates
5444 // run top-to-bottom (nome empty → nome shape → versao empty →
5445 // versao parse → fonte shape), so a one-entry caixa.lisp with
5446 // both wrong sees the name-side diagnostic first (the name is
5447 // the self-locating axis — without a valid name, the parse
5448 // diagnostic can't quote `:nome "<bad>"`). Same ordering
5449 // discipline as `membro_caixa_invalid_fires_before_versao_check`
5450 // (3f9d7a0).
5451 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5452 d.versao = String::new();
5453 let err = d.validate().unwrap_err();
5454 assert!(
5455 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5456 "got {err:?}"
5457 );
5458 }
5459
5460 #[test]
5461 fn nome_invalid_fires_before_versao_invalid() {
5462 // Ordering pin: a malformed `:nome` fires before the `:versao`
5463 // parse-side check on the *same* entry. Pin separately from
5464 // the empty-versao ordering so a future re-ordering surfaces
5465 // here, parallel to the b0c8389 / c4213a4 trajectory.
5466 let d = Dep::simple("Caixa-Teia", "^^0.1");
5467 let err = d.validate().unwrap_err();
5468 assert!(
5469 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5470 "got {err:?}"
5471 );
5472 }
5473
5474 #[test]
5475 fn nome_invalid_fires_before_fonte_invalid() {
5476 // Ordering pin: a malformed `:nome` fires before the `:fonte`
5477 // shape check on the *same* entry. The `:fonte` diagnostic
5478 // names the offending dep's `:nome` verbatim (via
5479 // `DepSource::validate(&self.nome)`), so a non-self-locating
5480 // name would taint the downstream diagnostic too — the gate
5481 // ordering keeps both diagnostics individually self-locating.
5482 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5483 d.fonte = Some(DepSource::Git {
5484 repo: String::new(),
5485 tag: None,
5486 rev: None,
5487 branch: None,
5488 });
5489 let err = d.validate().unwrap_err();
5490 assert!(
5491 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5492 "got {err:?}"
5493 );
5494 }
5495
5496 #[test]
5497 fn nome_invalid_diagnostic_carries_offending_name() {
5498 // The diagnostic-shape pin: the error names the offending
5499 // `:nome` value verbatim so the author can grep their
5500 // caixa.lisp without re-running the build, and carries a
5501 // non-empty `reason` from `is_dns_1123_label` so the
5502 // predicate's own wording flows through to the diagnostic.
5503 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5504 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5505 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5506 // share a structurally-equivalent diagnostic family.
5507 let d = Dep::simple("Caixa_Teia", "^0.1");
5508 let err = d.validate().unwrap_err();
5509 let DepError::NomeInvalid { nome, reason } = err else {
5510 panic!("expected NomeInvalid, got other variant");
5511 };
5512 assert_eq!(nome, "Caixa_Teia");
5513 assert!(
5514 !reason.is_empty(),
5515 "NomeInvalid `reason` must carry the predicate's wording verbatim"
5516 );
5517 }
5518
5519 #[test]
5520 fn validate_rejects_invalid_versao_requirement() {
5521 // The fail-before-pass-after pin: a non-empty but malformed
5522 // requirement (`"^bad-version"`) silently passed every pre-gate
5523 // codebase because `:deps :versao` wasn't validated. The parse
5524 // failure surfaced far downstream at lacre-resolve time with a
5525 // `semver::Error` that didn't name which `:deps` entry carried
5526 // the typo. The new gate moves the check to caixa-build time
5527 // at the source caixa.lisp.
5528 let d = Dep::simple("caixa-teia", "^bad-version");
5529 let err = d.validate().unwrap_err();
5530 assert!(
5531 matches!(
5532 err,
5533 DepError::VersaoInvalid { ref nome, ref versao, .. }
5534 if nome == "caixa-teia" && versao == "^bad-version"
5535 ),
5536 "got {err:?}"
5537 );
5538 }
5539
5540 #[test]
5541 fn validate_rejects_versao_with_double_caret_typo() {
5542 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5543 // Cargo-shaped requirement on first glance but fails the parser
5544 // because semver doesn't accept stacked operators. Pin this
5545 // adjacent-shape footgun explicitly so a future relaxation that
5546 // accepts "looks-canonical-but-isn't" forms surfaces here, in
5547 // parity with the `:membros` / `:children` fixtures.
5548 let d = Dep::simple("caixa-teia", "^^0.1");
5549 let err = d.validate().unwrap_err();
5550 assert!(
5551 matches!(
5552 err,
5553 DepError::VersaoInvalid { ref nome, ref versao, .. }
5554 if nome == "caixa-teia" && versao == "^^0.1"
5555 ),
5556 "got {err:?}"
5557 );
5558 }
5559
5560 #[test]
5561 fn validate_rejects_versao_with_v_prefixed_tag() {
5562 // `"v0.1"` is the canonical "git-tag-shape leaking into the
5563 // semver requirement slot" typo — an author copies the
5564 // publish-side git-tag string verbatim into `:versao`, but
5565 // Cargo's semver parser rejects the leading `v`. Same fixture
5566 // pinned for `:membros :versao` (9888b13) and `:children
5567 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5568 // are *accepted* by the semver crate as an `*` wildcard on the
5569 // patch axis — they're a Cargo-side valid shape, not a typo.)
5570 let d = Dep::simple("caixa-teia", "v0.1");
5571 let err = d.validate().unwrap_err();
5572 assert!(
5573 matches!(
5574 err,
5575 DepError::VersaoInvalid { ref nome, ref versao, .. }
5576 if nome == "caixa-teia" && versao == "v0.1"
5577 ),
5578 "got {err:?}"
5579 );
5580 }
5581
5582 #[test]
5583 fn validate_accepts_canonical_versao_forms() {
5584 // The five Cargo-shaped requirement forms `:membros :versao`
5585 // and `:children :versao` already accept via
5586 // `crate::parse_requirement` must pass the deps gate without
5587 // re-validating at the resolver layer. Pin every leg so a
5588 // future tightening of the canonical set surfaces here as a
5589 // test failure.
5590 for form in [
5591 "^0.1", // caret — minor-range pin (the most common shape)
5592 "~0.1.2", // tilde — patch-range pin
5593 "0.1.0", // exact — single-version pin
5594 "*", // wildcard — explicitly any-version
5595 ">=0.1, <2", // multi-range — comma-separated comparators
5596 ] {
5597 Dep::simple("caixa-teia", form)
5598 .validate()
5599 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5600 }
5601 }
5602
5603 #[test]
5604 fn versao_empty_takes_precedence_over_invalid() {
5605 // Order pin: the existing `VersaoEmpty` diagnostic (which
5606 // doesn't try to parse) fires before the new `VersaoInvalid`
5607 // parse-side diagnostic, so an empty `:versao` keeps its
5608 // narrower error message — `parse_requirement("")` would
5609 // otherwise return `Ok(STAR)` and silently pass, but the empty
5610 // arm catches it first.
5611 let mut d = Dep::simple("caixa-teia", "ignored");
5612 d.versao = String::new();
5613 let err = d.validate().unwrap_err();
5614 assert!(
5615 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5616 "got {err:?}"
5617 );
5618 }
5619
5620 #[test]
5621 fn nome_empty_takes_precedence_over_versao_invalid() {
5622 // Order pin: even when `:versao` is malformed and would raise
5623 // its own diagnostic, `:nome ""` fires first because the
5624 // per-entry parse diagnostic needs a non-empty name to be
5625 // self-locating. Mirrors the
5626 // `membros_validation_runs_before_contratos_membership_check`
5627 // ordering on the typed-graph layer.
5628 let mut d = Dep::simple("placeholder", "^bad");
5629 d.nome = String::new();
5630 let err = d.validate().unwrap_err();
5631 assert_eq!(err, DepError::NomeEmpty);
5632 }
5633
5634 #[test]
5635 fn versao_invalid_diagnostic_carries_offending_versao() {
5636 // The diagnostic-shape pin: the error names the offending
5637 // `:versao` value verbatim so the author can grep their
5638 // caixa.lisp without re-running the build, and carries a
5639 // non-empty `reason` from `semver::VersionReq::parse` so the
5640 // parser's own wording flows through to the diagnostic.
5641 let d = Dep::simple("caixa-teia", "not-a-req");
5642 let err = d.validate().unwrap_err();
5643 let DepError::VersaoInvalid {
5644 nome,
5645 versao,
5646 reason,
5647 } = err
5648 else {
5649 panic!("expected VersaoInvalid, got other variant");
5650 };
5651 assert_eq!(nome, "caixa-teia");
5652 assert_eq!(versao, "not-a-req");
5653 assert!(
5654 !reason.is_empty(),
5655 "VersaoInvalid `reason` must carry the parser's wording verbatim"
5656 );
5657 }
5658
5659 // -- :fonte value-shape gate ------------------------------------------
5660
5661 fn dep_with_fonte(fonte: DepSource) -> Dep {
5662 let mut d = Dep::simple("caixa-teia", "^0.1");
5663 d.fonte = Some(fonte);
5664 d
5665 }
5666
5667 #[test]
5668 fn validate_accepts_git_fonte_with_tag() {
5669 // The positive-control pin on the canonical git source — exactly
5670 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5671 // shape every existing caixa-resolver integration test uses.
5672 let d = dep_with_fonte(DepSource::Git {
5673 repo: "github:pleme-io/caixa-teia".into(),
5674 tag: Some("v0.1.0".into()),
5675 rev: None,
5676 branch: None,
5677 });
5678 d.validate().unwrap();
5679 }
5680
5681 #[test]
5682 fn validate_accepts_git_fonte_with_rev() {
5683 // Each of the three pin axes is independently a valid single-pin
5684 // shape; pin the :rev arm so a future relaxation that only
5685 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5686 // OID — the canonical `git rev-parse HEAD` emission shape the
5687 // `crate::render::is_git_oid` value-shape gate now requires;
5688 // abbreviated OIDs are ambiguous across repo history and
5689 // rejected at this gate (pinned separately by
5690 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5691 let d = dep_with_fonte(DepSource::Git {
5692 repo: "github:pleme-io/caixa-teia".into(),
5693 tag: None,
5694 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5695 branch: None,
5696 });
5697 d.validate().unwrap();
5698 }
5699
5700 #[test]
5701 fn validate_accepts_git_fonte_with_branch() {
5702 // The :branch arm is the third valid single-pin shape — pinned
5703 // separately so the gate-accepts-all-three-pin-axes contract is
5704 // a build-error to relax.
5705 let d = dep_with_fonte(DepSource::Git {
5706 repo: "github:pleme-io/caixa-teia".into(),
5707 tag: None,
5708 rev: None,
5709 branch: Some("main".into()),
5710 });
5711 d.validate().unwrap();
5712 }
5713
5714 #[test]
5715 fn validate_accepts_path_fonte() {
5716 // The positive-control pin on the path source — non-empty
5717 // :caminho, no pin axes (paths have no commit identity). Pinned
5718 // so a future "paths must also pin a rev" tightening surfaces
5719 // here as a structural decision, not a silent break.
5720 let d = dep_with_fonte(DepSource::Path {
5721 caminho: "../caixa-teia".into(),
5722 });
5723 d.validate().unwrap();
5724 }
5725
5726 #[test]
5727 fn validate_rejects_git_fonte_with_empty_repo() {
5728 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5729 // "v1")`: the empty-repo shape silently passed every pre-gate
5730 // codebase because `:fonte` wasn't validated. The git-clone
5731 // failure surfaced far downstream at lacre-resolve time with no
5732 // field naming which `:deps` entry carried the typo. The new
5733 // gate moves the check to caixa-build time at the source
5734 // caixa.lisp.
5735 let d = dep_with_fonte(DepSource::Git {
5736 repo: String::new(),
5737 tag: Some("v0.1.0".into()),
5738 rev: None,
5739 branch: None,
5740 });
5741 let err = d.validate().unwrap_err();
5742 assert!(
5743 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5744 "got {err:?}"
5745 );
5746 }
5747
5748 // -- :repo value-shape gate -------------------------------------------
5749 //
5750 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5751 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5752 // codebase admitted any non-empty string; the new
5753 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5754 // URL intersection-floor at validate time, peer with the three pin
5755 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5756 // `is_git_oid`). Every test in this section is a fail-before /
5757 // pass-after pin on a specific authoring footgun.
5758
5759 #[test]
5760 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5761 // The canonical paste-from-doc footgun on `:repo` — an author
5762 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5763 // a doc paragraph. Until this gate landed the empty-repo arm
5764 // passed (the string isn't empty), the resolver issued
5765 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5766 // surfaced at clone time with a quoting-confused error far from
5767 // the source caixa.lisp. Same paste-from-doc footgun the
5768 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5769 // axis — now closed on the `:repo` URL axis too.
5770 let d = dep_with_fonte(DepSource::Git {
5771 repo: "github:pleme-io/caixa-teia ".into(),
5772 tag: Some("v0.1.0".into()),
5773 rev: None,
5774 branch: None,
5775 });
5776 let err = d.validate().unwrap_err();
5777 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5778 panic!("expected FonteRepoShape, got other variant");
5779 };
5780 assert_eq!(nome, "caixa-teia");
5781 assert_eq!(repo, "github:pleme-io/caixa-teia ");
5782 assert!(
5783 reason.contains("whitespace"),
5784 "reason must surface the whitespace arm, got {reason:?}"
5785 );
5786 }
5787
5788 #[test]
5789 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5790 // The canonical CLI-argument-injection footgun at the `git clone`
5791 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5792 // argv parser read the value as a CLI flag, escaping the
5793 // subprocess argument boundary. The `--` separator workaround
5794 // does not fix the typed slot's accepted set; the gate rejects
5795 // the shape upstream at validate time so the resolver never
5796 // invokes a `git clone -…` subprocess.
5797 let d = dep_with_fonte(DepSource::Git {
5798 repo: "-upload-pack=evil".into(),
5799 tag: Some("v0.1.0".into()),
5800 rev: None,
5801 branch: None,
5802 });
5803 let err = d.validate().unwrap_err();
5804 let DepError::FonteRepoShape { repo, reason, .. } = err else {
5805 panic!("expected FonteRepoShape, got other variant");
5806 };
5807 assert_eq!(repo, "-upload-pack=evil");
5808 assert!(
5809 reason.contains("must not start with `-`"),
5810 "reason must surface the leading-`-` arm, got {reason:?}"
5811 );
5812 }
5813
5814 #[test]
5815 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5816 // The canonical paste-from-multiline-doc footgun — a `:repo`
5817 // string with an embedded `\n` silently breaks git's URL parser
5818 // and is a class of CRLF-injection at the subprocess-argument
5819 // boundary. Caught by the control-char arm (0x0A < 0x20).
5820 let d = dep_with_fonte(DepSource::Git {
5821 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5822 tag: Some("v0.1.0".into()),
5823 rev: None,
5824 branch: None,
5825 });
5826 let err = d.validate().unwrap_err();
5827 let DepError::FonteRepoShape { reason, .. } = err else {
5828 panic!("expected FonteRepoShape, got other variant");
5829 };
5830 assert!(
5831 reason.contains("control character"),
5832 "reason must surface the control-char arm, got {reason:?}"
5833 );
5834 }
5835
5836 #[test]
5837 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5838 // Tab is the sibling whitespace footgun (the canonical
5839 // copy-from-aligned-table paste); pinned separately from the
5840 // space arm so a future relaxation that only catches one
5841 // surfaces here.
5842 let d = dep_with_fonte(DepSource::Git {
5843 repo: "github:pleme-io/caixa-teia\t".into(),
5844 tag: Some("v0.1.0".into()),
5845 rev: None,
5846 branch: None,
5847 });
5848 let err = d.validate().unwrap_err();
5849 assert!(
5850 matches!(
5851 err,
5852 DepError::FonteRepoShape { ref reason, .. }
5853 if reason.contains("whitespace")
5854 ),
5855 "got {err:?}"
5856 );
5857 }
5858
5859 #[test]
5860 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
5861 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
5862 // non-ASCII silently breaks at git's URL parser and round-trips
5863 // inconsistently across NFC/NFD normalization on APFS /
5864 // case-folding filesystems. Same intersection-floor
5865 // [`is_git_ref_name`] enforces on the refname axes.
5866 let d = dep_with_fonte(DepSource::Git {
5867 repo: "https://github.com/pleme-io/café".into(),
5868 tag: Some("v0.1.0".into()),
5869 rev: None,
5870 branch: None,
5871 });
5872 let err = d.validate().unwrap_err();
5873 assert!(
5874 matches!(
5875 err,
5876 DepError::FonteRepoShape { ref reason, .. }
5877 if reason.contains("non-ASCII")
5878 ),
5879 "got {err:?}"
5880 );
5881 }
5882
5883 #[test]
5884 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
5885 // The fail-before-pass-after pin for the canonical paste-from-
5886 // browser-address-bar footgun on `:repo`: an author copies a
5887 // GitHub permalink to a README anchor / line-permalink and
5888 // forgets to trim the `#fragment` tail. Until this arm landed
5889 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
5890 // silently passed every prior arm (no whitespace, no control
5891 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
5892 // or `:`), libcurl's URL parser stripped the `#readme` tail
5893 // before opening the HTTPS transport, and the lacre embedded
5894 // the value verbatim in its per-dep BLAKE3 closure — two
5895 // authors whose values differ only in their fragment anchor
5896 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
5897 // `git clone` but lock to two distinct lacres, defeating the
5898 // THEORY.md §V.2 render-determinism contract. Same value-shape
5899 // axis-floor every peer typed surface enforces; peer `:fonte
5900 // :tag` / `:fonte :branch` already reject the byte-class through
5901 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
5902 // URL grammar admitted) and `:entrada :paths` rejects `#` as
5903 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
5904 let d = dep_with_fonte(DepSource::Git {
5905 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
5906 tag: Some("v0.1.0".into()),
5907 rev: None,
5908 branch: None,
5909 });
5910 let err = d.validate().unwrap_err();
5911 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5912 panic!("expected FonteRepoShape, got other variant");
5913 };
5914 assert_eq!(nome, "caixa-teia");
5915 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
5916 assert!(
5917 reason.contains("must not contain `#`"),
5918 "reason must surface the fragment-`#` arm, got {reason:?}"
5919 );
5920 assert!(
5921 reason.contains("fragment"),
5922 "reason must name the URL fragment grammar, got {reason:?}"
5923 );
5924 }
5925
5926 #[test]
5927 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
5928 // The symmetric paste-from-Nix-flake-ref footgun — an author
5929 // confuses the Nix flake-reference idiom (`github:foo/
5930 // bar#packageName`, where `#packageName` selects a flake
5931 // output) with the bare git `:repo` shape. The pleme-io
5932 // substrate authors compose flakes downstream of caixa
5933 // (caixa-flake renders a flake.nix), so the cross-idiom leak
5934 // is the canonical near-miss: the author writes the
5935 // flake-ref shape into a git `:repo` slot. Pinned separately
5936 // from the HTTPS-anchor arm so a future relaxation that
5937 // narrows to one URL scheme surfaces here.
5938 let d = dep_with_fonte(DepSource::Git {
5939 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
5940 tag: Some("v0.1.0".into()),
5941 rev: None,
5942 branch: None,
5943 });
5944 let err = d.validate().unwrap_err();
5945 let DepError::FonteRepoShape { reason, .. } = err else {
5946 panic!("expected FonteRepoShape, got other variant");
5947 };
5948 assert!(
5949 reason.contains("must not contain `#`"),
5950 "reason must surface the fragment-`#` arm, got {reason:?}"
5951 );
5952 assert!(
5953 reason.contains("Nix flake"),
5954 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
5955 );
5956 }
5957
5958 #[test]
5959 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
5960 // The fail-before-pass-after pin for the canonical paste-from-
5961 // browser-address-bar footgun on `:repo` (peer with the
5962 // a68f818 fragment-`#` arm on the same axis). An author
5963 // copies a GitHub tab deep-link out of the address bar and
5964 // forgets to trim the `?tab=…` query tail. Until this arm
5965 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
5966 // silently passed every prior arm (no whitespace, no control
5967 // chars, no non-ASCII, no `#` fragment, contains a `:`,
5968 // doesn't start with `-` or `:`); GitHub silently ignored
5969 // the `?query` tail and served the same repo regardless;
5970 // the lacre embedded the value verbatim in its per-dep
5971 // BLAKE3 closure — two authors whose values differ only in
5972 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
5973 // `?utm_source=twitter`) resolve to the byte-identical
5974 // upstream `git clone` but lock to two distinct lacres,
5975 // defeating the THEORY.md §V.2 render-determinism contract
5976 // on the same axis the `#` fragment arm closes. Same value-
5977 // shape axis-floor every peer typed surface enforces; peer
5978 // `:fonte :tag` / `:fonte :branch` already reject the byte-
5979 // class through `is_git_ref_name`'s alphabet (refspec glob
5980 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
5981 // :paths` rejects `?` as the query separator in
5982 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
5983 let d = dep_with_fonte(DepSource::Git {
5984 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
5985 tag: Some("v0.1.0".into()),
5986 rev: None,
5987 branch: None,
5988 });
5989 let err = d.validate().unwrap_err();
5990 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5991 panic!("expected FonteRepoShape, got other variant");
5992 };
5993 assert_eq!(nome, "caixa-teia");
5994 assert_eq!(
5995 repo,
5996 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
5997 );
5998 assert!(
5999 reason.contains("must not contain `?`"),
6000 "reason must surface the query-`?` arm, got {reason:?}"
6001 );
6002 assert!(
6003 reason.contains("query"),
6004 "reason must name the URL query grammar, got {reason:?}"
6005 );
6006 }
6007
6008 #[test]
6009 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6010 // The symmetric paste-from-social-share footgun — an author
6011 // copies a repo URL out of a Slack unfurl / Twitter share /
6012 // newsletter link / Discord embed and forgets to trim the
6013 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6014 // campaign-tracker tail. Every major social-share / unfurl /
6015 // newsletter platform appends these UTM parameters; the
6016 // canonical near-miss on the `:repo` axis. Pinned separately
6017 // from the GitHub-tab-deep-link arm so a future relaxation
6018 // that narrows to one query-parameter class surfaces here.
6019 let d = dep_with_fonte(DepSource::Git {
6020 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6021 .into(),
6022 tag: Some("v0.1.0".into()),
6023 rev: None,
6024 branch: None,
6025 });
6026 let err = d.validate().unwrap_err();
6027 let DepError::FonteRepoShape { reason, .. } = err else {
6028 panic!("expected FonteRepoShape, got other variant");
6029 };
6030 assert!(
6031 reason.contains("must not contain `?`"),
6032 "reason must surface the query-`?` arm, got {reason:?}"
6033 );
6034 assert!(
6035 reason.contains("campaign-tracker"),
6036 "reason must name the campaign-tracker paste footgun, got {reason:?}"
6037 );
6038 }
6039
6040 #[test]
6041 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6042 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6043 // both per-byte arms inside the same `for &b in s.as_bytes()`
6044 // loop, so the byte that appears first in the value's byte
6045 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6046 // (fragment before query — unusual URL-grammar but value-
6047 // disjoint at byte level) carries both `#` and `?`; the `#`
6048 // byte appears first, so the fragment-`#` arm fires, surfacing
6049 // the more self-locating diagnostic on the byte the author
6050 // pasted earliest in the URL. Mirrors the peer cascade
6051 // discipline `fonte_repo_control_char_fires_before_fragment`
6052 // pins on the prior `:repo` byte-class arm.
6053 let d = dep_with_fonte(DepSource::Git {
6054 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6055 tag: Some("v0.1.0".into()),
6056 rev: None,
6057 branch: None,
6058 });
6059 let err = d.validate().unwrap_err();
6060 let DepError::FonteRepoShape { reason, .. } = err else {
6061 panic!("expected FonteRepoShape, got other variant");
6062 };
6063 assert!(
6064 reason.contains("must not contain `#`"),
6065 "reason must surface the fragment-`#` arm (fires before query-`?` when \
6066 `#` byte appears first in value), got {reason:?}"
6067 );
6068 }
6069
6070 #[test]
6071 fn fonte_repo_control_char_fires_before_fragment() {
6072 // Cascade pin: the control-char arm structurally precedes the
6073 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6074 // positive on both arms (contains LF and `#`), but the narrower
6075 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6076 // (`control character`) wins so the author sees the more
6077 // self-locating arm first. Mirrors the peer cascade discipline
6078 // every prior `:repo` byte-class arm establishes.
6079 let d = dep_with_fonte(DepSource::Git {
6080 repo: "github:pleme-io/caixa-teia\n#readme".into(),
6081 tag: Some("v0.1.0".into()),
6082 rev: None,
6083 branch: None,
6084 });
6085 let err = d.validate().unwrap_err();
6086 let DepError::FonteRepoShape { reason, .. } = err else {
6087 panic!("expected FonteRepoShape, got other variant");
6088 };
6089 assert!(
6090 reason.contains("control character"),
6091 "reason must surface the control-char arm, got {reason:?}"
6092 );
6093 }
6094
6095 #[test]
6096 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6097 // The fail-before-pass-after pin for the canonical Windows-
6098 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6099 // backslash arm on the sibling `:caminho` path-fonte axis).
6100 // An author pastes a Windows Explorer address-bar / PowerShell
6101 // `Get-Location` output into a `file://` URL slot, producing
6102 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6103 // value silently passed every prior arm (no whitespace, no
6104 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6105 // with `-` or `:`); libcurl's URL parser silently translates
6106 // `\` → `/` on some platforms and refuses it on others, so
6107 // the byte rides verbatim into the lacre's per-dep content-
6108 // address but is silently rewritten / rejected at the wire —
6109 // two authors whose `:repo` values differ only in backslash-
6110 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6111 // resolve to the byte-identical local clone but lock to two
6112 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6113 // render-determinism contract on the same axis the `#`
6114 // fragment and `?` query arms close. Same value-shape axis-
6115 // floor every peer typed surface enforces; the `:caminho`
6116 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6117 let d = dep_with_fonte(DepSource::Git {
6118 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6119 tag: Some("v0.1.0".into()),
6120 rev: None,
6121 branch: None,
6122 });
6123 let err = d.validate().unwrap_err();
6124 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6125 panic!("expected FonteRepoShape, got other variant");
6126 };
6127 assert_eq!(nome, "caixa-teia");
6128 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6129 assert!(
6130 reason.contains("must not contain `\\`"),
6131 "reason must surface the backslash-`\\` arm, got {reason:?}"
6132 );
6133 assert!(
6134 reason.contains("Windows"),
6135 "reason must name the Windows-path-confusion footgun, got {reason:?}"
6136 );
6137 }
6138
6139 #[test]
6140 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6141 // The symmetric Win32-shell-mangled-slashes footgun — an author
6142 // copies `https://github.com/foo/bar` into a Win32 shell that
6143 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6144 // separator-coercion bug), pastes the result into a `:repo`
6145 // slot, and produces `https:\\github.com\foo\bar`. Pinned
6146 // separately from the `file://` Explorer-paste arm so a future
6147 // relaxation that narrows to one URL scheme surfaces here.
6148 let d = dep_with_fonte(DepSource::Git {
6149 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6150 tag: Some("v0.1.0".into()),
6151 rev: None,
6152 branch: None,
6153 });
6154 let err = d.validate().unwrap_err();
6155 let DepError::FonteRepoShape { reason, .. } = err else {
6156 panic!("expected FonteRepoShape, got other variant");
6157 };
6158 assert!(
6159 reason.contains("must not contain `\\`"),
6160 "reason must surface the backslash-`\\` arm, got {reason:?}"
6161 );
6162 assert!(
6163 reason.contains("path separator") || reason.contains("path-segment separator"),
6164 "reason must name the URL path-segment separator grammar, got {reason:?}"
6165 );
6166 }
6167
6168 #[test]
6169 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6170 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6171 // are both per-byte arms inside the same `for &b in s.as_bytes()`
6172 // loop, so the byte that appears first in the value's byte order
6173 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6174 // both `#` and `\`; the `#` byte appears first, so the fragment-
6175 // `#` arm fires, surfacing the more self-locating diagnostic on
6176 // the byte the author pasted earliest in the URL. Mirrors the
6177 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6178 // pins on the prior `:repo` byte-class arm.
6179 let d = dep_with_fonte(DepSource::Git {
6180 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6181 tag: Some("v0.1.0".into()),
6182 rev: None,
6183 branch: None,
6184 });
6185 let err = d.validate().unwrap_err();
6186 let DepError::FonteRepoShape { reason, .. } = err else {
6187 panic!("expected FonteRepoShape, got other variant");
6188 };
6189 assert!(
6190 reason.contains("must not contain `#`"),
6191 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6192 `#` byte appears first in value), got {reason:?}"
6193 );
6194 }
6195
6196 #[test]
6197 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6198 // The fail-before-pass-after pin for the canonical URI Template
6199 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6200 // README quick-start snippet / OpenAPI `servers:` URL / Helm
6201 // chart `home:` template that carries unresolved
6202 // `{org}` / `{repo}` placeholders and pastes the raw template
6203 // into the `:repo` slot, expecting the substrate to resolve the
6204 // placeholder downstream. Until this arm landed the value
6205 // silently passed every prior arm (no whitespace, no control
6206 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6207 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6208 // / `%7D` on the wire, so the byte rides verbatim into the
6209 // lacre's per-dep content-address but round-trips inconsistently
6210 // between the lacre's per-dep content-address and the
6211 // resolver's `git clone <repo>` invocation, defeating the
6212 // THEORY.md §V.2 render-determinism contract on the same axis
6213 // the `#` fragment, `?` query, and `\` backslash arms close;
6214 // every git porcelain entry-point additionally fetches a
6215 // nonexistent literal-`{placeholder}`-named path far from the
6216 // source caixa.lisp.
6217 let d = dep_with_fonte(DepSource::Git {
6218 repo: "https://github.com/{org}/caixa-teia".into(),
6219 tag: Some("v0.1.0".into()),
6220 rev: None,
6221 branch: None,
6222 });
6223 let err = d.validate().unwrap_err();
6224 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6225 panic!("expected FonteRepoShape, got other variant");
6226 };
6227 assert_eq!(nome, "caixa-teia");
6228 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6229 assert!(
6230 reason.contains("must not contain `{`"),
6231 "reason must surface the open-brace `{{` arm, got {reason:?}"
6232 );
6233 assert!(
6234 reason.contains("URI Template") || reason.contains("RFC 6570"),
6235 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6236 );
6237 }
6238
6239 #[test]
6240 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6241 // The symmetric Mustache / Handlebars doubled-brace
6242 // substitution-form footgun every CI / IaC templating engine
6243 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6244 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6245 // chart README quick-start snippet emits. Pinned separately
6246 // from the single-`{` `{org}` arm so a future relaxation that
6247 // narrows to one substitution-form surfaces here.
6248 let d = dep_with_fonte(DepSource::Git {
6249 repo: "https://github.com/{{org}}/caixa-teia".into(),
6250 tag: Some("v0.1.0".into()),
6251 rev: None,
6252 branch: None,
6253 });
6254 let err = d.validate().unwrap_err();
6255 let DepError::FonteRepoShape { reason, .. } = err else {
6256 panic!("expected FonteRepoShape, got other variant");
6257 };
6258 assert!(
6259 reason.contains("must not contain `{`"),
6260 "reason must surface the open-brace `{{` arm, got {reason:?}"
6261 );
6262 }
6263
6264 #[test]
6265 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6266 // Asymmetric `}`-only shape — covers the closing-brace-by-
6267 // itself footgun (an author truncated `{org}/{repo}` mid-edit
6268 // and left a trailing `}` from the prior template fragment,
6269 // or pasted a value that included a closing brace from a
6270 // surrounding shell context). Pinned to ensure the predicate
6271 // refuses each brace independently rather than only when both
6272 // appear — a future regression that ANDs the two byte tests
6273 // surfaces here.
6274 let d = dep_with_fonte(DepSource::Git {
6275 repo: "https://github.com/pleme-io/caixa-teia}".into(),
6276 tag: Some("v0.1.0".into()),
6277 rev: None,
6278 branch: None,
6279 });
6280 let err = d.validate().unwrap_err();
6281 let DepError::FonteRepoShape { reason, .. } = err else {
6282 panic!("expected FonteRepoShape, got other variant");
6283 };
6284 assert!(
6285 reason.contains("must not contain `}`"),
6286 "reason must surface the close-brace `}}` arm, got {reason:?}"
6287 );
6288 }
6289
6290 #[test]
6291 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6292 // Cascade pin: the fragment-`#` arm and the template-`{` /
6293 // `}` arm are both per-byte arms inside the same
6294 // `for &b in s.as_bytes()` loop, so the byte that appears
6295 // first in the value's byte order wins. A `:repo
6296 // "https://github.com/p/x#readme{org}"` carries both `#` and
6297 // `{`; the `#` byte appears first, so the fragment-`#` arm
6298 // fires, surfacing the more self-locating diagnostic on the
6299 // byte the author pasted earliest in the URL. Mirrors the
6300 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6301 // pins on the prior `:repo` byte-class arm.
6302 let d = dep_with_fonte(DepSource::Git {
6303 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6304 tag: Some("v0.1.0".into()),
6305 rev: None,
6306 branch: None,
6307 });
6308 let err = d.validate().unwrap_err();
6309 let DepError::FonteRepoShape { reason, .. } = err else {
6310 panic!("expected FonteRepoShape, got other variant");
6311 };
6312 assert!(
6313 reason.contains("must not contain `#`"),
6314 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6315 `#` byte appears first in value), got {reason:?}"
6316 );
6317 }
6318
6319 #[test]
6320 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6321 // The fail-before-pass-after pin for the canonical
6322 // shell-output-redirection footgun on `:repo`: an author
6323 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6324 // / `… >output.txt`) into the `:repo` slot without trimming
6325 // the redirect. Until this arm landed the value silently
6326 // passed every prior arm (no whitespace, no control chars,
6327 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6328 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6329 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6330 // percent-encode set maps `>` → `%3E` on the wire, so the
6331 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6332 // but is silently rewritten or rejected at libcurl's URL-
6333 // parser layer — two authors whose values differ only in
6334 // their redirect tail (`>build.log` vs nothing) resolve to
6335 // the byte-identical upstream `git clone` but lock to two
6336 // distinct lacres, defeating the THEORY.md §V.2 render-
6337 // determinism contract. Peer with the `:caminho` axis's
6338 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6339 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6340 // byte RFC-3986-reserved set on `:entrada :paths`.
6341 let d = dep_with_fonte(DepSource::Git {
6342 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6343 tag: Some("v0.1.0".into()),
6344 rev: None,
6345 branch: None,
6346 });
6347 let err = d.validate().unwrap_err();
6348 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6349 panic!("expected FonteRepoShape, got other variant");
6350 };
6351 assert_eq!(nome, "caixa-teia");
6352 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6353 assert!(
6354 reason.contains("must not contain `>`"),
6355 "reason must surface the output-redirection `>` arm, got {reason:?}"
6356 );
6357 assert!(
6358 reason.contains("redirection") || reason.contains("'delims'"),
6359 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6360 );
6361 }
6362
6363 #[test]
6364 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6365 // The symmetric shell-input-redirection footgun — an author
6366 // pastes a shell-pipeline head (`git clone <input.url` /
6367 // `cat <README.md`) into the `:repo` slot. Pinned separately
6368 // from the `>`-output arm so a future relaxation that only
6369 // catches one of the two redirect bytes surfaces here. Peer
6370 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6371 // arm which closes both `<` and `>` under the same banner.
6372 let d = dep_with_fonte(DepSource::Git {
6373 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6374 tag: Some("v0.1.0".into()),
6375 rev: None,
6376 branch: None,
6377 });
6378 let err = d.validate().unwrap_err();
6379 let DepError::FonteRepoShape { reason, .. } = err else {
6380 panic!("expected FonteRepoShape, got other variant");
6381 };
6382 assert!(
6383 reason.contains("must not contain `<`"),
6384 "reason must surface the input-redirection `<` arm, got {reason:?}"
6385 );
6386 assert!(
6387 reason.contains("RFC 3986") || reason.contains("'unwise'"),
6388 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6389 );
6390 }
6391
6392 #[test]
6393 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6394 // The fail-before-pass-after pin for the canonical
6395 // paste-from-shell-prompt-with-backticked-substitution footgun
6396 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6397 // `:caminho` path-fonte axis). An author pastes a URL whose
6398 // segment carries a backticked command-substitution wrapper
6399 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6400 // from a doc / README quick-start snippet that expected the
6401 // substrate to substitute the value downstream. Until this arm
6402 // landed the value silently passed every prior arm (no
6403 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6404 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6405 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6406 // 'unwise' set and the WHATWG URL spec's fragment percent-
6407 // encode set maps `` ` `` → `%60` on the wire, so the byte
6408 // rides verbatim into the lacre's per-dep BLAKE3 closure but
6409 // is silently rewritten or rejected at libcurl's URL-parser
6410 // layer — two authors whose values differ only in their
6411 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6412 // byte-identical upstream `git clone` but lock to two distinct
6413 // lacres, defeating the THEORY.md §V.2 render-determinism
6414 // contract. Peer with the `:caminho` axis's
6415 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6416 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6417 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6418 let d = dep_with_fonte(DepSource::Git {
6419 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6420 tag: Some("v0.1.0".into()),
6421 rev: None,
6422 branch: None,
6423 });
6424 let err = d.validate().unwrap_err();
6425 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6426 panic!("expected FonteRepoShape, got other variant");
6427 };
6428 assert_eq!(nome, "caixa-teia");
6429 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6430 assert!(
6431 reason.contains("must not contain `` ` ``"),
6432 "reason must surface the backtick command-substitution arm, got {reason:?}"
6433 );
6434 assert!(
6435 reason.contains("command-substitution") || reason.contains("'unwise'"),
6436 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6437 got {reason:?}"
6438 );
6439 }
6440
6441 #[test]
6442 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6443 // Cascade pin: the fragment-`#` arm and the backtick command-
6444 // substitution arm are both per-byte arms inside the same
6445 // `for &b in s.as_bytes()` loop, so the byte that appears first
6446 // in the value's byte order wins. A `:repo
6447 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6448 // and backtick; the `#` byte appears first, so the fragment-
6449 // `#` arm fires, surfacing the more self-locating diagnostic
6450 // on the byte the author pasted earliest in the URL. Mirrors
6451 // the peer cascade discipline
6452 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6453 // pins on the prior `:repo` byte-class arm.
6454 let d = dep_with_fonte(DepSource::Git {
6455 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6456 tag: Some("v0.1.0".into()),
6457 rev: None,
6458 branch: None,
6459 });
6460 let err = d.validate().unwrap_err();
6461 let DepError::FonteRepoShape { reason, .. } = err else {
6462 panic!("expected FonteRepoShape, got other variant");
6463 };
6464 assert!(
6465 reason.contains("must not contain `#`"),
6466 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6467 appears first in value), got {reason:?}"
6468 );
6469 }
6470
6471 #[test]
6472 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6473 // Cascade pin: the shell-redirection `<` / `>` arm and the
6474 // backtick command-substitution arm are both per-byte arms
6475 // inside the same `for &b in s.as_bytes()` loop, so the byte
6476 // that appears first in the value's byte order wins. A `:repo
6477 // "https://github.com/p/x>build.log/`whoami`"` carries both
6478 // `>` and backtick; the `>` byte appears first, so the
6479 // shell-redirection arm fires, surfacing the more self-
6480 // locating diagnostic on the byte the author pasted earliest
6481 // in the URL. Pins the natural-order cascade so a future
6482 // reorder of the per-byte arms surfaces here.
6483 let d = dep_with_fonte(DepSource::Git {
6484 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6485 tag: Some("v0.1.0".into()),
6486 rev: None,
6487 branch: None,
6488 });
6489 let err = d.validate().unwrap_err();
6490 let DepError::FonteRepoShape { reason, .. } = err else {
6491 panic!("expected FonteRepoShape, got other variant");
6492 };
6493 assert!(
6494 reason.contains("must not contain `>`"),
6495 "reason must surface the shell-redirection `>` arm (fires before backtick when \
6496 `>` byte appears first in value), got {reason:?}"
6497 );
6498 }
6499
6500 #[test]
6501 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6502 // Cascade pin: the fragment-`#` arm and the shell-redirection
6503 // `<` / `>` arm are both per-byte arms inside the same
6504 // `for &b in s.as_bytes()` loop, so the byte that appears
6505 // first in the value's byte order wins. A `:repo
6506 // "https://github.com/p/x#readme>build.log"` carries both
6507 // `#` and `>`; the `#` byte appears first, so the fragment-
6508 // `#` arm fires, surfacing the more self-locating diagnostic
6509 // on the byte the author pasted earliest in the URL. Mirrors
6510 // the peer cascade discipline
6511 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6512 // pins on the prior `:repo` byte-class arm.
6513 let d = dep_with_fonte(DepSource::Git {
6514 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6515 tag: Some("v0.1.0".into()),
6516 rev: None,
6517 branch: None,
6518 });
6519 let err = d.validate().unwrap_err();
6520 let DepError::FonteRepoShape { reason, .. } = err else {
6521 panic!("expected FonteRepoShape, got other variant");
6522 };
6523 assert!(
6524 reason.contains("must not contain `#`"),
6525 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6526 `#` byte appears first in value), got {reason:?}"
6527 );
6528 }
6529
6530 #[test]
6531 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6532 // The fail-before-pass-after pin for the canonical
6533 // paste-from-shell-prompt-with-piped-pipeline footgun on
6534 // `:repo` (peer with the 124106f pipe arm on the sibling
6535 // `:caminho` path-fonte axis). An author pastes a shell
6536 // pipeline (`git clone <url> | tee build.log`,
6537 // `git ls-remote <url> | head`) into the `:repo` slot,
6538 // forgetting to trim the `| <consumer>` tail. Until this arm
6539 // landed the value silently passed every prior arm (no
6540 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6541 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6542 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6543 // 'unwise' set and the WHATWG URL spec's fragment percent-
6544 // encode set maps `|` → `%7C` on the wire, so the byte rides
6545 // verbatim into the lacre's per-dep BLAKE3 closure but is
6546 // silently rewritten or rejected at libcurl's URL-parser
6547 // layer — two authors whose values differ only in their pipe
6548 // tail (`|tee build.log` vs nothing) resolve to the byte-
6549 // identical upstream `git clone` but lock to two distinct
6550 // lacres, defeating the THEORY.md §V.2 render-determinism
6551 // contract. Peer with the `:caminho` axis's
6552 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6553 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6554 // RFC-3986-reserved set on `:entrada :paths`.
6555 let d = dep_with_fonte(DepSource::Git {
6556 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6557 tag: Some("v0.1.0".into()),
6558 rev: None,
6559 branch: None,
6560 });
6561 let err = d.validate().unwrap_err();
6562 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6563 panic!("expected FonteRepoShape, got other variant");
6564 };
6565 assert_eq!(nome, "caixa-teia");
6566 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6567 assert!(
6568 reason.contains("must not contain `|`"),
6569 "reason must surface the shell-pipe arm, got {reason:?}"
6570 );
6571 assert!(
6572 reason.contains("pipe") || reason.contains("'unwise'"),
6573 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6574 );
6575 }
6576
6577 #[test]
6578 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6579 // Cascade pin: the fragment-`#` arm and the pipe arm are both
6580 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6581 // so the byte that appears first in the value's byte order
6582 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6583 // both `#` and `|`; the `#` byte appears first, so the
6584 // fragment-`#` arm fires, surfacing the more self-locating
6585 // diagnostic on the byte the author pasted earliest in the
6586 // URL. Mirrors the peer cascade discipline
6587 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6588 // pins on the prior `:repo` byte-class arm.
6589 let d = dep_with_fonte(DepSource::Git {
6590 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6591 tag: Some("v0.1.0".into()),
6592 rev: None,
6593 branch: None,
6594 });
6595 let err = d.validate().unwrap_err();
6596 let DepError::FonteRepoShape { reason, .. } = err else {
6597 panic!("expected FonteRepoShape, got other variant");
6598 };
6599 assert!(
6600 reason.contains("must not contain `#`"),
6601 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6602 appears first in value), got {reason:?}"
6603 );
6604 }
6605
6606 #[test]
6607 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6608 // Cascade pin: the backtick arm and the pipe arm are both per-
6609 // byte arms inside the same `for &b in s.as_bytes()` loop, so
6610 // the byte that appears first in the value's byte order wins.
6611 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6612 // `` ` `` and `|`; the backtick byte appears first, so the
6613 // backtick arm fires, surfacing the more self-locating
6614 // diagnostic on the byte the author pasted earliest in the
6615 // URL. Pins the natural-order cascade so a future reorder of
6616 // the per-byte arms surfaces here.
6617 let d = dep_with_fonte(DepSource::Git {
6618 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6619 tag: Some("v0.1.0".into()),
6620 rev: None,
6621 branch: None,
6622 });
6623 let err = d.validate().unwrap_err();
6624 let DepError::FonteRepoShape { reason, .. } = err else {
6625 panic!("expected FonteRepoShape, got other variant");
6626 };
6627 assert!(
6628 reason.contains("must not contain `` ` ``"),
6629 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6630 appears first in value), got {reason:?}"
6631 );
6632 }
6633
6634 #[test]
6635 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6636 // The fail-before-pass-after pin for the canonical
6637 // paste-from-shell-prompt-with-sequential-command-tail footgun
6638 // on `:repo` (peer with the 05c358e `;` arm on the sibling
6639 // `:caminho` path-fonte axis). An author pastes a shell
6640 // one-liner that chained a cleanup tail after the URL
6641 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6642 // echo done`) into the `:repo` slot, forgetting to trim the
6643 // `; <cmd>` tail. Until this arm landed the value silently
6644 // passed every prior `is_git_repo_url` arm (no whitespace, no
6645 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6646 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6647 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6648 // reserved set and the WHATWG URL spec's fragment percent-
6649 // encode set maps `;` → `%3B` on the wire, so the byte rides
6650 // verbatim into the lacre's per-dep BLAKE3 closure but is
6651 // silently rewritten at libcurl's URL-parser layer — two
6652 // authors whose values differ only in their sequential-command
6653 // tail (`; rm -rf build` vs nothing) resolve to the byte-
6654 // identical upstream `git clone` but lock to two distinct
6655 // lacres, defeating the THEORY.md §V.2 render-determinism
6656 // contract. Peer with the `:caminho` axis's
6657 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6658 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6659 // byte RFC-3986-reserved set on `:entrada :paths`.
6660 let d = dep_with_fonte(DepSource::Git {
6661 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6662 tag: Some("v0.1.0".into()),
6663 rev: None,
6664 branch: None,
6665 });
6666 let err = d.validate().unwrap_err();
6667 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6668 panic!("expected FonteRepoShape, got other variant");
6669 };
6670 assert_eq!(nome, "caixa-teia");
6671 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6672 assert!(
6673 reason.contains("must not contain `;`"),
6674 "reason must surface the shell-command-separator arm, got {reason:?}"
6675 );
6676 assert!(
6677 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6678 "reason must name the shell-command-separator / RFC-3986-sub-delims \
6679 rationale, got {reason:?}"
6680 );
6681 }
6682
6683 #[test]
6684 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6685 // Cascade pin: the fragment-`#` arm and the semicolon arm are
6686 // both per-byte arms inside the same `for &b in s.as_bytes()`
6687 // loop, so the byte that appears first in the value's byte
6688 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6689 // carries both `#` and `;`; the `#` byte appears first, so the
6690 // fragment-`#` arm fires, surfacing the more self-locating
6691 // diagnostic on the byte the author pasted earliest in the URL.
6692 // Mirrors the peer cascade discipline
6693 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6694 // pins on the prior `:repo` byte-class arm.
6695 let d = dep_with_fonte(DepSource::Git {
6696 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6697 tag: Some("v0.1.0".into()),
6698 rev: None,
6699 branch: None,
6700 });
6701 let err = d.validate().unwrap_err();
6702 let DepError::FonteRepoShape { reason, .. } = err else {
6703 panic!("expected FonteRepoShape, got other variant");
6704 };
6705 assert!(
6706 reason.contains("must not contain `#`"),
6707 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6708 byte appears first in value), got {reason:?}"
6709 );
6710 }
6711
6712 #[test]
6713 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6714 // Cascade pin: the pipe arm and the semicolon arm are both
6715 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6716 // so the byte that appears first in the value's byte order
6717 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6718 // both `|` and `;`; the `|` byte appears first, so the
6719 // pipe arm fires, surfacing the more self-locating diagnostic
6720 // on the byte the author pasted earliest in the URL. Pins the
6721 // natural-order cascade so a future reorder of the per-byte
6722 // arms surfaces here.
6723 let d = dep_with_fonte(DepSource::Git {
6724 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6725 tag: Some("v0.1.0".into()),
6726 rev: None,
6727 branch: None,
6728 });
6729 let err = d.validate().unwrap_err();
6730 let DepError::FonteRepoShape { reason, .. } = err else {
6731 panic!("expected FonteRepoShape, got other variant");
6732 };
6733 assert!(
6734 reason.contains("must not contain `|`"),
6735 "reason must surface the pipe arm (fires before semicolon when `|` byte \
6736 appears first in value), got {reason:?}"
6737 );
6738 }
6739
6740 #[test]
6741 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6742 // The fail-before-pass-after pin for the canonical
6743 // paste-from-shell-prompt-with-background-launch-tail footgun
6744 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6745 // `:caminho` path-fonte axis). An author pastes a shell one-
6746 // liner that detached the clone into the background
6747 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6748 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6749 // `&& <cmd>` tail. Until this arm landed the value silently
6750 // passed every prior `is_git_repo_url` arm (no whitespace,
6751 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6752 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6753 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6754 // the 'sub-delims' / reserved set and the WHATWG URL spec's
6755 // fragment percent-encode set maps `&` → `%26` on the wire,
6756 // so the byte rides verbatim into the lacre's per-dep
6757 // BLAKE3 closure but is silently rewritten at libcurl's
6758 // URL-parser layer — two authors whose values differ only
6759 // in their background-launch tail (`& sleep 1` vs nothing)
6760 // resolve to the byte-identical upstream `git clone` but
6761 // lock to two distinct lacres, defeating the THEORY.md
6762 // §V.2 render-determinism contract. Peer with the
6763 // `:caminho` axis's `FonteCaminhoShellBackground` arm
6764 // (e12e4f3) on the sibling path-fonte axis, and
6765 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6766 // reserved set on `:entrada :paths`.
6767 let d = dep_with_fonte(DepSource::Git {
6768 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6769 tag: Some("v0.1.0".into()),
6770 rev: None,
6771 branch: None,
6772 });
6773 let err = d.validate().unwrap_err();
6774 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6775 panic!("expected FonteRepoShape, got other variant");
6776 };
6777 assert_eq!(nome, "caixa-teia");
6778 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6779 assert!(
6780 reason.contains("must not contain `&`"),
6781 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6782 );
6783 assert!(
6784 reason.contains("background-task") || reason.contains("'sub-delims'"),
6785 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6786 got {reason:?}"
6787 );
6788 }
6789
6790 #[test]
6791 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6792 // The fail-before-pass-after pin for the symmetric `&&`
6793 // logical-AND build-chain paste footgun: an author pastes
6794 // a `git clone <url> && cd <repo>` build-chain one-liner
6795 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6796 // is the same `&` byte twice in a row; the per-byte arm
6797 // fires on the first `&` it sees. Pinned separately from
6798 // the single-`&` background-launch shape so a future
6799 // diagnostic-surface change that special-cased the
6800 // doubled-byte form surfaces here.
6801 let d = dep_with_fonte(DepSource::Git {
6802 repo: "github:pleme-io/caixa-teia&&echo".into(),
6803 tag: Some("v0.1.0".into()),
6804 rev: None,
6805 branch: None,
6806 });
6807 let err = d.validate().unwrap_err();
6808 let DepError::FonteRepoShape { reason, .. } = err else {
6809 panic!("expected FonteRepoShape, got other variant");
6810 };
6811 assert!(
6812 reason.contains("must not contain `&`"),
6813 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6814 shape too, got {reason:?}"
6815 );
6816 }
6817
6818 #[test]
6819 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6820 // Cascade pin: the fragment-`#` arm and the background-`&`
6821 // arm are both per-byte arms inside the same `for &b in
6822 // s.as_bytes()` loop, so the byte that appears first in the
6823 // value's byte order wins. A `:repo
6824 // "https://github.com/p/x#readme & sleep"` carries both `#`
6825 // and `&`; the `#` byte appears first, so the fragment-`#`
6826 // arm fires, surfacing the more self-locating diagnostic on
6827 // the byte the author pasted earliest in the URL. Mirrors
6828 // the peer cascade discipline
6829 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6830 // on the prior `:repo` byte-class arm.
6831 let d = dep_with_fonte(DepSource::Git {
6832 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6833 tag: Some("v0.1.0".into()),
6834 rev: None,
6835 branch: None,
6836 });
6837 let err = d.validate().unwrap_err();
6838 let DepError::FonteRepoShape { reason, .. } = err else {
6839 panic!("expected FonteRepoShape, got other variant");
6840 };
6841 assert!(
6842 reason.contains("must not contain `#`"),
6843 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6844 byte appears first in value), got {reason:?}"
6845 );
6846 }
6847
6848 #[test]
6849 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6850 // Cascade pin: the semicolon arm and the background-`&` arm
6851 // are both per-byte arms inside the same `for &b in
6852 // s.as_bytes()` loop, so the byte that appears first in the
6853 // value's byte order wins. A `:repo
6854 // "https://github.com/p/x; rm & sleep"` carries both `;` and
6855 // `&`; the `;` byte appears first, so the semicolon arm
6856 // fires, surfacing the more self-locating diagnostic on the
6857 // byte the author pasted earliest in the URL. Pins the
6858 // natural-order cascade so a future reorder of the per-byte
6859 // arms surfaces here.
6860 let d = dep_with_fonte(DepSource::Git {
6861 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
6862 tag: Some("v0.1.0".into()),
6863 rev: None,
6864 branch: None,
6865 });
6866 let err = d.validate().unwrap_err();
6867 let DepError::FonteRepoShape { reason, .. } = err else {
6868 panic!("expected FonteRepoShape, got other variant");
6869 };
6870 assert!(
6871 reason.contains("must not contain `;`"),
6872 "reason must surface the semicolon arm (fires before background-`&` when `;` \
6873 byte appears first in value), got {reason:?}"
6874 );
6875 }
6876
6877 #[test]
6878 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
6879 // The fail-before-pass-after pin for the canonical
6880 // paste-from-shell-prompt-with-unsubstituted-variable footgun
6881 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
6882 // `:caminho` path-fonte axis). An author pastes a shell one-
6883 // liner that referenced an environment variable
6884 // (`git clone https://github.com/$ORG/x`, `git clone
6885 // github:$USER/repo`) into the `:repo` slot, forgetting to
6886 // substitute the literal value at author time. Until this arm
6887 // landed the value silently passed every prior
6888 // `is_git_repo_url` arm (no whitespace, no control chars, no
6889 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
6890 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
6891 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
6892 // reserved set and the WHATWG URL spec's fragment percent-
6893 // encode set maps `$` → `%24` on the wire, so the byte rides
6894 // verbatim into the lacre's per-dep BLAKE3 closure but is
6895 // silently rewritten at libcurl's URL-parser layer — two
6896 // authors whose values differ only in their `$VAR` /
6897 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
6898 // identical upstream `git clone` but lock to two distinct
6899 // lacres, defeating the THEORY.md §V.2 render-determinism
6900 // contract. Beyond determinism, the value is a structural
6901 // host-layout leak: two authors with the same `:repo` slot
6902 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
6903 // different upstreams. Peer with the `:caminho` axis's
6904 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
6905 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6906 // byte RFC-3986-reserved set on `:entrada :paths`.
6907 let d = dep_with_fonte(DepSource::Git {
6908 repo: "https://github.com/$ORG/caixa-teia".into(),
6909 tag: Some("v0.1.0".into()),
6910 rev: None,
6911 branch: None,
6912 });
6913 let err = d.validate().unwrap_err();
6914 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6915 panic!("expected FonteRepoShape, got other variant");
6916 };
6917 assert_eq!(nome, "caixa-teia");
6918 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
6919 assert!(
6920 reason.contains("must not contain `$`"),
6921 "reason must surface the shell-variable-expansion arm, got {reason:?}"
6922 );
6923 assert!(
6924 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
6925 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
6926 rationale, got {reason:?}"
6927 );
6928 }
6929
6930 #[test]
6931 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
6932 // The fail-before-pass-after pin for the symmetric POSIX-
6933 // shell braced `${VAR}` expansion paste footgun: an author
6934 // pastes a CI-manifest line `git clone
6935 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
6936 // Actions / GitLab CI / Drone shape) and forgets to
6937 // substitute the literal value. The `${...}` shape is the
6938 // same `$` byte at the leading position of the expansion;
6939 // the per-byte arm fires on the `$`. Pinned separately from
6940 // the bare-`$VAR` shape so a future diagnostic-surface
6941 // change that special-cased the braced form surfaces here.
6942 let d = dep_with_fonte(DepSource::Git {
6943 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
6944 tag: Some("v0.1.0".into()),
6945 rev: None,
6946 branch: None,
6947 });
6948 let err = d.validate().unwrap_err();
6949 let DepError::FonteRepoShape { reason, .. } = err else {
6950 panic!("expected FonteRepoShape, got other variant");
6951 };
6952 assert!(
6953 reason.contains("must not contain `$`"),
6954 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
6955 shape too, got {reason:?}"
6956 );
6957 }
6958
6959 #[test]
6960 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
6961 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
6962 // arm are both per-byte arms inside the same `for &b in
6963 // s.as_bytes()` loop, so the byte that appears first in the
6964 // value's byte order wins. A `:repo
6965 // "https://github.com/p/x#readme$HOME"` carries both `#` and
6966 // `$`; the `#` byte appears first, so the fragment-`#` arm
6967 // fires, surfacing the more self-locating diagnostic on the
6968 // byte the author pasted earliest in the URL. Mirrors the
6969 // peer cascade discipline
6970 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
6971 // on the prior `:repo` byte-class arm.
6972 let d = dep_with_fonte(DepSource::Git {
6973 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
6974 tag: Some("v0.1.0".into()),
6975 rev: None,
6976 branch: None,
6977 });
6978 let err = d.validate().unwrap_err();
6979 let DepError::FonteRepoShape { reason, .. } = err else {
6980 panic!("expected FonteRepoShape, got other variant");
6981 };
6982 assert!(
6983 reason.contains("must not contain `#`"),
6984 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
6985 `#` byte appears first in value), got {reason:?}"
6986 );
6987 }
6988
6989 #[test]
6990 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
6991 // Cascade pin: the background-`&` arm and the
6992 // var-expansion-`$` arm are both per-byte arms inside the
6993 // same `for &b in s.as_bytes()` loop, so the byte that
6994 // appears first in the value's byte order wins. A `:repo
6995 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
6996 // `$`; the `&` byte appears first, so the background arm
6997 // fires, surfacing the more self-locating diagnostic on the
6998 // byte the author pasted earliest in the URL. Pins the
6999 // natural-order cascade so a future reorder of the per-byte
7000 // arms surfaces here — `$` is the most recent byte-class arm,
7001 // so the cascade-pin sweep extends to cover every immediately
7002 // prior byte arm (`#`, `&`) firing first when ordered ahead
7003 // of `$` in the value.
7004 let d = dep_with_fonte(DepSource::Git {
7005 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7006 tag: Some("v0.1.0".into()),
7007 rev: None,
7008 branch: None,
7009 });
7010 let err = d.validate().unwrap_err();
7011 let DepError::FonteRepoShape { reason, .. } = err else {
7012 panic!("expected FonteRepoShape, got other variant");
7013 };
7014 assert!(
7015 reason.contains("must not contain `&`"),
7016 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7017 `&` byte appears first in value), got {reason:?}"
7018 );
7019 }
7020
7021 #[test]
7022 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7023 // The fail-before-pass-after pin for the canonical
7024 // paste-from-shell-prompt glob footgun on `:repo` (peer with
7025 // the cf9034b `*` / `?` arm on the sibling `:caminho`
7026 // path-fonte axis). An author pastes a shell one-liner that
7027 // referenced a glob expansion (`ls
7028 // github.com/pleme-io/caixa-*`, `git clone
7029 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7030 // to substitute the literal repo name. Until this arm landed
7031 // the `*` byte silently passed every prior `is_git_repo_url`
7032 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7033 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7034 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7035 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7036 // the WHATWG URL spec's special-query percent-encode set maps
7037 // `*` → `%2A` on the wire, so the byte rides verbatim into
7038 // the lacre's per-dep BLAKE3 closure but is silently
7039 // rewritten at libcurl's URL-parser layer — two authors
7040 // whose values differ only in their asterisk presence
7041 // resolve to the byte-identical upstream `git clone` but
7042 // lock to two distinct lacres, defeating the THEORY.md §V.2
7043 // render-determinism contract. Peer with the `:caminho`
7044 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7045 // sibling path-fonte axis, and the `is_git_ref_name`
7046 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7047 // axes.
7048 let d = dep_with_fonte(DepSource::Git {
7049 repo: "https://github.com/pleme-io/caixa-*".into(),
7050 tag: Some("v0.1.0".into()),
7051 rev: None,
7052 branch: None,
7053 });
7054 let err = d.validate().unwrap_err();
7055 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7056 panic!("expected FonteRepoShape, got other variant");
7057 };
7058 assert_eq!(nome, "caixa-teia");
7059 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7060 assert!(
7061 reason.contains("must not contain `*`"),
7062 "reason must surface the shell-glob arm, got {reason:?}"
7063 );
7064 assert!(
7065 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7066 "reason must name the shell-glob / pathname-expansion / \
7067 RFC-3986-sub-delims rationale, got {reason:?}"
7068 );
7069 }
7070
7071 #[test]
7072 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7073 // The fail-before-pass-after pin for the symmetric bash
7074 // `globstar` recursive-glob paste footgun: an author pastes
7075 // a `ls github.com/pleme-io/**/x` (the canonical
7076 // `globstar`-shopt-enabled recursive-listing tail) into the
7077 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7078 // the per-byte arm fires on the first `*`. Pinned
7079 // separately from the single-`*` shape so a future
7080 // diagnostic-surface change that special-cased the
7081 // double-`*` form surfaces here.
7082 let d = dep_with_fonte(DepSource::Git {
7083 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7084 tag: Some("v0.1.0".into()),
7085 rev: None,
7086 branch: None,
7087 });
7088 let err = d.validate().unwrap_err();
7089 let DepError::FonteRepoShape { reason, .. } = err else {
7090 panic!("expected FonteRepoShape, got other variant");
7091 };
7092 assert!(
7093 reason.contains("must not contain `*`"),
7094 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7095 got {reason:?}"
7096 );
7097 }
7098
7099 #[test]
7100 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7101 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7102 // both per-byte arms inside the same `for &b in s.as_bytes()`
7103 // loop, so the byte that appears first in the value's byte
7104 // order wins. A `:repo
7105 // "https://github.com/p/x#readme*tail"` carries both `#` and
7106 // `*`; the `#` byte appears first, so the fragment-`#` arm
7107 // fires, surfacing the more self-locating diagnostic on the
7108 // byte the author pasted earliest in the URL. Mirrors the
7109 // peer cascade discipline
7110 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7111 // on the prior `:repo` byte-class arm.
7112 let d = dep_with_fonte(DepSource::Git {
7113 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7114 tag: Some("v0.1.0".into()),
7115 rev: None,
7116 branch: None,
7117 });
7118 let err = d.validate().unwrap_err();
7119 let DepError::FonteRepoShape { reason, .. } = err else {
7120 panic!("expected FonteRepoShape, got other variant");
7121 };
7122 assert!(
7123 reason.contains("must not contain `#`"),
7124 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7125 appears first in value), got {reason:?}"
7126 );
7127 }
7128
7129 #[test]
7130 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7131 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7132 // arm are both per-byte arms inside the same `for &b in
7133 // s.as_bytes()` loop, so the byte that appears first in the
7134 // value's byte order wins. A `:repo
7135 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7136 // the `$` byte appears first, so the var-expansion arm
7137 // fires, surfacing the more self-locating diagnostic on the
7138 // byte the author pasted earliest in the URL. Pins the
7139 // natural-order cascade so a future reorder of the per-byte
7140 // arms surfaces here — `*` is the most recent byte-class
7141 // arm, so the cascade-pin sweep extends to cover the
7142 // immediately prior `$` byte arm firing first when ordered
7143 // ahead of `*` in the value.
7144 let d = dep_with_fonte(DepSource::Git {
7145 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7146 tag: Some("v0.1.0".into()),
7147 rev: None,
7148 branch: None,
7149 });
7150 let err = d.validate().unwrap_err();
7151 let DepError::FonteRepoShape { reason, .. } = err else {
7152 panic!("expected FonteRepoShape, got other variant");
7153 };
7154 assert!(
7155 reason.contains("must not contain `$`"),
7156 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7157 byte appears first in value), got {reason:?}"
7158 );
7159 }
7160
7161 #[test]
7162 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7163 // The fail-before-pass-after pin for the canonical paste-from-
7164 // shell-prompt subshell-grouping footgun on `:repo`. An author
7165 // pastes a doc / README snippet carrying a regex-alternation
7166 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7167 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7168 // `:repo` slot, forgetting to substitute one literal org name.
7169 // Until this arm landed the `(` byte silently passed every
7170 // prior `is_git_repo_url` arm (no whitespace, no control
7171 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7172 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7173 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7174 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7175 // URL spec's special-query percent-encode set maps `(` →
7176 // `%28` and `)` → `%29` on the wire, so the byte rides
7177 // verbatim into the lacre's per-dep BLAKE3 closure but is
7178 // silently rewritten at libcurl's URL-parser layer —
7179 // defeating the THEORY.md §V.2 render-determinism contract on
7180 // the same axis the prior twelve byte-class arms close.
7181 let d = dep_with_fonte(DepSource::Git {
7182 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7183 tag: Some("v0.1.0".into()),
7184 rev: None,
7185 branch: None,
7186 });
7187 let err = d.validate().unwrap_err();
7188 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7189 panic!("expected FonteRepoShape, got other variant");
7190 };
7191 assert_eq!(nome, "caixa-teia");
7192 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7193 assert!(
7194 reason.contains("must not contain `(`"),
7195 "reason must surface the subshell-open-paren arm, got {reason:?}"
7196 );
7197 assert!(
7198 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7199 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7200 got {reason:?}"
7201 );
7202 }
7203
7204 #[test]
7205 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7206 // The symmetric arm pin on the closing `)` byte: an author
7207 // pastes a `$(date)` command-substitution wrapper or a
7208 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7209 // Pinned separately from the opening `(` shape so a future
7210 // diagnostic-surface change that only checked one boundary
7211 // surfaces here. The `(` byte appears earlier in the
7212 // canonical regex / subshell wrapper so the per-byte loop
7213 // fires on `(` first; this test exercises a `:repo` value
7214 // carrying only the closing `)` byte (no opening paren) so
7215 // the `)` arm fires directly — pinning the byte-class arm
7216 // independent of order.
7217 let d = dep_with_fonte(DepSource::Git {
7218 repo: "github:pleme-io/caixa-teia)tail".into(),
7219 tag: Some("v0.1.0".into()),
7220 rev: None,
7221 branch: None,
7222 });
7223 let err = d.validate().unwrap_err();
7224 let DepError::FonteRepoShape { reason, .. } = err else {
7225 panic!("expected FonteRepoShape, got other variant");
7226 };
7227 assert!(
7228 reason.contains("must not contain `)`"),
7229 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7230 got {reason:?}"
7231 );
7232 }
7233
7234 #[test]
7235 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7236 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7237 // are both per-byte arms inside the same `for &b in
7238 // s.as_bytes()` loop, so the byte that appears first in the
7239 // value's byte order wins. A `:repo
7240 // "https://github.com/p/x#readme(tail)"` carries both `#` and
7241 // `(`; the `#` byte appears first, so the fragment-`#` arm
7242 // fires, surfacing the more self-locating diagnostic on the
7243 // byte the author pasted earliest in the URL. Mirrors the
7244 // peer cascade discipline
7245 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7246 // on the prior `:repo` byte-class arm.
7247 let d = dep_with_fonte(DepSource::Git {
7248 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7249 tag: Some("v0.1.0".into()),
7250 rev: None,
7251 branch: None,
7252 });
7253 let err = d.validate().unwrap_err();
7254 let DepError::FonteRepoShape { reason, .. } = err else {
7255 panic!("expected FonteRepoShape, got other variant");
7256 };
7257 assert!(
7258 reason.contains("must not contain `#`"),
7259 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7260 byte appears first in value), got {reason:?}"
7261 );
7262 }
7263
7264 #[test]
7265 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7266 // Cascade pin: the glob-`*` arm (the immediate-predecessor
7267 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7268 // per-byte arms inside the same `for &b in s.as_bytes()`
7269 // loop, so the byte that appears first in the value's byte
7270 // order wins. A `:repo
7271 // "https://github.com/p/x-*-(date)"` carries both `*` and
7272 // `(`; the `*` byte appears first, so the glob arm fires,
7273 // surfacing the more self-locating diagnostic on the byte
7274 // the author pasted earliest in the URL. Pins the natural-
7275 // order cascade so a future reorder of the per-byte arms
7276 // surfaces here — `(` is the most recent byte-class arm,
7277 // so the cascade-pin sweep extends to cover the immediately
7278 // prior `*` byte arm firing first when ordered ahead of `(`
7279 // in the value.
7280 let d = dep_with_fonte(DepSource::Git {
7281 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7282 tag: Some("v0.1.0".into()),
7283 rev: None,
7284 branch: None,
7285 });
7286 let err = d.validate().unwrap_err();
7287 let DepError::FonteRepoShape { reason, .. } = err else {
7288 panic!("expected FonteRepoShape, got other variant");
7289 };
7290 assert!(
7291 reason.contains("must not contain `*`"),
7292 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7293 appears first in value), got {reason:?}"
7294 );
7295 }
7296
7297 #[test]
7298 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7299 // The fail-before-pass-after pin for the canonical paste-from-
7300 // doc-shell-quoting footgun on `:repo`. An author copies a
7301 // README quick-start snippet (`$ git clone "https://github.com/
7302 // foo/bar"`) and keeps the surrounding double-quote bytes when
7303 // pasting into the `:repo` slot — the doc wraps the URL in
7304 // double quotes so the shell doesn't re-lex metachars inside,
7305 // but the typed slot is itself a byte-level string parser, not
7306 // a shell context, so the quote bytes ride into the value
7307 // verbatim. Until this arm landed the `"` byte silently passed
7308 // every prior `is_git_repo_url` arm (no whitespace, no control
7309 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7310 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7311 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7312 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7313 // `` ` ``) every URL parser is required to refuse or percent-
7314 // encode, and the WHATWG URL spec's 'C0 control percent-encode
7315 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7316 // into the lacre's per-dep BLAKE3 closure but is silently
7317 // rewritten at libcurl's URL-parser layer, defeating the
7318 // THEORY.md §V.2 render-determinism contract.
7319 let d = dep_with_fonte(DepSource::Git {
7320 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7321 tag: Some("v0.1.0".into()),
7322 rev: None,
7323 branch: None,
7324 });
7325 let err = d.validate().unwrap_err();
7326 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7327 panic!("expected FonteRepoShape, got other variant");
7328 };
7329 assert_eq!(nome, "caixa-teia");
7330 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7331 assert!(
7332 reason.contains("must not contain `\"`"),
7333 "reason must surface the shell-double-quote arm, got {reason:?}"
7334 );
7335 assert!(
7336 reason.contains("double-quote") || reason.contains("'delims'"),
7337 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7338 got {reason:?}"
7339 );
7340 }
7341
7342 #[test]
7343 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7344 // The symmetric stray-quote tail pin: an author pastes only a
7345 // closing `"` from a shell-history line like `git clone
7346 // "https://github.com/foo/bar" && cd …` (the trim went too
7347 // far in one direction but not the other) into the `:repo`
7348 // slot. Pinned separately from the wrapped-quote shape so a
7349 // future diagnostic-surface change that only checked one
7350 // boundary (only leading, only trailing, only paired) surfaces
7351 // here — the per-byte arm fires anywhere `"` appears.
7352 let d = dep_with_fonte(DepSource::Git {
7353 repo: "github:pleme-io/caixa-teia\"".into(),
7354 tag: Some("v0.1.0".into()),
7355 rev: None,
7356 branch: None,
7357 });
7358 let err = d.validate().unwrap_err();
7359 let DepError::FonteRepoShape { reason, .. } = err else {
7360 panic!("expected FonteRepoShape, got other variant");
7361 };
7362 assert!(
7363 reason.contains("must not contain `\"`"),
7364 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7365 got {reason:?}"
7366 );
7367 }
7368
7369 #[test]
7370 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7371 // Cascade pin: the fragment-`#` arm and the double-quote arm
7372 // are both per-byte arms inside the same `for &b in
7373 // s.as_bytes()` loop, so the byte that appears first in the
7374 // value's byte order wins. A `:repo
7375 // "https://github.com/p/x#readme\"tail"` carries both `#` and
7376 // `"`; the `#` byte appears first, so the fragment-`#` arm
7377 // fires, surfacing the more self-locating diagnostic on the
7378 // byte the author pasted earliest in the URL.
7379 let d = dep_with_fonte(DepSource::Git {
7380 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7381 tag: Some("v0.1.0".into()),
7382 rev: None,
7383 branch: None,
7384 });
7385 let err = d.validate().unwrap_err();
7386 let DepError::FonteRepoShape { reason, .. } = err else {
7387 panic!("expected FonteRepoShape, got other variant");
7388 };
7389 assert!(
7390 reason.contains("must not contain `#`"),
7391 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7392 byte appears first in value), got {reason:?}"
7393 );
7394 }
7395
7396 #[test]
7397 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7398 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7399 // byte-class arm, 3b99147) and the double-quote arm are both
7400 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7401 // so the byte that appears first in the value's byte order
7402 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7403 // and `"`; the `(` byte appears first, so the subshell arm
7404 // fires, surfacing the more self-locating diagnostic on the
7405 // byte the author pasted earliest in the URL. Pins the natural-
7406 // order cascade so a future reorder of the per-byte arms
7407 // surfaces here — `"` is the most recent byte-class arm, so
7408 // the cascade-pin sweep extends to cover the immediately prior
7409 // `(` byte arm firing first when ordered ahead of `"` in the
7410 // value.
7411 let d = dep_with_fonte(DepSource::Git {
7412 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7413 tag: Some("v0.1.0".into()),
7414 rev: None,
7415 branch: None,
7416 });
7417 let err = d.validate().unwrap_err();
7418 let DepError::FonteRepoShape { reason, .. } = err else {
7419 panic!("expected FonteRepoShape, got other variant");
7420 };
7421 assert!(
7422 reason.contains("must not contain `(`"),
7423 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7424 byte appears first in value), got {reason:?}"
7425 );
7426 }
7427
7428 #[test]
7429 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7430 // The fail-before-pass-after pin for the canonical paste-from-
7431 // doc-strong-quoting footgun on `:repo`. An author copies a
7432 // security-conscious README quick-start snippet (`$ git clone
7433 // 'https://github.com/foo/bar'`) and keeps the surrounding
7434 // single-quote bytes when pasting into the `:repo` slot — the
7435 // doc strong-quotes the URL so the shell suppresses every form
7436 // of expansion on the bytes inside (no `$`, no backtick, no
7437 // glob, no word-splitting), but the typed slot is itself a
7438 // byte-level string parser, not a shell context, so the quote
7439 // bytes ride into the value verbatim. Until this arm landed the
7440 // `'` byte silently passed every prior `is_git_repo_url` arm
7441 // (no whitespace, no control chars, no non-ASCII, no `#`, no
7442 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7443 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7444 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7445 // set, peer with the `\"` 'delims' double-quote arm and the
7446 // partner ASCII shell-string-delimiter byte every byte-level
7447 // string parser sharing a value-shape with a shell argument
7448 // must refuse on a URL-shaped slot.
7449 let d = dep_with_fonte(DepSource::Git {
7450 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7451 tag: Some("v0.1.0".into()),
7452 rev: None,
7453 branch: None,
7454 });
7455 let err = d.validate().unwrap_err();
7456 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7457 panic!("expected FonteRepoShape, got other variant");
7458 };
7459 assert_eq!(nome, "caixa-teia");
7460 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7461 assert!(
7462 reason.contains("must not contain `'`"),
7463 "reason must surface the shell-single-quote arm, got {reason:?}"
7464 );
7465 assert!(
7466 reason.contains("single-quote") || reason.contains("strong-quote"),
7467 "reason must name the shell-single-quote / strong-quote rationale, \
7468 got {reason:?}"
7469 );
7470 }
7471
7472 #[test]
7473 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7474 // The symmetric English-typography pin: an author writes
7475 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7476 // from-prose idiom every README / commit-message / chat-thread
7477 // reference to a repo carries) expecting the substrate to
7478 // coerce it to a kebab-case slug — but the byte rides into the
7479 // lacre verbatim. Pinned separately from the wrapped-quote
7480 // shape so a future diagnostic-surface change that only checked
7481 // the boundary positions (only leading, only trailing, only
7482 // paired) surfaces here — the per-byte arm fires anywhere `'`
7483 // appears in the value.
7484 let d = dep_with_fonte(DepSource::Git {
7485 repo: "github:pleme-io/repo's-fork".into(),
7486 tag: Some("v0.1.0".into()),
7487 rev: None,
7488 branch: None,
7489 });
7490 let err = d.validate().unwrap_err();
7491 let DepError::FonteRepoShape { reason, .. } = err else {
7492 panic!("expected FonteRepoShape, got other variant");
7493 };
7494 assert!(
7495 reason.contains("must not contain `'`"),
7496 "reason must surface the shell-single-quote arm on the mid-string \
7497 apostrophe shape, got {reason:?}"
7498 );
7499 }
7500
7501 #[test]
7502 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7503 // Cascade pin: the fragment-`#` arm and the single-quote arm
7504 // are both per-byte arms inside the same `for &b in
7505 // s.as_bytes()` loop, so the byte that appears first in the
7506 // value's byte order wins. A `:repo
7507 // "https://github.com/p/x#readme'tail"` carries both `#` and
7508 // `'`; the `#` byte appears first, so the fragment-`#` arm
7509 // fires, surfacing the more self-locating diagnostic on the
7510 // byte the author pasted earliest in the URL.
7511 let d = dep_with_fonte(DepSource::Git {
7512 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7513 tag: Some("v0.1.0".into()),
7514 rev: None,
7515 branch: None,
7516 });
7517 let err = d.validate().unwrap_err();
7518 let DepError::FonteRepoShape { reason, .. } = err else {
7519 panic!("expected FonteRepoShape, got other variant");
7520 };
7521 assert!(
7522 reason.contains("must not contain `#`"),
7523 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7524 byte appears first in value), got {reason:?}"
7525 );
7526 }
7527
7528 #[test]
7529 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7530 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7531 // byte-class arm, 4267d8b) and the single-quote arm are both
7532 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7533 // so the byte that appears first in the value's byte order
7534 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7535 // `'`; the `"` byte appears first, so the double-quote arm
7536 // fires, surfacing the more self-locating diagnostic on the
7537 // byte the author pasted earliest in the URL. Pins the natural-
7538 // order cascade so a future reorder of the per-byte arms
7539 // surfaces here — `'` is the most recent byte-class arm, so
7540 // the cascade-pin sweep extends to cover the immediately prior
7541 // `"` byte arm firing first when ordered ahead of `'` in the
7542 // value.
7543 let d = dep_with_fonte(DepSource::Git {
7544 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7545 tag: Some("v0.1.0".into()),
7546 rev: None,
7547 branch: None,
7548 });
7549 let err = d.validate().unwrap_err();
7550 let DepError::FonteRepoShape { reason, .. } = err else {
7551 panic!("expected FonteRepoShape, got other variant");
7552 };
7553 assert!(
7554 reason.contains("must not contain `\"`"),
7555 "reason must surface the double-quote arm (fires before single-quote when `\"` \
7556 byte appears first in value), got {reason:?}"
7557 );
7558 }
7559
7560 #[test]
7561 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7562 // The fail-before-pass-after pin for the canonical paste-from-
7563 // shell-history footgun on `:repo`. An author copies a `git
7564 // clone <url>!sudo make install` one-liner from a README's
7565 // quick-start snippet, intending the trailing `!sudo` as a
7566 // shell-history-expansion reference but the typed slot is itself
7567 // a byte-level string parser, not a shell context, so the byte
7568 // rides into the value verbatim. Until this arm landed the `!`
7569 // byte silently passed every prior `is_git_repo_url` arm (no
7570 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7571 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7572 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7573 // start with `-` or `:`); bash with the default `histexpand`
7574 // mode rewrites `!command` to the most recent history entry
7575 // beginning with `command`, the canonical RCE-class injection
7576 // vector when the byte rides into a shell argument.
7577 let d = dep_with_fonte(DepSource::Git {
7578 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7579 tag: Some("v0.1.0".into()),
7580 rev: None,
7581 branch: None,
7582 });
7583 let err = d.validate().unwrap_err();
7584 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7585 panic!("expected FonteRepoShape, got other variant");
7586 };
7587 assert_eq!(nome, "caixa-teia");
7588 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7589 assert!(
7590 reason.contains("must not contain `!`"),
7591 "reason must surface the shell-history-expansion arm, got {reason:?}"
7592 );
7593 assert!(
7594 reason.contains("history-expansion") || reason.contains("bang"),
7595 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7596 );
7597 }
7598
7599 #[test]
7600 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7601 // The symmetric `!!` repeat-prior-command pin: an author paste-
7602 // trims a `git clone <url>` retry idiom from shell history that
7603 // expands to the previous command via `!!`. Pinned separately
7604 // from the wrapped `!command` shape so a future diagnostic-
7605 // surface change that only checked the leading or paired-bang
7606 // position surfaces here — the per-byte arm fires anywhere `!`
7607 // appears in the value.
7608 let d = dep_with_fonte(DepSource::Git {
7609 repo: "github:pleme-io/caixa-teia!!".into(),
7610 tag: Some("v0.1.0".into()),
7611 rev: None,
7612 branch: None,
7613 });
7614 let err = d.validate().unwrap_err();
7615 let DepError::FonteRepoShape { reason, .. } = err else {
7616 panic!("expected FonteRepoShape, got other variant");
7617 };
7618 assert!(
7619 reason.contains("must not contain `!`"),
7620 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7621 got {reason:?}"
7622 );
7623 }
7624
7625 #[test]
7626 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7627 // Cascade pin: the fragment-`#` arm and the bang arm are both
7628 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7629 // so the byte that appears first in the value's byte order
7630 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7631 // both `#` and `!`; the `#` byte appears first, so the
7632 // fragment-`#` arm fires, surfacing the more self-locating
7633 // diagnostic on the byte the author pasted earliest in the URL.
7634 let d = dep_with_fonte(DepSource::Git {
7635 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7636 tag: Some("v0.1.0".into()),
7637 rev: None,
7638 branch: None,
7639 });
7640 let err = d.validate().unwrap_err();
7641 let DepError::FonteRepoShape { reason, .. } = err else {
7642 panic!("expected FonteRepoShape, got other variant");
7643 };
7644 assert!(
7645 reason.contains("must not contain `#`"),
7646 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7647 appears first in value), got {reason:?}"
7648 );
7649 }
7650
7651 #[test]
7652 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7653 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7654 // byte-class arm, e7a109f) and the bang arm are both per-byte
7655 // arms inside the same `for &b in s.as_bytes()` loop, so the
7656 // byte that appears first in the value's byte order wins. A
7657 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7658 // `'` byte appears first, so the single-quote arm fires,
7659 // surfacing the more self-locating diagnostic on the byte the
7660 // author pasted earliest in the URL. Pins the natural-order
7661 // cascade so a future reorder of the per-byte arms surfaces
7662 // here — `!` is the most recent byte-class arm, so the
7663 // cascade-pin sweep extends to cover the immediately prior `'`
7664 // byte arm firing first when ordered ahead of `!` in the value.
7665 let d = dep_with_fonte(DepSource::Git {
7666 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7667 tag: Some("v0.1.0".into()),
7668 rev: None,
7669 branch: None,
7670 });
7671 let err = d.validate().unwrap_err();
7672 let DepError::FonteRepoShape { reason, .. } = err else {
7673 panic!("expected FonteRepoShape, got other variant");
7674 };
7675 assert!(
7676 reason.contains("must not contain `'`"),
7677 "reason must surface the single-quote arm (fires before bang when `'` byte \
7678 appears first in value), got {reason:?}"
7679 );
7680 }
7681
7682 #[test]
7683 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7684 // The fail-before-pass-after pin for the canonical
7685 // list-separator-belongs-to-list-grammar footgun on `:repo`.
7686 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7687 // one-liner from a multi-repo bootstrap doc, intending the
7688 // comma to separate multiple repo entries but the typed
7689 // `:repo` slot names *one* repo (the list-separator belongs
7690 // to the `:deps` list grammar, not to the value). Until this
7691 // arm landed the `,` byte silently passed every prior
7692 // `is_git_repo_url` arm (no whitespace, no control chars, no
7693 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7694 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7695 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7696 // `:`); the byte rode into the lacre's per-dep content-
7697 // address and the resolver's `git clone <repo>` subprocess
7698 // invocation, where no host's repo registry resolved the
7699 // comma-bearing slug.
7700 let d = dep_with_fonte(DepSource::Git {
7701 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7702 tag: Some("v0.1.0".into()),
7703 rev: None,
7704 branch: None,
7705 });
7706 let err = d.validate().unwrap_err();
7707 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7708 panic!("expected FonteRepoShape, got other variant");
7709 };
7710 assert_eq!(nome, "caixa-teia");
7711 assert_eq!(
7712 repo,
7713 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7714 );
7715 assert!(
7716 reason.contains("must not contain `,`"),
7717 "reason must surface the list-separator-comma arm, got {reason:?}"
7718 );
7719 assert!(
7720 reason.contains("list-separator") || reason.contains("sub-delims"),
7721 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7722 got {reason:?}"
7723 );
7724 }
7725
7726 #[test]
7727 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7728 // The symmetric trailing-`,` paste-from-prose pin: an author
7729 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7730 // comma every README-prose list-of-projects sentence carries,
7731 // mistakenly retained when the slug is pasted mid-sentence)
7732 // expecting the substrate to coerce it to a kebab-case slug.
7733 // Pinned separately from the wrapped mid-token shape so a
7734 // future diagnostic-surface change that only checked the
7735 // leading or paired-comma position surfaces here — the
7736 // per-byte arm fires anywhere `,` appears in the value.
7737 let d = dep_with_fonte(DepSource::Git {
7738 repo: "github:pleme-io/caixa-feira,".into(),
7739 tag: Some("v0.1.0".into()),
7740 rev: None,
7741 branch: None,
7742 });
7743 let err = d.validate().unwrap_err();
7744 let DepError::FonteRepoShape { reason, .. } = err else {
7745 panic!("expected FonteRepoShape, got other variant");
7746 };
7747 assert!(
7748 reason.contains("must not contain `,`"),
7749 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7750 got {reason:?}"
7751 );
7752 }
7753
7754 #[test]
7755 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7756 // Cascade pin: the fragment-`#` arm and the comma arm are
7757 // both per-byte arms inside the same `for &b in s.as_bytes()`
7758 // loop, so the byte that appears first in the value's byte
7759 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7760 // carries both `#` and `,`; the `#` byte appears first, so
7761 // the fragment-`#` arm fires, surfacing the more self-
7762 // locating diagnostic on the byte the author pasted earliest
7763 // in the URL.
7764 let d = dep_with_fonte(DepSource::Git {
7765 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7766 tag: Some("v0.1.0".into()),
7767 rev: None,
7768 branch: None,
7769 });
7770 let err = d.validate().unwrap_err();
7771 let DepError::FonteRepoShape { reason, .. } = err else {
7772 panic!("expected FonteRepoShape, got other variant");
7773 };
7774 assert!(
7775 reason.contains("must not contain `#`"),
7776 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7777 appears first in value), got {reason:?}"
7778 );
7779 }
7780
7781 #[test]
7782 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7783 // Cascade pin: the bang-`!` arm (the immediate-predecessor
7784 // byte-class arm, 7d53c68) and the comma arm are both
7785 // per-byte arms inside the same `for &b in s.as_bytes()`
7786 // loop, so the byte that appears first in the value's byte
7787 // order wins. A `:repo "github:p/x!mid,tail"` carries both
7788 // `!` and `,`; the `!` byte appears first, so the bang arm
7789 // fires, surfacing the more self-locating diagnostic on the
7790 // byte the author pasted earliest in the URL. Pins the
7791 // natural-order cascade so a future reorder of the per-byte
7792 // arms surfaces here — `,` is the most recent byte-class
7793 // arm, so the cascade-pin sweep extends to cover the
7794 // immediately prior `!` byte arm firing first when ordered
7795 // ahead of `,` in the value.
7796 let d = dep_with_fonte(DepSource::Git {
7797 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7798 tag: Some("v0.1.0".into()),
7799 rev: None,
7800 branch: None,
7801 });
7802 let err = d.validate().unwrap_err();
7803 let DepError::FonteRepoShape { reason, .. } = err else {
7804 panic!("expected FonteRepoShape, got other variant");
7805 };
7806 assert!(
7807 reason.contains("must not contain `!`"),
7808 "reason must surface the bang arm (fires before comma when `!` byte \
7809 appears first in value), got {reason:?}"
7810 );
7811 }
7812
7813 #[test]
7814 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7815 // The fail-before-pass-after pin for the canonical
7816 // shell-env-var-assignment-belongs-to-shell-grammar footgun
7817 // on `:repo`. An author copies
7818 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7819 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7820 // git clone <url>`, etc. — the canonical
7821 // git-troubleshooting README idiom for a one-shot env-var
7822 // scoped to the `git clone` invocation) from a shell-prompt
7823 // one-liner, intending the `KEY=VALUE` prefix as a shell-
7824 // grammar env-var assignment but the typed `:repo` slot is
7825 // a value parser, not a shell context, so the bytes ride
7826 // into the value verbatim. Until this arm landed the `=`
7827 // byte silently passed every prior `is_git_repo_url` arm
7828 // (no whitespace, no control chars, no non-ASCII, no `#`,
7829 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7830 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7831 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7832 // the byte rode into the lacre's per-dep content-address
7833 // and the resolver's `git clone <repo>` subprocess
7834 // invocation, where the upstream host's git porcelain
7835 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7836 // path that no host's repo registry resolves.
7837 let d = dep_with_fonte(DepSource::Git {
7838 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7839 tag: Some("v0.1.0".into()),
7840 rev: None,
7841 branch: None,
7842 });
7843 let err = d.validate().unwrap_err();
7844 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7845 panic!("expected FonteRepoShape, got other variant");
7846 };
7847 assert_eq!(nome, "caixa-teia");
7848 assert_eq!(
7849 repo,
7850 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
7851 );
7852 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
7853 // appears before the ` ` byte at position 21, so the `=`
7854 // arm fires (not the whitespace arm) — both arms guard
7855 // the slot, but the per-byte for-loop scans left-to-right
7856 // and the first matching byte wins.
7857 assert!(
7858 reason.contains("must not contain `=`"),
7859 "reason must surface the equals-`=` arm on the env-var-assignment \
7860 paste shape, got {reason:?}"
7861 );
7862 assert!(
7863 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
7864 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
7865 );
7866 }
7867
7868 #[test]
7869 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
7870 // The symmetric paste-from-gitconfig pin: an author copies
7871 // `url=https://github.com/p/x` from `git config --get-all
7872 // remote.origin.url` output, a `.gitconfig` `[remote
7873 // "origin"] url = https://…` ini-stanza paste, or a
7874 // `git config remote.origin.url <value>` doc snippet,
7875 // intending the `url=` prefix as the ini-key but the typed
7876 // `:repo` slot is a URL value parser, not a gitconfig
7877 // grammar. With no leading whitespace and no earlier-arm
7878 // bytes in the value, the `=` arm itself fires (rather
7879 // than cascading to the whitespace arm as in the env-var
7880 // paste shape). Pinned separately so a future diagnostic-
7881 // surface change that only checked the whitespace-leading
7882 // shape surfaces here — the per-byte arm fires anywhere
7883 // `=` appears in the value.
7884 let d = dep_with_fonte(DepSource::Git {
7885 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
7886 tag: Some("v0.1.0".into()),
7887 rev: None,
7888 branch: None,
7889 });
7890 let err = d.validate().unwrap_err();
7891 let DepError::FonteRepoShape { reason, .. } = err else {
7892 panic!("expected FonteRepoShape, got other variant");
7893 };
7894 assert!(
7895 reason.contains("must not contain `=`"),
7896 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
7897 paste shape, got {reason:?}"
7898 );
7899 assert!(
7900 reason.contains("key-value-separator") || reason.contains("sub-delims"),
7901 "reason must name the key-value-separator / RFC-3986-sub-delims \
7902 rationale, got {reason:?}"
7903 );
7904 }
7905
7906 #[test]
7907 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
7908 // Cascade pin: the fragment-`#` arm and the `=` arm are
7909 // both per-byte arms inside the same `for &b in s.as_bytes()`
7910 // loop, so the byte that appears first in the value's byte
7911 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
7912 // carries both `#` and `=`; the `#` byte appears first, so
7913 // the fragment-`#` arm fires, surfacing the more self-
7914 // locating diagnostic on the byte the author pasted earliest
7915 // in the URL.
7916 let d = dep_with_fonte(DepSource::Git {
7917 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
7918 tag: Some("v0.1.0".into()),
7919 rev: None,
7920 branch: None,
7921 });
7922 let err = d.validate().unwrap_err();
7923 let DepError::FonteRepoShape { reason, .. } = err else {
7924 panic!("expected FonteRepoShape, got other variant");
7925 };
7926 assert!(
7927 reason.contains("must not contain `#`"),
7928 "reason must surface the fragment-`#` arm (fires before equals when \
7929 `#` byte appears first in value), got {reason:?}"
7930 );
7931 }
7932
7933 #[test]
7934 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
7935 // Cascade pin: the comma-`,` arm (the immediate-predecessor
7936 // byte-class arm, 775b80e) and the `=` arm are both per-byte
7937 // arms inside the same `for &b in s.as_bytes()` loop, so
7938 // the byte that appears first in the value's byte order
7939 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
7940 // and `=`; the `,` byte appears first, so the comma arm
7941 // fires, surfacing the more self-locating diagnostic on
7942 // the byte the author pasted earliest in the URL. Pins the
7943 // natural-order cascade so a future reorder of the per-byte
7944 // arms surfaces here — `=` is the most recent byte-class
7945 // arm, so the cascade-pin sweep extends to cover the
7946 // immediately prior `,` byte arm firing first when ordered
7947 // ahead of `=` in the value.
7948 let d = dep_with_fonte(DepSource::Git {
7949 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
7950 tag: Some("v0.1.0".into()),
7951 rev: None,
7952 branch: None,
7953 });
7954 let err = d.validate().unwrap_err();
7955 let DepError::FonteRepoShape { reason, .. } = err else {
7956 panic!("expected FonteRepoShape, got other variant");
7957 };
7958 assert!(
7959 reason.contains("must not contain `,`"),
7960 "reason must surface the comma arm (fires before equals when `,` byte \
7961 appears first in value), got {reason:?}"
7962 );
7963 }
7964
7965 #[test]
7966 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
7967 // The fail-before-pass-after pin for the canonical paste-from-
7968 // browser-address-bar percent-encoded-space footgun on `:repo`.
7969 // An author copies `https://github.com/p/x%20test` from a
7970 // browser address bar (or a percent-encoded README hyperlink,
7971 // or a `curl --data-urlencode` shell-pipeline output)
7972 // intending `%20` as the URL encoding of a literal space; the
7973 // typed `:repo` slot already rejects the literal space byte
7974 // (the whitespace arm at the top of `is_git_repo_url`), so an
7975 // author trying to express "I really meant a space" reaches
7976 // for percent-encoding. Until this arm landed the `%` byte
7977 // silently passed every prior `is_git_repo_url` arm and rode
7978 // verbatim into the lacre's per-dep content-address — but
7979 // libcurl re-percent-encodes `%` to `%25` on the wire (since
7980 // `%` is reserved as the escape-sequence lead-in), so the
7981 // wire request becomes `https://github.com/p/x%2520test`, a
7982 // path the lacre's content-address never names. The classic
7983 // render-determinism violation on the encoding-mechanism axis
7984 // itself.
7985 let d = dep_with_fonte(DepSource::Git {
7986 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
7987 tag: Some("v0.1.0".into()),
7988 rev: None,
7989 branch: None,
7990 });
7991 let err = d.validate().unwrap_err();
7992 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7993 panic!("expected FonteRepoShape, got other variant");
7994 };
7995 assert_eq!(nome, "caixa-teia");
7996 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
7997 assert!(
7998 reason.contains("must not contain `%`"),
7999 "reason must surface the percent-`%` arm on the percent-encoded-space \
8000 paste shape, got {reason:?}"
8001 );
8002 assert!(
8003 reason.contains("percent-encoding") || reason.contains("%25"),
8004 "reason must name the percent-encoding / `%25` re-encoding rationale, \
8005 got {reason:?}"
8006 );
8007 }
8008
8009 #[test]
8010 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8011 // The symmetric over-encoded-path-separator pin: an author
8012 // writes `:repo "https://github.com/p%2Fx"` intending the
8013 // `%2F` as the URL encoding of `/` (the canonical
8014 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8015 // footgun every API client library and OAuth redirect-URI
8016 // documentation surfaces — the `/` is the URL-path-separator
8017 // and some templates percent-encode it to escape interpretation
8018 // as a path separator). The GitHub Smart-HTTP transport
8019 // resolves the URL's path-segment grammar before the
8020 // percent-decoding pass, so the value identifies a different
8021 // resource on the wire than the literal-`/` form the lacre's
8022 // content-address must agree with — two authors whose `:repo`
8023 // values differ only in their `/` vs `%2F` presence lock to
8024 // two distinct BLAKE3 closures for the byte-identical upstream
8025 // `git clone`. Pinned separately so a future diagnostic
8026 // surface that only catches the `%20` shape surfaces here too.
8027 let d = dep_with_fonte(DepSource::Git {
8028 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8029 tag: Some("v0.1.0".into()),
8030 rev: None,
8031 branch: None,
8032 });
8033 let err = d.validate().unwrap_err();
8034 let DepError::FonteRepoShape { reason, .. } = err else {
8035 panic!("expected FonteRepoShape, got other variant");
8036 };
8037 assert!(
8038 reason.contains("must not contain `%`"),
8039 "reason must surface the percent-`%` arm on the over-encoded-path \
8040 shape, got {reason:?}"
8041 );
8042 assert!(
8043 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8044 "reason must name the render-determinism / BLAKE3-closure rationale, \
8045 got {reason:?}"
8046 );
8047 }
8048
8049 #[test]
8050 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8051 // Cascade pin: the fragment-`#` arm and the `%` arm are both
8052 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8053 // so the byte that appears first in the value's byte order
8054 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8055 // both `#` and `%`; the `#` byte appears first, so the
8056 // fragment-`#` arm fires, surfacing the more self-locating
8057 // diagnostic on the byte the author pasted earliest in the URL.
8058 let d = dep_with_fonte(DepSource::Git {
8059 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8060 tag: Some("v0.1.0".into()),
8061 rev: None,
8062 branch: None,
8063 });
8064 let err = d.validate().unwrap_err();
8065 let DepError::FonteRepoShape { reason, .. } = err else {
8066 panic!("expected FonteRepoShape, got other variant");
8067 };
8068 assert!(
8069 reason.contains("must not contain `#`"),
8070 "reason must surface the fragment-`#` arm (fires before percent when \
8071 `#` byte appears first in value), got {reason:?}"
8072 );
8073 }
8074
8075 #[test]
8076 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8077 // Cascade pin: the equals-`=` arm (the immediate-predecessor
8078 // byte-class arm, acf99af) and the `%` arm are both per-byte
8079 // arms inside the same `for &b in s.as_bytes()` loop, so the
8080 // byte that appears first in the value's byte order wins.
8081 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8082 // the `=` byte appears first, so the equals arm fires,
8083 // surfacing the more self-locating diagnostic on the byte the
8084 // author pasted earliest in the URL. Pins the natural-order
8085 // cascade so a future reorder of the per-byte arms surfaces
8086 // here — `%` is the most recent byte-class arm, so the
8087 // cascade-pin sweep extends to cover the immediately prior
8088 // `=` byte arm firing first when ordered ahead of `%` in the
8089 // value.
8090 let d = dep_with_fonte(DepSource::Git {
8091 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8092 tag: Some("v0.1.0".into()),
8093 rev: None,
8094 branch: None,
8095 });
8096 let err = d.validate().unwrap_err();
8097 let DepError::FonteRepoShape { reason, .. } = err else {
8098 panic!("expected FonteRepoShape, got other variant");
8099 };
8100 assert!(
8101 reason.contains("must not contain `=`"),
8102 "reason must surface the equals arm (fires before percent when `=` byte \
8103 appears first in value), got {reason:?}"
8104 );
8105 }
8106
8107 #[test]
8108 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8109 // The fail-before-pass-after pin for the canonical paste-from-
8110 // shell-history footgun on `:repo`. An author copies a
8111 // `git clone <url>` line from their terminal followed by a
8112 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8113 // history shorthand (the `^old^new^` form re-runs the prior
8114 // history entry with the first `old` substituted by `new`,
8115 // bash's default behavior on interactive sessions with
8116 // `set -o histexpand`), forgetting to trim the trailing
8117 // `^...^...` shell-history fragment from the URL value. The
8118 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8119 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8120 // classes), the WHATWG URL spec's 'fragment percent-encode
8121 // set' maps `^` → `%5E` on the wire, so the byte rides
8122 // verbatim into the lacre's per-dep content-address but
8123 // libcurl re-encodes it to `%5E` at `git clone` time — the
8124 // classic render-determinism violation on the same axis the
8125 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8126 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8127 // `#` arms close.
8128 let d = dep_with_fonte(DepSource::Git {
8129 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8130 tag: Some("v0.1.0".into()),
8131 rev: None,
8132 branch: None,
8133 });
8134 let err = d.validate().unwrap_err();
8135 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8136 panic!("expected FonteRepoShape, got other variant");
8137 };
8138 assert_eq!(nome, "caixa-teia");
8139 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8140 assert!(
8141 reason.contains("must not contain `^`"),
8142 "reason must surface the caret-`^` arm on the paste-from-shell-history \
8143 shape, got {reason:?}"
8144 );
8145 assert!(
8146 reason.contains("history-substitution") || reason.contains("%5E"),
8147 "reason must name the shell-history-substitution / `%5E` wire-encoding \
8148 rationale, got {reason:?}"
8149 );
8150 }
8151
8152 #[test]
8153 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8154 // The symmetric paste-from-doc-grep-pipeline footgun: an
8155 // author writes `:repo "github:p/^archived"` after copying a
8156 // `grep '^archived'` regex-anchor / negation idiom from a
8157 // doc / README quick-listing snippet, expecting the substrate
8158 // to coerce it to a literal repo name. The byte rides
8159 // verbatim into the lacre's per-dep content-address and
8160 // diverges from the byte-identical literal `archived` form
8161 // every other author authored — the canonical render-
8162 // determinism violation pin on the second footgun shape the
8163 // caret-`^` arm closes.
8164 let d = dep_with_fonte(DepSource::Git {
8165 repo: "github:pleme-io/^archived".into(),
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("must not contain `^`"),
8176 "reason must surface the caret-`^` arm on the regex-anchor shape, \
8177 got {reason:?}"
8178 );
8179 assert!(
8180 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8181 "reason must name the render-determinism / BLAKE3-closure rationale, \
8182 got {reason:?}"
8183 );
8184 }
8185
8186 #[test]
8187 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8188 // Cascade pin: the `%` arm (the immediate-predecessor byte-
8189 // class arm, a323db8) and the `^` arm are both per-byte arms
8190 // inside the same `for &b in s.as_bytes()` loop, so the byte
8191 // that appears first in the value's byte order wins. A
8192 // `:repo "https://github.com/p/x%20mid^tail"` carries both
8193 // `%` and `^`; the `%` byte appears first, so the percent
8194 // arm fires, surfacing the more self-locating diagnostic on
8195 // the byte the author pasted earliest in the URL. Pins the
8196 // natural-order cascade so a future reorder of the per-byte
8197 // arms surfaces here — `^` is the most recent byte-class arm,
8198 // so the cascade-pin sweep extends to cover the immediately
8199 // prior `%` byte arm firing first when ordered ahead of `^`
8200 // in the value.
8201 let d = dep_with_fonte(DepSource::Git {
8202 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8203 tag: Some("v0.1.0".into()),
8204 rev: None,
8205 branch: None,
8206 });
8207 let err = d.validate().unwrap_err();
8208 let DepError::FonteRepoShape { reason, .. } = err else {
8209 panic!("expected FonteRepoShape, got other variant");
8210 };
8211 assert!(
8212 reason.contains("must not contain `%`"),
8213 "reason must surface the percent arm (fires before caret when `%` byte \
8214 appears first in value), got {reason:?}"
8215 );
8216 }
8217
8218 #[test]
8219 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8220 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8221 // (no `github:` prefix, no scheme). Every documented form
8222 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8223 // `file://`, or `git@host:path`); a bare `org/repo` is
8224 // ambiguous (`git clone` reads as a relative filesystem path
8225 // rather than the GitHub-shorthand expansion the author
8226 // probably intended) and the gate rejects the shape upstream.
8227 let d = dep_with_fonte(DepSource::Git {
8228 repo: "pleme-io/caixa-teia".into(),
8229 tag: Some("v0.1.0".into()),
8230 rev: None,
8231 branch: None,
8232 });
8233 let err = d.validate().unwrap_err();
8234 let DepError::FonteRepoShape { reason, .. } = err else {
8235 panic!("expected FonteRepoShape, got other variant");
8236 };
8237 assert!(
8238 reason.contains("must contain a `:`"),
8239 "reason must surface the missing-`:` arm, got {reason:?}"
8240 );
8241 assert!(
8242 reason.contains("github:"),
8243 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8244 );
8245 }
8246
8247 #[test]
8248 fn validate_rejects_git_fonte_with_repo_leading_colon() {
8249 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8250 // scheme that no git porcelain entry-point accepts. Pinned
8251 // separately from the missing-`:` arm because a value with a
8252 // leading `:` does technically contain a `:` separator; the
8253 // shape gate rejects on a dedicated arm so the diagnostic
8254 // names the specific footgun.
8255 let d = dep_with_fonte(DepSource::Git {
8256 repo: ":pleme-io/caixa-teia".into(),
8257 tag: Some("v0.1.0".into()),
8258 rev: None,
8259 branch: None,
8260 });
8261 let err = d.validate().unwrap_err();
8262 let DepError::FonteRepoShape { reason, .. } = err else {
8263 panic!("expected FonteRepoShape, got other variant");
8264 };
8265 assert!(
8266 reason.contains("must not start with `:`"),
8267 "reason must surface the leading-`:` arm, got {reason:?}"
8268 );
8269 }
8270
8271 #[test]
8272 fn validate_rejects_git_fonte_with_repo_too_long() {
8273 // The cap arm — a `:repo` value longer than
8274 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8275 // structurally untenable on every realistic landing site (the
8276 // resolver's `git clone` invocation, the future M4 CR
8277 // materializer's per-dep `repo:` axis); a value of that length
8278 // is almost certainly a paste-from-binary slug.
8279 let too_long = format!(
8280 "github:pleme-io/{}",
8281 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8282 );
8283 let d = dep_with_fonte(DepSource::Git {
8284 repo: too_long.clone(),
8285 tag: Some("v0.1.0".into()),
8286 rev: None,
8287 branch: None,
8288 });
8289 let err = d.validate().unwrap_err();
8290 let DepError::FonteRepoShape { reason, .. } = err else {
8291 panic!("expected FonteRepoShape, got other variant");
8292 };
8293 assert!(
8294 reason.contains("2048"),
8295 "reason must name the cap, got {reason:?}"
8296 );
8297 }
8298
8299 #[test]
8300 fn validate_accepts_canonical_git_fonte_repo_shapes() {
8301 // The positive-control sweep: every documented author shape on
8302 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8303 // must pass the value-shape gate. Pinned so a future tightening
8304 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8305 // here as a structural decision. Each form is exercised with the
8306 // same canonical `:tag` pin so only the `:repo` axis varies.
8307 for repo in [
8308 // The pleme-io registry-shorthand convention — `github:org/repo`.
8309 "github:pleme-io/caixa-teia",
8310 // Other host-aliased shorthands (the resolver's pluggable
8311 // host-prefix table).
8312 "gitlab:pleme-io/caixa-teia",
8313 "codeberg:pleme-io/caixa-teia",
8314 "sourcehut:~pleme-io/caixa-teia",
8315 // Full HTTPS URL with and without `.git` suffix.
8316 "https://github.com/pleme-io/caixa-teia",
8317 "https://github.com/pleme-io/caixa-teia.git",
8318 // HTTP (rare; dev / mirror).
8319 "http://example.com/pleme-io/caixa-teia.git",
8320 // SSH URL.
8321 "ssh://git@github.com/pleme-io/caixa-teia.git",
8322 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8323 // Scp-style SSH — the canonical `git@host:path` short form.
8324 "git@github.com:pleme-io/caixa-teia.git",
8325 "git@git.example.com:team/private.git",
8326 // Anonymous git protocol.
8327 "git://git.example.com/pleme-io/caixa-teia.git",
8328 // Local file URL (dev path).
8329 "file:///tmp/caixa-teia",
8330 ] {
8331 let d = dep_with_fonte(DepSource::Git {
8332 repo: repo.into(),
8333 tag: Some("v0.1.0".into()),
8334 rev: None,
8335 branch: None,
8336 });
8337 d.validate()
8338 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8339 }
8340 }
8341
8342 #[test]
8343 fn fonte_repo_empty_takes_precedence_over_shape() {
8344 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8345 // diagnostic; doesn't try to parse the URL shape) fires before
8346 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8347 // keeps its narrower error message. Mirrors
8348 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8349 // on the ordering layer.
8350 let d = dep_with_fonte(DepSource::Git {
8351 repo: String::new(),
8352 tag: Some("v0.1.0".into()),
8353 rev: None,
8354 branch: None,
8355 });
8356 let err = d.validate().unwrap_err();
8357 assert!(
8358 matches!(err, DepError::FonteRepoEmpty { .. }),
8359 "got {err:?}"
8360 );
8361 }
8362
8363 #[test]
8364 fn fonte_repo_shape_fires_before_pin_missing() {
8365 // Order pin: a malformed `:repo` value on a dep with no pin set
8366 // surfaces the `:repo` shape diagnostic (the more self-locating
8367 // axis — the `:repo` is the load-bearing identity of the source;
8368 // a missing pin is downstream from "do we even know the repo")
8369 // rather than collapsing onto the pin-missing diagnostic. The
8370 // shape gate runs inline before the pin enumeration in
8371 // `DepSource::validate`.
8372 let d = dep_with_fonte(DepSource::Git {
8373 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8374 tag: None,
8375 rev: None,
8376 branch: None,
8377 });
8378 let err = d.validate().unwrap_err();
8379 assert!(
8380 matches!(err, DepError::FonteRepoShape { .. }),
8381 "got {err:?}"
8382 );
8383 }
8384
8385 #[test]
8386 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8387 // The diagnostic-shape pin: the error names the offending
8388 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8389 // so the author can grep their caixa.lisp without re-running
8390 // the build. Mirrors the diagnostic-shape sweep on every prior
8391 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8392 let d = dep_with_fonte(DepSource::Git {
8393 repo: "pleme-io/caixa-teia".into(),
8394 tag: Some("v0.1.0".into()),
8395 rev: None,
8396 branch: None,
8397 });
8398 let err = d.validate().unwrap_err();
8399 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8400 panic!("expected FonteRepoShape, got other variant");
8401 };
8402 assert_eq!(nome, "caixa-teia");
8403 assert_eq!(repo, "pleme-io/caixa-teia");
8404 assert!(
8405 !reason.is_empty(),
8406 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8407 );
8408 }
8409
8410 #[test]
8411 fn validate_rejects_git_fonte_with_no_pin() {
8412 // The fail-before-pass-after pin for the canonical
8413 // `(:tipo git :repo "github:pleme-io/x")` shape with no
8414 // :tag/:rev/:branch — until this gate landed the resolver's
8415 // ResolveError::MissingPin surfaced at fetch time, far from the
8416 // source caixa.lisp. The new gate moves the check to validate
8417 // time and names the offending dep.
8418 let d = dep_with_fonte(DepSource::Git {
8419 repo: "github:pleme-io/caixa-teia".into(),
8420 tag: None,
8421 rev: None,
8422 branch: None,
8423 });
8424 let err = d.validate().unwrap_err();
8425 assert!(
8426 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8427 "got {err:?}"
8428 );
8429 }
8430
8431 #[test]
8432 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8433 // The canonical "pin drift" footgun: an author writes
8434 // `:tag "v1"` and later adds `:branch "main"` without removing
8435 // the :tag, and the resolver silently picks :tag (precedence
8436 // :rev > :tag > :branch). The :branch was dropped with no
8437 // diagnostic. The gate now rejects multi-pin shapes so the
8438 // author makes the precedence explicit at the source.
8439 let d = dep_with_fonte(DepSource::Git {
8440 repo: "github:pleme-io/caixa-teia".into(),
8441 tag: Some("v0.1.0".into()),
8442 rev: None,
8443 branch: Some("main".into()),
8444 });
8445 let err = d.validate().unwrap_err();
8446 let DepError::FontePinAmbiguous { nome, pins } = err else {
8447 panic!("expected FontePinAmbiguous");
8448 };
8449 assert_eq!(nome, "caixa-teia");
8450 assert!(pins.contains(":tag"));
8451 assert!(pins.contains(":branch"));
8452 assert!(!pins.contains(":rev"));
8453 }
8454
8455 #[test]
8456 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8457 // Sibling arm of the pin-drift footgun: :tag + :rev set
8458 // simultaneously. Pinned separately so a future relaxation
8459 // that only catches the (:tag, :branch) pair surfaces here.
8460 let d = dep_with_fonte(DepSource::Git {
8461 repo: "github:pleme-io/caixa-teia".into(),
8462 tag: Some("v0.1.0".into()),
8463 rev: Some("c0ffee".into()),
8464 branch: None,
8465 });
8466 let err = d.validate().unwrap_err();
8467 let DepError::FontePinAmbiguous { nome, pins } = err else {
8468 panic!("expected FontePinAmbiguous");
8469 };
8470 assert_eq!(nome, "caixa-teia");
8471 assert!(pins.contains(":tag"));
8472 assert!(pins.contains(":rev"));
8473 }
8474
8475 #[test]
8476 fn validate_rejects_git_fonte_with_all_three_pins() {
8477 // The maximal ambiguity case — every pin axis set. Pinned so a
8478 // future relaxation that only catches pairs surfaces here. The
8479 // diagnostic must enumerate every offending axis so the author
8480 // sees the full set, not just the first match.
8481 let d = dep_with_fonte(DepSource::Git {
8482 repo: "github:pleme-io/caixa-teia".into(),
8483 tag: Some("v0.1.0".into()),
8484 rev: Some("c0ffee".into()),
8485 branch: Some("main".into()),
8486 });
8487 let err = d.validate().unwrap_err();
8488 let DepError::FontePinAmbiguous { nome, pins } = err else {
8489 panic!("expected FontePinAmbiguous");
8490 };
8491 assert_eq!(nome, "caixa-teia");
8492 assert!(pins.contains(":tag"));
8493 assert!(pins.contains(":rev"));
8494 assert!(pins.contains(":branch"));
8495 }
8496
8497 #[test]
8498 fn validate_rejects_git_fonte_with_empty_tag_pin() {
8499 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8500 // inner string is empty. Distinct from FontePinMissing (where
8501 // every axis is None) — pinned separately so a future
8502 // tightening collapsing them surfaces here as a structural
8503 // decision.
8504 let d = dep_with_fonte(DepSource::Git {
8505 repo: "github:pleme-io/caixa-teia".into(),
8506 tag: Some(String::new()),
8507 rev: None,
8508 branch: None,
8509 });
8510 let err = d.validate().unwrap_err();
8511 let DepError::FontePinEmpty { nome, pin } = err else {
8512 panic!("expected FontePinEmpty");
8513 };
8514 assert_eq!(nome, "caixa-teia");
8515 assert_eq!(pin, ":tag");
8516 }
8517
8518 #[test]
8519 fn validate_rejects_git_fonte_with_empty_rev_pin() {
8520 // Sibling arm — the empty-pin diagnostic names which axis
8521 // carries the empty value, so the author's grep target is
8522 // unambiguous.
8523 let d = dep_with_fonte(DepSource::Git {
8524 repo: "github:pleme-io/caixa-teia".into(),
8525 tag: None,
8526 rev: Some(String::new()),
8527 branch: None,
8528 });
8529 let err = d.validate().unwrap_err();
8530 let DepError::FontePinEmpty { nome, pin } = err else {
8531 panic!("expected FontePinEmpty");
8532 };
8533 assert_eq!(nome, "caixa-teia");
8534 assert_eq!(pin, ":rev");
8535 }
8536
8537 #[test]
8538 fn validate_rejects_path_fonte_with_empty_caminho() {
8539 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8540 // until this gate landed the resolver's
8541 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8542 // fetch time — not actionable. The new gate moves the check to
8543 // validate time and names the offending dep.
8544 let d = dep_with_fonte(DepSource::Path {
8545 caminho: String::new(),
8546 });
8547 let err = d.validate().unwrap_err();
8548 assert!(
8549 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8550 "got {err:?}"
8551 );
8552 }
8553
8554 #[test]
8555 fn validate_rejects_path_fonte_with_absolute_caminho() {
8556 // The fail-before-pass-after pin for the absolute-`:caminho`
8557 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8558 // Until this gate landed an absolute `:caminho` silently
8559 // passed validate; the lacre pipeline embedded the
8560 // host-specific filesystem path verbatim in its
8561 // content-address (`conteudo: format!("path:{caminho}")`,
8562 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8563 // differed per machine — the build succeeded but two CI
8564 // runners with different `${HOME}` layouts emitted two
8565 // distinct lacres for the byte-identical caixa, silently
8566 // breaking the THEORY.md §V.2 render-determinism contract
8567 // far from the source caixa.lisp. The new gate moves the
8568 // check to validate time and names the offending dep +
8569 // caminho verbatim.
8570 let d = dep_with_fonte(DepSource::Path {
8571 caminho: "/home/me/work/caixa-teia".into(),
8572 });
8573 let err = d.validate().unwrap_err();
8574 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8575 panic!("expected FonteCaminhoAbsolute, got other variant");
8576 };
8577 assert_eq!(nome, "caixa-teia");
8578 assert_eq!(caminho, "/home/me/work/caixa-teia");
8579 }
8580
8581 #[test]
8582 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8583 // The canonical sibling-workspace dep form
8584 // (`:caminho "../caixa-teia"`) remains accepted. The
8585 // absolute-path gate above is specifically narrower than the
8586 // shared [`crate::render::is_sandboxed_relative_path`]
8587 // predicate (which additionally forbids `..` traversal): a
8588 // local-path dep's canonical author surface is the in-tree
8589 // sibling-workspace path, so a full sandboxed-relative-path
8590 // lift would structurally reject every legitimate path-fonte
8591 // dep. Pinned so a future tightening to the full predicate
8592 // surfaces here as a structural decision, not a silent break.
8593 let d = dep_with_fonte(DepSource::Path {
8594 caminho: "../caixa-teia".into(),
8595 });
8596 d.validate().unwrap();
8597 }
8598
8599 #[test]
8600 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8601 // A multi-segment relative `:caminho`
8602 // (`"vendor/forks/caixa-teia"`) remains accepted — the
8603 // absolute-path gate brackets the host-layout-leaking shape
8604 // at the leading-`/` boundary only; every relative shape past
8605 // the empty arm continues to pass. Pinned alongside the
8606 // `..`-traversal positive control so a future tightening
8607 // surfaces the full set of legitimate relative forms here
8608 // rather than at a downstream consumer.
8609 let d = dep_with_fonte(DepSource::Path {
8610 caminho: "vendor/forks/caixa-teia".into(),
8611 });
8612 d.validate().unwrap();
8613 }
8614
8615 #[test]
8616 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8617 // The fail-before-pass-after pin for the tilde-expansion
8618 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8619 // Until this gate landed the b94fd83 absolute arm let `~/foo`
8620 // through (`Path::is_absolute` returns false on a leading `~`
8621 // — the tilde is a shell-expansion convention, not a POSIX
8622 // path component), so the lacre embedded the value verbatim
8623 // and the resolver folded it through `Path::join` without
8624 // expansion, looking for a literal `./~/work/caixa-teia`
8625 // subdirectory and failing at resolve time with a
8626 // `No such file or directory` error far from the source
8627 // caixa.lisp. The new gate moves the check to validate time
8628 // and names the offending dep + caminho verbatim.
8629 let d = dep_with_fonte(DepSource::Path {
8630 caminho: "~/work/caixa-teia".into(),
8631 });
8632 let err = d.validate().unwrap_err();
8633 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8634 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8635 };
8636 assert_eq!(nome, "caixa-teia");
8637 assert_eq!(caminho, "~/work/caixa-teia");
8638 }
8639
8640 #[test]
8641 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8642 // The bare `~` form (canonical "I meant `$HOME` and forgot
8643 // the rest"): both the leading-tilde arm catches it and the
8644 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8645 // sweeps through the same arm. Pinned both to ensure the
8646 // gate doesn't narrow to `~/` only.
8647 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8648 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8649 let err = d.validate().unwrap_err();
8650 assert!(
8651 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8652 "{s:?} → {err:?}",
8653 );
8654 }
8655 }
8656
8657 #[test]
8658 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8659 // The leading-`~` is the canonical shell-expansion footgun —
8660 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8661 // backup-file-suffix idiom) is a legitimate POSIX path byte
8662 // with no shell-expansion semantic at the leading position.
8663 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8664 // sweep that would break every legitimate-shape backup-file
8665 // path.
8666 let d = dep_with_fonte(DepSource::Path {
8667 caminho: "../foo~bar/caixa-teia".into(),
8668 });
8669 d.validate().unwrap();
8670 }
8671
8672 #[test]
8673 fn fonte_caminho_empty_fires_before_tilde_expansion() {
8674 // Cascade pin: the empty arm structurally precedes the
8675 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8676 // pin establishes the precedence at the diagnostic-shape
8677 // level should a future codec round-trip ever produce a
8678 // probe-as-both value. Mirrors the peer
8679 // `fonte_repo_empty_fires_before_pin_missing` cascade
8680 // discipline.
8681 let d = dep_with_fonte(DepSource::Path {
8682 caminho: String::new(),
8683 });
8684 let err = d.validate().unwrap_err();
8685 assert!(
8686 matches!(err, DepError::FonteCaminhoEmpty { .. }),
8687 "got {err:?}",
8688 );
8689 }
8690
8691 #[test]
8692 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8693 // Diagnostic-shape pin (peer with
8694 // `validate_rejects_path_fonte_with_absolute_caminho`'s
8695 // payload assertion): the error's Display surfaces both the
8696 // offending `:nome` and the offending `:caminho` verbatim
8697 // so a `feira lint` run can render the diagnostic without
8698 // re-parsing.
8699 let d = dep_with_fonte(DepSource::Path {
8700 caminho: "~alice/dev/caixa-teia".into(),
8701 });
8702 let rendered = d.validate().unwrap_err().to_string();
8703 assert!(
8704 rendered.contains("caixa-teia"),
8705 "diagnostic must name the offending dep: {rendered}",
8706 );
8707 assert!(
8708 rendered.contains("~alice/dev/caixa-teia"),
8709 "diagnostic must quote the offending caminho: {rendered}",
8710 );
8711 assert!(
8712 rendered.contains('~'),
8713 "diagnostic must reference the tilde footgun: {rendered}",
8714 );
8715 }
8716
8717 #[test]
8718 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8719 // The fail-before-pass-after pin for the shell-variable-
8720 // expansion `:caminho` shape: `(:tipo path :caminho
8721 // "$HOME/work/caixa-teia")`. Until this gate landed the
8722 // b94fd83 absolute arm + the a5c248e tilde arm both let
8723 // `$HOME/foo` through (`Path::is_absolute` returns false on
8724 // a leading `$` — the `$` is a shell convention, not a POSIX
8725 // path component; `starts_with('~')` returns false too), so
8726 // the lacre embedded the value verbatim and the resolver
8727 // folded it through `Path::join` without `$`-expansion,
8728 // looking for a literal `./$HOME/work/caixa-teia`
8729 // subdirectory and failing at resolve time with a
8730 // `No such file or directory` error far from the source
8731 // caixa.lisp. The new gate moves the check to validate time
8732 // and names the offending dep + caminho verbatim.
8733 let d = dep_with_fonte(DepSource::Path {
8734 caminho: "$HOME/work/caixa-teia".into(),
8735 });
8736 let err = d.validate().unwrap_err();
8737 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8738 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8739 };
8740 assert_eq!(nome, "caixa-teia");
8741 assert_eq!(caminho, "$HOME/work/caixa-teia");
8742 }
8743
8744 #[test]
8745 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8746 // Sweep over every leading-`$` shape: the `${VAR}`-braced
8747 // form (canonical "paste-from-CI-manifest" footgun every
8748 // GitHub Actions / GitLab CI / Drone manifest carries on
8749 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8750 // canonical "I'm referencing a per-user config dir"),
8751 // and the bare `$` (canonical "I meant `$HOME` and forgot
8752 // the rest"). All shapes route through the same gate's
8753 // byte check. Pinned so the gate doesn't narrow to a
8754 // single shape (e.g. `$HOME/` only).
8755 for s in [
8756 "${HOME}/work/caixa-teia",
8757 "${WORKSPACE}/caixa-teia",
8758 "$XDG_CONFIG_HOME/caixa",
8759 "$",
8760 ] {
8761 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8762 let err = d.validate().unwrap_err();
8763 assert!(
8764 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8765 "{s:?} → {err:?}",
8766 );
8767 }
8768 }
8769
8770 #[test]
8771 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8772 // The `$` byte is the canonical shell-variable-expansion /
8773 // command-substitution / arithmetic-expansion sentinel and
8774 // is rejected at *every* position on the `:caminho` axis: the
8775 // leading arm surfaces `FonteCaminhoVarExpansion`, the
8776 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8777 // (6620f39). Pinned so a future arm doesn't narrow the gate
8778 // back to the leading position and re-open the paste-from-
8779 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8780 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8781 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8782 // the lacre content-address (`path:{caminho}`,
8783 // caixa-resolver/src/resolve.rs:189).
8784 let d = dep_with_fonte(DepSource::Path {
8785 caminho: "../foo$bar/caixa-teia".into(),
8786 });
8787 let err = d.validate().unwrap_err();
8788 assert!(
8789 matches!(
8790 err,
8791 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8792 ),
8793 "got {err:?}",
8794 );
8795 }
8796
8797 #[test]
8798 fn fonte_caminho_tilde_fires_before_var_expansion() {
8799 // Cascade pin: the tilde arm structurally precedes the var
8800 // arm (the bytes `~` and `$` don't overlap at the leading
8801 // position), but the pin establishes the precedence at the
8802 // diagnostic-shape level should a future codec round-trip
8803 // ever produce a probe-as-both value. Mirrors the peer
8804 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8805 // discipline on the immediate-predecessor arm.
8806 let d = dep_with_fonte(DepSource::Path {
8807 caminho: "~/work/caixa-teia".into(),
8808 });
8809 let err = d.validate().unwrap_err();
8810 assert!(
8811 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8812 "got {err:?}",
8813 );
8814 }
8815
8816 #[test]
8817 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8818 // Diagnostic-shape pin (peer with
8819 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8820 // payload assertion on the immediate-predecessor arm): the
8821 // error's Display surfaces both the offending `:nome` and
8822 // the offending `:caminho` verbatim plus the `$` footgun
8823 // character itself so a `feira lint` run can render the
8824 // diagnostic without re-parsing.
8825 let d = dep_with_fonte(DepSource::Path {
8826 caminho: "${WORKSPACE}/caixa-teia".into(),
8827 });
8828 let rendered = d.validate().unwrap_err().to_string();
8829 assert!(
8830 rendered.contains("caixa-teia"),
8831 "diagnostic must name the offending dep: {rendered}",
8832 );
8833 assert!(
8834 rendered.contains("${WORKSPACE}/caixa-teia"),
8835 "diagnostic must quote the offending caminho: {rendered}",
8836 );
8837 assert!(
8838 rendered.contains('$'),
8839 "diagnostic must reference the dollar footgun: {rendered}",
8840 );
8841 }
8842
8843 #[test]
8844 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8845 // The fail-before-pass-after pin for the load-bearing NUL byte:
8846 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8847 // routes the path through `CString::new` which fails with
8848 // `NulError`); until this gate landed a `:caminho
8849 // "../caixa\0teia"` silently passed validate, the lacre
8850 // pipeline embedded the value verbatim, and the failure
8851 // surfaced at the resolver's `Path::join` → `CString::new`
8852 // boundary with a non-self-locating `NulError` far from the
8853 // source caixa.lisp. The new gate moves the check to validate
8854 // time and names the offending dep + caminho + offending byte
8855 // verbatim.
8856 let d = dep_with_fonte(DepSource::Path {
8857 caminho: "../caixa\0teia".into(),
8858 });
8859 let err = d.validate().unwrap_err();
8860 let DepError::FonteCaminhoControlChar {
8861 nome,
8862 caminho,
8863 byte,
8864 } = err
8865 else {
8866 panic!("expected FonteCaminhoControlChar, got {err:?}");
8867 };
8868 assert_eq!(nome, "caixa-teia");
8869 assert_eq!(caminho, "../caixa\0teia");
8870 assert_eq!(byte, 0x00);
8871 }
8872
8873 #[test]
8874 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
8875 // The canonical paste-from-multiline-doc footgun on `:caminho`
8876 // — author copies `"../caixa-teia\n"` (trailing newline) out
8877 // of a multi-line code-fence or, worse, a `:caminho
8878 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
8879 // injection sibling on the path axis the `is_git_repo_url`
8880 // control-char arm already closes on `:repo`). Pinned
8881 // separately from the NUL arm so a future relaxation that
8882 // catches one but not the other surfaces here.
8883 let d = dep_with_fonte(DepSource::Path {
8884 caminho: "../caixa-teia\n".into(),
8885 });
8886 let err = d.validate().unwrap_err();
8887 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8888 panic!("expected FonteCaminhoControlChar, got {err:?}");
8889 };
8890 assert_eq!(byte, 0x0A);
8891 }
8892
8893 #[test]
8894 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
8895 // The CRLF sibling of the LF arm — Windows-line-ending
8896 // paste-from-multiline-doc on a `\r\n`-terminated buffer
8897 // leaves a stray `\r` mid-string after the LF strip. Pinned
8898 // separately from the LF arm so a future relaxation that
8899 // only catches LF surfaces here.
8900 let d = dep_with_fonte(DepSource::Path {
8901 caminho: "../caixa-teia\r".into(),
8902 });
8903 let err = d.validate().unwrap_err();
8904 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8905 panic!("expected FonteCaminhoControlChar, got {err:?}");
8906 };
8907 assert_eq!(byte, 0x0D);
8908 }
8909
8910 #[test]
8911 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
8912 // The canonical paste-from-aligned-table footgun — a `\t`
8913 // mid-`:caminho` is invisible in most editors but rides
8914 // through the lacre's content-address verbatim, so two
8915 // paste-from-distinct-tables (one editor strips tabs, one
8916 // preserves them) yield divergent lacres for the byte-
8917 // identical-looking caixa. Pinned separately from the
8918 // whitespace-shaped LF/CR arms so a future relaxation that
8919 // narrows to line-terminator-only surfaces here.
8920 let d = dep_with_fonte(DepSource::Path {
8921 caminho: "../caixa\tteia".into(),
8922 });
8923 let err = d.validate().unwrap_err();
8924 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8925 panic!("expected FonteCaminhoControlChar, got {err:?}");
8926 };
8927 assert_eq!(byte, 0x09);
8928 }
8929
8930 #[test]
8931 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
8932 // The DEL byte (`0x7F`) closes the upper-end paste-from-
8933 // binary-blob footgun — the gate's contract is `b < 0x20 ||
8934 // b == 0x7F`, matching the `is_git_repo_url` /
8935 // `is_git_ref_name` predicates' control-char arms. Pinned
8936 // separately from the lower-range arms so a future narrowing
8937 // to `< 0x20` only surfaces here.
8938 let d = dep_with_fonte(DepSource::Path {
8939 caminho: "../caixa\x7fteia".into(),
8940 });
8941 let err = d.validate().unwrap_err();
8942 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
8943 panic!("expected FonteCaminhoControlChar, got {err:?}");
8944 };
8945 assert_eq!(byte, 0x7F);
8946 }
8947
8948 #[test]
8949 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
8950 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
8951 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
8952 // are opaque byte sequences and UTF-8 multi-byte sequences
8953 // are a legitimate filename shape (the `café-teia/foo` idiom).
8954 // Pinned so the gate doesn't widen to a full ASCII-only sweep
8955 // that would break every legitimate-shape UTF-8 path.
8956 let d = dep_with_fonte(DepSource::Path {
8957 caminho: "../café-teia/foo".into(),
8958 });
8959 d.validate().unwrap();
8960 }
8961
8962 #[test]
8963 fn fonte_caminho_var_fires_before_control_char() {
8964 // Cascade pin: the var-expansion arm structurally precedes the
8965 // control-char arm. A value like `"$\n"` probes positive on
8966 // both arms (`starts_with('$')` and contains LF), but the
8967 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
8968 // wins so the author sees the more self-locating shell-
8969 // expansion arm first. Mirrors the
8970 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
8971 // discipline on the immediate-predecessor arm.
8972 let d = dep_with_fonte(DepSource::Path {
8973 caminho: "$HOME\n".into(),
8974 });
8975 let err = d.validate().unwrap_err();
8976 assert!(
8977 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8978 "got {err:?}",
8979 );
8980 }
8981
8982 #[test]
8983 fn validate_rejects_path_fonte_with_leading_space_caminho() {
8984 // The fail-before-pass-after pin for the leading ASCII space
8985 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
8986 // Until this gate landed the b94fd83 absolute arm + the a5c248e
8987 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
8988 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
8989 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
8990 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
8991 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
8992 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
8993 // are caught, but the most common whitespace `0x20` space is
8994 // not). The lacre embedded the value verbatim and the resolver
8995 // folded it through `Path::join` looking for a literal `./ ../
8996 // caixa-teia` subdirectory and failing at resolve time with a
8997 // non-self-locating `No such file or directory` error far from
8998 // the source caixa.lisp. The new gate moves the check to
8999 // validate time and names the offending dep + caminho verbatim.
9000 let d = dep_with_fonte(DepSource::Path {
9001 caminho: " ../caixa-teia".into(),
9002 });
9003 let err = d.validate().unwrap_err();
9004 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9005 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9006 };
9007 assert_eq!(nome, "caixa-teia");
9008 assert_eq!(caminho, " ../caixa-teia");
9009 }
9010
9011 #[test]
9012 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9013 // The aligned-doc paste footgun sweep: more than one leading
9014 // space (`" ../caixa-teia"` — the canonical "I selected the
9015 // aligned column from a four-`:fonte`-entry `:deps` block"
9016 // paste) routes through the same gate's `starts_with(' ')`
9017 // byte check. Pinned so the gate doesn't narrow to a
9018 // single-space prefix.
9019 let d = dep_with_fonte(DepSource::Path {
9020 caminho: " ../caixa-teia".into(),
9021 });
9022 let err = d.validate().unwrap_err();
9023 assert!(
9024 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9025 "got {err:?}",
9026 );
9027 }
9028
9029 #[test]
9030 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9031 // The leading-space is the canonical paste-from-aligned-doc
9032 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9033 // canonical "I have a directory with a space in its name"
9034 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9035 // legitimate path with no whitespace-leak semantic at the
9036 // non-leading position. Pinned so the gate doesn't widen to a
9037 // full no-space-anywhere sweep that would break every
9038 // legitimate-shape space-in-filename path.
9039 let d = dep_with_fonte(DepSource::Path {
9040 caminho: "../my dir/caixa-teia".into(),
9041 });
9042 d.validate().unwrap();
9043 }
9044
9045 #[test]
9046 fn fonte_caminho_var_fires_before_leading_whitespace() {
9047 // Cascade pin: the var-expansion arm structurally precedes the
9048 // leading-whitespace arm. A value like `"$ "` would probe positive
9049 // on var (`starts_with('$')`) but the leading-byte arms walk
9050 // left-to-right so the var arm fires on the leading `$` before
9051 // the leading-whitespace arm probes. Mirrors the
9052 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9053 // discipline on the immediate-predecessor arms.
9054 let d = dep_with_fonte(DepSource::Path {
9055 caminho: "$VAR".into(),
9056 });
9057 let err = d.validate().unwrap_err();
9058 assert!(
9059 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9060 "got {err:?}",
9061 );
9062 }
9063
9064 #[test]
9065 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9066 // Cascade pin: the leading-whitespace arm structurally precedes
9067 // the control-char arm. A value like `" ../foo\n"` probes
9068 // positive on both (starts with space AND contains LF), but
9069 // the narrower leading-byte diagnostic
9070 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9071 // more self-locating paste-from-aligned-doc arm first. Mirrors
9072 // the `fonte_caminho_var_fires_before_control_char` cascade
9073 // discipline on the immediate-predecessor arm.
9074 let d = dep_with_fonte(DepSource::Path {
9075 caminho: " ../foo\n".into(),
9076 });
9077 let err = d.validate().unwrap_err();
9078 assert!(
9079 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9080 "got {err:?}",
9081 );
9082 }
9083
9084 #[test]
9085 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9086 // Diagnostic-shape pin (peer with
9087 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9088 // payload assertion on the immediate-predecessor arm): the
9089 // error's Display surfaces both the offending `:nome` and the
9090 // offending `:caminho` verbatim, so a `feira lint` run can
9091 // render the diagnostic without re-parsing and the author can
9092 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9093 // one edit.
9094 let d = dep_with_fonte(DepSource::Path {
9095 caminho: " ../caixa-teia".into(),
9096 });
9097 let rendered = d.validate().unwrap_err().to_string();
9098 assert!(
9099 rendered.contains("caixa-teia"),
9100 "diagnostic must name the offending dep: {rendered}",
9101 );
9102 assert!(
9103 rendered.contains(" ../caixa-teia"),
9104 "diagnostic must quote the offending caminho: {rendered}",
9105 );
9106 assert!(
9107 rendered.contains("space"),
9108 "diagnostic must name the space footgun: {rendered}",
9109 );
9110 }
9111
9112 #[test]
9113 fn fonte_caminho_absolute_fires_before_control_char() {
9114 // Cascade pin on the sibling leading-byte arm: a leading `/`
9115 // value with embedded control byte (`"/etc/passwd\n"`) routes
9116 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9117 // — the host-layout-leak diagnostic is the load-bearing axis,
9118 // the control byte is the secondary observation. Same precedence
9119 // logic on every prior leading-byte arm.
9120 let d = dep_with_fonte(DepSource::Path {
9121 caminho: "/etc/passwd\n".into(),
9122 });
9123 let err = d.validate().unwrap_err();
9124 assert!(
9125 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9126 "got {err:?}",
9127 );
9128 }
9129
9130 #[test]
9131 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9132 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9133 // injection `:caminho` shape sweep. Until this gate landed
9134 // every prior leading-byte arm passed a leading-`-` value
9135 // through: `Path::is_absolute` returns false on `-` (the
9136 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9137 // `starts_with('$')` / `starts_with(' ')` all return false,
9138 // and `0x2D` sits outside the control-byte set. The lacre
9139 // embedded the value verbatim and the resolver folded it
9140 // through `Path::join` looking for a literal `./-rf` /
9141 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9142 // `Path::join` time is non-self-locating but harmless, while
9143 // the failure at every downstream `git -C {caminho}` /
9144 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9145 // is arbitrary-CLI-arg-injection because none of those
9146 // porcelains carry a `--` argument-list terminator between
9147 // the flag block and the path argument. The new arm moves the
9148 // rejection to `Caixa::from_lisp` boundary time and names
9149 // the offending dep + caminho verbatim.
9150 //
9151 // Sweep spans the canonical CLI-arg-injection shapes matching
9152 // the peer sweep on the sibling `is_git_ref_name` /
9153 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9154 // `find -rf` reinterpretation vector), `-C` (the `git -C`
9155 // change-directory-config-injection paste), long-flag
9156 // `--upload-pack=cat /etc/passwd` (the canonical
9157 // arbitrary-command-execution vector on every git porcelain
9158 // entry point), git-config-injection `--config=core.merge=ours`,
9159 // and the degenerate single-byte `-` value.
9160 for caminho in [
9161 "-rf",
9162 "-C",
9163 "--upload-pack=cat /etc/passwd",
9164 "--config=core.merge=ours",
9165 "-",
9166 ] {
9167 let d = dep_with_fonte(DepSource::Path {
9168 caminho: caminho.into(),
9169 });
9170 let err = d.validate().unwrap_err();
9171 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9172 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9173 };
9174 assert_eq!(nome, "caixa-teia");
9175 assert_eq!(got, caminho);
9176 }
9177 }
9178
9179 #[test]
9180 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9181 // The leading-`-` is the canonical CLI-arg-injection footgun
9182 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9183 // canonical kebab-separator-between-alphanumeric-segments
9184 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9185 // — a mid-path segment starting with `-`, still a legitimate
9186 // POSIX filename byte at that non-leading position because the
9187 // subprocess reads the whole `{caminho}` value as one positional
9188 // argument, so only the very first byte of the composite path
9189 // string is at the CLI-arg-injection boundary) is a legitimate
9190 // path with no CLI-flag-reinterpretation semantic at the non-
9191 // leading position of the top-level value. Pinned so the gate
9192 // doesn't widen to a full no-`-`-anywhere sweep that would
9193 // break every legitimate-shape kebab-in-filename path (i.e.
9194 // essentially every sibling-workspace caixa dep).
9195 for caminho in [
9196 "../caixa-teia",
9197 "../caixa-teia/-hidden",
9198 "./my-lib",
9199 "../foo-bar/baz",
9200 ] {
9201 let d = dep_with_fonte(DepSource::Path {
9202 caminho: caminho.into(),
9203 });
9204 d.validate()
9205 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9206 }
9207 }
9208
9209 #[test]
9210 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9211 // Cascade pin: the leading-whitespace arm structurally precedes
9212 // the leading-hyphen arm. A value like `" -rf"` probes positive
9213 // on both (leading space AND, one byte in, a `-` — though the
9214 // leading-hyphen arm probes only the very first byte so it
9215 // wouldn't fire on this value; the pin instead documents the
9216 // arm order on the more common "leading space then a hyphen"
9217 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9218 // The narrower leading-space diagnostic (the paste-from-aligned-
9219 // doc footgun) wins so the author sees the more self-locating
9220 // whitespace arm first. Mirrors the
9221 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9222 // discipline on the immediate-predecessor arm.
9223 let d = dep_with_fonte(DepSource::Path {
9224 caminho: " -rf".into(),
9225 });
9226 let err = d.validate().unwrap_err();
9227 assert!(
9228 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9229 "got {err:?}",
9230 );
9231 }
9232
9233 #[test]
9234 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9235 // Cascade pin: the leading-hyphen arm structurally precedes
9236 // the control-char arm. A value like `"-rf\n"` probes positive
9237 // on both (starts with `-` AND contains LF), but the narrower
9238 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9239 // the author sees the more self-locating CLI-arg-injection arm
9240 // first. Mirrors the
9241 // `fonte_caminho_leading_whitespace_fires_before_control_char`
9242 // cascade discipline on the immediate-predecessor arm.
9243 let d = dep_with_fonte(DepSource::Path {
9244 caminho: "-rf\n".into(),
9245 });
9246 let err = d.validate().unwrap_err();
9247 assert!(
9248 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9249 "got {err:?}",
9250 );
9251 }
9252
9253 #[test]
9254 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9255 // Diagnostic-shape pin (peer with
9256 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9257 // payload assertion on the immediate-predecessor arm): the
9258 // error's Display surfaces both the offending `:nome` and the
9259 // offending `:caminho` verbatim plus the CLI-argument-injection
9260 // vocabulary, so a `feira lint` run can render the diagnostic
9261 // without re-parsing and the author can grep their caixa.lisp
9262 // for `:caminho "<value>"` and fix it in one edit.
9263 let d = dep_with_fonte(DepSource::Path {
9264 caminho: "--upload-pack=cat /etc/passwd".into(),
9265 });
9266 let rendered = d.validate().unwrap_err().to_string();
9267 assert!(
9268 rendered.contains("caixa-teia"),
9269 "diagnostic must name the offending dep: {rendered}",
9270 );
9271 assert!(
9272 rendered.contains("--upload-pack=cat /etc/passwd"),
9273 "diagnostic must quote the offending caminho: {rendered}",
9274 );
9275 assert!(
9276 rendered.contains("CLI-argument-injection"),
9277 "diagnostic must name the CLI-argument-injection vector: {rendered}",
9278 );
9279 assert!(
9280 rendered.contains("`-`"),
9281 "diagnostic must name the offending byte: {rendered}",
9282 );
9283 }
9284
9285 #[test]
9286 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9287 // Diagnostic-shape pin (peer with
9288 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9289 // payload assertion on the immediate-predecessor arm): the
9290 // error's Display surfaces the offending `:nome`, the
9291 // offending `:caminho` verbatim, and the offending byte in
9292 // hex form (`0x09` for tab) so a `feira lint` run can render
9293 // the diagnostic without re-parsing.
9294 let d = dep_with_fonte(DepSource::Path {
9295 caminho: "../caixa\tteia".into(),
9296 });
9297 let rendered = d.validate().unwrap_err().to_string();
9298 assert!(
9299 rendered.contains("caixa-teia"),
9300 "diagnostic must name the offending dep: {rendered}",
9301 );
9302 assert!(
9303 rendered.contains("../caixa\tteia"),
9304 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9305 );
9306 assert!(
9307 rendered.contains("0x09"),
9308 "diagnostic must name the offending byte in hex: {rendered:?}",
9309 );
9310 }
9311
9312 #[test]
9313 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9314 // The fail-before-pass-after pin for the canonical Windows-
9315 // path-separator paste footgun: an author who pastes a path
9316 // from Windows-Explorer's `Copy as path`, PowerShell's
9317 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9318 // produces `..\caixa-teia`-shape values that silently passed
9319 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9320 // false; `\` is neither a leading-byte sentinel nor a
9321 // control byte). On POSIX resolvers the value rides through
9322 // `Path::join` as a literal directory name and fails at
9323 // resolve time with `No such file or directory`; on Windows
9324 // resolvers the value resolves to the parent's sibling — two
9325 // distinct directories for the byte-identical caixa.lisp.
9326 // The new arm moves the rejection to validate time and names
9327 // the offending dep + caminho verbatim.
9328 let d = dep_with_fonte(DepSource::Path {
9329 caminho: "..\\caixa-teia".into(),
9330 });
9331 let err = d.validate().unwrap_err();
9332 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9333 panic!("expected FonteCaminhoBackslash, got {err:?}");
9334 };
9335 assert_eq!(nome, "caixa-teia");
9336 assert_eq!(caminho, "..\\caixa-teia");
9337 }
9338
9339 #[test]
9340 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9341 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9342 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9343 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9344 // false (POSIX absolute paths start with `/`, drive letters
9345 // are not a POSIX concept), so the b94fd83 absolute arm
9346 // doesn't fire; the value contains `\` bytes that this arm
9347 // now catches with the more self-locating Windows-path-
9348 // separator diagnostic. Pinned separately from the bare
9349 // `..\caixa-teia` shape so a future arm that targets only
9350 // leading-`..\` doesn't regress the drive-letter coverage.
9351 let d = dep_with_fonte(DepSource::Path {
9352 caminho: "C:\\work\\caixa-teia".into(),
9353 });
9354 let err = d.validate().unwrap_err();
9355 assert!(
9356 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9357 "got {err:?}",
9358 );
9359 }
9360
9361 #[test]
9362 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9363 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9364 // PowerShell tab-completion-on-a-directory append). Pinned
9365 // separately from the embedded-`\` shape so the gate's
9366 // contract is "any `\` anywhere", not "any `\` not at end".
9367 let d = dep_with_fonte(DepSource::Path {
9368 caminho: "..\\caixa-teia\\".into(),
9369 });
9370 let err = d.validate().unwrap_err();
9371 assert!(
9372 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9373 "got {err:?}",
9374 );
9375 }
9376
9377 #[test]
9378 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9379 // The positive-control pin: the gate targets `\` only,
9380 // never `/`. The canonical relative POSIX path
9381 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9382 // so legitimate nested-directory deps aren't broken. Pinned
9383 // so the gate doesn't accidentally widen to a "no path
9384 // separators at all" sweep.
9385 let d = dep_with_fonte(DepSource::Path {
9386 caminho: "../caixa-teia/foo/bar".into(),
9387 });
9388 d.validate().unwrap();
9389 }
9390
9391 #[test]
9392 fn fonte_caminho_control_char_fires_before_backslash() {
9393 // Cascade pin: the control-char arm structurally precedes the
9394 // backslash arm. A value like `"..\caixa\0teia"` probes
9395 // positive on both (`\` byte + NUL byte), but the control-
9396 // char diagnostic wins so the author sees the more self-
9397 // locating POSIX-syscall-rejected-byte diagnostic first
9398 // (NUL outright breaks `CString::new` at every `std::fs`
9399 // syscall boundary; the `\` divergence is the cross-OS-
9400 // separator axis). Mirrors the
9401 // `fonte_caminho_var_fires_before_control_char` cascade
9402 // discipline on the immediate-predecessor arm.
9403 let d = dep_with_fonte(DepSource::Path {
9404 caminho: "..\\caixa\0teia".into(),
9405 });
9406 let err = d.validate().unwrap_err();
9407 assert!(
9408 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9409 "got {err:?}",
9410 );
9411 }
9412
9413 #[test]
9414 fn fonte_caminho_absolute_fires_before_backslash() {
9415 // Cascade pin on the load-bearing leading-byte arm: a leading
9416 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9417 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9418 // — the host-layout-leak diagnostic is the load-bearing
9419 // axis, the `\` byte is the secondary observation. Same
9420 // precedence logic as every prior leading-byte arm.
9421 let d = dep_with_fonte(DepSource::Path {
9422 caminho: "/etc/passwd\\foo".into(),
9423 });
9424 let err = d.validate().unwrap_err();
9425 assert!(
9426 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9427 "got {err:?}",
9428 );
9429 }
9430
9431 #[test]
9432 fn fonte_caminho_var_fires_before_backslash() {
9433 // Cascade pin on the var-expansion arm: a leading-`$` value
9434 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9435 // PowerShell-env-var paste-from-CI-manifest footgun) routes
9436 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9437 // The shell-expansion diagnostic is the more self-locating
9438 // axis since both the leading `$` and the embedded `\`
9439 // are Windows-shell artifacts but the `$` is the root-cause
9440 // surface (an author who removes the `$` is likely to leave
9441 // the `\` too).
9442 let d = dep_with_fonte(DepSource::Path {
9443 caminho: "$WORKSPACE\\caixa-teia".into(),
9444 });
9445 let err = d.validate().unwrap_err();
9446 assert!(
9447 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9448 "got {err:?}",
9449 );
9450 }
9451
9452 #[test]
9453 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9454 // Diagnostic-shape pin (peer with the prior
9455 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9456 // on every preceding arm): the error's Display surfaces the
9457 // offending `:nome` and the offending `:caminho` verbatim
9458 // so a `feira lint` run can render the diagnostic without
9459 // re-parsing.
9460 let d = dep_with_fonte(DepSource::Path {
9461 caminho: "..\\caixa-teia".into(),
9462 });
9463 let rendered = d.validate().unwrap_err().to_string();
9464 assert!(
9465 rendered.contains("caixa-teia"),
9466 "diagnostic must name the offending dep: {rendered}",
9467 );
9468 assert!(
9469 rendered.contains("..\\caixa-teia"),
9470 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9471 );
9472 assert!(
9473 rendered.contains('\\'),
9474 "diagnostic must reference the backslash footgun: {rendered:?}",
9475 );
9476 }
9477
9478 #[test]
9479 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9480 // The fail-before-pass-after pin for the canonical trailing-`/`
9481 // paste footgun: an author who shell-tab-completes a sibling
9482 // directory (every interactive shell — bash/zsh/fish/nushell —
9483 // appends `/` on tab-completing a directory) produces
9484 // `"../caixa-teia/"`-shape values that silently passed every
9485 // prior arm (the leading byte is `.`, no control bytes, no
9486 // backslash). `Path::join` resolves both shapes to the same
9487 // directory at the resolver, but the lacre embeds the value
9488 // verbatim and the BLAKE3 closures diverge across two
9489 // workstations whose authors differ only in tab-completion
9490 // habits.
9491 let d = dep_with_fonte(DepSource::Path {
9492 caminho: "../caixa-teia/".into(),
9493 });
9494 let err = d.validate().unwrap_err();
9495 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9496 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9497 };
9498 assert_eq!(nome, "caixa-teia");
9499 assert_eq!(caminho, "../caixa-teia/");
9500 }
9501
9502 #[test]
9503 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9504 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9505 // directory and tab-completed it" footgun). Pinned separately
9506 // from the canonical `"../caixa-teia/"` shape so the gate's
9507 // contract is "any trailing `/`", not "trailing `/` after a leaf
9508 // name".
9509 let d = dep_with_fonte(DepSource::Path {
9510 caminho: "./".into(),
9511 });
9512 let err = d.validate().unwrap_err();
9513 assert!(
9514 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9515 "got {err:?}",
9516 );
9517 }
9518
9519 #[test]
9520 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9521 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9522 // that double-templated `${VAR}/` over an already-`/`-suffixed
9523 // path" footgun). The gate fires on the last byte being `/`
9524 // regardless of how many `/` precede it; the arm contract is
9525 // "the value ends with `/`", structurally.
9526 let d = dep_with_fonte(DepSource::Path {
9527 caminho: "../caixa-teia//".into(),
9528 });
9529 let err = d.validate().unwrap_err();
9530 assert!(
9531 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9532 "got {err:?}",
9533 );
9534 }
9535
9536 #[test]
9537 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9538 // The `"../"` shape (the canonical "I want the parent" tab-
9539 // completion footgun on a bare `..` path). Pinned separately so
9540 // the gate doesn't accidentally narrow to "trailing `/` only on
9541 // multi-segment paths".
9542 let d = dep_with_fonte(DepSource::Path {
9543 caminho: "../".into(),
9544 });
9545 let err = d.validate().unwrap_err();
9546 assert!(
9547 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9548 "got {err:?}",
9549 );
9550 }
9551
9552 #[test]
9553 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9554 // The positive-control pin: the gate targets the trailing byte
9555 // only, never internal `/` separators. The canonical nested
9556 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9557 // to validate cleanly so legitimate deeply-nested deps aren't
9558 // broken. Pinned so the gate doesn't accidentally widen to a
9559 // "no `/` separators anywhere" sweep that would defeat the
9560 // entire path-fonte author surface.
9561 let d = dep_with_fonte(DepSource::Path {
9562 caminho: "../caixa-teia/foo/bar".into(),
9563 });
9564 d.validate().unwrap();
9565 }
9566
9567 #[test]
9568 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9569 // The positive-control pin on the degenerate single-`.` shape
9570 // (the canonical "the caixa.lisp's own directory" idiom). The
9571 // gate fires on the trailing byte being `/`, not on the path
9572 // being short, so `"."` (one byte, not `/`) must continue to
9573 // validate cleanly.
9574 let d = dep_with_fonte(DepSource::Path {
9575 caminho: ".".into(),
9576 });
9577 d.validate().unwrap();
9578 }
9579
9580 #[test]
9581 fn fonte_caminho_control_char_fires_before_trailing_slash() {
9582 // Cascade pin: the control-char arm structurally precedes the
9583 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9584 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9585 // (control bytes are the paste-from-multiline-doc footgun the
9586 // d624c8d arm already closes). Mirrors the
9587 // `fonte_caminho_control_char_fires_before_backslash` cascade
9588 // discipline on the immediate-predecessor arm.
9589 let d = dep_with_fonte(DepSource::Path {
9590 caminho: "../foo\n/".into(),
9591 });
9592 let err = d.validate().unwrap_err();
9593 assert!(
9594 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9595 "got {err:?}",
9596 );
9597 }
9598
9599 #[test]
9600 fn fonte_caminho_backslash_fires_before_trailing_slash() {
9601 // Cascade pin on the backslash arm: a value like `"..\foo/"`
9602 // ends in `/` but the embedded `\` is the load-bearing
9603 // diagnostic (the cross-host-OS-separator divergence vector
9604 // the 3a4e1d7 arm closes). Same precedence logic as the prior
9605 // narrower-diagnostic-first cascade.
9606 let d = dep_with_fonte(DepSource::Path {
9607 caminho: "..\\caixa-teia/".into(),
9608 });
9609 let err = d.validate().unwrap_err();
9610 assert!(
9611 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9612 "got {err:?}",
9613 );
9614 }
9615
9616 #[test]
9617 fn fonte_caminho_absolute_fires_before_trailing_slash() {
9618 // Cascade pin on the load-bearing leading-byte arm: a leading
9619 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9620 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9621 // — the host-layout-leak diagnostic is the load-bearing axis,
9622 // the trailing `/` is the secondary observation. Same
9623 // precedence logic as every prior leading-byte arm.
9624 let d = dep_with_fonte(DepSource::Path {
9625 caminho: "/etc/passwd/".into(),
9626 });
9627 let err = d.validate().unwrap_err();
9628 assert!(
9629 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9630 "got {err:?}",
9631 );
9632 }
9633
9634 #[test]
9635 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9636 // Diagnostic-shape pin (peer with the prior
9637 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9638 // every preceding arm): the error's Display surfaces the
9639 // offending `:nome` and the offending `:caminho` verbatim so a
9640 // `feira lint` run can render the diagnostic without re-parsing.
9641 let d = dep_with_fonte(DepSource::Path {
9642 caminho: "../caixa-teia/".into(),
9643 });
9644 let rendered = d.validate().unwrap_err().to_string();
9645 assert!(
9646 rendered.contains("caixa-teia"),
9647 "diagnostic must name the offending dep: {rendered}",
9648 );
9649 assert!(
9650 rendered.contains("../caixa-teia/"),
9651 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9652 );
9653 assert!(
9654 rendered.contains("trailing"),
9655 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9656 );
9657 }
9658
9659 // -- :caminho shell-redirection metacharacter arm -----------------------
9660
9661 #[test]
9662 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9663 // The fail-before-pass-after pin for the canonical output-redirection
9664 // paste footgun: an author copies a shell pipeline tail
9665 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9666 // line including the `> build.log` redirect" idiom) and silently
9667 // passed every prior arm (`Path::is_absolute` false on `..`, no
9668 // control bytes, no backslash, doesn't end in `/`). The lacre
9669 // embedded the value verbatim, the resolver folded it through
9670 // `Path::join` looking for a literal `./../caixa-teia>build.log`
9671 // subdirectory, and the failure surfaced at resolve time with a
9672 // non-self-locating `No such file or directory` error. The new arm
9673 // moves the rejection to validate time and names the offending dep
9674 // + caminho + byte verbatim.
9675 let d = dep_with_fonte(DepSource::Path {
9676 caminho: "../caixa-teia>build.log".into(),
9677 });
9678 let err = d.validate().unwrap_err();
9679 let DepError::FonteCaminhoShellRedirection {
9680 nome,
9681 caminho,
9682 byte,
9683 } = err
9684 else {
9685 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9686 };
9687 assert_eq!(nome, "caixa-teia");
9688 assert_eq!(caminho, "../caixa-teia>build.log");
9689 assert_eq!(byte, b'>');
9690 }
9691
9692 #[test]
9693 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9694 // The symmetric input-redirection paste shape
9695 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9696 // `command < input.lisp` line from a tatara-lisp REPL log"
9697 // idiom). Pinned separately from the `>` shape so the gate's
9698 // contract is "any `<` or `>` anywhere", not single-byte coverage.
9699 let d = dep_with_fonte(DepSource::Path {
9700 caminho: "../caixa-teia<input.lisp".into(),
9701 });
9702 let err = d.validate().unwrap_err();
9703 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9704 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9705 };
9706 assert_eq!(byte, b'<');
9707 }
9708
9709 #[test]
9710 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9711 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9712 // "I forgot the source side of the redirect" idiom). Pinned
9713 // separately from the embedded-byte shapes so the gate covers
9714 // every position, not only mid-path.
9715 let d = dep_with_fonte(DepSource::Path {
9716 caminho: ">../caixa-teia".into(),
9717 });
9718 let err = d.validate().unwrap_err();
9719 assert!(
9720 matches!(
9721 err,
9722 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9723 ),
9724 "got {err:?}",
9725 );
9726 }
9727
9728 #[test]
9729 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9730 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9731 // the canonical "I copied a `>>` append redirect" idiom). The arm
9732 // fires on the first `>` encountered; pinned so a future arm that
9733 // tries to distinguish `>` from `>>` doesn't break the broader
9734 // contract.
9735 let d = dep_with_fonte(DepSource::Path {
9736 caminho: "../caixa-teia>>build.log".into(),
9737 });
9738 let err = d.validate().unwrap_err();
9739 assert!(
9740 matches!(
9741 err,
9742 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9743 ),
9744 "got {err:?}",
9745 );
9746 }
9747
9748 #[test]
9749 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9750 // The positive-control pin: the gate targets only `<` / `>`,
9751 // never adjacent printable ASCII or POSIX-valid bytes. The
9752 // canonical relative POSIX path (`"../caixa-teia"`) and a
9753 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9754 // continue to validate cleanly so the gate doesn't widen to a
9755 // "no printable punctuation anywhere" sweep that would defeat
9756 // the entire path-fonte author surface.
9757 let d = dep_with_fonte(DepSource::Path {
9758 caminho: "../caixa-teia/foo/bar".into(),
9759 });
9760 d.validate().unwrap();
9761 }
9762
9763 #[test]
9764 fn fonte_caminho_backslash_fires_before_shell_redirection() {
9765 // Cascade pin on the immediate-predecessor arm: a value carrying
9766 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9767 // canonical "I pasted a Windows-shell command with output
9768 // redirect" footgun) routes through `FonteCaminhoBackslash` not
9769 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9770 // divergence is the load-bearing axis (an author who removes
9771 // the `\` is the root-cause edit; the `>` falls away in the
9772 // same edit since it's downstream of the Windows-shell
9773 // convention).
9774 let d = dep_with_fonte(DepSource::Path {
9775 caminho: "..\\caixa-teia>build.log".into(),
9776 });
9777 let err = d.validate().unwrap_err();
9778 assert!(
9779 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9780 "got {err:?}",
9781 );
9782 }
9783
9784 #[test]
9785 fn fonte_caminho_control_char_fires_before_shell_redirection() {
9786 // Cascade pin on the embedded-control-byte arm: a value carrying
9787 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9788 // canonical paste-from-multiline-doc footgun where a newline
9789 // landed mid-caminho) routes through `FonteCaminhoControlChar`
9790 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9791 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9792 // load-bearing axis on every value that probes positive for
9793 // both — mirrors the cascade discipline on every prior arm.
9794 let d = dep_with_fonte(DepSource::Path {
9795 caminho: "../foo\n>bar".into(),
9796 });
9797 let err = d.validate().unwrap_err();
9798 assert!(
9799 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9800 "got {err:?}",
9801 );
9802 }
9803
9804 #[test]
9805 fn fonte_caminho_absolute_fires_before_shell_redirection() {
9806 // Cascade pin on the load-bearing leading-byte arm: a leading
9807 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9808 // routes through `FonteCaminhoAbsolute` not
9809 // `FonteCaminhoShellRedirection` — the host-layout-leak
9810 // diagnostic is the load-bearing axis, the `>` byte is the
9811 // secondary observation. Same precedence logic as every prior
9812 // leading-byte arm.
9813 let d = dep_with_fonte(DepSource::Path {
9814 caminho: "/etc/passwd>out".into(),
9815 });
9816 let err = d.validate().unwrap_err();
9817 assert!(
9818 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9819 "got {err:?}",
9820 );
9821 }
9822
9823 #[test]
9824 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9825 // Cascade pin on the immediate-successor arm: a value carrying
9826 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9827 // canonical "I tab-completed a path that already had a
9828 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9829 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9830 // the more semantic-locating axis (an author who removes the
9831 // `<` / `>` typically also drops the trailing separator since
9832 // both are paste-from-shell artifacts).
9833 let d = dep_with_fonte(DepSource::Path {
9834 caminho: "../foo></".into(),
9835 });
9836 let err = d.validate().unwrap_err();
9837 assert!(
9838 matches!(
9839 err,
9840 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9841 ),
9842 "got {err:?}",
9843 );
9844 }
9845
9846 #[test]
9847 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9848 // Diagnostic-shape pin (peer with
9849 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9850 // payload assertion on the closest peer arm that also carries a
9851 // `byte` field): the error's Display surfaces the offending
9852 // `:nome`, the offending `:caminho` verbatim, and the offending
9853 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
9854 // run can render the diagnostic without re-parsing.
9855 let d = dep_with_fonte(DepSource::Path {
9856 caminho: "../caixa-teia>build.log".into(),
9857 });
9858 let rendered = d.validate().unwrap_err().to_string();
9859 assert!(
9860 rendered.contains("caixa-teia"),
9861 "diagnostic must name the offending dep: {rendered}",
9862 );
9863 assert!(
9864 rendered.contains("../caixa-teia>build.log"),
9865 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9866 );
9867 assert!(
9868 rendered.contains("0x3e"),
9869 "diagnostic must name the offending byte in hex: {rendered:?}",
9870 );
9871 assert!(
9872 rendered.contains("redirection"),
9873 "diagnostic must name the shell-redirection footgun: {rendered:?}",
9874 );
9875 }
9876
9877 // -- :caminho shell-pipe metacharacter arm ----------------------------
9878
9879 #[test]
9880 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
9881 // The fail-before-pass-after pin for the canonical shell-pipe
9882 // paste footgun: an author copies a shell-history line
9883 // (`"../caixa-teia | grep foo"` — the canonical "I selected
9884 // the whole `ls dir | grep` line out of zsh history") and
9885 // silently passed every prior arm (`Path::is_absolute` false
9886 // on `..`, no control bytes, no backslash, no `<` / `>`,
9887 // doesn't end in `/`). The lacre embedded the value verbatim,
9888 // the resolver folded it through `Path::join` looking for a
9889 // literal `./../caixa-teia | grep foo` subdirectory, and the
9890 // failure surfaced at resolve time with a non-self-locating
9891 // `No such file or directory` error. The new arm moves the
9892 // rejection to validate time and names the offending dep +
9893 // caminho verbatim.
9894 let d = dep_with_fonte(DepSource::Path {
9895 caminho: "../caixa-teia | grep foo".into(),
9896 });
9897 let err = d.validate().unwrap_err();
9898 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
9899 panic!("expected FonteCaminhoShellPipe, got {err:?}");
9900 };
9901 assert_eq!(nome, "caixa-teia");
9902 assert_eq!(caminho, "../caixa-teia | grep foo");
9903 }
9904
9905 #[test]
9906 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
9907 // Leading-position `|` shape (`"|../caixa-teia"` — the
9908 // degenerate "I forgot the source side of the pipe" idiom).
9909 // Pinned separately from the embedded-byte shape so the gate
9910 // covers every position, not only mid-path.
9911 let d = dep_with_fonte(DepSource::Path {
9912 caminho: "|../caixa-teia".into(),
9913 });
9914 let err = d.validate().unwrap_err();
9915 assert!(
9916 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9917 "got {err:?}",
9918 );
9919 }
9920
9921 #[test]
9922 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
9923 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
9924 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
9925 // idiom). The arm fires on the first `|` encountered; pinned
9926 // so a future arm that tries to distinguish `|` from `||`
9927 // doesn't break the broader contract.
9928 let d = dep_with_fonte(DepSource::Path {
9929 caminho: "../caixa-teia||fallback".into(),
9930 });
9931 let err = d.validate().unwrap_err();
9932 assert!(
9933 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
9934 "got {err:?}",
9935 );
9936 }
9937
9938 #[test]
9939 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
9940 // The positive-control pin: the gate targets only `|`, never
9941 // adjacent printable ASCII or POSIX-valid bytes. The canonical
9942 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
9943 // pathed variant with adjacent printable punctuation
9944 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
9945 // cleanly so the gate doesn't widen to a "no printable
9946 // punctuation anywhere" sweep that would defeat the entire
9947 // path-fonte author surface.
9948 let d = dep_with_fonte(DepSource::Path {
9949 caminho: "../caixa-teia/sub-dir.v2".into(),
9950 });
9951 d.validate().unwrap();
9952 }
9953
9954 #[test]
9955 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
9956 // Cascade pin on the immediate-predecessor arm: a value carrying
9957 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
9958 // canonical "I pasted a `cmd < input | tee` pipeline tail"
9959 // footgun) routes through `FonteCaminhoShellRedirection` not
9960 // `FonteCaminhoShellPipe`. The input/output redirection
9961 // metachar carries the more self-locating `byte: u8` payload
9962 // (it names which of `<` or `>` triggered), so the prior arm
9963 // wins on every probe-as-both value — same cascade discipline
9964 // every prior `:caminho` arm establishes.
9965 let d = dep_with_fonte(DepSource::Path {
9966 caminho: "../caixa-teia<input|tee".into(),
9967 });
9968 let err = d.validate().unwrap_err();
9969 assert!(
9970 matches!(
9971 err,
9972 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
9973 ),
9974 "got {err:?}",
9975 );
9976 }
9977
9978 #[test]
9979 fn fonte_caminho_backslash_fires_before_shell_pipe() {
9980 // Cascade pin on the upstream backslash arm: a value carrying
9981 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
9982 // "I pasted a Windows-shell command with pipe to tee"
9983 // footgun) routes through `FonteCaminhoBackslash` not
9984 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
9985 // divergence is the load-bearing axis on every probe-as-both
9986 // value (an author who removes the `\` is the root-cause edit;
9987 // the `|` falls away in the same edit since it's downstream of
9988 // the Windows-shell convention).
9989 let d = dep_with_fonte(DepSource::Path {
9990 caminho: "..\\caixa-teia|tee".into(),
9991 });
9992 let err = d.validate().unwrap_err();
9993 assert!(
9994 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9995 "got {err:?}",
9996 );
9997 }
9998
9999 #[test]
10000 fn fonte_caminho_control_char_fires_before_shell_pipe() {
10001 // Cascade pin on the embedded-control-byte arm: a value
10002 // carrying both a control byte and `|` (`"../foo\n|bar"` —
10003 // the canonical paste-from-multiline-doc footgun where a
10004 // newline landed mid-caminho) routes through
10005 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10006 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10007 // diagnostic is the load-bearing axis on every value that
10008 // probes positive for both — mirrors the cascade discipline
10009 // on every prior arm.
10010 let d = dep_with_fonte(DepSource::Path {
10011 caminho: "../foo\n|bar".into(),
10012 });
10013 let err = d.validate().unwrap_err();
10014 assert!(
10015 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10016 "got {err:?}",
10017 );
10018 }
10019
10020 #[test]
10021 fn fonte_caminho_absolute_fires_before_shell_pipe() {
10022 // Cascade pin on the load-bearing leading-byte arm: a leading
10023 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10024 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10025 // — the host-layout-leak diagnostic is the load-bearing axis,
10026 // the `|` byte is the secondary observation. Same precedence
10027 // logic as every prior leading-byte arm.
10028 let d = dep_with_fonte(DepSource::Path {
10029 caminho: "/etc/passwd|tee".into(),
10030 });
10031 let err = d.validate().unwrap_err();
10032 assert!(
10033 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10034 "got {err:?}",
10035 );
10036 }
10037
10038 #[test]
10039 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10040 // Cascade pin on the immediate-successor arm: a value carrying
10041 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10042 // "I tab-completed a path that already had a pipeline tail"
10043 // footgun) routes through `FonteCaminhoShellPipe` not
10044 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10045 // the more semantic-locating axis (an author who removes the
10046 // `|` typically also drops the trailing separator since both
10047 // are paste-from-shell artifacts).
10048 let d = dep_with_fonte(DepSource::Path {
10049 caminho: "../foo|tee/".into(),
10050 });
10051 let err = d.validate().unwrap_err();
10052 assert!(
10053 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10054 "got {err:?}",
10055 );
10056 }
10057
10058 #[test]
10059 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10060 // Diagnostic-shape pin (peer with
10061 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10062 // on the closest single-byte peer arm): the error's Display
10063 // surfaces the offending `:nome` and the offending `:caminho`
10064 // verbatim, and names the shell-pipe footgun explicitly so a
10065 // `feira lint` run can render the diagnostic without
10066 // re-parsing.
10067 let d = dep_with_fonte(DepSource::Path {
10068 caminho: "../caixa-teia | grep foo".into(),
10069 });
10070 let rendered = d.validate().unwrap_err().to_string();
10071 assert!(
10072 rendered.contains("caixa-teia"),
10073 "diagnostic must name the offending dep: {rendered}",
10074 );
10075 assert!(
10076 rendered.contains("../caixa-teia | grep foo"),
10077 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10078 );
10079 assert!(
10080 rendered.contains('|'),
10081 "diagnostic must reference the pipe footgun: {rendered:?}",
10082 );
10083 assert!(
10084 rendered.contains("pipe"),
10085 "diagnostic must name the shell-pipe footgun: {rendered:?}",
10086 );
10087 }
10088
10089 // -- :caminho shell-command-separator metacharacter arm ---------------
10090
10091 #[test]
10092 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10093 // The fail-before-pass-after pin for the canonical shell-command-
10094 // separator paste footgun: an author copies a shell one-liner
10095 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10096 // whole `cd path; do-thing` chain out of a shell-history block")
10097 // and silently passed every prior arm (`Path::is_absolute` false
10098 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10099 // doesn't end in `/`). The lacre embedded the value verbatim, the
10100 // resolver folded it through `Path::join` looking for a literal
10101 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10102 // surfaced at resolve time with a non-self-locating `No such file
10103 // or directory` error. The new arm moves the rejection to validate
10104 // time and names the offending dep + caminho verbatim.
10105 let d = dep_with_fonte(DepSource::Path {
10106 caminho: "../caixa-teia; rm -rf build".into(),
10107 });
10108 let err = d.validate().unwrap_err();
10109 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10110 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10111 };
10112 assert_eq!(nome, "caixa-teia");
10113 assert_eq!(caminho, "../caixa-teia; rm -rf build");
10114 }
10115
10116 #[test]
10117 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10118 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10119 // "I forgot the prior command side of the separator" idiom).
10120 // Pinned separately from the embedded-byte shape so the gate
10121 // covers every position, not only mid-path.
10122 let d = dep_with_fonte(DepSource::Path {
10123 caminho: ";../caixa-teia".into(),
10124 });
10125 let err = d.validate().unwrap_err();
10126 assert!(
10127 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10128 "got {err:?}",
10129 );
10130 }
10131
10132 #[test]
10133 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10134 // The POSIX `case` arm `;;` terminator shape
10135 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10136 // arm tail" idiom). The arm fires on the first `;` encountered;
10137 // pinned so a future arm that tries to distinguish `;` from `;;`
10138 // doesn't break the broader contract.
10139 let d = dep_with_fonte(DepSource::Path {
10140 caminho: "../caixa-teia;;next".into(),
10141 });
10142 let err = d.validate().unwrap_err();
10143 assert!(
10144 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10145 "got {err:?}",
10146 );
10147 }
10148
10149 #[test]
10150 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10151 // The positive-control pin: the gate targets only `;`, never
10152 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10153 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10154 // pathed variant with adjacent printable punctuation
10155 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10156 // cleanly so the gate doesn't widen to a "no printable
10157 // punctuation anywhere" sweep that would defeat the entire
10158 // path-fonte author surface.
10159 let d = dep_with_fonte(DepSource::Path {
10160 caminho: "../caixa-teia/sub-dir.v2".into(),
10161 });
10162 d.validate().unwrap();
10163 }
10164
10165 #[test]
10166 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10167 // Cascade pin on the immediate-predecessor arm: a value carrying
10168 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10169 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10170 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10171 // pipeline-tail paste is the load-bearing root-cause edit on
10172 // every probe-as-both value (an author who removes the `|`
10173 // typically also drops the trailing `; cleanup` since both are
10174 // the same paste-from-shell-history artifact) — same cascade
10175 // discipline every prior `:caminho` arm establishes.
10176 let d = dep_with_fonte(DepSource::Path {
10177 caminho: "../caixa-teia | tee; rm".into(),
10178 });
10179 let err = d.validate().unwrap_err();
10180 assert!(
10181 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10182 "got {err:?}",
10183 );
10184 }
10185
10186 #[test]
10187 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10188 // Cascade pin on the upstream shell-redirection arm: a value
10189 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10190 // the canonical "I pasted a `cmd > log; cleanup` chain"
10191 // footgun) routes through `FonteCaminhoShellRedirection` not
10192 // `FonteCaminhoShellSemicolon`. The input/output redirection
10193 // metachar carries the more self-locating `byte: u8` payload
10194 // (it names which of `<` or `>` triggered), so the prior arm
10195 // wins on every probe-as-both value.
10196 let d = dep_with_fonte(DepSource::Path {
10197 caminho: "../caixa-teia>log; rm".into(),
10198 });
10199 let err = d.validate().unwrap_err();
10200 assert!(
10201 matches!(
10202 err,
10203 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10204 ),
10205 "got {err:?}",
10206 );
10207 }
10208
10209 #[test]
10210 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10211 // Cascade pin on the upstream backslash arm: a value carrying
10212 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10213 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10214 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10215 // The cross-host-OS-separator divergence is the load-bearing axis
10216 // on every probe-as-both value (an author who removes the `\` is
10217 // the root-cause edit; the `;` falls away in the same edit since
10218 // it's downstream of the Windows-shell convention).
10219 let d = dep_with_fonte(DepSource::Path {
10220 caminho: "..\\caixa-teia;rm".into(),
10221 });
10222 let err = d.validate().unwrap_err();
10223 assert!(
10224 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10225 "got {err:?}",
10226 );
10227 }
10228
10229 #[test]
10230 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10231 // Cascade pin on the embedded-control-byte arm: a value carrying
10232 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10233 // paste-from-multiline-doc footgun where a newline landed mid-
10234 // caminho) routes through `FonteCaminhoControlChar` not
10235 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10236 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10237 // on every value that probes positive for both — mirrors the
10238 // cascade discipline on every prior arm.
10239 let d = dep_with_fonte(DepSource::Path {
10240 caminho: "../foo\n;bar".into(),
10241 });
10242 let err = d.validate().unwrap_err();
10243 assert!(
10244 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10245 "got {err:?}",
10246 );
10247 }
10248
10249 #[test]
10250 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10251 // Cascade pin on the load-bearing leading-byte arm: a leading
10252 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10253 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10254 // — the host-layout-leak diagnostic is the load-bearing axis,
10255 // the `;` byte is the secondary observation. Same precedence
10256 // logic as every prior leading-byte arm.
10257 let d = dep_with_fonte(DepSource::Path {
10258 caminho: "/etc/passwd;rm".into(),
10259 });
10260 let err = d.validate().unwrap_err();
10261 assert!(
10262 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10263 "got {err:?}",
10264 );
10265 }
10266
10267 #[test]
10268 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10269 // Cascade pin on the immediate-successor arm: a value carrying
10270 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10271 // "I tab-completed a path that already had a `; cleanup` tail"
10272 // footgun) routes through `FonteCaminhoShellSemicolon` not
10273 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10274 // the more semantic-locating axis (an author who removes the
10275 // `;` typically also drops the trailing separator since both
10276 // are paste-from-shell artifacts).
10277 let d = dep_with_fonte(DepSource::Path {
10278 caminho: "../foo;rm/".into(),
10279 });
10280 let err = d.validate().unwrap_err();
10281 assert!(
10282 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10283 "got {err:?}",
10284 );
10285 }
10286
10287 #[test]
10288 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10289 // Diagnostic-shape pin (peer with
10290 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10291 // on the closest single-byte peer arm): the error's Display
10292 // surfaces the offending `:nome` and the offending `:caminho`
10293 // verbatim, and names the shell-command-separator footgun
10294 // explicitly so a `feira lint` run can render the diagnostic
10295 // without re-parsing.
10296 let d = dep_with_fonte(DepSource::Path {
10297 caminho: "../caixa-teia; rm -rf build".into(),
10298 });
10299 let rendered = d.validate().unwrap_err().to_string();
10300 assert!(
10301 rendered.contains("caixa-teia"),
10302 "diagnostic must name the offending dep: {rendered}",
10303 );
10304 assert!(
10305 rendered.contains("../caixa-teia; rm -rf build"),
10306 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10307 );
10308 assert!(
10309 rendered.contains(';'),
10310 "diagnostic must reference the semicolon footgun: {rendered:?}",
10311 );
10312 assert!(
10313 rendered.contains("command-separator"),
10314 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10315 );
10316 }
10317
10318 #[test]
10319 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10320 // The fail-before-pass-after pin for the canonical shell-
10321 // background-task paste footgun: an author copies a shell one-
10322 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10323 // the whole `cd path & sleep 1` background-launch out of a
10324 // shell-history block") and silently passed every prior arm
10325 // (`Path::is_absolute` false on `..`, no control bytes, no
10326 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10327 // The lacre embedded the value verbatim, the resolver folded it
10328 // through `Path::join` looking for a literal `./../caixa-teia &
10329 // sleep 1` subdirectory, and the failure surfaced at resolve
10330 // time with a non-self-locating `No such file or directory`
10331 // error. The new arm moves the rejection to validate time and
10332 // names the offending dep + caminho verbatim.
10333 let d = dep_with_fonte(DepSource::Path {
10334 caminho: "../caixa-teia & sleep 1".into(),
10335 });
10336 let err = d.validate().unwrap_err();
10337 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10338 panic!("expected FonteCaminhoShellBackground, got {err:?}");
10339 };
10340 assert_eq!(nome, "caixa-teia");
10341 assert_eq!(caminho, "../caixa-teia & sleep 1");
10342 }
10343
10344 #[test]
10345 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10346 // Leading-position `&` shape (`"&../caixa-teia"` — the
10347 // degenerate "I forgot the prior command side of the
10348 // background terminator" idiom). Pinned separately from the
10349 // embedded-byte shape so the gate covers every position, not
10350 // only mid-path.
10351 let d = dep_with_fonte(DepSource::Path {
10352 caminho: "&../caixa-teia".into(),
10353 });
10354 let err = d.validate().unwrap_err();
10355 assert!(
10356 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10357 "got {err:?}",
10358 );
10359 }
10360
10361 #[test]
10362 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10363 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10364 // canonical "I copied a `cd path && make` build chain" idiom
10365 // every Makefile / shell-script wraps). The arm fires on the
10366 // first `&` encountered; pinned so a future arm that tries to
10367 // distinguish `&` from `&&` doesn't break the broader contract.
10368 let d = dep_with_fonte(DepSource::Path {
10369 caminho: "../caixa-teia && make".into(),
10370 });
10371 let err = d.validate().unwrap_err();
10372 assert!(
10373 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10374 "got {err:?}",
10375 );
10376 }
10377
10378 #[test]
10379 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10380 // The positive-control pin: the gate targets only `&`, never
10381 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10382 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10383 // pathed variant with adjacent printable punctuation
10384 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10385 // cleanly so the gate doesn't widen to a "no printable
10386 // punctuation anywhere" sweep that would defeat the entire
10387 // path-fonte author surface.
10388 let d = dep_with_fonte(DepSource::Path {
10389 caminho: "../caixa-teia/sub-dir.v2".into(),
10390 });
10391 d.validate().unwrap();
10392 }
10393
10394 #[test]
10395 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10396 // Cascade pin on the immediate-predecessor arm: a value carrying
10397 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10398 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10399 // routes through `FonteCaminhoShellSemicolon` not
10400 // `FonteCaminhoShellBackground`. The sequential-command-
10401 // separator paste is the more common shell-history paste idiom
10402 // on every probe-as-both value (an author who removes the `;`
10403 // typically also drops the trailing `& sleep` since both are
10404 // paste-from-shell-history artifacts) — same cascade discipline
10405 // every prior `:caminho` arm establishes.
10406 let d = dep_with_fonte(DepSource::Path {
10407 caminho: "../caixa-teia; rm & sleep".into(),
10408 });
10409 let err = d.validate().unwrap_err();
10410 assert!(
10411 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10412 "got {err:?}",
10413 );
10414 }
10415
10416 #[test]
10417 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10418 // Cascade pin on the upstream shell-pipe arm: a value carrying
10419 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10420 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10421 // chain" footgun) routes through `FonteCaminhoShellPipe` not
10422 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10423 // load-bearing root-cause edit on every probe-as-both value.
10424 let d = dep_with_fonte(DepSource::Path {
10425 caminho: "../caixa-teia | tee & sleep".into(),
10426 });
10427 let err = d.validate().unwrap_err();
10428 assert!(
10429 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10430 "got {err:?}",
10431 );
10432 }
10433
10434 #[test]
10435 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10436 // Cascade pin on the upstream shell-redirection arm: a value
10437 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10438 // the canonical "I pasted a `cmd > log & sleep` background-
10439 // redirect chain" footgun) routes through
10440 // `FonteCaminhoShellRedirection` not
10441 // `FonteCaminhoShellBackground`. The input/output redirection
10442 // metachar carries the more self-locating `byte: u8` payload
10443 // (it names which of `<` or `>` triggered), so the prior arm
10444 // wins on every probe-as-both value.
10445 let d = dep_with_fonte(DepSource::Path {
10446 caminho: "../caixa-teia>log & sleep".into(),
10447 });
10448 let err = d.validate().unwrap_err();
10449 assert!(
10450 matches!(
10451 err,
10452 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10453 ),
10454 "got {err:?}",
10455 );
10456 }
10457
10458 #[test]
10459 fn fonte_caminho_backslash_fires_before_shell_background() {
10460 // Cascade pin on the upstream backslash arm: a value carrying
10461 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10462 // "I pasted a Windows-shell `cd ..\path & sleep` background-
10463 // launch chain") routes through `FonteCaminhoBackslash` not
10464 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10465 // divergence is the load-bearing axis on every probe-as-both
10466 // value (an author who removes the `\` is the root-cause edit;
10467 // the `&` falls away in the same edit since it's downstream of
10468 // the Windows-shell convention).
10469 let d = dep_with_fonte(DepSource::Path {
10470 caminho: "..\\caixa-teia & sleep".into(),
10471 });
10472 let err = d.validate().unwrap_err();
10473 assert!(
10474 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10475 "got {err:?}",
10476 );
10477 }
10478
10479 #[test]
10480 fn fonte_caminho_control_char_fires_before_shell_background() {
10481 // Cascade pin on the embedded-control-byte arm: a value
10482 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10483 // the canonical paste-from-multiline-doc footgun where a
10484 // newline landed mid-caminho) routes through
10485 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10486 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10487 // diagnostic is the load-bearing axis on every value that
10488 // probes positive for both — mirrors the cascade discipline on
10489 // every prior arm.
10490 let d = dep_with_fonte(DepSource::Path {
10491 caminho: "../foo\n&sleep".into(),
10492 });
10493 let err = d.validate().unwrap_err();
10494 assert!(
10495 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10496 "got {err:?}",
10497 );
10498 }
10499
10500 #[test]
10501 fn fonte_caminho_absolute_fires_before_shell_background() {
10502 // Cascade pin on the load-bearing leading-byte arm: a leading
10503 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10504 // through `FonteCaminhoAbsolute` not
10505 // `FonteCaminhoShellBackground` — the host-layout-leak
10506 // diagnostic is the load-bearing axis, the `&` byte is the
10507 // secondary observation. Same precedence logic as every prior
10508 // leading-byte arm.
10509 let d = dep_with_fonte(DepSource::Path {
10510 caminho: "/etc/passwd & sleep".into(),
10511 });
10512 let err = d.validate().unwrap_err();
10513 assert!(
10514 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10515 "got {err:?}",
10516 );
10517 }
10518
10519 #[test]
10520 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10521 // Cascade pin on the immediate-successor arm: a value carrying
10522 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10523 // canonical "I tab-completed a path that already had a `&
10524 // sleep` background-launch tail" footgun) routes through
10525 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10526 // The embedded shell-metachar is the more semantic-locating
10527 // axis (an author who removes the `&` typically also drops
10528 // the trailing separator since both are paste-from-shell
10529 // artifacts).
10530 let d = dep_with_fonte(DepSource::Path {
10531 caminho: "../foo&sleep/".into(),
10532 });
10533 let err = d.validate().unwrap_err();
10534 assert!(
10535 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10536 "got {err:?}",
10537 );
10538 }
10539
10540 #[test]
10541 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10542 // Diagnostic-shape pin (peer with
10543 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10544 // on the closest single-byte peer arm): the error's Display
10545 // surfaces the offending `:nome` and the offending `:caminho`
10546 // verbatim, and names the shell-background / logical-AND
10547 // footgun explicitly so a `feira lint` run can render the
10548 // diagnostic without re-parsing.
10549 let d = dep_with_fonte(DepSource::Path {
10550 caminho: "../caixa-teia & sleep 1".into(),
10551 });
10552 let rendered = d.validate().unwrap_err().to_string();
10553 assert!(
10554 rendered.contains("caixa-teia"),
10555 "diagnostic must name the offending dep: {rendered}",
10556 );
10557 assert!(
10558 rendered.contains("../caixa-teia & sleep 1"),
10559 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10560 );
10561 assert!(
10562 rendered.contains('&'),
10563 "diagnostic must reference the ampersand footgun: {rendered:?}",
10564 );
10565 assert!(
10566 rendered.contains("background") || rendered.contains("list-AND"),
10567 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10568 );
10569 }
10570
10571 #[test]
10572 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10573 // The fail-before-pass-after pin for the canonical shell-
10574 // command-substitution paste footgun: an author copies a
10575 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10576 // — the canonical "I pasted a path that included a `pwd`
10577 // / `whoami` / `date` legacy command-substitution expansion
10578 // out of a shell-history block") and silently passed every
10579 // prior arm (`Path::is_absolute` false on `..`, no control
10580 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10581 // end in `/`). The lacre embedded the value verbatim, the
10582 // resolver folded it through `Path::join` looking for a
10583 // literal `./../caixa-teia/`whoami`` subdirectory, and the
10584 // failure surfaced at resolve time with a non-self-locating
10585 // `No such file or directory` error. The new arm moves the
10586 // rejection to validate time and names the offending dep +
10587 // caminho verbatim.
10588 let d = dep_with_fonte(DepSource::Path {
10589 caminho: "../caixa-teia/`whoami`".into(),
10590 });
10591 let err = d.validate().unwrap_err();
10592 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10593 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10594 };
10595 assert_eq!(nome, "caixa-teia");
10596 assert_eq!(caminho, "../caixa-teia/`whoami`");
10597 }
10598
10599 #[test]
10600 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10601 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10602 // the canonical `<backtick>pwd<backtick>/path` working-
10603 // directory expansion shape every shell-side path-composition
10604 // idiom carries). Pinned separately from the embedded-byte
10605 // shape so the gate covers every position, not only mid-path.
10606 let d = dep_with_fonte(DepSource::Path {
10607 caminho: "`pwd`/caixa-teia".into(),
10608 });
10609 let err = d.validate().unwrap_err();
10610 assert!(
10611 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10612 "got {err:?}",
10613 );
10614 }
10615
10616 #[test]
10617 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10618 // Trailing-position backtick shape (`"../caixa-teia`"` — the
10619 // degenerate "I selected an unbalanced backtick out of a
10620 // shell-history block" idiom that probes for the cascade's
10621 // last-byte handling). The trailing-`/` arm fires only on
10622 // last-byte `/`; an unbalanced trailing backtick must route
10623 // through this arm regardless of position.
10624 let d = dep_with_fonte(DepSource::Path {
10625 caminho: "../caixa-teia`".into(),
10626 });
10627 let err = d.validate().unwrap_err();
10628 assert!(
10629 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10630 "got {err:?}",
10631 );
10632 }
10633
10634 #[test]
10635 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10636 // The canonical balanced-pair shape (``"../<backtick>cat
10637 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10638 // command-injection paste idiom every shell-side hardening
10639 // guide enumerates first). The arm fires on the first
10640 // backtick encountered; pinned so a future arm that tries to
10641 // distinguish the opening from the closing byte doesn't break
10642 // the broader contract.
10643 let d = dep_with_fonte(DepSource::Path {
10644 caminho: "../`cat /etc/passwd`".into(),
10645 });
10646 let err = d.validate().unwrap_err();
10647 assert!(
10648 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10649 "got {err:?}",
10650 );
10651 }
10652
10653 #[test]
10654 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10655 // The positive-control pin: the gate targets only the
10656 // backtick byte, never adjacent printable ASCII or POSIX-
10657 // valid bytes. The canonical relative POSIX path
10658 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10659 // adjacent printable punctuation
10660 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10661 // cleanly so the gate doesn't widen to a "no printable
10662 // punctuation anywhere" sweep that would defeat the entire
10663 // path-fonte author surface.
10664 let d = dep_with_fonte(DepSource::Path {
10665 caminho: "../caixa-teia/sub-dir.v2".into(),
10666 });
10667 d.validate().unwrap();
10668 }
10669
10670 #[test]
10671 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10672 // Cascade pin on the immediate-predecessor arm: a value
10673 // carrying both `&` and a backtick (``"../caixa-teia &
10674 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10675 // `cmd & <backtick>sleep N<backtick>` background-launch +
10676 // command-substitution chain" footgun) routes through
10677 // `FonteCaminhoShellBackground` not
10678 // `FonteCaminhoShellCommandSubstitution`. The background-
10679 // launch tail is the more common shell-history paste idiom
10680 // on every probe-as-both value — same cascade discipline
10681 // every prior `:caminho` arm establishes.
10682 let d = dep_with_fonte(DepSource::Path {
10683 caminho: "../caixa-teia & `sleep 1`".into(),
10684 });
10685 let err = d.validate().unwrap_err();
10686 assert!(
10687 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10688 "got {err:?}",
10689 );
10690 }
10691
10692 #[test]
10693 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10694 // Cascade pin on the upstream shell-semicolon arm: a value
10695 // carrying both `;` and a backtick (``"../caixa-teia;
10696 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10697 // `cmd; <backtick>follow-up<backtick>` sequential-chain
10698 // footgun) routes through `FonteCaminhoShellSemicolon` not
10699 // `FonteCaminhoShellCommandSubstitution`. The sequential-
10700 // command-separator paste is the load-bearing root-cause
10701 // edit on every probe-as-both value.
10702 let d = dep_with_fonte(DepSource::Path {
10703 caminho: "../caixa-teia; `whoami`".into(),
10704 });
10705 let err = d.validate().unwrap_err();
10706 assert!(
10707 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10708 "got {err:?}",
10709 );
10710 }
10711
10712 #[test]
10713 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10714 // Cascade pin on the upstream shell-pipe arm: a value
10715 // carrying both `|` and a backtick (``"../caixa-teia |
10716 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10717 // command-substitution paste idiom) routes through
10718 // `FonteCaminhoShellPipe` not
10719 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10720 // paste is the load-bearing root-cause edit on every
10721 // probe-as-both value.
10722 let d = dep_with_fonte(DepSource::Path {
10723 caminho: "../caixa-teia | `tee log`".into(),
10724 });
10725 let err = d.validate().unwrap_err();
10726 assert!(
10727 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10728 "got {err:?}",
10729 );
10730 }
10731
10732 #[test]
10733 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10734 // Cascade pin on the upstream shell-redirection arm: a value
10735 // carrying both `>` and a backtick (``"../caixa-teia>log
10736 // <backtick>date<backtick>"`` — the canonical "I pasted a
10737 // `cmd > log <backtick>date<backtick>` redirect-plus-
10738 // substitution chain" footgun) routes through
10739 // `FonteCaminhoShellRedirection` not
10740 // `FonteCaminhoShellCommandSubstitution`. The input/output
10741 // redirection metachar carries the more self-locating `byte`
10742 // payload (it names which of `<` or `>` triggered), so the
10743 // prior arm wins on every probe-as-both value.
10744 let d = dep_with_fonte(DepSource::Path {
10745 caminho: "../caixa-teia>log `date`".into(),
10746 });
10747 let err = d.validate().unwrap_err();
10748 assert!(
10749 matches!(
10750 err,
10751 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10752 ),
10753 "got {err:?}",
10754 );
10755 }
10756
10757 #[test]
10758 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10759 // Cascade pin on the upstream backslash arm: a value
10760 // carrying both `\` and a backtick (``"..\caixa-teia
10761 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10762 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10763 // chain") routes through `FonteCaminhoBackslash` not
10764 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10765 // separator divergence is the load-bearing axis on every
10766 // probe-as-both value (an author who removes the `\` is the
10767 // root-cause edit; the backtick falls away in the same edit
10768 // since it's downstream of the Windows-shell convention).
10769 let d = dep_with_fonte(DepSource::Path {
10770 caminho: "..\\caixa-teia `whoami`".into(),
10771 });
10772 let err = d.validate().unwrap_err();
10773 assert!(
10774 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10775 "got {err:?}",
10776 );
10777 }
10778
10779 #[test]
10780 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10781 // Cascade pin on the embedded-control-byte arm: a value
10782 // carrying both a control byte and a backtick (`"../foo\n
10783 // `whoami`"` — the canonical paste-from-multiline-doc
10784 // footgun where a newline landed mid-caminho between two
10785 // paste fragments) routes through `FonteCaminhoControlChar`
10786 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10787 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10788 // is the load-bearing axis on every value that probes
10789 // positive for both — mirrors the cascade discipline on
10790 // every prior arm.
10791 let d = dep_with_fonte(DepSource::Path {
10792 caminho: "../foo\n`whoami`".into(),
10793 });
10794 let err = d.validate().unwrap_err();
10795 assert!(
10796 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10797 "got {err:?}",
10798 );
10799 }
10800
10801 #[test]
10802 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10803 // Cascade pin on the load-bearing leading-byte arm: a
10804 // leading `/` value with embedded backtick (``"/etc/passwd
10805 // <backtick>whoami<backtick>"``) routes through
10806 // `FonteCaminhoAbsolute` not
10807 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10808 // leak diagnostic is the load-bearing axis, the backtick
10809 // byte is the secondary observation. Same precedence logic
10810 // as every prior leading-byte arm.
10811 let d = dep_with_fonte(DepSource::Path {
10812 caminho: "/etc/passwd `whoami`".into(),
10813 });
10814 let err = d.validate().unwrap_err();
10815 assert!(
10816 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10817 "got {err:?}",
10818 );
10819 }
10820
10821 #[test]
10822 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10823 // Cascade pin on the immediate-successor arm: a value
10824 // carrying both a backtick and a trailing `/`
10825 // (``"../`whoami`/"`` — the canonical "I tab-completed a
10826 // path that already had a backticked `whoami` substitution
10827 // tail" footgun) routes through
10828 // `FonteCaminhoShellCommandSubstitution` not
10829 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10830 // is the more semantic-locating axis (an author who removes
10831 // the backtick typically also drops the trailing separator
10832 // since both are paste-from-shell artifacts).
10833 let d = dep_with_fonte(DepSource::Path {
10834 caminho: "../`whoami`/".into(),
10835 });
10836 let err = d.validate().unwrap_err();
10837 assert!(
10838 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10839 "got {err:?}",
10840 );
10841 }
10842
10843 #[test]
10844 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10845 // Diagnostic-shape pin (peer with
10846 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10847 // on the closest single-byte peer arm): the error's Display
10848 // surfaces the offending `:nome` and the offending `:caminho`
10849 // verbatim, and names the shell-command-substitution footgun
10850 // explicitly so a `feira lint` run can render the diagnostic
10851 // without re-parsing.
10852 let d = dep_with_fonte(DepSource::Path {
10853 caminho: "../caixa-teia/`whoami`".into(),
10854 });
10855 let rendered = d.validate().unwrap_err().to_string();
10856 assert!(
10857 rendered.contains("caixa-teia"),
10858 "diagnostic must name the offending dep: {rendered}",
10859 );
10860 assert!(
10861 rendered.contains("../caixa-teia/`whoami`"),
10862 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10863 );
10864 assert!(
10865 rendered.contains('`'),
10866 "diagnostic must reference the backtick footgun: {rendered:?}",
10867 );
10868 assert!(
10869 rendered.contains("command-substitution"),
10870 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
10871 );
10872 }
10873
10874 #[test]
10875 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
10876 // The fail-before-pass-after pin for the canonical pathname-
10877 // expansion paste footgun: an author copies an `ls
10878 // ../caixa-teia/*` shell-listing tail into the `:caminho`
10879 // slot and silently passes every prior arm
10880 // (`Path::is_absolute` false on `..`, no control bytes, no
10881 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
10882 // doesn't end in `/`). The lacre embedded the value
10883 // verbatim, the resolver folded it through `Path::join`
10884 // looking for a literal `./../caixa-teia/*` subdirectory,
10885 // and the failure surfaced at resolve time with a non-self-
10886 // locating `No such file or directory` error. The new arm
10887 // moves the rejection to validate time and names the
10888 // offending dep + caminho + byte verbatim.
10889 let d = dep_with_fonte(DepSource::Path {
10890 caminho: "../caixa-teia/*".into(),
10891 });
10892 let err = d.validate().unwrap_err();
10893 let DepError::FonteCaminhoShellGlob {
10894 nome,
10895 caminho,
10896 byte,
10897 } = err
10898 else {
10899 panic!("expected FonteCaminhoShellGlob, got {err:?}");
10900 };
10901 assert_eq!(nome, "caixa-teia");
10902 assert_eq!(caminho, "../caixa-teia/*");
10903 assert_eq!(byte, b'*');
10904 }
10905
10906 #[test]
10907 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
10908 // The symmetric single-char-wildcard paste shape
10909 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
10910 // out of shell history" idiom). Pinned separately from the
10911 // `*` shape so the gate's contract is "any `*` or `?`
10912 // anywhere", not single-byte coverage.
10913 let d = dep_with_fonte(DepSource::Path {
10914 caminho: "../foo?".into(),
10915 });
10916 let err = d.validate().unwrap_err();
10917 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
10918 panic!("expected FonteCaminhoShellGlob, got {err:?}");
10919 };
10920 assert_eq!(byte, b'?');
10921 }
10922
10923 #[test]
10924 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
10925 // Leading-position `*` shape (`"*/caixa-teia"` — the
10926 // degenerate "I selected only the wildcard prefix out of a
10927 // shell-glob expression" idiom). Pinned separately from the
10928 // embedded-byte shapes so the gate covers every position,
10929 // not only mid-path.
10930 let d = dep_with_fonte(DepSource::Path {
10931 caminho: "*/caixa-teia".into(),
10932 });
10933 let err = d.validate().unwrap_err();
10934 assert!(
10935 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10936 "got {err:?}",
10937 );
10938 }
10939
10940 #[test]
10941 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
10942 // The bash/zsh `globstar` recursive-glob shape
10943 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
10944 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
10945 // The arm fires on the first `*` encountered; pinned so a
10946 // future arm that tries to distinguish single `*` from
10947 // double `**` doesn't break the broader contract.
10948 let d = dep_with_fonte(DepSource::Path {
10949 caminho: "../caixa-teia/**/foo".into(),
10950 });
10951 let err = d.validate().unwrap_err();
10952 assert!(
10953 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10954 "got {err:?}",
10955 );
10956 }
10957
10958 #[test]
10959 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
10960 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
10961 // — the "I selected `*.lisp` to mean every Lisp source file
10962 // in the dep root" footgun the prior arms structurally
10963 // cannot catch since `.` is a POSIX-valid path-component
10964 // byte). Pinned so the gate's contract covers the most
10965 // idiomatic glob-paste shape every author meets first.
10966 let d = dep_with_fonte(DepSource::Path {
10967 caminho: "../caixa-teia/*.lisp".into(),
10968 });
10969 let err = d.validate().unwrap_err();
10970 assert!(
10971 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
10972 "got {err:?}",
10973 );
10974 }
10975
10976 #[test]
10977 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
10978 // The positive-control pin: the gate targets only `*` /
10979 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
10980 // The canonical relative POSIX path (`"../caixa-teia"`) and
10981 // a nested deeply-pathed variant with adjacent printable
10982 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
10983 // to validate cleanly so the gate doesn't widen to a "no
10984 // printable punctuation anywhere" sweep that would defeat
10985 // the entire path-fonte author surface.
10986 let d = dep_with_fonte(DepSource::Path {
10987 caminho: "../caixa-teia/sub-dir.v2".into(),
10988 });
10989 d.validate().unwrap();
10990 }
10991
10992 #[test]
10993 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
10994 // Cascade pin on the immediate-predecessor arm: a value
10995 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
10996 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
10997 // command-substitution + glob chain") routes through
10998 // `FonteCaminhoShellCommandSubstitution` not
10999 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11000 // injection vector is the load-bearing root-cause edit on
11001 // every probe-as-both value — same cascade discipline every
11002 // prior `:caminho` arm establishes.
11003 let d = dep_with_fonte(DepSource::Path {
11004 caminho: "../`whoami`/*".into(),
11005 });
11006 let err = d.validate().unwrap_err();
11007 assert!(
11008 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11009 "got {err:?}",
11010 );
11011 }
11012
11013 #[test]
11014 fn fonte_caminho_shell_background_fires_before_shell_glob() {
11015 // Cascade pin on the upstream shell-background arm: a value
11016 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11017 // canonical "I pasted a `cmd & ls /*` background + glob
11018 // chain" footgun) routes through `FonteCaminhoShellBackground`
11019 // not `FonteCaminhoShellGlob`. The background-launch tail is
11020 // the load-bearing root-cause edit on every probe-as-both
11021 // value.
11022 let d = dep_with_fonte(DepSource::Path {
11023 caminho: "../caixa-teia & ls /*".into(),
11024 });
11025 let err = d.validate().unwrap_err();
11026 assert!(
11027 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11028 "got {err:?}",
11029 );
11030 }
11031
11032 #[test]
11033 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11034 // Cascade pin on the upstream shell-semicolon arm: a value
11035 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11036 // canonical sequential-cleanup + glob paste idiom) routes
11037 // through `FonteCaminhoShellSemicolon` not
11038 // `FonteCaminhoShellGlob`. The sequential-command-separator
11039 // paste is the load-bearing root-cause edit on every
11040 // probe-as-both value.
11041 let d = dep_with_fonte(DepSource::Path {
11042 caminho: "../caixa-teia; rm *".into(),
11043 });
11044 let err = d.validate().unwrap_err();
11045 assert!(
11046 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11047 "got {err:?}",
11048 );
11049 }
11050
11051 #[test]
11052 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11053 // Cascade pin on the upstream shell-pipe arm: a value
11054 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11055 // canonical pipeline-to-glob paste idiom) routes through
11056 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11057 // pipeline-tail paste is the load-bearing root-cause edit
11058 // on every probe-as-both value.
11059 let d = dep_with_fonte(DepSource::Path {
11060 caminho: "../caixa-teia | ls *".into(),
11061 });
11062 let err = d.validate().unwrap_err();
11063 assert!(
11064 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11065 "got {err:?}",
11066 );
11067 }
11068
11069 #[test]
11070 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11071 // Cascade pin on the upstream shell-redirection arm: a value
11072 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11073 // canonical "I pasted a `cmd > log *` redirect-plus-glob
11074 // chain" footgun) routes through
11075 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11076 // The input/output redirection metachar carries the more
11077 // self-locating `byte` payload (it names which of `<` or `>`
11078 // triggered), so the prior arm wins on every probe-as-both
11079 // value.
11080 let d = dep_with_fonte(DepSource::Path {
11081 caminho: "../caixa-teia>log *".into(),
11082 });
11083 let err = d.validate().unwrap_err();
11084 assert!(
11085 matches!(
11086 err,
11087 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11088 ),
11089 "got {err:?}",
11090 );
11091 }
11092
11093 #[test]
11094 fn fonte_caminho_backslash_fires_before_shell_glob() {
11095 // Cascade pin on the upstream backslash arm: a value
11096 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11097 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11098 // expression" footgun) routes through
11099 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11100 // cross-host-OS-separator divergence is the load-bearing
11101 // axis on every probe-as-both value (an author who removes
11102 // the `\` is the root-cause edit; the `*` falls away in the
11103 // same edit since it's downstream of the Windows-shell
11104 // convention).
11105 let d = dep_with_fonte(DepSource::Path {
11106 caminho: "..\\caixa-teia\\*".into(),
11107 });
11108 let err = d.validate().unwrap_err();
11109 assert!(
11110 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11111 "got {err:?}",
11112 );
11113 }
11114
11115 #[test]
11116 fn fonte_caminho_control_char_fires_before_shell_glob() {
11117 // Cascade pin on the embedded-control-byte arm: a value
11118 // carrying both a control byte and `*` (`"../foo\n*"` — the
11119 // canonical paste-from-multiline-doc footgun where a
11120 // newline landed mid-caminho between two paste fragments)
11121 // routes through `FonteCaminhoControlChar` not
11122 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11123 // NUL-`CString::new`-fail diagnostic is the load-bearing
11124 // axis on every value that probes positive for both —
11125 // mirrors the cascade discipline on every prior arm.
11126 let d = dep_with_fonte(DepSource::Path {
11127 caminho: "../foo\n*".into(),
11128 });
11129 let err = d.validate().unwrap_err();
11130 assert!(
11131 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11132 "got {err:?}",
11133 );
11134 }
11135
11136 #[test]
11137 fn fonte_caminho_absolute_fires_before_shell_glob() {
11138 // Cascade pin on the load-bearing leading-byte arm: a
11139 // leading `/` value with embedded `*` (`"/etc/*"`) routes
11140 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11141 // — the host-layout-leak diagnostic is the load-bearing
11142 // axis, the glob byte is the secondary observation. Same
11143 // precedence logic as every prior leading-byte arm.
11144 let d = dep_with_fonte(DepSource::Path {
11145 caminho: "/etc/*".into(),
11146 });
11147 let err = d.validate().unwrap_err();
11148 assert!(
11149 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11150 "got {err:?}",
11151 );
11152 }
11153
11154 #[test]
11155 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11156 // Cascade pin on the immediate-successor arm: a value
11157 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11158 // canonical "I tab-completed a path that already had a
11159 // glob-expansion tail" footgun) routes through
11160 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11161 // The embedded shell-metachar is the more semantic-locating
11162 // axis (an author who removes the `*` typically also drops
11163 // the trailing separator since both are paste-from-shell
11164 // artifacts).
11165 let d = dep_with_fonte(DepSource::Path {
11166 caminho: "../foo*/".into(),
11167 });
11168 let err = d.validate().unwrap_err();
11169 assert!(
11170 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11171 "got {err:?}",
11172 );
11173 }
11174
11175 #[test]
11176 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11177 // Diagnostic-shape pin (peer with
11178 // `fonte_caminho_shell_redirection_diagnostic_*` on the
11179 // closest two-byte peer arm): the error's Display surfaces
11180 // the offending `:nome`, the offending `:caminho` verbatim,
11181 // the offending byte's hex / character form, and names the
11182 // shell-glob / pathname-expansion footgun explicitly so a
11183 // `feira lint` run can render the diagnostic without
11184 // re-parsing.
11185 let d = dep_with_fonte(DepSource::Path {
11186 caminho: "../caixa-teia/*.lisp".into(),
11187 });
11188 let rendered = d.validate().unwrap_err().to_string();
11189 assert!(
11190 rendered.contains("caixa-teia"),
11191 "diagnostic must name the offending dep: {rendered}",
11192 );
11193 assert!(
11194 rendered.contains("../caixa-teia/*.lisp"),
11195 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11196 );
11197 assert!(
11198 rendered.contains("0x2a"),
11199 "diagnostic must surface the offending byte hex: {rendered:?}",
11200 );
11201 assert!(
11202 rendered.contains("glob"),
11203 "diagnostic must name the shell-glob footgun: {rendered:?}",
11204 );
11205 assert!(
11206 rendered.contains("pathname-expansion"),
11207 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11208 );
11209 }
11210
11211 #[test]
11212 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11213 // The fail-before-pass-after pin for the canonical modern-Bourne
11214 // command-substitution paste footgun: an author copies a
11215 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11216 // `$(<cmd>)` expansion would land the current date as a
11217 // subdirectory name and silently passed every prior arm
11218 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11219 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11220 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11221 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11222 // sits mid-path). The lacre embedded the value verbatim, the
11223 // resolver folded it through `Path::join` looking for a literal
11224 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11225 // surfaced at resolve time with a non-self-locating `No such
11226 // file or directory` error. The new arm moves the rejection to
11227 // validate time and names the offending dep + caminho + byte
11228 // verbatim. The arm fires on the first `(` encountered (the
11229 // opening byte of `$(date)`).
11230 let d = dep_with_fonte(DepSource::Path {
11231 caminho: "../caixa-teia/$(date)/build".into(),
11232 });
11233 let err = d.validate().unwrap_err();
11234 let DepError::FonteCaminhoShellSubshellGrouping {
11235 nome,
11236 caminho,
11237 byte,
11238 } = err
11239 else {
11240 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11241 };
11242 assert_eq!(nome, "caixa-teia");
11243 assert_eq!(caminho, "../caixa-teia/$(date)/build");
11244 assert_eq!(byte, b'(');
11245 }
11246
11247 #[test]
11248 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11249 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11250 // the degenerate "I selected an unbalanced closing paren out of
11251 // a shell-history block" idiom that probes for the cascade's
11252 // last-byte handling on a value carrying only the closing byte).
11253 // Pinned separately from the open-paren shape so the gate's
11254 // contract is "any `(` or `)` anywhere", not single-byte
11255 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11256 // caminho_carrying_question_glob` shape on the immediate-
11257 // predecessor `FonteCaminhoShellGlob` arm.
11258 let d = dep_with_fonte(DepSource::Path {
11259 caminho: "../caixa-teia)".into(),
11260 });
11261 let err = d.validate().unwrap_err();
11262 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11263 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11264 };
11265 assert_eq!(byte, b')');
11266 }
11267
11268 #[test]
11269 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11270 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11271 // canonical "I selected a `(cd foo)` subshell-grouping prefix
11272 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11273 // Pinned separately from the embedded-byte shape so the gate
11274 // covers every position, not only mid-path.
11275 let d = dep_with_fonte(DepSource::Path {
11276 caminho: "(cd foo)/caixa-teia".into(),
11277 });
11278 let err = d.validate().unwrap_err();
11279 assert!(
11280 matches!(
11281 err,
11282 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11283 ),
11284 "got {err:?}",
11285 );
11286 }
11287
11288 #[test]
11289 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11290 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11291 // — the canonical "I copied a `(pwd)` working-directory-probe
11292 // subshell-grouping idiom every shell-history block carries"
11293 // footgun). The value carries no other cascade-preceding
11294 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11295 // `*` / `?`) so the arm fires on the first `(` encountered;
11296 // pinned so a future arm that tries to distinguish the
11297 // opening from the closing byte doesn't break the broader
11298 // contract. Mirrors the peer
11299 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11300 // backtick_pair` shape on the upstream `FonteCaminhoShell\
11301 // CommandSubstitution` arm.
11302 let d = dep_with_fonte(DepSource::Path {
11303 caminho: "../(pwd)/caixa-teia".into(),
11304 });
11305 let err = d.validate().unwrap_err();
11306 assert!(
11307 matches!(
11308 err,
11309 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11310 ),
11311 "got {err:?}",
11312 );
11313 }
11314
11315 #[test]
11316 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11317 // The positive-control pin: the gate targets only `(` / `)`,
11318 // never adjacent printable ASCII or POSIX-valid bytes. The
11319 // canonical relative POSIX path (`"../caixa-teia"`) and a
11320 // nested deeply-pathed variant with adjacent printable
11321 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11322 // validate cleanly so the gate doesn't widen to a "no printable
11323 // punctuation anywhere" sweep that would defeat the entire
11324 // path-fonte author surface.
11325 let d = dep_with_fonte(DepSource::Path {
11326 caminho: "../caixa-teia/sub-dir.v2".into(),
11327 });
11328 d.validate().unwrap();
11329 }
11330
11331 #[test]
11332 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11333 // Cascade pin on the immediate-predecessor arm: a value
11334 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11335 // canonical "I pasted a glob expansion followed by a
11336 // subshell-grouping tail" footgun) routes through
11337 // `FonteCaminhoShellGlob` not
11338 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11339 // shape is the more common shell-history paste idiom on every
11340 // probe-as-both value — same cascade discipline every prior
11341 // `:caminho` arm establishes.
11342 let d = dep_with_fonte(DepSource::Path {
11343 caminho: "../caixa-teia/*(date)".into(),
11344 });
11345 let err = d.validate().unwrap_err();
11346 assert!(
11347 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11348 "got {err:?}",
11349 );
11350 }
11351
11352 #[test]
11353 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11354 // Cascade pin on the upstream shell-command-substitution arm: a
11355 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11356 // — the canonical "I pasted a legacy-backtick + modern-paren
11357 // command-substitution chain" footgun) routes through
11358 // `FonteCaminhoShellCommandSubstitution` not
11359 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11360 // command-injection vector is the load-bearing root-cause edit
11361 // on every probe-as-both value.
11362 let d = dep_with_fonte(DepSource::Path {
11363 caminho: "../`whoami`/$(date)".into(),
11364 });
11365 let err = d.validate().unwrap_err();
11366 assert!(
11367 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11368 "got {err:?}",
11369 );
11370 }
11371
11372 #[test]
11373 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11374 // Cascade pin on the upstream shell-background arm: a value
11375 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11376 // the canonical "I pasted a `cmd & (cd foo)` background-launch
11377 // + subshell-grouping chain" footgun) routes through
11378 // `FonteCaminhoShellBackground` not
11379 // `FonteCaminhoShellSubshellGrouping`. The background-launch
11380 // tail is the load-bearing root-cause edit on every probe-as-
11381 // both value.
11382 let d = dep_with_fonte(DepSource::Path {
11383 caminho: "../caixa-teia & (cd foo)".into(),
11384 });
11385 let err = d.validate().unwrap_err();
11386 assert!(
11387 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11388 "got {err:?}",
11389 );
11390 }
11391
11392 #[test]
11393 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11394 // Cascade pin on the upstream shell-semicolon arm: a value
11395 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11396 // the canonical sequential-cleanup + subshell-grouping paste
11397 // idiom) routes through `FonteCaminhoShellSemicolon` not
11398 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11399 // separator paste is the load-bearing root-cause edit on
11400 // every probe-as-both value.
11401 let d = dep_with_fonte(DepSource::Path {
11402 caminho: "../caixa-teia; (cd foo)".into(),
11403 });
11404 let err = d.validate().unwrap_err();
11405 assert!(
11406 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11407 "got {err:?}",
11408 );
11409 }
11410
11411 #[test]
11412 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11413 // Cascade pin on the upstream shell-pipe arm: a value carrying
11414 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11415 // canonical pipeline-to-subshell-grouping paste idiom) routes
11416 // through `FonteCaminhoShellPipe` not
11417 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11418 // is the load-bearing root-cause edit on every probe-as-both
11419 // value.
11420 let d = dep_with_fonte(DepSource::Path {
11421 caminho: "../caixa-teia | (tee log)".into(),
11422 });
11423 let err = d.validate().unwrap_err();
11424 assert!(
11425 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11426 "got {err:?}",
11427 );
11428 }
11429
11430 #[test]
11431 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11432 // Cascade pin on the upstream shell-redirection arm: a value
11433 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11434 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11435 // plus-subshell-grouping chain" footgun) routes through
11436 // `FonteCaminhoShellRedirection` not
11437 // `FonteCaminhoShellSubshellGrouping`. The input/output
11438 // redirection metachar carries the more self-locating `byte`
11439 // payload (it names which of `<` or `>` triggered), so the
11440 // prior arm wins on every probe-as-both value.
11441 let d = dep_with_fonte(DepSource::Path {
11442 caminho: "../caixa-teia>log (cd foo)".into(),
11443 });
11444 let err = d.validate().unwrap_err();
11445 assert!(
11446 matches!(
11447 err,
11448 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11449 ),
11450 "got {err:?}",
11451 );
11452 }
11453
11454 #[test]
11455 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11456 // Cascade pin on the upstream backslash arm: a value carrying
11457 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11458 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11459 // through `FonteCaminhoBackslash` not
11460 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11461 // separator divergence is the load-bearing axis on every
11462 // probe-as-both value (an author who removes the `\` is the
11463 // root-cause edit; the `(` falls away in the same edit since
11464 // it's downstream of the Windows-shell convention).
11465 let d = dep_with_fonte(DepSource::Path {
11466 caminho: "..\\caixa-teia\\(cd foo)".into(),
11467 });
11468 let err = d.validate().unwrap_err();
11469 assert!(
11470 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11471 "got {err:?}",
11472 );
11473 }
11474
11475 #[test]
11476 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11477 // Cascade pin on the embedded-control-byte arm: a value
11478 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11479 // the canonical paste-from-multiline-doc footgun where a
11480 // newline landed mid-caminho between two paste fragments)
11481 // routes through `FonteCaminhoControlChar` not
11482 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11483 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11484 // load-bearing axis on every value that probes positive for
11485 // both — mirrors the cascade discipline on every prior arm.
11486 let d = dep_with_fonte(DepSource::Path {
11487 caminho: "../foo\n(cd bar)".into(),
11488 });
11489 let err = d.validate().unwrap_err();
11490 assert!(
11491 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11492 "got {err:?}",
11493 );
11494 }
11495
11496 #[test]
11497 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11498 // Cascade pin on the load-bearing leading-byte arm: a leading
11499 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11500 // through `FonteCaminhoAbsolute` not
11501 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11502 // diagnostic is the load-bearing axis, the subshell-grouping
11503 // byte is the secondary observation. Same precedence logic as
11504 // every prior leading-byte arm.
11505 let d = dep_with_fonte(DepSource::Path {
11506 caminho: "/etc/(cd foo)".into(),
11507 });
11508 let err = d.validate().unwrap_err();
11509 assert!(
11510 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11511 "got {err:?}",
11512 );
11513 }
11514
11515 #[test]
11516 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11517 // Cascade pin on the upstream leading-`$` var-expansion arm: a
11518 // value carrying both a leading `$` and a `(` (`"$(date)/\
11519 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11520 // command-substitution at the head of a sibling-workspace
11521 // path" footgun) routes through `FonteCaminhoVarExpansion` not
11522 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11523 // shell-variable-expansion is the more self-locating diagnostic
11524 // on values that probe as both — same load-bearing-leading-
11525 // byte cascade discipline every prior `:caminho` arm
11526 // establishes. Closing both halves of `$(<cmd>)` structurally
11527 // (leading `$` here, trailing `)` on the new arm) excludes the
11528 // entire modern Bourne command-substitution surface from the
11529 // typed `:caminho` accepted set; the cascade preserves the
11530 // narrower leading-byte diagnostic on values that probe both
11531 // halves at the canonical leading position.
11532 let d = dep_with_fonte(DepSource::Path {
11533 caminho: "$(date)/caixa-teia".into(),
11534 });
11535 let err = d.validate().unwrap_err();
11536 assert!(
11537 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11538 "got {err:?}",
11539 );
11540 }
11541
11542 #[test]
11543 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11544 // Cascade pin on the immediate-successor arm: a value carrying
11545 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11546 // "I tab-completed a path that already had a subshell-grouping
11547 // expansion tail" footgun) routes through
11548 // `FonteCaminhoShellSubshellGrouping` not
11549 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11550 // the more semantic-locating axis (an author who removes the
11551 // `(` typically also drops the trailing separator since both
11552 // are paste-from-shell artifacts).
11553 let d = dep_with_fonte(DepSource::Path {
11554 caminho: "../(cd foo)/".into(),
11555 });
11556 let err = d.validate().unwrap_err();
11557 assert!(
11558 matches!(
11559 err,
11560 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11561 ),
11562 "got {err:?}",
11563 );
11564 }
11565
11566 #[test]
11567 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11568 // Diagnostic-shape pin (peer with
11569 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11570 // on the closest two-byte peer arm): the error's Display
11571 // surfaces the offending `:nome`, the offending `:caminho`
11572 // verbatim, the offending byte's hex / character form, and
11573 // names the shell-subshell-grouping footgun explicitly so a
11574 // `feira lint` run can render the diagnostic without re-
11575 // parsing.
11576 let d = dep_with_fonte(DepSource::Path {
11577 caminho: "../caixa-teia/$(date)/build".into(),
11578 });
11579 let rendered = d.validate().unwrap_err().to_string();
11580 assert!(
11581 rendered.contains("caixa-teia"),
11582 "diagnostic must name the offending dep: {rendered}",
11583 );
11584 assert!(
11585 rendered.contains("../caixa-teia/$(date)/build"),
11586 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11587 );
11588 assert!(
11589 rendered.contains("0x28"),
11590 "diagnostic must surface the offending byte hex: {rendered:?}",
11591 );
11592 assert!(
11593 rendered.contains("subshell-grouping"),
11594 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11595 );
11596 assert!(
11597 rendered.contains("command-substitution"),
11598 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11599 {rendered:?}",
11600 );
11601 }
11602
11603 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11604 //
11605 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11606 // `)`) byte-pair arm: the same per-byte cascade with the same
11607 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11608 // `}` brace-expansion / URI-Template placeholder axis. The peer
11609 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11610 // byte pair on the sibling `:fonte :repo` axis under the same
11611 // banner.
11612
11613 #[test]
11614 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11615 // The fail-before-pass-after pin for the canonical paste-from-
11616 // shell-history brace-expansion footgun: an author copies a
11617 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11618 // liner whose `{a,b}` brace expansion fans across two siblings
11619 // and silently passed every prior arm (`Path::is_absolute`
11620 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11621 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11622 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11623 // `FonteCaminhoVarExpansion` arm doesn't fire because the
11624 // value starts with `..` not `$`). The lacre embedded the
11625 // value verbatim, the resolver folded it through `Path::join`
11626 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11627 // subdirectory, and the failure surfaced at resolve time with
11628 // a non-self-locating `No such file or directory` error. The
11629 // new arm moves the rejection to validate time and names the
11630 // offending dep + caminho + byte verbatim. The arm fires on
11631 // the first `{` encountered.
11632 let d = dep_with_fonte(DepSource::Path {
11633 caminho: "../{caixa-teia,caixa-helm}/build".into(),
11634 });
11635 let err = d.validate().unwrap_err();
11636 let DepError::FonteCaminhoShellBraceExpansion {
11637 nome,
11638 caminho,
11639 byte,
11640 } = err
11641 else {
11642 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11643 };
11644 assert_eq!(nome, "caixa-teia");
11645 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11646 assert_eq!(byte, b'{');
11647 }
11648
11649 #[test]
11650 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11651 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11652 // the degenerate "I selected an unbalanced closing brace out
11653 // of a shell-history block" idiom that probes for the
11654 // cascade's last-byte handling on a value carrying only the
11655 // closing byte). Pinned separately from the open-brace shape
11656 // so the gate's contract is "any `{` or `}` anywhere", not
11657 // single-byte coverage. Mirrors the peer
11658 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11659 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11660 // arm.
11661 let d = dep_with_fonte(DepSource::Path {
11662 caminho: "../caixa-teia}".into(),
11663 });
11664 let err = d.validate().unwrap_err();
11665 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11666 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11667 };
11668 assert_eq!(byte, b'}');
11669 }
11670
11671 #[test]
11672 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11673 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11674 // — the canonical "I selected a `{a,b}` brace-expansion prefix
11675 // out of a shell-history one-liner" idiom). Pinned separately
11676 // from the embedded-byte shape so the gate covers every
11677 // position, not only mid-path.
11678 let d = dep_with_fonte(DepSource::Path {
11679 caminho: "{caixa-teia,caixa-helm}/build".into(),
11680 });
11681 let err = d.validate().unwrap_err();
11682 assert!(
11683 matches!(
11684 err,
11685 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11686 ),
11687 "got {err:?}",
11688 );
11689 }
11690
11691 #[test]
11692 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11693 // The canonical URI-Template / Mustache / Helm doubled-brace
11694 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11695 // "I copied a `https://github.com/{{org}}/caixa-teia` README
11696 // quick-start / OpenAPI spec / Helm chart `home:` template
11697 // and forgot to substitute the placeholder" footgun). The arm
11698 // fires on the first `{` encountered; pinned so the gate's
11699 // coverage extends from the bare-brace shell-history shape to
11700 // the doubled-brace URI-Template / templating-engine shape.
11701 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11702 // sibling `:fonte :repo` axis.
11703 let d = dep_with_fonte(DepSource::Path {
11704 caminho: "../{{org}}/caixa-teia".into(),
11705 });
11706 let err = d.validate().unwrap_err();
11707 assert!(
11708 matches!(
11709 err,
11710 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11711 ),
11712 "got {err:?}",
11713 );
11714 }
11715
11716 #[test]
11717 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11718 // The canonical bash brace-range-expansion shape (`"../caixa-
11719 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11720 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11721 // sequence-range form to the `{a,b,c}` comma-separated form).
11722 // The arm fires on the first `{` encountered; pinned so the
11723 // gate's coverage extends from the comma-separated form to
11724 // the integer-range form.
11725 let d = dep_with_fonte(DepSource::Path {
11726 caminho: "../caixa-v{1..10}".into(),
11727 });
11728 let err = d.validate().unwrap_err();
11729 assert!(
11730 matches!(
11731 err,
11732 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11733 ),
11734 "got {err:?}",
11735 );
11736 }
11737
11738 #[test]
11739 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11740 // The positive-control pin: the gate targets only `{` / `}`,
11741 // never adjacent printable ASCII or POSIX-valid bytes. The
11742 // canonical relative POSIX path (`"../caixa-teia"`) and a
11743 // nested deeply-pathed variant with adjacent printable
11744 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11745 // validate cleanly so the gate doesn't widen to a "no
11746 // printable punctuation anywhere" sweep that would defeat
11747 // the entire path-fonte author surface. Peer with
11748 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11749 // on the immediate-predecessor arm.
11750 let d = dep_with_fonte(DepSource::Path {
11751 caminho: "../caixa-teia/sub-dir.v2".into(),
11752 });
11753 d.validate().unwrap();
11754 }
11755
11756 #[test]
11757 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11758 // Cascade pin on the immediate-predecessor arm: a value
11759 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11760 // canonical "I pasted a subshell-grouping followed by a
11761 // brace-expansion tail" footgun) routes through
11762 // `FonteCaminhoShellSubshellGrouping` not
11763 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11764 // shape is the more semantic-locating axis on every probe-
11765 // as-both value because it closes both halves of the modern
11766 // Bourne `$(<cmd>)` command-substitution surface — same
11767 // cascade discipline every prior `:caminho` arm establishes.
11768 let d = dep_with_fonte(DepSource::Path {
11769 caminho: "../(cd foo)/{a,b}".into(),
11770 });
11771 let err = d.validate().unwrap_err();
11772 assert!(
11773 matches!(
11774 err,
11775 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11776 ),
11777 "got {err:?}",
11778 );
11779 }
11780
11781 #[test]
11782 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11783 // Cascade pin on the upstream shell-glob arm: a value carrying
11784 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11785 // "I pasted a glob expansion followed by a brace-expansion
11786 // tail" footgun) routes through `FonteCaminhoShellGlob` not
11787 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11788 // shape is the load-bearing root-cause edit on every
11789 // probe-as-both value.
11790 let d = dep_with_fonte(DepSource::Path {
11791 caminho: "../caixa-teia/*{a,b}".into(),
11792 });
11793 let err = d.validate().unwrap_err();
11794 assert!(
11795 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11796 "got {err:?}",
11797 );
11798 }
11799
11800 #[test]
11801 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11802 // Cascade pin on the upstream shell-command-substitution arm:
11803 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11804 // — the canonical "I pasted a legacy-backtick command-
11805 // substitution followed by a brace-expansion fan-out" footgun)
11806 // routes through `FonteCaminhoShellCommandSubstitution` not
11807 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11808 // command-injection vector is the load-bearing root-cause
11809 // edit on every probe-as-both value.
11810 let d = dep_with_fonte(DepSource::Path {
11811 caminho: "../`whoami`/{a,b}".into(),
11812 });
11813 let err = d.validate().unwrap_err();
11814 assert!(
11815 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11816 "got {err:?}",
11817 );
11818 }
11819
11820 #[test]
11821 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11822 // Cascade pin on the upstream shell-background arm: a value
11823 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11824 // canonical "I pasted a `cmd & {fork-fan}` background-launch
11825 // + brace-expansion chain" footgun) routes through
11826 // `FonteCaminhoShellBackground` not
11827 // `FonteCaminhoShellBraceExpansion`. The background-launch
11828 // tail is the load-bearing root-cause edit on every
11829 // probe-as-both value.
11830 let d = dep_with_fonte(DepSource::Path {
11831 caminho: "../caixa-teia & {a,b}".into(),
11832 });
11833 let err = d.validate().unwrap_err();
11834 assert!(
11835 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11836 "got {err:?}",
11837 );
11838 }
11839
11840 #[test]
11841 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11842 // Cascade pin on the upstream shell-semicolon arm: a value
11843 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11844 // canonical sequential-cleanup + brace-expansion paste
11845 // idiom) routes through `FonteCaminhoShellSemicolon` not
11846 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11847 // separator paste is the load-bearing root-cause edit on
11848 // every probe-as-both value.
11849 let d = dep_with_fonte(DepSource::Path {
11850 caminho: "../caixa-teia; {a,b}".into(),
11851 });
11852 let err = d.validate().unwrap_err();
11853 assert!(
11854 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11855 "got {err:?}",
11856 );
11857 }
11858
11859 #[test]
11860 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
11861 // Cascade pin on the upstream shell-pipe arm: a value
11862 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
11863 // — the canonical pipeline-to-brace-expansion paste idiom)
11864 // routes through `FonteCaminhoShellPipe` not
11865 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
11866 // is the load-bearing root-cause edit on every probe-as-
11867 // both value.
11868 let d = dep_with_fonte(DepSource::Path {
11869 caminho: "../caixa-teia | {tee,cat}".into(),
11870 });
11871 let err = d.validate().unwrap_err();
11872 assert!(
11873 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11874 "got {err:?}",
11875 );
11876 }
11877
11878 #[test]
11879 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
11880 // Cascade pin on the upstream shell-redirection arm: a value
11881 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
11882 // the canonical "I pasted a `cmd > log {a,b}` redirect-
11883 // plus-brace-expansion chain" footgun) routes through
11884 // `FonteCaminhoShellRedirection` not
11885 // `FonteCaminhoShellBraceExpansion`. The input/output
11886 // redirection metachar carries the more self-locating
11887 // `byte` payload, so the prior arm wins on every probe-
11888 // as-both value.
11889 let d = dep_with_fonte(DepSource::Path {
11890 caminho: "../caixa-teia>log {a,b}".into(),
11891 });
11892 let err = d.validate().unwrap_err();
11893 assert!(
11894 matches!(
11895 err,
11896 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11897 ),
11898 "got {err:?}",
11899 );
11900 }
11901
11902 #[test]
11903 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
11904 // Cascade pin on the upstream backslash arm: a value
11905 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
11906 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
11907 // chain") routes through `FonteCaminhoBackslash` not
11908 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
11909 // separator divergence is the load-bearing axis on every
11910 // probe-as-both value.
11911 let d = dep_with_fonte(DepSource::Path {
11912 caminho: "..\\caixa-teia\\{a,b}".into(),
11913 });
11914 let err = d.validate().unwrap_err();
11915 assert!(
11916 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11917 "got {err:?}",
11918 );
11919 }
11920
11921 #[test]
11922 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
11923 // Cascade pin on the embedded-control-byte arm: a value
11924 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
11925 // the canonical paste-from-multiline-doc footgun where a
11926 // newline landed mid-caminho between two paste fragments)
11927 // routes through `FonteCaminhoControlChar` not
11928 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
11929 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11930 // load-bearing axis on every value that probes positive for
11931 // both — mirrors the cascade discipline on every prior arm.
11932 let d = dep_with_fonte(DepSource::Path {
11933 caminho: "../foo\n{a,b}".into(),
11934 });
11935 let err = d.validate().unwrap_err();
11936 assert!(
11937 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11938 "got {err:?}",
11939 );
11940 }
11941
11942 #[test]
11943 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
11944 // Cascade pin on the load-bearing leading-byte arm: a
11945 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
11946 // routes through `FonteCaminhoAbsolute` not
11947 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
11948 // diagnostic is the load-bearing axis, the brace-expansion
11949 // byte is the secondary observation. Same precedence logic
11950 // as every prior leading-byte arm.
11951 let d = dep_with_fonte(DepSource::Path {
11952 caminho: "/etc/{a,b}".into(),
11953 });
11954 let err = d.validate().unwrap_err();
11955 assert!(
11956 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11957 "got {err:?}",
11958 );
11959 }
11960
11961 #[test]
11962 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
11963 // Cascade pin on the upstream leading-`$` var-expansion
11964 // arm: a value carrying both a leading `$` and a `{`
11965 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
11966 // `${ORG}` shell-variable + curly-brace expansion at the
11967 // head of a sibling-workspace path" footgun) routes through
11968 // `FonteCaminhoVarExpansion` not
11969 // `FonteCaminhoShellBraceExpansion`. The leading-byte
11970 // shell-variable-expansion is the more self-locating
11971 // diagnostic on values that probe as both — same
11972 // load-bearing-leading-byte cascade discipline every prior
11973 // `:caminho` arm establishes.
11974 let d = dep_with_fonte(DepSource::Path {
11975 caminho: "${ORG}/caixa-teia".into(),
11976 });
11977 let err = d.validate().unwrap_err();
11978 assert!(
11979 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11980 "got {err:?}",
11981 );
11982 }
11983
11984 #[test]
11985 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
11986 // Cascade pin on the immediate-successor arm: a value
11987 // carrying both `{` and a trailing `/`
11988 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
11989 // tab-completed a path that already had a brace-expansion
11990 // expansion tail" footgun) routes through
11991 // `FonteCaminhoShellBraceExpansion` not
11992 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11993 // is the more semantic-locating axis (an author who removes
11994 // the `{` typically also drops the trailing separator since
11995 // both are paste-from-shell artifacts).
11996 let d = dep_with_fonte(DepSource::Path {
11997 caminho: "../{caixa-teia,caixa-helm}/".into(),
11998 });
11999 let err = d.validate().unwrap_err();
12000 assert!(
12001 matches!(
12002 err,
12003 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12004 ),
12005 "got {err:?}",
12006 );
12007 }
12008
12009 #[test]
12010 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12011 // Diagnostic-shape pin (peer with
12012 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12013 // on the closest two-byte peer arm): the error's Display
12014 // surfaces the offending `:nome`, the offending `:caminho`
12015 // verbatim, the offending byte's hex / character form, and
12016 // names the shell-brace-expansion / URI-Template footgun
12017 // explicitly so a `feira lint` run can render the diagnostic
12018 // without re-parsing.
12019 let d = dep_with_fonte(DepSource::Path {
12020 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12021 });
12022 let rendered = d.validate().unwrap_err().to_string();
12023 assert!(
12024 rendered.contains("caixa-teia"),
12025 "diagnostic must name the offending dep: {rendered}",
12026 );
12027 assert!(
12028 rendered.contains("../{caixa-teia,caixa-helm}/build"),
12029 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12030 );
12031 assert!(
12032 rendered.contains("0x7b"),
12033 "diagnostic must surface the offending byte hex: {rendered:?}",
12034 );
12035 assert!(
12036 rendered.contains("brace-expansion"),
12037 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12038 );
12039 assert!(
12040 rendered.contains("URI Template"),
12041 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12042 {rendered:?}",
12043 );
12044 }
12045
12046 #[test]
12047 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12048 // The canonical paste-from-shell-history bracket-glob /
12049 // character-class footgun: an author copies a
12050 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12051 // `[a-z]` POSIX glob character-class matches every lowercase-
12052 // ASCII-suffix sibling caixa directory and silently passed
12053 // every prior arm (`Path::is_absolute` false on `..`, no
12054 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12055 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12056 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12057 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12058 // value starts with `..` not `$`). The lacre embedded the
12059 // value verbatim, the resolver folded it through
12060 // `Path::join` looking for a literal `./../caixa-[a-z]/
12061 // build` subdirectory, and the failure surfaced at resolve
12062 // time with a non-self-locating `No such file or directory`
12063 // error. The new arm moves the rejection to validate time
12064 // and names the offending dep + caminho + byte verbatim.
12065 // The arm fires on the first `[` encountered.
12066 let d = dep_with_fonte(DepSource::Path {
12067 caminho: "../caixa-[a-z]/build".into(),
12068 });
12069 let err = d.validate().unwrap_err();
12070 let DepError::FonteCaminhoShellBracketExpansion {
12071 nome,
12072 caminho,
12073 byte,
12074 } = err
12075 else {
12076 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12077 };
12078 assert_eq!(nome, "caixa-teia");
12079 assert_eq!(caminho, "../caixa-[a-z]/build");
12080 assert_eq!(byte, b'[');
12081 }
12082
12083 #[test]
12084 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12085 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12086 // — the degenerate "I selected an unbalanced closing bracket
12087 // out of a glob character-class block" idiom that probes for
12088 // the cascade's last-byte handling on a value carrying only
12089 // the closing byte). Pinned separately from the open-bracket
12090 // shape so the gate's contract is "any `[` or `]` anywhere",
12091 // not single-byte coverage. Mirrors the peer
12092 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12093 // shape on the immediate-predecessor
12094 // `FonteCaminhoShellBraceExpansion` arm.
12095 let d = dep_with_fonte(DepSource::Path {
12096 caminho: "../caixa-teia]".into(),
12097 });
12098 let err = d.validate().unwrap_err();
12099 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12100 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12101 };
12102 assert_eq!(byte, b']');
12103 }
12104
12105 #[test]
12106 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12107 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12108 // canonical "I selected a `[caixa-teia]` TOML-table-header /
12109 // glob-character-class prefix out of an aligned config /
12110 // shell-history one-liner" idiom). Pinned separately from
12111 // the embedded-byte shape so the gate covers every position,
12112 // not only mid-path.
12113 let d = dep_with_fonte(DepSource::Path {
12114 caminho: "[caixa-teia]/build".into(),
12115 });
12116 let err = d.validate().unwrap_err();
12117 assert!(
12118 matches!(
12119 err,
12120 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12121 ),
12122 "got {err:?}",
12123 );
12124 }
12125
12126 #[test]
12127 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12128 // The canonical TOML inline-array / YAML flow-sequence
12129 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12130 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12131 // inline-array out of a sibling-Cargo manifest" cross-idiom
12132 // leak; the symmetric YAML flow-sequence form `paths: [/a,
12133 // /b]` paste-from-values.yaml shape carries the same
12134 // bracket pair). The arm fires on the first `[` encountered;
12135 // pinned so the gate's coverage extends from the bare-
12136 // bracket glob-character-class shape to the TOML / YAML /
12137 // JSON array-literal shape.
12138 let d = dep_with_fonte(DepSource::Path {
12139 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12140 });
12141 let err = d.validate().unwrap_err();
12142 assert!(
12143 matches!(
12144 err,
12145 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12146 ),
12147 "got {err:?}",
12148 );
12149 }
12150
12151 #[test]
12152 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12153 // The canonical POSIX `test` / `[` builtin command paste
12154 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12155 // script conditional every paste-from-shell-script idiom
12156 // carries; bash's `[[ <expr> ]]` extended-test grammar
12157 // would surface the same byte pair). The arm fires on the
12158 // first `[` encountered; pinned so the gate's coverage
12159 // extends from the embedded-glob-character-class shape to
12160 // the leading-`test`-builtin / extended-test form.
12161 let d = dep_with_fonte(DepSource::Path {
12162 caminho: "../[ -d caixa-teia ]".into(),
12163 });
12164 let err = d.validate().unwrap_err();
12165 assert!(
12166 matches!(
12167 err,
12168 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12169 ),
12170 "got {err:?}",
12171 );
12172 }
12173
12174 #[test]
12175 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12176 // The positive-control pin: the gate targets only `[` /
12177 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12178 // The canonical relative POSIX path (`"../caixa-teia"`) and
12179 // a nested deeply-pathed variant with adjacent printable
12180 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12181 // to validate cleanly so the gate doesn't widen to a "no
12182 // printable punctuation anywhere" sweep that would defeat
12183 // the entire path-fonte author surface. Peer with
12184 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12185 // on the immediate-predecessor arm.
12186 let d = dep_with_fonte(DepSource::Path {
12187 caminho: "../caixa-teia/sub-dir.v2".into(),
12188 });
12189 d.validate().unwrap();
12190 }
12191
12192 #[test]
12193 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12194 // Cascade pin on the immediate-predecessor arm: a value
12195 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12196 // canonical "I pasted a brace-expansion fan followed by a
12197 // glob-character-class tail" footgun) routes through
12198 // `FonteCaminhoShellBraceExpansion` not
12199 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12200 // fan is the load-bearing root-cause edit on every
12201 // probe-as-both value because the bracket-class tail
12202 // typically rides on a prior brace-expansion expansion;
12203 // same cascade discipline every prior `:caminho` arm
12204 // establishes.
12205 let d = dep_with_fonte(DepSource::Path {
12206 caminho: "../{a,b}[ch]".into(),
12207 });
12208 let err = d.validate().unwrap_err();
12209 assert!(
12210 matches!(
12211 err,
12212 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12213 ),
12214 "got {err:?}",
12215 );
12216 }
12217
12218 #[test]
12219 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12220 // Cascade pin on the upstream shell-subshell-grouping arm:
12221 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12222 // the canonical "I pasted a subshell-grouping followed by
12223 // a glob-character-class tail" footgun) routes through
12224 // `FonteCaminhoShellSubshellGrouping` not
12225 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12226 // `$(<cmd>)` command-substitution boundary is the load-
12227 // bearing axis on every probe-as-both value.
12228 let d = dep_with_fonte(DepSource::Path {
12229 caminho: "../(cd foo)/[ch]".into(),
12230 });
12231 let err = d.validate().unwrap_err();
12232 assert!(
12233 matches!(
12234 err,
12235 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12236 ),
12237 "got {err:?}",
12238 );
12239 }
12240
12241 #[test]
12242 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12243 // Cascade pin on the upstream shell-glob arm: a value
12244 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12245 // canonical "I pasted a `*.[ch]` C-source-file glob whose
12246 // unbounded `*` precedes the bracket character-class"
12247 // footgun) routes through `FonteCaminhoShellGlob` not
12248 // `FonteCaminhoShellBracketExpansion`. The unbounded
12249 // pathname-expansion sentinel is the load-bearing root-
12250 // cause edit on every probe-as-both value — the unbounded
12251 // `*` carries the more aggressive expansion vector than
12252 // the bounded `[ch]` class, so the prior arm wins.
12253 let d = dep_with_fonte(DepSource::Path {
12254 caminho: "../caixa-teia/*[ch]".into(),
12255 });
12256 let err = d.validate().unwrap_err();
12257 assert!(
12258 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12259 "got {err:?}",
12260 );
12261 }
12262
12263 #[test]
12264 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12265 // Cascade pin on the upstream shell-command-substitution
12266 // arm: a value carrying both a backtick and `[`
12267 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12268 // legacy-backtick command-substitution followed by a
12269 // glob-character-class tail" footgun) routes through
12270 // `FonteCaminhoShellCommandSubstitution` not
12271 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12272 // command-injection vector is the load-bearing root-cause
12273 // edit on every probe-as-both value.
12274 let d = dep_with_fonte(DepSource::Path {
12275 caminho: "../`whoami`/[ch]".into(),
12276 });
12277 let err = d.validate().unwrap_err();
12278 assert!(
12279 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12280 "got {err:?}",
12281 );
12282 }
12283
12284 #[test]
12285 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12286 // Cascade pin on the upstream shell-background arm: a
12287 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12288 // — the canonical "I pasted a `cmd & [glob]` background-
12289 // launch + bracket-class chain" footgun) routes through
12290 // `FonteCaminhoShellBackground` not
12291 // `FonteCaminhoShellBracketExpansion`. The background-
12292 // launch tail is the load-bearing root-cause edit on
12293 // every probe-as-both value.
12294 let d = dep_with_fonte(DepSource::Path {
12295 caminho: "../caixa-teia & [ch]".into(),
12296 });
12297 let err = d.validate().unwrap_err();
12298 assert!(
12299 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12300 "got {err:?}",
12301 );
12302 }
12303
12304 #[test]
12305 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12306 // Cascade pin on the upstream shell-semicolon arm: a value
12307 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12308 // canonical sequential-cleanup + bracket-class paste
12309 // idiom) routes through `FonteCaminhoShellSemicolon` not
12310 // `FonteCaminhoShellBracketExpansion`. The sequential-
12311 // command-separator paste is the load-bearing root-cause
12312 // edit on every probe-as-both value.
12313 let d = dep_with_fonte(DepSource::Path {
12314 caminho: "../caixa-teia; [ch]".into(),
12315 });
12316 let err = d.validate().unwrap_err();
12317 assert!(
12318 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12319 "got {err:?}",
12320 );
12321 }
12322
12323 #[test]
12324 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12325 // Cascade pin on the upstream shell-pipe arm: a value
12326 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12327 // the canonical pipeline-to-bracket-class paste idiom)
12328 // routes through `FonteCaminhoShellPipe` not
12329 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12330 // paste is the load-bearing root-cause edit on every
12331 // probe-as-both value.
12332 let d = dep_with_fonte(DepSource::Path {
12333 caminho: "../caixa-teia | [tee]".into(),
12334 });
12335 let err = d.validate().unwrap_err();
12336 assert!(
12337 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12338 "got {err:?}",
12339 );
12340 }
12341
12342 #[test]
12343 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12344 // Cascade pin on the upstream shell-redirection arm: a
12345 // value carrying both `>` and `[` (`"../caixa-teia>log
12346 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12347 // redirect-plus-bracket chain" footgun) routes through
12348 // `FonteCaminhoShellRedirection` not
12349 // `FonteCaminhoShellBracketExpansion`. The input/output
12350 // redirection metachar carries the more self-locating
12351 // `byte` payload, so the prior arm wins on every
12352 // probe-as-both value.
12353 let d = dep_with_fonte(DepSource::Path {
12354 caminho: "../caixa-teia>log [ch]".into(),
12355 });
12356 let err = d.validate().unwrap_err();
12357 assert!(
12358 matches!(
12359 err,
12360 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12361 ),
12362 "got {err:?}",
12363 );
12364 }
12365
12366 #[test]
12367 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12368 // Cascade pin on the upstream backslash arm: a value
12369 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12370 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12371 // chain") routes through `FonteCaminhoBackslash` not
12372 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12373 // separator divergence is the load-bearing axis on every
12374 // probe-as-both value.
12375 let d = dep_with_fonte(DepSource::Path {
12376 caminho: "..\\caixa-teia\\[ch]".into(),
12377 });
12378 let err = d.validate().unwrap_err();
12379 assert!(
12380 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12381 "got {err:?}",
12382 );
12383 }
12384
12385 #[test]
12386 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12387 // Cascade pin on the embedded-control-byte arm: a value
12388 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12389 // the canonical paste-from-multiline-doc footgun where a
12390 // newline landed mid-caminho between two paste fragments)
12391 // routes through `FonteCaminhoControlChar` not
12392 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12393 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12394 // the load-bearing axis on every value that probes
12395 // positive for both — mirrors the cascade discipline on
12396 // every prior arm.
12397 let d = dep_with_fonte(DepSource::Path {
12398 caminho: "../foo\n[ch]".into(),
12399 });
12400 let err = d.validate().unwrap_err();
12401 assert!(
12402 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12403 "got {err:?}",
12404 );
12405 }
12406
12407 #[test]
12408 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12409 // Cascade pin on the load-bearing leading-byte arm: a
12410 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12411 // routes through `FonteCaminhoAbsolute` not
12412 // `FonteCaminhoShellBracketExpansion` — the host-layout-
12413 // leak diagnostic is the load-bearing axis, the bracket-
12414 // expansion byte is the secondary observation. Same
12415 // precedence logic as every prior leading-byte arm.
12416 let d = dep_with_fonte(DepSource::Path {
12417 caminho: "/etc/[ch]".into(),
12418 });
12419 let err = d.validate().unwrap_err();
12420 assert!(
12421 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12422 "got {err:?}",
12423 );
12424 }
12425
12426 #[test]
12427 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12428 // Cascade pin on the upstream leading-`$` var-expansion
12429 // arm: a value carrying both a leading `$` and a `[`
12430 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12431 // variable + bracket-class at the head of a sibling-
12432 // workspace path" footgun) routes through
12433 // `FonteCaminhoVarExpansion` not
12434 // `FonteCaminhoShellBracketExpansion`. The leading-byte
12435 // shell-variable-expansion is the more self-locating
12436 // diagnostic on values that probe as both — same
12437 // load-bearing-leading-byte cascade discipline every
12438 // prior `:caminho` arm establishes.
12439 let d = dep_with_fonte(DepSource::Path {
12440 caminho: "$DIR/[ch]".into(),
12441 });
12442 let err = d.validate().unwrap_err();
12443 assert!(
12444 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12445 "got {err:?}",
12446 );
12447 }
12448
12449 #[test]
12450 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12451 // Cascade pin on the immediate-successor arm: a value
12452 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12453 // the canonical "I tab-completed a path that already had
12454 // a bracket-glob-character-class expansion tail" footgun)
12455 // routes through `FonteCaminhoShellBracketExpansion` not
12456 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12457 // is the more semantic-locating axis (an author who
12458 // removes the `[` typically also drops the trailing
12459 // separator since both are paste-from-shell artifacts).
12460 let d = dep_with_fonte(DepSource::Path {
12461 caminho: "../[a-z]/".into(),
12462 });
12463 let err = d.validate().unwrap_err();
12464 assert!(
12465 matches!(
12466 err,
12467 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12468 ),
12469 "got {err:?}",
12470 );
12471 }
12472
12473 #[test]
12474 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12475 // Diagnostic-shape pin (peer with
12476 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12477 // on the closest two-byte peer arm): the error's Display
12478 // surfaces the offending `:nome`, the offending `:caminho`
12479 // verbatim, the offending byte's hex / character form, and
12480 // names the shell-bracket-expansion / glob-character-class
12481 // footgun explicitly so a `feira lint` run can render the
12482 // diagnostic without re-parsing.
12483 let d = dep_with_fonte(DepSource::Path {
12484 caminho: "../caixa-[a-z]/build".into(),
12485 });
12486 let rendered = d.validate().unwrap_err().to_string();
12487 assert!(
12488 rendered.contains("caixa-teia"),
12489 "diagnostic must name the offending dep: {rendered}",
12490 );
12491 assert!(
12492 rendered.contains("../caixa-[a-z]/build"),
12493 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12494 );
12495 assert!(
12496 rendered.contains("0x5b"),
12497 "diagnostic must surface the offending byte hex: {rendered:?}",
12498 );
12499 assert!(
12500 rendered.contains("bracket-expansion"),
12501 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12502 );
12503 assert!(
12504 rendered.contains("glob-character-class"),
12505 "diagnostic must reference the POSIX glob-character-class vocabulary: \
12506 {rendered:?}",
12507 );
12508 }
12509
12510 #[test]
12511 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12512 // The canonical paste-from-shell-history strong-quoted
12513 // sibling-workspace-path footgun: an author copies a
12514 // `cd '../caixa-teia'` shell-history one-liner whose strong-
12515 // quoting preserved the path across a whitespace paste
12516 // boundary and silently passed every prior arm
12517 // (`Path::is_absolute` false on `'..`, no control bytes, no
12518 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12519 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12520 // doesn't end in `/`; the leading-`$` f4efe9c
12521 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12522 // value starts with `'` not `$`). The lacre embedded the
12523 // value verbatim, the resolver folded it through
12524 // `Path::join` looking for a literal `./'../caixa-teia'`
12525 // subdirectory, and the failure surfaced at resolve time
12526 // with a non-self-locating `No such file or directory`
12527 // error. The new arm moves the rejection to validate time
12528 // and names the offending dep + caminho + byte verbatim.
12529 // The arm fires on the first `'` encountered.
12530 let d = dep_with_fonte(DepSource::Path {
12531 caminho: "'../caixa-teia'".into(),
12532 });
12533 let err = d.validate().unwrap_err();
12534 let DepError::FonteCaminhoShellQuoteGrouping {
12535 nome,
12536 caminho,
12537 byte,
12538 } = err
12539 else {
12540 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12541 };
12542 assert_eq!(nome, "caixa-teia");
12543 assert_eq!(caminho, "'../caixa-teia'");
12544 assert_eq!(byte, b'\'');
12545 }
12546
12547 #[test]
12548 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12549 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12550 // — the canonical paste-from-JSON-config / paste-from-YAML-
12551 // flow-scalar / paste-from-TOML-basic-string / paste-from-
12552 // tatara-lisp-string-literal cross-idiom leak). Pinned
12553 // separately from the single-quote shape so the gate's
12554 // contract is "any `'` or `\"` anywhere", not single-byte
12555 // coverage. Mirrors the peer
12556 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12557 // shape on the immediate-predecessor
12558 // `FonteCaminhoShellBracketExpansion` arm.
12559 let d = dep_with_fonte(DepSource::Path {
12560 caminho: "\"../caixa-teia\"".into(),
12561 });
12562 let err = d.validate().unwrap_err();
12563 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12564 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12565 };
12566 assert_eq!(byte, b'"');
12567 }
12568
12569 #[test]
12570 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12571 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12572 // canonical "I pasted a JSON key-value pair fragment into
12573 // the middle of the path" idiom). Pinned separately from
12574 // the leading-byte shape so the gate covers every position,
12575 // not only leading.
12576 let d = dep_with_fonte(DepSource::Path {
12577 caminho: "../\"caixa-teia\"".into(),
12578 });
12579 let err = d.validate().unwrap_err();
12580 assert!(
12581 matches!(
12582 err,
12583 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12584 ),
12585 "got {err:?}",
12586 );
12587 }
12588
12589 #[test]
12590 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12591 // The canonical YAML double-quoted flow-scalar cross-idiom
12592 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12593 // `path: \"...\"` YAML flow-scalar entry out of an aligned
12594 // values.yaml / K8s manifest and dropped it verbatim into
12595 // the `:caminho` slot including the `path: ` key prefix"
12596 // paste-idiom). The arm fires on the first `"` encountered;
12597 // pinned so the gate's coverage extends from the bare-quote
12598 // paste shape to the aligned-YAML-manifest cross-idiom-leak
12599 // shape.
12600 let d = dep_with_fonte(DepSource::Path {
12601 caminho: "path: \"../caixa-teia\"".into(),
12602 });
12603 let err = d.validate().unwrap_err();
12604 assert!(
12605 matches!(
12606 err,
12607 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12608 ),
12609 "got {err:?}",
12610 );
12611 }
12612
12613 #[test]
12614 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12615 // The positive-control pin: the gate targets only `'` /
12616 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12617 // The canonical relative POSIX path (`"../caixa-teia"`) and
12618 // a nested deeply-pathed variant with adjacent printable
12619 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12620 // to validate cleanly so the gate doesn't widen to a "no
12621 // printable punctuation anywhere" sweep that would defeat
12622 // the entire path-fonte author surface. Peer with
12623 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12624 // on the immediate-predecessor arm.
12625 let d = dep_with_fonte(DepSource::Path {
12626 caminho: "../caixa-teia/sub-dir.v2".into(),
12627 });
12628 d.validate().unwrap();
12629 }
12630
12631 #[test]
12632 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12633 // Cascade pin on the immediate-predecessor arm: a value
12634 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12635 // "I pasted a glob-character-class followed by a strong-
12636 // quoted literal tail" footgun) routes through
12637 // `FonteCaminhoShellBracketExpansion` not
12638 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12639 // expansion is the load-bearing root-cause edit on every
12640 // probe-as-both value; same cascade discipline every prior
12641 // `:caminho` arm establishes.
12642 let d = dep_with_fonte(DepSource::Path {
12643 caminho: "../[a-z]'x'".into(),
12644 });
12645 let err = d.validate().unwrap_err();
12646 assert!(
12647 matches!(
12648 err,
12649 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12650 ),
12651 "got {err:?}",
12652 );
12653 }
12654
12655 #[test]
12656 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12657 // Cascade pin on the upstream shell-brace-expansion arm: a
12658 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12659 // canonical "I pasted a brace-expansion fan followed by a
12660 // strong-quoted literal tail" footgun) routes through
12661 // `FonteCaminhoShellBraceExpansion` not
12662 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12663 // is the load-bearing root-cause edit on every probe-as-
12664 // both value.
12665 let d = dep_with_fonte(DepSource::Path {
12666 caminho: "../{a,b}'x'".into(),
12667 });
12668 let err = d.validate().unwrap_err();
12669 assert!(
12670 matches!(
12671 err,
12672 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12673 ),
12674 "got {err:?}",
12675 );
12676 }
12677
12678 #[test]
12679 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12680 // Cascade pin on the upstream shell-subshell-grouping arm:
12681 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12682 // the canonical "I pasted a subshell-grouping followed by
12683 // a strong-quoted literal tail" footgun) routes through
12684 // `FonteCaminhoShellSubshellGrouping` not
12685 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12686 // `$(<cmd>)` command-substitution boundary is the load-
12687 // bearing axis on every probe-as-both value.
12688 let d = dep_with_fonte(DepSource::Path {
12689 caminho: "../(cd foo)/'x'".into(),
12690 });
12691 let err = d.validate().unwrap_err();
12692 assert!(
12693 matches!(
12694 err,
12695 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12696 ),
12697 "got {err:?}",
12698 );
12699 }
12700
12701 #[test]
12702 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12703 // Cascade pin on the upstream shell-glob arm: a value
12704 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12705 // canonical "I pasted a `*` unbounded pathname-expansion
12706 // followed by a strong-quoted literal tail" footgun) routes
12707 // through `FonteCaminhoShellGlob` not
12708 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12709 // expansion sentinel is the load-bearing root-cause edit
12710 // on every probe-as-both value.
12711 let d = dep_with_fonte(DepSource::Path {
12712 caminho: "../caixa-teia/*'x'".into(),
12713 });
12714 let err = d.validate().unwrap_err();
12715 assert!(
12716 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12717 "got {err:?}",
12718 );
12719 }
12720
12721 #[test]
12722 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12723 // Cascade pin on the upstream shell-command-substitution
12724 // arm: a value carrying both a backtick and `'`
12725 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12726 // legacy-backtick command-substitution followed by a
12727 // strong-quoted literal tail" footgun) routes through
12728 // `FonteCaminhoShellCommandSubstitution` not
12729 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12730 // command-injection vector is the load-bearing root-cause
12731 // edit on every probe-as-both value.
12732 let d = dep_with_fonte(DepSource::Path {
12733 caminho: "../`whoami`/'x'".into(),
12734 });
12735 let err = d.validate().unwrap_err();
12736 assert!(
12737 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12738 "got {err:?}",
12739 );
12740 }
12741
12742 #[test]
12743 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12744 // Cascade pin on the upstream shell-background arm: a value
12745 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12746 // canonical "I pasted a `cmd & 'literal'` background-launch
12747 // + quote chain" footgun) routes through
12748 // `FonteCaminhoShellBackground` not
12749 // `FonteCaminhoShellQuoteGrouping`. The background-launch
12750 // tail is the load-bearing root-cause edit on every
12751 // probe-as-both value.
12752 let d = dep_with_fonte(DepSource::Path {
12753 caminho: "../caixa-teia & 'x'".into(),
12754 });
12755 let err = d.validate().unwrap_err();
12756 assert!(
12757 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12758 "got {err:?}",
12759 );
12760 }
12761
12762 #[test]
12763 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12764 // Cascade pin on the upstream shell-semicolon arm: a value
12765 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12766 // canonical sequential-cleanup + quote paste idiom) routes
12767 // through `FonteCaminhoShellSemicolon` not
12768 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12769 // separator paste is the load-bearing root-cause edit on
12770 // every probe-as-both value.
12771 let d = dep_with_fonte(DepSource::Path {
12772 caminho: "../caixa-teia; 'x'".into(),
12773 });
12774 let err = d.validate().unwrap_err();
12775 assert!(
12776 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12777 "got {err:?}",
12778 );
12779 }
12780
12781 #[test]
12782 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12783 // Cascade pin on the upstream shell-pipe arm: a value
12784 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12785 // canonical pipeline-to-quoted-literal paste idiom) routes
12786 // through `FonteCaminhoShellPipe` not
12787 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12788 // is the load-bearing root-cause edit on every probe-as-
12789 // both value.
12790 let d = dep_with_fonte(DepSource::Path {
12791 caminho: "../caixa-teia | 'x'".into(),
12792 });
12793 let err = d.validate().unwrap_err();
12794 assert!(
12795 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12796 "got {err:?}",
12797 );
12798 }
12799
12800 #[test]
12801 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12802 // Cascade pin on the upstream shell-redirection arm: a
12803 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12804 // — the canonical "I pasted a `cmd > log 'literal'`
12805 // redirect-plus-quote chain" footgun) routes through
12806 // `FonteCaminhoShellRedirection` not
12807 // `FonteCaminhoShellQuoteGrouping`. The input/output
12808 // redirection metachar carries the more self-locating
12809 // `byte` payload, so the prior arm wins on every probe-as-
12810 // both value.
12811 let d = dep_with_fonte(DepSource::Path {
12812 caminho: "../caixa-teia>log 'x'".into(),
12813 });
12814 let err = d.validate().unwrap_err();
12815 assert!(
12816 matches!(
12817 err,
12818 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12819 ),
12820 "got {err:?}",
12821 );
12822 }
12823
12824 #[test]
12825 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12826 // Cascade pin on the upstream backslash arm: a value
12827 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12828 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12829 // chain" footgun) routes through `FonteCaminhoBackslash`
12830 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12831 // separator divergence is the load-bearing axis on every
12832 // probe-as-both value.
12833 let d = dep_with_fonte(DepSource::Path {
12834 caminho: "..\\caixa-teia\\'x'".into(),
12835 });
12836 let err = d.validate().unwrap_err();
12837 assert!(
12838 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12839 "got {err:?}",
12840 );
12841 }
12842
12843 #[test]
12844 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12845 // Cascade pin on the embedded-control-byte arm: a value
12846 // carrying both a control byte and `'` (`"../foo\n'x'"` —
12847 // the canonical paste-from-multiline-doc footgun where a
12848 // newline landed mid-caminho between two paste fragments)
12849 // routes through `FonteCaminhoControlChar` not
12850 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
12851 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12852 // the load-bearing axis on every value that probes
12853 // positive for both — mirrors the cascade discipline on
12854 // every prior arm.
12855 let d = dep_with_fonte(DepSource::Path {
12856 caminho: "../foo\n'x'".into(),
12857 });
12858 let err = d.validate().unwrap_err();
12859 assert!(
12860 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12861 "got {err:?}",
12862 );
12863 }
12864
12865 #[test]
12866 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
12867 // Cascade pin on the load-bearing leading-byte arm: a
12868 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
12869 // through `FonteCaminhoAbsolute` not
12870 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
12871 // diagnostic is the load-bearing axis, the quote byte is
12872 // the secondary observation. Same precedence logic as every
12873 // prior leading-byte arm.
12874 let d = dep_with_fonte(DepSource::Path {
12875 caminho: "/etc/'x'".into(),
12876 });
12877 let err = d.validate().unwrap_err();
12878 assert!(
12879 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12880 "got {err:?}",
12881 );
12882 }
12883
12884 #[test]
12885 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
12886 // Cascade pin on the upstream leading-`$` var-expansion
12887 // arm: a value carrying both a leading `$` and a `'`
12888 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
12889 // variable + quoted literal at the head of a sibling-
12890 // workspace path" footgun) routes through
12891 // `FonteCaminhoVarExpansion` not
12892 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
12893 // shell-variable-expansion is the more self-locating
12894 // diagnostic on values that probe as both — same
12895 // load-bearing-leading-byte cascade discipline every
12896 // prior `:caminho` arm establishes.
12897 let d = dep_with_fonte(DepSource::Path {
12898 caminho: "$DIR/'x'".into(),
12899 });
12900 let err = d.validate().unwrap_err();
12901 assert!(
12902 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12903 "got {err:?}",
12904 );
12905 }
12906
12907 #[test]
12908 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
12909 // Cascade pin on the immediate-successor arm: a value
12910 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
12911 // — the canonical "I tab-completed a path whose strong-
12912 // quoted body already carried the quoting from a shell-
12913 // history paste" footgun) routes through
12914 // `FonteCaminhoShellQuoteGrouping` not
12915 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12916 // is the more semantic-locating axis (an author who removes
12917 // the `'` typically also drops the trailing separator since
12918 // both are paste-from-shell artifacts).
12919 let d = dep_with_fonte(DepSource::Path {
12920 caminho: "../'caixa-teia'/".into(),
12921 });
12922 let err = d.validate().unwrap_err();
12923 assert!(
12924 matches!(
12925 err,
12926 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
12927 ),
12928 "got {err:?}",
12929 );
12930 }
12931
12932 #[test]
12933 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
12934 // Diagnostic-shape pin (peer with
12935 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12936 // on the closest two-byte peer arm): the error's Display
12937 // surfaces the offending `:nome`, the offending `:caminho`
12938 // verbatim, the offending byte's hex / character form, and
12939 // names the shell-quote-grouping / cross-config-DSL-string-
12940 // literal-delimiter footgun explicitly so a `feira lint`
12941 // run can render the diagnostic without re-parsing.
12942 let d = dep_with_fonte(DepSource::Path {
12943 caminho: "'../caixa-teia'".into(),
12944 });
12945 let rendered = d.validate().unwrap_err().to_string();
12946 assert!(
12947 rendered.contains("caixa-teia"),
12948 "diagnostic must name the offending dep: {rendered}",
12949 );
12950 assert!(
12951 rendered.contains("'../caixa-teia'"),
12952 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12953 );
12954 assert!(
12955 rendered.contains("0x27"),
12956 "diagnostic must surface the offending byte hex: {rendered:?}",
12957 );
12958 assert!(
12959 rendered.contains("quote-grouping"),
12960 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
12961 );
12962 assert!(
12963 rendered.contains("string-literal"),
12964 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
12965 vocabulary: {rendered:?}",
12966 );
12967 }
12968
12969 #[test]
12970 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
12971 // The canonical paste-from-shell-history-with-trailing-
12972 // annotation footgun: an author pastes a `cd ../caixa-teia
12973 // # legacy sibling` shell-history one-liner whose unquoted `#`
12974 // comment-lead separates the path from an inline annotation.
12975 // The POSIX shell trims the annotation to `../caixa-teia`
12976 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
12977 // `Path::is_absolute` returns false on `..`, `#` is neither
12978 // a leading-byte sentinel nor a control byte nor `\` nor
12979 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
12980 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
12981 // `"`, and the value's last byte isn't `/` — so the value
12982 // silently passed every prior arm. The resolver folded the
12983 // value through `Path::join` looking for a literal
12984 // `./../caixa-teia # legacy sibling` subdirectory and the
12985 // failure surfaced at resolve time with a non-self-locating
12986 // `No such file or directory` error. The new arm moves the
12987 // rejection to validate time and names the offending dep +
12988 // caminho + byte verbatim.
12989 let d = dep_with_fonte(DepSource::Path {
12990 caminho: "../caixa-teia # legacy sibling".into(),
12991 });
12992 let err = d.validate().unwrap_err();
12993 let DepError::FonteCaminhoShellComment {
12994 nome,
12995 caminho,
12996 byte,
12997 } = err
12998 else {
12999 panic!("expected FonteCaminhoShellComment, got {err:?}");
13000 };
13001 assert_eq!(nome, "caixa-teia");
13002 assert_eq!(caminho, "../caixa-teia # legacy sibling");
13003 assert_eq!(byte, b'#');
13004 }
13005
13006 #[test]
13007 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13008 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13009 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
13010 // canonical "I copied a `path: ../caixa-teia # pin` YAML
13011 // scalar-plus-comment entry out of an aligned values.yaml and
13012 // dropped it verbatim into the `:caminho` slot" paste-idiom).
13013 // Pinned separately from the shell-history shape so the
13014 // gate's coverage extends from the single-space `#` shape to
13015 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
13016 // requires the `#` to be preceded by whitespace to lex as a
13017 // comment (bare `foo#bar` is a single scalar); the double-
13018 // space paste from an aligned manifest is the canonical
13019 // shape.
13020 let d = dep_with_fonte(DepSource::Path {
13021 caminho: "../caixa-teia # pin".into(),
13022 });
13023 let err = d.validate().unwrap_err();
13024 assert!(
13025 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13026 "got {err:?}",
13027 );
13028 }
13029
13030 #[test]
13031 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13032 // The URL-fragment-identifier paste shape
13033 // (`"../caixa-teia#readme"` — the canonical
13034 // paste-from-browser-address-bar permalink shape where the
13035 // browser preserved the `#anchor` tail on the copy). Pinned
13036 // separately from the whitespace-separated shell / YAML
13037 // comment shapes so the gate covers the unpadded RFC 3986
13038 // §3.5 fragment-delimiter position too, not only positions
13039 // preceded by unquoted whitespace. Peer with the immediate-
13040 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13041 // (a68f818) which closes the same byte under the same URL-
13042 // fragment-identifier banner.
13043 let d = dep_with_fonte(DepSource::Path {
13044 caminho: "../caixa-teia#readme".into(),
13045 });
13046 let err = d.validate().unwrap_err();
13047 assert!(
13048 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13049 "got {err:?}",
13050 );
13051 }
13052
13053 #[test]
13054 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13055 // Leading-position `#` shape (`"#../caixa-teia"` — the
13056 // "I copied a shell-comment-out entry from a commented-out
13057 // dep row" footgun). Pinned separately from the embedded
13058 // shapes so the gate covers every position, not only
13059 // whitespace-preceded / mid-value.
13060 let d = dep_with_fonte(DepSource::Path {
13061 caminho: "#../caixa-teia".into(),
13062 });
13063 let err = d.validate().unwrap_err();
13064 assert!(
13065 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13066 "got {err:?}",
13067 );
13068 }
13069
13070 #[test]
13071 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13072 // The positive-control pin: the gate targets only `#`,
13073 // never adjacent printable ASCII or POSIX-valid bytes. The
13074 // canonical relative POSIX path (`"../caixa-teia"`) and a
13075 // nested deeply-pathed variant with adjacent printable
13076 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13077 // to validate cleanly so the gate doesn't widen to a "no
13078 // printable punctuation anywhere" sweep that would defeat
13079 // the entire path-fonte author surface. Peer with
13080 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13081 // on the immediate-predecessor arm.
13082 let d = dep_with_fonte(DepSource::Path {
13083 caminho: "../caixa-teia/sub-dir.v2".into(),
13084 });
13085 d.validate().unwrap();
13086 }
13087
13088 #[test]
13089 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13090 // Cascade pin on the immediate-predecessor arm: a value
13091 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13092 // "I pasted a strong-quoted literal followed by a URL-
13093 // fragment permalink tail" footgun) routes through
13094 // `FonteCaminhoShellQuoteGrouping` not
13095 // `FonteCaminhoShellComment`. The shell-string-literal-
13096 // delimiter is the load-bearing root-cause edit on every
13097 // probe-as-both value; same cascade discipline every prior
13098 // `:caminho` arm establishes.
13099 let d = dep_with_fonte(DepSource::Path {
13100 caminho: "../'x'#pin".into(),
13101 });
13102 let err = d.validate().unwrap_err();
13103 assert!(
13104 matches!(
13105 err,
13106 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13107 ),
13108 "got {err:?}",
13109 );
13110 }
13111
13112 #[test]
13113 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13114 // Cascade pin on the upstream shell-bracket-expansion arm:
13115 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13116 // canonical "I pasted a glob-character-class followed by a
13117 // URL-fragment tail" footgun) routes through
13118 // `FonteCaminhoShellBracketExpansion` not
13119 // `FonteCaminhoShellComment`. The glob-character-class
13120 // expansion is the load-bearing root-cause edit on every
13121 // probe-as-both value.
13122 let d = dep_with_fonte(DepSource::Path {
13123 caminho: "../[a-z]#pin".into(),
13124 });
13125 let err = d.validate().unwrap_err();
13126 assert!(
13127 matches!(
13128 err,
13129 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13130 ),
13131 "got {err:?}",
13132 );
13133 }
13134
13135 #[test]
13136 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13137 // Cascade pin on the upstream shell-brace-expansion arm: a
13138 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13139 // canonical "I pasted a brace-expansion fan followed by a
13140 // URL-fragment tail" footgun) routes through
13141 // `FonteCaminhoShellBraceExpansion` not
13142 // `FonteCaminhoShellComment`. The brace-expansion fan is the
13143 // load-bearing root-cause edit on every probe-as-both value.
13144 let d = dep_with_fonte(DepSource::Path {
13145 caminho: "../{a,b}#pin".into(),
13146 });
13147 let err = d.validate().unwrap_err();
13148 assert!(
13149 matches!(
13150 err,
13151 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13152 ),
13153 "got {err:?}",
13154 );
13155 }
13156
13157 #[test]
13158 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13159 // Cascade pin on the upstream shell-subshell-grouping arm:
13160 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13161 // the canonical "I pasted a subshell-grouping followed by a
13162 // URL-fragment tail" footgun) routes through
13163 // `FonteCaminhoShellSubshellGrouping` not
13164 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13165 // command-substitution boundary is the load-bearing axis on
13166 // every probe-as-both value.
13167 let d = dep_with_fonte(DepSource::Path {
13168 caminho: "../(cd foo)#pin".into(),
13169 });
13170 let err = d.validate().unwrap_err();
13171 assert!(
13172 matches!(
13173 err,
13174 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13175 ),
13176 "got {err:?}",
13177 );
13178 }
13179
13180 #[test]
13181 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13182 // Cascade pin on the upstream shell-glob arm: a value
13183 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13184 // canonical "I pasted a `*` unbounded pathname-expansion
13185 // followed by a URL-fragment tail" footgun) routes through
13186 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13187 // The unbounded pathname-expansion sentinel is the load-
13188 // bearing root-cause edit on every probe-as-both value.
13189 let d = dep_with_fonte(DepSource::Path {
13190 caminho: "../caixa-teia/*#pin".into(),
13191 });
13192 let err = d.validate().unwrap_err();
13193 assert!(
13194 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13195 "got {err:?}",
13196 );
13197 }
13198
13199 #[test]
13200 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13201 // Cascade pin on the upstream shell-command-substitution
13202 // arm: a value carrying both a backtick and `#`
13203 // (``"../`whoami`#pin"`` — the canonical "I pasted a
13204 // legacy-backtick command-substitution followed by a URL-
13205 // fragment tail" footgun) routes through
13206 // `FonteCaminhoShellCommandSubstitution` not
13207 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13208 // injection vector is the load-bearing root-cause edit on
13209 // every probe-as-both value.
13210 let d = dep_with_fonte(DepSource::Path {
13211 caminho: "../`whoami`#pin".into(),
13212 });
13213 let err = d.validate().unwrap_err();
13214 assert!(
13215 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13216 "got {err:?}",
13217 );
13218 }
13219
13220 #[test]
13221 fn fonte_caminho_shell_background_fires_before_shell_comment() {
13222 // Cascade pin on the upstream shell-background arm: a value
13223 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13224 // the canonical "I pasted a `cmd &` background-launch
13225 // followed by a URL-fragment tail" footgun) routes through
13226 // `FonteCaminhoShellBackground` not
13227 // `FonteCaminhoShellComment`. The background-launch tail is
13228 // the load-bearing root-cause edit on every probe-as-both
13229 // value.
13230 let d = dep_with_fonte(DepSource::Path {
13231 caminho: "../caixa-teia&pin#tail".into(),
13232 });
13233 let err = d.validate().unwrap_err();
13234 assert!(
13235 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13236 "got {err:?}",
13237 );
13238 }
13239
13240 #[test]
13241 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13242 // Cascade pin on the upstream shell-semicolon arm: a value
13243 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13244 // the canonical sequential-cleanup + URL-fragment paste
13245 // idiom) routes through `FonteCaminhoShellSemicolon` not
13246 // `FonteCaminhoShellComment`. The sequential-command-
13247 // separator paste is the load-bearing root-cause edit on
13248 // every probe-as-both value.
13249 let d = dep_with_fonte(DepSource::Path {
13250 caminho: "../caixa-teia;pin#tail".into(),
13251 });
13252 let err = d.validate().unwrap_err();
13253 assert!(
13254 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13255 "got {err:?}",
13256 );
13257 }
13258
13259 #[test]
13260 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13261 // Cascade pin on the upstream shell-pipe arm: a value
13262 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13263 // the canonical pipeline-to-URL-fragment paste idiom) routes
13264 // through `FonteCaminhoShellPipe` not
13265 // `FonteCaminhoShellComment`. The pipeline-tail paste is
13266 // the load-bearing root-cause edit on every probe-as-both
13267 // value.
13268 let d = dep_with_fonte(DepSource::Path {
13269 caminho: "../caixa-teia|pin#tail".into(),
13270 });
13271 let err = d.validate().unwrap_err();
13272 assert!(
13273 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13274 "got {err:?}",
13275 );
13276 }
13277
13278 #[test]
13279 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13280 // Cascade pin on the upstream shell-redirection arm: a
13281 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13282 // — the canonical "I pasted a `cmd > log` redirect followed
13283 // by a URL-fragment tail" footgun) routes through
13284 // `FonteCaminhoShellRedirection` not
13285 // `FonteCaminhoShellComment`. The input/output redirection
13286 // metachar carries the more self-locating `byte` payload,
13287 // so the prior arm wins on every probe-as-both value.
13288 let d = dep_with_fonte(DepSource::Path {
13289 caminho: "../caixa-teia>log#pin".into(),
13290 });
13291 let err = d.validate().unwrap_err();
13292 assert!(
13293 matches!(
13294 err,
13295 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13296 ),
13297 "got {err:?}",
13298 );
13299 }
13300
13301 #[test]
13302 fn fonte_caminho_backslash_fires_before_shell_comment() {
13303 // Cascade pin on the upstream backslash arm: a value
13304 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13305 // canonical "I pasted a Windows-shell path followed by a
13306 // URL-fragment tail" footgun) routes through
13307 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13308 // The cross-host-OS-separator divergence is the load-
13309 // bearing axis on every probe-as-both value.
13310 let d = dep_with_fonte(DepSource::Path {
13311 caminho: "..\\caixa-teia#pin".into(),
13312 });
13313 let err = d.validate().unwrap_err();
13314 assert!(
13315 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13316 "got {err:?}",
13317 );
13318 }
13319
13320 #[test]
13321 fn fonte_caminho_control_char_fires_before_shell_comment() {
13322 // Cascade pin on the embedded-control-byte arm: a value
13323 // carrying both a control byte and `#` (`"../foo\n#pin"` —
13324 // the canonical paste-from-multiline-doc footgun where a
13325 // newline landed mid-caminho between the path and an
13326 // annotation) routes through `FonteCaminhoControlChar` not
13327 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13328 // byte diagnostic is the load-bearing axis on every value
13329 // that probes positive for both — mirrors the cascade
13330 // discipline on every prior arm.
13331 let d = dep_with_fonte(DepSource::Path {
13332 caminho: "../foo\n#pin".into(),
13333 });
13334 let err = d.validate().unwrap_err();
13335 assert!(
13336 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13337 "got {err:?}",
13338 );
13339 }
13340
13341 #[test]
13342 fn fonte_caminho_absolute_fires_before_shell_comment() {
13343 // Cascade pin on the load-bearing leading-byte arm: a
13344 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13345 // routes through `FonteCaminhoAbsolute` not
13346 // `FonteCaminhoShellComment` — the host-layout-leak
13347 // diagnostic is the load-bearing axis, the fragment byte is
13348 // the secondary observation. Same precedence logic as every
13349 // prior leading-byte arm.
13350 let d = dep_with_fonte(DepSource::Path {
13351 caminho: "/etc/foo#pin".into(),
13352 });
13353 let err = d.validate().unwrap_err();
13354 assert!(
13355 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13356 "got {err:?}",
13357 );
13358 }
13359
13360 #[test]
13361 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13362 // Cascade pin on the upstream leading-`$` var-expansion
13363 // arm: a value carrying both a leading `$` and a `#`
13364 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13365 // shell-variable at the head of a sibling-workspace path
13366 // followed by a URL-fragment tail" footgun) routes through
13367 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13368 // The leading-byte shell-variable-expansion is the more
13369 // self-locating diagnostic on values that probe as both.
13370 let d = dep_with_fonte(DepSource::Path {
13371 caminho: "$DIR/foo#pin".into(),
13372 });
13373 let err = d.validate().unwrap_err();
13374 assert!(
13375 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13376 "got {err:?}",
13377 );
13378 }
13379
13380 #[test]
13381 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13382 // Cascade pin on the immediate-successor arm: a value
13383 // carrying both `#` and a trailing `/`
13384 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13385 // a URL-fragment-carrying path" footgun) routes through
13386 // `FonteCaminhoShellComment` not
13387 // `FonteCaminhoTrailingSlash`. The embedded fragment /
13388 // comment-lead byte is the more semantic-locating axis (an
13389 // author who removes the `#pin` fragment typically also
13390 // drops the trailing separator since both are paste-from-
13391 // URL / paste-from-shell-tab-completion artifacts).
13392 let d = dep_with_fonte(DepSource::Path {
13393 caminho: "../caixa-teia#pin/".into(),
13394 });
13395 let err = d.validate().unwrap_err();
13396 assert!(
13397 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13398 "got {err:?}",
13399 );
13400 }
13401
13402 #[test]
13403 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13404 // Diagnostic-shape pin (peer with
13405 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13406 // on the immediate-predecessor arm): the error's Display
13407 // surfaces the offending `:nome`, the offending `:caminho`
13408 // verbatim, the offending byte's hex / character form, and
13409 // names the shell-comment / URL-fragment-identifier /
13410 // YAML-comment cross-config-DSL footgun explicitly so a
13411 // `feira lint` run can render the diagnostic without
13412 // re-parsing.
13413 let d = dep_with_fonte(DepSource::Path {
13414 caminho: "../caixa-teia#readme".into(),
13415 });
13416 let rendered = d.validate().unwrap_err().to_string();
13417 assert!(
13418 rendered.contains("caixa-teia"),
13419 "diagnostic must name the offending dep: {rendered}",
13420 );
13421 assert!(
13422 rendered.contains("../caixa-teia#readme"),
13423 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13424 );
13425 assert!(
13426 rendered.contains("0x23"),
13427 "diagnostic must surface the offending byte hex: {rendered:?}",
13428 );
13429 assert!(
13430 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13431 "diagnostic must name the shell-comment footgun: {rendered:?}",
13432 );
13433 assert!(
13434 rendered.contains("fragment") || rendered.contains("URL-fragment"),
13435 "diagnostic must reference the URL-fragment-identifier vocabulary: \
13436 {rendered:?}",
13437 );
13438 }
13439
13440 #[test]
13441 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13442 // The canonical paste-from-browser-address-bar percent-
13443 // encoded-space footgun: an author copies `../caixa%20teia`
13444 // out of a URL-encoded README hyperlink / browser address
13445 // bar / percent-encoded permalink expecting `%20` to decode
13446 // to a literal space at the filesystem layer. POSIX
13447 // `std::path::Path` treats `%` as a literal path-component
13448 // byte, so `Path::join` looks for a literal
13449 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13450 // returns false on `..`, `%` is neither a leading-byte
13451 // sentinel nor a control byte nor `\` nor `<` / `>` nor
13452 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13453 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13454 // and the value's last byte isn't `/` — so the value
13455 // silently passed every prior arm. The new arm moves the
13456 // rejection to validate time and names the offending dep +
13457 // caminho + byte verbatim.
13458 let d = dep_with_fonte(DepSource::Path {
13459 caminho: "../caixa%20teia".into(),
13460 });
13461 let err = d.validate().unwrap_err();
13462 let DepError::FonteCaminhoUrlPercentEncoding {
13463 nome,
13464 caminho,
13465 byte,
13466 } = err
13467 else {
13468 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13469 };
13470 assert_eq!(nome, "caixa-teia");
13471 assert_eq!(caminho, "../caixa%20teia");
13472 assert_eq!(byte, b'%');
13473 }
13474
13475 #[test]
13476 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13477 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13478 // intending the `%2F` as the URL encoding of `/`) locks a
13479 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13480 // the byte-identical `path:../caixa/teia` form. Pinned
13481 // separately from the space-encoded shape so the gate's
13482 // coverage extends past the single canonical `%20` example
13483 // to any two-hex-digit percent-encoded sequence.
13484 let d = dep_with_fonte(DepSource::Path {
13485 caminho: "../caixa%2Fteia".into(),
13486 });
13487 let err = d.validate().unwrap_err();
13488 assert!(
13489 matches!(
13490 err,
13491 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13492 ),
13493 "got {err:?}",
13494 );
13495 }
13496
13497 #[test]
13498 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13499 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13500 // where `%` isn't followed by two hex digits) — every
13501 // WHATWG-conformant URL parser rejects the value at parse
13502 // time per RFC 3986 §2.1, but the byte would silently ride
13503 // into the lacre before the resolver subprocess crosses the
13504 // URL-parser boundary. Pinned separately from the well-
13505 // formed `%HH` shapes so the gate covers every percent-
13506 // occurrence, not only strictly-conformant escapes.
13507 let d = dep_with_fonte(DepSource::Path {
13508 caminho: "../caixa-teia%foo".into(),
13509 });
13510 let err = d.validate().unwrap_err();
13511 assert!(
13512 matches!(
13513 err,
13514 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13515 ),
13516 "got {err:?}",
13517 );
13518 }
13519
13520 #[test]
13521 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13522 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13523 // — the canonical paste-from-top-of-doc YAML directive
13524 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13525 // separately from embedded shapes so the gate covers the
13526 // leading-position `%` too, not only mid-value occurrences.
13527 let d = dep_with_fonte(DepSource::Path {
13528 caminho: "%YAML/../caixa-teia".into(),
13529 });
13530 let err = d.validate().unwrap_err();
13531 assert!(
13532 matches!(
13533 err,
13534 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13535 ),
13536 "got {err:?}",
13537 );
13538 }
13539
13540 #[test]
13541 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13542 // The printf-format-specifier paste shape
13543 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13544 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13545 // 134 format-string-injection vector). Pinned separately
13546 // from the URL-encoding shapes so the gate's rationale
13547 // extends past the RFC 3986 axis to the C / POSIX printf
13548 // format-directive-lead axis.
13549 let d = dep_with_fonte(DepSource::Path {
13550 caminho: "../caixa-%s-teia".into(),
13551 });
13552 let err = d.validate().unwrap_err();
13553 assert!(
13554 matches!(
13555 err,
13556 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13557 ),
13558 "got {err:?}",
13559 );
13560 }
13561
13562 #[test]
13563 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13564 // The positive-control pin: the gate targets only `%`,
13565 // never adjacent printable ASCII or POSIX-valid bytes. The
13566 // canonical relative POSIX path (`"../caixa-teia"`) and a
13567 // nested deeply-pathed variant with adjacent printable
13568 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13569 // to validate cleanly so the gate doesn't widen to a "no
13570 // printable punctuation anywhere" sweep that would defeat
13571 // the entire path-fonte author surface. Peer with
13572 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13573 // on the immediate-predecessor arm.
13574 let d = dep_with_fonte(DepSource::Path {
13575 caminho: "../caixa-teia/sub-dir.v2".into(),
13576 });
13577 d.validate().unwrap();
13578 }
13579
13580 #[test]
13581 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13582 // Cascade pin on the immediate-predecessor arm: a value
13583 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13584 // canonical "I pasted a URL-fragment permalink followed by a
13585 // percent-encoded space tail" footgun) routes through
13586 // `FonteCaminhoShellComment` not
13587 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13588 // identifier is the load-bearing downstream-truncation edit
13589 // on every probe-as-both value; same cascade discipline
13590 // every prior `:caminho` arm establishes.
13591 let d = dep_with_fonte(DepSource::Path {
13592 caminho: "../caixa-teia#pin%20".into(),
13593 });
13594 let err = d.validate().unwrap_err();
13595 assert!(
13596 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13597 "got {err:?}",
13598 );
13599 }
13600
13601 #[test]
13602 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13603 // Cascade pin on the upstream shell-quote-grouping arm: a
13604 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13605 // canonical "I pasted a strong-quoted literal followed by
13606 // a percent-encoded space" footgun) routes through
13607 // `FonteCaminhoShellQuoteGrouping` not
13608 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13609 // literal-delimiter is the load-bearing root-cause edit on
13610 // every probe-as-both value.
13611 let d = dep_with_fonte(DepSource::Path {
13612 caminho: "../'x'%20teia".into(),
13613 });
13614 let err = d.validate().unwrap_err();
13615 assert!(
13616 matches!(
13617 err,
13618 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13619 ),
13620 "got {err:?}",
13621 );
13622 }
13623
13624 #[test]
13625 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13626 // Cascade pin on the upstream backslash arm: a value
13627 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13628 // canonical "I pasted a Windows-shell path followed by a
13629 // percent-encoded space" footgun) routes through
13630 // `FonteCaminhoBackslash` not
13631 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13632 // separator divergence is the load-bearing root-cause edit
13633 // on every probe-as-both value.
13634 let d = dep_with_fonte(DepSource::Path {
13635 caminho: "..\\caixa%20teia".into(),
13636 });
13637 let err = d.validate().unwrap_err();
13638 assert!(
13639 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13640 "got {err:?}",
13641 );
13642 }
13643
13644 #[test]
13645 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13646 // Cascade pin on the upstream control-char arm: a value
13647 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13648 // the canonical "I pasted a paste-from-binary-blob path
13649 // followed by a percent-encoded space" footgun) routes
13650 // through `FonteCaminhoControlChar` not
13651 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13652 // rejected byte is the load-bearing root-cause edit on
13653 // every probe-as-both value.
13654 let d = dep_with_fonte(DepSource::Path {
13655 caminho: "../caixa\0%20teia".into(),
13656 });
13657 let err = d.validate().unwrap_err();
13658 assert!(
13659 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13660 "got {err:?}",
13661 );
13662 }
13663
13664 #[test]
13665 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13666 // Cascade pin on the upstream absolute-path arm: a value
13667 // that's both absolute and carries `%` (`"/etc/passwd%20"`
13668 // — the canonical "I pasted an absolute path with a
13669 // percent-encoded space tail" footgun) routes through
13670 // `FonteCaminhoAbsolute` not
13671 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13672 // the load-bearing root-cause edit on every probe-as-both
13673 // value.
13674 let d = dep_with_fonte(DepSource::Path {
13675 caminho: "/etc/passwd%20".into(),
13676 });
13677 let err = d.validate().unwrap_err();
13678 assert!(
13679 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13680 "got {err:?}",
13681 );
13682 }
13683
13684 #[test]
13685 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13686 // Cascade pin on the upstream var-expansion arm: a value
13687 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13688 // — the canonical "I pasted a `$HOME`-rooted path with a
13689 // percent-encoded space" footgun) routes through
13690 // `FonteCaminhoVarExpansion` not
13691 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13692 // expansion is the load-bearing root-cause edit on every
13693 // probe-as-both value.
13694 let d = dep_with_fonte(DepSource::Path {
13695 caminho: "$HOME/caixa%20teia".into(),
13696 });
13697 let err = d.validate().unwrap_err();
13698 assert!(
13699 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13700 "got {err:?}",
13701 );
13702 }
13703
13704 #[test]
13705 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13706 // Cascade pin on the immediate-successor arm: a value
13707 // carrying both `%` and a trailing `/`
13708 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13709 // percent-encoded-space-carrying path" footgun) routes
13710 // through `FonteCaminhoUrlPercentEncoding` not
13711 // `FonteCaminhoTrailingSlash`. The embedded percent-
13712 // encoding-escape byte is the more semantic-locating axis
13713 // (an author who decodes the `%20` to a literal space is
13714 // likely to also tab-strip the trailing separator since
13715 // both are paste-from-URL / paste-from-shell-tab-completion
13716 // artifacts).
13717 let d = dep_with_fonte(DepSource::Path {
13718 caminho: "../caixa%20teia/".into(),
13719 });
13720 let err = d.validate().unwrap_err();
13721 assert!(
13722 matches!(
13723 err,
13724 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13725 ),
13726 "got {err:?}",
13727 );
13728 }
13729
13730 #[test]
13731 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13732 // Diagnostic-shape pin (peer with
13733 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13734 // on the immediate-predecessor arm): the error's Display
13735 // surfaces the offending `:nome`, the offending `:caminho`
13736 // verbatim, the offending byte's hex / character form, and
13737 // names the URL-percent-encoding-escape / printf-format-
13738 // specifier footgun explicitly so a `feira lint` run can
13739 // render the diagnostic without re-parsing.
13740 let d = dep_with_fonte(DepSource::Path {
13741 caminho: "../caixa%20teia".into(),
13742 });
13743 let rendered = d.validate().unwrap_err().to_string();
13744 assert!(
13745 rendered.contains("caixa-teia"),
13746 "diagnostic must name the offending dep: {rendered}",
13747 );
13748 assert!(
13749 rendered.contains("../caixa%20teia"),
13750 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13751 );
13752 assert!(
13753 rendered.contains("0x25"),
13754 "diagnostic must surface the offending byte hex: {rendered:?}",
13755 );
13756 assert!(
13757 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13758 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13759 );
13760 assert!(
13761 rendered.contains("printf") || rendered.contains("format-specifier"),
13762 "diagnostic must reference the printf-format-specifier vocabulary: \
13763 {rendered:?}",
13764 );
13765 }
13766
13767 #[test]
13768 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13769 // The canonical embedded-`$` shell-variable-expansion paste
13770 // shape (`"../foo$HOME/bar"` — an author copies a partially-
13771 // substituted shell one-liner where the leading segment is a
13772 // literal `../foo` while the mid segment carries the un-
13773 // substituted `$HOME` template). The leading-`$` position is
13774 // already gated by the f4efe9c leading-byte arm which routes
13775 // through `FonteCaminhoVarExpansion`; this arm closes the
13776 // last positional gap on `$` — every position on the axis is
13777 // structurally rejected.
13778 let d = dep_with_fonte(DepSource::Path {
13779 caminho: "../foo$HOME/bar".into(),
13780 });
13781 let err = d.validate().unwrap_err();
13782 let DepError::FonteCaminhoShellVariableExpansion {
13783 nome,
13784 caminho,
13785 byte,
13786 } = err
13787 else {
13788 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13789 };
13790 assert_eq!(nome, "caixa-teia");
13791 assert_eq!(caminho, "../foo$HOME/bar");
13792 assert_eq!(byte, b'$');
13793 }
13794
13795 #[test]
13796 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13797 // The symmetric braced-CI-manifest paste shape
13798 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13799 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13800 // footgun). Pinned separately from the bare-`$VAR` shape so
13801 // the gate covers both POSIX shell §2.6 Parameter Expansion
13802 // syntactic forms, not only the unbraced variant. The
13803 // embedded `{` byte in `${...}` is also caught by the 598b770
13804 // shell-brace-expansion arm but that arm fires earlier in
13805 // the cascade — the `$` arm's coverage extends to `${...}`
13806 // structurally, so the diagnostic asserted here is the
13807 // brace-expansion one (which is a valid outcome; the point
13808 // of the pin is that the value never survives validation).
13809 let d = dep_with_fonte(DepSource::Path {
13810 caminho: "../foo${WORKSPACE}/bar".into(),
13811 });
13812 let err = d.validate().unwrap_err();
13813 assert!(
13814 matches!(
13815 err,
13816 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13817 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13818 ),
13819 "got {err:?}",
13820 );
13821 }
13822
13823 #[test]
13824 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13825 // The paste-from-shell-prompt command-substitution idiom
13826 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13827 // `$VAR` shape so the gate's rationale extends to POSIX shell
13828 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13829 // legacy `` `<cmd>` `` form is already closed by the c370458
13830 // backtick arm). The embedded `(` byte in `$(...)` is also
13831 // caught structurally by the 0633c91 shell-subshell-grouping
13832 // arm which fires earlier in the cascade — the diagnostic
13833 // asserted here is either outcome, since both structurally
13834 // reject the value; the point of the pin is that the value
13835 // never survives validation.
13836 let d = dep_with_fonte(DepSource::Path {
13837 caminho: "../foo$(whoami)/bar".into(),
13838 });
13839 let err = d.validate().unwrap_err();
13840 assert!(
13841 matches!(
13842 err,
13843 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13844 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13845 ),
13846 "got {err:?}",
13847 );
13848 }
13849
13850 #[test]
13851 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
13852 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
13853 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
13854 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
13855 // idiom copied into a caminho template). None of the prior
13856 // shell-metachar arms cover this shape (`1` is a bare digit;
13857 // no `(` / `{` / letter follows the `$`), so the arm is the
13858 // sole gate on the shape.
13859 let d = dep_with_fonte(DepSource::Path {
13860 caminho: "../foo$1/bar".into(),
13861 });
13862 let err = d.validate().unwrap_err();
13863 assert!(
13864 matches!(
13865 err,
13866 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13867 ),
13868 "got {err:?}",
13869 );
13870 }
13871
13872 #[test]
13873 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
13874 // The positive-control pin (peer with
13875 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
13876 // on the immediate-predecessor arm): the gate targets only
13877 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
13878 // A relative POSIX path carrying dashes / dots / slashes /
13879 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
13880 // validate cleanly so the gate doesn't widen to a "no
13881 // printable punctuation anywhere" sweep that would defeat
13882 // the entire path-fonte author surface.
13883 let d = dep_with_fonte(DepSource::Path {
13884 caminho: "../caixa-teia/sub-dir.v2".into(),
13885 });
13886 d.validate().unwrap();
13887 }
13888
13889 #[test]
13890 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
13891 // Cascade pin on the leading-`$` sibling arm at line 540: a
13892 // value starting with `$` and carrying an embedded `$` too
13893 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
13894 // fully-templated CI path with two un-substituted variables")
13895 // routes through `FonteCaminhoVarExpansion` not
13896 // `FonteCaminhoShellVariableExpansion`. The leading-byte
13897 // host-layout-leak is the load-bearing self-locating axis
13898 // (the leading position dominates the semantic-locating
13899 // rationale on every probe-as-both value); the embedded
13900 // arm's positional-agnostic sweep catches only values whose
13901 // leading byte doesn't route through the earlier leading-
13902 // byte arms.
13903 let d = dep_with_fonte(DepSource::Path {
13904 caminho: "$HOME/foo$WORKSPACE/bar".into(),
13905 });
13906 let err = d.validate().unwrap_err();
13907 assert!(
13908 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13909 "got {err:?}",
13910 );
13911 }
13912
13913 #[test]
13914 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
13915 // Cascade pin on the immediate-predecessor arm: a value
13916 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
13917 // — the canonical "I pasted a percent-encoded space adjacent
13918 // to a `$HOME` template") routes through
13919 // `FonteCaminhoUrlPercentEncoding` not
13920 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
13921 // encoding-escape byte is the more semantic-locating axis
13922 // (the paste-from-browser-address-bar shape is the load-
13923 // bearing self-locating edit); same cascade discipline every
13924 // prior `:caminho` arm establishes.
13925 let d = dep_with_fonte(DepSource::Path {
13926 caminho: "../foo%20$HOME/bar".into(),
13927 });
13928 let err = d.validate().unwrap_err();
13929 assert!(
13930 matches!(
13931 err,
13932 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13933 ),
13934 "got {err:?}",
13935 );
13936 }
13937
13938 #[test]
13939 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
13940 // Cascade pin on the immediate-successor arm: a value
13941 // carrying both embedded `$` and a trailing `/`
13942 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
13943 // `$HOME`-template-carrying path") routes through
13944 // `FonteCaminhoShellVariableExpansion` not
13945 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
13946 // expansion byte is the more semantic-locating axis on
13947 // probe-as-both values (an author who substitutes the
13948 // `$HOME` template with a literal value is likely to also
13949 // tab-strip the trailing separator).
13950 let d = dep_with_fonte(DepSource::Path {
13951 caminho: "../foo$HOME/bar/".into(),
13952 });
13953 let err = d.validate().unwrap_err();
13954 assert!(
13955 matches!(
13956 err,
13957 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13958 ),
13959 "got {err:?}",
13960 );
13961 }
13962
13963 #[test]
13964 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
13965 // Diagnostic-shape pin (peer with
13966 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
13967 // on the immediate-predecessor arm): the error's Display
13968 // surfaces the offending `:nome`, the offending `:caminho`
13969 // verbatim, the offending byte's hex / character form, and
13970 // names the shell-variable-expansion / command-substitution
13971 // footgun explicitly so a `feira lint` run can render the
13972 // diagnostic without re-parsing.
13973 let d = dep_with_fonte(DepSource::Path {
13974 caminho: "../foo$HOME/bar".into(),
13975 });
13976 let rendered = d.validate().unwrap_err().to_string();
13977 assert!(
13978 rendered.contains("caixa-teia"),
13979 "diagnostic must name the offending dep: {rendered}",
13980 );
13981 assert!(
13982 rendered.contains("../foo$HOME/bar"),
13983 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13984 );
13985 assert!(
13986 rendered.contains("0x24"),
13987 "diagnostic must surface the offending byte hex: {rendered:?}",
13988 );
13989 assert!(
13990 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
13991 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
13992 );
13993 assert!(
13994 rendered.contains("command-substitution") || rendered.contains("command substitution"),
13995 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
13996 );
13997 }
13998
13999 #[test]
14000 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14001 // The fail-before-pass-after pin for the canonical paste-from-
14002 // shell-history footgun on `:caminho`. An author copies a `cd
14003 // ../caixa-teia && !sudo make install` one-liner from a quick-
14004 // start README, intending the trailing `!sudo` as a shell-
14005 // history-expansion reference but the typed slot is itself a
14006 // byte-level string parser, not a shell context, so the byte
14007 // rides into the value verbatim. Until this arm landed the `!`
14008 // byte silently passed every prior `:caminho` cascade arm
14009 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14010 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14011 // `#` / `%` / `$`); bash with the default `histexpand` mode
14012 // rewrites `!command` to the most recent history entry
14013 // beginning with `command`, the canonical RCE-class injection
14014 // vector when the byte rides into a shell argument executed
14015 // under `bash -i` (the operator-notebook interactive shell).
14016 let d = dep_with_fonte(DepSource::Path {
14017 caminho: "../caixa-teia!sudo".into(),
14018 });
14019 let err = d.validate().unwrap_err();
14020 let DepError::FonteCaminhoShellHistoryExpansion {
14021 nome,
14022 caminho,
14023 byte,
14024 } = err
14025 else {
14026 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14027 };
14028 assert_eq!(nome, "caixa-teia");
14029 assert_eq!(caminho, "../caixa-teia!sudo");
14030 assert_eq!(byte, b'!');
14031 }
14032
14033 #[test]
14034 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14035 // The symmetric `!!` repeat-prior-command paste idiom (peer with
14036 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14037 // on `is_git_repo_url`). Pinned separately from the wrapped
14038 // `!command` shape so a future diagnostic-surface change that
14039 // only checked the leading or paired-bang position surfaces
14040 // here — the per-byte arm fires anywhere `!` appears in the
14041 // value, including at consecutive positions in the middle.
14042 let d = dep_with_fonte(DepSource::Path {
14043 caminho: "../foo!!/bar".into(),
14044 });
14045 let err = d.validate().unwrap_err();
14046 assert!(
14047 matches!(
14048 err,
14049 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14050 ),
14051 "got {err:?}",
14052 );
14053 }
14054
14055 #[test]
14056 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14057 // The English-typography enthusiasm-form paste-from-prose
14058 // idiom: an author writes `:caminho "../caixa-teia!"`
14059 // expecting the substrate to coerce it to a kebab-case slug.
14060 // Pinned separately from the `!<word>` shell-history shape so
14061 // the gate's rationale extends to the paste-from-prose surface
14062 // (the same rationale the peer `is_git_repo_url` bang arm at
14063 // 7d53c68 covers). None of the prior shell-metachar arms cover
14064 // this shape (no `!<word>` reference and no `!!` repeat), so
14065 // the arm is the sole gate on the shape.
14066 let d = dep_with_fonte(DepSource::Path {
14067 caminho: "../caixa-teia!".into(),
14068 });
14069 let err = d.validate().unwrap_err();
14070 assert!(
14071 matches!(
14072 err,
14073 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14074 ),
14075 "got {err:?}",
14076 );
14077 }
14078
14079 #[test]
14080 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14081 // The positive-control pin (peer with
14082 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14083 // on the immediate-predecessor arm): the gate targets only
14084 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14085 // A relative POSIX path carrying dashes / dots / slashes /
14086 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14087 // validate cleanly so the gate doesn't widen to a "no
14088 // printable punctuation anywhere" sweep that would defeat
14089 // the entire path-fonte author surface.
14090 let d = dep_with_fonte(DepSource::Path {
14091 caminho: "../caixa-teia/sub-dir.v2".into(),
14092 });
14093 d.validate().unwrap();
14094 }
14095
14096 #[test]
14097 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14098 // Cascade pin on the immediate-predecessor arm: a value
14099 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14100 // — the canonical "I pasted a `$HOME`-templated path adjacent
14101 // to a trailing `!sudo` history-expansion") routes through
14102 // `FonteCaminhoShellVariableExpansion` not
14103 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14104 // expansion byte is the more semantic-locating axis on
14105 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14106 // template shape is the load-bearing self-locating edit);
14107 // same cascade discipline every prior `:caminho` arm
14108 // establishes.
14109 let d = dep_with_fonte(DepSource::Path {
14110 caminho: "../foo$HOME/bar!sudo".into(),
14111 });
14112 let err = d.validate().unwrap_err();
14113 assert!(
14114 matches!(
14115 err,
14116 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14117 ),
14118 "got {err:?}",
14119 );
14120 }
14121
14122 #[test]
14123 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14124 // Cascade pin on the immediate-successor arm: a value carrying
14125 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14126 // — the canonical "I tab-completed a `!sudo`-carrying path")
14127 // routes through `FonteCaminhoShellHistoryExpansion` not
14128 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14129 // expansion byte is the more semantic-locating axis on probe-
14130 // as-both values (an author who removes the `!sudo` history
14131 // reference is likely to also tab-strip the trailing separator).
14132 let d = dep_with_fonte(DepSource::Path {
14133 caminho: "../caixa-teia!sudo/".into(),
14134 });
14135 let err = d.validate().unwrap_err();
14136 assert!(
14137 matches!(
14138 err,
14139 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14140 ),
14141 "got {err:?}",
14142 );
14143 }
14144
14145 #[test]
14146 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14147 // Diagnostic-shape pin (peer with
14148 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14149 // on the immediate-predecessor arm): the error's Display
14150 // surfaces the offending `:nome`, the offending `:caminho`
14151 // verbatim, the offending byte's hex / character form, and
14152 // names the shell-history-expansion / bang-operator footgun
14153 // explicitly so a `feira lint` run can render the diagnostic
14154 // without re-parsing.
14155 let d = dep_with_fonte(DepSource::Path {
14156 caminho: "../caixa-teia!sudo".into(),
14157 });
14158 let rendered = d.validate().unwrap_err().to_string();
14159 assert!(
14160 rendered.contains("caixa-teia"),
14161 "diagnostic must name the offending dep: {rendered}",
14162 );
14163 assert!(
14164 rendered.contains("../caixa-teia!sudo"),
14165 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14166 );
14167 assert!(
14168 rendered.contains("0x21"),
14169 "diagnostic must surface the offending byte hex: {rendered:?}",
14170 );
14171 assert!(
14172 rendered.contains("history-expansion") || rendered.contains("history expansion"),
14173 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14174 );
14175 assert!(
14176 rendered.contains("bang"),
14177 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14178 );
14179 }
14180
14181 #[test]
14182 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14183 // The fail-before-pass-after pin for the canonical paste-from-
14184 // shell-history-quick-substitution footgun on `:caminho`. An
14185 // author copies a `git clone <bad-url>` line from their terminal,
14186 // corrects it via bash's `^bad^good` quick-substitution history
14187 // operator (bash reference §9.3, `set -o histexpand` mode's
14188 // default for interactive sessions), and pastes the trailing
14189 // `^bad^good` substitution fragment into a `:caminho` value
14190 // without trimming the leading `git clone` prefix — the byte
14191 // rides into the manifest verbatim. Until this arm landed the
14192 // `^` byte silently passed every prior `:caminho` cascade arm
14193 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14194 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14195 // `%` / `$` / `!`); bash with the default `histexpand` mode
14196 // rewrites the prior command's `bad` string to `good` and re-
14197 // executes it, the paired-operator half of the `set -o
14198 // histexpand` feature the peer `!` arm already closes the prefix
14199 // half of. The peer `is_git_repo_url` axis rejects the byte at
14200 // 49e142f under the same shell-history-substitution / RFC-3986-
14201 // unwise banner.
14202 let d = dep_with_fonte(DepSource::Path {
14203 caminho: "../foo^bad^good".into(),
14204 });
14205 let err = d.validate().unwrap_err();
14206 let DepError::FonteCaminhoShellHistorySubstitution {
14207 nome,
14208 caminho,
14209 byte,
14210 } = err
14211 else {
14212 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14213 };
14214 assert_eq!(nome, "caixa-teia");
14215 assert_eq!(caminho, "../foo^bad^good");
14216 assert_eq!(byte, b'^');
14217 }
14218
14219 #[test]
14220 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14221 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14222 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14223 // on `is_git_repo_url`). An author copies a `grep '^archived'`
14224 // regex-anchor / negation idiom from a doc snippet and the byte
14225 // rides in verbatim. Pinned separately from the `^old^new^`
14226 // quick-substitution shape so a future diagnostic-surface change
14227 // that only checked the paired-caret history-substitution
14228 // position surfaces here — the per-byte arm fires anywhere `^`
14229 // appears in the value, including at a solitary leading-of-
14230 // segment position.
14231 let d = dep_with_fonte(DepSource::Path {
14232 caminho: "../foo/^archived".into(),
14233 });
14234 let err = d.validate().unwrap_err();
14235 assert!(
14236 matches!(
14237 err,
14238 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14239 ),
14240 "got {err:?}",
14241 );
14242 }
14243
14244 #[test]
14245 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14246 // The trailing-`^` history-substitution-open shape — an author
14247 // starts typing a `^bad^good` quick-substitution but pastes only
14248 // the leading `^` sentinel before context-switching (a bash-
14249 // reference §9.3 valid histexpand prefix on its own — even a
14250 // solitary `^` on the prior command's whole re-execution shape).
14251 // Pinned separately from the `^old^new^` full-form and the leading-
14252 // of-segment `^archived` regex-anchor shape so the gate's
14253 // rationale extends to the paste-from-shell-history-with-only-
14254 // the-first-byte-selected surface. None of the prior shell-
14255 // metachar arms cover this shape.
14256 let d = dep_with_fonte(DepSource::Path {
14257 caminho: "../caixa-teia^".into(),
14258 });
14259 let err = d.validate().unwrap_err();
14260 assert!(
14261 matches!(
14262 err,
14263 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14264 ),
14265 "got {err:?}",
14266 );
14267 }
14268
14269 #[test]
14270 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14271 // The positive-control pin (peer with
14272 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14273 // on the immediate-predecessor arm): the gate targets only
14274 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14275 // A relative POSIX path carrying dashes / dots / slashes /
14276 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14277 // continue to validate cleanly so the gate doesn't widen to
14278 // a "no printable punctuation anywhere" sweep that would
14279 // defeat the entire path-fonte author surface.
14280 let d = dep_with_fonte(DepSource::Path {
14281 caminho: "../caixa-teia/sub_v2.rc".into(),
14282 });
14283 d.validate().unwrap();
14284 }
14285
14286 #[test]
14287 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14288 // Cascade pin on the immediate-predecessor arm: a value carrying
14289 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14290 // canonical "I pasted a `!sudo` history-reference next to a
14291 // `^bad^good` quick-substitution") routes through
14292 // `FonteCaminhoShellHistoryExpansion` not
14293 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14294 // the more semantic-locating axis on probe-as-both values (an
14295 // author who removes the `!sudo` reference is likely to also
14296 // strip the paired `^` substitution fragment); same cascade
14297 // discipline every prior `:caminho` arm establishes.
14298 let d = dep_with_fonte(DepSource::Path {
14299 caminho: "../foo!sudo^bad^good".into(),
14300 });
14301 let err = d.validate().unwrap_err();
14302 assert!(
14303 matches!(
14304 err,
14305 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14306 ),
14307 "got {err:?}",
14308 );
14309 }
14310
14311 #[test]
14312 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14313 // Cascade pin on the immediate-successor arm: a value carrying
14314 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14315 // the canonical "I tab-completed a `^bad^good`-carrying path")
14316 // routes through `FonteCaminhoShellHistorySubstitution` not
14317 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14318 // substitution byte is the more semantic-locating axis on probe-
14319 // as-both values (an author who removes the `^bad^good`
14320 // substitution fragment is likely to also tab-strip the trailing
14321 // separator).
14322 let d = dep_with_fonte(DepSource::Path {
14323 caminho: "../foo^bad^good/".into(),
14324 });
14325 let err = d.validate().unwrap_err();
14326 assert!(
14327 matches!(
14328 err,
14329 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14330 ),
14331 "got {err:?}",
14332 );
14333 }
14334
14335 #[test]
14336 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14337 {
14338 // Diagnostic-shape pin (peer with
14339 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14340 // on the immediate-predecessor arm): the error's Display
14341 // surfaces the offending `:nome`, the offending `:caminho`
14342 // verbatim, the offending byte's hex form, and names the
14343 // shell-history-substitution / RFC-3986-'unwise' / regex-
14344 // negation footgun explicitly so a `feira lint` run can render
14345 // the diagnostic without re-parsing.
14346 let d = dep_with_fonte(DepSource::Path {
14347 caminho: "../foo^bad^good".into(),
14348 });
14349 let rendered = d.validate().unwrap_err().to_string();
14350 assert!(
14351 rendered.contains("caixa-teia"),
14352 "diagnostic must name the offending dep: {rendered}",
14353 );
14354 assert!(
14355 rendered.contains("../foo^bad^good"),
14356 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14357 );
14358 assert!(
14359 rendered.contains("0x5e") || rendered.contains("0x5E"),
14360 "diagnostic must surface the offending byte hex: {rendered:?}",
14361 );
14362 assert!(
14363 rendered.contains("history-substitution") || rendered.contains("history substitution"),
14364 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14365 );
14366 assert!(
14367 rendered.contains("unwise"),
14368 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14369 );
14370 }
14371
14372 #[test]
14373 fn fonte_repo_empty_fires_before_pin_missing() {
14374 // Order pin: empty `:repo` is the more self-locating diagnostic
14375 // (every git source needs a repo; the pin discussion is
14376 // secondary), so it fires before the pin-missing arm even when
14377 // both are violated. Mirrors the
14378 // `nome_empty_takes_precedence_over_versao_invalid` ordering
14379 // discipline on the per-entry layer.
14380 let d = dep_with_fonte(DepSource::Git {
14381 repo: String::new(),
14382 tag: None,
14383 rev: None,
14384 branch: None,
14385 });
14386 let err = d.validate().unwrap_err();
14387 assert!(
14388 matches!(err, DepError::FonteRepoEmpty { .. }),
14389 "got {err:?}"
14390 );
14391 }
14392
14393 #[test]
14394 fn fonte_pin_missing_fires_before_pin_empty() {
14395 // Order pin: a fully-None pin set is structurally distinct from
14396 // a Some(empty) pin — the first surfaces as FontePinMissing
14397 // (no axis chosen), the second as FontePinEmpty (axis chosen
14398 // but value blank). Pin the disjoint relationship so a future
14399 // unification collapses to one variant only as a structural
14400 // decision.
14401 let d = dep_with_fonte(DepSource::Git {
14402 repo: "github:pleme-io/caixa-teia".into(),
14403 tag: None,
14404 rev: None,
14405 branch: None,
14406 });
14407 assert!(matches!(
14408 d.validate().unwrap_err(),
14409 DepError::FontePinMissing { .. }
14410 ));
14411 }
14412
14413 #[test]
14414 fn nome_empty_takes_precedence_over_fonte_invalid() {
14415 // Order pin: a per-entry diagnostic without a non-empty :nome
14416 // can't be self-locating, so :nome "" fires first even when
14417 // :fonte is also malformed. Mirrors
14418 // `nome_empty_takes_precedence_over_versao_invalid` on the
14419 // adjacent axis.
14420 let mut d = dep_with_fonte(DepSource::Git {
14421 repo: String::new(),
14422 tag: None,
14423 rev: None,
14424 branch: None,
14425 });
14426 d.nome = String::new();
14427 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14428 }
14429
14430 #[test]
14431 fn versao_invalid_takes_precedence_over_fonte_invalid() {
14432 // Order pin: the :versao parse-side diagnostic is narrower than
14433 // the :fonte shape diagnostic — a malformed :versao always names
14434 // the parser's reason, which is more actionable than the
14435 // :fonte gate's "the pins are wrong" wording. Pin the ordering
14436 // so a re-ordering surfaces here.
14437 let mut d = dep_with_fonte(DepSource::Git {
14438 repo: String::new(),
14439 tag: None,
14440 rev: None,
14441 branch: None,
14442 });
14443 d.versao = "v0.1".into();
14444 let err = d.validate().unwrap_err();
14445 assert!(
14446 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14447 "got {err:?}"
14448 );
14449 }
14450
14451 #[test]
14452 fn fonte_invalid_diagnostic_carries_offending_nome() {
14453 // The diagnostic-shape pin: every :fonte error variant names
14454 // the offending dep's :nome verbatim, so the author can grep
14455 // caixa.lisp for the `:nome "<n>"` block and fix it in one
14456 // edit. Cover all seven variants so a future variant addition
14457 // forces a parallel diagnostic-shape decision.
14458 for (case, fonte) in [
14459 (
14460 "repo-empty",
14461 DepSource::Git {
14462 repo: String::new(),
14463 tag: Some("v1".into()),
14464 rev: None,
14465 branch: None,
14466 },
14467 ),
14468 (
14469 "repo-shape",
14470 DepSource::Git {
14471 repo: "github:p/x ".into(),
14472 tag: Some("v1".into()),
14473 rev: None,
14474 branch: None,
14475 },
14476 ),
14477 (
14478 "pin-missing",
14479 DepSource::Git {
14480 repo: "github:p/x".into(),
14481 tag: None,
14482 rev: None,
14483 branch: None,
14484 },
14485 ),
14486 (
14487 "pin-ambiguous",
14488 DepSource::Git {
14489 repo: "github:p/x".into(),
14490 tag: Some("v1".into()),
14491 rev: None,
14492 branch: Some("main".into()),
14493 },
14494 ),
14495 (
14496 "pin-empty",
14497 DepSource::Git {
14498 repo: "github:p/x".into(),
14499 tag: Some(String::new()),
14500 rev: None,
14501 branch: None,
14502 },
14503 ),
14504 (
14505 "caminho-empty",
14506 DepSource::Path {
14507 caminho: String::new(),
14508 },
14509 ),
14510 (
14511 "caminho-absolute",
14512 DepSource::Path {
14513 caminho: "/home/me/work/caixa-teia".into(),
14514 },
14515 ),
14516 ] {
14517 let d = dep_with_fonte(fonte);
14518 let msg = d
14519 .validate()
14520 .expect_err(&format!("{case}: expected fonte error"))
14521 .to_string();
14522 assert!(
14523 msg.contains("\"caixa-teia\""),
14524 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14525 );
14526 }
14527 }
14528
14529 // -- :tag / :branch value-shape gate ----------------------------------
14530
14531 #[test]
14532 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14533 // The canonical paste-from-doc footgun on `:tag` — author
14534 // copies `"v0.1.0 "` (trailing space) out of a release-notes
14535 // paragraph. Until this gate landed the empty-pin arm passed
14536 // (the string isn't empty), the resolver issued
14537 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14538 // surfaced at clone time with a quoting-confused git error
14539 // far from the source caixa.lisp. The new gate moves the
14540 // check to caixa-build time and names the offending dep +
14541 // pin + value verbatim.
14542 let d = dep_with_fonte(DepSource::Git {
14543 repo: "github:pleme-io/caixa-teia".into(),
14544 tag: Some("v0.1.0 ".into()),
14545 rev: None,
14546 branch: None,
14547 });
14548 let err = d.validate().unwrap_err();
14549 let DepError::FontePinShape {
14550 nome,
14551 pin,
14552 value,
14553 reason,
14554 } = err
14555 else {
14556 panic!("expected FontePinShape, got other variant");
14557 };
14558 assert_eq!(nome, "caixa-teia");
14559 assert_eq!(pin, ":tag");
14560 assert_eq!(value, "v0.1.0 ");
14561 assert!(
14562 reason.contains("whitespace"),
14563 "reason must surface the whitespace arm, got {reason:?}"
14564 );
14565 }
14566
14567 #[test]
14568 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14569 // The `.lock` suffix is git's atomic-rename guard for
14570 // in-flight ref updates — a refname ending in `.lock` is
14571 // unwritable on disk. Pinned separately from the whitespace
14572 // arm so a future relaxation that admits one but not the
14573 // other surfaces here.
14574 let d = dep_with_fonte(DepSource::Git {
14575 repo: "github:pleme-io/caixa-teia".into(),
14576 tag: Some("v0.1.0.lock".into()),
14577 rev: None,
14578 branch: None,
14579 });
14580 let err = d.validate().unwrap_err();
14581 let DepError::FontePinShape {
14582 pin, value, reason, ..
14583 } = err
14584 else {
14585 panic!("expected FontePinShape, got other variant");
14586 };
14587 assert_eq!(pin, ":tag");
14588 assert_eq!(value, "v0.1.0.lock");
14589 assert!(
14590 reason.contains(".lock"),
14591 "reason must surface the .lock arm, got {reason:?}"
14592 );
14593 }
14594
14595 #[test]
14596 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14597 // The canonical "branch name with spaces" footgun (`feature
14598 // foo`, `release branch`) — git's refname parser rejects raw
14599 // whitespace, and the failure surfaces at `git checkout
14600 // 'feature foo'` time with a quoting-confused error far from
14601 // the source caixa.lisp. Pinned on the `:branch` axis so the
14602 // gate-applies-to-both-:tag-and-:branch contract is a build-
14603 // error to relax.
14604 let d = dep_with_fonte(DepSource::Git {
14605 repo: "github:pleme-io/caixa-teia".into(),
14606 tag: None,
14607 rev: None,
14608 branch: Some("feature/foo bar".into()),
14609 });
14610 let err = d.validate().unwrap_err();
14611 let DepError::FontePinShape {
14612 pin, value, reason, ..
14613 } = err
14614 else {
14615 panic!("expected FontePinShape, got other variant");
14616 };
14617 assert_eq!(pin, ":branch");
14618 assert_eq!(value, "feature/foo bar");
14619 assert!(
14620 reason.contains("whitespace"),
14621 "reason must surface the whitespace arm, got {reason:?}"
14622 );
14623 }
14624
14625 #[test]
14626 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14627 // The `refs/heads/main` shape — the canonical "I copied the
14628 // fully-qualified ref out of `git show-ref` instead of the
14629 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14630 // at clone time, so this resolves to a literal ref named
14631 // `refs/heads/refs/heads/main` on disk; the silent double-
14632 // prefix is the load-bearing reason to gate at validate.
14633 // The diagnostic must enumerate the leaf the author probably
14634 // meant (`"main"`) so the fix is one edit.
14635 let d = dep_with_fonte(DepSource::Git {
14636 repo: "github:pleme-io/caixa-teia".into(),
14637 tag: None,
14638 rev: None,
14639 branch: Some("refs/heads/main".into()),
14640 });
14641 let err = d.validate().unwrap_err();
14642 let DepError::FontePinShape {
14643 pin, value, reason, ..
14644 } = err
14645 else {
14646 panic!("expected FontePinShape, got other variant");
14647 };
14648 assert_eq!(pin, ":branch");
14649 assert_eq!(value, "refs/heads/main");
14650 assert!(
14651 reason.contains("fully-qualified"),
14652 "reason must surface the qualified-prefix arm, got {reason:?}"
14653 );
14654 assert!(
14655 reason.contains("\"main\""),
14656 "reason must quote the leaf the author probably meant, got {reason:?}"
14657 );
14658 }
14659
14660 #[test]
14661 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14662 // Sibling arm of the qualified-prefix gate on the `:tag`
14663 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14664 // footgun). Pinned separately so a future relaxation that
14665 // only catches the `:branch` arm surfaces here.
14666 let d = dep_with_fonte(DepSource::Git {
14667 repo: "github:pleme-io/caixa-teia".into(),
14668 tag: Some("refs/tags/v0.1.0".into()),
14669 rev: None,
14670 branch: None,
14671 });
14672 let err = d.validate().unwrap_err();
14673 let DepError::FontePinShape {
14674 pin, value, reason, ..
14675 } = err
14676 else {
14677 panic!("expected FontePinShape, got other variant");
14678 };
14679 assert_eq!(pin, ":tag");
14680 assert_eq!(value, "refs/tags/v0.1.0");
14681 assert!(
14682 reason.contains("fully-qualified"),
14683 "reason must surface the qualified-prefix arm, got {reason:?}"
14684 );
14685 assert!(
14686 reason.contains("\"v0.1.0\""),
14687 "reason must quote the leaf the author probably meant, got {reason:?}"
14688 );
14689 }
14690
14691 #[test]
14692 fn validate_rejects_git_fonte_with_branch_named_at() {
14693 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14694 // unsourceable. Pinned so a future relaxation that admits
14695 // any single-character refname surfaces here.
14696 let d = dep_with_fonte(DepSource::Git {
14697 repo: "github:pleme-io/caixa-teia".into(),
14698 tag: None,
14699 rev: None,
14700 branch: Some("@".into()),
14701 });
14702 let err = d.validate().unwrap_err();
14703 let DepError::FontePinShape { pin, value, .. } = err else {
14704 panic!("expected FontePinShape, got other variant");
14705 };
14706 assert_eq!(pin, ":branch");
14707 assert_eq!(value, "@");
14708 }
14709
14710 #[test]
14711 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14712 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14713 // a `:tag "../escape"` (path-traversal-shaped slug) silently
14714 // passes parse and surfaces as a refname-parse error or, on
14715 // older git, a literal `../escape` checkout that escapes the
14716 // refs/ directory tree. Pinned separately from the
14717 // qualified-prefix arm so a future relaxation that catches
14718 // one but not the other surfaces here.
14719 let d = dep_with_fonte(DepSource::Git {
14720 repo: "github:pleme-io/caixa-teia".into(),
14721 tag: Some("../escape".into()),
14722 rev: None,
14723 branch: None,
14724 });
14725 let err = d.validate().unwrap_err();
14726 let DepError::FontePinShape { pin, value, .. } = err else {
14727 panic!("expected FontePinShape, got other variant");
14728 };
14729 assert_eq!(pin, ":tag");
14730 assert_eq!(value, "../escape");
14731 }
14732
14733 #[test]
14734 fn validate_accepts_git_fonte_with_hierarchical_branch() {
14735 // The positive-control pin: hierarchical refnames with one or
14736 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14737 // canonical idiom) round-trip through the gate. Pinned
14738 // separately from the leaf-`"main"` positive control so a
14739 // future tightening that rejects all multi-component refnames
14740 // surfaces here.
14741 let d = dep_with_fonte(DepSource::Git {
14742 repo: "github:pleme-io/caixa-teia".into(),
14743 tag: None,
14744 rev: None,
14745 branch: Some("feature/checkout-rewrite".into()),
14746 });
14747 d.validate().unwrap();
14748 }
14749
14750 #[test]
14751 fn validate_accepts_git_fonte_with_prerelease_tag() {
14752 // The positive-control pin: semver pre-release shape
14753 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14754 // (only consecutive `..` and trailing `.` are rejected), the
14755 // mid-component hyphen is allowed. Pinned separately from
14756 // the bare-`"v0.1.0"` positive control so a future tightening
14757 // that rejects pre-release tags surfaces here.
14758 let d = dep_with_fonte(DepSource::Git {
14759 repo: "github:pleme-io/caixa-teia".into(),
14760 tag: Some("v0.1.0-alpha.1".into()),
14761 rev: None,
14762 branch: None,
14763 });
14764 d.validate().unwrap();
14765 }
14766
14767 #[test]
14768 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14769 // The `:rev` axis is routed through `crate::render::is_git_oid`
14770 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14771 // value with refname-shape punctuation (here, a `:` mid-string
14772 // — would be a refname violation under `is_git_ref_name` too)
14773 // is rejected at the OID-shape gate. The two predicates
14774 // partition the `:fonte` pin axes structurally: an `:rev` value
14775 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14776 // *still* rejected here because every refname character outside
14777 // `[0-9a-f]` fails the OID gate. Same shape as
14778 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14779 // on the refname-shaped axes — the diagnostic names the
14780 // offending dep + pin + value verbatim. The flip-from-accept
14781 // case the prior `:tag`/`:branch` gate left as a "future axis"
14782 // (e70d213) — now landed.
14783 let d = dep_with_fonte(DepSource::Git {
14784 repo: "github:pleme-io/caixa-teia".into(),
14785 tag: None,
14786 rev: Some("c0ffee:notarefname".into()),
14787 branch: None,
14788 });
14789 let err = d.validate().unwrap_err();
14790 let DepError::FontePinShape {
14791 nome,
14792 pin,
14793 value,
14794 reason,
14795 } = err
14796 else {
14797 panic!("expected FontePinShape, got other variant");
14798 };
14799 assert_eq!(nome, "caixa-teia");
14800 assert_eq!(pin, ":rev");
14801 assert_eq!(value, "c0ffee:notarefname");
14802 assert!(
14803 !reason.is_empty(),
14804 "FontePinShape `reason` must carry the predicate's wording verbatim"
14805 );
14806 }
14807
14808 #[test]
14809 fn validate_accepts_git_fonte_with_rev_full_sha1() {
14810 // The positive-control pin on the SHA-1 OID width: exactly 40
14811 // lowercase hex characters — the canonical `git rev-parse HEAD`
14812 // emission on a SHA-1-hashed repository (the default on every
14813 // pre-2.42 git and the canonical pleme-io substrate hash).
14814 // Pinned separately from the SHA-256 positive control so a
14815 // future tightening that only admits one width surfaces here.
14816 let d = dep_with_fonte(DepSource::Git {
14817 repo: "github:pleme-io/caixa-teia".into(),
14818 tag: None,
14819 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14820 branch: None,
14821 });
14822 d.validate().unwrap();
14823 }
14824
14825 #[test]
14826 fn validate_accepts_git_fonte_with_rev_full_sha256() {
14827 // The positive-control pin on the SHA-256 OID width: exactly
14828 // 64 lowercase hex characters — `git`'s
14829 // `extensions.objectFormat = sha256` emission (GA since Git
14830 // 2.42 / Oct 2023). The substrate admits either canonical
14831 // width so an `:rev` authored against a SHA-256-hashed
14832 // upstream round-trips through the gate without per-repo
14833 // configuration. Pinned separately from the SHA-1 positive
14834 // control so a future tightening that drops one width surfaces
14835 // here as a structural decision.
14836 let d = dep_with_fonte(DepSource::Git {
14837 repo: "github:pleme-io/caixa-teia".into(),
14838 tag: None,
14839 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14840 branch: None,
14841 });
14842 d.validate().unwrap();
14843 }
14844
14845 #[test]
14846 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14847 // The canonical `git log --short` / `git rev-parse --short HEAD`
14848 // paste-from-release-notes footgun: a 7-char prefix (git's
14849 // default `core.abbrev`) silently passes string emptiness
14850 // checks and resolves to one commit today, but becomes ambiguous
14851 // tomorrow as the repo grows. Until this gate landed the empty-
14852 // pin arm passed (the string isn't empty) and the resolver
14853 // accepted the prefix through git's separate prefix-lookup pass
14854 // — defeating the reproducibility contract `:rev` carries vs.
14855 // `:tag` / `:branch`. The new gate moves the check to caixa-
14856 // build time and names the offending dep + pin + value verbatim.
14857 let d = dep_with_fonte(DepSource::Git {
14858 repo: "github:pleme-io/caixa-teia".into(),
14859 tag: None,
14860 rev: Some("c0ffee0".into()),
14861 branch: None,
14862 });
14863 let err = d.validate().unwrap_err();
14864 let DepError::FontePinShape {
14865 pin, value, reason, ..
14866 } = err
14867 else {
14868 panic!("expected FontePinShape, got other variant");
14869 };
14870 assert_eq!(pin, ":rev");
14871 assert_eq!(value, "c0ffee0");
14872 assert!(
14873 reason.contains("abbreviated") || reason.contains("ambiguous"),
14874 "reason must surface the abbreviation arm, got {reason:?}"
14875 );
14876 }
14877
14878 #[test]
14879 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
14880 // The canonical "I pasted the SHA in uppercase" footgun: `git
14881 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
14882 // bearing `:rev` round-trips inconsistently across the
14883 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
14884 // equality-check pipeline and fails the lacre's content-
14885 // addressing probe with a confusing case-only diff. Pinned
14886 // separately from the non-hex arm so a future relaxation that
14887 // admits one but not the other surfaces here.
14888 let d = dep_with_fonte(DepSource::Git {
14889 repo: "github:pleme-io/caixa-teia".into(),
14890 tag: None,
14891 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
14892 branch: None,
14893 });
14894 let err = d.validate().unwrap_err();
14895 let DepError::FontePinShape {
14896 pin, value, reason, ..
14897 } = err
14898 else {
14899 panic!("expected FontePinShape, got other variant");
14900 };
14901 assert_eq!(pin, ":rev");
14902 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
14903 assert!(
14904 reason.contains("uppercase"),
14905 "reason must surface the uppercase arm, got {reason:?}"
14906 );
14907 }
14908
14909 #[test]
14910 fn validate_rejects_git_fonte_with_rev_refname_value() {
14911 // The cross-axis mis-slot footgun: `:rev "main"` — the author
14912 // conflated `:rev` (hex commit ID, immutable) and `:branch`
14913 // (mutable ref pointing at whatever HEAD is today). Until this
14914 // gate landed the resolver silently dispatched on the value
14915 // shape ("`main` doesn't look like a SHA, fall back to
14916 // refname"), defeating the `:rev` reproducibility contract.
14917 // The new gate rejects every non-hex value on the `:rev` axis,
14918 // so the `:rev`/`:branch` boundary is structurally enforced —
14919 // a refname in the `:rev` slot is a build error, not a
14920 // resolver-time silent reinterpretation.
14921 let d = dep_with_fonte(DepSource::Git {
14922 repo: "github:pleme-io/caixa-teia".into(),
14923 tag: None,
14924 rev: Some("main".into()),
14925 branch: None,
14926 });
14927 let err = d.validate().unwrap_err();
14928 let DepError::FontePinShape {
14929 pin, value, reason, ..
14930 } = err
14931 else {
14932 panic!("expected FontePinShape, got other variant");
14933 };
14934 assert_eq!(pin, ":rev");
14935 assert_eq!(value, "main");
14936 // 4 chars `main` fails the length arm before the character arm,
14937 // so the diagnostic surfaces the abbreviation wording (same
14938 // path the `c0ffee0` 7-char fixture lands on); the structural
14939 // assertion is just that the `:rev "main"` value is rejected.
14940 assert!(
14941 !reason.is_empty(),
14942 "FontePinShape reason must be non-empty for refname-shaped :rev"
14943 );
14944 }
14945
14946 #[test]
14947 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
14948 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
14949 // conflated `:rev` and `:tag`. Pinned separately from the
14950 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
14951 // that catches one but not the other surfaces here. The
14952 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
14953 // assertion is just that the cross-axis mis-slot is a build
14954 // error, regardless of which sub-arm surfaces the diagnostic
14955 // (`is_git_oid` rejects at the first violation; longer
14956 // tag-shape values would hit the non-hex arm instead).
14957 let d = dep_with_fonte(DepSource::Git {
14958 repo: "github:pleme-io/caixa-teia".into(),
14959 tag: None,
14960 rev: Some("v0.1.0".into()),
14961 branch: None,
14962 });
14963 let err = d.validate().unwrap_err();
14964 let DepError::FontePinShape {
14965 pin, value, reason, ..
14966 } = err
14967 else {
14968 panic!("expected FontePinShape, got other variant");
14969 };
14970 assert_eq!(pin, ":rev");
14971 assert_eq!(value, "v0.1.0");
14972 assert!(
14973 !reason.is_empty(),
14974 "FontePinShape reason must be non-empty for tag-shaped :rev"
14975 );
14976 }
14977
14978 #[test]
14979 fn validate_rejects_git_fonte_with_rev_too_long() {
14980 // Boundary case on the upper end: 41 hex chars — one past the
14981 // SHA-1 width, well below the SHA-256 width. Pin so a future
14982 // relaxation that admits "long enough to be a SHA" without
14983 // matching either canonical width surfaces here. The diagnostic
14984 // names the offending length verbatim so the author's grep
14985 // target is unambiguous (either trim one char or paste the
14986 // full SHA-256).
14987 let too_long: String = "0".repeat(41);
14988 let d = dep_with_fonte(DepSource::Git {
14989 repo: "github:pleme-io/caixa-teia".into(),
14990 tag: None,
14991 rev: Some(too_long.clone()),
14992 branch: None,
14993 });
14994 let err = d.validate().unwrap_err();
14995 let DepError::FontePinShape {
14996 pin, value, reason, ..
14997 } = err
14998 else {
14999 panic!("expected FontePinShape, got other variant");
15000 };
15001 assert_eq!(pin, ":rev");
15002 assert_eq!(value, too_long);
15003 assert!(
15004 reason.contains("41"),
15005 "reason must surface the offending length verbatim, got {reason:?}"
15006 );
15007 }
15008
15009 #[test]
15010 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15011 // The canonical paste-from-doc footgun on `:rev` — author
15012 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15013 // commit-message paragraph. Until this gate landed the empty-
15014 // pin arm passed (the string isn't empty), the resolver issued
15015 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15016 // clone time with a quoting-confused git error far from the
15017 // source caixa.lisp. The new gate moves the check to caixa-
15018 // build time. Length is 41 (40 hex + space) so the length arm
15019 // fires first — pinned separately from the pure-length arm to
15020 // ensure the diagnostic surfaces *some* parser wording, not
15021 // silently pass through.
15022 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15023 let d = dep_with_fonte(DepSource::Git {
15024 repo: "github:pleme-io/caixa-teia".into(),
15025 tag: None,
15026 rev: Some(with_space.clone()),
15027 branch: None,
15028 });
15029 let err = d.validate().unwrap_err();
15030 let DepError::FontePinShape {
15031 pin, value, reason, ..
15032 } = err
15033 else {
15034 panic!("expected FontePinShape, got other variant");
15035 };
15036 assert_eq!(pin, ":rev");
15037 assert_eq!(value, with_space);
15038 assert!(
15039 !reason.is_empty(),
15040 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15041 );
15042 }
15043
15044 #[test]
15045 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15046 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15047 // variant on this axis names the offending dep's `:nome` + the
15048 // `:rev` axis + the offending value verbatim, so the author's
15049 // grep target is the literal `:rev "<value>"` block in
15050 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15051 // carries_offending_nome_pin_value` test on the refname-shaped
15052 // (`:tag` / `:branch`) axes.
15053 let d = dep_with_fonte(DepSource::Git {
15054 repo: "github:p/x".into(),
15055 tag: None,
15056 rev: Some("not-a-sha".into()),
15057 branch: None,
15058 });
15059 let msg = d
15060 .validate()
15061 .expect_err(":rev: expected FontePinShape")
15062 .to_string();
15063 assert!(
15064 msg.contains("\"caixa-teia\""),
15065 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15066 );
15067 assert!(
15068 msg.contains(":rev"),
15069 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15070 );
15071 assert!(
15072 msg.contains("not-a-sha"),
15073 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15074 );
15075 }
15076
15077 #[test]
15078 fn fonte_pin_empty_fires_before_pin_shape() {
15079 // Order pin: a `Some("")` `:tag` is the more self-locating
15080 // diagnostic (the author chose an axis but left it blank;
15081 // grep is unambiguous), so it fires before the shape gate
15082 // even when both arms would match. Pinned so a future
15083 // reordering surfaces here. Mirrors the
15084 // `fonte_repo_empty_fires_before_pin_missing` ordering
15085 // discipline on the peer per-axis arms.
15086 let d = dep_with_fonte(DepSource::Git {
15087 repo: "github:pleme-io/caixa-teia".into(),
15088 tag: Some(String::new()),
15089 rev: None,
15090 branch: None,
15091 });
15092 assert!(matches!(
15093 d.validate().unwrap_err(),
15094 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15095 ));
15096 }
15097
15098 #[test]
15099 fn fonte_pin_shape_fires_after_repo_empty() {
15100 // Order pin: `:repo ""` is the more self-locating axis
15101 // (every git source needs a repo; the per-pin shape gate is
15102 // secondary), so the repo-empty arm fires before the
15103 // per-pin shape arm even when both are violated. Pinned so
15104 // a future reordering surfaces here. Mirrors
15105 // `fonte_repo_empty_fires_before_pin_missing` on the
15106 // adjacent axis pair.
15107 let d = dep_with_fonte(DepSource::Git {
15108 repo: String::new(),
15109 tag: Some("v0.1.0 ".into()),
15110 rev: None,
15111 branch: None,
15112 });
15113 assert!(matches!(
15114 d.validate().unwrap_err(),
15115 DepError::FonteRepoEmpty { .. }
15116 ));
15117 }
15118
15119 #[test]
15120 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15121 // Diagnostic-shape pin across both refname-shaped axes
15122 // (`:tag` + `:branch`): every `FontePinShape` variant names
15123 // the offending dep's `:nome` + the offending pin axis + the
15124 // offending value verbatim, so the author's grep target is
15125 // unambiguous (the literal `:tag "<value>"` / `:branch
15126 // "<value>"` lands in caixa.lisp with quotes). Cover both
15127 // pin axes so a future variant addition forces a parallel
15128 // diagnostic-shape decision.
15129 for (pin_label, fonte) in [
15130 (
15131 ":tag",
15132 DepSource::Git {
15133 repo: "github:p/x".into(),
15134 tag: Some("v0.1.0~1".into()),
15135 rev: None,
15136 branch: None,
15137 },
15138 ),
15139 (
15140 ":branch",
15141 DepSource::Git {
15142 repo: "github:p/x".into(),
15143 tag: None,
15144 rev: None,
15145 branch: Some("feature/foo*".into()),
15146 },
15147 ),
15148 ] {
15149 let d = dep_with_fonte(fonte);
15150 let msg = d
15151 .validate()
15152 .expect_err(&format!("{pin_label}: expected FontePinShape"))
15153 .to_string();
15154 assert!(
15155 msg.contains("\"caixa-teia\""),
15156 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15157 );
15158 assert!(
15159 msg.contains(pin_label),
15160 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15161 );
15162 }
15163 }
15164
15165 #[test]
15166 fn git_source_json_round_trip() {
15167 let src = DepSource::Git {
15168 repo: "github:pleme-io/caixa-teia".into(),
15169 tag: Some("v0.1.0".into()),
15170 rev: None,
15171 branch: None,
15172 };
15173 let s = serde_json::to_string(&src).unwrap();
15174 assert!(s.contains(&format!(
15175 r#""{tipo}":"{git}""#,
15176 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15177 git = crate::render::DEP_SOURCE_TIPO_GIT,
15178 )));
15179 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15180 assert!(s.contains(r#""tag":"v0.1.0""#));
15181 assert!(!s.contains("rev"));
15182 assert!(!s.contains("branch"));
15183 let round: DepSource = serde_json::from_str(&s).unwrap();
15184 assert_eq!(round, src);
15185 }
15186
15187 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15188 //
15189 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15190 // attribute on [`DepSource`] pins three load-bearing byte-sequences
15191 // that flow into every serialized `Dep.fonte` block: the outer
15192 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15193 // the two admitted variant-tag values `"git"` / `"path"` the
15194 // `rename_all = "lowercase"` attribute pins as the discriminator's
15195 // closed-set arms. The three pin tests below round-trip a
15196 // fully-populated variant of each arm through
15197 // [`serde_json::to_value`] and assert each canonical byte-sequence
15198 // appears at its axis — pins a hypothetical future
15199 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15200 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15201 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15202 // at build time rather than at fetch time when the resolver's
15203 // `Dep.fonte` dispatch silently fails to match on the drifted
15204 // discriminator. Same "serialize-and-check" discipline the peer
15205 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15206 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15207 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15208 // family in caixa-core lacking a lifted peer.
15209
15210 #[test]
15211 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15212 // Fail-before-pass-after: a future `tag = "type"` at the derive
15213 // attribute would serialize under `"type":"git"`, and this test
15214 // would trip because `"tipo"` no longer appears at the emitted
15215 // discriminator key. A future `rename_all = "kebab-case"` /
15216 // `"snake_case"` (both no-ops on `Git` since it lacks internal
15217 // word boundaries) is caught by the sibling
15218 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15219 // pin below (Path has no internal boundary either but the pair
15220 // catches any per-arm inconsistency). A future variant rename
15221 // `Git` → `Repository` would emit `"tipo":"repository"` and
15222 // trip this pin.
15223 let src = DepSource::Git {
15224 repo: "github:pleme-io/caixa-teia".into(),
15225 tag: Some("v0.1.0".into()),
15226 rev: None,
15227 branch: None,
15228 };
15229 let json = serde_json::to_value(&src).unwrap();
15230 let obj = json.as_object().expect("Git serializes as a JSON object");
15231 assert_eq!(
15232 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15233 .and_then(serde_json::Value::as_str),
15234 Some(crate::render::DEP_SOURCE_TIPO_GIT),
15235 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15236 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15237 detected in {json}"
15238 );
15239 }
15240
15241 #[test]
15242 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15243 // Fail-before-pass-after: a future variant rename `Path` →
15244 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15245 // this pin. A per-consumer disambiguation as the `defcaixa`
15246 // macro stabilizes ("caminho" → "path" for English-uniformity)
15247 // is scoped to the inner field key, not the discriminator; this
15248 // pin is orthogonal to that and catches only the outer
15249 // discriminator drift.
15250 let src = DepSource::Path {
15251 caminho: "../caixa-teia".into(),
15252 };
15253 let json = serde_json::to_value(&src).unwrap();
15254 let obj = json.as_object().expect("Path serializes as a JSON object");
15255 assert_eq!(
15256 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15257 .and_then(serde_json::Value::as_str),
15258 Some(crate::render::DEP_SOURCE_TIPO_PATH),
15259 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15260 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15261 detected in {json}"
15262 );
15263 }
15264
15265 #[test]
15266 fn dep_source_key_consts_are_pairwise_distinct() {
15267 // Cross-axis collapse detector: a hypothetical future edit that
15268 // accidentally set two of the three consts to the same byte
15269 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15270 // pass every per-arm serialize pin above but silently collapse
15271 // the discriminator's closed-set arms onto one another; this pin
15272 // catches the collapse at build time.
15273 assert_ne!(
15274 crate::render::DEP_SOURCE_KEY_TIPO,
15275 crate::render::DEP_SOURCE_TIPO_GIT,
15276 );
15277 assert_ne!(
15278 crate::render::DEP_SOURCE_KEY_TIPO,
15279 crate::render::DEP_SOURCE_TIPO_PATH,
15280 );
15281 assert_ne!(
15282 crate::render::DEP_SOURCE_TIPO_GIT,
15283 crate::render::DEP_SOURCE_TIPO_PATH,
15284 );
15285 }
15286
15287 #[test]
15288 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15289 // Shape pin against `rename_all` drift: the two variant-tag
15290 // consts must be ASCII-lowercase-only to match the
15291 // `rename_all = "lowercase"` attribute the derive uses; a future
15292 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15293 // would emit `"GIT"` / `"Git"` instead and trip this pin.
15294 for (label, s) in [
15295 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15296 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15297 ] {
15298 assert!(!s.is_empty(), "{label} must not be empty");
15299 assert!(
15300 s.bytes().all(|b| b.is_ascii_lowercase()),
15301 "{label} must be ASCII-lowercase-only (matching \
15302 rename_all = \"lowercase\"), got {s:?}",
15303 );
15304 }
15305 }
15306
15307 // ── per-entry :caracteristicas set-not-multiset gate ────────────
15308 //
15309 // Every Vec-keyed-by-name authoring surface on the typed Caixa
15310 // surface that identifies its entries by a name field now uniformly
15311 // closes the set-not-multiset discipline at build time (cite
15312 // `validate_caracteristicas`'s peer-axis enumeration). The
15313 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15314 // set-shaped (a feature is either enabled or not — there is no
15315 // `feature × 2` semantic), so two entries naming the same feature
15316 // are a redundant declaration the caixa-resolver's lacre pipeline
15317 // would silently dedup at resolve time. The empty-feature arm
15318 // closes the parallel "operationally-meaningless value" axis on
15319 // the same slot. Same linear-walk + `HashSet` + first-collision
15320 // shape every peer set gate uses; same empty-first cascade every
15321 // peer per-entry shape + duplicate gate uses (the empty-feature
15322 // axis is the more-actionable defect since two `""` entries would
15323 // both report `caracteristica: ""` under a duplicate-first
15324 // ordering, with no way to distinguish the offending site).
15325
15326 fn dep_with_features(features: &[&str]) -> Dep {
15327 Dep {
15328 nome: "caixa-teia".into(),
15329 versao: "^0.1".into(),
15330 fonte: None,
15331 opcional: false,
15332 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15333 }
15334 }
15335
15336 #[test]
15337 fn validate_rejects_empty_caracteristica() {
15338 // Fail-before-pass-after pin: every pre-gate codebase accepted
15339 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15340 // imposed no per-entry shape contract), the dep validated, and
15341 // the empty feature would have reached the future caixa-resolver
15342 // lacre pipeline as a no-op feature enable — silently dropping
15343 // the author's intent far from the source `caixa.lisp`. The new
15344 // gate surfaces the structural defect at the typed-validate
15345 // surface with a self-locating diagnostic naming the offending
15346 // dep's `:nome`.
15347 let d = dep_with_features(&[""]);
15348 assert!(
15349 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15350 "expected CaracteristicaEmpty, got {:?}",
15351 d.validate(),
15352 );
15353 }
15354
15355 #[test]
15356 fn validate_rejects_duplicate_caracteristica() {
15357 // Fail-before-pass-after pin on the set-not-multiset arm: the
15358 // feature-toggle slot is set-shaped, so `(:caracteristicas
15359 // ("http" "http"))` is a redundant declaration the lacre
15360 // pipeline dedupes silently at resolve time. The diagnostic
15361 // names the offending dep + the colliding feature verbatim so
15362 // the author can grep their caixa.lisp for `:caracteristicas`
15363 // and fix it in one edit. First-collision determinism is
15364 // pinned separately below.
15365 let d = dep_with_features(&["http", "http"]);
15366 assert!(
15367 matches!(
15368 d.validate().unwrap_err(),
15369 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15370 if nome == "caixa-teia" && caracteristica == "http"
15371 ),
15372 "expected CaracteristicaDuplicate, got {:?}",
15373 d.validate(),
15374 );
15375 }
15376
15377 #[test]
15378 fn validate_accepts_distinct_caracteristicas() {
15379 // The canonical authoring shape — every feature distinct — must
15380 // remain a clean pass (positive control sweep). Covers the
15381 // canonical kebab-case feature names a target caixa typically
15382 // declares.
15383 dep_with_features(&["http", "json", "tls"])
15384 .validate()
15385 .unwrap();
15386 }
15387
15388 #[test]
15389 fn validate_accepts_single_caracteristica() {
15390 // Single-element list is the minimum non-empty shape; passes
15391 // the gate as the identity of the duplicate check (no second
15392 // entry to collide with).
15393 dep_with_features(&["http"]).validate().unwrap();
15394 }
15395
15396 #[test]
15397 fn validate_accepts_empty_caracteristicas_list() {
15398 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15399 // produces `caracteristicas: Vec::new()`; the empty list is
15400 // the gate's empty-set identity and passes vacuously. Pin
15401 // this so a future tightening that requires ≥1 feature
15402 // surfaces here as a test failure rather than a silent
15403 // contract narrowing.
15404 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15405 assert!(dep_with_features(&[]).validate().is_ok());
15406 }
15407
15408 #[test]
15409 fn validate_caracteristica_empty_fires_before_duplicate() {
15410 // Empty-first cascade: an entry with an empty feature *and*
15411 // duplicate entries surfaces the empty diagnostic first. The
15412 // empty-feature axis is the more-actionable defect since
15413 // `caracteristica: ""` is unambiguous; under duplicate-first
15414 // ordering the diagnostic could report the empty string from
15415 // either of two empty entries with no way to distinguish.
15416 // Mirrors the peer empty-before-duplicate ordering
15417 // discipline every per-entry shape + duplicate gate establishes
15418 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15419 // `DuplicateChildCaixa`, `validate_membros`'s
15420 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15421 let d = dep_with_features(&["", "http", "http"]);
15422 assert!(matches!(
15423 d.validate().unwrap_err(),
15424 DepError::CaracteristicaEmpty { .. }
15425 ));
15426 }
15427
15428 #[test]
15429 fn validate_caracteristica_duplicate_first_collision_determinism() {
15430 // Three matching entries: the second occurrence surfaces the
15431 // diagnostic (the second is the first *collision* — the first
15432 // entry is the establishing one, not a duplicate). Mirrors
15433 // every peer first-collision posture
15434 // (`SupervisorError::DuplicateChildCaixa` reports the second
15435 // collision, `AplicacaoError::MembroDuplicate` reports the
15436 // second, `DepError::DuplicateNome` reports the second).
15437 // Pinning this so a future shortcut that flips to last-
15438 // collision (or non-deterministic) surfaces here.
15439 let d = dep_with_features(&["http", "http", "http"]);
15440 assert!(matches!(
15441 d.validate().unwrap_err(),
15442 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15443 ));
15444 }
15445
15446 #[test]
15447 fn validate_per_entry_shape_fires_before_caracteristicas() {
15448 // Per-entry shape precedence: a dep with a malformed `:nome`
15449 // (uppercase) AND duplicate `:caracteristicas` surfaces the
15450 // narrower `NomeInvalid` diagnostic first, not the set-gate
15451 // diagnostic. The `:nome` is the self-locating axis (every
15452 // diagnostic from the caracteristicas gate quotes the
15453 // offending dep's `:nome` to anchor the grep target —
15454 // surfacing the malformed name first keeps that anchor
15455 // valid). Same precedence shape every peer per-entry-shape
15456 // arm establishes against its peer set-gate
15457 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15458 // on the cross-entry `:nome` axis).
15459 let d = Dep {
15460 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15461 versao: "^0.1".into(),
15462 fonte: None,
15463 opcional: false,
15464 caracteristicas: vec!["http".into(), "http".into()],
15465 };
15466 assert!(matches!(
15467 d.validate().unwrap_err(),
15468 DepError::NomeInvalid { .. }
15469 ));
15470 }
15471
15472 // ── per-entry :caracteristicas value-shape gate ──────────────────
15473 //
15474 // Until this gate landed `:caracteristicas` only refused the empty
15475 // string and cross-entry duplicates: a non-empty distinct but
15476 // structurally invalid feature name silently passed validate and the
15477 // failure surfaced at `cargo metadata` time as Cargo's
15478 // `restricted_names::validate_feature_name` parser rejection, far from
15479 // the source `caixa.lisp` with no field naming which `:deps` entry's
15480 // `:caracteristicas` carried the typo. The lifted predicate makes the
15481 // Cargo-feature-name-grammar intersection-floor a substrate-level
15482 // invariant at validate time. Same trajectory as the eight peer
15483 // value-shape predicates each typed surface downstream of a structured
15484 // grammar already follows.
15485
15486 #[test]
15487 fn validate_rejects_caracteristica_with_leading_plus() {
15488 // Fail-before-pass-after pin on the canonical Cargo
15489 // `+<feature>` activation-form-in-feature-name-slot footgun.
15490 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15491 // `+optional-feature` as an enablement of a previously-disabled
15492 // feature; pasting that activation form into `:caracteristicas`
15493 // (which names the feature itself) silently passed pre-gate and
15494 // failed at `cargo metadata` parse time.
15495 let d = dep_with_features(&["+http"]);
15496 let err = d.validate().unwrap_err();
15497 assert!(
15498 matches!(
15499 err,
15500 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15501 if nome == "caixa-teia" && caracteristica == "+http"
15502 ),
15503 "expected CaracteristicaInvalid, got {err:?}"
15504 );
15505 }
15506
15507 #[test]
15508 fn validate_rejects_caracteristica_with_leading_hyphen() {
15509 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15510 // is a legitimate continuation character (kebab-case feature
15511 // names like `runtime-tokio` pass) but Cargo rejects it at the
15512 // start; the structural defect — and its CLI-argument-injection
15513 // adjacency at any downstream Cargo subprocess invocation — is
15514 // closed at validate time, not at `cargo metadata` time.
15515 let d = dep_with_features(&["-json"]);
15516 let err = d.validate().unwrap_err();
15517 assert!(
15518 matches!(
15519 err,
15520 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15521 ),
15522 "expected CaracteristicaInvalid, got {err:?}"
15523 );
15524 }
15525
15526 #[test]
15527 fn validate_rejects_caracteristica_with_leading_dot() {
15528 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15529 // a legitimate continuation character (version-suffix shapes
15530 // like `feat.v2` pass) but the leading-dot form is the
15531 // canonical dotted-version-suffix-as-feature-name confusion.
15532 let d = dep_with_features(&[".feat"]);
15533 let err = d.validate().unwrap_err();
15534 assert!(matches!(
15535 err,
15536 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15537 ));
15538 }
15539
15540 #[test]
15541 fn validate_rejects_caracteristica_with_whitespace() {
15542 // Fail-before-pass-after pin on the embedded-whitespace footgun:
15543 // a feature name with a space inside is structurally a multi-
15544 // token blob (the canonical paste-from-doc footgun, or an
15545 // accidental `"http server"` where the author meant
15546 // `"http-server"`).
15547 let d = dep_with_features(&["http feature"]);
15548 let err = d.validate().unwrap_err();
15549 assert!(matches!(
15550 err,
15551 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15552 ));
15553 }
15554
15555 #[test]
15556 fn validate_rejects_caracteristica_with_comma() {
15557 // Fail-before-pass-after pin on the embedded-comma footgun:
15558 // the list-separator-belongs-to-the-list-grammar
15559 // miscomprehension where the author writes
15560 // `:caracteristicas ("http,json")` intending two features but
15561 // the `Vec<String>` field consumes the bare token as one entry.
15562 let d = dep_with_features(&["http,json"]);
15563 let err = d.validate().unwrap_err();
15564 assert!(matches!(
15565 err,
15566 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15567 ));
15568 }
15569
15570 #[test]
15571 fn validate_rejects_caracteristica_with_slash() {
15572 // Fail-before-pass-after pin on the embedded-slash footgun:
15573 // Cargo's `dep/feat` namespaced-dep syntax applies inside
15574 // `[dependencies.<dep>.features]` list entries that already
15575 // name the parent dep (so the syntax says "enable feature
15576 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15577 // per-dep already (a sibling slot on the `Dep` itself), so the
15578 // segment separator within an entry must be `-`, `_`, `+`,
15579 // or `.`. The diagnostic remediation points at the canonical
15580 // Cargo namespaced-dep discipline.
15581 let d = dep_with_features(&["http/json"]);
15582 let err = d.validate().unwrap_err();
15583 assert!(matches!(
15584 err,
15585 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15586 ));
15587 }
15588
15589 #[test]
15590 fn validate_rejects_caracteristica_with_non_ascii() {
15591 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15592 // byte footgun: NFC-vs-NFD normalization across filesystems
15593 // silently rewrites the feature-key, breaking the lacre's
15594 // content-addressing invariant. Pinned at a canonical
15595 // smart-quote-paste shape (`café`) where the raw `é` byte is the
15596 // documented APFS round-trip break.
15597 let d = dep_with_features(&["caf\u{e9}"]);
15598 let err = d.validate().unwrap_err();
15599 assert!(matches!(
15600 err,
15601 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15602 ));
15603 }
15604
15605 #[test]
15606 fn validate_rejects_caracteristica_with_control_character() {
15607 // Fail-before-pass-after pin on the embedded-control-character
15608 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15609 // feature name is the canonical paste-from-multiline-doc
15610 // footgun the predicate's reason wording specifically calls out.
15611 let d = dep_with_features(&["http\njson"]);
15612 let err = d.validate().unwrap_err();
15613 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15614 }
15615
15616 #[test]
15617 fn validate_accepts_canonical_caracteristicas_shapes() {
15618 // Positive control sweep: every canonical Cargo feature name
15619 // shape the pleme-io ecosystem uses must still pass. Mirrors
15620 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15621 // sweep — drift between either landing site and the predicate's
15622 // accepted set is a build error visible at this pair of tests,
15623 // not a per-renderer "this passed validate but failed at
15624 // cargo metadata time" surprise on the next acceptance.
15625 for s in [
15626 "http",
15627 "json",
15628 "derive",
15629 "serde_json",
15630 "runtime-tokio",
15631 "tokio.full",
15632 "v0.1",
15633 "http+json",
15634 "_internal",
15635 "__private",
15636 "default",
15637 "rt-multi-thread",
15638 "feat.v2",
15639 ] {
15640 let d = dep_with_features(&[s]);
15641 d.validate().unwrap_or_else(|e| {
15642 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15643 });
15644 }
15645 }
15646
15647 #[test]
15648 fn validate_caracteristica_empty_fires_before_invalid() {
15649 // Cascade precedence pin: an entry list with both an empty
15650 // feature AND an invalid-shape feature surfaces the
15651 // `CaracteristicaEmpty` arm first (the empty value carries no
15652 // self-locating data — `caracteristica: ""` is the diagnostic
15653 // with no way to anchor a grep target — so closing the empty
15654 // axis first preserves the per-entry-shape diagnostic's
15655 // self-locating discipline). Same empty-first cascade every
15656 // peer per-entry shape gate establishes
15657 // (`SupervisorSpec::validate`'s `EmptyChildName` before
15658 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15659 // before `MembroCaixaInvalid`).
15660 let d = dep_with_features(&["", "+http"]);
15661 assert!(matches!(
15662 d.validate().unwrap_err(),
15663 DepError::CaracteristicaEmpty { .. }
15664 ));
15665 }
15666
15667 #[test]
15668 fn validate_caracteristica_invalid_fires_before_duplicate() {
15669 // Per-entry-shape precedence pin: an entry list with the same
15670 // invalid feature shape declared twice surfaces the
15671 // `CaracteristicaInvalid` diagnostic on the first entry, not
15672 // the `CaracteristicaDuplicate` on the second collision. The
15673 // per-entry shape gate fires before the cross-entry set gate
15674 // — same precedence shape every peer two-arm-plus-set gate
15675 // establishes (`SupervisorSpec::validate`'s
15676 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15677 // `validate_membros`'s `MembroCaixaInvalid` before
15678 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15679 // cross-list `DuplicateNome`).
15680 let d = dep_with_features(&["+http", "+http"]);
15681 assert!(matches!(
15682 d.validate().unwrap_err(),
15683 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15684 ));
15685 }
15686
15687 #[test]
15688 fn validate_rejects_caracteristica_at_65_byte_boundary() {
15689 // Boundary pin on the 64-byte cap — both the boundary-accepting
15690 // case and the boundary-exceeding case in one place, so a
15691 // future cap shift surfaces both arms simultaneously, mirroring
15692 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15693 // predicate-level pin at the dep-axis landing site.
15694 let max_ok = "a".repeat(64);
15695 dep_with_features(&[&max_ok])
15696 .validate()
15697 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15698 let too_long = "a".repeat(65);
15699 let d = dep_with_features(&[&too_long]);
15700 assert!(matches!(
15701 d.validate().unwrap_err(),
15702 DepError::CaracteristicaInvalid { .. }
15703 ));
15704 }
15705
15706 // ── self-dep cross-slot gate ─────────────────────────────────────
15707
15708 #[test]
15709 fn validate_no_self_dep_rejects_self_in_deps() {
15710 // A caixa whose `:deps` lists its own `:nome` is a one-node
15711 // cycle in the lacre closure's dep-graph traversal — rejected,
15712 // naming the parent and the offending list tag.
15713 let deps = vec![
15714 Dep::simple("caixa-teia", "^0.1"),
15715 Dep::simple("orquestra", "^0.1"),
15716 ];
15717 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15718 assert!(
15719 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15720 "got {err:?}"
15721 );
15722 }
15723
15724 #[test]
15725 fn validate_no_self_dep_rejects_self_in_deps_dev() {
15726 // Same gate on the `:deps-dev` axis — neither dep list is a
15727 // second-class citizen on the self-edge invariant.
15728 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15729 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15730 assert!(
15731 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15732 "got {err:?}"
15733 );
15734 }
15735
15736 #[test]
15737 fn validate_no_self_dep_deps_fires_before_deps_dev() {
15738 // Walk order pin: a caixa that self-references on both lists
15739 // surfaces the `:deps` arm first — the load-bearing axis the
15740 // lacre closure resolves at every build. Mirrors the canonical
15741 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15742 let deps = vec![Dep::simple("orquestra", "^0.1")];
15743 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15744 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15745 assert!(
15746 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15747 "got {err:?}"
15748 );
15749 }
15750
15751 #[test]
15752 fn validate_no_self_dep_accepts_distinct_names() {
15753 // Positive control: every dep names a distinct caixa. The
15754 // canonical author surface — peer of
15755 // [`validate_no_self_supervision_accepts_distinct_children`].
15756 let deps = vec![
15757 Dep::simple("caixa-teia", "^0.1"),
15758 Dep::simple("caixa-arch", "^0.1"),
15759 ];
15760 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15761 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15762 }
15763
15764 #[test]
15765 fn validate_no_self_dep_empty_lists_pass() {
15766 // A caixa with no declared deps has nothing to self-reference —
15767 // the gate is vacuously satisfied. Peer of
15768 // [`validate_no_self_supervision_empty_children_is_ok`].
15769 validate_no_self_dep(&[], &[], "orquestra").unwrap();
15770 }
15771
15772 #[test]
15773 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15774 // Diagnostic-shape pin (peer with
15775 // [`validate_no_self_supervision`]'s diagnostic): the error's
15776 // Display surfaces both the offending list tag and the
15777 // parent's `:nome` verbatim, so the author can grep their
15778 // caixa.lisp for the offending block in one edit. Names
15779 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15780 // surface — every legitimate "I want to use code from this
15781 // caixa" intent routes through one of those three slots.
15782 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15783 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15784 .unwrap_err()
15785 .to_string();
15786 assert!(
15787 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15788 "diagnostic must name the offending list tag: {rendered}",
15789 );
15790 assert!(
15791 rendered.contains("orquestra"),
15792 "diagnostic must quote the parent caixa name: {rendered}",
15793 );
15794 assert!(
15795 rendered.contains(":bibliotecas"),
15796 "diagnostic must point at the corrective code-surface slot: {rendered}",
15797 );
15798 }
15799
15800 #[test]
15801 fn validate_no_self_dep_accepts_coincidental_substring_match() {
15802 // Identity is exact-string equality, not substring — a dep
15803 // named `"orquestra-helper"` is a distinct caixa even when the
15804 // parent is `"orquestra"`. Pin the exact-match discipline so a
15805 // future relaxation that uses `contains` surfaces here, peer
15806 // with the supervision-tree and Aplicacao-membership gates
15807 // which all use exact-string equality on the typed identity.
15808 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15809 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15810 }
15811
15812 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15813
15814 #[test]
15815 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15816 // Scalar-value pin: the two author-facing kebab-case labels the
15817 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15818 // the two-list dep-graph slot axis, one arm per typed slot.
15819 // Mirrors the peer scalar-value pin the sibling
15820 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15821 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15822 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15823 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15824 // (882f498) M3 top-level author-labels, and
15825 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15826 // Supervisor top-level author-labels carry, so every kind-scoped
15827 // typed-slot-family axis routes through one canonical per-arm
15828 // declaration.
15829 //
15830 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15831 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15832 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15833 // for symmetry) lands as an edit to exactly one const, and
15834 // every consumer that reaches for the label picks it up at
15835 // build time rather than at runtime as a downstream mismatch on
15836 // a `DepError::DuplicateNome { list: … }` diagnostic far from
15837 // the rename's commit.
15838 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15839 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15840 }
15841
15842 #[test]
15843 fn dep_author_key_consts_are_pairwise_distinct() {
15844 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15845 // must not collapse onto one byte-string. A future copy-paste
15846 // slip that renamed both consts to the same value (or a rebrand
15847 // that dropped the `-dev` suffix from one but not the other)
15848 // would leave every `DepError::DuplicateNome { list: … }`
15849 // diagnostic naming an unattributable list — the linter would
15850 // route the author to the wrong caixa.lisp block, or the
15851 // cross-list precedence gate
15852 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
15853 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
15854 // duplicate. Peer of the sibling
15855 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
15856 // other top-level kind-scoped slot-family axes carry
15857 // (implicitly held by their different byte-values today).
15858 assert_ne!(
15859 crate::render::DEP_AUTHOR_KEY_DEPS,
15860 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
15861 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
15862 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
15863 self-locates the offending block in the author's caixa.lisp",
15864 );
15865 }
15866
15867 #[test]
15868 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
15869 // Production-through-const pin: the two per-arm list tags
15870 // [`validate_no_self_dep`] threads onto the `list:` field of a
15871 // returned [`DepError::DepIsSelf`] route through the lifted
15872 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
15873 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
15874 // the walker (a rename that reaches one arm but not the const,
15875 // or vice versa) surfaces here at build time rather than at
15876 // runtime as a `feira lint` diagnostic naming the wrong list
15877 // tag. Mirror of the peer
15878 // [`crate::Caixa::declared_servico_slots`] production tagger
15879 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
15880 // onto the two-list dep-graph gate.
15881 let deps = vec![Dep::simple("orquestra", "^0.1")];
15882 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15883 let DepError::DepIsSelf { list, .. } = err else {
15884 panic!("expected DepIsSelf from :deps walk");
15885 };
15886 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
15887
15888 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15889 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15890 let DepError::DepIsSelf { list, .. } = err else {
15891 panic!("expected DepIsSelf from :deps-dev walk");
15892 };
15893 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
15894 }
15895
15896 // ── Dep::nome accessor pins ───────────────────────────────────────
15897 //
15898 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
15899 // projection over the plain-shorthand / explicit-git / explicit-path
15900 // fixture triad the [`Dep`] docstring lists (so the accessor's
15901 // accept-set is exercised across every author-surface `:fonte`
15902 // shape); by-borrow pointer identity so the projection stays
15903 // zero-copy at every consumer site; and validate-composition through
15904 // the [`validate_no_self_dep`] cross-slot gate reading its
15905 // parent-name equality check through the lifted accessor rather than
15906 // the raw field.
15907
15908 #[test]
15909 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
15910 // Plain-shorthand form (`:fonte None`).
15911 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
15912 // Explicit git-source form with a tag pin — same accessor path.
15913 assert_eq!(
15914 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
15915 "caixa-teia",
15916 );
15917 // Explicit path-source form.
15918 assert_eq!(
15919 Dep {
15920 nome: "caixa-teia".to_string(),
15921 versao: "0.1.0".to_string(),
15922 fonte: Some(DepSource::Path {
15923 caminho: "../caixa-teia".to_string(),
15924 }),
15925 opcional: false,
15926 caracteristicas: Vec::new(),
15927 }
15928 .nome(),
15929 "caixa-teia",
15930 );
15931 // The empty-string `:nome` sentinel (which [`Dep::validate`]
15932 // refuses through the [`DepError::NomeEmpty`] arm) still round-
15933 // trips as an empty `&str` through the accessor — the accessor is
15934 // a projection, not a gate; the gate is [`Dep::validate`].
15935 assert_eq!(Dep::simple("", "^0.1").nome(), "");
15936 }
15937
15938 #[test]
15939 fn dep_nome_is_by_borrow_pointer_identity() {
15940 // Zero-copy pin: the accessor must borrow into the field's own
15941 // storage, not clone. If a future rewrite regresses to
15942 // `self.nome.clone().leak()` or an owned-buffer shape, the two
15943 // pointers diverge and this pin fails at build time.
15944 let d = Dep::simple("caixa-teia", "^0.1");
15945 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
15946 }
15947
15948 // ── Dep::versao_requirement accessor pins ─────────────────────────
15949 //
15950 // Three coherence pins on the lifted `Dep::versao_requirement`
15951 // accessor: byte-equal projection over the plain-shorthand /
15952 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
15953 // lists plus the empty-sentinel that round-trips as `""` (the accessor
15954 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
15955 // borrow pointer identity so the projection stays zero-copy at every
15956 // consumer site; and validate-composition through the
15957 // [`crate::render::require_valid_versao_requirement`] cascade reading
15958 // its requirement-shape check through the lifted accessor rather than
15959 // the raw field.
15960 #[test]
15961 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
15962 // Plain-shorthand form (`:fonte None`).
15963 assert_eq!(
15964 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
15965 "^0.1",
15966 );
15967 // Explicit git-source form with a tag pin — same accessor path.
15968 assert_eq!(
15969 Dep::git(
15970 "caixa-teia",
15971 "~0.1.2",
15972 "github:pleme-io/caixa-teia",
15973 "v0.1.0"
15974 )
15975 .versao_requirement(),
15976 "~0.1.2",
15977 );
15978 // Explicit path-source form.
15979 assert_eq!(
15980 Dep {
15981 nome: "caixa-teia".to_string(),
15982 versao: "0.1.0".to_string(),
15983 fonte: Some(DepSource::Path {
15984 caminho: "../caixa-teia".to_string(),
15985 }),
15986 opcional: false,
15987 caracteristicas: Vec::new(),
15988 }
15989 .versao_requirement(),
15990 "0.1.0",
15991 );
15992 // The wildcard requirement (`"*"`) — the shorthand
15993 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
15994 // verbatim through the accessor as `"*"`, same byte-shape the
15995 // author wrote.
15996 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
15997 // The empty-string `:versao` sentinel (which [`Dep::validate`]
15998 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
15999 // trips as an empty `&str` through the accessor — the accessor is
16000 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16001 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16002 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16003 }
16004
16005 #[test]
16006 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16007 // Zero-copy pin: the accessor must borrow into the field's own
16008 // storage, not clone. If a future rewrite regresses to
16009 // `self.versao.clone().leak()` or an owned-buffer shape, the two
16010 // pointers diverge and this pin fails at build time. Peer of the
16011 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16012 // discipline extended onto the requirement-carrying axis.
16013 let d = Dep::simple("caixa-teia", "^0.1");
16014 assert!(std::ptr::eq(
16015 d.versao_requirement().as_ptr(),
16016 d.versao.as_ptr(),
16017 ));
16018 }
16019
16020 #[test]
16021 fn dep_validate_reads_requirement_through_accessor() {
16022 // Composition pin: the [`Dep::validate`]
16023 // [`crate::render::require_valid_versao_requirement`] cascade
16024 // consumes the requirement string through the lifted accessor —
16025 // both the requirement-gate input and the
16026 // [`DepError::VersaoInvalid`] error-body carrier route through
16027 // `self.versao_requirement()`. A valid requirement passes
16028 // (positive control); a malformed-but-non-empty requirement fails
16029 // and the diagnostic quotes the offending byte-string verbatim
16030 // (same shape the accessor projects), so a future regression that
16031 // detoured the requirement carrier through a different byte-
16032 // string (say the parsed `VersionReq`'s `Display`, or a
16033 // normalized rewrite) would surface here at build time. The
16034 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16035 // ahead of the parse arm, pinning the empty-first cascade the
16036 // accessor's `""` sentinel round-trip acknowledges.
16037 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16038 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16039 assert!(
16040 matches!(
16041 &err,
16042 DepError::VersaoInvalid {
16043 nome,
16044 versao,
16045 ..
16046 } if nome == "caixa-teia" && versao == "v0.1",
16047 ),
16048 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16049 );
16050 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16051 assert!(
16052 matches!(
16053 &err,
16054 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16055 ),
16056 "expected VersaoEmpty from the empty-first arm, got {err:?}",
16057 );
16058 }
16059
16060 // ── Dep::fonte accessor pins ──────────────────────────────────────
16061 //
16062 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16063 // equal projection over the plain-shorthand (`:fonte None`) /
16064 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16065 // docstring lists (so the accessor's accept-set is exercised across
16066 // every author-surface `:fonte` shape and both `DepSource` variants);
16067 // pointer identity so the borrowed reference points into the field's
16068 // own `Option<DepSource>` storage (not a cloned side-buffer); and
16069 // validate-composition through the [`Dep::validate`] gate reading
16070 // its per-`:fonte` [`DepSource::validate`] delegation through the
16071 // lifted accessor rather than the raw `if let Some(ref fonte) =
16072 // self.fonte` bracket.
16073
16074 #[test]
16075 fn dep_fonte_returns_declared_source_across_shapes() {
16076 // Plain-shorthand form — `:fonte` omitted, accessor projects
16077 // the `None` partition the resolver-side default-fill treats
16078 // as "resolve through `github:<default-org>/<nome>`".
16079 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16080 // Explicit git-source form with a tag pin — same accessor path.
16081 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16082 match git.fonte() {
16083 Some(DepSource::Git {
16084 repo,
16085 tag,
16086 rev,
16087 branch,
16088 }) => {
16089 assert_eq!(repo, "github:pleme-io/caixa-teia");
16090 assert_eq!(tag.as_deref(), Some("v0.1.0"));
16091 assert!(rev.is_none());
16092 assert!(branch.is_none());
16093 }
16094 other => panic!("expected explicit git :fonte, got {other:?}"),
16095 }
16096 // Explicit path-source form — the dev-only local-filesystem
16097 // arm the [`Dep`] docstring's third fixture carries.
16098 let path = Dep {
16099 nome: "caixa-teia".to_string(),
16100 versao: "0.1.0".to_string(),
16101 fonte: Some(DepSource::Path {
16102 caminho: "../caixa-teia".to_string(),
16103 }),
16104 opcional: false,
16105 caracteristicas: Vec::new(),
16106 };
16107 match path.fonte() {
16108 Some(DepSource::Path { caminho }) => {
16109 assert_eq!(caminho, "../caixa-teia");
16110 }
16111 other => panic!("expected explicit path :fonte, got {other:?}"),
16112 }
16113 }
16114
16115 #[test]
16116 fn dep_fonte_is_by_borrow_pointer_identity() {
16117 // Zero-copy pin: the accessor must borrow into the field's own
16118 // `Option<DepSource>` storage, not clone into a side buffer. If
16119 // a future rewrite regresses to `self.fonte.clone()` or an
16120 // owned-buffer shape, the two pointers diverge and this pin
16121 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16122 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16123 // identity pins — same by-borrow discipline extended onto the
16124 // outer-`Dep` `Option<&Composite>` composite-reference axis.
16125 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16126 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16127 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16128 assert!(std::ptr::eq(accessed, raw));
16129 }
16130
16131 #[test]
16132 fn dep_validate_reads_fonte_through_accessor() {
16133 // Composition pin: [`Dep::validate`]'s per-`:fonte`
16134 // [`DepSource::validate`] delegation consumes the typed slot
16135 // through the lifted accessor — an author-omitted `:fonte`
16136 // still passes the outer gate (positive control), an explicit
16137 // well-formed git source with exactly one pin passes, and a
16138 // malformed git source (empty `:repo`) surfaces the
16139 // [`DepError::FonteRepoEmpty`] variant quoting the offending
16140 // dep's `:nome` verbatim so a future regression that detoured
16141 // the `:fonte` delegation through a different path (say a
16142 // per-scope override projector) would surface here at build
16143 // time. Peer of the sibling
16144 // `dep_validate_reads_requirement_through_accessor` composition
16145 // pin on the `:versao` axis.
16146 // Positive control 1: no `:fonte` at all.
16147 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16148 // Positive control 2: well-formed git source.
16149 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16150 .validate()
16151 .unwrap();
16152 // Negative control: empty `:repo` — the accessor still returns
16153 // `Some(&DepSource::Git { repo: "", … })` and the delegated
16154 // `DepSource::validate` gate raises the typed carrier.
16155 let bad = Dep {
16156 nome: "caixa-teia".to_string(),
16157 versao: "^0.1".to_string(),
16158 fonte: Some(DepSource::Git {
16159 repo: String::new(),
16160 tag: Some("v0.1.0".to_string()),
16161 rev: None,
16162 branch: None,
16163 }),
16164 opcional: false,
16165 caracteristicas: Vec::new(),
16166 };
16167 let err = bad.validate().unwrap_err();
16168 assert!(
16169 matches!(
16170 &err,
16171 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16172 ),
16173 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16174 );
16175 }
16176
16177 #[test]
16178 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16179 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16180 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16181 // own `:nome` through the lifted accessor rather than the raw
16182 // field. Fails-before-passes-after: with the accessor lifted the
16183 // gate reads its equality check through `dep.nome() ==
16184 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16185 // the diagnostic still names the offending list tag as expected.
16186 let deps = vec![Dep::simple("orquestra", "^0.1")];
16187 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16188 assert!(matches!(
16189 err,
16190 DepError::DepIsSelf {
16191 ref nome,
16192 list,
16193 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16194 ));
16195 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16196 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16197 assert!(matches!(
16198 err,
16199 DepError::DepIsSelf {
16200 ref nome,
16201 list,
16202 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16203 ));
16204 // A non-matching `:nome` passes through the accessor gate.
16205 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16206 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16207 }
16208
16209 // ── Dep::caracteristicas accessor pins ────────────────────────────
16210 //
16211 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16212 // byte-equal projection over the default-empty / single-entry /
16213 // multi-entry fixture triad (so the accessor's accept-set is
16214 // exercised across every author-surface `:caracteristicas` shape,
16215 // matching the peer sibling family's fixture-triad discipline); by-
16216 // borrow pointer identity so the projection stays zero-copy at every
16217 // consumer site; and validate-composition through the
16218 // [`Dep::validate_caracteristicas`] gate reading its per-entry
16219 // linear walk through the lifted accessor rather than the raw
16220 // `for c in &self.caracteristicas` bracket.
16221
16222 #[test]
16223 fn dep_caracteristicas_returns_declared_features_across_shapes() {
16224 // Default-empty form — the [`Dep::simple`] constructor's
16225 // `Vec::new()` fill; the accessor projects the empty slice
16226 // verbatim (no `None` collapse).
16227 assert!(
16228 Dep::simple("caixa-teia", "^0.1")
16229 .caracteristicas()
16230 .is_empty(),
16231 );
16232 // Single-entry form — the canonical Cargo-shaped one-feature
16233 // enable ([`crate::render::is_cargo_feature_name`] accepts the
16234 // `"http"` byte-string as a valid feature name).
16235 let one = Dep {
16236 nome: "caixa-teia".to_string(),
16237 versao: "^0.1".to_string(),
16238 fonte: None,
16239 opcional: false,
16240 caracteristicas: vec!["http".to_string()],
16241 };
16242 assert_eq!(one.caracteristicas(), &["http".to_string()]);
16243 // Multi-entry form — the substrate's set-shaped multi-feature
16244 // enable, exercising the accessor over a length-two slice with
16245 // no duplicate collapse.
16246 let two = Dep {
16247 nome: "caixa-teia".to_string(),
16248 versao: "^0.1".to_string(),
16249 fonte: None,
16250 opcional: false,
16251 caracteristicas: vec!["http".to_string(), "json".to_string()],
16252 };
16253 assert_eq!(
16254 two.caracteristicas(),
16255 &["http".to_string(), "json".to_string()],
16256 );
16257 }
16258
16259 #[test]
16260 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16261 // Zero-copy pin: the accessor must borrow into the field's own
16262 // `Vec<String>` storage, not clone into a side buffer. If a
16263 // future rewrite regresses to `self.caracteristicas.clone()` or
16264 // an owned-buffer shape, the two pointers diverge and this pin
16265 // fails at build time. Peer of the sibling per-`Dep`
16266 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16267 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16268 // borrow discipline extended onto the outer-`Dep` `&[String]`
16269 // slice-projection axis.
16270 let d = Dep {
16271 nome: "caixa-teia".to_string(),
16272 versao: "^0.1".to_string(),
16273 fonte: None,
16274 opcional: false,
16275 caracteristicas: vec!["http".to_string(), "json".to_string()],
16276 };
16277 assert!(std::ptr::eq(
16278 d.caracteristicas().as_ptr(),
16279 d.caracteristicas.as_ptr(),
16280 ));
16281 }
16282
16283 #[test]
16284 fn dep_validate_reads_caracteristicas_through_accessor() {
16285 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16286 // linear walk consumes the feature-toggle list through the
16287 // lifted accessor — a well-formed `:caracteristicas` set passes
16288 // (positive control), an empty-string entry surfaces the
16289 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16290 // `Dep::nome`, and a within-list duplicate surfaces the
16291 // [`DepError::CaracteristicaDuplicate`] variant so a future
16292 // regression that detoured the walk through a different byte-
16293 // string list (say a per-scope override projector) would surface
16294 // here at build time. Peer of the sibling
16295 // `dep_validate_reads_fonte_through_accessor` /
16296 // `dep_validate_reads_requirement_through_accessor` composition
16297 // pins on the `:fonte` / `:versao` axes.
16298 // Positive control: two distinct well-formed feature names pass.
16299 Dep {
16300 nome: "caixa-teia".to_string(),
16301 versao: "^0.1".to_string(),
16302 fonte: None,
16303 opcional: false,
16304 caracteristicas: vec!["http".to_string(), "json".to_string()],
16305 }
16306 .validate()
16307 .unwrap();
16308 // Negative control 1: empty-string feature-name entry — the
16309 // accessor still returns `&[""]` and the walk raises the typed
16310 // empty-first carrier.
16311 let err = Dep {
16312 nome: "caixa-teia".to_string(),
16313 versao: "^0.1".to_string(),
16314 fonte: None,
16315 opcional: false,
16316 caracteristicas: vec![String::new()],
16317 }
16318 .validate()
16319 .unwrap_err();
16320 assert!(
16321 matches!(
16322 &err,
16323 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16324 ),
16325 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16326 );
16327 // Negative control 2: within-list duplicate — the accessor's
16328 // slice view carries both entries, and the walk's dedup arm
16329 // raises the typed duplicate carrier quoting the offending
16330 // feature name verbatim.
16331 let err = Dep {
16332 nome: "caixa-teia".to_string(),
16333 versao: "^0.1".to_string(),
16334 fonte: None,
16335 opcional: false,
16336 caracteristicas: vec!["http".to_string(), "http".to_string()],
16337 }
16338 .validate()
16339 .unwrap_err();
16340 assert!(
16341 matches!(
16342 &err,
16343 DepError::CaracteristicaDuplicate {
16344 nome,
16345 caracteristica,
16346 } if nome == "caixa-teia" && caracteristica == "http",
16347 ),
16348 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16349 );
16350 }
16351
16352 // ── Dep::opcional accessor pins ───────────────────────────────────
16353 //
16354 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16355 // equal projection over the default-`false` / explicit-`true`
16356 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16357 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16358 // exercising the accessor's accept-set over every author-surface
16359 // `:fonte` shape × every author-surface `:opcional` shape; and by-
16360 // `Copy` idempotency so the projection stays value-return (no
16361 // silent detour to a fresh `&bool` borrow that would introduce a
16362 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16363 // shape elides). No composition pin — `:opcional` does not
16364 // participate in [`Dep::validate`] (an opcional dep with any bool
16365 // value is validate-accepted; the missing-source arm is a resolver-
16366 // side runtime dispatch, not a build-time refusal), so the axis
16367 // reduces to the value-shape + `Copy` pin pair the peer
16368 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16369 // outer-`Option<Copy>` accessor pins already carry.
16370
16371 #[test]
16372 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16373 // Default-`false` form via the [`Dep::simple`] constructor —
16374 // the accessor projects the `false` bit the default-fill sets.
16375 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16376 // Default-`false` form via the [`Dep::git`] constructor — same
16377 // default fill; the accessor projects `false` regardless of the
16378 // `:fonte` arm.
16379 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16380 // Explicit-`true` form × plain-shorthand `:fonte` — the
16381 // canonical author-surface "this dep may be missing" shape.
16382 let plain_true = Dep {
16383 nome: "caixa-teia".to_string(),
16384 versao: "^0.1".to_string(),
16385 fonte: None,
16386 opcional: true,
16387 caracteristicas: Vec::new(),
16388 };
16389 assert!(plain_true.opcional());
16390 // Explicit-`true` form × explicit git-source — the accessor
16391 // projects the bit verbatim regardless of the `:fonte` arm.
16392 let git_true = Dep {
16393 nome: "caixa-teia".to_string(),
16394 versao: "^0.1".to_string(),
16395 fonte: Some(DepSource::Git {
16396 repo: "github:pleme-io/caixa-teia".to_string(),
16397 tag: Some("v0.1.0".to_string()),
16398 rev: None,
16399 branch: None,
16400 }),
16401 opcional: true,
16402 caracteristicas: Vec::new(),
16403 };
16404 assert!(git_true.opcional());
16405 // Explicit-`true` form × explicit path-source — the dev-only
16406 // local-filesystem arm the [`Dep`] docstring's third fixture
16407 // carries.
16408 let path_true = Dep {
16409 nome: "caixa-teia".to_string(),
16410 versao: "0.1.0".to_string(),
16411 fonte: Some(DepSource::Path {
16412 caminho: "../caixa-teia".to_string(),
16413 }),
16414 opcional: true,
16415 caracteristicas: Vec::new(),
16416 };
16417 assert!(path_true.opcional());
16418 }
16419
16420 #[test]
16421 fn dep_opcional_projects_bool_by_copy() {
16422 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16423 // (`bool: Copy`) — the accessor does not borrow `&self` past
16424 // the call (no lifetime on the return type), and calling the
16425 // accessor twice on the same [`Dep`] must yield discriminant-
16426 // equal values (idempotent, no side effects on `&self`). Peer
16427 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16428 // `max_restarts_projects_option_by_copy` (eba5211) /
16429 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16430 // outer-`Caixa` altitude — extended here to the outer-`Dep`
16431 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16432 // replaces the pointer-equality claim the sibling per-`Dep`
16433 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16434 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16435 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16436 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16437 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16438 // the same discriminant, so the axis reduces to discriminant
16439 // equality).
16440 //
16441 // Pins against a future silent detour that returned a fresh
16442 // `&bool` reference (which would type-check but silently
16443 // introduce a borrow of `&self` past the call, collapsing the
16444 // load-bearing "no lifetime on the return type" `Copy`
16445 // projection the plain-`Copy`-scalar axis's `bool` shape
16446 // carries) or a stale-read side effect that flipped the outer
16447 // discriminant on successive calls.
16448 for opcional in [false, true] {
16449 let d = Dep {
16450 nome: "caixa-teia".to_string(),
16451 versao: "^0.1".to_string(),
16452 fonte: None,
16453 opcional,
16454 caracteristicas: Vec::new(),
16455 };
16456 let first = d.opcional();
16457 let second = d.opcional();
16458 assert_eq!(
16459 first, second,
16460 "Dep::opcional must be idempotent — two successive calls \
16461 on the same &self must return the same bool",
16462 );
16463 assert_eq!(
16464 first, opcional,
16465 "Dep::opcional must return :opcional verbatim by Copy — \
16466 got {first}, expected {opcional}",
16467 );
16468 assert_eq!(
16469 d.opcional(),
16470 d.opcional,
16471 "Dep::opcional accessor and self.opcional field access \
16472 must byte-equal — a bit-flip drift would silently split \
16473 the paired resolver-side drop-vs-error dispatch from \
16474 the storage-side default-fill the [`Dep::simple`] / \
16475 [`Dep::git`] constructor pair carries",
16476 );
16477 }
16478 }
16479
16480 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16481
16482 #[test]
16483 fn sole_pin_returns_none_for_path_source() {
16484 // A path source carries no git-ref, so `sole_pin()` returns
16485 // `None` structurally — the sibling arm every git-fetching
16486 // consumer partitions off before reaching for a git-ref. Pins
16487 // the Path-arm branch of the accessor against a future silent
16488 // detour that treats a `Self::Path` as an unpinned-git source
16489 // and returns the wrong "no pin" signal (e.g. the empty string,
16490 // or a hard-coded `Some("HEAD")` matching the caixa-crd
16491 // path-arm `git_ref` fill).
16492 let s = DepSource::Path {
16493 caminho: "../local-caixa".to_string(),
16494 };
16495 assert_eq!(s.sole_pin(), None);
16496 }
16497
16498 #[test]
16499 fn sole_pin_returns_none_for_unpinned_git_source() {
16500 // The [`DepSource::default_github`] shorthand shape carries no
16501 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16502 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16503 // materializes when the author omits `:fonte` entirely, then
16504 // hands to `fetch_git` which raises `ResolveError::MissingPin`
16505 // on the `None` arm — the accessor's return matches the arm
16506 // the resolver's diagnostic keys off.
16507 let s = DepSource::default_github("pleme-io", "caixa-teia");
16508 assert_eq!(s.sole_pin(), None);
16509 }
16510
16511 #[test]
16512 fn sole_pin_returns_rev_when_only_rev_is_set() {
16513 let s = DepSource::Git {
16514 repo: "github:o/x".into(),
16515 tag: None,
16516 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16517 branch: None,
16518 };
16519 assert_eq!(
16520 s.sole_pin(),
16521 Some("deadbeefcafebabe1234567890abcdef12345678")
16522 );
16523 }
16524
16525 #[test]
16526 fn sole_pin_returns_tag_when_only_tag_is_set() {
16527 let s = DepSource::Git {
16528 repo: "github:o/x".into(),
16529 tag: Some("v0.1.0".into()),
16530 rev: None,
16531 branch: None,
16532 };
16533 assert_eq!(s.sole_pin(), Some("v0.1.0"));
16534 }
16535
16536 #[test]
16537 fn sole_pin_returns_branch_when_only_branch_is_set() {
16538 let s = DepSource::Git {
16539 repo: "github:o/x".into(),
16540 tag: None,
16541 rev: None,
16542 branch: Some("main".into()),
16543 };
16544 assert_eq!(s.sole_pin(), Some("main"));
16545 }
16546
16547 #[test]
16548 fn sole_pin_precedence_rev_beats_tag_and_branch() {
16549 // Precedence: rev > tag > branch. Validate() rejects
16550 // multiple-pin shapes, but the accessor's precedence is defined
16551 // for pre-validate consumers (the resolver's `MissingPin`
16552 // diagnostic path, the caixa-crd round-trip's default `"main"`
16553 // fallback) and as defense-in-depth if the gate is ever
16554 // bypassed. Pins the same precedence caixa-resolver's
16555 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16556 // inline.
16557 let s = DepSource::Git {
16558 repo: "github:o/x".into(),
16559 tag: Some("v1".into()),
16560 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16561 branch: Some("main".into()),
16562 };
16563 assert_eq!(
16564 s.sole_pin(),
16565 Some("deadbeefcafebabe1234567890abcdef12345678")
16566 );
16567 }
16568
16569 #[test]
16570 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16571 let s = DepSource::Git {
16572 repo: "github:o/x".into(),
16573 tag: Some("v1".into()),
16574 rev: None,
16575 branch: Some("main".into()),
16576 };
16577 assert_eq!(s.sole_pin(), Some("v1"));
16578 }
16579
16580 #[test]
16581 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16582 // Fail-before-pass-after byte-parity pin: the substrate accessor
16583 // must return byte-identical to the inline
16584 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16585 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16586 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16587 // time if the accessor's precedence silently drifts from the
16588 // consumer-side cascade — the exact drift this lift converges
16589 // to one substrate primitive to close structurally.
16590 //
16591 // Iterates through the 2^3 = 8 combinations of (tag, rev,
16592 // branch) each-either-`None`-or-`Some`, so every arm of the
16593 // precedence cascade lands under the pin. `validate()` refuses
16594 // the 4 multi-pin combinations, but the accessor's return is
16595 // defined on all 8.
16596 let vals = [Some("R".to_string()), None];
16597 for tag in &vals {
16598 for rev in &vals {
16599 for branch in &vals {
16600 let s = DepSource::Git {
16601 repo: "github:o/x".into(),
16602 tag: tag.clone(),
16603 rev: rev.clone(),
16604 branch: branch.clone(),
16605 };
16606 // The exact inline cascade the two pre-lift
16607 // consumer sites hand-rolled, byte-for-byte.
16608 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16609 assert_eq!(
16610 s.sole_pin(),
16611 expected,
16612 "sole_pin() must byte-equal \
16613 rev.or(tag).or(branch) for \
16614 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16615 a drift would silently split caixa-resolver's \
16616 fetch_git checkout target from caixa-crd's \
16617 dep_into_ref git_ref fill",
16618 );
16619 }
16620 }
16621 }
16622 }
16623
16624 // Fail-before-pass-after pins on the eleven
16625 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16626 // constructors folded from the [`DepSource::validate_caminho`]
16627 // wire-up sites. Each pins the generated ctor's output to the
16628 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16629 // any wrapper-side lowercase / trim / re-order / silent-field-swap
16630 // regression on the two-field `{ nome: nome.to_string(), caminho:
16631 // caminho.to_string() }` construction surfaces here rather than at
16632 // a downstream diagnostic-shape mismatch. Peer of the sibling
16633 // `empty_child_version_ctor_matches_struct_literal_wrap` /
16634 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16635 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16636 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16637 // pins on the peer `SupervisorError` / `AplicacaoError` /
16638 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16639
16640 #[test]
16641 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16642 assert_eq!(
16643 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16644 DepError::FonteCaminhoAbsolute {
16645 nome: "caixa-teia".to_string(),
16646 caminho: "/home/me/work/caixa-teia".to_string(),
16647 },
16648 "generated fonte_caminho_absolute ctor must produce byte-equal \
16649 DepError to the open-coded struct-literal wrap on the same \
16650 (&str, &str) fixture",
16651 );
16652 }
16653
16654 #[test]
16655 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16656 assert_eq!(
16657 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16658 DepError::FonteCaminhoTildeExpansion {
16659 nome: "caixa-teia".to_string(),
16660 caminho: "~/work/caixa-teia".to_string(),
16661 },
16662 );
16663 }
16664
16665 #[test]
16666 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16667 assert_eq!(
16668 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16669 DepError::FonteCaminhoVarExpansion {
16670 nome: "caixa-teia".to_string(),
16671 caminho: "$HOME/work/caixa-teia".to_string(),
16672 },
16673 );
16674 }
16675
16676 #[test]
16677 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16678 assert_eq!(
16679 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16680 DepError::FonteCaminhoLeadingWhitespace {
16681 nome: "caixa-teia".to_string(),
16682 caminho: " ../caixa-teia".to_string(),
16683 },
16684 );
16685 }
16686
16687 #[test]
16688 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16689 assert_eq!(
16690 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16691 DepError::FonteCaminhoLeadingHyphen {
16692 nome: "caixa-teia".to_string(),
16693 caminho: "-rf".to_string(),
16694 },
16695 );
16696 }
16697
16698 #[test]
16699 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16700 assert_eq!(
16701 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16702 DepError::FonteCaminhoBackslash {
16703 nome: "caixa-teia".to_string(),
16704 caminho: "..\\caixa-teia".to_string(),
16705 },
16706 );
16707 }
16708
16709 #[test]
16710 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16711 assert_eq!(
16712 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16713 DepError::FonteCaminhoShellPipe {
16714 nome: "caixa-teia".to_string(),
16715 caminho: "../caixa-teia|evil".to_string(),
16716 },
16717 );
16718 }
16719
16720 #[test]
16721 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16722 assert_eq!(
16723 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16724 DepError::FonteCaminhoShellSemicolon {
16725 nome: "caixa-teia".to_string(),
16726 caminho: "../caixa-teia;evil".to_string(),
16727 },
16728 );
16729 }
16730
16731 #[test]
16732 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16733 assert_eq!(
16734 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16735 DepError::FonteCaminhoShellBackground {
16736 nome: "caixa-teia".to_string(),
16737 caminho: "../caixa-teia&".to_string(),
16738 },
16739 );
16740 }
16741
16742 #[test]
16743 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16744 assert_eq!(
16745 DepError::fonte_caminho_shell_command_substitution(
16746 "caixa-teia",
16747 "../caixa-teia`whoami`",
16748 ),
16749 DepError::FonteCaminhoShellCommandSubstitution {
16750 nome: "caixa-teia".to_string(),
16751 caminho: "../caixa-teia`whoami`".to_string(),
16752 },
16753 );
16754 }
16755
16756 #[test]
16757 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16758 assert_eq!(
16759 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16760 DepError::FonteCaminhoTrailingSlash {
16761 nome: "caixa-teia".to_string(),
16762 caminho: "../caixa-teia/".to_string(),
16763 },
16764 );
16765 }
16766
16767 #[test]
16768 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16769 // Cross-axis pin: sweep the two constructor input axes
16770 // (`nome: &str`, `caminho: &str`) through a non-default fixture
16771 // pair against every generated arm in the
16772 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16773 // / trim / truncate / re-order on the two-field
16774 // `{ nome, caminho }` construction — or a silent field swap
16775 // between the two axes at codegen time — surfaces here rather
16776 // than at a downstream diagnostic-shape mismatch. Peer of the
16777 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16778 // to_string` cross-axis routing pin on the peer
16779 // `SupervisorError` envelope, extended here onto the
16780 // `DepError` `{ nome: String, caminho: String }` envelope so
16781 // every substrate-primitive ctor family in caixa-core
16782 // guarantees each `&str`-field construction routes the
16783 // caller's `&str` verbatim through `.to_string()`.
16784 let nome = "sibling-teia";
16785 let caminho = "../workspace/sibling";
16786 let cases: [(DepError, DepError); 11] = [
16787 (
16788 DepError::fonte_caminho_absolute(nome, caminho),
16789 DepError::FonteCaminhoAbsolute {
16790 nome: nome.to_string(),
16791 caminho: caminho.to_string(),
16792 },
16793 ),
16794 (
16795 DepError::fonte_caminho_tilde_expansion(nome, caminho),
16796 DepError::FonteCaminhoTildeExpansion {
16797 nome: nome.to_string(),
16798 caminho: caminho.to_string(),
16799 },
16800 ),
16801 (
16802 DepError::fonte_caminho_var_expansion(nome, caminho),
16803 DepError::FonteCaminhoVarExpansion {
16804 nome: nome.to_string(),
16805 caminho: caminho.to_string(),
16806 },
16807 ),
16808 (
16809 DepError::fonte_caminho_leading_whitespace(nome, caminho),
16810 DepError::FonteCaminhoLeadingWhitespace {
16811 nome: nome.to_string(),
16812 caminho: caminho.to_string(),
16813 },
16814 ),
16815 (
16816 DepError::fonte_caminho_leading_hyphen(nome, caminho),
16817 DepError::FonteCaminhoLeadingHyphen {
16818 nome: nome.to_string(),
16819 caminho: caminho.to_string(),
16820 },
16821 ),
16822 (
16823 DepError::fonte_caminho_backslash(nome, caminho),
16824 DepError::FonteCaminhoBackslash {
16825 nome: nome.to_string(),
16826 caminho: caminho.to_string(),
16827 },
16828 ),
16829 (
16830 DepError::fonte_caminho_shell_pipe(nome, caminho),
16831 DepError::FonteCaminhoShellPipe {
16832 nome: nome.to_string(),
16833 caminho: caminho.to_string(),
16834 },
16835 ),
16836 (
16837 DepError::fonte_caminho_shell_semicolon(nome, caminho),
16838 DepError::FonteCaminhoShellSemicolon {
16839 nome: nome.to_string(),
16840 caminho: caminho.to_string(),
16841 },
16842 ),
16843 (
16844 DepError::fonte_caminho_shell_background(nome, caminho),
16845 DepError::FonteCaminhoShellBackground {
16846 nome: nome.to_string(),
16847 caminho: caminho.to_string(),
16848 },
16849 ),
16850 (
16851 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
16852 DepError::FonteCaminhoShellCommandSubstitution {
16853 nome: nome.to_string(),
16854 caminho: caminho.to_string(),
16855 },
16856 ),
16857 (
16858 DepError::fonte_caminho_trailing_slash(nome, caminho),
16859 DepError::FonteCaminhoTrailingSlash {
16860 nome: nome.to_string(),
16861 caminho: caminho.to_string(),
16862 },
16863 ),
16864 ];
16865 for (via_ctor, via_struct_literal) in cases {
16866 assert_eq!(
16867 via_ctor, via_struct_literal,
16868 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
16869 through `.to_string()` in declared field order — a field-swap or \
16870 silent-conversion regression surfaces here rather than at a \
16871 downstream diagnostic-shape mismatch",
16872 );
16873 }
16874 }
16875
16876 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
16877 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
16878 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
16879 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
16880 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
16881
16882 #[test]
16883 fn versao_empty_ctor_matches_struct_literal_wrap() {
16884 assert_eq!(
16885 DepError::versao_empty("caixa-teia"),
16886 DepError::VersaoEmpty {
16887 nome: "caixa-teia".to_string(),
16888 },
16889 );
16890 }
16891
16892 #[test]
16893 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
16894 assert_eq!(
16895 DepError::fonte_repo_empty("caixa-teia"),
16896 DepError::FonteRepoEmpty {
16897 nome: "caixa-teia".to_string(),
16898 },
16899 );
16900 }
16901
16902 #[test]
16903 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
16904 assert_eq!(
16905 DepError::fonte_pin_missing("caixa-teia"),
16906 DepError::FontePinMissing {
16907 nome: "caixa-teia".to_string(),
16908 },
16909 );
16910 }
16911
16912 #[test]
16913 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
16914 assert_eq!(
16915 DepError::fonte_caminho_empty("caixa-teia"),
16916 DepError::FonteCaminhoEmpty {
16917 nome: "caixa-teia".to_string(),
16918 },
16919 );
16920 }
16921
16922 #[test]
16923 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
16924 assert_eq!(
16925 DepError::caracteristica_empty("caixa-teia"),
16926 DepError::CaracteristicaEmpty {
16927 nome: "caixa-teia".to_string(),
16928 },
16929 );
16930 }
16931
16932 #[test]
16933 fn dep_nome_only_ctors_route_nome_through_to_string() {
16934 // Cross-axis routing pin: sweep the single constructor input
16935 // axis (`nome: &str`) through a non-default fixture against
16936 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
16937 // any wrapper-side lowercase / trim / truncate at codegen time
16938 // — or a silent field re-name away from the canonical `nome`
16939 // axis on any one variant — surfaces here rather than at a
16940 // downstream diagnostic-shape mismatch. Peer of the sibling
16941 // `fonte_caminho_ctors_route_nome_and_caminho_through_
16942 // to_string` cross-axis routing pin on the same envelope's
16943 // two-slot family (f85f145) and of the peer
16944 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
16945 // pin on the `SupervisorError` single-slot family (db09650).
16946 let nome = "sibling-teia";
16947 let cases: [(DepError, DepError); 5] = [
16948 (
16949 DepError::versao_empty(nome),
16950 DepError::VersaoEmpty {
16951 nome: nome.to_string(),
16952 },
16953 ),
16954 (
16955 DepError::fonte_repo_empty(nome),
16956 DepError::FonteRepoEmpty {
16957 nome: nome.to_string(),
16958 },
16959 ),
16960 (
16961 DepError::fonte_pin_missing(nome),
16962 DepError::FontePinMissing {
16963 nome: nome.to_string(),
16964 },
16965 ),
16966 (
16967 DepError::fonte_caminho_empty(nome),
16968 DepError::FonteCaminhoEmpty {
16969 nome: nome.to_string(),
16970 },
16971 ),
16972 (
16973 DepError::caracteristica_empty(nome),
16974 DepError::CaracteristicaEmpty {
16975 nome: nome.to_string(),
16976 },
16977 ),
16978 ];
16979 for (via_ctor, via_struct_literal) in cases {
16980 assert_eq!(
16981 via_ctor, via_struct_literal,
16982 "dep_nome_only_ctors!-generated ctor must route `nome` \
16983 through `.to_string()` onto the canonical `nome` field \
16984 — a field-rename or silent-conversion regression surfaces \
16985 here rather than at a downstream diagnostic-shape mismatch",
16986 );
16987 }
16988 }
16989
16990 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
16991 // &'static str }` two-slot envelope on `DepError`, strict
16992 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
16993 // same envelope's `{ nome: String }` one-slot shape and of the
16994 // peer `supervisor_caixa_only_ctors!` (db09650) on the
16995 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
16996
16997 #[test]
16998 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
16999 assert_eq!(
17000 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17001 DepError::DuplicateNome {
17002 nome: "caixa-teia".to_string(),
17003 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17004 },
17005 "generated duplicate_nome ctor must produce byte-equal \
17006 `DepError::DuplicateNome` to the pre-lift struct-literal \
17007 wrap on the same scalar fixtures",
17008 );
17009 }
17010
17011 #[test]
17012 fn dep_is_self_ctor_matches_struct_literal_wrap() {
17013 assert_eq!(
17014 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17015 DepError::DepIsSelf {
17016 nome: "orquestra".to_string(),
17017 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17018 },
17019 "generated dep_is_self ctor must produce byte-equal \
17020 `DepError::DepIsSelf` to the pre-lift struct-literal \
17021 wrap on the same scalar fixtures",
17022 );
17023 }
17024
17025 #[test]
17026 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17027 // Cross-axis routing pin: sweep the two constructor input axes
17028 // (`nome: &str`, `list: &'static str`) through non-default
17029 // fixtures against every generated arm in the
17030 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17031 // lowercase / trim / truncate at codegen time — or a silent
17032 // field re-name away from the canonical `nome` / `list` axes
17033 // on any one variant, or a `list` axis silently rerouted
17034 // through `.to_string()` instead of passed as `&'static str`
17035 // verbatim — surfaces here rather than at a downstream
17036 // diagnostic-shape mismatch. Peer of the sibling
17037 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17038 // (792aa92) on the same envelope's one-slot family, and of the
17039 // peer
17040 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17041 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17042 // two-slot `{ caixa: String, reason: String }` shape.
17043 let nome = "sibling-teia";
17044 let cases: [(DepError, DepError); 4] = [
17045 (
17046 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17047 DepError::DuplicateNome {
17048 nome: nome.to_string(),
17049 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17050 },
17051 ),
17052 (
17053 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17054 DepError::DuplicateNome {
17055 nome: nome.to_string(),
17056 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17057 },
17058 ),
17059 (
17060 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17061 DepError::DepIsSelf {
17062 nome: nome.to_string(),
17063 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17064 },
17065 ),
17066 (
17067 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17068 DepError::DepIsSelf {
17069 nome: nome.to_string(),
17070 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17071 },
17072 ),
17073 ];
17074 for (via_ctor, via_struct_literal) in cases {
17075 assert_eq!(
17076 via_ctor, via_struct_literal,
17077 "dep_nome_list_ctors!-generated ctor must route `nome` \
17078 through `.to_string()` onto the canonical `nome` field \
17079 and pass `list` verbatim onto the canonical `&'static str` \
17080 `list` field — a field-rename, silent-conversion, or \
17081 axis-swap regression surfaces here rather than at a \
17082 downstream diagnostic-shape mismatch",
17083 );
17084 }
17085 }
17086
17087 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17088 // value: String, reason: String }` four-slot envelope on
17089 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17090 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17091 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17092 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
17093 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
17094 // envelope. Single-variant lift closing the last open-coded ctor
17095 // site on the `:fonte (:tipo git …)` value-shape trajectory.
17096
17097 #[test]
17098 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17099 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17100 // ctor: sweep both wire-up-shape arms (the refname-pin arm
17101 // routing `":tag"` / `":branch"` value through
17102 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17103 // routing `":rev"` through [`crate::render::is_git_oid`]) and
17104 // assert byte-equal `PartialEq` against the pre-lift
17105 // struct-literal, so any wrapper-side field-rename /
17106 // silent-conversion regression surfaces here rather than at a
17107 // downstream diagnostic-shape mismatch. Peer of the sibling
17108 // per-envelope byte-equal ctor pins
17109 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17110 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17111 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17112 assert_eq!(
17113 DepError::fonte_pin_shape(
17114 "caixa-teia",
17115 ":tag",
17116 "v0.1.0 ",
17117 "trailing whitespace".to_string(),
17118 ),
17119 DepError::FontePinShape {
17120 nome: "caixa-teia".to_string(),
17121 pin: ":tag".to_string(),
17122 value: "v0.1.0 ".to_string(),
17123 reason: "trailing whitespace".to_string(),
17124 },
17125 "fonte_pin_shape ctor must produce byte-equal \
17126 `DepError::FontePinShape` to the pre-lift struct-literal \
17127 wrap on a refname-pin (`:tag` / `:branch`) fixture",
17128 );
17129 assert_eq!(
17130 DepError::fonte_pin_shape(
17131 "caixa-teia",
17132 ":rev",
17133 "DEADBEEF",
17134 "abbreviated OID rejected".to_string(),
17135 ),
17136 DepError::FontePinShape {
17137 nome: "caixa-teia".to_string(),
17138 pin: ":rev".to_string(),
17139 value: "DEADBEEF".to_string(),
17140 reason: "abbreviated OID rejected".to_string(),
17141 },
17142 "fonte_pin_shape ctor must produce byte-equal \
17143 `DepError::FontePinShape` to the pre-lift struct-literal \
17144 wrap on a hex-OID-pin (`:rev`) fixture",
17145 );
17146 }
17147
17148 #[test]
17149 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17150 // Cross-axis routing pin: sweep every one of the four
17151 // constructor input axes (`nome: &str`, `pin: &str`,
17152 // `value: &str`, `reason: String`) through non-default
17153 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17154 // any wrapper-side lowercase / trim / truncate at codegen time
17155 // — or a silent field re-name / axis-swap on any one of the
17156 // four fields, or a `reason` axis silently routed through
17157 // `.to_string()` instead of forwarded owned — surfaces here
17158 // rather than at a downstream diagnostic-shape mismatch. Peer
17159 // of the sibling
17160 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17161 // (792aa92) and
17162 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17163 // pin (6f5e0cd) on the same envelope's one- and two-slot
17164 // families. Distinct-per-axis fixtures rule out any two-axis
17165 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17166 // etc.) that would still pass a same-fixture-per-axis pin.
17167 let nome = "sibling-teia";
17168 let pin = ":branch";
17169 let value = "feature/bar";
17170 let reason = "embedded space".to_string();
17171 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17172 let via_struct_literal = DepError::FontePinShape {
17173 nome: nome.to_string(),
17174 pin: pin.to_string(),
17175 value: value.to_string(),
17176 reason: reason.clone(),
17177 };
17178 assert_eq!(
17179 via_ctor, via_struct_literal,
17180 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17181 through `.to_string()` onto their canonical fields and \
17182 forward `reason` owned onto the canonical `reason` field \
17183 — a field-rename, silent-conversion, or axis-swap \
17184 regression surfaces here rather than at a downstream \
17185 diagnostic-shape mismatch",
17186 );
17187 let DepError::FontePinShape {
17188 nome: n,
17189 pin: p,
17190 value: v,
17191 reason: r,
17192 } = via_ctor
17193 else {
17194 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17195 };
17196 assert_eq!(n, nome);
17197 assert_eq!(p, pin);
17198 assert_eq!(v, value);
17199 assert_eq!(r, reason);
17200 }
17201
17202 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17203 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17204 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17205 // the same envelope's `{ nome: String, caminho: String }` two-slot
17206 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17207 // same envelope's `{ nome: String }` one-slot shape.
17208
17209 #[test]
17210 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17211 assert_eq!(
17212 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17213 DepError::FonteCaminhoControlChar {
17214 nome: "caixa-teia".to_string(),
17215 caminho: "../caixa-teia\x00foo".to_string(),
17216 byte: 0x00,
17217 },
17218 );
17219 }
17220
17221 #[test]
17222 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17223 assert_eq!(
17224 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17225 DepError::FonteCaminhoShellRedirection {
17226 nome: "caixa-teia".to_string(),
17227 caminho: "../caixa-teia>log".to_string(),
17228 byte: b'>',
17229 },
17230 );
17231 }
17232
17233 #[test]
17234 #[allow(
17235 clippy::too_many_lines,
17236 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17237 byte-classification arm on the {nome,caminho,byte} envelope; \
17238 the linear per-variant repetition is exactly what the sweep \
17239 is pinning — a helper macro would hide the shape the fold is \
17240 keying on"
17241 )]
17242 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17243 // Cross-axis routing pin: sweep the three constructor input axes
17244 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17245 // non-default fixture triple against every generated arm in the
17246 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17247 // lowercase / trim / truncate on the two `&str` axes — a silent
17248 // field swap between `nome` and `caminho`, or a silent
17249 // re-classification of the offending byte — surfaces here rather
17250 // than at a downstream diagnostic-shape mismatch. Peer of the
17251 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17252 // to_string` cross-axis routing pin on the same envelope's
17253 // two-slot family (f85f145) and of the sibling
17254 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17255 // same envelope's one-slot family (792aa92), extended here onto
17256 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17257 // envelope so every substrate-primitive ctor family in
17258 // caixa-core's `DepError` envelope guarantees each field routes
17259 // the caller's value verbatim through `.to_string()` (or byte-
17260 // identity for `byte: u8`) in declared field order.
17261 let nome = "sibling-teia";
17262 let caminho = "../workspace/sibling";
17263 let byte = 0x2A_u8;
17264 let cases: [(DepError, DepError); 12] = [
17265 (
17266 DepError::fonte_caminho_control_char(nome, caminho, byte),
17267 DepError::FonteCaminhoControlChar {
17268 nome: nome.to_string(),
17269 caminho: caminho.to_string(),
17270 byte,
17271 },
17272 ),
17273 (
17274 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17275 DepError::FonteCaminhoShellRedirection {
17276 nome: nome.to_string(),
17277 caminho: caminho.to_string(),
17278 byte,
17279 },
17280 ),
17281 (
17282 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17283 DepError::FonteCaminhoShellGlob {
17284 nome: nome.to_string(),
17285 caminho: caminho.to_string(),
17286 byte,
17287 },
17288 ),
17289 (
17290 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17291 DepError::FonteCaminhoShellSubshellGrouping {
17292 nome: nome.to_string(),
17293 caminho: caminho.to_string(),
17294 byte,
17295 },
17296 ),
17297 (
17298 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17299 DepError::FonteCaminhoShellBraceExpansion {
17300 nome: nome.to_string(),
17301 caminho: caminho.to_string(),
17302 byte,
17303 },
17304 ),
17305 (
17306 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17307 DepError::FonteCaminhoShellBracketExpansion {
17308 nome: nome.to_string(),
17309 caminho: caminho.to_string(),
17310 byte,
17311 },
17312 ),
17313 (
17314 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17315 DepError::FonteCaminhoShellQuoteGrouping {
17316 nome: nome.to_string(),
17317 caminho: caminho.to_string(),
17318 byte,
17319 },
17320 ),
17321 (
17322 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17323 DepError::FonteCaminhoShellComment {
17324 nome: nome.to_string(),
17325 caminho: caminho.to_string(),
17326 byte,
17327 },
17328 ),
17329 (
17330 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17331 DepError::FonteCaminhoUrlPercentEncoding {
17332 nome: nome.to_string(),
17333 caminho: caminho.to_string(),
17334 byte,
17335 },
17336 ),
17337 (
17338 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17339 DepError::FonteCaminhoShellVariableExpansion {
17340 nome: nome.to_string(),
17341 caminho: caminho.to_string(),
17342 byte,
17343 },
17344 ),
17345 (
17346 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17347 DepError::FonteCaminhoShellHistoryExpansion {
17348 nome: nome.to_string(),
17349 caminho: caminho.to_string(),
17350 byte,
17351 },
17352 ),
17353 (
17354 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17355 DepError::FonteCaminhoShellHistorySubstitution {
17356 nome: nome.to_string(),
17357 caminho: caminho.to_string(),
17358 byte,
17359 },
17360 ),
17361 ];
17362 for (via_ctor, via_struct_literal) in cases {
17363 assert_eq!(
17364 via_ctor, via_struct_literal,
17365 "fonte_caminho_byte_ctors!-generated ctor must route \
17366 (nome, caminho, byte) through `.to_string()` / byte-\
17367 identity in declared field order — a field-swap or \
17368 silent-conversion regression surfaces here rather than \
17369 at a downstream diagnostic-shape mismatch",
17370 );
17371 }
17372 }
17373
17374 #[test]
17375 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17376 // Fail-before-pass-after byte-parity pin on the lifted
17377 // `impl AsRef<str> for DepList` — asserts the standard-
17378 // library trait impl and the substrate-primitive
17379 // [`super::DepList::as_str`] `pub const fn` accessor resolve
17380 // to the same `&str` per instance across the two-arm closed
17381 // set, so any future silent detour that routes the impl
17382 // through a divergent projection (a per-arm inline
17383 // `match self { DepList::Prod => ":deps", … }` re-inlining
17384 // that opens a compile-time link to the un-lifted arm-literal,
17385 // a swap onto a second projection axis) trips at caixa-core
17386 // test time under `PartialEq` rather than at a downstream
17387 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17388 // every one of the two arms [`super::DepList::ALL`] carries
17389 // so no arm's projection is covered only by the sibling
17390 // `Display` path. Peer of the sibling
17391 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17392 // (1723611) on the top-level dialect-classification closed-
17393 // set typed enum, and the peer
17394 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17395 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17396 // typed enum — the pins together close the substrate
17397 // primitive's `AsRef<str>` projection axis onto the seventh
17398 // (and last unlifted) closed-set typed enum on the caixa
17399 // surface.
17400 for &list in super::DepList::ALL {
17401 assert_eq!(
17402 <super::DepList as AsRef<str>>::as_ref(&list),
17403 list.as_str(),
17404 "AsRef<str> impl on DepList::{list:?} must byte-equal \
17405 DepList::as_str on the same instance — divergence \
17406 signals a silent detour off the substrate-primitive \
17407 accessor"
17408 );
17409 }
17410 }
17411
17412 #[test]
17413 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17414 // Fail-before-pass-after byte-parity pin on the three-path
17415 // convergence discipline the [`super::DepList`] two-list
17416 // dep-graph closed-set typed enum now carries on the `&str`-
17417 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17418 // newly lifted impl), `format!("{v}")` (the pre-existing
17419 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17420 // primitive `pub const fn` accessor both trait impls delegate
17421 // through) must resolve to the same byte-string on every
17422 // instance across the two-arm closed set. Refuses any future
17423 // divergence between the two trait impls (a stray
17424 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17425 // rather than delegating through the shared accessor; a
17426 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17427 // literal cascade) that would silently split the two
17428 // projection paths of the same closed-set typed enum. Mirrors
17429 // the sibling three-path-convergence discipline the peer
17430 // [`crate::CaixaDialeto`] typed enum carries
17431 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17432 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17433 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17434 // d8136db), the peer [`crate::CaixaKind`] triple
17435 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17436 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17437 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17438 // 16d5c7e).
17439 for &list in super::DepList::ALL {
17440 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17441 let via_display: String = format!("{list}");
17442 let via_accessor: &str = list.as_str();
17443 assert_eq!(via_as_ref, via_accessor);
17444 assert_eq!(via_display, via_accessor);
17445 assert_eq!(via_as_ref, via_display.as_str());
17446 }
17447 }
17448}
17449
17450#[cfg(test)]
17451mod dep_source_is_variant_tests {
17452 use super::*;
17453
17454 fn all_variants() -> Vec<(DepSource, &'static str)> {
17455 vec![
17456 (
17457 DepSource::Git {
17458 repo: "github:pleme-io/caixa-teia".into(),
17459 tag: Some("v0.1.0".into()),
17460 rev: None,
17461 branch: None,
17462 },
17463 "Git",
17464 ),
17465 (
17466 DepSource::Path {
17467 caminho: "../caixa-teia".into(),
17468 },
17469 "Path",
17470 ),
17471 ]
17472 }
17473
17474 fn predicate_row(s: &DepSource) -> [bool; 2] {
17475 [s.is_git(), s.is_path()]
17476 }
17477
17478 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17479 // derive-generated per-arm predicate partition — for every variant
17480 // in `all_variants()`, the observed 2-slot predicate row must equal
17481 // a one-hot row with the `true` at exactly the same index as the
17482 // variant's declaration order. Expected rows are generated live
17483 // from the enumeration rather than transcribed by hand, so a
17484 // copy-paste flip that reroutes one arm through the wrong predicate
17485 // lane trips at the identity-diagonal assertion the way every peer
17486 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17487 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17488 // / [`crate::upgrade::UpgradeInstruction`] /
17489 // [`crate::aplicacao::PlacementStrategy`] /
17490 // [`crate::aplicacao::RateLimitUnit`] /
17491 // [`crate::aplicacao::WitTarget`] /
17492 // [`crate::render::PathShapeViolation`] partition pin already does.
17493 #[test]
17494 fn dep_source_is_variant_predicates_partition_the_arm_set() {
17495 let variants = all_variants();
17496 for (idx, (variant, name)) in variants.iter().enumerate() {
17497 let observed = predicate_row(variant);
17498 let mut expected = [false; 2];
17499 expected[idx] = true;
17500 assert_eq!(
17501 observed, expected,
17502 "DepSource::{name} at declaration-order slot {idx} must \
17503 satisfy exactly one is_* predicate (its own); observed \
17504 row must equal the one-hot expected row — a drift \
17505 would silently reroute one `:fonte`-arm consumer \
17506 through the wrong predicate lane"
17507 );
17508 }
17509 }
17510
17511 // Byte-parity pin on the two field-agnostic `matches!` shapes the
17512 // per-arm arm-discriminator predicates replace at any future
17513 // consumer site (a `:fonte`-shape-only lint rule that flags path
17514 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17515 // a future admission-webhook that rejects `:fonte` shapes outside
17516 // the `is_git()` accept-set, a caixa-lacre indexing pass that
17517 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17518 // Refuses a future accidental split between the derived predicate
17519 // and its `matches!` shape — a hand-rolled shadow impl that
17520 // overrides one path, an accidental rebrand that leaves one
17521 // consumer on the raw `matches!` form — on the two load-bearing
17522 // `:fonte`-arm-discriminator axes every downstream substrate
17523 // consumer of the dep-source axis keys off.
17524 #[test]
17525 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17526 for (variant, name) in all_variants() {
17527 let via_matches_git = matches!(variant, DepSource::Git { .. });
17528 let via_predicate_git = variant.is_git();
17529 assert_eq!(
17530 via_predicate_git, via_matches_git,
17531 "DepSource::{name}.is_git() must byte-equal \
17532 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17533 future converged consumer site would silently \
17534 disagree with its pre-lift shape"
17535 );
17536 let via_matches_path = matches!(variant, DepSource::Path { .. });
17537 let via_predicate_path = variant.is_path();
17538 assert_eq!(
17539 via_predicate_path, via_matches_path,
17540 "DepSource::{name}.is_path() must byte-equal \
17541 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17542 future converged consumer site would silently \
17543 disagree with its pre-lift shape"
17544 );
17545 }
17546 }
17547
17548 // Cross-pin against every constructor path that materializes a
17549 // [`DepSource`] shape today (the [`DepSource::default_github`]
17550 // resolver-side fallback that materializes an unpinned
17551 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17552 // surface constructor that materializes a pinned `:tag`-carrying
17553 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17554 // fixture family builds inline). Every constructor's return must
17555 // satisfy the arm-discriminator predicate the constructor's
17556 // variant name matches — a future constructor addition (an
17557 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17558 // enclosing docstring already names as a trajectory item) surfaces
17559 // as a build-time failure that names the offending drift when its
17560 // return arm doesn't route through the paired predicate.
17561 #[test]
17562 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
17563 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
17564 assert!(
17565 via_default_github.is_git(),
17566 "DepSource::default_github must materialize a Git-arm shape — \
17567 a future constructor that routed through a non-Git arm \
17568 (a registry-fetch pin, a `DepSource::Feira` promotion) \
17569 would silently split the resolver's unpinned-shorthand \
17570 materializer from the sole_pin() precedence cascade"
17571 );
17572 assert!(
17573 !via_default_github.is_path(),
17574 "DepSource::default_github must NOT materialize a Path-arm \
17575 shape — the paired negation pin"
17576 );
17577
17578 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
17579 .fonte
17580 .expect("Dep::git materializes a Some(fonte)");
17581 assert!(
17582 via_dep_git.is_git(),
17583 "Dep::git's `:fonte` materialization must land on the Git \
17584 arm — the author-surface pinned-git constructor's return \
17585 must route through the paired predicate"
17586 );
17587 assert!(!via_dep_git.is_path(), "paired negation pin");
17588
17589 let via_path = DepSource::Path {
17590 caminho: "../caixa-teia".into(),
17591 };
17592 assert!(
17593 via_path.is_path(),
17594 "the dev-mode Path-arm materialization must satisfy is_path()"
17595 );
17596 assert!(!via_path.is_git(), "paired negation pin");
17597 }
17598
17599 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
17600 // String, reason: String }` three-slot envelope on `DepError`,
17601 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
17602 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
17603 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
17604 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
17605 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
17606 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
17607
17608 #[test]
17609 fn versao_invalid_ctor_matches_struct_literal_wrap() {
17610 assert_eq!(
17611 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
17612 DepError::VersaoInvalid {
17613 nome: "caixa-teia".to_string(),
17614 versao: "^0..1".to_string(),
17615 reason: "invalid comparator".to_string(),
17616 },
17617 "versao_invalid ctor must produce byte-equal \
17618 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
17619 );
17620 }
17621
17622 #[test]
17623 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
17624 assert_eq!(
17625 DepError::fonte_repo_shape(
17626 "caixa-teia",
17627 "-upload-pack=evil",
17628 "leading dash rejected".to_string(),
17629 ),
17630 DepError::FonteRepoShape {
17631 nome: "caixa-teia".to_string(),
17632 repo: "-upload-pack=evil".to_string(),
17633 reason: "leading dash rejected".to_string(),
17634 },
17635 "fonte_repo_shape ctor must produce byte-equal \
17636 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
17637 );
17638 }
17639
17640 #[test]
17641 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
17642 assert_eq!(
17643 DepError::caracteristica_invalid(
17644 "caixa-teia",
17645 "bad feature!",
17646 "embedded space rejected".to_string(),
17647 ),
17648 DepError::CaracteristicaInvalid {
17649 nome: "caixa-teia".to_string(),
17650 caracteristica: "bad feature!".to_string(),
17651 reason: "embedded space rejected".to_string(),
17652 },
17653 "caracteristica_invalid ctor must produce byte-equal \
17654 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
17655 );
17656 }
17657
17658 #[test]
17659 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
17660 // Cross-axis routing pin: sweep the three constructor input axes
17661 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
17662 // distinct-per-axis fixtures against every generated arm in the
17663 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
17664 // lowercase / trim / truncate on the two `&str` axes — a silent
17665 // field swap between `nome`, the middle `<axis>` field, and
17666 // `reason`, or a `reason` axis silently rerouted through
17667 // `.to_string()` instead of forwarded owned — surfaces here rather
17668 // than at a downstream diagnostic-shape mismatch. Peer of the
17669 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
17670 // through_to_string` (0e35793) cross-axis routing pin on the same
17671 // envelope's `{ nome, caminho, byte }` three-slot family and of
17672 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
17673 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
17674 // — extended here onto the `{ nome, <axis>: String, reason:
17675 // String }` three-slot envelope so every substrate-primitive ctor
17676 // family in caixa-core's `DepError` envelope guarantees each field
17677 // routes the caller's value verbatim through `.to_string()` (or
17678 // owned-forward for `reason: String`) in declared field order.
17679 // Distinct-per-axis fixtures rule out any two-axis swap
17680 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
17681 // same-fixture-per-axis pin.
17682 let nome = "sibling-teia";
17683 let axis = "distinct-axis-value";
17684 let reason = "distinct rejection sentence".to_string();
17685 assert_eq!(
17686 DepError::versao_invalid(nome, axis, reason.clone()),
17687 DepError::VersaoInvalid {
17688 nome: nome.to_string(),
17689 versao: axis.to_string(),
17690 reason: reason.clone(),
17691 },
17692 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
17693 `reason` → `reason` in declared field order",
17694 );
17695 assert_eq!(
17696 DepError::fonte_repo_shape(nome, axis, reason.clone()),
17697 DepError::FonteRepoShape {
17698 nome: nome.to_string(),
17699 repo: axis.to_string(),
17700 reason: reason.clone(),
17701 },
17702 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
17703 `reason` → `reason` in declared field order",
17704 );
17705 assert_eq!(
17706 DepError::caracteristica_invalid(nome, axis, reason.clone()),
17707 DepError::CaracteristicaInvalid {
17708 nome: nome.to_string(),
17709 caracteristica: axis.to_string(),
17710 reason: reason.clone(),
17711 },
17712 "caracteristica_invalid must route `nome` → `nome`, \
17713 `axis` → `caracteristica`, `reason` → `reason` in declared \
17714 field order",
17715 );
17716 }
17717
17718 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
17719 // two-slot envelope on `DepError`, missing rung between
17720 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
17721 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
17722 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
17723 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
17724 // two-slot `{ nome, list: &'static str }` envelope (same slot
17725 // count, `&'static str` axis instead of owned `String` axis).
17726
17727 #[test]
17728 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
17729 assert_eq!(
17730 DepError::fonte_pin_empty("caixa-teia", ":tag"),
17731 DepError::FontePinEmpty {
17732 nome: "caixa-teia".to_string(),
17733 pin: ":tag".to_string(),
17734 },
17735 "fonte_pin_empty ctor must produce byte-equal \
17736 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
17737 on the same `(&str, &str)` fixture",
17738 );
17739 }
17740
17741 #[test]
17742 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
17743 assert_eq!(
17744 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
17745 DepError::FontePinAmbiguous {
17746 nome: "caixa-teia".to_string(),
17747 pins: ":tag, :rev".to_string(),
17748 },
17749 "fonte_pin_ambiguous ctor must produce byte-equal \
17750 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
17751 wrap on the same `(&str, &str)` fixture",
17752 );
17753 }
17754
17755 #[test]
17756 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
17757 assert_eq!(
17758 DepError::caracteristica_duplicate("caixa-teia", "http"),
17759 DepError::CaracteristicaDuplicate {
17760 nome: "caixa-teia".to_string(),
17761 caracteristica: "http".to_string(),
17762 },
17763 "caracteristica_duplicate ctor must produce byte-equal \
17764 `DepError::CaracteristicaDuplicate` to the pre-lift \
17765 struct-literal wrap on the same `(&str, &str)` fixture",
17766 );
17767 }
17768
17769 #[test]
17770 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
17771 // Owned-`String` routing pin: thread the real
17772 // `set.join(", ")` `String` carrier through the ctor's
17773 // `&str`-parameter Deref coercion, so the ambiguity-arm
17774 // wire-up site's actual `&set.join(", ")` shape stays
17775 // byte-equal to a direct `":tag, :rev"` literal. A future
17776 // parameter-shape change silently dropping the Deref
17777 // coercion route (e.g., a switch to `impl Into<String>`)
17778 // surfaces here rather than at the wire-up's compile
17779 // error far from the ctor definition.
17780 let set: Vec<&'static str> = vec![":tag", ":rev"];
17781 let joined: String = set.join(", ");
17782 assert_eq!(
17783 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
17784 DepError::FontePinAmbiguous {
17785 nome: "caixa-teia".to_string(),
17786 pins: ":tag, :rev".to_string(),
17787 },
17788 "fonte_pin_ambiguous ctor must accept an owned-`String` \
17789 `&set.join(\", \")` carrier via Deref coercion — the exact \
17790 shape the ambiguity-arm wire-up site passes into it",
17791 );
17792 }
17793
17794 #[test]
17795 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
17796 // Cross-axis routing pin: sweep the two constructor input axes
17797 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
17798 // fixtures against every generated arm in the
17799 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
17800 // trim / truncate at codegen time — a silent field swap between
17801 // `nome` and the middle `<axis>` field, or a `<axis>` axis
17802 // silently rerouted through the wrong field on any one variant
17803 // — surfaces here rather than at a downstream diagnostic-shape
17804 // mismatch. Peer of the sibling
17805 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17806 // (6f5e0cd) pin on the same envelope's peer two-slot family
17807 // (`{ nome, list: &'static str }`) and of the sibling
17808 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
17809 // (5621f8a) pin on the same envelope's three-slot `{ nome,
17810 // <axis>: String, reason: String }` family — extended here onto
17811 // the `{ nome, <axis>: String }` two-slot envelope so the last
17812 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
17813 // ladder guarantees each field routes the caller's value
17814 // verbatim through `.to_string()` in declared field order.
17815 // Distinct-per-axis fixtures rule out any two-axis swap
17816 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
17817 // per-axis pin.
17818 let nome = "sibling-teia";
17819 let axis = "distinct-axis-value";
17820 assert_eq!(
17821 DepError::fonte_pin_empty(nome, axis),
17822 DepError::FontePinEmpty {
17823 nome: nome.to_string(),
17824 pin: axis.to_string(),
17825 },
17826 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
17827 in declared field order",
17828 );
17829 assert_eq!(
17830 DepError::fonte_pin_ambiguous(nome, axis),
17831 DepError::FontePinAmbiguous {
17832 nome: nome.to_string(),
17833 pins: axis.to_string(),
17834 },
17835 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
17836 in declared field order",
17837 );
17838 assert_eq!(
17839 DepError::caracteristica_duplicate(nome, axis),
17840 DepError::CaracteristicaDuplicate {
17841 nome: nome.to_string(),
17842 caracteristica: axis.to_string(),
17843 },
17844 "caracteristica_duplicate must route `nome` → `nome`, \
17845 `axis` → `caracteristica` in declared field order",
17846 );
17847 }
17848
17849 #[test]
17850 fn nome_invalid_ctor_matches_struct_literal_wrap() {
17851 // Equivalence pin: the ctor produces byte-equal
17852 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
17853 // literal that cloned the offending `:deps :nome` verbatim and
17854 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
17855 // owned `reason` payload at the caller site inside
17856 // [`Dep::validate`]. Guards any future field-addition /
17857 // reordering / accessor-return tweak on the variant. Sibling of
17858 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
17859 // (below) and the sibling three-slot
17860 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
17861 // pin on the same envelope's three-slot `{ nome, <axis>: String,
17862 // reason: String }` family.
17863 let nome = "Caixa-Teia";
17864 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
17865 let via_ctor = DepError::nome_invalid(nome, reason.clone());
17866 let via_literal = DepError::NomeInvalid {
17867 nome: nome.to_string(),
17868 reason,
17869 };
17870 assert_eq!(
17871 via_ctor, via_literal,
17872 "nome_invalid(nome, reason) must byte-equal the open-coded \
17873 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
17874 );
17875 assert_eq!(
17876 via_ctor.to_string(),
17877 via_literal.to_string(),
17878 "Display byte-string must byte-equal the open-coded struct-literal"
17879 );
17880 }
17881
17882 #[test]
17883 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
17884 // Boundary-sweep pin on the ctor's two-slot projection: sweep
17885 // the two ctor input axes (`nome: &str`, `reason: String`)
17886 // through distinct-per-axis fixtures against a representative
17887 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
17888 // wrapper-side silent lowercase / trim / truncate at codegen
17889 // time — a silent field swap between `nome` and `reason`, an
17890 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
17891 // divergence on the `reason` axis — surfaces at caixa-core
17892 // build time rather than at a downstream diagnostic consumer
17893 // that reads `err.nome` / `err.reason` back and gets a different
17894 // value than the one it stored. Peer of the sibling
17895 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
17896 // (7f7c950) pin on the same envelope's peer two-slot family
17897 // (`{ nome, <axis>: String }`) — extended here onto the
17898 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
17899 // variant carries. Distinct-per-axis fixtures rule out any
17900 // two-axis swap (`nome` ↔ `reason`) that would still pass a
17901 // same-fixture-per-axis pin. The sweep list carries a mixed
17902 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
17903 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
17904 // over-63-byte) so a future silent per-input normalization
17905 // surfaces on the arm that diverges.
17906 for nome in [
17907 "Caixa-Teia",
17908 "caixa_teia",
17909 "caixa.teia",
17910 "-caixa-teia",
17911 "caixa-teia-",
17912 "caixa/teia",
17913 &"a".repeat(64),
17914 ] {
17915 let reason = crate::render::is_dns_1123_label(nome)
17916 .expect_err("fixture must be a DNS-1123-refused label");
17917 let via_ctor = DepError::nome_invalid(nome, reason.clone());
17918 let DepError::NomeInvalid {
17919 nome: stored_nome,
17920 reason: stored_reason,
17921 } = via_ctor
17922 else {
17923 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
17924 };
17925 assert_eq!(
17926 stored_nome, nome,
17927 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
17928 );
17929 assert_eq!(
17930 stored_reason, reason,
17931 "reason slot must forward the owned `String` verbatim for {nome:?}"
17932 );
17933 }
17934 }
17935
17936 #[test]
17937 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
17938 // End-to-end pin: the sole in-crate wire-up site
17939 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
17940 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
17941 // the ctor's output on the same DNS-1123-refused `:deps :nome`
17942 // fixture, with identical `Display` rendering. A future silent
17943 // de-lift of the wire-up back to the open-coded struct-literal
17944 // trips this test at caixa-core build time rather than at a
17945 // downstream diagnostic consumer far from the wire-up commit.
17946 // Sibling of the peer
17947 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
17948 // pin on the same wire-up — extended here from a `matches!`
17949 // shape check to a byte-identity + Display parity route through
17950 // the ctor.
17951 let d = Dep::simple("Caixa_Teia", "^0.1");
17952 let observed = d.validate().unwrap_err();
17953 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
17954 .expect_err("fixture must be DNS-1123-refused");
17955 let expected = DepError::nome_invalid("Caixa_Teia", reason);
17956 assert_eq!(
17957 observed, expected,
17958 "Dep::validate's DNS-1123 refusal arm must byte-equal \
17959 nome_invalid(nome, reason)"
17960 );
17961 assert_eq!(
17962 observed.to_string(),
17963 expected.to_string(),
17964 "Display byte-string parity"
17965 );
17966 }
17967}