caixa_core/dep.rs
1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17/// :versao "^0.1"
18/// :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22/// :versao "*"
23/// :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27/// :versao "0.1.0"
28/// :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33 /// Caixa name — must match the target caixa's `:nome`.
34 pub nome: String,
35
36 /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37 pub versao: String,
38
39 /// Where to fetch the caixa from. Defaults to the feira registry.
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub fonte: Option<DepSource>,
42
43 /// If true, a missing `:fonte` is not a build failure.
44 #[serde(default, skip_serializing_if = "is_false")]
45 pub opcional: bool,
46
47 /// Feature flags to enable on the target caixa.
48 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81 /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82 /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83 /// or any git-ssh URL.
84 Git {
85 repo: String,
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 tag: Option<String>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 rev: Option<String>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 branch: Option<String>,
92 },
93 /// Local filesystem path — dev only; cannot be published.
94 Path { caminho: String },
95}
96
97impl DepSource {
98 /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99 ///
100 /// This is the resolver-side fallback for `dep.fonte: None`, not an
101 /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102 /// all `None`) and is therefore rejected by [`Self::validate`]. The
103 /// resolver fills the pin in at fetch time from the resolved commit;
104 /// authors never serialize this shape as a `Dep::fonte` value.
105 #[must_use]
106 pub fn default_github(org: &str, nome: &str) -> Self {
107 Self::Git {
108 repo: format!("github:{org}/{nome}"),
109 tag: None,
110 rev: None,
111 branch: None,
112 }
113 }
114
115 /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116 /// every consumer that reads "which single git ref does this source
117 /// resolve to?" keys off — returns the author-declared `:tag` /
118 /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119 /// borrowed from the typed slot's own `Option<String>` storage; `None`
120 /// on [`Self::Path`] (a path source carries no git-ref) and on a
121 /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122 /// `None` (the [`Self::default_github`] shorthand shape the resolver
123 /// materializes when the author omits `:fonte` — rejected by
124 /// [`Self::validate`], but the accessor's return is defined on this
125 /// arm too so pre-validate consumers reach for the same typed dispatch
126 /// as post-validate ones).
127 ///
128 /// **Precedence: rev > tag > branch.** The canonical precedence every
129 /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130 /// per-fetch `git checkout <ref>` reads through the same
131 /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132 /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133 /// through the same cascade at caixa-crd/src/conversion.rs. The
134 /// [`Self::validate`] gate enforces "exactly one pin set" — under
135 /// that invariant every accepted [`Self::Git`] carries exactly one
136 /// non-`None` pin and the precedence is unobservable, but the
137 /// precedence remains defined for pre-validate consumers (the
138 /// resolver's `MissingPin` diagnostic path, the caixa-crd
139 /// round-trip's default `"main"` fallback the author never sees a
140 /// diagnostic on) and defense-in-depth for a hypothetical future
141 /// state where multiple pins survive the gate. The precedence is
142 /// **rev before tag** because `:rev` (a git commit OID) is the
143 /// reproducibility-strongest identifier — an OID resolves to exactly
144 /// one commit regardless of which refname points at it, whereas
145 /// `:tag` and `:branch` are refnames the remote can silently move
146 /// (a tag re-push, a branch head advance); the resolver's freeze
147 /// step at fetch time promotes the resolved commit to `:rev` for
148 /// exactly this reason. **Tag before branch** because `:tag` is
149 /// conventionally immutable (a release tag) whereas `:branch` is
150 /// conventionally mutable (a tracking ref) — a caixa carrying both
151 /// a release tag and a tracking branch reads as "prefer the release
152 /// pin, fall through to the tracking pin only if the release is
153 /// missing". The cascade order also matches the byte-order every
154 /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155 /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156 /// [`Self::validate`]'s `pins` array).
157 ///
158 /// Prior to this lift the "sole set pin" projection sat twice in the
159 /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160 /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161 /// { … })?;`) and at caixa-crd's `dep_into_ref`
162 /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163 /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164 /// of the same precedence cascade with no compile-time link back to
165 /// the typed slot. A future extension of the pin axis to a richer
166 /// author surface (a `:commit` pin peer of `:rev` once the substrate
167 /// grows a signed-commit-verification pin, a `:ref` pin the M4
168 /// substrate operator resolves per-cluster ahead of fetch, a
169 /// promotion of the plain `Option<String>` pins to a typed
170 /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171 /// once the sibling [`crate::render::is_git_oid`] /
172 /// [`crate::render::is_git_ref_name`] gates land as typed
173 /// constructors) would have had to be threaded through both
174 /// open-coded copies in lockstep or the resolver's `git checkout`
175 /// target would silently disagree with the CRD's `git_ref` fill —
176 /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177 /// "v1"))` would ship with the resolver checking out `deadbeef`
178 /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179 /// lacre closure disagreeing with the emitted K8s CR the operator
180 /// reads. Lifting the resolution to a typed method on the substrate
181 /// primitive means both downstream consumers reach for exactly one
182 /// typed dispatch — the resolver's accept-set migrates as a unit on
183 /// any future pin-axis addition.
184 ///
185 /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186 /// `Option<&DepSource>` composite-reference accessor on the outer-
187 /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188 /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189 /// git-fetching consumer runs after the outer `:fonte` slot resolves
190 /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191 /// substrate primitive, thin projections at each consumer" discipline
192 /// the outer accessor family already carries.
193 #[must_use]
194 pub fn sole_pin(&self) -> Option<&str> {
195 match self {
196 Self::Git {
197 tag, rev, branch, ..
198 } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199 Self::Path { .. } => None,
200 }
201 }
202
203 /// Validate the `:fonte` value-shape: every author-surface
204 /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205 /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206 /// value; every `:fonte (:tipo path …)` must carry a non-empty
207 /// `:caminho`.
208 ///
209 /// Called from [`Dep::validate`] with the dep's `:nome` so every
210 /// diagnostic carries the offending entry verbatim — same
211 /// self-locating shape the `:deps :versao` (2420c44),
212 /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213 /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214 /// (3f9d7a0) gates already expose.
215 ///
216 /// Until this gate landed `:fonte` was the only `:deps`-related
217 /// typed surface still untyped past `Caixa::from_lisp`:
218 /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219 /// passed parse and surfaced as a git-clone failure at
220 /// lacre-resolve time, far from the source caixa.lisp.
221 /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222 /// passed parse and surfaced as the resolver's
223 /// [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224 /// at fetch time, again far from the source caixa.lisp; lifting
225 /// to validate-time gives the author the same diagnostic at the
226 /// edit site.
227 /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228 /// pins set — passed parse and the resolver silently picked
229 /// `:rev > :tag > :branch`, ignoring the other pins with no
230 /// diagnostic; the author had no way to know their `:branch`
231 /// was dropped. This is the canonical "pin drift" footgun.
232 /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233 /// passed parse and surfaced as `git checkout ""` at fetch time.
234 /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235 /// parse and surfaced as
236 /// [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237 /// with `path: PathBuf("")` — not actionable.
238 ///
239 /// Each rejected shape maps to a typed
240 /// [`DepError::Fonte*`] variant that names the offending
241 /// dep's `:nome` and the specific axis, so the author can grep
242 /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243 /// one edit.
244 pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245 match self {
246 Self::Git {
247 repo,
248 tag,
249 rev,
250 branch,
251 } => {
252 if repo.is_empty() {
253 return Err(DepError::fonte_repo_empty(nome));
254 }
255 // The `:repo` value flows verbatim into the caixa-resolver's
256 // `git clone <repo>` subprocess invocation. Until this gate
257 // landed `:repo` was the last untyped `:fonte`-related axis
258 // past the empty arm: a malformed-but-non-empty repo URL
259 // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260 // `":repo "-upload-pack=evil""` leading `-` — the canonical
261 // CLI-argument-injection vector at the `git clone` boundary;
262 // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263 // reads as a relative filesystem path rather than the
264 // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265 // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266 // silently passed validate and the failure surfaced at
267 // lacre-resolve time with a porcelain-quoting-confused error
268 // far from the source caixa.lisp. The lifted predicate makes
269 // the git-porcelain-URL intersection-floor a substrate-level
270 // invariant at validate time, peer with the three pin axes
271 // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272 // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273 // — every `:fonte (:tipo git …)` past validate is now
274 // structurally accept-shaped on every axis the resolver
275 // consumes (the `:repo` URL the `git clone` invokes against,
276 // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277 // accepts, the `:rev` commit OID the lacre's content-
278 // addressing equality probe resolves), closing the
279 // `:fonte` slot's value-shape trajectory end-to-end.
280 if let Err(reason) = crate::render::is_git_repo_url(repo) {
281 return Err(DepError::fonte_repo_shape(nome, repo, reason));
282 }
283 let pins: [(&'static str, Option<&String>); 3] = [
284 (":tag", tag.as_ref()),
285 (":rev", rev.as_ref()),
286 (":branch", branch.as_ref()),
287 ];
288 let set: Vec<&'static str> =
289 pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290 match set.len() {
291 0 => {
292 return Err(DepError::fonte_pin_missing(nome));
293 }
294 1 => {
295 for (pin, value) in pins {
296 if value.is_some_and(String::is_empty) {
297 return Err(DepError::fonte_pin_empty(nome, pin));
298 }
299 }
300 }
301 _ => {
302 return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303 }
304 }
305 // Per-pin value-shape gate. The refname-shaped axes
306 // (`:tag` + `:branch`) route through
307 // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308 // `:rev` axis routes through
309 // [`crate::render::is_git_oid`]. The two predicates
310 // partition the `:fonte` pin axes structurally — refname
311 // vs. hex commit — so a cross-axis mis-slot (the
312 // canonical "I conflated `:rev` and `:branch`" footgun:
313 // `:rev "main"` defeating the reproducibility contract,
314 // `:tag "deadbeef…"` mis-slotting a SHA into the
315 // refname-shaped axis) lands at the offending axis's
316 // predicate, not at lacre-resolve `git fetch` /
317 // `git checkout` time. Their valid sets intersect at
318 // the empty set: every refname is rejected by
319 // `is_git_oid`, every OID is rejected by
320 // `is_git_ref_name`, structurally.
321 //
322 // Until this gate landed `:tag` / `:branch` were the
323 // refname-shaped axes still untyped past the empty-pin
324 // arm: a malformed-but-non-empty refname
325 // (`:tag "v0.1.0 "` trailing space — the canonical
326 // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327 // with git's atomic-rename guard suffix; `:tag "../escape"`
328 // path-traversal via consecutive dots; `:branch "main "`
329 // trailing space; `:branch "feature/foo bar"` embedded
330 // space; `:branch "@"` the literal HEAD alias;
331 // `:branch "refs/heads/main"` the fully-qualified ref
332 // copied from `git show-ref` output that resolves to
333 // a literal ref named `refs/heads/refs/heads/main` on
334 // disk) silently passed validate; the `:rev` axis was
335 // the last `:fonte`-related axis still untyped past the
336 // empty-pin arm: a malformed-but-non-empty hex-OID
337 // (`:rev "main"` conflating with `:branch` — the
338 // reproducibility-contract leak; `:rev "v0.1.0"`
339 // conflating with `:tag` — the same mis-slot on the
340 // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341 // 6-char prefix that's ambiguous across repo history;
342 // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343 // inconsistently against `git rev-parse HEAD`'s
344 // lowercase emission) silently passed validate and the
345 // failure surfaced at lacre-resolve `git fetch` /
346 // `git checkout` time with a quoting-confused error
347 // far from the source caixa.lisp, with no field naming
348 // which `:deps` entry carried the typo. Lifting both
349 // gates to caixa-build time matches the value-shape
350 // trajectory the peer typed axes already follow
351 // (c4213a4 typed WitContract endpoint/subject/slot;
352 // eb3456d :entrada :paths; c7d05ec :entrada :host;
353 // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354 // 63e18a0 :contratos :subject; 2f4316e :contratos
355 // :slot; e70d213 :fonte :tag + :branch) — the typed
356 // slot's valid set matches its downstream consumer's
357 // accepted set (here, the git porcelain's refname /
358 // commit-OID grammars at `git fetch` / `git checkout`
359 // time), structurally. Same diagnostic shape every
360 // per-axis value-shape lift already exposes
361 // (`*Invalid { axis, reason }`); the `value:` field
362 // carries the offending refname / OID verbatim so the
363 // author can grep their caixa.lisp for the
364 // `:tag "<value>"` / `:branch "<value>"` /
365 // `:rev "<value>"` literal and fix it in one edit.
366 for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367 if let Some(v) = value
368 && let Err(reason) = crate::render::is_git_ref_name(v)
369 {
370 return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371 }
372 }
373 if let Some(v) = rev.as_ref()
374 && let Err(reason) = crate::render::is_git_oid(v)
375 {
376 return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377 }
378 Ok(())
379 }
380 Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381 }
382 }
383
384 /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385 /// `:caminho` axis. Walks the leading-byte cascade closed by the
386 /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387 /// orthogonal embedded-control-byte arm (d624c8d) covering
388 /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389 /// embedded-`\` Windows-path-separator arm closing the
390 /// cross-host-OS-separator divergence vector on the same
391 /// THEORY.md §V.2 render-determinism axis.
392 ///
393 /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394 /// per-arm cascade now spans nine diagnostic shapes — every new
395 /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396 /// a future glob-metachar `*` / `?` arm) lands here rather than
397 /// re-inflating `Self::validate`. The
398 /// function stays a thin per-arm linear walk for one reason: each
399 /// arm's diagnostic carries a distinct typed [`DepError`] variant
400 /// rather than a parser-shaped `reason` string, so collapsing the
401 /// cascade onto a generic [`crate::render`] predicate would regress
402 /// the per-arm self-locating diagnostic that `feira lint` consumers
403 /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404 /// [`crate::render::is_git_repo_url`], etc.) lives on the
405 /// reason-string-shaped axes; the `:caminho` axis keeps its
406 /// per-arm variant shape.
407 #[allow(
408 clippy::too_many_lines,
409 reason = "the per-arm cascade is structurally flat by design — every \
410 `:caminho` arm carries its own typed [`DepError`] variant + \
411 per-arm Why comment, so collapsing the cascade onto a generic \
412 [`crate::render`] predicate would regress the per-arm self-locating \
413 diagnostic the `feira lint` consumer surface depends on"
414 )]
415 fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416 if caminho.is_empty() {
417 return Err(DepError::fonte_caminho_empty(nome));
418 }
419 // Reproducibility gate on the `:fonte (:tipo path …)`
420 // `:caminho` axis. The lacre pipeline embeds the value
421 // verbatim in its per-dep content-address
422 // (`conteudo: format!("path:{caminho}")`,
423 // caixa-resolver/src/resolve.rs:189) and that string
424 // folds into the BLAKE3 closure the lacre keys every
425 // downstream consumer (the substrate's reproducibility
426 // contract, CAIXA-SDLC §III.2 — the lacre is the
427 // build's content-addressed identity, peer of the Nix
428 // store path) against. Until this gate landed an
429 // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430 // canonical "I dragged the folder out of Finder into
431 // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432 // the macOS path-layout peer; the
433 // `${WORKSPACE}/caixa-teia` shell-expanded literal
434 // pasted from a CI manifest) silently passed validate
435 // and the failure surfaced *as a successful build with
436 // a divergent lacre*: the BLAKE3 closure on Alice's
437 // workstation differed from the closure on Bob's
438 // workstation, two CI runners with different
439 // `${HOME}` layouts emitted two distinct
440 // content-addresses for the byte-identical caixa, and
441 // the substrate's "the lacre is the build's identity"
442 // contract silently broke far from the source
443 // caixa.lisp — the most insidious failure mode the
444 // typed slot can carry (no error surfaces; the
445 // divergence is invisible until two machines compare
446 // lacres). The same THEORY.md §V.2 render-determinism
447 // discipline `is_sandboxed_relative_path` already
448 // applies on the M2 typed path-slots
449 // (`:behavior :on-*`, `:upgrade-from :state-change
450 // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451 // narrowed to the absolute-vs-relative axis only:
452 // `:fonte :caminho`'s canonical author-surface form is
453 // the `..`-traversing sibling-workspace path
454 // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455 // full `is_sandboxed_relative_path` lift would
456 // structurally reject every legitimate path-fonte
457 // dep. The narrower
458 // `std::path::Path::is_absolute` cut admits the
459 // sibling-workspace form while still rejecting the
460 // host-layout-leaking absolute shape — the
461 // reproducibility contract bites at exactly the
462 // absolute boundary, and that's the axis the
463 // substrate-level invariant is meant to hold. Same
464 // diagnostic shape every per-axis value-shape lift on
465 // the surrounding [`DepError::Fonte*`] cluster carries
466 // (the offending `:nome` + offending `:caminho`
467 // quoted verbatim so the author can grep their
468 // caixa.lisp for the `:caminho "<value>"` literal and
469 // fix it in one edit). The empty arm strictly
470 // precedes this arm so the blank-string footgun
471 // surfaces the more self-locating
472 // `FonteCaminhoEmpty` diagnostic (the empty string
473 // is not absolute under `Path::new("").is_absolute()`
474 // so the precedence is a no-op at value level — the
475 // pin matters only at the diagnostic-shape level if
476 // a future codec round-trip ever produces an empty
477 // string that probes as absolute).
478 if std::path::Path::new(caminho).is_absolute() {
479 return Err(DepError::fonte_caminho_absolute(nome, caminho));
480 }
481 // Reproducibility gate's tilde-expansion arm. The b94fd83
482 // `FonteCaminhoAbsolute` closes the leading-`/`
483 // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484 // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485 // doc footgun) silently passed both the empty arm and
486 // the absolute arm because `Path::new("~").is_absolute()`
487 // returns `false` — `~` is a shell-expansion convention,
488 // not a POSIX path component, so `std::path::Path` treats
489 // it as a literal directory-name segment. The lacre
490 // pipeline then embedded the value verbatim
491 // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492 // failure mode forked per consumer:
493 //
494 // - The caixa-resolver's `Path` arm folds `:caminho`
495 // through `Path::new(caminho).join(<file>)` without
496 // `~`-expansion, so the build looked for a literal
497 // `./~/work/caixa-teia` subdirectory and failed at
498 // resolve time with a `No such file or directory`
499 // error far from the source caixa.lisp (the lacre
500 // itself, though, was already byte-identical across
501 // machines — every machine emitted the same
502 // `path:~/work/caixa-teia` content-address).
503 // - A future caixa-resolver pass that *does* expand `~`
504 // (the canonical shell-convention idiom every
505 // resolver eventually reaches for once an author
506 // reports the literal-`~`-directory bug) would re-
507 // introduce the host-layout-leak the b94fd83 absolute
508 // gate closes: Alice's `~` expands to `/home/alice`,
509 // Bob's to `/home/bob`, two CI runners with different
510 // `$HOME` layouts resolve to two distinct paths for
511 // the byte-identical caixa, and the substrate's
512 // "the lacre is the build's identity" contract
513 // silently breaks far from the source caixa.lisp.
514 //
515 // Closing the gate at `DepSource::validate` (here at the
516 // canonical caixa-build-time boundary, peer with the
517 // absolute arm above) refuses both failure modes
518 // structurally: the typed accepted set excludes every
519 // `~`-prefixed authoring shape, so the resolver is
520 // free to grow `~`-expansion (or any other convention-
521 // expansion the substrate adopts) without re-opening
522 // the host-layout-leak at the typed boundary. Same
523 // diagnostic shape every per-axis value-shape gate on
524 // the surrounding [`DepError::Fonte*`] cluster carries
525 // (the offending `:nome` + offending `:caminho` quoted
526 // verbatim so the author can grep their caixa.lisp for
527 // the `:caminho "<value>"` literal and fix it in one
528 // edit).
529 //
530 // The cascade preserves narrower-diagnostic-first
531 // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532 // → `FonteCaminhoTildeExpansion`. The empty arm
533 // structurally precedes both (the bytes "" / "~" don't
534 // overlap), and the absolute arm structurally precedes
535 // the tilde arm (an absolute path can't start with `~`
536 // since absolute paths start with `/`; the bytes "/" /
537 // "~" don't overlap either). Both arms are
538 // value-disjoint, so the precedence is a no-op at value
539 // level — the pin matters only at the diagnostic-shape
540 // level if a future codec round-trip ever produces a
541 // value that probes as both absolute and tilde-prefixed.
542 if caminho.starts_with('~') {
543 return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544 }
545 // Reproducibility gate's shell-variable-expansion arm.
546 // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547 // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548 // closes the leading-`~` shell-home-expansion shape; the
549 // leading-`$` is the sibling shell-variable-expansion shape
550 // — same host-layout-leaking semantic, different syntactic
551 // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552 // canonical paste-from-`echo $HOME`-doc footgun) and the
553 // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554 // the canonical paste-from-CI-manifest footgun every
555 // GitHub Actions / GitLab CI / Drone manifest carries)
556 // silently passed every prior arm because
557 // `Path::is_absolute` returns false on `$` (the `$` is a
558 // shell convention, not a POSIX path component, so
559 // `std::path::Path` treats it as a literal directory-name
560 // segment) and the tilde arm's `starts_with('~')` doesn't
561 // fire.
562 //
563 // Same per-consumer failure-fork the tilde arm closes:
564 //
565 // - The caixa-resolver's `Path` arm folds `:caminho`
566 // through `Path::new(caminho).join(<file>)` without
567 // `$`-expansion, so the build looks for a literal
568 // `./$HOME/work/caixa-teia` subdirectory and fails at
569 // resolve time with a `No such file or directory`
570 // error far from the source caixa.lisp.
571 // - A future caixa-resolver pass that *does* expand
572 // `$VAR` (the shell-convention idiom every resolver
573 // eventually reaches for once an author reports the
574 // literal-`$HOME`-directory bug, especially for CI's
575 // `${WORKSPACE}` idiom) would re-introduce the host-
576 // layout-leak the b94fd83 absolute gate closes:
577 // Alice's `$HOME` expands to `/home/alice`, Bob's to
578 // `/home/bob`, two CI runners with different
579 // `${WORKSPACE}` layouts resolve to two distinct
580 // paths for the byte-identical caixa, and the
581 // substrate's "the lacre is the build's identity"
582 // contract silently breaks far from the source
583 // caixa.lisp.
584 //
585 // Closing the gate at `DepSource::validate` (here at the
586 // canonical caixa-build-time boundary, peer with the
587 // absolute + tilde arms above) refuses both failure modes
588 // structurally. Same diagnostic shape every per-axis
589 // value-shape gate on the surrounding [`DepError::Fonte*`]
590 // cluster carries (the offending `:nome` + offending
591 // `:caminho` quoted verbatim).
592 //
593 // The cascade preserves narrower-diagnostic-first ordering:
594 // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595 // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596 // The empty arm structurally precedes all three subsequent
597 // arms; the absolute arm structurally precedes both the
598 // tilde and the var arms (absolute paths start with `/`,
599 // the bytes `/` / `~` / `$` don't overlap at the leading
600 // position); the tilde arm structurally precedes the var
601 // arm (`~` and `$` don't overlap at the leading position).
602 // Every pair is value-disjoint, so the precedence is a
603 // no-op at value level — the pin matters only at the
604 // diagnostic-shape level if a future codec round-trip ever
605 // produces a probe-as-both value.
606 //
607 // The gate covers every leading-`$` shape: the canonical
608 // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609 // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610 // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611 // GitHub Actions / GitLab CI / Drone paste footgun), the
612 // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613 // (degenerate "I meant `$HOME` and forgot the rest"). All
614 // shapes route through the same `caminho.starts_with('$')`
615 // byte check.
616 if caminho.starts_with('$') {
617 return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618 }
619 // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620 // f4efe9c arms closed the leading-byte host-layout-leak shapes
621 // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622 // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623 // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624 // *except* the ASCII space byte `0x20`). The bare ASCII space at
625 // the leading position is the orthogonal paste-from-aligned-doc
626 // shape that silently passed every prior arm: `Path::is_absolute`
627 // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628 // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629 // the value's last byte is not `/`, so the canonical
630 // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631 // form in a multi-entry `:deps` block sits at the same column —
632 // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633 // it from the rendered alignment into a fresh entry preserves the
634 // leading whitespace verbatim) silently rendered as a path with
635 // a leading-space directory component the resolver folds through
636 // `Path::join` looking for a literal `./ ../caixa-teia`
637 // subdirectory that fails at resolve time with a non-self-
638 // locating `No such file or directory` error.
639 //
640 // The lacre pipeline's reproducibility contract bites
641 // strictly at this byte: `path:" ../caixa-teia"` and
642 // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643 // (`conteudo: format!("path:{caminho}")`,
644 // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645 // semantic-identical caixa, and the substrate's "the lacre is
646 // the build's identity" contract (CAIXA-SDLC §III.2) silently
647 // breaks across two workstations whose authors differ only in
648 // paste-from-aligned-doc whitespace habits — the most insidious
649 // failure mode the typed slot can carry (no error surfaces; the
650 // divergence is invisible until two machines compare lacres).
651 //
652 // The arm fires AFTER the absolute / tilde / var leading-byte
653 // arms (each names the more self-locating shell-convention
654 // diagnostic on values that probe as that arm's leading-byte
655 // sentinel followed by a leading space — e.g.
656 // `:caminho "/ /foo"` surfaces `FonteCaminhoAbsolute` because
657 // the leading byte is `/`, not space) and BEFORE the
658 // embedded-control-byte arm (a leading-space value with an
659 // embedded control byte surfaces the broader leading-space
660 // diagnostic because the cascade walks leading-byte arms first
661 // — peer with how `FonteCaminhoAbsolute` precedes
662 // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663 //
664 // The peer single-token-shaped axes already reject leading
665 // whitespace on the same paste-from-aligned-doc contract:
666 // [`crate::render::is_git_repo_url`] rejects leading whitespace
667 // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668 // leading whitespace on `:fonte :tag`/`:branch`,
669 // [`crate::render::is_chart_description_shape`] rejects leading
670 // whitespace on `:descricao`,
671 // [`crate::render::is_spdx_expression_shape`] rejects leading
672 // whitespace on `:licenca`. Closing the same byte on
673 // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674 // space anywhere in a typed string slot" invariant structurally
675 // consistent across every value-shape-gated typed surface (the
676 // `:caminho` axis was the last typed string surface still
677 // admitting a leading space byte).
678 if caminho.starts_with(' ') {
679 return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680 }
681 // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682 // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683 // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684 // this arm closes the orthogonal leading-`-` axis on the same
685 // subprocess-argument-boundary the peer `is_git_repo_url` arm
686 // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687 // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688 // `:fonte :tag` / `:branch`) already reject.
689 //
690 // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691 // content-address (`conteudo: format!("path:{caminho}")`,
692 // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693 // value through `Path::join` looking for a literal `./{caminho}`
694 // subdirectory. Every downstream subprocess that consumes the
695 // resolved path — a `git -C {caminho} <verb>` invocation, a
696 // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697 // future operator-side `nix build --path {caminho}` spawn, an
698 // `xargs` / `find {caminho}` / `stat {caminho}` /
699 // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700 // as a CLI flag rather than a positional path when the
701 // subprocess invocation does not carry a `--` argument-list
702 // terminator between the flag block and the path argument. The
703 // canonical footguns:
704 //
705 // - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706 // `find -rf` reinterpretation; the byte the peer
707 // `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708 // example paste-idiom carries as its first token).
709 // - `:caminho "-C"` — `git -C` config-injection paste
710 // (`git -C -C` reinterprets the second `-C` as another
711 // `--change-directory` flag rather than the path
712 // argument; the canonical `git -C <path>` porcelain
713 // idiom every multi-repo workspace tool carries).
714 // - `:caminho "--upload-pack=cat /etc/passwd"` — the
715 // canonical long-flag CLI-arg-injection vector at every
716 // git porcelain entry point (`git clone`, `git fetch`,
717 // `git ls-remote`) that consumes a path or URL
718 // argument; peer with `is_git_repo_url`'s leading-`-`
719 // arm (render.rs:2037) on the sibling `:fonte :repo`
720 // axis, which the arm's diagnostic explicitly cites.
721 // - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722 // override paste-idiom (paste-from-`git -c foo=bar`
723 // shell-history footgun that reinterprets the value as
724 // a `[foo] bar` config injection on every git porcelain
725 // entry point).
726 //
727 // POSIX `std::path::Path` treats a leading `-` as a literal
728 // filename byte, so the resolver folds `-rf` through `Path::join`
729 // and looks for a literal `./-rf` subdirectory — the failure
730 // surfaces at resolve time with a non-self-locating `No such
731 // file or directory` error far from the source caixa.lisp, and
732 // the value rides through the lacre content-address into every
733 // downstream shell-spawned subprocess. On any consumer that
734 // shells out without the `--` terminator (the common case at
735 // every porcelain entry-point) the reinterpretation is silent
736 // and the failure mode is arbitrary-argument-injection.
737 //
738 // The arm fires AFTER the absolute / tilde / var / leading-space
739 // leading-byte arms (each names the more self-locating shell-
740 // convention diagnostic on values that probe as that arm's
741 // leading-byte sentinel — the byte sets are pairwise disjoint at
742 // the leading position, so the precedence pin is a no-op at
743 // value level, but the ordering keeps every leading-byte arm's
744 // diagnostic-shape stable) and BEFORE the embedded-control-byte
745 // arm (a leading-`-` value with an embedded control byte
746 // surfaces the narrower leading-`-` diagnostic because the
747 // cascade walks leading-byte arms first — peer with how
748 // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749 // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750 // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751 //
752 // The peer single-token-shaped axes already reject leading `-`
753 // on the same CLI-arg-injection contract:
754 // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755 // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756 // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757 // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758 // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759 // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760 // [`crate::render::is_cargo_feature_name`] rejects it on
761 // `:caracteristicas`, and the feira `init` / `add <nome>`
762 // positional gate (868c191) rejects it on the CLI positional
763 // itself. Closing the same byte on `:fonte :caminho` makes the
764 // substrate-wide "no leading `-` anywhere in a typed single-
765 // token string slot routed through a subprocess argument"
766 // invariant structurally consistent across every value-shape-
767 // gated typed surface (the `:caminho` axis was the last typed
768 // string surface still admitting a leading `-` byte).
769 if caminho.starts_with('-') {
770 return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771 }
772 // Reproducibility gate's embedded-control-byte arm. The
773 // b94fd83 + a5c248e + f4efe9c arms closed the three
774 // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775 // this arm closes the orthogonal embedded-control-byte
776 // axis — any ASCII control byte (`0x00..=0x1F` plus
777 // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778 // shape every peer single-token-typed-slot value-shape
779 // predicate the surrounding [`crate::render`] cluster
780 // gates against (the lifted `is_git_repo_url` arm on
781 // `:fonte :repo`, the `is_git_ref_name` arm on
782 // `:tag`/`:branch`, the `is_chart_description_shape` /
783 // `is_chart_maintainer_name_shape` /
784 // `is_chart_keyword_shape` arms on the
785 // Helm-chart-shaped axes); now consistent on the
786 // `:caminho` axis too.
787 //
788 // Until this gate landed any embedded control byte
789 // silently passed validate, the lacre pipeline embedded
790 // the value verbatim in its per-dep content-address
791 // (`conteudo: format!("path:{caminho}")`,
792 // caixa-resolver/src/resolve.rs:189), and the failure
793 // forked per byte and per consumer:
794 //
795 // - NUL (`0x00`) the canonical "POSIX paths cannot
796 // contain a NUL byte" shape: every `std::fs` syscall
797 // routes the path through `CString::new`, which
798 // fails with `NulError` on the first NUL byte; the
799 // build would surface a `NulError` at resolve time
800 // far from the source caixa.lisp.
801 // - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802 // multiline-doc footgun: a `:caminho
803 // "../caixa-teia\nrm -rf /"` value (paste landed mid-
804 // `:caminho` block from a multi-line code-fence)
805 // silently round-trips through `Path::join` but the
806 // embedded newline class is a sibling of the CRLF-at-
807 // subprocess-argument injection vector
808 // `is_git_repo_url` already closes on `:repo`.
809 // - Tab (`0x09`) the canonical paste-from-aligned-table
810 // footgun: the tab is invisible in most editors, and
811 // the lacre embeds the value verbatim so two
812 // paste-from-distinct-tables yield divergent lacres
813 // across host editors that strip vs preserve tabs.
814 // - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815 // paste-from-binary-blob shape every peer single-
816 // token-shaped slot rejects under the same
817 // `b < 0x20 || b == 0x7F` predicate.
818 //
819 // Mirrors the cascade discipline every prior `:caminho`
820 // arm establishes: `FonteCaminhoEmpty` →
821 // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822 // → `FonteCaminhoVarExpansion` →
823 // `FonteCaminhoLeadingWhitespace` →
824 // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825 // The six leading-byte arms structurally precede the
826 // embedded-byte arm because the leading-byte shapes are
827 // the more self-locating diagnostic on values that probe
828 // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829 // narrower `FonteCaminhoAbsolute` rather than the broader
830 // embedded-control-byte arm); the precedence pin matters
831 // at the diagnostic-shape level even though the empty /
832 // absolute / tilde / var arms are value-disjoint from a
833 // bare control byte (which would itself be a leading
834 // byte under the empty / absolute / tilde / var arms'
835 // leading-position semantics, but those arms guard the
836 // specific shell-convention characters `/` / `~` / `$`
837 // — a leading `0x01` byte falls through to this arm).
838 for &b in caminho.as_bytes() {
839 if b < 0x20 || b == 0x7F {
840 return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841 }
842 }
843 // Reproducibility gate's Windows-path-separator arm. The four
844 // leading-byte arms (`/` / `~` / `$`) and the embedded-
845 // control-byte arm close the host-layout-leaking + paste-from-
846 // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847 // the orthogonal cross-host-OS-separator shape — same render-
848 // determinism axis, different semantic mechanism. POSIX
849 // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850 // inside a single path component (so `..\caixa-teia` is one
851 // directory named literally `..\caixa-teia`, sibling of `.`
852 // and `..`); Windows [`std::path::Path`] treats `\` as a
853 // primary path separator equal to `/` (so `..\caixa-teia` is
854 // the parent's sibling directory `caixa-teia`). The lacre
855 // pipeline embeds the value verbatim in its per-dep content-
856 // address (`conteudo: format!("path:{caminho}")`, caixa-
857 // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858 // values resolve to two distinct directories across runner
859 // OSes — the same THEORY.md §V.2 render-determinism contract
860 // the absolute / tilde / var arms protect, here against the
861 // cross-host-OS-separator divergence vector. Even on POSIX-
862 // only resolvers (the canonical pleme-io substrate posture),
863 // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864 // PowerShell `Get-Location` paste-idiom footgun) silently
865 // passes every prior arm because `Path::is_absolute` returns
866 // false on `..` and `\` is neither a leading-byte sentinel
867 // nor a control byte, then the resolver folds the value
868 // through `Path::new(caminho).join(<file>)` looking for a
869 // literal `./..\caixa-teia` subdirectory and fails at
870 // resolve time with a non-self-locating `No such file or
871 // directory` error far from the source caixa.lisp.
872 //
873 // The peer single-token-shaped axes on the same git-CLI /
874 // path-CLI consumer cluster already reject `\` under the same
875 // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876 // line 1441 (`"must not contain \\ … the canonical Windows-
877 // path-leak footgun; use / for hierarchical refs"`) gates
878 // `:fonte :tag` / `:fonte :branch` against the same byte,
879 // and [`crate::render::is_gateway_api_http_path`] line 506
880 // includes `\` in the eleven-byte RFC-3986-reserved rejection
881 // set on `:entrada :paths`. Closing the same byte on `:fonte
882 // :caminho` makes the substrate-wide "no Windows path
883 // separator anywhere in a typed string slot" invariant
884 // structurally consistent across every path-shaped typed
885 // surface (the `:caminho` axis was the last typed string
886 // surface still admitting `\`).
887 //
888 // The arm fires AFTER the control-char arm because the
889 // control-char diagnostic is the more self-locating axis on
890 // values that probe as both (`"..\caixa\0teia"` carries both
891 // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892 // rejected byte, so `FonteCaminhoControlChar` wins). Same
893 // narrower-diagnostic-first cascade discipline every prior
894 // arm establishes. A pure-`\` value
895 // (`"..\caixa-teia"` with no control bytes) falls through
896 // every prior arm and lands here.
897 for &b in caminho.as_bytes() {
898 if b == b'\\' {
899 return Err(DepError::fonte_caminho_backslash(nome, caminho));
900 }
901 }
902 // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903 // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904 // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905 // paste-from-shell-prompt footgun class, different syntactic surface.
906 // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907 // single path component (so `../caixa-teia>output` is one directory
908 // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909 // but every interactive shell (bash / zsh / fish / nushell) lexes
910 // `<` / `>` as input / output redirection operators — a `:caminho
911 // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912 // pipeline that wrote build output and forgot to trim the redirect"
913 // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914 // redirection paste idiom) silently passes every prior arm because
915 // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916 // byte sentinels nor control bytes nor `\`, and the value's last byte
917 // isn't `/`. The resolver folds the value through
918 // `Path::new(caminho).join(<file>)` looking for a literal
919 // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920 // with a non-self-locating `No such file or directory` error far
921 // from the source caixa.lisp.
922 //
923 // The lacre pipeline embeds the value verbatim in its per-dep
924 // content-address (`conteudo: format!("path:{caminho}")`,
925 // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926 // the BLAKE3 closure and rides downstream as part of the build's
927 // identity. The bytes carry a second class of hazard the prior
928 // separator-shaped arms don't: every typed-string slot whose value
929 // ever flows verbatim into a shell-spawned subprocess (the caixa-
930 // resolver's `git clone` invocation, a future `feira tofu` shell-
931 // out, a future operator-side `nix flake check` spawn) is the
932 // canonical CRLF-at-subprocess-argument / shell-metachar injection
933 // surface that every peer single-token-shaped typed slot already
934 // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935 // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936 // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937 // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938 // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939 // shell-metachar-injection banner. The `:caminho` axis was the last
940 // typed string surface still admitting these two bytes; this arm
941 // closes the gap so the substrate-wide "no shell-redirection
942 // metacharacter anywhere in a typed string slot" invariant is now
943 // structurally consistent across every path-shaped typed surface.
944 //
945 // The arm fires AFTER the control-char arm + backslash arm because
946 // both prior arms carry more self-locating diagnostics on values
947 // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948 // cross-OS-separator divergence is the load-bearing axis, so the
949 // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950 // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951 // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952 // because the embedded redirection byte is the more semantic-
953 // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954 // but the load-bearing diagnostic is the embedded `<` shell-
955 // redirection — the trailing `/` is the secondary observation, and
956 // an author who removes the `<` is likely to also tab-strip the
957 // trailing separator).
958 for &b in caminho.as_bytes() {
959 if b == b'<' || b == b'>' {
960 return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961 }
962 }
963 // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964 // arm closes the `<` / `>` input/output redirection sentinels; `|`
965 // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966 // shell-prompt footgun class, different syntactic surface. POSIX
967 // `std::path::Path` treats `|` as a literal path-component byte (so
968 // `../caixa-teia|tee` is one directory named literally
969 // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970 // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971 // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972 // `ls ../caixa-teia | grep` line out of a shell-history block and
973 // forgot to trim the pipeline tail" footgun) or `:caminho
974 // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975 // circuit OR line" idiom) silently passes every prior arm because
976 // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977 // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978 // value's last byte isn't `/`. The resolver folds the value through
979 // `Path::new(caminho).join(<file>)` looking for a literal
980 // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981 // with a non-self-locating `No such file or directory` error far
982 // from the source caixa.lisp.
983 //
984 // The lacre pipeline embeds the value verbatim in its per-dep
985 // content-address (`conteudo: format!("path:{caminho}")`,
986 // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987 // BLAKE3 closure and rides downstream as part of the build's identity
988 // into every shell-spawned subprocess (the caixa-resolver's `git
989 // clone` invocation, a future `feira tofu` shell-out, a future
990 // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991 // subprocess-argument / shell-metachar injection surface every peer
992 // single-token-shaped typed slot already closes. The peer path-shaped
993 // axis [`crate::render::is_gateway_api_http_path`]
994 // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996 // axis was the last typed path-string surface still admitting this
997 // byte; this arm closes the gap so the substrate-wide "no shell-
998 // composition metacharacter anywhere in a typed string slot that
999 // flows verbatim into a shell-spawned subprocess" invariant extends
1000 // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001 // `:caminho` axis.
1002 //
1003 // The arm fires AFTER the shell-redirection arm because the prior
1004 // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005 // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006 // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007 // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008 // cascade discipline every prior `:caminho` arm establishes). The arm
1009 // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010 // the more semantic-locating axis on probe-as-both values
1011 // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012 // embedded `|` shell-pipe — the trailing `/` is the secondary
1013 // observation, and an author who removes the `|` is likely to also
1014 // tab-strip the trailing separator).
1015 for &b in caminho.as_bytes() {
1016 if b == b'|' {
1017 return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018 }
1019 }
1020 // Reproducibility gate's shell-command-separator arm. The 124106f
1021 // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022 // shell-command-separator sentinel — same paste-from-shell-prompt
1023 // footgun class, different syntactic surface. POSIX `std::path::Path`
1024 // treats `;` as a literal path-component byte (so
1025 // `../caixa-teia;rm -rf /` is one directory named literally
1026 // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027 // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028 // sequential-command terminator that fires the next command
1029 // regardless of the prior command's exit status — a `:caminho
1030 // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031 // one-liner that chained a cleanup tail after the directory name"
1032 // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033 // POSIX `case` arm's `;;` terminator into the middle of a path"
1034 // idiom) silently passes every prior arm because `Path::is_absolute`
1035 // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036 // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037 // byte isn't `/`. The resolver folds the value through
1038 // `Path::new(caminho).join(<file>)` looking for a literal
1039 // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040 // time with a non-self-locating `No such file or directory` error far
1041 // from the source caixa.lisp.
1042 //
1043 // The lacre pipeline embeds the value verbatim in its per-dep
1044 // content-address (`conteudo: format!("path:{caminho}")`,
1045 // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046 // BLAKE3 closure and rides downstream as part of the build's identity
1047 // into every shell-spawned subprocess (the caixa-resolver's `git
1048 // clone` invocation, a future `feira tofu` shell-out, a future
1049 // operator-side `nix flake check` spawn) as the canonical
1050 // shell-metachar injection surface every peer single-token-shaped
1051 // typed slot already closes. The peer path-shaped axis
1052 // [`crate::render::is_gateway_api_http_path`]
1053 // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055 // axis was the last typed path-string surface still admitting this
1056 // byte; this arm closes the gap so the substrate-wide "no shell-
1057 // composition metacharacter anywhere in a typed string slot that
1058 // flows verbatim into a shell-spawned subprocess" invariant extends
1059 // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060 // `:caminho` axis.
1061 //
1062 // The arm fires AFTER the shell-pipe arm because the prior arm's
1063 // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064 // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065 // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066 // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067 // cascade discipline every prior `:caminho` arm establishes). The arm
1068 // fires BEFORE the trailing-`/` arm because the embedded
1069 // command-separator byte is the more semantic-locating axis on
1070 // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071 // load-bearing diagnostic is the embedded `;` shell-command-
1072 // separator — the trailing `/` is the secondary observation, and an
1073 // author who removes the `;` is likely to also tab-strip the trailing
1074 // separator).
1075 for &b in caminho.as_bytes() {
1076 if b == b';' {
1077 return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078 }
1079 }
1080 // Reproducibility gate's shell-background / logical-AND arm. The
1081 // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082 // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083 // — same paste-from-shell-prompt footgun class, different
1084 // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085 // literal path-component byte (so `../caixa-teia & sleep 1` is
1086 // one directory named literally `../caixa-teia & sleep 1`,
1087 // sibling of `.` and `..`), but every interactive shell
1088 // (bash / zsh / fish / nushell) lexes `&` two ways:
1089 //
1090 // - Single `&` as the background-task terminator that detaches
1091 // the prior command into the background and returns control
1092 // to the prompt immediately (the canonical `cmd &` idiom
1093 // every long-running pipeline uses);
1094 // - Double `&&` as the logical-AND list operator that fires
1095 // the next command only if the prior command succeeded (the
1096 // canonical `make && make install` idiom every build script
1097 // carries).
1098 //
1099 // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100 // pasted a `cd path & sleep 1` background-launch into the
1101 // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102 // (the symmetric "I copied a `cd path && make` build chain"
1103 // idiom) silently passes every prior arm because
1104 // `Path::is_absolute` returns false on `..`, `&` is neither a
1105 // leading-byte sentinel nor a control byte nor `\` nor
1106 // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107 // The resolver folds the value through
1108 // `Path::new(caminho).join(<file>)` looking for a literal
1109 // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110 // time with a non-self-locating `No such file or directory`
1111 // error far from the source caixa.lisp.
1112 //
1113 // The lacre pipeline embeds the value verbatim in its per-dep
1114 // content-address (`conteudo: format!("path:{caminho}")`,
1115 // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116 // the BLAKE3 closure and rides downstream as part of the build's
1117 // identity into every shell-spawned subprocess (the
1118 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119 // shell-out, a future operator-side `nix flake check` spawn) as
1120 // the canonical shell-metachar injection surface every peer
1121 // single-token-shaped typed slot already closes. The peer
1122 // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123 // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125 // `:caminho` axis was the last typed path-string surface still
1126 // admitting this byte; this arm closes the gap so the
1127 // substrate-wide "no shell-composition metacharacter anywhere
1128 // in a typed string slot that flows verbatim into a
1129 // shell-spawned subprocess" invariant extends from
1130 // shell-command-separator (`;`) to shell-background /
1131 // logical-AND (`&`) on the `:caminho` axis.
1132 //
1133 // The arm fires AFTER the shell-command-separator arm because
1134 // the prior arm's `cmd-a; cmd-b` shape is the more common
1135 // shell-history paste idiom on values that probe as both
1136 // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137 // command-separator-tail paste is the load-bearing root-cause
1138 // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139 // discipline every prior `:caminho` arm establishes). The arm
1140 // fires BEFORE the trailing-`/` arm because the embedded
1141 // background / list-AND byte is the more semantic-locating axis
1142 // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143 // load-bearing diagnostic is the embedded `&` shell-background
1144 // / logical-AND metachar — the trailing `/` is the secondary
1145 // observation, and an author who removes the `&` is likely to
1146 // also tab-strip the trailing separator).
1147 for &b in caminho.as_bytes() {
1148 if b == b'&' {
1149 return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150 }
1151 }
1152 // Reproducibility gate's shell-command-substitution arm. The
1153 // e12e4f3 shell-background / logical-AND arm closes the `&`
1154 // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155 // command-substitution sentinel — every POSIX shell (sh /
1156 // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157 // the canonical legacy wrapper that runs the enclosed command
1158 // and substitutes its standard-output verbatim into the
1159 // surrounding word (a `whoami` wrapped in backticks expands
1160 // to the current user's name; a `cat /etc/passwd` wrapped in
1161 // backticks expands to the file's contents — the canonical
1162 // CWE-78 shell-command-injection vector every shell-side
1163 // hardening guide enumerates first). POSIX
1164 // `std::path::Path` treats backtick as a literal path-
1165 // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166 // is one directory named literally that, sibling of `.` and
1167 // `..`).
1168 //
1169 // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170 // canonical "I pasted a shell one-liner carrying a backticked
1171 // `whoami` command-substitution expansion into the `:caminho`
1172 // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173 // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174 // path` working-directory expansion") silently passes every
1175 // prior arm because `Path::is_absolute` returns false on
1176 // `..`, the backtick byte is neither a leading-byte sentinel
1177 // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178 // modern `$()` form at leading position only; backtick is
1179 // the orthogonal legacy form) nor a control byte nor `\` nor
1180 // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181 // byte isn't `/`. The resolver folds the value through
1182 // `Path::new(caminho).join(<file>)` looking for a literal
1183 // subdirectory whose name embeds the backticked token and
1184 // fails at resolve time with a non-self-locating `No such
1185 // file or directory` error far from the source caixa.lisp.
1186 //
1187 // The lacre pipeline embeds the value verbatim in its per-
1188 // dep content-address (`conteudo: format!("path:{caminho}")`,
1189 // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190 // lands in the BLAKE3 closure and rides downstream as part
1191 // of the build's identity into every shell-spawned
1192 // subprocess (the caixa-resolver's `git clone` invocation, a
1193 // future `feira tofu` shell-out, a future operator-side
1194 // `nix flake check` spawn) as the canonical shell-metachar
1195 // injection surface every peer single-token-shaped typed
1196 // slot already closes. The peer path-shaped axis
1197 // [`crate::render::is_gateway_api_http_path`]
1198 // (caixa-core/src/render.rs:506) rejects backtick as part of
1199 // its eleven-byte RFC-3986-reserved set on `:entrada
1200 // :paths`. The `:caminho` axis was the last typed path-
1201 // string surface still admitting this byte; this arm closes
1202 // the gap so the substrate-wide "no shell-composition
1203 // metacharacter anywhere in a typed string slot that flows
1204 // verbatim into a shell-spawned subprocess" invariant
1205 // extends from shell-background / logical-AND (`&`) to
1206 // shell-command-substitution (backtick) on the `:caminho`
1207 // axis.
1208 //
1209 // The arm fires AFTER the shell-background arm because the
1210 // prior arm's `cmd & sleep` shape is the more common shell-
1211 // history paste idiom on values that probe as both (a
1212 // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213 // both `&` and a backtick — the background-launch tail is
1214 // the load-bearing root-cause edit, so
1215 // `FonteCaminhoShellBackground` wins; same cascade
1216 // discipline every prior `:caminho` arm establishes). The
1217 // arm fires BEFORE the trailing-`/` arm because the
1218 // embedded command-substitution byte is the more semantic-
1219 // locating axis on probe-as-both values (a
1220 // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221 // load-bearing diagnostic is the embedded backtick shell-
1222 // command-substitution metachar — the trailing `/` is the
1223 // secondary observation, and an author who removes the
1224 // backtick is likely to also tab-strip the trailing
1225 // separator).
1226 for &b in caminho.as_bytes() {
1227 if b == b'`' {
1228 return Err(DepError::fonte_caminho_shell_command_substitution(
1229 nome, caminho,
1230 ));
1231 }
1232 }
1233 // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234 // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235 // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236 // paste-from-shell-prompt footgun class, different syntactic surface.
1237 // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238 // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239 // sequence of characters in a path component (including the empty
1240 // sequence), `?` matches exactly one character. POSIX
1241 // `std::path::Path` treats both bytes as literal path-component bytes
1242 // (so `../caixa-teia/*.lisp` is one directory named literally
1243 // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244 //
1245 // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246 // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247 // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248 // `rm foo?` single-char-wildcard removal idiom") silently passes
1249 // every prior arm because `Path::is_absolute` returns false on `..`,
1250 // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251 // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252 // value's last byte isn't `/`. The resolver folds the value through
1253 // `Path::new(caminho).join(<file>)` looking for a literal
1254 // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255 // non-self-locating `No such file or directory` error far from the
1256 // source caixa.lisp.
1257 //
1258 // The lacre pipeline embeds the value verbatim in its per-dep
1259 // content-address (`conteudo: format!("path:{caminho}")`,
1260 // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261 // the BLAKE3 closure and rides downstream as part of the build's
1262 // identity into every shell-spawned subprocess (the caixa-resolver's
1263 // `git clone` invocation, a future `feira tofu` shell-out, a future
1264 // operator-side `nix flake check` spawn) as the canonical
1265 // shell-metachar / pathname-expansion surface every peer
1266 // single-token-shaped typed slot already closes. The peer path-shaped
1267 // axis [`crate::render::is_gateway_api_http_path`]
1268 // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270 // `:caminho` axis was the last typed path-string surface still
1271 // admitting these two bytes; this arm closes the gap so the
1272 // substrate-wide "no shell-composition / glob-expansion
1273 // metacharacter anywhere in a typed string slot that flows verbatim
1274 // into a shell-spawned subprocess" invariant extends from
1275 // shell-command-substitution (backtick) to glob-expansion
1276 // (`*` / `?`) on the `:caminho` axis.
1277 //
1278 // The arm fires AFTER the backtick arm because the prior arm's
1279 // CWE-78 shell-command-injection vector is the load-bearing
1280 // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281 // carries both backtick and `*` — the command-substitution paste
1282 // is the load-bearing root-cause edit, so
1283 // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284 // discipline every prior `:caminho` arm establishes). The arm
1285 // fires BEFORE the trailing-`/` arm because the embedded glob
1286 // byte is the more semantic-locating axis on probe-as-both values
1287 // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288 // embedded `*` glob metachar — the trailing `/` is the secondary
1289 // observation, and an author who removes the `*` is likely to
1290 // also tab-strip the trailing separator).
1291 for &b in caminho.as_bytes() {
1292 if b == b'*' || b == b'?' {
1293 return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294 }
1295 }
1296 // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297 // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298 // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299 // grouping sentinels — same paste-from-shell-prompt footgun class,
1300 // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301 // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302 // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303 // shell with a fresh environment scope (the canonical sandboxing
1304 // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305 // to scope a `cd` to one subshell without disturbing the parent's
1306 // working directory), and `$(<cmd>)` is the modern Bourne
1307 // command-substitution shape the upstream f4efe9c
1308 // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309 // the closing `)` byte completes that substitution shape and must
1310 // be refused on the same axis (peer with the
1311 // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312 // same byte-pair on the sibling `:fonte :repo` axis under the
1313 // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314 // POSIX `std::path::Path` treats both bytes as literal path-
1315 // component bytes (so `../caixa-teia/(date)` is one directory
1316 // named literally `../caixa-teia/(date)`, sibling of `.` and
1317 // `..`).
1318 //
1319 // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320 // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321 // liner whose modern command-substitution expansion lands the
1322 // current date as a subdirectory name" footgun) or `:caminho
1323 // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324 // `(cd foo && pwd)` subshell-grouping working-directory probe
1325 // idiom") silently passes every prior arm because
1326 // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327 // neither leading-byte sentinels nor control bytes nor `\` nor
1328 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329 // and the value's last byte isn't `/`. The resolver folds the
1330 // value through `Path::new(caminho).join(<file>)` looking for a
1331 // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332 // at resolve time with a non-self-locating `No such file or
1333 // directory` error far from the source caixa.lisp.
1334 //
1335 // The lacre pipeline embeds the value verbatim in its per-dep
1336 // content-address (`conteudo: format!("path:{caminho}")`,
1337 // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338 // in the BLAKE3 closure and rides downstream as part of the
1339 // build's identity into every shell-spawned subprocess (the
1340 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341 // shell-out, a future operator-side `nix flake check` spawn) as
1342 // the canonical shell-metachar / subshell-grouping surface every
1343 // peer single-token-shaped typed slot already closes. The peer
1344 // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345 // rejects the same byte pair on `:fonte :repo` under the same
1346 // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347 // `:caminho` axis was the last typed path-string surface still
1348 // admitting these two bytes;
1349 // this arm closes the gap so the substrate-wide "no shell-
1350 // composition metacharacter anywhere in a typed string slot that
1351 // flows verbatim into a shell-spawned subprocess" invariant
1352 // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353 // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354 // leading-`$` arm, the typed `:caminho` accepted set now
1355 // structurally excludes the entire modern Bourne
1356 // command-substitution surface — leading `$` closes the
1357 // leading byte of every `$(<cmd>)` shape, this arm closes the
1358 // trailing `)` boundary.
1359 //
1360 // The arm fires AFTER the shell-glob arm because the prior arm's
1361 // `*` / `?` pathname-expansion shape is the more common shell-
1362 // history paste idiom on values that probe as both
1363 // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364 // glob-paste-tail is the load-bearing root-cause edit, so
1365 // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366 // prior `:caminho` arm establishes). The arm fires BEFORE the
1367 // trailing-`/` arm because the embedded subshell-grouping byte
1368 // is the more semantic-locating axis on probe-as-both values
1369 // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370 // is the embedded `(` shell-subshell-grouping metachar — the
1371 // trailing `/` is the secondary observation, and an author who
1372 // removes the `(` is likely to also tab-strip the trailing
1373 // separator).
1374 for &b in caminho.as_bytes() {
1375 if b == b'(' || b == b')' {
1376 return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377 nome, caminho, b,
1378 ));
1379 }
1380 }
1381 // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382 // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383 // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384 // URI-Template-placeholder byte pair — same paste-from-shell-
1385 // prompt + paste-from-templated-doc footgun class, different
1386 // syntactic surface. Every POSIX-derived shell that implements
1387 // brace expansion (bash / zsh / ksh / fish; the canonical
1388 // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389 // `cp file{,.bak}` idiom every shell-history block carries)
1390 // expands `{a,b,c}` to the cross-product of its comma-separated
1391 // members and `{1..10}` to the integer range; RFC 6570 reserves
1392 // the matched pair for URI Template placeholders (the canonical
1393 // `https://{host}/{org}/{repo}` substitution shape every
1394 // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395 // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396 // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397 // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398 // shape) emit. POSIX `std::path::Path` treats both bytes as
1399 // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400 // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401 // sibling of `.` and `..`).
1402 //
1403 // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404 // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405 // expansion one-liner that fans across two siblings" footgun)
1406 // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407 // a `{{org}}` Mustache / Helm template placeholder out of a
1408 // README quick-start and forgot to substitute") silently passes
1409 // every prior arm because `Path::is_absolute` returns false on
1410 // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411 // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412 // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413 // byte isn't `/`. The resolver folds the value through
1414 // `Path::new(caminho).join(<file>)` looking for a literal
1415 // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416 // at resolve time with a non-self-locating `No such file or
1417 // directory` error far from the source caixa.lisp.
1418 //
1419 // The lacre pipeline embeds the value verbatim in its per-dep
1420 // content-address (`conteudo: format!("path:{caminho}")`,
1421 // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422 // lands in the BLAKE3 closure and rides downstream as part of
1423 // the build's identity into every shell-spawned subprocess
1424 // (the caixa-resolver's `git clone` invocation, a future
1425 // `feira tofu` shell-out, a future operator-side `nix flake
1426 // check` spawn) as the canonical shell-metachar / brace-
1427 // expansion surface every peer single-token-shaped typed
1428 // slot already closes. The peer git-source axis
1429 // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430 // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431 // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432 // shell-brace-expansion banner. The `:caminho` axis was the last
1433 // typed path-string surface still admitting these two bytes;
1434 // this arm closes the gap so the substrate-wide "no shell-
1435 // composition metacharacter anywhere in a typed string slot
1436 // that flows verbatim into a shell-spawned subprocess"
1437 // invariant extends from shell-subshell-grouping (`(` / `)`)
1438 // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439 // and the typed `:caminho` accepted set now also structurally
1440 // excludes the URI Template / templating-engine placeholder
1441 // surface that would silently round-trip through any
1442 // downstream IaC templating-engine layer.
1443 //
1444 // The arm fires AFTER the shell-subshell-grouping arm because
1445 // the prior arm's `(` / `)` shape is the more semantic-locating
1446 // axis on values that probe as both (`"../{cd foo}(date)"`
1447 // carries both `{` and `(` — the parenthesis-pair is the
1448 // load-bearing modern-Bourne-command-substitution surface the
1449 // prior arm closes; same cascade discipline every prior
1450 // `:caminho` arm establishes). The arm fires BEFORE the
1451 // trailing-`/` arm because the embedded brace-expansion byte
1452 // is the more semantic-locating axis on probe-as-both values
1453 // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454 // load-bearing diagnostic is the embedded `{` brace-expansion
1455 // metachar — the trailing `/` is the secondary observation,
1456 // and an author who removes the `{` is likely to also tab-
1457 // strip the trailing separator).
1458 for &b in caminho.as_bytes() {
1459 if b == b'{' || b == b'}' {
1460 return Err(DepError::fonte_caminho_shell_brace_expansion(
1461 nome, caminho, b,
1462 ));
1463 }
1464 }
1465 // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466 // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467 // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468 // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469 // footgun class, different syntactic surface. Every POSIX shell
1470 // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471 // bracket pair as the glob character-class operator: `[abc]`
1472 // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473 // ASCII letter; `[^x]` negates (the canonical
1474 // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475 // lowercase-sibling glob every shell-history block carries —
1476 // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477 // closing the unbounded pathname-expansion sentinels). The
1478 // bracket pair additionally carries the POSIX `test` /
1479 // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480 // the canonical idiom every shell-script conditional uses) and
1481 // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482 // bracket pair is the TOML inline-array delimiter
1483 // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484 // manifest cross-idiom-leak vector), the YAML flow-sequence
1485 // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486 // values.yaml cross-idiom leak), the JSON array delimiter,
1487 // and the POSIX-ERE / PCRE bracket-expression / character-
1488 // class anchor (the canonical paste-from-regex-doc shape).
1489 // POSIX `std::path::Path` treats both bytes as literal path-
1490 // component bytes (so `../[caixa-teia]` is one directory
1491 // named literally `../[caixa-teia]`, sibling of `.` and
1492 // `..`).
1493 //
1494 // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495 // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496 // one-liner that matches every lowercase-sibling-suffix
1497 // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498 // build"` (the symmetric "I pasted a TOML inline-array /
1499 // YAML flow-sequence shape out of an aligned manifest"
1500 // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501 // `*.[ch]` C-source character-class paste-from-shell-history
1502 // shape) silently passes every prior arm because
1503 // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504 // neither leading-byte sentinels nor control bytes nor `\`
1505 // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506 // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507 // last byte isn't `/`. The resolver folds the value through
1508 // `Path::new(caminho).join(<file>)` looking for a literal
1509 // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510 // time with a non-self-locating `No such file or directory`
1511 // error far from the source caixa.lisp.
1512 //
1513 // The lacre pipeline embeds the value verbatim in its per-dep
1514 // content-address (`conteudo: format!("path:{caminho}")`,
1515 // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516 // lands in the BLAKE3 closure and rides downstream as part of
1517 // the build's identity into every shell-spawned subprocess
1518 // (the caixa-resolver's `git clone` invocation, a future
1519 // `feira tofu` shell-out, a future operator-side `nix flake
1520 // check` spawn) as the canonical shell-metachar / glob-
1521 // character-class / TOML-array surface every peer single-
1522 // token-shaped typed slot already closes. The `:caminho` axis
1523 // was the last typed path-string surface still admitting
1524 // these two bytes; this arm closes the gap so the substrate-
1525 // wide "no shell-composition metacharacter anywhere in a
1526 // typed string slot that flows verbatim into a shell-spawned
1527 // subprocess" invariant extends from shell-brace-expansion
1528 // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529 // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530 // the typed `:caminho` accepted set now structurally excludes
1531 // the entire POSIX pathname-expansion / glob surface —
1532 // unbounded glob (`*` / `?`) AND bounded character-class
1533 // (`[abc]` / `[a-z]`).
1534 //
1535 // The arm fires AFTER the shell-brace-expansion arm because
1536 // the prior arm's `{` / `}` shape is the more semantic-
1537 // locating axis on values that probe as both
1538 // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539 // expansion fan is the load-bearing root-cause edit, so
1540 // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541 // discipline every prior `:caminho` arm establishes). The arm
1542 // fires BEFORE the trailing-`/` arm because the embedded
1543 // bracket-expansion byte is the more semantic-locating axis
1544 // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545 // load-bearing diagnostic is the embedded `[` glob-character-
1546 // class metachar — the trailing `/` is the secondary
1547 // observation, and an author who removes the `[` is likely
1548 // to also tab-strip the trailing separator).
1549 for &b in caminho.as_bytes() {
1550 if b == b'[' || b == b']' {
1551 return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552 nome, caminho, b,
1553 ));
1554 }
1555 }
1556 // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557 // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558 // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559 // delimiter pair — same paste-from-shell-prompt footgun class,
1560 // different syntactic surface. Every POSIX shell (sh / bash /
1561 // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562 // string-literal quoting operator: `'…'` is the strong
1563 // (no-expansion) single-quoted string and `"…"` is the weak
1564 // (variable-/command-substitution-preserving) double-quoted
1565 // string — the canonical `cd '../caixa-teia'` shell-history
1566 // idiom every path-with-embedded-whitespace paste block carries,
1567 // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568 // shape. Beyond shell, the two bytes carry the JSON string-literal
1569 // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570 // config cross-idiom-leak vector), the YAML double-quoted +
1571 // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572 // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573 // manifest cross-idiom leak), the TOML basic + literal string
1574 // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575 // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576 // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577 // — the canonical "I copied the entire `:caminho "..."` slot
1578 // rather than just the string body" author-surface footgun),
1579 // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580 // excludes both bytes from the `unreserved / pct-encoded /
1581 // sub-delims / ":" / "@"` `pchar` production. POSIX
1582 // `std::path::Path` treats both bytes as literal path-component
1583 // bytes (so `../"caixa-teia"` is one directory named literally
1584 // `../"caixa-teia"`, sibling of `.` and `..`).
1585 //
1586 // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587 // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588 // quoting preserved the sibling-workspace path verbatim across
1589 // the whitespace paste boundary" footgun), `:caminho
1590 // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591 // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592 // string / paste-from-tatara-lisp string-literal cross-idiom-
1593 // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594 // quote "I pasted a JSON key-value pair fragment into the
1595 // middle of the path" idiom) silently passes every prior arm
1596 // because `Path::is_absolute` returns false on `..` / `'` /
1597 // `"`, `'` / `"` are neither leading-byte sentinels nor
1598 // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599 // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600 // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601 // folds the value through `Path::new(caminho).join(<file>)`
1602 // looking for a literal `./'../caixa-teia'` subdirectory and
1603 // fails at resolve time with a non-self-locating `No such file
1604 // or directory` error far from the source caixa.lisp.
1605 //
1606 // The lacre pipeline embeds the value verbatim in its per-dep
1607 // content-address (`conteudo: format!("path:{caminho}")`,
1608 // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609 // lands in the BLAKE3 closure and rides downstream as part of
1610 // the build's identity into every shell-spawned subprocess
1611 // (the caixa-resolver's `git clone` invocation, a future
1612 // `feira tofu` shell-out, a future operator-side `nix flake
1613 // check` spawn) as the canonical shell-metachar / string-
1614 // literal-delimiter surface every peer single-token-shaped
1615 // typed slot already closes. The peer `:fonte :repo` axis
1616 // closes both bytes under the same shell-quote-grouping /
1617 // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618 // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619 // `:caminho` axis was the last typed path-string surface
1620 // still admitting these two bytes; this arm closes the gap
1621 // so the substrate-wide "no shell-composition metacharacter
1622 // anywhere in a typed string slot that flows verbatim into a
1623 // shell-spawned subprocess" invariant extends from shell-
1624 // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625 // / `"`) on the `:caminho` axis. Together with the peer
1626 // JSON / YAML / TOML string-literal delimiters closing at
1627 // this arm and the 598b770 `{` / `}` brace-expansion arm
1628 // closing the templating-engine-placeholder boundary, the
1629 // typed `:caminho` accepted set now structurally excludes
1630 // the entire cross-config-DSL string-literal / templating
1631 // paste-from-aligned-manifest cross-idiom-leak surface that
1632 // would silently round-trip through any downstream JSON /
1633 // YAML / TOML / HCL / tatara-lisp parsing layer.
1634 //
1635 // The arm fires AFTER the shell-bracket-expansion arm because
1636 // the prior arm's `[` / `]` shape is the more semantic-
1637 // locating axis on values that probe as both (`"../[a-z]'x'"`
1638 // carries both `[` and `'` — the glob-character-class
1639 // expansion is the load-bearing root-cause edit, so
1640 // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641 // discipline every prior `:caminho` arm establishes). The arm
1642 // fires BEFORE the trailing-`/` arm because the embedded
1643 // quote-grouping byte is the more semantic-locating axis on
1644 // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645 // the load-bearing diagnostic is the embedded `'` shell-
1646 // string-literal metachar — the trailing `/` is the secondary
1647 // observation, and an author who removes the `'` is likely to
1648 // also tab-strip the trailing separator).
1649 for &b in caminho.as_bytes() {
1650 if b == b'\'' || b == b'"' {
1651 return Err(DepError::fonte_caminho_shell_quote_grouping(
1652 nome, caminho, b,
1653 ));
1654 }
1655 }
1656 // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657 // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658 // the orthogonal "byte at which four distinct downstream parsers all
1659 // truncate the value at the first occurrence" surface, and no prior arm
1660 // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661 // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662 // of a word (or after unquoted whitespace) as the comment-lead: from
1663 // that byte to the end of the physical line is a comment discarded
1664 // before command parsing (`cd ../caixa-teia # legacy sibling` — the
1665 // canonical paste-from-shell-history-with-trailing-annotation shape
1666 // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667 // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668 // at any position preceded by whitespace or at line-start (`path:
1669 // ../caixa-teia # pin` — the canonical paste-from-values.yaml /
1670 // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671 // treats `;` as the comment-lead but a growing number of consumer
1672 // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673 // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674 // the comment-lead too — the pair extends the cross-config-DSL
1675 // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676 // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677 // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678 // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679 // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680 // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681 // `#` selects a flake output — the same axis the peer
1682 // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683 // surface at a68f818 with the same downstream-drops-the-tail
1684 // rationale).
1685 //
1686 // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687 // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688 // paste-from-shell-history-with-trailing-annotation footgun),
1689 // `:caminho "../caixa-teia # pin"` (the symmetric YAML flow-scalar
1690 // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691 // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692 // silently passes every prior arm because `Path::is_absolute` returns
1693 // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694 // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695 // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696 // and the value's last byte isn't `/`. The resolver folds the value
1697 // through `Path::new(caminho).join(<file>)` looking for a literal
1698 // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699 // resolve time with a non-self-locating `No such file or directory`
1700 // error far from the source caixa.lisp — while every downstream
1701 // shell / YAML / URL parser silently truncates the value at the `#`
1702 // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703 // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704 // an emitted YAML `path:` scalar disagree with the resolver on which
1705 // directory the value names. Two workstations whose downstream
1706 // shell / YAML / URL parsing layers differ in unquoted-`#`
1707 // recognition emit divergent build artifacts for the byte-identical
1708 // caixa.lisp value.
1709 //
1710 // The lacre pipeline embeds the value verbatim in its per-dep
1711 // content-address (`conteudo: format!("path:{caminho}")`,
1712 // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713 // closure and rides downstream as part of the build's identity into
1714 // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715 // invocation, a future `feira tofu` shell-out, a future operator-side
1716 // `nix flake check` spawn) as the canonical shell-metachar /
1717 // comment-lead / URL-fragment-delimiter surface every peer
1718 // single-token-shaped typed slot already closes. The peer `:fonte
1719 // :repo` axis closes the byte under the URL-fragment-identifier
1720 // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721 // the last typed path-string surface still admitting the byte. This
1722 // arm closes the gap so the substrate-wide "no shell-composition
1723 // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724 // typed string slot that flows verbatim into a shell-spawned
1725 // subprocess or downstream YAML / URL parser" invariant extends from
1726 // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727 // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728 // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729 // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730 // templating-engine-placeholder boundary, the typed `:caminho`
1731 // accepted set now structurally excludes the entire
1732 // paste-with-trailing-annotation / paste-from-URL-permalink /
1733 // paste-from-YAML-comment cross-idiom-leak surface that would
1734 // silently round-trip through any downstream shell / YAML / URL /
1735 // dotenv / gitconfig / HCL parsing layer to a different value than
1736 // the resolver's `Path::join` sees.
1737 //
1738 // The arm fires AFTER the shell-quote-grouping arm because the prior
1739 // arm's `'` / `"` shape is the more semantic-locating axis on values
1740 // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741 // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742 // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743 // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744 // trailing-`/` arm because the embedded comment-lead / fragment-
1745 // delimiter byte is the more semantic-locating axis on probe-as-both
1746 // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747 // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748 // observation, and an author who removes the `#pin` fragment is
1749 // likely to also tab-strip the trailing separator).
1750 for &b in caminho.as_bytes() {
1751 if b == b'#' {
1752 return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753 }
1754 }
1755 // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756 // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757 // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758 // byte — the mandatory encoding mechanism for every byte outside the
1759 // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760 // itself must be percent-encoded as `%25` to appear literally inside
1761 // a URL value. The byte carries three distinct render-determinism
1762 // hazards on the `:caminho` axis, no prior arm has covered it, and
1763 // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764 // already closes the same byte under the same URL-percent-encoding
1765 // banner — the `:caminho` axis was the last typed path-string surface
1766 // still admitting the byte.
1767 //
1768 // First, the paste-from-browser-address-bar percent-encoded-space
1769 // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770 // README hyperlink / a browser address bar / a percent-encoded
1771 // permalink expecting `%20` to decode to a literal space at the
1772 // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773 // literal path-component byte, so `Path::join` looks for a literal
1774 // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775 // non-self-locating `No such file or directory` error far from the
1776 // source caixa.lisp — while the author's mental model was
1777 // `../caixa teia`, the decoded shape. Two authors whose only
1778 // difference is percent-encoding presence resolve to two distinct
1779 // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780 // for what they intended as the byte-identical sibling-workspace
1781 // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782 // content-address (`conteudo: format!("path:{caminho}")`,
1783 // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784 // downstream into the BLAKE3 closure and locks the substrate's
1785 // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786 // to the wrong encoding — the same THEORY.md §V.2 render-
1787 // determinism vector every prior `:caminho` arm protects.
1788 //
1789 // Second, the printf-format-specifier lead footgun: `%` is the C /
1790 // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791 // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792 // shell-diagnostic one-liner carries) and the printf builtin is
1793 // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794 // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795 // value flowing into any future `feira` verb that shells out with a
1796 // printf-formatted path template silently gets reinterpreted as a
1797 // format-directive rather than a literal byte — the canonical
1798 // CWE-134 format-string-injection vector.
1799 //
1800 // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801 // ksh reserve `%N` at word-start as the job-control specifier —
1802 // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803 // "the most recent job whose command started with `foo`". A future
1804 // `feira` verb that invokes `kill %1` on a caminho-scoped
1805 // subprocess would silently redirect the signal to a wrong target.
1806 //
1807 // Beyond the three shell-side hazards, `%` is a first-class parser
1808 // byte in three cross-config-DSL layers the substrate's paste-idiom
1809 // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810 // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811 // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812 // YAML directive block silently trips the YAML directive parser on
1813 // any downstream emitted YAML manifest); Prometheus / Grafana
1814 // template syntax uses `%(var)s` as the substitution lead; and Nix
1815 // interpolation uses `${var}` (not `%`) but Envsubst /
1816 // Kubernetes / OpenShift template layers use `%VAR%` as the
1817 // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818 // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819 //
1820 // The three malformed-`%HH` classes documented on the peer
1821 // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822 //
1823 // - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824 // where `%` isn't followed by two hex digits) — every WHATWG-
1825 // conformant URL parser rejects the value at parse time per
1826 // RFC 3986 §2.1, but the byte rides into the lacre before
1827 // the resolver subprocess crosses the URL-parser boundary.
1828 // - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829 // intending the `%2F` as the URL encoding of `/`) locks a
1830 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831 // the byte-identical `path:../caixa/teia` form.
1832 // - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833 // already itself an encoded `%`, so the intent was likely a
1834 // literal `%20` that survived one round-trip through a
1835 // URL-encoder that shouldn't have run) locks a triply-
1836 // divergent closure across the encoded / once-decoded /
1837 // twice-decoded chain.
1838 //
1839 // POSIX `std::path::Path` treats the byte as a literal path-
1840 // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841 // paste-from-browser-address-bar percent-encoded-space footgun),
1842 // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843 // directive-block cross-idiom leak), or `:caminho
1844 // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845 // shell-diagnostic-one-liner shape) silently passes every prior arm
1846 // because `Path::is_absolute` returns false on `..`, `%` is neither
1847 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850 // value's last byte isn't `/`. The resolver folds the value through
1851 // `Path::new(caminho).join(<file>)` looking for a literal
1852 // subdirectory named `../caixa%20teia` and fails at resolve time
1853 // with a non-self-locating `No such file or directory` error far
1854 // from the source caixa.lisp — while every downstream URL parser /
1855 // shell printf builtin / YAML directive parser silently
1856 // reinterprets the byte to a different value than the resolver's
1857 // `Path::join` sees. Two workstations whose downstream URL / shell
1858 // / YAML layers differ in `%HH` recognition emit divergent build
1859 // artifacts for the byte-identical caixa.lisp value.
1860 //
1861 // The lacre pipeline embeds the value verbatim in its per-dep
1862 // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863 // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864 // closure and rides into every shell-spawned subprocess (the
1865 // resolver's `git clone`, a future `feira tofu` shell-out, a
1866 // future operator-side `nix flake check` spawn) as the canonical
1867 // URL-percent-encoding-escape / printf-format-specifier / bash-
1868 // job-control-specifier surface every peer single-token-shaped
1869 // typed slot already closes. This arm closes the gap so the
1870 // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871 // specifier / job-control-specifier / YAML-directive-lead byte
1872 // anywhere in a typed string slot that flows verbatim into a
1873 // shell-spawned subprocess or downstream URL / printf / YAML
1874 // parser" invariant extends from shell-comment / URL-fragment
1875 // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876 // `:caminho` axis.
1877 //
1878 // The arm fires AFTER the shell-comment arm because the prior
1879 // arm's `#` shape is the more semantic-locating axis on values
1880 // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881 // and `#` — the URL-fragment-identifier is the load-bearing
1882 // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883 // same cascade discipline every prior `:caminho` arm establishes).
1884 // The arm fires BEFORE the trailing-`/` arm because the embedded
1885 // percent-encoding-escape byte is the more semantic-locating axis
1886 // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887 // the load-bearing diagnostic is the embedded `%` percent-
1888 // encoding-escape — the trailing `/` is the secondary observation,
1889 // and an author who decodes the `%20` to a literal space is
1890 // likely to also tab-strip the trailing separator).
1891 for &b in caminho.as_bytes() {
1892 if b == b'%' {
1893 return Err(DepError::fonte_caminho_url_percent_encoding(
1894 nome, caminho, b,
1895 ));
1896 }
1897 }
1898 // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899 // command-substitution / arithmetic-expansion arm. The f4efe9c
1900 // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901 // through `FonteCaminhoVarExpansion` under the leading-byte-
1902 // sentinel host-layout-leak banner (peer with the b94fd83
1903 // absolute / a5c248e tilde leading-byte arms), but the arm
1904 // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905 // (embedded `$HOME` in a nested path segment — the canonical
1906 // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907 // an author copies a partially-substituted shell one-liner and
1908 // the leading segment is a literal `../foo` while the mid
1909 // segment carries the un-substituted `$HOME` template), a
1910 // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911 // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912 // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913 // (the paste-from-shell-prompt command-substitution idiom), or
1914 // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915 // idiom) silently passes every prior arm because
1916 // `Path::is_absolute` returns false on `..`, `$` is neither a
1917 // leading-byte sentinel (the f4efe9c arm fires only at position
1918 // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919 // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920 // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921 // value's last byte isn't `/`. Note that `$(...)` command-
1922 // substitution and `$((...))` arithmetic-expansion each carry
1923 // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924 // arm catches structurally at the earlier `(` position — but
1925 // an author who reaches for the sh-brace-substitution
1926 // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927 // which no prior arm covers. This arm closes the last
1928 // positional gap on the `$` byte on the `:caminho` axis so
1929 // every position — leading (`FonteCaminhoVarExpansion`) and
1930 // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931 // structurally rejected.
1932 //
1933 // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934 // ash / fish / nushell) lexes `$` as the variable-expansion /
1935 // command-substitution / arithmetic-expansion operator per
1936 // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937 // Expansion) expands a named variable, `${<name>}` (Parameter
1938 // Expansion braced form) does the same with an explicit token
1939 // boundary, `$(<cmd>)` (Command Substitution modern form,
1940 // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941 // already closes) runs a subshell and substitutes its stdout,
1942 // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943 // arithmetic expression. Every form is a host-layout /
1944 // environment-state / shell-subprocess-side-effect leak when
1945 // the byte lands in a value the resolver passes to a shell-
1946 // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947 // the Nix `${var}` string-interpolation lead (the paste-from-
1948 // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949 // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950 // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951 // variable lead (the paste-from-`Makefile` shape), the
1952 // JavaScript / TypeScript template-literal `${expr}` interp
1953 // lead (the paste-from-JS-template-string idiom in a
1954 // multi-lang-monorepo where a `path` attribute gets copied out
1955 // of a `package.json` script or a Vite config), the envsubst /
1956 // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957 // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958 // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959 // from-`.php`-config footgun), the Perl scalar-variable lead
1960 // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961 // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962 // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963 // cross-idiom paste-footgun surface is broader than any single
1964 // shell layer — `$` is a first-class parser byte in nearly
1965 // every config / templating / build-system DSL the substrate's
1966 // paste-idiom surface routinely crosses. The peer `:fonte
1967 // :repo` axis closes the byte under the shell-variable-
1968 // expansion / URL-sub-delim banner (b9d187c `$` on
1969 // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970 // axes close `$` as part of `is_git_ref_name`'s printable-
1971 // ASCII-restricted grammar (`git check-ref-format` rejects the
1972 // byte outright), and the peer `:entrada :paths` axis closes
1973 // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974 // reserved set. The `:caminho` axis was the last typed path-
1975 // string surface still admitting `$` at positions other than 0.
1976 //
1977 // POSIX `std::path::Path` treats `$` as a literal path-
1978 // component byte, so `:caminho "../foo$HOME/bar"` silently
1979 // routes through `Path::new(caminho).join(<file>)` looking for
1980 // a literal `./{caminho}` subdirectory that fails at resolve
1981 // time with a non-self-locating `No such file or directory`
1982 // error far from the source caixa.lisp. But every downstream
1983 // shell / envsubst / Nix / Make / K8s-template parser silently
1984 // reinterprets the byte to a different value than the
1985 // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986 // to a `cd '{caminho}'` command line, a `nix flake check`
1987 // invocation on an emitted YAML `path:` scalar folded through
1988 // envsubst, or a `helm template` invocation with a
1989 // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990 // template all disagree with the resolver on which directory
1991 // the value names. Two workstations whose downstream shell /
1992 // envsubst / Nix / Make / K8s-template parsing layers differ
1993 // in `$VAR` recognition (or, worse, expand the byte against
1994 // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995 // `$HOME=/home/bob`) emit divergent build artifacts for the
1996 // byte-identical caixa.lisp value. Even in the case where the
1997 // resolver strictly does NOT expand `$VAR` (the current
1998 // implementation) the divergence still bites at the lacre-
1999 // identity axis: the lacre pipeline embeds the value verbatim
2000 // in its per-dep content-address (`conteudo:
2001 // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002 // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003 // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004 // one author would have produced by substituting the literal
2005 // value at author time, defeating the THEORY.md §V.2 render-
2006 // determinism contract on the same axis every prior `:caminho`
2007 // arm protects.
2008 //
2009 // Beyond the render-determinism / host-layout-leak vectors,
2010 // `$` at any position in a value flowing verbatim into a
2011 // shell-spawned subprocess is the canonical CWE-78 shell-
2012 // command-injection surface every peer single-token-shaped
2013 // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014 // that rides into a future `feira tofu` shell-out as `cd
2015 // '../foo$(whoami)/bar'` gets substituted by the shell at
2016 // subprocess-argument-expansion time even inside single quotes
2017 // in fewer positions than one might expect (the substitution
2018 // fires only outside single-quoting per POSIX §2.2.2, but
2019 // eval-style wrappers and `sh -c` layers that route the value
2020 // through re-parsing round-trip the substitution — the same
2021 // vector the c370458 backtick arm closes at the sibling
2022 // command-substitution-legacy-form surface). Every future
2023 // `feira` verb that shells out with a `caminho`-formatted
2024 // subprocess argument silently inherits this substitution
2025 // vector unless the typed slot's accepted set structurally
2026 // excludes the byte.
2027 //
2028 // Frontier inspiration: OTP's `gen_server` return-value grammar
2029 // rejects mid-tuple shell-metachar bytes by construction —
2030 // `{noreply, State}` never carries a raw `$` because the
2031 // Erlang term type system has no notion of "string that gets
2032 // shelled out"; caixa's typed slots inherit the same
2033 // structural discipline (types-are-theorems, the compounding
2034 // mandate's leverage-point-1) by refusing values that would
2035 // silently reinterpret at any downstream layer. Peer with
2036 // Unison's content-addressed code (no ambient environment —
2037 // every reference is a hash, no `$VAR` substitution possible)
2038 // and Pony's capabilities (a path capability that carries a
2039 // `$` would be ill-typed at the reference layer).
2040 //
2041 // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042 // e3558fa `%` arm) because a value carrying both `%` and `$`
2043 // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044 // encoded space next to a `$HOME` template") surfaces the
2045 // narrower URL-encoding diagnostic first — the paste-from-
2046 // browser-address-bar shape is the load-bearing self-locating
2047 // edit on every probe-as-both value; same cascade discipline
2048 // every prior `:caminho` arm establishes (a323db8 % before
2049 // this arm, this arm before trailing-`/`). The arm fires
2050 // BEFORE the trailing-`/` arm because the embedded shell-
2051 // variable-expansion byte is the more semantic-locating axis
2052 // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053 // but the load-bearing diagnostic is the embedded `$` — the
2054 // trailing `/` is the secondary observation, and an author
2055 // who substitutes the `$HOME` template with a literal value is
2056 // likely to also tab-strip the trailing separator).
2057 for &b in caminho.as_bytes() {
2058 if b == b'$' {
2059 return Err(DepError::fonte_caminho_shell_variable_expansion(
2060 nome, caminho, b,
2061 ));
2062 }
2063 }
2064 // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065 // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066 // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067 // orthogonal POSIX shell-history-expansion sentinel every interactive
2068 // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069 // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070 // re-runs the most recent history entry beginning with `command`,
2071 // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072 // last word of the prior command, `!:N` substitutes the Nth word,
2073 // `^old^new` rewrites the prior command's `old` to `new` (the
2074 // canonical set of `set -o histexpand` operators bash's default
2075 // interactive session enables). Beyond the shell-history layer,
2076 // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077 // admits the byte inside a path segment, but every WHATWG-conformant
2078 // special-scheme URL parser percent-encodes it inside a query
2079 // component via the 'special-query percent-encode set' the peer
2080 // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081 // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082 // (logical-negation prefix — the paste-from-source-code idiom where
2083 // an author copies `!path.exists()` out of a Rust snippet and the
2084 // trailing punctuation crosses the string-literal boundary); the
2085 // canonical English-typography emphasis / exclamation mark (the
2086 // paste-from-prose enthusiasm-form idiom where an author writes
2087 // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088 // to a kebab-case slug); and the Nix flake-ref import-attribute
2089 // `import ./foo.nix { … }` sibling operator surface.
2090 //
2091 // POSIX `std::path::Path` treats `!` as a literal path-component
2092 // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093 // from-shell-history footgun where the author copies a `cd
2094 // ../caixa-teia && !sudo make install` one-liner from a quick-
2095 // start README and the trailing `!sudo` rides in verbatim as a
2096 // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097 // `!!` repeat-prior-command paste idiom), a `:caminho
2098 // "../caixa-teia!"` (the English-typography enthusiasm-form
2099 // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100 // last-word-substitution shape) silently pass every prior arm
2101 // because `Path::is_absolute` returns false on `..`, `!` is neither
2102 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105 // and the value's last byte isn't `/`. The resolver folds the value
2106 // through `Path::new(caminho).join(<file>)` looking for a literal
2107 // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108 // with a non-self-locating `No such file or directory` error far
2109 // from the source caixa.lisp — while every downstream interactive
2110 // shell with `set -o histexpand` reinterprets the byte as the
2111 // history-expansion prefix, and the failure mode forks per
2112 // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113 // line executed under `bash -i` (the operator-notebook interactive
2114 // shell) substitutes the `!sudo` reference to the most recent
2115 // history entry starting with `sudo`, silently invoking whatever
2116 // privileged command that entry named.
2117 //
2118 // The lacre pipeline embeds the value verbatim in its per-dep
2119 // content-address (`conteudo: format!("path:{caminho}")`,
2120 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121 // BLAKE3 closure and rides into every shell-spawned subprocess
2122 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123 // a future operator-side `nix flake check` spawn) as the
2124 // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125 // every peer single-token-shaped typed slot already closes. The
2126 // peer `:fonte :repo` axis closes the byte under the same shell-
2127 // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128 // `is_git_repo_url`); the `:caminho` axis was the last typed
2129 // path-string surface still admitting the byte. This arm closes
2130 // the gap so the substrate-wide "no shell-composition
2131 // metacharacter / history-expansion sentinel anywhere in a typed
2132 // string slot that flows verbatim into a shell-spawned subprocess"
2133 // invariant extends from shell-variable-expansion (`$`) to shell-
2134 // history-expansion (`!`) on the `:caminho` axis. Together with
2135 // the peer c370458 backtick command-substitution-legacy-form arm
2136 // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137 // sibling `:repo` axis, the typed `:caminho` accepted set now
2138 // structurally excludes every byte the POSIX shell §2.6 Word
2139 // Expansions section, §2.3 Token Recognition step 6, and every
2140 // history-expansion / brace-expansion / pathname-expansion /
2141 // parameter-expansion / command-substitution / arithmetic-
2142 // expansion operator lexes as a first-class parser byte.
2143 //
2144 // Frontier inspiration: Unison's content-addressed code (no
2145 // ambient environment — every reference is a hash, no `!<num>`
2146 // history-index substitution possible; the caixa substrate's
2147 // lacre discipline arrives at the same guarantee by refusing
2148 // bytes at manifest-parse time that would reinterpret against
2149 // ambient shell history state); Pony's capabilities (a path
2150 // capability that carries a `!` would be ill-typed at the
2151 // reference layer).
2152 //
2153 // The arm fires AFTER the shell-variable-expansion arm because a
2154 // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155 // canonical "I pasted a `$HOME`-templated path adjacent to a
2156 // trailing `!sudo` history-expansion") surfaces the narrower
2157 // shell-variable-expansion diagnostic first — the paste-from-CI-
2158 // manifest-with-`$VAR`-template shape is the load-bearing self-
2159 // locating edit on every probe-as-both value; same cascade
2160 // discipline every prior `:caminho` arm establishes. The arm
2161 // fires BEFORE the trailing-`/` arm because the embedded shell-
2162 // history-expansion byte is the more semantic-locating axis on
2163 // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164 // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165 // is the secondary observation, and an author who removes the
2166 // `!sudo` history reference is likely to also tab-strip the
2167 // trailing separator).
2168 for &b in caminho.as_bytes() {
2169 if b == b'!' {
2170 return Err(DepError::fonte_caminho_shell_history_expansion(
2171 nome, caminho, b,
2172 ));
2173 }
2174 }
2175 // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176 // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177 // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178 // (`0x5E`) is the paired-operator half of the same bash-reference
2179 // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180 // form (POSIX bash rewrites the prior command's `old` string to
2181 // `new` and re-executes it, the canonical typo-correction one-
2182 // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183 // trailing substitution fragment verbatim into a `:caminho` value
2184 // when the author trims only the leading `git clone` prefix). The
2185 // peer `:fonte :repo` axis closes the byte under the same
2186 // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187 // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188 // path-string surface still admitting the byte after 6a04767
2189 // landed the `!` arm.
2190 //
2191 // Beyond bash history-substitution, `^` carries five distinct
2192 // downstream-reinterpretation surfaces the typed slot's accepted
2193 // set must structurally exclude:
2194 //
2195 // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196 // layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197 // required to percent-encode-or-refuse at the wire boundary.
2198 // The WHATWG URL spec's 'fragment percent-encode set' maps
2199 // `^` → `%5E` at the query / fragment component transition;
2200 // libcurl silently percent-encodes the byte on the wire, so a
2201 // `:caminho "../foo^bar"` value the resolver's `Path::join`
2202 // sees as a literal `./../foo^bar` subdirectory diverges from
2203 // the byte-transformed `%5E` shape any downstream `feira tofu`
2204 // curl-invocation or artifact-registry-fetch would emit — the
2205 // canonical wire-boundary divergence vector the peer
2206 // `{`, `}`, `|`, `\` `:caminho` arms already close (
2207 // `FonteCaminhoShellBraceExpansion` at 598b770,
2208 // `FonteCaminhoShellPipe` at the pipe arm,
2209 // `FonteCaminhoBackslash` at the backslash arm).
2210 // 2. **Regex character-class negation prefix `[^abc]`** — the
2211 // canonical paste-from-doc-regex-pipeline footgun where an
2212 // author copies a `grep '[^abc]'` idiom from a docs quick-
2213 // listing and the character-class negation byte rides in
2214 // verbatim.
2215 // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216 // JavaScript / Nix / Go — the paste-from-source-code idiom
2217 // where an author copies an `x ^ y`-shaped expression out of
2218 // a source snippet and the operator crosses the string-
2219 // literal boundary.
2220 // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221 // escapes the next character in a `cmd.exe` batch context (a
2222 // peer of the backslash arm's Windows-separator-leak vector).
2223 // A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224 // file footgun reinterprets at every `cmd.exe`-spawned
2225 // subprocess (the resolver's future Windows-runner shell-out,
2226 // the operator's WinRM path, a future PowerShell-embedded
2227 // invocation).
2228 // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229 // paste-from-typeset-doc footgun where a mathematical
2230 // superscript notation (`x^2` / `M^T`) leaks from prose.
2231 //
2232 // POSIX `std::path::Path` treats `^` as a literal path-component
2233 // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234 // substitution), `:caminho "../foo^"` (trailing history-
2235 // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236 // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237 // arm at 986963b fires first on this shape), or `:caminho
2238 // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239 // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240 // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241 // / `"` / `#` / `%` / `$` / `!`) and route through
2242 // `Path::new(caminho).join(<file>)` looking for a literal
2243 // `./{caminho}` subdirectory that fails at resolve time with a
2244 // non-self-locating `No such file or directory` error far from
2245 // the source caixa.lisp — while every downstream shell / curl /
2246 // regex / `cmd.exe` layer reinterprets the byte to its own
2247 // semantic.
2248 //
2249 // The lacre pipeline embeds the value verbatim in its per-dep
2250 // content-address (`conteudo: format!("path:{caminho}")`,
2251 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252 // BLAKE3 closure and rides into every shell-spawned subprocess
2253 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254 // a future operator-side `nix flake check` spawn) as the
2255 // canonical shell-history-substitution / RFC-3986-unwise /
2256 // regex-negation surface every peer single-token-shaped typed
2257 // slot already closes. This arm together with the immediate-
2258 // predecessor `!` arm (6a04767) closes the full `set -o
2259 // histexpand` operator surface on the `:caminho` axis — the
2260 // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261 // quick-substitution form via `^` — so the substrate-wide "no
2262 // shell-history operator anywhere in a typed string slot that
2263 // flows verbatim into a shell-spawned subprocess" invariant
2264 // extends from the `!` prefix half to the `^` quick-substitution
2265 // half. Every peer bash-history operator now fails at manifest-
2266 // parse time with a self-locating diagnostic naming the offending
2267 // caixa.lisp rather than at resolve-time as a `Path::join`-
2268 // derived `No such file or directory` (harmless but non-self-
2269 // locating) or worse riding into a downstream `bash -i` context
2270 // that reinterprets the byte-pair against ambient history state.
2271 //
2272 // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273 // "Quick substitution. Repeat the previous command, replacing
2274 // string1 with string2." + RFC 3986 §2 'unwise' set
2275 // ("characters that gateways and other transport agents are
2276 // known to sometimes modify") + Pony's capabilities (a path
2277 // capability that carries a `^` would be ill-typed at the
2278 // reference layer, matching the same structural discipline the
2279 // sibling `!` history-expansion arm inherits from Unison's
2280 // content-addressed no-ambient-history discipline).
2281 //
2282 // The arm fires AFTER the shell-history-expansion `!` arm because
2283 // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284 // the canonical "I pasted a `!sudo` history-reference next to a
2285 // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286 // form `!` diagnostic first — the `!` form is the load-bearing
2287 // self-locating edit on every probe-as-both value (an author who
2288 // removes the `!sudo` reference is likely to also strip the
2289 // paired `^` substitution fragment); same cascade discipline
2290 // every prior `:caminho` arm establishes. The arm fires BEFORE
2291 // the trailing-`/` arm because the embedded shell-history-
2292 // substitution byte is the more semantic-locating axis on
2293 // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294 // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295 // is the secondary observation, and an author who removes the
2296 // `^bar` substitution fragment is likely to also tab-strip the
2297 // trailing separator).
2298 for &b in caminho.as_bytes() {
2299 if b == b'^' {
2300 return Err(DepError::fonte_caminho_shell_history_substitution(
2301 nome, caminho, b,
2302 ));
2303 }
2304 }
2305 // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306 // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307 // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308 // backslash arm closes the cross-host-OS-separator vector. The
2309 // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310 // footgun — `Path::join("../caixa-teia")` and
2311 // `Path::join("../caixa-teia/")` resolve to the same directory
2312 // (POSIX path-component-walk treats trailing `/` as a no-op for
2313 // directory targets, which `:caminho` always names — the sibling-
2314 // workspace dep root is structurally a directory). The lacre
2315 // pipeline embeds the value verbatim in its per-dep content-address
2316 // (`conteudo: format!("path:{caminho}")`,
2317 // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318 // semantic-meaning yields two distinct BLAKE3 closures depending on
2319 // whether the author shell-tab-completed the path (every interactive
2320 // shell appends `/` on tab-completing a directory, idiomatic in
2321 // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322 // shells emits without trailing `/`, but `realpath -e -m` on a
2323 // directory with trailing `/` preserves it), or copied a Cargo
2324 // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325 // (Cargo accepts both shapes and folds them the same way). Two
2326 // workstations whose authors differ only in tab-completion habits
2327 // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328 // and the substrate's "the lacre is the build's identity" contract
2329 // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330 //
2331 // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332 // arm protects, here against the trailing-separator divergence
2333 // vector: every typed slot's accepted set excludes byte-divergent
2334 // values that round-trip to the same downstream semantic. The peer
2335 // path-shaped axes already reject trailing separators on the same
2336 // contract: [`crate::render::is_gateway_api_http_path`] gates
2337 // `:entrada :paths` against any non-canonical normalization, and
2338 // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339 // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340 // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341 // whose canonical form would re-introduce determinism divergence.
2342 //
2343 // The arm fires last in the cascade because every prior arm carries
2344 // a more self-locating diagnostic on values that probe as both
2345 // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346 // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347 // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348 // the load-bearing diagnostic is the absolute host-layout-leak —
2349 // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350 // but the load-bearing diagnostic is the Windows-separator cross-
2351 // OS divergence — the backslash arm wins). The arm covers every
2352 // shape where the last byte is `/` regardless of length, including
2353 // the degenerate single-`/` (which the absolute arm catches first)
2354 // and the consecutive-`//` (where every prior arm passes on the
2355 // bytes other than the trailing `/`).
2356 if caminho.as_bytes().last() == Some(&b'/') {
2357 return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358 }
2359 Ok(())
2360 }
2361}
2362
2363impl Dep {
2364 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365 /// accessor every consumer of the dep-graph identity axis keys off —
2366 /// returns the author-declared `:nome` byte-string verbatim as a
2367 /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368 ///
2369 /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370 /// label that names the target caixa (validated by [`Self::validate`]
2371 /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372 /// same accept-set the peer caixa-identifier axes carry — top-level
2373 /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374 /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375 /// downstream consumer that fans on the dep's name-identity keys off
2376 /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377 /// [`crate::render::insert_first_seen`] dedup key + the paired
2378 /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379 /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380 /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381 /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382 /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383 /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384 /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385 /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386 /// every `caixa-resolver` `ResolveError::MissingPath` /
2387 /// `ResolveError::MissingPin` carrier that names the offending dep
2388 /// (`resolve.rs:177,206`), each resolved
2389 /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390 /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391 /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392 ///
2393 /// Prior to this lift the `.nome` byte-string was read inline at every
2394 /// production site — the [`crate::Caixa::validate_deps`] paired
2395 /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396 /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397 /// parent-equality checks, and every caixa-resolver / caixa-feira
2398 /// site enumerated above — open-coded field-accesses that expressed
2399 /// no compile-time link back to the typed slot. A future extension of
2400 /// the `:deps :nome` axis to a richer author surface (a per-scope
2401 /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402 /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403 /// namespace-qualified rewrite the future M4 lacre-federation layer
2404 /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405 /// to a richer scoped-identifier newtype once cross-registry federation
2406 /// lands) would have had to be threaded through every open-coded copy
2407 /// in lockstep or two consumers would silently disagree on which caixa
2408 /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409 /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410 /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411 /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412 /// requeue-suppression seen-set, one build-time diagnostic
2413 /// disagreeing with the run-time closure the substrate's lacre
2414 /// pipeline actually materializes. Lifting the resolution rule to a
2415 /// typed method on the substrate primitive means every downstream
2416 /// consumer of the caixa's per-`:deps` identity surface reaches for
2417 /// exactly one typed dispatch — the resolver's accept-set migrates as
2418 /// a unit on any future axis addition.
2419 ///
2420 /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421 /// `&str`-return required-scalar projection pattern the sibling
2422 /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423 /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424 /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425 /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426 /// accessors — same "one typed dispatch on the substrate primitive,
2427 /// thin projections at each consumer" discipline extended onto the
2428 /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429 /// remaining unlifted caixa-name-referencing accessor family in the
2430 /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431 /// term the field's docstring already reaches for ("Caixa name — must
2432 /// match the target caixa's `:nome`") and the peer caixa-identity
2433 /// accessor family the substrate already carries.
2434 #[must_use]
2435 pub const fn nome(&self) -> &str {
2436 self.nome.as_str()
2437 }
2438
2439 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440 /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441 /// the dep-graph version-pin axis keys off — returns the author-
2442 /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443 /// borrowed from the typed slot's own [`String`] storage.
2444 ///
2445 /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446 /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447 /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448 /// entry-point consumes — same accept-set the peer requirement-
2449 /// carrying axes carry (per-`:membros`
2450 /// [`crate::Membro::versao_requirement`], per-`:children`
2451 /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452 /// through the shared
2453 /// [`crate::render::require_valid_versao_requirement`] cascade in
2454 /// [`Self::validate`]. Every downstream consumer that fans on the
2455 /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456 /// `require_valid_versao_requirement` gate + the paired
2457 /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458 /// requirement-shape rejection, the `feira lock` stub-resolver's
2459 /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460 /// `conteudo` hash-input interpolation and the paired
2461 /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462 /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463 ///
2464 /// Prior to this lift the `.versao` byte-string was read inline at
2465 /// every production site — the [`Self::validate`] paired
2466 /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467 /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468 /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469 /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470 /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471 /// same shapes — open-coded field-accesses that expressed no
2472 /// compile-time link back to the typed slot. A future extension of
2473 /// the `:deps :versao` axis to a richer author surface (a per-scope
2474 /// version-lock overlay the resolver folds through the
2475 /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476 /// docstring already acknowledges, a per-cluster canary-version
2477 /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478 /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479 /// once cross-registry federation lands) would have had to be
2480 /// threaded through every open-coded copy in lockstep or two
2481 /// consumers would silently disagree on which release constraint a
2482 /// given dep resolves to — the [`Self::validate`] requirement-gate
2483 /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484 /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485 /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486 /// content-addressed hash the substrate's fetch pipeline actually
2487 /// materializes, one build-time diagnostic disagreeing with the
2488 /// run-time closure. Lifting the resolution rule to a typed method
2489 /// on the substrate primitive means every downstream consumer of
2490 /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491 /// one typed dispatch — the resolver's accept-set migrates as a
2492 /// unit on any future axis addition.
2493 ///
2494 /// Second accessor on the outer `Dep` type — folds on the outer-
2495 /// `Dep` `&str`-return required-scalar projection pattern the
2496 /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497 /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498 /// (a40b0e3) / per-`:children`
2499 /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500 /// family) member/child version-pin accessors — the three
2501 /// requirement-carrying axes (`Dep::versao_requirement` on the
2502 /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503 /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504 /// Supervisor side) now share one accessor discipline for the
2505 /// shared substrate concept "another caixa referenced by a
2506 /// Cargo-shaped semver requirement". The pair
2507 /// `(nome(), versao_requirement())` jointly projects the
2508 /// `(nome, versao)` field pair every dep-graph consumer that fans
2509 /// on per-dep identity + version pin keys off. Named
2510 /// `versao_requirement()` rather than `versao()` because the field's
2511 /// storage-side `.versao` label is already the author-surface term
2512 /// (`:versao`); the accessor's name carries the semantic role — the
2513 /// semver *requirement* string the shared
2514 /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515 /// raw field access and a typed dispatch read differently at every
2516 /// consumer site. Matches the peer
2517 /// [`crate::Membro::versao_requirement`] /
2518 /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519 /// discipline verbatim.
2520 #[must_use]
2521 pub const fn versao_requirement(&self) -> &str {
2522 self.versao.as_str()
2523 }
2524
2525 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526 /// Zig-store-model per-dep source-tuple optional-composite-reference
2527 /// accessor every consumer of the dep-graph fetch-source axis keys
2528 /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529 /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530 /// own `Option<DepSource>` storage, with `None` naming the "author
2531 /// omitted `:fonte`" shorthand every resolver-side default-fill
2532 /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533 /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534 /// the [`Dep::fonte`] field docstring already documents) treats as
2535 /// the "resolve through the configured default host / org
2536 /// (`github:<default-org>/<nome>`)" partition.
2537 ///
2538 /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539 /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540 /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541 /// rev, branch }` for the git-clone arm every published caixa
2542 /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543 /// local-filesystem arm every unpublishable in-tree checkout
2544 /// resolves through. Every downstream consumer that fans on the
2545 /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546 /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547 /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548 /// diagnostics through the [`DepError::Fonte*`] carrier family
2549 /// naming the offending `Dep::nome`), the caixa-crd conversion
2550 /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551 /// `{repo, git_ref}` pair the K8s-CR side consumes
2552 /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553 /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554 /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555 /// concrete `DepSource` at run time.
2556 ///
2557 /// Prior to this lift the `.fonte` typed slot was read inline at
2558 /// every production site — the [`Self::validate`]
2559 /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560 /// gate delegates through, the caixa-crd `dep_into_ref`
2561 /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562 /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563 /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564 /// coded field-accesses that expressed no compile-time link back to
2565 /// the typed slot. A future extension of the `:deps :fonte` axis
2566 /// to a richer author surface (a per-scope source-override table
2567 /// the resolver folds through the `~/.config/caixa/config.yaml`
2568 /// entry the [`Dep`] docstring already acknowledges, a per-org
2569 /// mirror-fallback list the future M4 lacre-federation resolver
2570 /// consults ahead of the `default_github` fallback, a promotion of
2571 /// the plain `Option<DepSource>` to a richer
2572 /// `{primary, mirrors, integrity}` triple once cross-registry
2573 /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574 /// M4 lacre gate binds against ahead of the git-fetch) would have
2575 /// had to be threaded through every open-coded copy in lockstep or
2576 /// two consumers would silently disagree on which fetch source a
2577 /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578 /// gate reading the author-declared source while the caixa-crd
2579 /// projector read a per-scope-override-resolved source would
2580 /// silently split the build-time refusal from the CR the
2581 /// substrate's admission pipeline actually materializes, one
2582 /// build-time diagnostic disagreeing with the run-time closure.
2583 /// Lifting the resolution rule to a typed method on the substrate
2584 /// primitive means every downstream consumer of the caixa's per-
2585 /// `:deps` fetch-source surface reaches for exactly one typed
2586 /// dispatch — the resolver's accept-set migrates as a unit on any
2587 /// future axis addition.
2588 ///
2589 /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590 /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591 /// reference projection pattern the sibling per-`Dep` `:opcional`
2592 /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593 /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594 /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595 /// `Option<&Composite>` composite-reference sub-family the
2596 /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597 /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598 /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599 /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600 /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601 /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602 /// accessor already carries — extends that "one typed dispatch on
2603 /// the substrate primitive, thin projections at each consumer"
2604 /// discipline onto the third outer typed-slot altitude that carries
2605 /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606 /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607 /// copy or clone) because every downstream consumer of the fonte
2608 /// composite treats it as a read-only per-arm dispatch source — the
2609 /// reference-view is the narrowest borrow that supports every
2610 /// present + roadmapped consumer (per-arm match projection at the
2611 /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612 /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613 /// `default_github` fill applies" partition every resolver
2614 /// consults, `.cloned()`-on-demand for the two resolver-side
2615 /// default-fill call sites that require an owned `DepSource` for
2616 /// `Option::unwrap_or_else`) without cloning the composite through
2617 /// every consumer's fast path. The `Option` half of the return-type
2618 /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619 /// side default applies" partition (not a default composite the
2620 /// downstream must reject on emptiness) — the accessor projects the
2621 /// raw `Option<DepSource>` slot's presence bit through the
2622 /// reference-return unchanged. Named `fonte()` to match the storage
2623 /// field's name verbatim and the tatara-lisp author-surface term
2624 /// (`:fonte`) the field's own docstring already carries.
2625 ///
2626 /// Declared `pub const fn` — the body projects through
2627 /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628 /// well within the workspace MSRV, so every downstream `const`-
2629 /// context consumer of the per-`Dep` `:fonte` composite-reference
2630 /// accessor reaches through the same typed dispatch on the
2631 /// substrate primitive at const-eval time as at runtime. The
2632 /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633 /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634 /// that forwards through each lifted accessor) locks the posture
2635 /// load-bearing at caixa-core build time — any future accidental
2636 /// downgrade to non-`const` fails the wrapper with E0015
2637 /// (`cannot call non-const method`), strictly stronger than a
2638 /// runtime `assert!` and side-stepping the destructor-in-const
2639 /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640 /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641 /// `WitContract` pre-projection accessor family's `const`-eval-
2642 /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643 /// accessor family's parallel pass (231a968) — same "one canonical
2644 /// dispatch per axis, `const`-eval posture pinned at the substrate
2645 /// primitive, thin projections at each consumer" discipline
2646 /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647 ///
2648 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649 #[must_use]
2650 pub const fn fonte(&self) -> Option<&DepSource> {
2651 self.fonte.as_ref()
2652 }
2653
2654 /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655 /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656 /// every consumer of the dep-graph feature-flag axis keys off —
2657 /// returns the author-declared `:caracteristicas` feature-name list
2658 /// verbatim as a `&[String]` slice-view over the same backing buffer
2659 /// the raw `self.caracteristicas.as_slice()` field access borrows
2660 /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661 /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662 /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663 /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664 /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665 /// — possibly empty — and the returned `&[String]` degenerates to
2666 /// an empty slice on that arm without any silent `None` collapse).
2667 ///
2668 /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669 /// carries the set-shaped feature-toggle list the substrate walks
2670 /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671 /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672 /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673 /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674 /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675 /// walk, empty-first / value-shape-second / duplicate-third
2676 /// precedence via the peer per-axis two-arm cascade discipline every
2677 /// substrate-blessed Vec-keyed-by-name slot already follows).
2678 /// Every downstream consumer that fans on the dep's feature-toggle
2679 /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680 /// per-entry linear walk that gates each feature-name byte-string
2681 /// through the empty / value-shape / duplicate arms (raising the
2682 /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683 /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684 /// offending `Dep::nome`), and every future
2685 /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686 /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687 /// future caixa-resolver per-dep feature-projection walk that folds
2688 /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689 /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690 /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691 /// features slice the K8s-CR admission gate consumes, the future
2692 /// per-cluster feature-overlay the M4 lacre-federation resolver
2693 /// composes ahead of the substrate-wide feature-name accept-set).
2694 ///
2695 /// Prior to this lift the `.caracteristicas` byte-string list was
2696 /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697 /// &self.caracteristicas` walk — the only in-crate consumer of the
2698 /// raw field beyond the per-`Dep` constructor pair
2699 /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700 /// round-trip / per-test fixture-mutation paths — an open-coded
2701 /// field-access that expressed no compile-time link back to the
2702 /// typed slot. A future extension of the `:caracteristicas` axis to
2703 /// a richer author surface (a per-scope feature-overlay the resolver
2704 /// folds through the `~/.config/caixa/config.yaml` entry the
2705 /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706 /// activation overlay the future M4 lacre-federation layer applies
2707 /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708 /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709 /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710 /// docstring anticipates lands) would have had to be threaded
2711 /// through every open-coded copy in lockstep or two consumers
2712 /// would silently disagree on which feature closure a given dep
2713 /// activates — the [`Self::validate_caracteristicas`] gate walking
2714 /// the author-declared list while a downstream caixa-resolver
2715 /// consumer walked a per-scope-override-resolved list would
2716 /// silently split the build-time refusal from the lacre closure
2717 /// the substrate's fetch pipeline actually materializes, one
2718 /// build-time diagnostic disagreeing with the run-time closure.
2719 /// Lifting the resolution rule to a typed method on the substrate
2720 /// primitive means every downstream consumer of the caixa's per-
2721 /// `:deps` feature-toggle surface reaches for exactly one typed
2722 /// dispatch — the resolver's accept-set migrates as a unit on any
2723 /// future axis addition.
2724 ///
2725 /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726 /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727 /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728 /// future outer scalar lift folds on and closes the outer-`Dep`
2729 /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731 /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732 /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733 /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734 /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735 /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736 /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737 /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738 /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739 /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740 /// altitude — extends the "one typed dispatch on the substrate
2741 /// primitive, thin projections at each consumer" discipline onto the
2742 /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743 /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744 /// because every downstream consumer of the feature-toggle list
2745 /// treats it as a read-only sequence — the slice-view is the
2746 /// narrowest borrow that supports every present + roadmapped
2747 /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748 /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749 /// the typed view reaches for (the storage-side `Vec` remains
2750 /// reachable through the `pub caracteristicas` field for the
2751 /// mutation-carrying serde round-trip and per-test fixture-mutation
2752 /// paths). Named `caracteristicas()` to match the storage field's
2753 /// name verbatim and the tatara-lisp author-surface term
2754 /// (`:caracteristicas`) the field's own docstring already carries.
2755 ///
2756 /// Declared `pub const fn` — the body projects through
2757 /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758 /// well within the workspace MSRV, so every downstream `const`-
2759 /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760 /// accessor reaches through the same typed dispatch on the
2761 /// substrate primitive at const-eval time as at runtime. Pinned
2762 /// load-bearing by the paired
2763 /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764 /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765 /// the full pin-shape rationale.
2766 ///
2767 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768 #[must_use]
2769 pub const fn caracteristicas(&self) -> &[String] {
2770 self.caracteristicas.as_slice()
2771 }
2772
2773 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774 /// missing-source-tolerance flag scalar accessor every consumer of
2775 /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776 /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777 /// typed slot's own `bool` storage (no borrow of `&self` past the
2778 /// call; the `Copy`-return arm matches the peer
2779 /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780 /// projected sibling discipline the outer flat-spread family
2781 /// already carries). Default-`false` (`#[serde(default,
2782 /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783 /// `Dep` past parse definitionally carries a `bool` — `false` when
2784 /// the author omits `:opcional` — and the returned value degenerates
2785 /// to `false` on that arm without any silent `None` collapse).
2786 ///
2787 /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788 /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789 /// missing-source arm as a soft-fail rather than a build refusal"
2790 /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791 /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792 /// dropped from the resolved dep-graph rather than tripping the
2793 /// build-refusal edge that a mandatory `:opcional false` entry
2794 /// would). Every downstream consumer that fans on the dep's
2795 /// missing-source-tolerance keys off this accessor: the future
2796 /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797 /// dispatch on the opcional bit ahead of the lacre closure
2798 /// materialization), the future caixa-crd per-`spec.deps`
2799 /// `optional` boolean the K8s-CR admission gate consumes on the
2800 /// per-dep partition, and the future feira / caixa-resolver /
2801 /// caixa-crd feature-projection walk that folds the opcional bit
2802 /// into the resolved feature-closure the future M4 lacre-federation
2803 /// layer emits.
2804 ///
2805 /// Prior to this lift the `.opcional` `bool` slot was read inline
2806 /// at the sole in-crate consumer site — the tests-module
2807 /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808 /// pinning the [`Self::simple`] constructor's default-`false` fill
2809 /// (the only in-crate read of the raw field beyond the per-`Dep`
2810 /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811 /// serde round-trip / per-test fixture-mutation paths) — an open-
2812 /// coded field-access that expressed no compile-time link back to
2813 /// the typed slot. A future extension of the `:opcional` axis to a
2814 /// richer author surface (a per-scope opcional-override the resolver
2815 /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816 /// docstring already acknowledges, a per-cluster opcional-override
2817 /// the future M4 lacre-federation layer applies per-CR, a promotion
2818 /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819 /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820 /// roadmap lands) would have had to be threaded through every open-
2821 /// coded copy in lockstep or two consumers would silently disagree
2822 /// on which missing-source arm a given dep resolves to — the
2823 /// [`Self::simple`] constructor's default-`false` fill reading
2824 /// verbatim while a downstream caixa-resolver consumer read a per-
2825 /// scope-override-resolved bit would silently split the build-time
2826 /// arm from the lacre closure the substrate's fetch pipeline
2827 /// actually materializes, one build-time diagnostic disagreeing
2828 /// with the run-time closure. Lifting the resolution rule to a
2829 /// typed method on the substrate primitive means every downstream
2830 /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831 /// reaches for exactly one typed dispatch — the resolver's accept-
2832 /// set migrates as a unit on any future axis addition.
2833 ///
2834 /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835 /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837 /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838 /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839 /// `:caracteristicas`) now routes through exactly one typed
2840 /// dispatch on the substrate primitive. First outer-`Dep`
2841 /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842 /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843 /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844 /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845 /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846 /// already carries — extends the "one typed dispatch on the
2847 /// substrate primitive, thin projections at each consumer"
2848 /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849 /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850 /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851 /// every downstream consumer treats it as a plain discriminant
2852 /// value — the by-value return is the narrowest return-shape that
2853 /// supports every present + roadmapped consumer (`.then(…)` early
2854 /// return on the resolver-side drop-vs-error partition, direct
2855 /// bool composition with a per-scope-override projector, plain
2856 /// `if dep.opcional() { … }` early return at every future admission
2857 /// gate) without leaking the storage field's `bool`-in-`&self`
2858 /// lifetime the by-value return elides. Marked `pub const fn` so
2859 /// the accessor is `const`-callable — same discipline the peer
2860 /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861 /// accessor carries. Named `opcional()` to match the storage
2862 /// field's name verbatim and the tatara-lisp author-surface term
2863 /// (`:opcional`) the field's own docstring already carries.
2864 #[must_use]
2865 pub const fn opcional(&self) -> bool {
2866 self.opcional
2867 }
2868
2869 /// Build a minimal registry-sourced dep.
2870 #[must_use]
2871 pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872 Self {
2873 nome: nome.into(),
2874 versao: versao.into(),
2875 fonte: None,
2876 opcional: false,
2877 caracteristicas: Vec::new(),
2878 }
2879 }
2880
2881 /// Build a Git-sourced dep (tag-based).
2882 #[must_use]
2883 pub fn git(
2884 nome: impl Into<String>,
2885 versao: impl Into<String>,
2886 repo: impl Into<String>,
2887 tag: impl Into<String>,
2888 ) -> Self {
2889 Self {
2890 nome: nome.into(),
2891 versao: versao.into(),
2892 fonte: Some(DepSource::Git {
2893 repo: repo.into(),
2894 tag: Some(tag.into()),
2895 rev: None,
2896 branch: None,
2897 }),
2898 opcional: false,
2899 caracteristicas: Vec::new(),
2900 }
2901 }
2902
2903 /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904 /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905 /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906 /// semver requirement.
2907 ///
2908 /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909 /// is the same Cargo-shaped requirement string `:membros :versao`
2910 /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911 /// and `:children :versao` (validated at
2912 /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913 /// the lacre pipeline resolves all three axes through the same
2914 /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915 /// `:deps :versao` was the last `:versao` axis untyped past
2916 /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917 /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918 /// leaking-into-:versao `"v0.1"` typo, the accidental
2919 /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920 /// surfaced at lacre-resolve time, far from the source
2921 /// caixa.lisp, with no field naming which `:deps` entry carried
2922 /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923 /// the offending entry's `:nome` + the offending `:versao`
2924 /// verbatim + the parser's own wording in `reason`, so the
2925 /// author's grep target is unambiguous.
2926 ///
2927 /// The author surface for `:deps :nome` is the same DNS-1123 label
2928 /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929 /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930 /// `:membros :caixa` (validated at
2931 /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932 /// `:children :caixa` (validated at
2933 /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934 /// :nome` value flows verbatim through the lacre pipeline as the
2935 /// target caixa's `:nome` (which the gate at the *target* side now
2936 /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937 /// `lareira-<nome>` Helm chart name segment, the per-dep
2938 /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939 /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940 /// this gate landed `:deps :nome` was the fourth and last
2941 /// DNS-1123-shaped caixa-identifier axis still untyped past
2942 /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943 /// Teia"` uppercase — the canonical "I copied the README header"
2944 /// typo; `"caixa_teia"` underscore — the Go module / Python
2945 /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946 /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947 /// silently passed parse and surfaced at lacre-resolve time when
2948 /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949 /// — far from the source `:deps` entry, with a diagnostic naming
2950 /// the *target's* `:nome` rather than the dep entry that referenced
2951 /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952 /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953 /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954 /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955 /// so every downstream consumer (caixa-resolver's lacre fetch,
2956 /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957 /// fan-out emitter) reaches for the name knowing the value is
2958 /// apiserver-valid without re-validating.
2959 ///
2960 /// Empty checks fire first (narrower diagnostic), parse last —
2961 /// same ordering discipline as
2962 /// [`crate::AplicacaoSpec::validate_membros`] and
2963 /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964 /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965 /// structurally necessary even with the parse arm in place. The
2966 /// `:nome` shape gate runs after the `:nome` empty gate and before
2967 /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968 /// sees the name-side diagnostic first (the name is the
2969 /// self-locating axis — without it, the parse diagnostic can't
2970 /// quote `:nome "<bad>"`).
2971 pub fn validate(&self) -> Result<(), DepError> {
2972 if self.nome.is_empty() {
2973 return Err(DepError::NomeEmpty);
2974 }
2975 if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976 return Err(DepError::nome_invalid(&self.nome, reason));
2977 }
2978 // Delegate the empty-first + `parse_requirement` cascade to the
2979 // shared [`crate::render::require_valid_versao_requirement`]
2980 // helper — same two-arm shape the peer
2981 // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982 // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983 // :versao` route through, so drift between the three axes'
2984 // accepted requirement sets is structurally impossible and the
2985 // parse-side no-op the empty-first arm closes (semver's empty
2986 // parse yields an implicit `*`) lives in exactly one predicate.
2987 crate::render::require_valid_versao_requirement(
2988 self.versao_requirement(),
2989 || DepError::versao_empty(&self.nome),
2990 |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991 )?;
2992 if let Some(fonte) = self.fonte() {
2993 fonte.validate(&self.nome)?;
2994 }
2995 self.validate_caracteristicas()?;
2996 Ok(())
2997 }
2998
2999 /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000 /// are operationally meaningless. The `:caracteristicas` slot is
3001 /// a set of feature toggles to enable on the target caixa — same
3002 /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003 /// two structural footguns close here:
3004 ///
3005 /// - empty-string entry (`(:caracteristicas (""))`): the future
3006 /// caixa-resolver lacre pipeline would consume the empty
3007 /// identifier as a no-op feature enable, silently dropping the
3008 /// author's intent far from the source `caixa.lisp`;
3009 /// - duplicate entry within one dep (`(:caracteristicas ("http"
3010 /// "http"))`): the feature-toggle slot is set-shaped (enabling
3011 /// a feature twice has no additional semantic — there is no
3012 /// `feature × 2`), so two entries naming the same feature are
3013 /// a silent miscount, the same set-not-multiset distinction
3014 /// every peer Vec-keyed-by-name axis already closes
3015 /// ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016 /// `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017 /// on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018 /// on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019 /// on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020 /// on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021 /// on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022 /// / [`crate::UpgradeError::DuplicateStateChange`] /
3023 /// [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024 /// entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025 /// on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026 /// immediate-predecessor 359fba5 closed).
3027 ///
3028 /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029 /// every peer set-not-multiset gate uses; the empty arm fires
3030 /// before the duplicate arm so an entry with both an empty feature
3031 /// *and* a duplicate of some later feature surfaces the empty-
3032 /// shape diagnostic first (the empty-feature axis is the
3033 /// more-actionable defect since the missing-name renders the
3034 /// duplicate-key arm ambiguous: two `""` entries would both report
3035 /// `caracteristica: ""` with no way to distinguish the offending
3036 /// site). Empty-first cascade discipline mirrors every peer per-
3037 /// entry shape + duplicate gate
3038 /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039 /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040 /// before `MembroDuplicate`).
3041 ///
3042 /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043 /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044 /// fires between the empty arm and the duplicate arm — the
3045 /// canonical per-entry-shape-before-cross-entry-uniqueness
3046 /// precedence every peer two-arm + value-shape gate establishes
3047 /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048 /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049 /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050 /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051 /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052 /// Until the value-shape arm landed `:caracteristicas` accepted
3053 /// every non-empty distinct string — a structurally invalid
3054 /// feature name (`"http feature"` whitespace, `"+http"` the
3055 /// canonical paste-from-`+optional-feature` doc activation-form
3056 /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057 /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058 /// only applies inside list-grammar contexts, `"http,json"`
3059 /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060 /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061 /// inconsistently across NFC/NFD normalization, the 65-byte
3062 /// paste-from-binary slug) silently passed validate and the
3063 /// failure surfaced at `cargo metadata` time as the
3064 /// `restricted_names::validate_feature_name` parser's rejection,
3065 /// far from the source `caixa.lisp`, with no field naming which
3066 /// `:deps` entry's `:caracteristicas` carried the typo. The
3067 /// lifted predicate makes the Cargo-feature-name-grammar
3068 /// intersection-floor a substrate-level invariant at validate
3069 /// time — same trajectory as the eight peer
3070 /// [`crate::render`] value-shape predicates each typed surface
3071 /// downstream of a structured grammar already follows
3072 /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073 /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074 /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075 /// [`is_nats_subject`](crate::render::is_nats_subject),
3076 /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077 /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078 /// [`is_git_oid`](crate::render::is_git_oid),
3079 /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080 fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081 let mut seen = std::collections::HashSet::new();
3082 for c in self.caracteristicas() {
3083 if c.is_empty() {
3084 return Err(DepError::caracteristica_empty(&self.nome));
3085 }
3086 if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087 return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088 }
3089 crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090 DepError::caracteristica_duplicate(&self.nome, c)
3091 })?;
3092 }
3093 Ok(())
3094 }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140 deps: &[Dep],
3141 deps_dev: &[Dep],
3142 parent_nome: &str,
3143) -> Result<(), DepError> {
3144 for dep in deps {
3145 if dep.nome() == parent_nome {
3146 return Err(DepError::dep_is_self(
3147 parent_nome,
3148 crate::render::DEP_AUTHOR_KEY_DEPS,
3149 ));
3150 }
3151 }
3152 for dep in deps_dev {
3153 if dep.nome() == parent_nome {
3154 return Err(DepError::dep_is_self(
3155 parent_nome,
3156 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157 ));
3158 }
3159 }
3160 Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202 /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203 /// lacre closure resolves at every build. Wire-format
3204 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205 Prod,
3206 /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207 /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208 /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209 Dev,
3210}
3211
3212impl DepList {
3213 /// Exhaustive iteration surface for every consumer that reads the
3214 /// full closed-set (the future M4 admission webhook's per-list
3215 /// summary rejection body, any future round-trip pin harness). A
3216 /// future variant addition extends this slice as a single edit and
3217 /// every consumer picks up the new entry by construction — the
3218 /// compiler-checked exhaustiveness on the sibling method `match`
3219 /// arms is the build-time guarantee that no arm forgets to grow.
3220 pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222 /// Canonical author-surface tag every substrate consumer that
3223 /// names the offending dep-list in a diagnostic reaches for —
3224 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226 /// the same `&'static str` payload the sibling
3227 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228 /// already carry. Routing every dep-list diagnostic through the
3229 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230 /// literal-carry axis on the two-list dep-graph surface — a
3231 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232 /// wire-format promotion (a distinct diagnostic form for the
3233 /// `Dev` arm) reaches every consumer through one edit on the
3234 /// canonical constant, not a coordinated rewrite across the
3235 /// substrate's dep-graph consumers.
3236 #[must_use]
3237 pub const fn as_str(self) -> &'static str {
3238 match self {
3239 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241 }
3242 }
3243
3244 /// Substrate-canonical reverse projection on the two-list dep-graph
3245 /// axis — parses the author-surface wire tag back to the typed
3246 /// variant, or `None` when `s` is outside the closed-set arm-string
3247 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251 /// the round-trip migrate through one caixa-core edit on any future
3252 /// list-axis addition.
3253 ///
3254 /// Prior to this lift the substrate carried only the forward
3255 /// `Self → &str` projection on the two-list dep-graph axis (the
3256 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257 /// through it, the two [`DepError::DuplicateNome`] /
3258 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259 /// as a `&'static str` `list:` field). Every future consumer that
3260 /// wanted to promote the wire tag back to the typed enum (a future
3261 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262 /// wire form into the typed enum before dispatching to
3263 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265 /// wire re-parse of the per-list diagnostic body, a future
3266 /// [`DepError`] widening that promotes the two `list: &'static str`
3267 /// fields to a typed `list: DepList` carry so downstream consumers
3268 /// dispatch on the enum rather than string-comparing the wire
3269 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271 /// compile-time link back to the typed [`DepList`] enum. A future
3272 /// variant addition (a `:build-dep` or `:test-dep` third list once
3273 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276 /// would silently split the wire byte-string the emitter walks from
3277 /// the parser's arm-set — the round-trip would carry the new list
3278 /// through the forward projection but land on the fallback silently
3279 /// at every non-updated reverse parser, far from the arm-addition
3280 /// commit that caused the drift. Lifting the resolver to a typed
3281 /// method on the substrate primitive closes the drift footgun by
3282 /// construction: the parser's accept-set is the same set the
3283 /// [`Self::as_str`] emitter walks (routed through the same lifted
3284 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286 /// of the round-trip migrate through one caixa-core edit on any
3287 /// future list-axis addition.
3288 ///
3289 /// Same closed-set-reverse-projection discipline the sibling
3290 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295 /// carry on the peer wire-side `str → Self` axes — extended onto
3296 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297 /// closed-set typed enum on the caixa surface to converge on the
3298 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299 /// `from_str`) to match the peer shapes verbatim and side-step the
3300 /// derived [`std::str::FromStr`] impls the sibling
3301 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304 /// caller picks the diagnostic form appropriate for its use site —
3305 /// a future `feira dep --list …` arg-parse that surfaces
3306 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308 /// path folds `None` onto its per-CR structured refusal body.
3309 #[must_use]
3310 pub fn from_wire(s: &str) -> Option<Self> {
3311 match s {
3312 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314 _ => None,
3315 }
3316 }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335 f.write_str(self.as_str())
3336 }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391 fn as_ref(&self) -> &str {
3392 self.as_str()
3393 }
3394}
3395
3396/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3397/// [`DepList`] closed-set typed enum — routes through the paired
3398/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3399/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3400/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3401/// through, rather than an open-coded per-arm
3402/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3403/// has no compile-time link back to the substrate primitive.
3404///
3405/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3406/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3407/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3408/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3409/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3410/// which silently omitted [`DepList`] despite this enum being listed
3411/// as a sibling closed-set fieldless typed enum in every peer's
3412/// docstring). Every sibling closed-set fieldless typed enum on the
3413/// caixa surface now carries both trait-idiomatic axes
3414/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3415/// against the substrate-primitive canonical projection accessors
3416/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3417/// closed-set is the fifteenth and true-final peer.
3418///
3419/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3420/// `Option<Self>` return-shape's deliberate deferral of error typing:
3421/// the caller picks the diagnostic form appropriate for its use site
3422/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3423/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3424/// the M4 admission-webhook rejection body wraps `Err(())` with the
3425/// accepted-set enumeration).
3426///
3427/// Pinned load-bearing by
3428/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3429/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3430/// accept-set) and
3431/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3432/// (rejection witness against silent accept-set widening).
3433impl TryFrom<&str> for DepList {
3434 type Error = ();
3435
3436 fn try_from(s: &str) -> Result<Self, Self::Error> {
3437 Self::from_wire(s).ok_or(())
3438 }
3439}
3440
3441/// Trait-idiomatic *forward* projection on the two-list dep-graph
3442/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3443/// routes byte-for-byte through the paired substrate-primitive
3444/// [`DepList::as_str`] `pub const fn` accessor so
3445/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3446/// reaches the same two-arm lifted
3447/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3448/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3449/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3450/// surfaces already return.
3451///
3452/// Closes the substrate-wide trait-idiomatic forward-projection
3453/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3454/// via 523157d and traced through the 13 sibling closed-set typed
3455/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3456/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3457/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3458/// every peer's docstring naming it as a sibling. Paired with the
3459/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3460/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3461/// idiomatic axis pair, mirroring the pre-existing method-named
3462/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3463/// substrate-primitive axis pair.
3464///
3465/// The paired [`DepList::as_str`] returns `&'static str` by
3466/// construction — each arm resolves to a
3467/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3468/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3469/// static lifetime — so the trait's return-type promise is upheld
3470/// structurally.
3471///
3472/// Pinned load-bearing by
3473/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3474/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3475/// emit-set, plus a `const`-context materialization witness for the
3476/// `&'static str` lifetime promise) and
3477/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3478/// (partition pin + two-way round-trip through the paired
3479/// [`TryFrom<&str>`] axis).
3480impl From<DepList> for &'static str {
3481 fn from(list: DepList) -> &'static str {
3482 list.as_str()
3483 }
3484}
3485
3486/// Trait-idiomatic *forward* projection on the two-list dep-graph
3487/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3488/// `&'static str` axis — the borrowed-input companion to the paired
3489/// owned-input [`From<DepList> for &'static str`] impl immediately
3490/// above. Routes byte-for-byte through the same substrate-primitive
3491/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3492/// binds a `&DepList` through the standard-library `.into()` /
3493/// [`From<&Self> for &'static str`] axis (a
3494/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3495/// per-arm accept-set materializer that iterates the substrate-
3496/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3497/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3498/// forces every call site through an explicit `.copied()` /
3499/// dereference / [`Copy`]-bound restatement rather than the direct
3500/// trait-idiomatic projection; a future generic
3501/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3502/// that walks the `iter().map(Into::into)` shape verbatim; the future
3503/// M4 admission-webhook rejection body that composes the accepted-set
3504/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3505/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3506/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3507/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3508/// owned-input [`From<DepList> for &'static str`], the sibling
3509/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3510/// surfaces already return.
3511///
3512/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3513/// forward-projection family on the last-touched closed-set fieldless
3514/// typed enum — first-mover on the borrowed-input axis, mirroring the
3515/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3516/// input axis (523157d). Rust's `From` trait does not auto-derive the
3517/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3518/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3519/// in `core`), so every closed-set typed enum that carries the
3520/// owned-input axis but not the borrowed-input axis forces every
3521/// borrowed-input call site through a `.copied()` /
3522/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3523/// bounds have no compile-time link to the substrate primitive. The
3524/// remaining fourteen substrate-wide closed-set fieldless typed enum
3525/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3526/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3527/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3528/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3529/// of this campaign.
3530///
3531/// Pinned load-bearing by
3532/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3533/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3534/// emit-set via a borrowed input, plus a `const`-context materialization
3535/// witness) and
3536/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3537/// (cross-axis partition pin against the paired owned-input
3538/// [`From<DepList> for &'static str`] impl).
3539impl From<&DepList> for &'static str {
3540 fn from(list: &DepList) -> &'static str {
3541 list.as_str()
3542 }
3543}
3544
3545/// Errors raised by [`Dep::validate`].
3546///
3547/// Mirrors the per-axis error families the other `:versao`-carrying
3548/// typed surfaces expose
3549/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3550/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3551/// [`crate::SupervisorError::EmptyChildVersion`] /
3552/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3553/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3554#[derive(Debug, Error, PartialEq, Eq)]
3555pub enum DepError {
3556 #[error(
3557 ":deps entry has empty :nome (every dep must name a target caixa; \
3558 omit the entry instead of carrying an empty name)"
3559 )]
3560 NomeEmpty,
3561 #[error(
3562 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3563 (the value flows verbatim as the target caixa's `:nome`, the rendered \
3564 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3565 value, and the resolver's checkout-directory leaf — each apiserver-side \
3566 schema rejects non-DNS-1123 names at admission time; use a lowercase \
3567 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3568 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3569 )]
3570 NomeInvalid { nome: String, reason: String },
3571 #[error(
3572 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3573 constraint that resolves through the lacre pipeline)"
3574 )]
3575 VersaoEmpty { nome: String },
3576 #[error(
3577 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3578 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3579 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3580 and `:children :versao` carry; the lacre pipeline resolves all three \
3581 through the same parser)"
3582 )]
3583 VersaoInvalid {
3584 nome: String,
3585 versao: String,
3586 reason: String,
3587 },
3588 #[error(
3589 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3590 (every git source must name a repo — use a `github:org/repo` \
3591 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3592 entire :fonte block to fall back to the default-host resolver \
3593 convention)"
3594 )]
3595 FonteRepoEmpty { nome: String },
3596 #[error(
3597 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3598 invalid value-shape: {reason} (the value flows verbatim into the \
3599 caixa-resolver's `git clone <repo>` subprocess invocation; every \
3600 documented form carries a `:` separator and no whitespace / \
3601 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3602 an `https://host/path` / `ssh://[user@]host/path` / \
3603 `git://host/path` / `file:///path` URL, or the `git@host:path` \
3604 scp-style SSH form)"
3605 )]
3606 FonteRepoShape {
3607 nome: String,
3608 repo: String,
3609 reason: String,
3610 },
3611 #[error(
3612 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3613 (set exactly one of :tag, :rev, or :branch so the resolver \
3614 can pick a reproducible commit; omit the entire :fonte block \
3615 to fall back to the default-host resolver convention, which \
3616 resolves the latest tag matching :versao)"
3617 )]
3618 FontePinMissing { nome: String },
3619 #[error(
3620 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3621 set ({pins}); exactly one of :tag, :rev, or :branch must be \
3622 set so the resolver's checkout target is unambiguous (the \
3623 resolver's silent precedence is :rev > :tag > :branch — if \
3624 you intended one specifically, drop the others)"
3625 )]
3626 FontePinAmbiguous { nome: String, pins: String },
3627 #[error(
3628 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3629 (a set pin must name a non-empty git ref; drop the {pin} key \
3630 entirely to fall through to another pin axis)"
3631 )]
3632 FontePinEmpty { nome: String, pin: String },
3633 #[error(
3634 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3635 value-shape: {reason} (the git porcelain enforces the same shape at \
3636 `git fetch` / `git checkout` time on every pin; use a leaf refname \
3637 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3638 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3639 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3640 prepends at clone time, and avoid abbreviated SHAs which are \
3641 ambiguous across repository history)"
3642 )]
3643 FontePinShape {
3644 nome: String,
3645 pin: String,
3646 value: String,
3647 reason: String,
3648 },
3649 #[error(
3650 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3651 (every path source must name a non-empty filesystem path; \
3652 omit the entire :fonte block to fall back to the default-host \
3653 resolver convention)"
3654 )]
3655 FonteCaminhoEmpty { nome: String },
3656 #[error(
3657 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3658 absolute (the lacre pipeline embeds the value verbatim in its \
3659 per-dep content-address `path:{caminho}` at \
3660 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3661 BLAKE3 closure differ across machines — defeating the \
3662 reproducibility contract that's load-bearing for CSE; express \
3663 the path relative to the caixa.lisp location, e.g. \
3664 \"../caixa-teia\" for a sibling workspace dep)"
3665 )]
3666 FonteCaminhoAbsolute { nome: String, caminho: String },
3667 #[error(
3668 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3669 with `~` (the leading-tilde is a shell-expansion convention, not a \
3670 POSIX path component — `Path::is_absolute` returns false on it, so \
3671 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3672 pipeline embeds the value verbatim in its per-dep content-address \
3673 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3674 caixa-resolver folds it through `Path::join` without `~`-expansion, \
3675 so the build looks for a literal `./{caminho}` subdirectory and \
3676 fails at resolve time far from the source caixa.lisp; even worse, a \
3677 future caixa-resolver pass that *does* expand `~` would silently \
3678 re-open the host-layout-leak the b94fd83 absolute gate closes — \
3679 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3680 runners with different `$HOME` layouts resolve to two distinct paths \
3681 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3682 determinism contract; express the path relative to the caixa.lisp \
3683 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3684 spell out the full relative path explicitly if a workstation-rooted \
3685 dep is genuinely intended)"
3686 )]
3687 FonteCaminhoTildeExpansion { nome: String, caminho: String },
3688 #[error(
3689 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3690 with `$` (the leading-`$` is a shell-variable-expansion convention, \
3691 not a POSIX path component — `Path::is_absolute` returns false on it \
3692 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3693 embeds the value verbatim in its per-dep content-address \
3694 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3695 caixa-resolver folds it through `Path::join` without `$`-expansion, \
3696 so the build looks for a literal `./{caminho}` subdirectory and \
3697 fails at resolve time far from the source caixa.lisp; even worse, a \
3698 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3699 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3700 invites) would silently re-open the host-layout-leak the b94fd83 \
3701 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3702 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3703 layouts resolve to two distinct paths for the byte-identical caixa, \
3704 defeating the THEORY.md §V.2 render-determinism contract; express \
3705 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3706 for a sibling workspace dep, or spell out the full relative path \
3707 explicitly if a workstation-rooted dep is genuinely intended)"
3708 )]
3709 FonteCaminhoVarExpansion { nome: String, caminho: String },
3710 #[error(
3711 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3712 with a space (the leading ASCII space `0x20` is the orthogonal \
3713 paste-from-aligned-doc footgun that silently passes \
3714 `Path::is_absolute` and every prior leading-byte arm — \
3715 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3716 `./ ../caixa-teia` subdirectory the resolver fails to find at \
3717 resolve time with a non-self-locating `No such file or directory` \
3718 error far from the source caixa.lisp; the lacre pipeline embeds \
3719 the value verbatim in its per-dep content-address `path:{caminho}` \
3720 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
3721 semantic-identical caixa values (` ../caixa-teia` vs \
3722 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
3723 workstations whose authors differ only in paste-from-aligned- \
3724 caixa.lisp-doc whitespace habits — the most insidious failure \
3725 mode the typed slot can carry (no error surfaces; the divergence \
3726 is invisible until two machines compare lacres), defeating the \
3727 THEORY.md §V.2 render-determinism contract. The canonical \
3728 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
3729 a multi-entry `:deps` block sits at the same column — an author \
3730 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
3731 the rendered alignment into a fresh entry preserves the leading \
3732 whitespace verbatim); peer `:fonte :repo` axis already rejects \
3733 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
3734 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
3735 `is_chart_description_shape`, `:licenca` via \
3736 `is_spdx_expression_shape`. Drop the leading space; express the \
3737 path as a bare relative single-token like \"../caixa-teia\")"
3738 )]
3739 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
3740 #[error(
3741 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3742 with `-` (the canonical CLI-argument-injection footgun on the \
3743 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
3744 its per-dep content-address `path:{caminho}` at \
3745 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
3746 through `Path::join` looking for a literal `./{caminho}` \
3747 subdirectory. Every downstream subprocess that consumes the resolved \
3748 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
3749 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
3750 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
3751 value as a CLI flag rather than a positional path when the invocation \
3752 does not carry a `--` argument-list terminator between the flag block \
3753 and the path (the common case at every porcelain entry point). The \
3754 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
3755 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
3756 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
3757 CLI-arg-injection vector at every git porcelain entry point that \
3758 consumes a path or URL argument, peer with is_git_repo_url's \
3759 leading-`-` arm on the sibling `:fonte :repo` axis), \
3760 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
3761 POSIX `std::path::Path` treats a leading `-` as a literal filename \
3762 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
3763 for a literal `./-rf` subdirectory that fails at resolve time with a \
3764 non-self-locating `No such file or directory` error far from the \
3765 source caixa.lisp — but on any downstream shell-out without `--` the \
3766 reinterpretation is silent and the failure mode is arbitrary-\
3767 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
3768 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
3769 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
3770 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
3771 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
3772 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
3773 `:children :caixa`, `:deps :nome`, cluster names); \
3774 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
3775 the feira `init` / `add <nome>` positional gate (868c191) rejects \
3776 leading `-` on the CLI positional itself. Express the path as a bare \
3777 relative single-token like \"../caixa-teia\" — the sibling-workspace \
3778 directory name carries no leading-hyphen semantic, and `./` / `../` \
3779 prefixes structurally partition the leading-byte set to safe values.)"
3780 )]
3781 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
3782 #[error(
3783 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
3784 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
3785 every `std::fs` syscall routes the path through `CString::new` which \
3786 fails with `NulError` at resolve time; the lacre pipeline embeds the \
3787 value verbatim in its per-dep content-address `path:{caminho}` at \
3788 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
3789 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
3790 determinism contract — the canonical paste-from-multiline-doc \
3791 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
3792 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
3793 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
3794 already gates against. Express the path as a relative single-line ASCII \
3795 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
3796 )]
3797 FonteCaminhoControlChar {
3798 nome: String,
3799 caminho: String,
3800 byte: u8,
3801 },
3802 #[error(
3803 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
3804 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
3805 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
3806 not the parent's sibling — and the caixa-resolver folds the value through \
3807 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
3808 resolve time with a non-self-locating `No such file or directory` error far \
3809 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
3810 primary path separator equal to `/`, so byte-identical caixa.lisp values \
3811 resolve to two distinct directories across runner OSes — the lacre pipeline \
3812 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3813 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
3814 determinism contract via the cross-host-OS-separator divergence vector. The \
3815 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
3816 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
3817 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
3818 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
3819 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
3820 \"../caixa-teia\" for a sibling workspace dep)"
3821 )]
3822 FonteCaminhoBackslash { nome: String, caminho: String },
3823 #[error(
3824 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3825 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
3826 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
3827 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
3828 paste-from-shell-pipeline footgun where an author copies a `command > log` \
3829 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
3830 as literal path-component bytes, so the resolver folds the value through \
3831 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3832 subdirectory and fails at resolve time with a non-self-locating `No such \
3833 file or directory` error far from the source caixa.lisp. The lacre pipeline \
3834 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
3835 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
3836 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3837 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3838 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
3839 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
3840 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
3841 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
3842 RFC-3986-reserved set. Express the path as a bare relative single-token like \
3843 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
3844 redirection semantic.",
3845 ch = *byte as char
3846 )]
3847 FonteCaminhoShellRedirection {
3848 nome: String,
3849 caminho: String,
3850 byte: u8,
3851 },
3852 #[error(
3853 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
3854 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
3855 `|` as the pipe operator that wires one command's stdout to the next command's \
3856 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
3857 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
3858 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
3859 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
3860 treats `|` as a literal path-component byte, so the resolver folds the value \
3861 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3862 subdirectory and fails at resolve time with a non-self-locating `No such file or \
3863 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
3864 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
3865 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
3866 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
3867 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
3868 subprocess-argument / shell-metachar injection surface every peer single-token-\
3869 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
3870 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3871 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3872 workspace directory name carries no shell-pipe semantic."
3873 )]
3874 FonteCaminhoShellPipe { nome: String, caminho: String },
3875 #[error(
3876 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3877 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
3878 / nushell — lexes `;` as the sequential-command terminator that fires the next \
3879 command regardless of the prior command's exit status, so `:caminho \
3880 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
3881 footgun where an author copies a `cd path; do-thing` chain without trimming \
3882 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
3883 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
3884 literal path-component byte, so the resolver folds the value through \
3885 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
3886 subdirectory and fails at resolve time with a non-self-locating `No such file \
3887 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
3888 the value verbatim in its per-dep content-address `path:{caminho}` at \
3889 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3890 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
3891 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
3892 canonical shell-metachar injection surface every peer single-token-shaped \
3893 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
3894 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
3895 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
3896 workspace directory name carries no shell-command-separator semantic."
3897 )]
3898 FonteCaminhoShellSemicolon { nome: String, caminho: String },
3899 #[error(
3900 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3901 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
3902 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
3903 terminator detaching the prior command and returning control immediately to \
3904 the prompt, double `&&` as the logical-AND list operator firing the next \
3905 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
3906 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
3907 sleep 1` background-launch one-liner or a `cd path && make install` build-\
3908 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
3909 05c358e closed the sequential-command-separator vector, this arm closes the \
3910 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
3911 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
3912 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
3913 byte lands in the BLAKE3 closure and rides into every shell-spawned \
3914 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
3915 future operator-side `nix` spawn) as the canonical shell-metachar injection \
3916 surface every peer single-token-shaped typed slot already closes. The peer \
3917 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
3918 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
3919 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
3920 shell-background / logical-AND semantic."
3921 )]
3922 FonteCaminhoShellBackground { nome: String, caminho: String },
3923 #[error(
3924 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3925 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
3926 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
3927 wrapper that runs the enclosed command and substitutes its standard-output \
3928 verbatim into the surrounding word, so a backticked `whoami` expands to the \
3929 current user's name and a backticked `cat /etc/passwd` expands to the file's \
3930 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
3931 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
3932 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
3933 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
3934 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
3935 background / logical-AND vector, this arm closes the orthogonal command-\
3936 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
3937 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
3938 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
3939 value verbatim in its per-dep content-address `path:{caminho}` at \
3940 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
3941 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
3942 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
3943 shell-metachar injection surface every peer single-token-shaped typed slot \
3944 already closes. The peer `:entrada :paths` axis rejects the byte via \
3945 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
3946 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
3947 directory name carries no shell-command-substitution semantic."
3948 )]
3949 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
3950 #[error(
3951 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3952 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
3953 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
3954 expansion wildcards: `*` matches any sequence of characters in a path component \
3955 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
3956 canonical paste-from-shell-listing footgun where an author copies a \
3957 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
3958 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
3959 `std::path::Path` treats both bytes as literal path-component bytes, so the \
3960 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
3961 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
3962 locating `No such file or directory` error far from the source caixa.lisp. The \
3963 lacre pipeline embeds the value verbatim in its per-dep content-address \
3964 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
3965 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
3966 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
3967 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
3968 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
3969 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
3970 reserved set. Express the path as a bare relative single-token like \
3971 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
3972 / pathname-expansion semantic.",
3973 ch = *byte as char
3974 )]
3975 FonteCaminhoShellGlob {
3976 nome: String,
3977 caminho: String,
3978 byte: u8,
3979 },
3980 #[error(
3981 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
3982 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
3983 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
3984 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
3985 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
3986 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
3987 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
3988 arm closes the leading byte of — together the two arms now structurally exclude the \
3989 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
3990 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
3991 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
3992 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
3993 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
3994 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
3995 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
3996 self-locating `No such file or directory` error far from the source caixa.lisp. The \
3997 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
3998 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
3999 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4000 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4001 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4002 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4003 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4004 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4005 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4006 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4007 subshell-grouping semantic.",
4008 ch = *byte as char
4009 )]
4010 FonteCaminhoShellSubshellGrouping {
4011 nome: String,
4012 caminho: String,
4013 byte: u8,
4014 },
4015 #[error(
4016 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4017 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4018 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4019 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4020 comma-separated members and `{{1..10}}` expands to the integer range — the \
4021 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4022 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4023 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4024 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4025 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4026 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4027 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4028 `std::path::Path` treats the byte as a literal path-component byte, so a \
4029 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4030 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4031 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4032 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4033 silently passes every prior arm and the resolver folds the value through \
4034 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4035 resolve time with a non-self-locating `No such file or directory` error far from \
4036 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4037 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4038 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4039 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4040 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4041 expansion / URI-Template-placeholder surface every peer single-token-shaped \
4042 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4043 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4044 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4045 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4046 directory name carries no shell-brace-expansion / URI-Template-placeholder \
4047 semantic; if two siblings actually need pinning, author two separate `:deps` \
4048 entries rather than one brace-expanded `:caminho` value.",
4049 ch = *byte as char
4050 )]
4051 FonteCaminhoShellBraceExpansion {
4052 nome: String,
4053 caminho: String,
4054 byte: u8,
4055 },
4056 #[error(
4057 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4058 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4059 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4060 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4061 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4062 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4063 glob every shell-history block carries; the bracket pair additionally carries the \
4064 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4065 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4066 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4067 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4068 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4069 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4070 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4071 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4072 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4073 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4074 leak) silently passes every prior arm and the resolver folds the value through \
4075 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4076 resolve time with a non-self-locating `No such file or directory` error far from \
4077 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4078 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4079 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4080 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4081 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4082 surface every peer single-token-shaped typed slot already closes. Express the path \
4083 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4084 directory name carries no shell-bracket-expansion / glob-character-class / array-\
4085 literal semantic; if a family of sibling caixas actually needs pinning, author \
4086 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4087 ch = *byte as char
4088 )]
4089 FonteCaminhoShellBracketExpansion {
4090 nome: String,
4091 caminho: String,
4092 byte: u8,
4093 },
4094 #[error(
4095 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4096 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4097 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4098 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4099 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4100 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4101 every path-with-embedded-whitespace paste block carries and the symmetric \
4102 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4103 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4104 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4105 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4106 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4107 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4108 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4109 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4110 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4111 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4112 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4113 production. POSIX `std::path::Path` treats the byte as a literal path-component \
4114 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4115 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4116 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4117 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4118 shape) silently passes every prior arm and the resolver folds the value through \
4119 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4120 resolve time with a non-self-locating `No such file or directory` error far from \
4121 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4122 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4123 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4124 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4125 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4126 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4127 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4128 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4129 `is_git_repo_url`). Express the path as a bare relative single-token like \
4130 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4131 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4132 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4133 quoting on the outer syntactic layer, so an inner quote pair would nest and \
4134 desugar to a broken layer).",
4135 ch = *byte as char
4136 )]
4137 FonteCaminhoShellQuoteGrouping {
4138 nome: String,
4139 caminho: String,
4140 byte: u8,
4141 },
4142 #[error(
4143 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4144 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4145 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4146 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4147 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4148 discarding the byte and everything after it to the end of the physical line \
4149 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
4150 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4151 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4152 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
4153 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4154 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4155 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4156 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4157 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4158 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4159 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4160 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4161 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4162 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4163 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
4164 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4165 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4166 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4167 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4168 fails at resolve time with a non-self-locating `No such file or directory` \
4169 error far from the source caixa.lisp — while every downstream shell / YAML / \
4170 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4171 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4172 scalar disagree with the resolver on which directory the value names. The \
4173 lacre pipeline embeds the value verbatim in its per-dep content-address \
4174 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4175 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4176 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4177 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4178 fragment-delimiter surface every peer single-token-shaped typed slot already \
4179 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4180 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4181 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4182 workspace directory name carries no shell-comment / URL-fragment / YAML-\
4183 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4184 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4185 and drop any `#fragment` tail entirely (fragment identifiers select \
4186 renderings, not directories, and `:caminho` names a directory).",
4187 ch = *byte as char
4188 )]
4189 FonteCaminhoShellComment {
4190 nome: String,
4191 caminho: String,
4192 byte: u8,
4193 },
4194 #[error(
4195 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4196 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4197 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4198 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4199 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4200 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4201 literally inside a URL value. The canonical paste-from-browser-address-bar \
4202 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4203 encoded README hyperlink / browser address bar / percent-encoded permalink \
4204 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4205 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4206 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4207 `std::path::Path` treats the byte as a literal path-component byte, so \
4208 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4209 resolve time with a non-self-locating `No such file or directory` error far \
4210 from the source caixa.lisp — while every downstream URL parser / shell printf \
4211 builtin / YAML directive parser silently reinterprets the byte to a different \
4212 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4213 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4214 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4215 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4216 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4217 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4218 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4219 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4220 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4221 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4222 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4223 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4224 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4225 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4226 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4227 printf-format-specifier / job-control-specifier surface every peer single-\
4228 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4229 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4230 `is_git_repo_url`). Express the path as a bare relative single-token like \
4231 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4232 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4233 any `%20` percent-encoded-space with a literal space then reject the whole \
4234 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4235 directory name never carries an embedded space in practice); drop any \
4236 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4237 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4238 ch = *byte as char
4239 )]
4240 FonteCaminhoUrlPercentEncoding {
4241 nome: String,
4242 caminho: String,
4243 byte: u8,
4244 },
4245 #[error(
4246 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4247 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4248 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4249 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4250 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4251 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4252 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4253 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4254 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4255 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4256 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4257 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4258 the byte is a first-class parser byte in nearly every config / templating / \
4259 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4260 `std::path::Path` treats the byte as a literal path-component byte, so the \
4261 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4262 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4263 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4264 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4265 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4266 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4267 subdirectory that fails at resolve time with a non-self-locating `No such file \
4268 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4269 the value verbatim in its per-dep content-address `path:{caminho}` at \
4270 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4271 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4272 time lock to two distinct BLAKE3 closures across two workstations whose \
4273 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4274 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4275 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4276 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4277 is the canonical CWE-78 shell-command-injection surface every peer single-\
4278 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4279 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4280 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4281 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4282 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4283 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4284 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4285 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4286 so every position — leading and embedded — is structurally rejected. Substitute \
4287 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4288 time, or express the path as a bare relative single-token like \
4289 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4290 variable-expansion / command-substitution / arithmetic-expansion semantic.",
4291 ch = *byte as char
4292 )]
4293 FonteCaminhoShellVariableExpansion {
4294 nome: String,
4295 caminho: String,
4296 byte: u8,
4297 },
4298 #[error(
4299 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4300 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4301 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4302 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4303 reference §9.3: `!command` re-runs the most recent history entry beginning with \
4304 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4305 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4306 and the substitution fires at every history-expansion-enabled shell context — \
4307 `set -o histexpand` is bash's default for interactive sessions and the layer \
4308 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4309 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4310 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4311 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4312 encodes it inside a query component via the 'special-query percent-encode set' \
4313 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4314 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4315 prefix — the paste-from-source-code idiom where an author copies \
4316 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4317 the string-literal boundary); the canonical English-typography emphasis / \
4318 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4319 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4320 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4321 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4322 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4323 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4324 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4325 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4326 repeat-prior-command paste idiom), the English-typography `:caminho \
4327 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4328 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4329 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4330 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4331 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4332 subdirectory that fails at resolve time with a non-self-locating `No such file \
4333 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4334 the value verbatim in its per-dep content-address `path:{caminho}` at \
4335 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4336 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4337 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4338 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4339 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4340 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4341 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4342 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4343 name carries no shell-history-expansion / bang-operator semantic; drop any \
4344 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4345 idiom; and drop any trailing English-typography exclamation mark that pasted \
4346 from prose.",
4347 ch = *byte as char
4348 )]
4349 FonteCaminhoShellHistoryExpansion {
4350 nome: String,
4351 caminho: String,
4352 byte: u8,
4353 },
4354 #[error(
4355 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4356 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4357 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4358 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4359 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4360 substitution' history operator that rewrites the prior command's `old` string to \
4361 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4362 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4363 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4364 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4365 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4366 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4367 literal value diverges from every downstream `feira tofu` curl-invocation / \
4368 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4369 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4370 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4371 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4372 `std::path::Path` treats `^` as a literal path-component byte, so \
4373 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4374 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4375 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4376 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4377 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4378 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4379 that fails at resolve time with a non-self-locating `No such file or directory` \
4380 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4381 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4382 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4383 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4384 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4385 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4386 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4387 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4388 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4389 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4390 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4391 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4392 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4393 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4394 drop any trailing `^` history-substitution-open fragment.",
4395 ch = *byte as char
4396 )]
4397 FonteCaminhoShellHistorySubstitution {
4398 nome: String,
4399 caminho: String,
4400 byte: u8,
4401 },
4402 #[error(
4403 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4404 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4405 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4406 value verbatim in its per-dep content-address `path:{caminho}` at \
4407 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4408 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4409 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4410 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4411 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4412 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4413 trailing `/`; every `:caminho` value names a sibling-workspace directory \
4414 already, so the trailing separator carries no information. Use \
4415 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4416 )]
4417 FonteCaminhoTrailingSlash { nome: String, caminho: String },
4418 #[error(
4419 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4420 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4421 apply the same set-not-multiset discipline; one package per table), and \
4422 two entries naming the same caixa carry two version constraints / source \
4423 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4424 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4425 silently overwrites the first at the resolver-side `concrete_versao` step, \
4426 and the dropped entry's pin / features never reach the closure — far from \
4427 the source caixa.lisp, with no field naming which `:deps` entry was the \
4428 silent loser. If two version constraints are genuinely needed (the rare \
4429 multi-version closure case the lacre pipeline doesn't yet support), the \
4430 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4431 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4432 )]
4433 DuplicateNome { nome: String, list: &'static str },
4434 #[error(
4435 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4436 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4437 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4438 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4439 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4440 with the canonical kebab-case feature name the target caixa declares."
4441 )]
4442 CaracteristicaEmpty { nome: String },
4443 #[error(
4444 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4445 feature name: {reason} (the value flows verbatim into Cargo's \
4446 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4447 parser enforces the same shape at `cargo metadata` time; use a single-token \
4448 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4449 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4450 an ASCII alphanumeric or `_`)"
4451 )]
4452 CaracteristicaInvalid {
4453 nome: String,
4454 caracteristica: String,
4455 reason: String,
4456 },
4457 #[error(
4458 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4459 every feature-flag list keys its entries by name (Cargo's \
4460 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4461 per feature per dep), and two entries naming the same feature are a redundant \
4462 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4463 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4464 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4465 feature once regardless of declaration count, so the duplicate's pin / position never \
4466 reaches the closure with no field naming the silent loser. One entry per feature per \
4467 dep; if two distinct features are intended, name each verbatim."
4468 )]
4469 CaracteristicaDuplicate {
4470 nome: String,
4471 caracteristica: String,
4472 },
4473 #[error(
4474 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4475 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4476 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4477 rejects mid-traversal far from the source caixa.lisp or recurses on until \
4478 it exhausts its stack). Every :nome is globally-unique substrate identity, \
4479 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4480 *is* the parent itself, not a coincidentally-named peer. Drop the \
4481 self-referential dep entry — to reference code from this caixa, use \
4482 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4483 referencing the caixa's own code surface) instead."
4484 )]
4485 DepIsSelf { nome: String, list: &'static str },
4486}
4487
4488// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4489// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4490// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4491// variant — the paired `{ nome: String, caminho: String }` two-slot family
4492// on [`DepError`], sibling of the peer
4493// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4494// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4495// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4496// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4497// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4498// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4499// `{ de, para, wit, expected }`), and
4500// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4501// variants on `{ de, para, <field>: String, reason: String }`) on the
4502// `AplicacaoError` envelopes, the peer
4503// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4504// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4505// (0419438, 4 variants on `{ caixa, kind, slots }`),
4506// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4507// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4508// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4509// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4510// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4511// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4512// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4513// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4514//
4515// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4516// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4517// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4518// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4519// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4520// CommandSubstitution}` on the four single-byte shell operators; and the
4521// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4522// opened the identical `DepError::FonteCaminho<Variant> { nome:
4523// nome.to_string(), caminho: caminho.to_string() }` four-line
4524// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4525// — the exact "same block re-inlined at every consumer" shape the PRIME
4526// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4527// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4528// families each closed on their sibling envelopes. The eleven variants
4529// share one `{ nome: String, caminho: String }` shape, so the fold routes
4530// each wire-up site through one dispatch per typed variant.
4531//
4532// The macro below generates one `#[must_use]` inherent constructor per
4533// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4534// wire-up site collapses onto one dispatch:
4535// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4536// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4537// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4538// once — inside the macro — rather than at every wire-up site.
4539//
4540// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4541// shapes at the per-byte-classification arms — the
4542// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4543// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4544// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4545// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4546// cluster — carry an additional `byte: u8` naming the offending byte and
4547// so would break the uniform-two-field routing this macro promises. They
4548// instead fold onto the sibling three-field envelope through
4549// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4550// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4551// two-slot family is the `byte: u8` classification the arms carry. The
4552// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4553// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4554// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4555// envelope.
4556//
4557// Every future consumer that wants to construct one of these eleven
4558// variants outside the current in-crate [`DepSource::validate_caminho`]
4559// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4560// at lacre-resolve time re-checking the same value-shape axes the resolver
4561// consumes, a future `feira validate --deps` per-caixa admission verb
4562// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4563// rejecting a `:caminho` value against a cluster-local snapshot) now
4564// reaches each variant through one call rather than re-inlining the
4565// four-line struct-literal in lockstep with the eleven in-crate wire-up
4566// sites.
4567macro_rules! fonte_caminho_ctors {
4568 ($($ctor:ident => $variant:ident),* $(,)?) => {
4569 impl DepError {
4570 $(
4571 #[doc = concat!(
4572 "Construct a [`DepError::",
4573 stringify!($variant),
4574 "`] naming the offending `:deps :nome` + `:fonte ",
4575 "(:tipo path …) :caminho` pair. Folds the uniform ",
4576 "`Self::",
4577 stringify!($variant),
4578 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4579 "two-slot struct-literal onto one substrate primitive so ",
4580 "every [`DepSource::validate_caminho`] wire-up on this ",
4581 "variant reads through one dispatch rather than the ",
4582 "pre-lift four-line open-coded block."
4583 )]
4584 #[must_use]
4585 pub fn $ctor(nome: &str, caminho: &str) -> Self {
4586 Self::$variant {
4587 nome: nome.to_string(),
4588 caminho: caminho.to_string(),
4589 }
4590 }
4591 )*
4592 }
4593 };
4594}
4595
4596fonte_caminho_ctors! {
4597 fonte_caminho_absolute => FonteCaminhoAbsolute,
4598 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4599 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4600 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4601 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4602 fonte_caminho_backslash => FonteCaminhoBackslash,
4603 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4604 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4605 fonte_caminho_shell_background => FonteCaminhoShellBackground,
4606 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4607 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4608}
4609
4610// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4611// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4612// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4613// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4614// three-slot family on [`DepError`], strict sibling of the peer
4615// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4616// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4617// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4618// axis broke its uniform-two-field routing — the exact "future compounding
4619// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4620// here. Third fold family on this `DepError` envelope, sibling of the peer
4621// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4622// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4623// same enum.
4624//
4625// Each of the twelve wire-up sites on this shape (the control-byte arm
4626// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4627// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4628// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4629// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4630// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4631// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4632// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4633// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4634// `FonteCaminhoShellHistoryExpansion` on `!`, and
4635// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4636// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4637// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4638// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4639// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4640// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4641// closed on the sibling two-field envelope of this same enum. The twelve
4642// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4643// the fold routes each wire-up site through one dispatch per typed variant.
4644//
4645// The macro below generates one `#[must_use]` inherent constructor per
4646// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4647// so every wire-up site collapses onto one dispatch:
4648// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4649// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4650// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4651// `byte`) is spelled once — inside the macro — rather than at every wire-up
4652// site.
4653//
4654// Every future consumer that wants to construct one of these twelve
4655// variants outside the current in-crate [`DepSource::validate_caminho`]
4656// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4657// at lacre-resolve time re-checking the same value-shape axes the resolver
4658// consumes, a future `feira validate --deps` per-caixa admission verb
4659// re-checking the `:fonte :caminho` axis against the shell-metachar
4660// classification bytes this cluster catches, a per-lacre overlay resolver
4661// rejecting a `:caminho` value against a cluster-local snapshot) now
4662// reaches each variant through one call rather than re-inlining the
4663// five-line struct-literal in lockstep with the twelve in-crate wire-up
4664// sites.
4665macro_rules! fonte_caminho_byte_ctors {
4666 ($($ctor:ident => $variant:ident),* $(,)?) => {
4667 impl DepError {
4668 $(
4669 #[doc = concat!(
4670 "Construct a [`DepError::",
4671 stringify!($variant),
4672 "`] naming the offending `:deps :nome` + `:fonte ",
4673 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4674 "classification. Folds the uniform `Self::",
4675 stringify!($variant),
4676 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4677 "byte }` three-slot struct-literal onto one substrate ",
4678 "primitive so every [`DepSource::validate_caminho`] wire-up ",
4679 "on this variant reads through one dispatch rather than ",
4680 "the pre-lift five-line open-coded block."
4681 )]
4682 #[must_use]
4683 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4684 Self::$variant {
4685 nome: nome.to_string(),
4686 caminho: caminho.to_string(),
4687 byte,
4688 }
4689 }
4690 )*
4691 }
4692 };
4693}
4694
4695fonte_caminho_byte_ctors! {
4696 fonte_caminho_control_char => FonteCaminhoControlChar,
4697 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4698 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4699 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4700 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4701 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4702 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4703 fonte_caminho_shell_comment => FonteCaminhoShellComment,
4704 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4705 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4706 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4707 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4708}
4709
4710// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4711// single-slot struct-variant wire-up sites scattered across
4712// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4713// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4714// substrate primitive per typed variant — the paired `{ nome: String }`
4715// single-slot family on [`DepError`], sibling of the peer
4716// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4717// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4718// the same enum, and of the peer
4719// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4720// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
4721// axis. Second fold family on this `DepError` envelope, and the first on
4722// the single-`{ nome }` shape.
4723//
4724// The five wire-up sites this fold closes each opened the identical
4725// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
4726// struct-literal against the same `nome: &str` (or `self.nome: &String`)
4727// local — the exact "same block re-inlined at every consumer" shape the
4728// PRIME DIRECTIVE names as a bug. The five variants share one
4729// `{ nome: String }` shape, so the fold routes each wire-up site through
4730// one dispatch per typed variant.
4731//
4732// The macro below generates one `#[must_use]` inherent constructor per
4733// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
4734// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
4735// pre-lift struct-literal on the same `&str` fixture. The uniform
4736// one-field construction (`nome.to_string()`) is spelled once — inside
4737// the macro — rather than at every wire-up site. Callers that hold a
4738// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
4739// and lets the macro-owned `.to_string()` produce the fresh owning copy
4740// the enum variant needs; the semantics collapse onto the same
4741// `.clone()`-equivalent one this fold replaces at every site.
4742//
4743// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
4744// on the same envelope stays on its pre-lift open-coded wire-up shape —
4745// it carries no `nome` field (the offending `:nome` value *is* the empty
4746// string this variant catches) so the uniform `fn(nome: &str) -> Self`
4747// signature this macro promises does not apply. Every future consumer
4748// that wants to construct one of these five variants outside the current
4749// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
4750// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
4751// re-validator at lacre-resolve time, a future `feira validate --deps`
4752// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
4753// these empty-value shapes against a cluster-local snapshot) now reaches
4754// each variant through one call rather than re-inlining the three-line
4755// struct-literal in lockstep with the five in-crate wire-up sites.
4756macro_rules! dep_nome_only_ctors {
4757 ($($ctor:ident => $variant:ident),* $(,)?) => {
4758 impl DepError {
4759 $(
4760 #[doc = concat!(
4761 "Construct a [`DepError::",
4762 stringify!($variant),
4763 "`] naming the offending `:deps :nome`. Folds the ",
4764 "uniform `Self::",
4765 stringify!($variant),
4766 " { nome: nome.to_string() }` one-field ",
4767 "struct-literal onto one substrate primitive so every ",
4768 "in-crate wire-up on this variant reads through one ",
4769 "dispatch rather than the pre-lift three-line ",
4770 "open-coded block."
4771 )]
4772 #[must_use]
4773 pub fn $ctor(nome: &str) -> Self {
4774 Self::$variant { nome: nome.to_string() }
4775 }
4776 )*
4777 }
4778 };
4779}
4780
4781dep_nome_only_ctors! {
4782 versao_empty => VersaoEmpty,
4783 fonte_repo_empty => FonteRepoEmpty,
4784 fonte_pin_missing => FontePinMissing,
4785 fonte_caminho_empty => FonteCaminhoEmpty,
4786 caracteristica_empty => CaracteristicaEmpty,
4787}
4788
4789// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
4790// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
4791// [`crate::manifest::Caixa::validate_deps`] +
4792// [`validate_no_self_dep`] onto one substrate-primitive family per
4793// typed variant — the `DepError`-side siblings of the peer
4794// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
4795// on the `SupervisorError { caixa: String }` one-slot envelope and of
4796// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
4797// `DepError { nome: String }` one-slot envelope. The two variants
4798// carry the same `{ nome: String, list: &'static str }` two-slot
4799// shape: the `nome` field names the offending dep the diagnostic
4800// points the author back at, and the `list` field carries the
4801// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
4802// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
4803// [`validate_deps`] arms, and via the paired
4804// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
4805// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
4806// canonicals on the [`validate_no_self_dep`] arm) so the author can
4807// grep their caixa.lisp for the offending list block in one edit.
4808//
4809// Each of the four wire-up sites opened the same struct-literal
4810// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
4811// two-line block — the exact "same block re-inlined at every
4812// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
4813// altitude the peer `DepError` / `SupervisorError` /
4814// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
4815// already closed on their sibling envelopes. The two `#[must_use]`
4816// inherent constructors below fold each wire-up onto one dispatch:
4817// `DepError::duplicate_nome(<nome>, <list>)` and
4818// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
4819// pre-lift struct-literal on the same scalar fixtures. The `list:
4820// &'static str` parameter (not `impl Into<String>`) preserves the
4821// exact wire tag every consumer already passes verbatim — no
4822// downstream diagnostic reshaping at the lift, matching the peer
4823// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
4824// contract each wire-up site already keys off.
4825macro_rules! dep_nome_list_ctors {
4826 ($($ctor:ident => $variant:ident),* $(,)?) => {
4827 impl DepError {
4828 $(
4829 #[doc = concat!(
4830 "Construct a [`DepError::",
4831 stringify!($variant),
4832 "`] naming the offending `:deps :nome` and the ",
4833 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
4834 "the diagnostic points the author back at. Folds ",
4835 "the uniform `Self::",
4836 stringify!($variant),
4837 " { nome: nome.to_string(), list }` two-field ",
4838 "struct-literal onto one substrate primitive so ",
4839 "every in-crate wire-up on this variant reads ",
4840 "through one dispatch rather than the pre-lift ",
4841 "open-coded struct-literal block."
4842 )]
4843 #[must_use]
4844 pub fn $ctor(nome: &str, list: &'static str) -> Self {
4845 Self::$variant { nome: nome.to_string(), list }
4846 }
4847 )*
4848 }
4849 };
4850}
4851
4852dep_nome_list_ctors! {
4853 duplicate_nome => DuplicateNome,
4854 dep_is_self => DepIsSelf,
4855}
4856
4857// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
4858// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
4859// <value>.to_string(), reason }` struct-variant wire-up sites at
4860// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
4861// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
4862// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
4863// primitive family per typed variant — the `DepError`-side siblings of the
4864// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
4865// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
4866// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
4867// the two-slot `{ nome, caminho }` envelope, and
4868// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
4869// caminho, byte }` envelope. The three variants share the same
4870// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
4871// the `nome` field names the offending dep the diagnostic points the
4872// author back at, the middle `<axis>: String` field carries the offending
4873// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
4874// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
4875// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
4876// field carries the parser-shaped rejection sentence the paired
4877// [`crate::render::require_valid_versao_requirement`] /
4878// [`crate::render::is_git_repo_url`] /
4879// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
4880// axis-field name differs across variants (`versao` / `repo` /
4881// `caracteristica`) so the ctor family below takes the axis field name as
4882// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
4883// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
4884// -> Self` inherent constructor per typed variant that spells the uniform
4885// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
4886// `reason` forwarded owned) exactly once. Peer of the sibling
4887// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
4888// family on the `AplicacaoError` envelope's mirror-symmetric
4889// `{ <field>: String, reason: String }` two-slot shape — same
4890// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
4891// one `nome`-axis added at the per-dep-owned altitude the `DepError`
4892// envelope keys off (every `DepError` variant carries the offending
4893// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
4894// offending block in one edit).
4895//
4896// The three wire-up sites this fold closes are:
4897// - [`DepSource::validate`]'s `:repo` value-shape arm
4898// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
4899// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
4900// rejects the offending URL);
4901// - [`Dep::validate`]'s `:versao` requirement-shape arm
4902// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
4903// self.versao_requirement().to_string(), reason }` inside the
4904// [`crate::render::require_valid_versao_requirement`] callback pair);
4905// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
4906// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
4907// caracteristica: c.clone(), reason })` after
4908// [`crate::render::is_cargo_feature_name`] rejects the offending
4909// feature-name).
4910//
4911// Each opened the identical five-line struct-literal against the same
4912// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
4913// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
4914// same altitude the peer four already-lifted `DepError` ctor families
4915// closed on their sibling shape-envelopes. The three variant / axis-field
4916// discriminators are the only things that vary between them; the rest of
4917// the struct-literal is a byte-for-byte re-inline.
4918//
4919// Every future consumer wanting to raise one of these three diagnostics
4920// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
4921// time re-checking each declared dep against the same requirement +
4922// git-URL + feature-name value-shape cascade, a future `feira validate
4923// --deps` per-caixa admission verb re-running the shape gates on demand,
4924// a per-lacre overlay resolver rejecting an author-supplied dep against a
4925// cluster-local snapshot) now reaches one dispatch rather than re-inlining
4926// the five-line struct-literal in lockstep with the three in-crate
4927// wire-up sites.
4928macro_rules! dep_nome_axis_reason_ctors {
4929 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
4930 impl DepError {
4931 $(
4932 #[doc = concat!(
4933 "Construct a [`DepError::",
4934 stringify!($variant),
4935 "`] naming the offending `:deps :nome`, the offending ",
4936 "`:", stringify!($axis), "` axis value, and the ",
4937 "parser-shaped rejection `reason`. Folds the uniform ",
4938 "`Self::",
4939 stringify!($variant),
4940 " { nome: nome.to_string(), ",
4941 stringify!($axis),
4942 ": ",
4943 stringify!($axis),
4944 ".to_string(), reason }` three-field struct-literal ",
4945 "onto one substrate primitive so every in-crate ",
4946 "wire-up on this variant reads through one dispatch ",
4947 "rather than the pre-lift five-line open-coded block. ",
4948 "The `nome: &str` and `",
4949 stringify!($axis),
4950 ": &str` parameters accept `&str` literals and ",
4951 "`&String` (via Deref coercion) so every existing ",
4952 "wire-up threads through the ctor without a ",
4953 "pre-conversion; the `reason: String` parameter takes ",
4954 "an owned `String` (not `impl Into<String>`) matching ",
4955 "the paired `crate::render::*` predicate's ",
4956 "`Result<(), String>` return shape every wire-up ",
4957 "already holds owned at the call site."
4958 )]
4959 #[must_use]
4960 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
4961 Self::$variant {
4962 nome: nome.to_string(),
4963 $axis: $axis.to_string(),
4964 reason,
4965 }
4966 }
4967 )*
4968 }
4969 };
4970}
4971
4972dep_nome_axis_reason_ctors! {
4973 versao_invalid => VersaoInvalid { versao },
4974 fonte_repo_shape => FonteRepoShape { repo },
4975 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
4976}
4977
4978// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
4979// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
4980// <value>.to_string() }` struct-variant wire-up sites at
4981// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
4982// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
4983// per-entry set-not-multiset dedup closure onto one substrate-primitive
4984// family per typed variant — the missing two-slot rung on the
4985// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
4986// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
4987// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
4988// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
4989// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
4990// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
4991// symmetric sibling of the peer
4992// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
4993// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
4994// envelope — same `<axis>: <value>.to_string()` owned-forward payload
4995// shape, `reason` axis removed and `nome`-axis added at the per-dep-
4996// owned altitude the `DepError` envelope keys off (every `DepError`
4997// variant carries the offending `:deps :nome` verbatim so the author
4998// can grep their caixa.lisp for the offending block in one edit). The
4999// three variants share the same `{ nome: String, <axis>: String }`
5000// two-slot shape: the `nome` field names the offending dep the
5001// diagnostic points the author back at, and the middle `<axis>:
5002// String` field carries the offending per-envelope axis value verbatim
5003// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5004// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5005// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5006// The middle axis-field name differs across variants (`pin` / `pins` /
5007// `caracteristica`) so the ctor family below takes the axis field name
5008// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5009// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5010// Self` inherent constructor per typed variant that spells the
5011// uniform two-field construction (`nome.to_string()` /
5012// `<axis>.to_string()`) exactly once.
5013//
5014// The three wire-up sites this fold closes are:
5015// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5016// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5017// pin.to_string() });` inside the `set.len() == 1` branch after the
5018// `is_some_and(String::is_empty)` iterator);
5019// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5020// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5021// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5022// - [`Dep::validate_caracteristicas`]'s per-entry
5023// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5024// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5025// [`crate::render::insert_first_seen`]).
5026//
5027// Each opened the identical four-line struct-literal against the same
5028// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5029// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5030// same altitude the peer four already-lifted `DepError` ctor families
5031// closed on their sibling shape-envelopes. The three variant / axis-
5032// field discriminators are the only things that vary between them;
5033// the rest of the struct-literal is a byte-for-byte re-inline.
5034//
5035// Every future consumer wanting to raise one of these three
5036// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5037// at lacre-resolve time re-checking each declared dep against the
5038// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5039// set-not-multiset cascade, a future `feira validate --deps` per-
5040// caixa admission verb re-running the shape gates on demand, a
5041// per-lacre overlay resolver rejecting an author-supplied dep against
5042// a cluster-local snapshot the M4 CR materializer projects) now
5043// reaches one dispatch rather than re-inlining the four-line struct-
5044// literal in lockstep with the three in-crate wire-up sites.
5045macro_rules! dep_nome_axis_ctors {
5046 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5047 impl DepError {
5048 $(
5049 #[doc = concat!(
5050 "Construct a [`DepError::",
5051 stringify!($variant),
5052 "`] naming the offending `:deps :nome` and the ",
5053 "offending `:", stringify!($axis), "` axis value. ",
5054 "Folds the uniform `Self::",
5055 stringify!($variant),
5056 " { nome: nome.to_string(), ",
5057 stringify!($axis),
5058 ": ",
5059 stringify!($axis),
5060 ".to_string() }` two-field struct-literal onto one ",
5061 "substrate primitive so every in-crate wire-up on ",
5062 "this variant reads through one dispatch rather than ",
5063 "the pre-lift four-line open-coded block. Both `nome: ",
5064 "&str` and `",
5065 stringify!($axis),
5066 ": &str` parameters accept `&str` literals and ",
5067 "`&String` (via Deref coercion) so every existing ",
5068 "wire-up threads through the ctor without a pre-",
5069 "conversion."
5070 )]
5071 #[must_use]
5072 pub fn $ctor(nome: &str, $axis: &str) -> Self {
5073 Self::$variant {
5074 nome: nome.to_string(),
5075 $axis: $axis.to_string(),
5076 }
5077 }
5078 )*
5079 }
5080 };
5081}
5082
5083dep_nome_axis_ctors! {
5084 fonte_pin_empty => FontePinEmpty { pin },
5085 fonte_pin_ambiguous => FontePinAmbiguous { pins },
5086 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5087}
5088
5089// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5090// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5091// struct-variant wire-up sites at [`DepSource::validate`]'s
5092// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5093// the `DepError` envelope — the last open-coded ctor site remaining on
5094// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5095// carries, and the single-variant sibling of the peer four already-
5096// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5097// on the two-slot `{ nome, caminho }` envelope,
5098// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5099// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5100// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5101// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5102// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5103// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5104// `{ …, value: String, reason: String }` payload shape, one axis
5105// removed at the `nome`-only-owner altitude the `DepError` envelope
5106// keys off (no `edge_pair()` de/para pair).
5107//
5108// The two wire-up sites this fold closes are the paired refname-pin
5109// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5110// pin: pin.to_string(), value: v.clone(), reason }` inside the
5111// `[(":tag", tag), (":branch", branch)]` iterator against
5112// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5113// (`|| DepError::FontePinShape { nome: nome.to_string(),
5114// pin: ":rev".to_string(), value: v.clone(), reason }` against
5115// [`crate::render::is_git_oid`]) — each opened the identical
5116// `DepError::FontePinShape { … }` six-line struct-literal against the
5117// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5118// tuple, the exact "same block re-inlined at every consumer" shape
5119// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5120// the only thing that varies between them (`":tag"`/`":branch"` on
5121// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5122// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5123// route through the same ctor because their `pin` field carries the
5124// author-surface tag verbatim (matching the `FontePinEmpty` /
5125// `FontePinAmbiguous` sibling variants' `pin: String` axis
5126// convention), so the offending author can grep their caixa.lisp for
5127// the offending `:tag "<value>"` / `:branch "<value>"` /
5128// `:rev "<value>"` literal in one edit.
5129//
5130// The single ctor below folds each wire-up onto one dispatch:
5131// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5132// the pre-lift struct-literal on the same `(&str, &str, &str,
5133// String)` fixture. The uniform four-field construction
5134// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5135// `reason` forwarded owned) is spelled once here rather than at every
5136// wire-up site. The `reason: String` field takes an owned `String`
5137// (not `impl Into<String>`) matching the two call sites' pre-existing
5138// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5139// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5140// predicates return `Result<(), String>`, so the caller always holds
5141// an owned `String` at the wire-up site and threading it through the
5142// ctor without a `.into()` shim keeps the routing shape byte-equal to
5143// the pre-lift block. The `value: &str` parameter accepts both `&str`
5144// literals (unused today) and `&String` (from the caller-held
5145// `v: &String` on each arm, via Deref coercion), so every existing
5146// wire-up threads through the ctor without a pre-conversion.
5147//
5148// Every future consumer that wants to construct this variant outside
5149// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5150// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5151// re-checking the same value-shape axes the resolver consumes, a
5152// future `feira validate --deps` per-caixa admission verb re-checking
5153// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5154// resolver rejecting a git-pin value against a cluster-local
5155// snapshot) now reaches this variant through one call rather than
5156// re-inlining the six-line struct-literal in lockstep with the two
5157// in-crate wire-up sites.
5158impl DepError {
5159 /// Construct a [`DepError::FontePinShape`] naming the offending
5160 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5161 /// axis tag, the offending value, and the parser-shaped `reason`.
5162 /// Folds the uniform
5163 /// `Self::FontePinShape { nome: nome.to_string(),
5164 /// pin: pin.to_string(), value: value.to_string(), reason }`
5165 /// four-field struct-literal onto one substrate primitive so
5166 /// every [`DepSource::validate`] wire-up on this variant reads
5167 /// through one dispatch rather than the pre-lift six-line
5168 /// open-coded block. The `nome` string threads verbatim from
5169 /// [`Dep::nome`] at the call site; the `pin` string carries the
5170 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5171 /// `value` string carries the offending refname / hex-OID
5172 /// verbatim; and `reason` forwards the owned `String` returned
5173 /// by [`crate::render::is_git_ref_name`] /
5174 /// [`crate::render::is_git_oid`] without a `.into()` shim.
5175 #[must_use]
5176 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5177 Self::FontePinShape {
5178 nome: nome.to_string(),
5179 pin: pin.to_string(),
5180 value: value.to_string(),
5181 reason,
5182 }
5183 }
5184
5185 /// Construct a [`DepError::NomeInvalid`] naming the offending
5186 /// `:deps :nome` byte-string and the parser-shaped rejection
5187 /// `reason` returned by [`crate::render::is_dns_1123_label`].
5188 ///
5189 /// Folds the uniform
5190 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5191 /// struct-literal onto one substrate primitive so every wire-up on
5192 /// this variant reads through one dispatch rather than the pre-lift
5193 /// four-line open-coded `DepError::NomeInvalid { nome:
5194 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5195 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5196 /// ctor-family ladder (`{ nome }` one-slot →
5197 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5198 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5199 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5200 /// `{ nome, <axis>: String, reason: String }` three-slot →
5201 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5202 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5203 /// — the sole variant on the envelope carrying the
5204 /// `{ nome: String, reason: String }` two-slot shape without a
5205 /// middle axis, matching the peer
5206 /// [`crate::manifest::ManifestError::NomeInvalid`] +
5207 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5208 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5209 /// four-axis DNS-1123 caixa-identifier diagnostic family the
5210 /// existing `nome_invalid_diagnostic_carries_offending_name` test
5211 /// pins on this envelope.
5212 ///
5213 /// The `nome: &str` parameter accepts `&str` literals and `&String`
5214 /// (via Deref coercion) so the sole in-crate wire-up threads through
5215 /// the ctor without a pre-conversion; the `reason: String`
5216 /// parameter takes an owned `String` (not `impl Into<String>`)
5217 /// matching the [`crate::render::is_dns_1123_label`] predicate's
5218 /// `Result<(), String>` return shape the sole wire-up site already
5219 /// holds owned at the call site, keeping the routing byte-equal to
5220 /// the pre-lift block. Same owned-`String`-forward `reason` payload
5221 /// discipline as the sibling three-slot family
5222 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5223 /// and the four-slot [`DepError::fonte_pin_shape`] on
5224 /// `{ nome, pin, value, reason }`.
5225 ///
5226 /// Every future consumer that raises the same diagnostic outside
5227 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5228 /// re-validator at lacre-resolve time re-checking each declared
5229 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5230 /// side schema uses (the `:nome` value flows verbatim as the target
5231 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5232 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5233 /// checkout-directory leaf), a future `feira validate --deps`
5234 /// per-caixa admission verb re-running the shape gate on demand, a
5235 /// per-lacre overlay resolver rejecting an author-supplied dep's
5236 /// `:nome` against a cluster-local snapshot the M4 CR materializer
5237 /// projects, a future authoring-surface widening the field into a
5238 /// `(String, Vec<Suggestion>)` pair carrying a
5239 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5240 /// variant through one call rather than re-inlining the four-line
5241 /// struct-literal in lockstep with the one in-crate wire-up site.
5242 #[must_use]
5243 pub fn nome_invalid(nome: &str, reason: String) -> Self {
5244 Self::NomeInvalid {
5245 nome: nome.to_string(),
5246 reason,
5247 }
5248 }
5249}
5250
5251#[allow(clippy::trivially_copy_pass_by_ref)]
5252fn is_false(b: &bool) -> bool {
5253 !*b
5254}
5255
5256#[cfg(test)]
5257mod tests {
5258 use super::*;
5259
5260 #[test]
5261 fn registry_dep_is_minimal() {
5262 let d = Dep::simple("caixa-teia", "^0.1");
5263 assert_eq!(d.nome, "caixa-teia");
5264 assert_eq!(d.versao, "^0.1");
5265 assert!(d.fonte.is_none());
5266 assert!(!d.opcional());
5267 assert!(d.caracteristicas().is_empty());
5268 }
5269
5270 #[test]
5271 fn dep_string_scalar_accessor_pair_is_const_fn() {
5272 // Fail-before-pass-after pin on [`Dep::nome`] +
5273 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5274 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5275 // entry's [`String`] storage through the `pub const fn`
5276 // [`String::as_str`] (const-stable since Rust 1.87, well
5277 // within the workspace MSRV) — any future accidental
5278 // downgrade to non-`const` fails the corresponding
5279 // `<name>_via_const_fn` wrapper at caixa-core build time with
5280 // E0015 (`cannot call non-const method`), strictly stronger
5281 // than a runtime `assert!`. Sibling of the peer
5282 // per-M2/M3/universal-axis `String → &str` scalar-accessor
5283 // family pins on the sibling `const`-eval-surface passes
5284 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5285 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5286 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5287 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5288 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5289 // [`crate::aplicacao::Entrada::destination`] at the M3
5290 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5291 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5292 // M2 supervisor-tree axis,
5293 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5294 // M2 upgrade axis, and the per-`:contratos`
5295 // [`crate::aplicacao::WitContract::source`] /
5296 // [`crate::aplicacao::WitContract::destination`] /
5297 // [`crate::aplicacao::WitContract::world_ref`] trio the
5298 // sibling pin at 279823b already anchors).
5299 const fn nome_via_const_fn(d: &Dep) -> &str {
5300 d.nome()
5301 }
5302 const fn versao_via_const_fn(d: &Dep) -> &str {
5303 d.versao_requirement()
5304 }
5305 for (nome, versao) in [
5306 ("caixa-teia", "^0.1"),
5307 ("caixa-mesh", "~0.2.3"),
5308 ("caixa-helm", "*"),
5309 ] {
5310 let d = Dep::simple(nome, versao);
5311 assert_eq!(nome_via_const_fn(&d), d.nome());
5312 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5313 assert_eq!(d.nome(), nome);
5314 assert_eq!(d.versao_requirement(), versao);
5315 }
5316 }
5317
5318 #[test]
5319 fn dep_outer_accessor_family_is_const_fn() {
5320 // Fail-before-pass-after pin on [`Dep::fonte`] +
5321 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5322 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5323 // entry's composite / list storage through a `pub const fn`
5324 // stdlib method (`Option::<DepSource>::as_ref` /
5325 // `Vec::<String>::as_slice`, both const-stable since Rust
5326 // 1.83, well within the workspace MSRV). Any future
5327 // accidental downgrade to non-`const` fails the corresponding
5328 // `<name>_via_const_fn` wrapper at caixa-core build time with
5329 // E0015 (`cannot call non-const method`), strictly stronger
5330 // than a runtime `assert!` and side-stepping the destructor-
5331 // in-const restriction the `Dep` fixture's `String` /
5332 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5333 // direct-`const _: () = assert!(...)` residence.
5334 //
5335 // Peer of the sibling per-`Dep` scalar-accessor pair pin
5336 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5337 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5338 // the `const`-eval-surface discipline onto the composite-
5339 // reference and slice-return arms of the outer-`Dep` accessor
5340 // family, closing the four-slot outer surface (`:nome` +
5341 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5342 // posture. The `:opcional` `bool` arm already carries the
5343 // posture through [`Dep::opcional`]'s prior `pub const fn`
5344 // declaration, so this pin lands the last two unlifted
5345 // outer-`Dep` accessors and closes the family.
5346 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5347 d.fonte()
5348 }
5349 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5350 d.caracteristicas()
5351 }
5352 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5353 let empty = Dep::simple("caixa-teia", "^0.1");
5354 assert!(fonte_via_const_fn(&empty).is_none());
5355 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5356 assert!(caracteristicas_via_const_fn(&empty).is_empty());
5357 assert_eq!(
5358 caracteristicas_via_const_fn(&empty),
5359 empty.caracteristicas()
5360 );
5361 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5362 // still empty.
5363 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5364 assert!(fonte_via_const_fn(&git).is_some());
5365 assert_eq!(fonte_via_const_fn(&git), git.fonte());
5366 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5367 // Populated `:caracteristicas` — exercise the non-empty
5368 // slice-view arm to pin the accessor's borrow shape against
5369 // both a `Vec::new()` empty backing buffer and a populated one.
5370 let mut with_features = Dep::simple("caixa-teia", "^0.1");
5371 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5372 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5373 assert_eq!(
5374 caracteristicas_via_const_fn(&with_features),
5375 with_features.caracteristicas()
5376 );
5377 }
5378
5379 #[test]
5380 fn git_dep_carries_tag() {
5381 let d = Dep::git("t", "*", "github:o/r", "v1");
5382 match d.fonte {
5383 Some(DepSource::Git {
5384 ref repo, ref tag, ..
5385 }) => {
5386 assert_eq!(repo, "github:o/r");
5387 assert_eq!(tag.as_deref(), Some("v1"));
5388 }
5389 _ => panic!("expected Git source"),
5390 }
5391 }
5392
5393 #[test]
5394 fn validate_accepts_simple_dep() {
5395 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5396 }
5397
5398 #[test]
5399 fn validate_rejects_empty_nome() {
5400 // The fail-before-pass-after pin for `:nome ""`: the empty-name
5401 // arm fires first so the per-entry parse-side diagnostic doesn't
5402 // emit a useless `nome: ""` reference.
5403 let mut d = Dep::simple("placeholder", "^0.1");
5404 d.nome = String::new();
5405 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5406 }
5407
5408 #[test]
5409 fn validate_rejects_empty_versao() {
5410 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5411 // semver crate accepts the empty string as a wildcard match),
5412 // so the empty-`:versao` arm is structurally necessary even
5413 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5414 // `EmptyChildVersion` ordering on the other two `:versao` axes.
5415 let mut d = Dep::simple("caixa-teia", "ignored");
5416 d.versao = String::new();
5417 let err = d.validate().unwrap_err();
5418 assert!(
5419 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5420 "got {err:?}"
5421 );
5422 }
5423
5424 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5425
5426 #[test]
5427 fn validate_rejects_nome_with_uppercase() {
5428 // The fail-before-pass-after pin: a non-empty but uppercase
5429 // `:nome` silently passed `validate()` on every pre-gate
5430 // codebase because the prior shape only refused the empty
5431 // string. The DNS-1123 violation surfaced far downstream at
5432 // lacre-resolve time when the *target* caixa's `:nome` failed
5433 // its own gate — far from the `:deps` entry, with a diagnostic
5434 // naming the target rather than the dep entry that referenced
5435 // it. Same fail-before-pass-after fixture pinned for
5436 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5437 // and Caixa `:nome` (6c992f8).
5438 let d = Dep::simple("Caixa-Teia", "^0.1");
5439 let err = d.validate().unwrap_err();
5440 assert!(
5441 matches!(
5442 err,
5443 DepError::NomeInvalid { ref nome, ref reason }
5444 if nome == "Caixa-Teia" && reason.contains("uppercase")
5445 ),
5446 "got {err:?}"
5447 );
5448 }
5449
5450 #[test]
5451 fn validate_rejects_nome_with_underscore() {
5452 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5453 // "I'm thinking of Go module names / Python identifiers" leak.
5454 // Same fixture pinned for the peer caixa-identifier axes.
5455 let d = Dep::simple("caixa_teia", "^0.1");
5456 let err = d.validate().unwrap_err();
5457 assert!(
5458 matches!(
5459 err,
5460 DepError::NomeInvalid { ref nome, ref reason }
5461 if nome == "caixa_teia" && reason.contains('_')
5462 ),
5463 "got {err:?}"
5464 );
5465 }
5466
5467 #[test]
5468 fn validate_rejects_nome_with_dot() {
5469 // A `:deps :nome` is a single DNS-1123 *label*, not a
5470 // subdomain — dots are rejected. The `"caixa.teia"` shape is
5471 // the canonical "I confused the dep name with the FQDN /
5472 // namespace" footgun, distinct from the legitimate
5473 // `:fonte :repo "github:org/caixa-teia"` axis.
5474 let d = Dep::simple("caixa.teia", "^0.1");
5475 let err = d.validate().unwrap_err();
5476 assert!(
5477 matches!(
5478 err,
5479 DepError::NomeInvalid { ref nome, ref reason }
5480 if nome == "caixa.teia" && reason.contains('.')
5481 ),
5482 "got {err:?}"
5483 );
5484 }
5485
5486 #[test]
5487 fn validate_rejects_nome_with_leading_hyphen() {
5488 // RFC 1123 requires alphanumeric at both label boundaries.
5489 // Pinned in parity with the peer DNS-1123 fixtures.
5490 let d = Dep::simple("-caixa-teia", "^0.1");
5491 let err = d.validate().unwrap_err();
5492 assert!(
5493 matches!(
5494 err,
5495 DepError::NomeInvalid { ref nome, ref reason }
5496 if nome == "-caixa-teia" && reason.contains("alphanumeric")
5497 ),
5498 "got {err:?}"
5499 );
5500 }
5501
5502 #[test]
5503 fn validate_rejects_nome_with_trailing_hyphen() {
5504 let d = Dep::simple("caixa-teia-", "^0.1");
5505 let err = d.validate().unwrap_err();
5506 assert!(
5507 matches!(
5508 err,
5509 DepError::NomeInvalid { ref nome, ref reason }
5510 if nome == "caixa-teia-" && reason.contains("alphanumeric")
5511 ),
5512 "got {err:?}"
5513 );
5514 }
5515
5516 #[test]
5517 fn validate_rejects_nome_with_slash() {
5518 // The canonical "I copied the GitHub repo path into `:nome`
5519 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5520 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5521 // the local-name slot. Same fixture pinned for `:membros
5522 // :caixa` (3f9d7a0).
5523 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5524 let err = d.validate().unwrap_err();
5525 assert!(
5526 matches!(
5527 err,
5528 DepError::NomeInvalid { ref nome, ref reason }
5529 if nome == "pleme-io/caixa-teia" && reason.contains('/')
5530 ),
5531 "got {err:?}"
5532 );
5533 }
5534
5535 #[test]
5536 fn validate_rejects_nome_too_long() {
5537 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5538 // Built from a valid character set so the length-bound
5539 // diagnostic surfaces before any per-character check (the
5540 // order pin parallel to the per-character predicates inside
5541 // [`crate::render::is_dns_1123_label`]).
5542 let long = "a".repeat(64);
5543 let d = Dep::simple(&long, "^0.1");
5544 let err = d.validate().unwrap_err();
5545 assert!(
5546 matches!(
5547 err,
5548 DepError::NomeInvalid { ref nome, ref reason }
5549 if nome.len() == 64 && reason.contains("max length of 63")
5550 ),
5551 "got {err:?}"
5552 );
5553 }
5554
5555 #[test]
5556 fn validate_accepts_canonical_nome_labels() {
5557 // Positive-control sweep — every form the K8s apiserver
5558 // accepts as a DNS-1123 label must round-trip through
5559 // validate. Covers a hyphen-bearing label, a numeric-suffix
5560 // label, a leading-digit label, a single-character label, and
5561 // a 63-byte (exactly the cap) label — the same fixture set
5562 // the peer `:membros :caixa` / `:children :caixa` positive
5563 // controls pin.
5564 for nome in [
5565 "caixa-teia",
5566 "caixa-resolver2",
5567 "2nd-tier-cache",
5568 "x",
5569 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5570 ] {
5571 Dep::simple(nome, "^0.1")
5572 .validate()
5573 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5574 }
5575 }
5576
5577 #[test]
5578 fn nome_empty_takes_precedence_over_nome_invalid() {
5579 // Ordering pin: `NomeEmpty` is the more self-locating
5580 // diagnostic on `""` and must lead — `is_dns_1123_label` is
5581 // only reached after the empty-check fires at the call site.
5582 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5583 // (3f9d7a0) on the peer caixa-identifier axis.
5584 let mut d = Dep::simple("placeholder", "^0.1");
5585 d.nome = String::new();
5586 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5587 }
5588
5589 #[test]
5590 fn nome_invalid_fires_before_versao_empty() {
5591 // Ordering pin: a malformed `:nome` fires before any `:versao`
5592 // axis check on the *same* entry — the per-entry shape gates
5593 // run top-to-bottom (nome empty → nome shape → versao empty →
5594 // versao parse → fonte shape), so a one-entry caixa.lisp with
5595 // both wrong sees the name-side diagnostic first (the name is
5596 // the self-locating axis — without a valid name, the parse
5597 // diagnostic can't quote `:nome "<bad>"`). Same ordering
5598 // discipline as `membro_caixa_invalid_fires_before_versao_check`
5599 // (3f9d7a0).
5600 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5601 d.versao = String::new();
5602 let err = d.validate().unwrap_err();
5603 assert!(
5604 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5605 "got {err:?}"
5606 );
5607 }
5608
5609 #[test]
5610 fn nome_invalid_fires_before_versao_invalid() {
5611 // Ordering pin: a malformed `:nome` fires before the `:versao`
5612 // parse-side check on the *same* entry. Pin separately from
5613 // the empty-versao ordering so a future re-ordering surfaces
5614 // here, parallel to the b0c8389 / c4213a4 trajectory.
5615 let d = Dep::simple("Caixa-Teia", "^^0.1");
5616 let err = d.validate().unwrap_err();
5617 assert!(
5618 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5619 "got {err:?}"
5620 );
5621 }
5622
5623 #[test]
5624 fn nome_invalid_fires_before_fonte_invalid() {
5625 // Ordering pin: a malformed `:nome` fires before the `:fonte`
5626 // shape check on the *same* entry. The `:fonte` diagnostic
5627 // names the offending dep's `:nome` verbatim (via
5628 // `DepSource::validate(&self.nome)`), so a non-self-locating
5629 // name would taint the downstream diagnostic too — the gate
5630 // ordering keeps both diagnostics individually self-locating.
5631 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5632 d.fonte = Some(DepSource::Git {
5633 repo: String::new(),
5634 tag: None,
5635 rev: None,
5636 branch: None,
5637 });
5638 let err = d.validate().unwrap_err();
5639 assert!(
5640 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5641 "got {err:?}"
5642 );
5643 }
5644
5645 #[test]
5646 fn nome_invalid_diagnostic_carries_offending_name() {
5647 // The diagnostic-shape pin: the error names the offending
5648 // `:nome` value verbatim so the author can grep their
5649 // caixa.lisp without re-running the build, and carries a
5650 // non-empty `reason` from `is_dns_1123_label` so the
5651 // predicate's own wording flows through to the diagnostic.
5652 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5653 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5654 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5655 // share a structurally-equivalent diagnostic family.
5656 let d = Dep::simple("Caixa_Teia", "^0.1");
5657 let err = d.validate().unwrap_err();
5658 let DepError::NomeInvalid { nome, reason } = err else {
5659 panic!("expected NomeInvalid, got other variant");
5660 };
5661 assert_eq!(nome, "Caixa_Teia");
5662 assert!(
5663 !reason.is_empty(),
5664 "NomeInvalid `reason` must carry the predicate's wording verbatim"
5665 );
5666 }
5667
5668 #[test]
5669 fn validate_rejects_invalid_versao_requirement() {
5670 // The fail-before-pass-after pin: a non-empty but malformed
5671 // requirement (`"^bad-version"`) silently passed every pre-gate
5672 // codebase because `:deps :versao` wasn't validated. The parse
5673 // failure surfaced far downstream at lacre-resolve time with a
5674 // `semver::Error` that didn't name which `:deps` entry carried
5675 // the typo. The new gate moves the check to caixa-build time
5676 // at the source caixa.lisp.
5677 let d = Dep::simple("caixa-teia", "^bad-version");
5678 let err = d.validate().unwrap_err();
5679 assert!(
5680 matches!(
5681 err,
5682 DepError::VersaoInvalid { ref nome, ref versao, .. }
5683 if nome == "caixa-teia" && versao == "^bad-version"
5684 ),
5685 "got {err:?}"
5686 );
5687 }
5688
5689 #[test]
5690 fn validate_rejects_versao_with_double_caret_typo() {
5691 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5692 // Cargo-shaped requirement on first glance but fails the parser
5693 // because semver doesn't accept stacked operators. Pin this
5694 // adjacent-shape footgun explicitly so a future relaxation that
5695 // accepts "looks-canonical-but-isn't" forms surfaces here, in
5696 // parity with the `:membros` / `:children` fixtures.
5697 let d = Dep::simple("caixa-teia", "^^0.1");
5698 let err = d.validate().unwrap_err();
5699 assert!(
5700 matches!(
5701 err,
5702 DepError::VersaoInvalid { ref nome, ref versao, .. }
5703 if nome == "caixa-teia" && versao == "^^0.1"
5704 ),
5705 "got {err:?}"
5706 );
5707 }
5708
5709 #[test]
5710 fn validate_rejects_versao_with_v_prefixed_tag() {
5711 // `"v0.1"` is the canonical "git-tag-shape leaking into the
5712 // semver requirement slot" typo — an author copies the
5713 // publish-side git-tag string verbatim into `:versao`, but
5714 // Cargo's semver parser rejects the leading `v`. Same fixture
5715 // pinned for `:membros :versao` (9888b13) and `:children
5716 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5717 // are *accepted* by the semver crate as an `*` wildcard on the
5718 // patch axis — they're a Cargo-side valid shape, not a typo.)
5719 let d = Dep::simple("caixa-teia", "v0.1");
5720 let err = d.validate().unwrap_err();
5721 assert!(
5722 matches!(
5723 err,
5724 DepError::VersaoInvalid { ref nome, ref versao, .. }
5725 if nome == "caixa-teia" && versao == "v0.1"
5726 ),
5727 "got {err:?}"
5728 );
5729 }
5730
5731 #[test]
5732 fn validate_accepts_canonical_versao_forms() {
5733 // The five Cargo-shaped requirement forms `:membros :versao`
5734 // and `:children :versao` already accept via
5735 // `crate::parse_requirement` must pass the deps gate without
5736 // re-validating at the resolver layer. Pin every leg so a
5737 // future tightening of the canonical set surfaces here as a
5738 // test failure.
5739 for form in [
5740 "^0.1", // caret — minor-range pin (the most common shape)
5741 "~0.1.2", // tilde — patch-range pin
5742 "0.1.0", // exact — single-version pin
5743 "*", // wildcard — explicitly any-version
5744 ">=0.1, <2", // multi-range — comma-separated comparators
5745 ] {
5746 Dep::simple("caixa-teia", form)
5747 .validate()
5748 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
5749 }
5750 }
5751
5752 #[test]
5753 fn versao_empty_takes_precedence_over_invalid() {
5754 // Order pin: the existing `VersaoEmpty` diagnostic (which
5755 // doesn't try to parse) fires before the new `VersaoInvalid`
5756 // parse-side diagnostic, so an empty `:versao` keeps its
5757 // narrower error message — `parse_requirement("")` would
5758 // otherwise return `Ok(STAR)` and silently pass, but the empty
5759 // arm catches it first.
5760 let mut d = Dep::simple("caixa-teia", "ignored");
5761 d.versao = String::new();
5762 let err = d.validate().unwrap_err();
5763 assert!(
5764 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5765 "got {err:?}"
5766 );
5767 }
5768
5769 #[test]
5770 fn nome_empty_takes_precedence_over_versao_invalid() {
5771 // Order pin: even when `:versao` is malformed and would raise
5772 // its own diagnostic, `:nome ""` fires first because the
5773 // per-entry parse diagnostic needs a non-empty name to be
5774 // self-locating. Mirrors the
5775 // `membros_validation_runs_before_contratos_membership_check`
5776 // ordering on the typed-graph layer.
5777 let mut d = Dep::simple("placeholder", "^bad");
5778 d.nome = String::new();
5779 let err = d.validate().unwrap_err();
5780 assert_eq!(err, DepError::NomeEmpty);
5781 }
5782
5783 #[test]
5784 fn versao_invalid_diagnostic_carries_offending_versao() {
5785 // The diagnostic-shape pin: the error names the offending
5786 // `:versao` value verbatim so the author can grep their
5787 // caixa.lisp without re-running the build, and carries a
5788 // non-empty `reason` from `semver::VersionReq::parse` so the
5789 // parser's own wording flows through to the diagnostic.
5790 let d = Dep::simple("caixa-teia", "not-a-req");
5791 let err = d.validate().unwrap_err();
5792 let DepError::VersaoInvalid {
5793 nome,
5794 versao,
5795 reason,
5796 } = err
5797 else {
5798 panic!("expected VersaoInvalid, got other variant");
5799 };
5800 assert_eq!(nome, "caixa-teia");
5801 assert_eq!(versao, "not-a-req");
5802 assert!(
5803 !reason.is_empty(),
5804 "VersaoInvalid `reason` must carry the parser's wording verbatim"
5805 );
5806 }
5807
5808 // -- :fonte value-shape gate ------------------------------------------
5809
5810 fn dep_with_fonte(fonte: DepSource) -> Dep {
5811 let mut d = Dep::simple("caixa-teia", "^0.1");
5812 d.fonte = Some(fonte);
5813 d
5814 }
5815
5816 #[test]
5817 fn validate_accepts_git_fonte_with_tag() {
5818 // The positive-control pin on the canonical git source — exactly
5819 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
5820 // shape every existing caixa-resolver integration test uses.
5821 let d = dep_with_fonte(DepSource::Git {
5822 repo: "github:pleme-io/caixa-teia".into(),
5823 tag: Some("v0.1.0".into()),
5824 rev: None,
5825 branch: None,
5826 });
5827 d.validate().unwrap();
5828 }
5829
5830 #[test]
5831 fn validate_accepts_git_fonte_with_rev() {
5832 // Each of the three pin axes is independently a valid single-pin
5833 // shape; pin the :rev arm so a future relaxation that only
5834 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
5835 // OID — the canonical `git rev-parse HEAD` emission shape the
5836 // `crate::render::is_git_oid` value-shape gate now requires;
5837 // abbreviated OIDs are ambiguous across repo history and
5838 // rejected at this gate (pinned separately by
5839 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
5840 let d = dep_with_fonte(DepSource::Git {
5841 repo: "github:pleme-io/caixa-teia".into(),
5842 tag: None,
5843 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
5844 branch: None,
5845 });
5846 d.validate().unwrap();
5847 }
5848
5849 #[test]
5850 fn validate_accepts_git_fonte_with_branch() {
5851 // The :branch arm is the third valid single-pin shape — pinned
5852 // separately so the gate-accepts-all-three-pin-axes contract is
5853 // a build-error to relax.
5854 let d = dep_with_fonte(DepSource::Git {
5855 repo: "github:pleme-io/caixa-teia".into(),
5856 tag: None,
5857 rev: None,
5858 branch: Some("main".into()),
5859 });
5860 d.validate().unwrap();
5861 }
5862
5863 #[test]
5864 fn validate_accepts_path_fonte() {
5865 // The positive-control pin on the path source — non-empty
5866 // :caminho, no pin axes (paths have no commit identity). Pinned
5867 // so a future "paths must also pin a rev" tightening surfaces
5868 // here as a structural decision, not a silent break.
5869 let d = dep_with_fonte(DepSource::Path {
5870 caminho: "../caixa-teia".into(),
5871 });
5872 d.validate().unwrap();
5873 }
5874
5875 #[test]
5876 fn validate_rejects_git_fonte_with_empty_repo() {
5877 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
5878 // "v1")`: the empty-repo shape silently passed every pre-gate
5879 // codebase because `:fonte` wasn't validated. The git-clone
5880 // failure surfaced far downstream at lacre-resolve time with no
5881 // field naming which `:deps` entry carried the typo. The new
5882 // gate moves the check to caixa-build time at the source
5883 // caixa.lisp.
5884 let d = dep_with_fonte(DepSource::Git {
5885 repo: String::new(),
5886 tag: Some("v0.1.0".into()),
5887 rev: None,
5888 branch: None,
5889 });
5890 let err = d.validate().unwrap_err();
5891 assert!(
5892 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
5893 "got {err:?}"
5894 );
5895 }
5896
5897 // -- :repo value-shape gate -------------------------------------------
5898 //
5899 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
5900 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
5901 // codebase admitted any non-empty string; the new
5902 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
5903 // URL intersection-floor at validate time, peer with the three pin
5904 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
5905 // `is_git_oid`). Every test in this section is a fail-before /
5906 // pass-after pin on a specific authoring footgun.
5907
5908 #[test]
5909 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
5910 // The canonical paste-from-doc footgun on `:repo` — an author
5911 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
5912 // a doc paragraph. Until this gate landed the empty-repo arm
5913 // passed (the string isn't empty), the resolver issued
5914 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
5915 // surfaced at clone time with a quoting-confused error far from
5916 // the source caixa.lisp. Same paste-from-doc footgun the
5917 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
5918 // axis — now closed on the `:repo` URL axis too.
5919 let d = dep_with_fonte(DepSource::Git {
5920 repo: "github:pleme-io/caixa-teia ".into(),
5921 tag: Some("v0.1.0".into()),
5922 rev: None,
5923 branch: None,
5924 });
5925 let err = d.validate().unwrap_err();
5926 let DepError::FonteRepoShape { nome, repo, reason } = err else {
5927 panic!("expected FonteRepoShape, got other variant");
5928 };
5929 assert_eq!(nome, "caixa-teia");
5930 assert_eq!(repo, "github:pleme-io/caixa-teia ");
5931 assert!(
5932 reason.contains("whitespace"),
5933 "reason must surface the whitespace arm, got {reason:?}"
5934 );
5935 }
5936
5937 #[test]
5938 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
5939 // The canonical CLI-argument-injection footgun at the `git clone`
5940 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
5941 // argv parser read the value as a CLI flag, escaping the
5942 // subprocess argument boundary. The `--` separator workaround
5943 // does not fix the typed slot's accepted set; the gate rejects
5944 // the shape upstream at validate time so the resolver never
5945 // invokes a `git clone -…` subprocess.
5946 let d = dep_with_fonte(DepSource::Git {
5947 repo: "-upload-pack=evil".into(),
5948 tag: Some("v0.1.0".into()),
5949 rev: None,
5950 branch: None,
5951 });
5952 let err = d.validate().unwrap_err();
5953 let DepError::FonteRepoShape { repo, reason, .. } = err else {
5954 panic!("expected FonteRepoShape, got other variant");
5955 };
5956 assert_eq!(repo, "-upload-pack=evil");
5957 assert!(
5958 reason.contains("must not start with `-`"),
5959 "reason must surface the leading-`-` arm, got {reason:?}"
5960 );
5961 }
5962
5963 #[test]
5964 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
5965 // The canonical paste-from-multiline-doc footgun — a `:repo`
5966 // string with an embedded `\n` silently breaks git's URL parser
5967 // and is a class of CRLF-injection at the subprocess-argument
5968 // boundary. Caught by the control-char arm (0x0A < 0x20).
5969 let d = dep_with_fonte(DepSource::Git {
5970 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
5971 tag: Some("v0.1.0".into()),
5972 rev: None,
5973 branch: None,
5974 });
5975 let err = d.validate().unwrap_err();
5976 let DepError::FonteRepoShape { reason, .. } = err else {
5977 panic!("expected FonteRepoShape, got other variant");
5978 };
5979 assert!(
5980 reason.contains("control character"),
5981 "reason must surface the control-char arm, got {reason:?}"
5982 );
5983 }
5984
5985 #[test]
5986 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
5987 // Tab is the sibling whitespace footgun (the canonical
5988 // copy-from-aligned-table paste); pinned separately from the
5989 // space arm so a future relaxation that only catches one
5990 // surfaces here.
5991 let d = dep_with_fonte(DepSource::Git {
5992 repo: "github:pleme-io/caixa-teia\t".into(),
5993 tag: Some("v0.1.0".into()),
5994 rev: None,
5995 branch: None,
5996 });
5997 let err = d.validate().unwrap_err();
5998 assert!(
5999 matches!(
6000 err,
6001 DepError::FonteRepoShape { ref reason, .. }
6002 if reason.contains("whitespace")
6003 ),
6004 "got {err:?}"
6005 );
6006 }
6007
6008 #[test]
6009 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6010 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6011 // non-ASCII silently breaks at git's URL parser and round-trips
6012 // inconsistently across NFC/NFD normalization on APFS /
6013 // case-folding filesystems. Same intersection-floor
6014 // [`is_git_ref_name`] enforces on the refname axes.
6015 let d = dep_with_fonte(DepSource::Git {
6016 repo: "https://github.com/pleme-io/café".into(),
6017 tag: Some("v0.1.0".into()),
6018 rev: None,
6019 branch: None,
6020 });
6021 let err = d.validate().unwrap_err();
6022 assert!(
6023 matches!(
6024 err,
6025 DepError::FonteRepoShape { ref reason, .. }
6026 if reason.contains("non-ASCII")
6027 ),
6028 "got {err:?}"
6029 );
6030 }
6031
6032 #[test]
6033 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6034 // The fail-before-pass-after pin for the canonical paste-from-
6035 // browser-address-bar footgun on `:repo`: an author copies a
6036 // GitHub permalink to a README anchor / line-permalink and
6037 // forgets to trim the `#fragment` tail. Until this arm landed
6038 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6039 // silently passed every prior arm (no whitespace, no control
6040 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6041 // or `:`), libcurl's URL parser stripped the `#readme` tail
6042 // before opening the HTTPS transport, and the lacre embedded
6043 // the value verbatim in its per-dep BLAKE3 closure — two
6044 // authors whose values differ only in their fragment anchor
6045 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6046 // `git clone` but lock to two distinct lacres, defeating the
6047 // THEORY.md §V.2 render-determinism contract. Same value-shape
6048 // axis-floor every peer typed surface enforces; peer `:fonte
6049 // :tag` / `:fonte :branch` already reject the byte-class through
6050 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6051 // URL grammar admitted) and `:entrada :paths` rejects `#` as
6052 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6053 let d = dep_with_fonte(DepSource::Git {
6054 repo: "https://github.com/pleme-io/caixa-teia#readme".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 { nome, repo, reason } = err else {
6061 panic!("expected FonteRepoShape, got other variant");
6062 };
6063 assert_eq!(nome, "caixa-teia");
6064 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6065 assert!(
6066 reason.contains("must not contain `#`"),
6067 "reason must surface the fragment-`#` arm, got {reason:?}"
6068 );
6069 assert!(
6070 reason.contains("fragment"),
6071 "reason must name the URL fragment grammar, got {reason:?}"
6072 );
6073 }
6074
6075 #[test]
6076 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6077 // The symmetric paste-from-Nix-flake-ref footgun — an author
6078 // confuses the Nix flake-reference idiom (`github:foo/
6079 // bar#packageName`, where `#packageName` selects a flake
6080 // output) with the bare git `:repo` shape. The pleme-io
6081 // substrate authors compose flakes downstream of caixa
6082 // (caixa-flake renders a flake.nix), so the cross-idiom leak
6083 // is the canonical near-miss: the author writes the
6084 // flake-ref shape into a git `:repo` slot. Pinned separately
6085 // from the HTTPS-anchor arm so a future relaxation that
6086 // narrows to one URL scheme surfaces here.
6087 let d = dep_with_fonte(DepSource::Git {
6088 repo: "github:pleme-io/caixa-teia#caixa-teia".into(),
6089 tag: Some("v0.1.0".into()),
6090 rev: None,
6091 branch: None,
6092 });
6093 let err = d.validate().unwrap_err();
6094 let DepError::FonteRepoShape { reason, .. } = err else {
6095 panic!("expected FonteRepoShape, got other variant");
6096 };
6097 assert!(
6098 reason.contains("must not contain `#`"),
6099 "reason must surface the fragment-`#` arm, got {reason:?}"
6100 );
6101 assert!(
6102 reason.contains("Nix flake"),
6103 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6104 );
6105 }
6106
6107 #[test]
6108 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6109 // The fail-before-pass-after pin for the canonical paste-from-
6110 // browser-address-bar footgun on `:repo` (peer with the
6111 // a68f818 fragment-`#` arm on the same axis). An author
6112 // copies a GitHub tab deep-link out of the address bar and
6113 // forgets to trim the `?tab=…` query tail. Until this arm
6114 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6115 // silently passed every prior arm (no whitespace, no control
6116 // chars, no non-ASCII, no `#` fragment, contains a `:`,
6117 // doesn't start with `-` or `:`); GitHub silently ignored
6118 // the `?query` tail and served the same repo regardless;
6119 // the lacre embedded the value verbatim in its per-dep
6120 // BLAKE3 closure — two authors whose values differ only in
6121 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6122 // `?utm_source=twitter`) resolve to the byte-identical
6123 // upstream `git clone` but lock to two distinct lacres,
6124 // defeating the THEORY.md §V.2 render-determinism contract
6125 // on the same axis the `#` fragment arm closes. Same value-
6126 // shape axis-floor every peer typed surface enforces; peer
6127 // `:fonte :tag` / `:fonte :branch` already reject the byte-
6128 // class through `is_git_ref_name`'s alphabet (refspec glob
6129 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6130 // :paths` rejects `?` as the query separator in
6131 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6132 let d = dep_with_fonte(DepSource::Git {
6133 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6134 tag: Some("v0.1.0".into()),
6135 rev: None,
6136 branch: None,
6137 });
6138 let err = d.validate().unwrap_err();
6139 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6140 panic!("expected FonteRepoShape, got other variant");
6141 };
6142 assert_eq!(nome, "caixa-teia");
6143 assert_eq!(
6144 repo,
6145 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6146 );
6147 assert!(
6148 reason.contains("must not contain `?`"),
6149 "reason must surface the query-`?` arm, got {reason:?}"
6150 );
6151 assert!(
6152 reason.contains("query"),
6153 "reason must name the URL query grammar, got {reason:?}"
6154 );
6155 }
6156
6157 #[test]
6158 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6159 // The symmetric paste-from-social-share footgun — an author
6160 // copies a repo URL out of a Slack unfurl / Twitter share /
6161 // newsletter link / Discord embed and forgets to trim the
6162 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6163 // campaign-tracker tail. Every major social-share / unfurl /
6164 // newsletter platform appends these UTM parameters; the
6165 // canonical near-miss on the `:repo` axis. Pinned separately
6166 // from the GitHub-tab-deep-link arm so a future relaxation
6167 // that narrows to one query-parameter class surfaces here.
6168 let d = dep_with_fonte(DepSource::Git {
6169 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6170 .into(),
6171 tag: Some("v0.1.0".into()),
6172 rev: None,
6173 branch: None,
6174 });
6175 let err = d.validate().unwrap_err();
6176 let DepError::FonteRepoShape { reason, .. } = err else {
6177 panic!("expected FonteRepoShape, got other variant");
6178 };
6179 assert!(
6180 reason.contains("must not contain `?`"),
6181 "reason must surface the query-`?` arm, got {reason:?}"
6182 );
6183 assert!(
6184 reason.contains("campaign-tracker"),
6185 "reason must name the campaign-tracker paste footgun, got {reason:?}"
6186 );
6187 }
6188
6189 #[test]
6190 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6191 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6192 // both per-byte arms inside the same `for &b in s.as_bytes()`
6193 // loop, so the byte that appears first in the value's byte
6194 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6195 // (fragment before query — unusual URL-grammar but value-
6196 // disjoint at byte level) carries both `#` and `?`; the `#`
6197 // byte appears first, so the fragment-`#` arm fires, surfacing
6198 // the more self-locating diagnostic on the byte the author
6199 // pasted earliest in the URL. Mirrors the peer cascade
6200 // discipline `fonte_repo_control_char_fires_before_fragment`
6201 // pins on the prior `:repo` byte-class arm.
6202 let d = dep_with_fonte(DepSource::Git {
6203 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6204 tag: Some("v0.1.0".into()),
6205 rev: None,
6206 branch: None,
6207 });
6208 let err = d.validate().unwrap_err();
6209 let DepError::FonteRepoShape { reason, .. } = err else {
6210 panic!("expected FonteRepoShape, got other variant");
6211 };
6212 assert!(
6213 reason.contains("must not contain `#`"),
6214 "reason must surface the fragment-`#` arm (fires before query-`?` when \
6215 `#` byte appears first in value), got {reason:?}"
6216 );
6217 }
6218
6219 #[test]
6220 fn fonte_repo_control_char_fires_before_fragment() {
6221 // Cascade pin: the control-char arm structurally precedes the
6222 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6223 // positive on both arms (contains LF and `#`), but the narrower
6224 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6225 // (`control character`) wins so the author sees the more
6226 // self-locating arm first. Mirrors the peer cascade discipline
6227 // every prior `:repo` byte-class arm establishes.
6228 let d = dep_with_fonte(DepSource::Git {
6229 repo: "github:pleme-io/caixa-teia\n#readme".into(),
6230 tag: Some("v0.1.0".into()),
6231 rev: None,
6232 branch: None,
6233 });
6234 let err = d.validate().unwrap_err();
6235 let DepError::FonteRepoShape { reason, .. } = err else {
6236 panic!("expected FonteRepoShape, got other variant");
6237 };
6238 assert!(
6239 reason.contains("control character"),
6240 "reason must surface the control-char arm, got {reason:?}"
6241 );
6242 }
6243
6244 #[test]
6245 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6246 // The fail-before-pass-after pin for the canonical Windows-
6247 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6248 // backslash arm on the sibling `:caminho` path-fonte axis).
6249 // An author pastes a Windows Explorer address-bar / PowerShell
6250 // `Get-Location` output into a `file://` URL slot, producing
6251 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6252 // value silently passed every prior arm (no whitespace, no
6253 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6254 // with `-` or `:`); libcurl's URL parser silently translates
6255 // `\` → `/` on some platforms and refuses it on others, so
6256 // the byte rides verbatim into the lacre's per-dep content-
6257 // address but is silently rewritten / rejected at the wire —
6258 // two authors whose `:repo` values differ only in backslash-
6259 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6260 // resolve to the byte-identical local clone but lock to two
6261 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6262 // render-determinism contract on the same axis the `#`
6263 // fragment and `?` query arms close. Same value-shape axis-
6264 // floor every peer typed surface enforces; the `:caminho`
6265 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6266 let d = dep_with_fonte(DepSource::Git {
6267 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6268 tag: Some("v0.1.0".into()),
6269 rev: None,
6270 branch: None,
6271 });
6272 let err = d.validate().unwrap_err();
6273 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6274 panic!("expected FonteRepoShape, got other variant");
6275 };
6276 assert_eq!(nome, "caixa-teia");
6277 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6278 assert!(
6279 reason.contains("must not contain `\\`"),
6280 "reason must surface the backslash-`\\` arm, got {reason:?}"
6281 );
6282 assert!(
6283 reason.contains("Windows"),
6284 "reason must name the Windows-path-confusion footgun, got {reason:?}"
6285 );
6286 }
6287
6288 #[test]
6289 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6290 // The symmetric Win32-shell-mangled-slashes footgun — an author
6291 // copies `https://github.com/foo/bar` into a Win32 shell that
6292 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6293 // separator-coercion bug), pastes the result into a `:repo`
6294 // slot, and produces `https:\\github.com\foo\bar`. Pinned
6295 // separately from the `file://` Explorer-paste arm so a future
6296 // relaxation that narrows to one URL scheme surfaces here.
6297 let d = dep_with_fonte(DepSource::Git {
6298 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6299 tag: Some("v0.1.0".into()),
6300 rev: None,
6301 branch: None,
6302 });
6303 let err = d.validate().unwrap_err();
6304 let DepError::FonteRepoShape { reason, .. } = err else {
6305 panic!("expected FonteRepoShape, got other variant");
6306 };
6307 assert!(
6308 reason.contains("must not contain `\\`"),
6309 "reason must surface the backslash-`\\` arm, got {reason:?}"
6310 );
6311 assert!(
6312 reason.contains("path separator") || reason.contains("path-segment separator"),
6313 "reason must name the URL path-segment separator grammar, got {reason:?}"
6314 );
6315 }
6316
6317 #[test]
6318 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6319 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6320 // are both per-byte arms inside the same `for &b in s.as_bytes()`
6321 // loop, so the byte that appears first in the value's byte order
6322 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6323 // both `#` and `\`; the `#` byte appears first, so the fragment-
6324 // `#` arm fires, surfacing the more self-locating diagnostic on
6325 // the byte the author pasted earliest in the URL. Mirrors the
6326 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6327 // pins on the prior `:repo` byte-class arm.
6328 let d = dep_with_fonte(DepSource::Git {
6329 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6330 tag: Some("v0.1.0".into()),
6331 rev: None,
6332 branch: None,
6333 });
6334 let err = d.validate().unwrap_err();
6335 let DepError::FonteRepoShape { reason, .. } = err else {
6336 panic!("expected FonteRepoShape, got other variant");
6337 };
6338 assert!(
6339 reason.contains("must not contain `#`"),
6340 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6341 `#` byte appears first in value), got {reason:?}"
6342 );
6343 }
6344
6345 #[test]
6346 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6347 // The fail-before-pass-after pin for the canonical URI Template
6348 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6349 // README quick-start snippet / OpenAPI `servers:` URL / Helm
6350 // chart `home:` template that carries unresolved
6351 // `{org}` / `{repo}` placeholders and pastes the raw template
6352 // into the `:repo` slot, expecting the substrate to resolve the
6353 // placeholder downstream. Until this arm landed the value
6354 // silently passed every prior arm (no whitespace, no control
6355 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6356 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6357 // / `%7D` on the wire, so the byte rides verbatim into the
6358 // lacre's per-dep content-address but round-trips inconsistently
6359 // between the lacre's per-dep content-address and the
6360 // resolver's `git clone <repo>` invocation, defeating the
6361 // THEORY.md §V.2 render-determinism contract on the same axis
6362 // the `#` fragment, `?` query, and `\` backslash arms close;
6363 // every git porcelain entry-point additionally fetches a
6364 // nonexistent literal-`{placeholder}`-named path far from the
6365 // source caixa.lisp.
6366 let d = dep_with_fonte(DepSource::Git {
6367 repo: "https://github.com/{org}/caixa-teia".into(),
6368 tag: Some("v0.1.0".into()),
6369 rev: None,
6370 branch: None,
6371 });
6372 let err = d.validate().unwrap_err();
6373 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6374 panic!("expected FonteRepoShape, got other variant");
6375 };
6376 assert_eq!(nome, "caixa-teia");
6377 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6378 assert!(
6379 reason.contains("must not contain `{`"),
6380 "reason must surface the open-brace `{{` arm, got {reason:?}"
6381 );
6382 assert!(
6383 reason.contains("URI Template") || reason.contains("RFC 6570"),
6384 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6385 );
6386 }
6387
6388 #[test]
6389 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6390 // The symmetric Mustache / Handlebars doubled-brace
6391 // substitution-form footgun every CI / IaC templating engine
6392 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6393 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6394 // chart README quick-start snippet emits. Pinned separately
6395 // from the single-`{` `{org}` arm so a future relaxation that
6396 // narrows to one substitution-form surfaces here.
6397 let d = dep_with_fonte(DepSource::Git {
6398 repo: "https://github.com/{{org}}/caixa-teia".into(),
6399 tag: Some("v0.1.0".into()),
6400 rev: None,
6401 branch: None,
6402 });
6403 let err = d.validate().unwrap_err();
6404 let DepError::FonteRepoShape { reason, .. } = err else {
6405 panic!("expected FonteRepoShape, got other variant");
6406 };
6407 assert!(
6408 reason.contains("must not contain `{`"),
6409 "reason must surface the open-brace `{{` arm, got {reason:?}"
6410 );
6411 }
6412
6413 #[test]
6414 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6415 // Asymmetric `}`-only shape — covers the closing-brace-by-
6416 // itself footgun (an author truncated `{org}/{repo}` mid-edit
6417 // and left a trailing `}` from the prior template fragment,
6418 // or pasted a value that included a closing brace from a
6419 // surrounding shell context). Pinned to ensure the predicate
6420 // refuses each brace independently rather than only when both
6421 // appear — a future regression that ANDs the two byte tests
6422 // surfaces here.
6423 let d = dep_with_fonte(DepSource::Git {
6424 repo: "https://github.com/pleme-io/caixa-teia}".into(),
6425 tag: Some("v0.1.0".into()),
6426 rev: None,
6427 branch: None,
6428 });
6429 let err = d.validate().unwrap_err();
6430 let DepError::FonteRepoShape { reason, .. } = err else {
6431 panic!("expected FonteRepoShape, got other variant");
6432 };
6433 assert!(
6434 reason.contains("must not contain `}`"),
6435 "reason must surface the close-brace `}}` arm, got {reason:?}"
6436 );
6437 }
6438
6439 #[test]
6440 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6441 // Cascade pin: the fragment-`#` arm and the template-`{` /
6442 // `}` arm are both per-byte arms inside the same
6443 // `for &b in s.as_bytes()` loop, so the byte that appears
6444 // first in the value's byte order wins. A `:repo
6445 // "https://github.com/p/x#readme{org}"` carries both `#` and
6446 // `{`; the `#` byte appears first, so the fragment-`#` arm
6447 // fires, surfacing the more self-locating diagnostic on the
6448 // byte the author pasted earliest in the URL. Mirrors the
6449 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6450 // pins on the prior `:repo` byte-class arm.
6451 let d = dep_with_fonte(DepSource::Git {
6452 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6453 tag: Some("v0.1.0".into()),
6454 rev: None,
6455 branch: None,
6456 });
6457 let err = d.validate().unwrap_err();
6458 let DepError::FonteRepoShape { reason, .. } = err else {
6459 panic!("expected FonteRepoShape, got other variant");
6460 };
6461 assert!(
6462 reason.contains("must not contain `#`"),
6463 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6464 `#` byte appears first in value), got {reason:?}"
6465 );
6466 }
6467
6468 #[test]
6469 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6470 // The fail-before-pass-after pin for the canonical
6471 // shell-output-redirection footgun on `:repo`: an author
6472 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6473 // / `… >output.txt`) into the `:repo` slot without trimming
6474 // the redirect. Until this arm landed the value silently
6475 // passed every prior arm (no whitespace, no control chars,
6476 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6477 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6478 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6479 // percent-encode set maps `>` → `%3E` on the wire, so the
6480 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6481 // but is silently rewritten or rejected at libcurl's URL-
6482 // parser layer — two authors whose values differ only in
6483 // their redirect tail (`>build.log` vs nothing) resolve to
6484 // the byte-identical upstream `git clone` but lock to two
6485 // distinct lacres, defeating the THEORY.md §V.2 render-
6486 // determinism contract. Peer with the `:caminho` axis's
6487 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6488 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6489 // byte RFC-3986-reserved set on `:entrada :paths`.
6490 let d = dep_with_fonte(DepSource::Git {
6491 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6492 tag: Some("v0.1.0".into()),
6493 rev: None,
6494 branch: None,
6495 });
6496 let err = d.validate().unwrap_err();
6497 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6498 panic!("expected FonteRepoShape, got other variant");
6499 };
6500 assert_eq!(nome, "caixa-teia");
6501 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6502 assert!(
6503 reason.contains("must not contain `>`"),
6504 "reason must surface the output-redirection `>` arm, got {reason:?}"
6505 );
6506 assert!(
6507 reason.contains("redirection") || reason.contains("'delims'"),
6508 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6509 );
6510 }
6511
6512 #[test]
6513 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6514 // The symmetric shell-input-redirection footgun — an author
6515 // pastes a shell-pipeline head (`git clone <input.url` /
6516 // `cat <README.md`) into the `:repo` slot. Pinned separately
6517 // from the `>`-output arm so a future relaxation that only
6518 // catches one of the two redirect bytes surfaces here. Peer
6519 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6520 // arm which closes both `<` and `>` under the same banner.
6521 let d = dep_with_fonte(DepSource::Git {
6522 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6523 tag: Some("v0.1.0".into()),
6524 rev: None,
6525 branch: None,
6526 });
6527 let err = d.validate().unwrap_err();
6528 let DepError::FonteRepoShape { reason, .. } = err else {
6529 panic!("expected FonteRepoShape, got other variant");
6530 };
6531 assert!(
6532 reason.contains("must not contain `<`"),
6533 "reason must surface the input-redirection `<` arm, got {reason:?}"
6534 );
6535 assert!(
6536 reason.contains("RFC 3986") || reason.contains("'unwise'"),
6537 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6538 );
6539 }
6540
6541 #[test]
6542 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6543 // The fail-before-pass-after pin for the canonical
6544 // paste-from-shell-prompt-with-backticked-substitution footgun
6545 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6546 // `:caminho` path-fonte axis). An author pastes a URL whose
6547 // segment carries a backticked command-substitution wrapper
6548 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6549 // from a doc / README quick-start snippet that expected the
6550 // substrate to substitute the value downstream. Until this arm
6551 // landed the value silently passed every prior arm (no
6552 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6553 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6554 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6555 // 'unwise' set and the WHATWG URL spec's fragment percent-
6556 // encode set maps `` ` `` → `%60` on the wire, so the byte
6557 // rides verbatim into the lacre's per-dep BLAKE3 closure but
6558 // is silently rewritten or rejected at libcurl's URL-parser
6559 // layer — two authors whose values differ only in their
6560 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6561 // byte-identical upstream `git clone` but lock to two distinct
6562 // lacres, defeating the THEORY.md §V.2 render-determinism
6563 // contract. Peer with the `:caminho` axis's
6564 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6565 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6566 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6567 let d = dep_with_fonte(DepSource::Git {
6568 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6569 tag: Some("v0.1.0".into()),
6570 rev: None,
6571 branch: None,
6572 });
6573 let err = d.validate().unwrap_err();
6574 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6575 panic!("expected FonteRepoShape, got other variant");
6576 };
6577 assert_eq!(nome, "caixa-teia");
6578 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6579 assert!(
6580 reason.contains("must not contain `` ` ``"),
6581 "reason must surface the backtick command-substitution arm, got {reason:?}"
6582 );
6583 assert!(
6584 reason.contains("command-substitution") || reason.contains("'unwise'"),
6585 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6586 got {reason:?}"
6587 );
6588 }
6589
6590 #[test]
6591 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6592 // Cascade pin: the fragment-`#` arm and the backtick command-
6593 // substitution arm are both per-byte arms inside the same
6594 // `for &b in s.as_bytes()` loop, so the byte that appears first
6595 // in the value's byte order wins. A `:repo
6596 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6597 // and backtick; the `#` byte appears first, so the fragment-
6598 // `#` arm fires, surfacing the more self-locating diagnostic
6599 // on the byte the author pasted earliest in the URL. Mirrors
6600 // the peer cascade discipline
6601 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6602 // pins on the prior `:repo` byte-class arm.
6603 let d = dep_with_fonte(DepSource::Git {
6604 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6605 tag: Some("v0.1.0".into()),
6606 rev: None,
6607 branch: None,
6608 });
6609 let err = d.validate().unwrap_err();
6610 let DepError::FonteRepoShape { reason, .. } = err else {
6611 panic!("expected FonteRepoShape, got other variant");
6612 };
6613 assert!(
6614 reason.contains("must not contain `#`"),
6615 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6616 appears first in value), got {reason:?}"
6617 );
6618 }
6619
6620 #[test]
6621 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6622 // Cascade pin: the shell-redirection `<` / `>` arm and the
6623 // backtick command-substitution arm are both per-byte arms
6624 // inside the same `for &b in s.as_bytes()` loop, so the byte
6625 // that appears first in the value's byte order wins. A `:repo
6626 // "https://github.com/p/x>build.log/`whoami`"` carries both
6627 // `>` and backtick; the `>` byte appears first, so the
6628 // shell-redirection arm fires, surfacing the more self-
6629 // locating diagnostic on the byte the author pasted earliest
6630 // in the URL. Pins the natural-order cascade so a future
6631 // reorder of the per-byte arms surfaces here.
6632 let d = dep_with_fonte(DepSource::Git {
6633 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6634 tag: Some("v0.1.0".into()),
6635 rev: None,
6636 branch: None,
6637 });
6638 let err = d.validate().unwrap_err();
6639 let DepError::FonteRepoShape { reason, .. } = err else {
6640 panic!("expected FonteRepoShape, got other variant");
6641 };
6642 assert!(
6643 reason.contains("must not contain `>`"),
6644 "reason must surface the shell-redirection `>` arm (fires before backtick when \
6645 `>` byte appears first in value), got {reason:?}"
6646 );
6647 }
6648
6649 #[test]
6650 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6651 // Cascade pin: the fragment-`#` arm and the shell-redirection
6652 // `<` / `>` arm are both per-byte arms inside the same
6653 // `for &b in s.as_bytes()` loop, so the byte that appears
6654 // first in the value's byte order wins. A `:repo
6655 // "https://github.com/p/x#readme>build.log"` carries both
6656 // `#` and `>`; the `#` byte appears first, so the fragment-
6657 // `#` arm fires, surfacing the more self-locating diagnostic
6658 // on the byte the author pasted earliest in the URL. Mirrors
6659 // the peer cascade discipline
6660 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6661 // pins on the prior `:repo` byte-class arm.
6662 let d = dep_with_fonte(DepSource::Git {
6663 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6664 tag: Some("v0.1.0".into()),
6665 rev: None,
6666 branch: None,
6667 });
6668 let err = d.validate().unwrap_err();
6669 let DepError::FonteRepoShape { reason, .. } = err else {
6670 panic!("expected FonteRepoShape, got other variant");
6671 };
6672 assert!(
6673 reason.contains("must not contain `#`"),
6674 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6675 `#` byte appears first in value), got {reason:?}"
6676 );
6677 }
6678
6679 #[test]
6680 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6681 // The fail-before-pass-after pin for the canonical
6682 // paste-from-shell-prompt-with-piped-pipeline footgun on
6683 // `:repo` (peer with the 124106f pipe arm on the sibling
6684 // `:caminho` path-fonte axis). An author pastes a shell
6685 // pipeline (`git clone <url> | tee build.log`,
6686 // `git ls-remote <url> | head`) into the `:repo` slot,
6687 // forgetting to trim the `| <consumer>` tail. Until this arm
6688 // landed the value silently passed every prior arm (no
6689 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6690 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6691 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6692 // 'unwise' set and the WHATWG URL spec's fragment percent-
6693 // encode set maps `|` → `%7C` on the wire, so the byte rides
6694 // verbatim into the lacre's per-dep BLAKE3 closure but is
6695 // silently rewritten or rejected at libcurl's URL-parser
6696 // layer — two authors whose values differ only in their pipe
6697 // tail (`|tee build.log` vs nothing) resolve to the byte-
6698 // identical upstream `git clone` but lock to two distinct
6699 // lacres, defeating the THEORY.md §V.2 render-determinism
6700 // contract. Peer with the `:caminho` axis's
6701 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6702 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6703 // RFC-3986-reserved set on `:entrada :paths`.
6704 let d = dep_with_fonte(DepSource::Git {
6705 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6706 tag: Some("v0.1.0".into()),
6707 rev: None,
6708 branch: None,
6709 });
6710 let err = d.validate().unwrap_err();
6711 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6712 panic!("expected FonteRepoShape, got other variant");
6713 };
6714 assert_eq!(nome, "caixa-teia");
6715 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6716 assert!(
6717 reason.contains("must not contain `|`"),
6718 "reason must surface the shell-pipe arm, got {reason:?}"
6719 );
6720 assert!(
6721 reason.contains("pipe") || reason.contains("'unwise'"),
6722 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
6723 );
6724 }
6725
6726 #[test]
6727 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
6728 // Cascade pin: the fragment-`#` arm and the pipe arm are both
6729 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6730 // so the byte that appears first in the value's byte order
6731 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
6732 // both `#` and `|`; the `#` byte appears first, so the
6733 // fragment-`#` arm fires, surfacing the more self-locating
6734 // diagnostic on the byte the author pasted earliest in the
6735 // URL. Mirrors the peer cascade discipline
6736 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
6737 // pins on the prior `:repo` byte-class arm.
6738 let d = dep_with_fonte(DepSource::Git {
6739 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
6740 tag: Some("v0.1.0".into()),
6741 rev: None,
6742 branch: None,
6743 });
6744 let err = d.validate().unwrap_err();
6745 let DepError::FonteRepoShape { reason, .. } = err else {
6746 panic!("expected FonteRepoShape, got other variant");
6747 };
6748 assert!(
6749 reason.contains("must not contain `#`"),
6750 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
6751 appears first in value), got {reason:?}"
6752 );
6753 }
6754
6755 #[test]
6756 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
6757 // Cascade pin: the backtick arm and the pipe arm are both per-
6758 // byte arms inside the same `for &b in s.as_bytes()` loop, so
6759 // the byte that appears first in the value's byte order wins.
6760 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
6761 // `` ` `` and `|`; the backtick byte appears first, so the
6762 // backtick arm fires, surfacing the more self-locating
6763 // diagnostic on the byte the author pasted earliest in the
6764 // URL. Pins the natural-order cascade so a future reorder of
6765 // the per-byte arms surfaces here.
6766 let d = dep_with_fonte(DepSource::Git {
6767 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
6768 tag: Some("v0.1.0".into()),
6769 rev: None,
6770 branch: None,
6771 });
6772 let err = d.validate().unwrap_err();
6773 let DepError::FonteRepoShape { reason, .. } = err else {
6774 panic!("expected FonteRepoShape, got other variant");
6775 };
6776 assert!(
6777 reason.contains("must not contain `` ` ``"),
6778 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
6779 appears first in value), got {reason:?}"
6780 );
6781 }
6782
6783 #[test]
6784 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
6785 // The fail-before-pass-after pin for the canonical
6786 // paste-from-shell-prompt-with-sequential-command-tail footgun
6787 // on `:repo` (peer with the 05c358e `;` arm on the sibling
6788 // `:caminho` path-fonte axis). An author pastes a shell
6789 // one-liner that chained a cleanup tail after the URL
6790 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
6791 // echo done`) into the `:repo` slot, forgetting to trim the
6792 // `; <cmd>` tail. Until this arm landed the value silently
6793 // passed every prior `is_git_repo_url` arm (no whitespace, no
6794 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
6795 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
6796 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
6797 // reserved set and the WHATWG URL spec's fragment percent-
6798 // encode set maps `;` → `%3B` on the wire, so the byte rides
6799 // verbatim into the lacre's per-dep BLAKE3 closure but is
6800 // silently rewritten at libcurl's URL-parser layer — two
6801 // authors whose values differ only in their sequential-command
6802 // tail (`; rm -rf build` vs nothing) resolve to the byte-
6803 // identical upstream `git clone` but lock to two distinct
6804 // lacres, defeating the THEORY.md §V.2 render-determinism
6805 // contract. Peer with the `:caminho` axis's
6806 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
6807 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6808 // byte RFC-3986-reserved set on `:entrada :paths`.
6809 let d = dep_with_fonte(DepSource::Git {
6810 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
6811 tag: Some("v0.1.0".into()),
6812 rev: None,
6813 branch: None,
6814 });
6815 let err = d.validate().unwrap_err();
6816 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6817 panic!("expected FonteRepoShape, got other variant");
6818 };
6819 assert_eq!(nome, "caixa-teia");
6820 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
6821 assert!(
6822 reason.contains("must not contain `;`"),
6823 "reason must surface the shell-command-separator arm, got {reason:?}"
6824 );
6825 assert!(
6826 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
6827 "reason must name the shell-command-separator / RFC-3986-sub-delims \
6828 rationale, got {reason:?}"
6829 );
6830 }
6831
6832 #[test]
6833 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
6834 // Cascade pin: the fragment-`#` arm and the semicolon arm are
6835 // both per-byte arms inside the same `for &b in s.as_bytes()`
6836 // loop, so the byte that appears first in the value's byte
6837 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
6838 // carries both `#` and `;`; the `#` byte appears first, so the
6839 // fragment-`#` arm fires, surfacing the more self-locating
6840 // diagnostic on the byte the author pasted earliest in the URL.
6841 // Mirrors the peer cascade discipline
6842 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
6843 // pins on the prior `:repo` byte-class arm.
6844 let d = dep_with_fonte(DepSource::Git {
6845 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
6846 tag: Some("v0.1.0".into()),
6847 rev: None,
6848 branch: None,
6849 });
6850 let err = d.validate().unwrap_err();
6851 let DepError::FonteRepoShape { reason, .. } = err else {
6852 panic!("expected FonteRepoShape, got other variant");
6853 };
6854 assert!(
6855 reason.contains("must not contain `#`"),
6856 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
6857 byte appears first in value), got {reason:?}"
6858 );
6859 }
6860
6861 #[test]
6862 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
6863 // Cascade pin: the pipe arm and the semicolon arm are both
6864 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
6865 // so the byte that appears first in the value's byte order
6866 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
6867 // both `|` and `;`; the `|` byte appears first, so the
6868 // pipe arm fires, surfacing the more self-locating diagnostic
6869 // on the byte the author pasted earliest in the URL. Pins the
6870 // natural-order cascade so a future reorder of the per-byte
6871 // arms surfaces here.
6872 let d = dep_with_fonte(DepSource::Git {
6873 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
6874 tag: Some("v0.1.0".into()),
6875 rev: None,
6876 branch: None,
6877 });
6878 let err = d.validate().unwrap_err();
6879 let DepError::FonteRepoShape { reason, .. } = err else {
6880 panic!("expected FonteRepoShape, got other variant");
6881 };
6882 assert!(
6883 reason.contains("must not contain `|`"),
6884 "reason must surface the pipe arm (fires before semicolon when `|` byte \
6885 appears first in value), got {reason:?}"
6886 );
6887 }
6888
6889 #[test]
6890 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
6891 // The fail-before-pass-after pin for the canonical
6892 // paste-from-shell-prompt-with-background-launch-tail footgun
6893 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
6894 // `:caminho` path-fonte axis). An author pastes a shell one-
6895 // liner that detached the clone into the background
6896 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
6897 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
6898 // `&& <cmd>` tail. Until this arm landed the value silently
6899 // passed every prior `is_git_repo_url` arm (no whitespace,
6900 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
6901 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
6902 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
6903 // the 'sub-delims' / reserved set and the WHATWG URL spec's
6904 // fragment percent-encode set maps `&` → `%26` on the wire,
6905 // so the byte rides verbatim into the lacre's per-dep
6906 // BLAKE3 closure but is silently rewritten at libcurl's
6907 // URL-parser layer — two authors whose values differ only
6908 // in their background-launch tail (`& sleep 1` vs nothing)
6909 // resolve to the byte-identical upstream `git clone` but
6910 // lock to two distinct lacres, defeating the THEORY.md
6911 // §V.2 render-determinism contract. Peer with the
6912 // `:caminho` axis's `FonteCaminhoShellBackground` arm
6913 // (e12e4f3) on the sibling path-fonte axis, and
6914 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
6915 // reserved set on `:entrada :paths`.
6916 let d = dep_with_fonte(DepSource::Git {
6917 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
6918 tag: Some("v0.1.0".into()),
6919 rev: None,
6920 branch: None,
6921 });
6922 let err = d.validate().unwrap_err();
6923 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6924 panic!("expected FonteRepoShape, got other variant");
6925 };
6926 assert_eq!(nome, "caixa-teia");
6927 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
6928 assert!(
6929 reason.contains("must not contain `&`"),
6930 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
6931 );
6932 assert!(
6933 reason.contains("background-task") || reason.contains("'sub-delims'"),
6934 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
6935 got {reason:?}"
6936 );
6937 }
6938
6939 #[test]
6940 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
6941 // The fail-before-pass-after pin for the symmetric `&&`
6942 // logical-AND build-chain paste footgun: an author pastes
6943 // a `git clone <url> && cd <repo>` build-chain one-liner
6944 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
6945 // is the same `&` byte twice in a row; the per-byte arm
6946 // fires on the first `&` it sees. Pinned separately from
6947 // the single-`&` background-launch shape so a future
6948 // diagnostic-surface change that special-cased the
6949 // doubled-byte form surfaces here.
6950 let d = dep_with_fonte(DepSource::Git {
6951 repo: "github:pleme-io/caixa-teia&&echo".into(),
6952 tag: Some("v0.1.0".into()),
6953 rev: None,
6954 branch: None,
6955 });
6956 let err = d.validate().unwrap_err();
6957 let DepError::FonteRepoShape { reason, .. } = err else {
6958 panic!("expected FonteRepoShape, got other variant");
6959 };
6960 assert!(
6961 reason.contains("must not contain `&`"),
6962 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
6963 shape too, got {reason:?}"
6964 );
6965 }
6966
6967 #[test]
6968 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
6969 // Cascade pin: the fragment-`#` arm and the background-`&`
6970 // arm are both per-byte arms inside the same `for &b in
6971 // s.as_bytes()` loop, so the byte that appears first in the
6972 // value's byte order wins. A `:repo
6973 // "https://github.com/p/x#readme & sleep"` carries both `#`
6974 // and `&`; the `#` byte appears first, so the fragment-`#`
6975 // arm fires, surfacing the more self-locating diagnostic on
6976 // the byte the author pasted earliest in the URL. Mirrors
6977 // the peer cascade discipline
6978 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
6979 // on the prior `:repo` byte-class arm.
6980 let d = dep_with_fonte(DepSource::Git {
6981 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
6982 tag: Some("v0.1.0".into()),
6983 rev: None,
6984 branch: None,
6985 });
6986 let err = d.validate().unwrap_err();
6987 let DepError::FonteRepoShape { reason, .. } = err else {
6988 panic!("expected FonteRepoShape, got other variant");
6989 };
6990 assert!(
6991 reason.contains("must not contain `#`"),
6992 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
6993 byte appears first in value), got {reason:?}"
6994 );
6995 }
6996
6997 #[test]
6998 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
6999 // Cascade pin: the semicolon arm and the background-`&` arm
7000 // are both per-byte arms inside the same `for &b in
7001 // s.as_bytes()` loop, so the byte that appears first in the
7002 // value's byte order wins. A `:repo
7003 // "https://github.com/p/x; rm & sleep"` carries both `;` and
7004 // `&`; the `;` byte appears first, so the semicolon arm
7005 // fires, surfacing the more self-locating diagnostic on the
7006 // byte the author pasted earliest in the URL. Pins the
7007 // natural-order cascade so a future reorder of the per-byte
7008 // arms surfaces here.
7009 let d = dep_with_fonte(DepSource::Git {
7010 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7011 tag: Some("v0.1.0".into()),
7012 rev: None,
7013 branch: None,
7014 });
7015 let err = d.validate().unwrap_err();
7016 let DepError::FonteRepoShape { reason, .. } = err else {
7017 panic!("expected FonteRepoShape, got other variant");
7018 };
7019 assert!(
7020 reason.contains("must not contain `;`"),
7021 "reason must surface the semicolon arm (fires before background-`&` when `;` \
7022 byte appears first in value), got {reason:?}"
7023 );
7024 }
7025
7026 #[test]
7027 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7028 // The fail-before-pass-after pin for the canonical
7029 // paste-from-shell-prompt-with-unsubstituted-variable footgun
7030 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7031 // `:caminho` path-fonte axis). An author pastes a shell one-
7032 // liner that referenced an environment variable
7033 // (`git clone https://github.com/$ORG/x`, `git clone
7034 // github:$USER/repo`) into the `:repo` slot, forgetting to
7035 // substitute the literal value at author time. Until this arm
7036 // landed the value silently passed every prior
7037 // `is_git_repo_url` arm (no whitespace, no control chars, no
7038 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7039 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7040 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7041 // reserved set and the WHATWG URL spec's fragment percent-
7042 // encode set maps `$` → `%24` on the wire, so the byte rides
7043 // verbatim into the lacre's per-dep BLAKE3 closure but is
7044 // silently rewritten at libcurl's URL-parser layer — two
7045 // authors whose values differ only in their `$VAR` /
7046 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7047 // identical upstream `git clone` but lock to two distinct
7048 // lacres, defeating the THEORY.md §V.2 render-determinism
7049 // contract. Beyond determinism, the value is a structural
7050 // host-layout leak: two authors with the same `:repo` slot
7051 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7052 // different upstreams. Peer with the `:caminho` axis's
7053 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7054 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7055 // byte RFC-3986-reserved set on `:entrada :paths`.
7056 let d = dep_with_fonte(DepSource::Git {
7057 repo: "https://github.com/$ORG/caixa-teia".into(),
7058 tag: Some("v0.1.0".into()),
7059 rev: None,
7060 branch: None,
7061 });
7062 let err = d.validate().unwrap_err();
7063 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7064 panic!("expected FonteRepoShape, got other variant");
7065 };
7066 assert_eq!(nome, "caixa-teia");
7067 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7068 assert!(
7069 reason.contains("must not contain `$`"),
7070 "reason must surface the shell-variable-expansion arm, got {reason:?}"
7071 );
7072 assert!(
7073 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7074 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7075 rationale, got {reason:?}"
7076 );
7077 }
7078
7079 #[test]
7080 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7081 // The fail-before-pass-after pin for the symmetric POSIX-
7082 // shell braced `${VAR}` expansion paste footgun: an author
7083 // pastes a CI-manifest line `git clone
7084 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7085 // Actions / GitLab CI / Drone shape) and forgets to
7086 // substitute the literal value. The `${...}` shape is the
7087 // same `$` byte at the leading position of the expansion;
7088 // the per-byte arm fires on the `$`. Pinned separately from
7089 // the bare-`$VAR` shape so a future diagnostic-surface
7090 // change that special-cased the braced form surfaces here.
7091 let d = dep_with_fonte(DepSource::Git {
7092 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7093 tag: Some("v0.1.0".into()),
7094 rev: None,
7095 branch: None,
7096 });
7097 let err = d.validate().unwrap_err();
7098 let DepError::FonteRepoShape { reason, .. } = err else {
7099 panic!("expected FonteRepoShape, got other variant");
7100 };
7101 assert!(
7102 reason.contains("must not contain `$`"),
7103 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7104 shape too, got {reason:?}"
7105 );
7106 }
7107
7108 #[test]
7109 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7110 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7111 // arm are both per-byte arms inside the same `for &b in
7112 // s.as_bytes()` loop, so the byte that appears first in the
7113 // value's byte order wins. A `:repo
7114 // "https://github.com/p/x#readme$HOME"` carries both `#` and
7115 // `$`; the `#` byte appears first, so the fragment-`#` arm
7116 // fires, surfacing the more self-locating diagnostic on the
7117 // byte the author pasted earliest in the URL. Mirrors the
7118 // peer cascade discipline
7119 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7120 // on the prior `:repo` byte-class arm.
7121 let d = dep_with_fonte(DepSource::Git {
7122 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7123 tag: Some("v0.1.0".into()),
7124 rev: None,
7125 branch: None,
7126 });
7127 let err = d.validate().unwrap_err();
7128 let DepError::FonteRepoShape { reason, .. } = err else {
7129 panic!("expected FonteRepoShape, got other variant");
7130 };
7131 assert!(
7132 reason.contains("must not contain `#`"),
7133 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7134 `#` byte appears first in value), got {reason:?}"
7135 );
7136 }
7137
7138 #[test]
7139 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7140 // Cascade pin: the background-`&` arm and the
7141 // var-expansion-`$` arm are both per-byte arms inside the
7142 // same `for &b in s.as_bytes()` loop, so the byte that
7143 // appears first in the value's byte order wins. A `:repo
7144 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7145 // `$`; the `&` byte appears first, so the background arm
7146 // fires, surfacing the more self-locating diagnostic on the
7147 // byte the author pasted earliest in the URL. Pins the
7148 // natural-order cascade so a future reorder of the per-byte
7149 // arms surfaces here — `$` is the most recent byte-class arm,
7150 // so the cascade-pin sweep extends to cover every immediately
7151 // prior byte arm (`#`, `&`) firing first when ordered ahead
7152 // of `$` in the value.
7153 let d = dep_with_fonte(DepSource::Git {
7154 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7155 tag: Some("v0.1.0".into()),
7156 rev: None,
7157 branch: None,
7158 });
7159 let err = d.validate().unwrap_err();
7160 let DepError::FonteRepoShape { reason, .. } = err else {
7161 panic!("expected FonteRepoShape, got other variant");
7162 };
7163 assert!(
7164 reason.contains("must not contain `&`"),
7165 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7166 `&` byte appears first in value), got {reason:?}"
7167 );
7168 }
7169
7170 #[test]
7171 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7172 // The fail-before-pass-after pin for the canonical
7173 // paste-from-shell-prompt glob footgun on `:repo` (peer with
7174 // the cf9034b `*` / `?` arm on the sibling `:caminho`
7175 // path-fonte axis). An author pastes a shell one-liner that
7176 // referenced a glob expansion (`ls
7177 // github.com/pleme-io/caixa-*`, `git clone
7178 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7179 // to substitute the literal repo name. Until this arm landed
7180 // the `*` byte silently passed every prior `is_git_repo_url`
7181 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7182 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7183 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7184 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7185 // the WHATWG URL spec's special-query percent-encode set maps
7186 // `*` → `%2A` on the wire, so the byte rides verbatim into
7187 // the lacre's per-dep BLAKE3 closure but is silently
7188 // rewritten at libcurl's URL-parser layer — two authors
7189 // whose values differ only in their asterisk presence
7190 // resolve to the byte-identical upstream `git clone` but
7191 // lock to two distinct lacres, defeating the THEORY.md §V.2
7192 // render-determinism contract. Peer with the `:caminho`
7193 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7194 // sibling path-fonte axis, and the `is_git_ref_name`
7195 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7196 // axes.
7197 let d = dep_with_fonte(DepSource::Git {
7198 repo: "https://github.com/pleme-io/caixa-*".into(),
7199 tag: Some("v0.1.0".into()),
7200 rev: None,
7201 branch: None,
7202 });
7203 let err = d.validate().unwrap_err();
7204 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7205 panic!("expected FonteRepoShape, got other variant");
7206 };
7207 assert_eq!(nome, "caixa-teia");
7208 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7209 assert!(
7210 reason.contains("must not contain `*`"),
7211 "reason must surface the shell-glob arm, got {reason:?}"
7212 );
7213 assert!(
7214 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7215 "reason must name the shell-glob / pathname-expansion / \
7216 RFC-3986-sub-delims rationale, got {reason:?}"
7217 );
7218 }
7219
7220 #[test]
7221 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7222 // The fail-before-pass-after pin for the symmetric bash
7223 // `globstar` recursive-glob paste footgun: an author pastes
7224 // a `ls github.com/pleme-io/**/x` (the canonical
7225 // `globstar`-shopt-enabled recursive-listing tail) into the
7226 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7227 // the per-byte arm fires on the first `*`. Pinned
7228 // separately from the single-`*` shape so a future
7229 // diagnostic-surface change that special-cased the
7230 // double-`*` form surfaces here.
7231 let d = dep_with_fonte(DepSource::Git {
7232 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7233 tag: Some("v0.1.0".into()),
7234 rev: None,
7235 branch: None,
7236 });
7237 let err = d.validate().unwrap_err();
7238 let DepError::FonteRepoShape { reason, .. } = err else {
7239 panic!("expected FonteRepoShape, got other variant");
7240 };
7241 assert!(
7242 reason.contains("must not contain `*`"),
7243 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7244 got {reason:?}"
7245 );
7246 }
7247
7248 #[test]
7249 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7250 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7251 // both per-byte arms inside the same `for &b in s.as_bytes()`
7252 // loop, so the byte that appears first in the value's byte
7253 // order wins. A `:repo
7254 // "https://github.com/p/x#readme*tail"` carries both `#` and
7255 // `*`; the `#` byte appears first, so the fragment-`#` arm
7256 // fires, surfacing the more self-locating diagnostic on the
7257 // byte the author pasted earliest in the URL. Mirrors the
7258 // peer cascade discipline
7259 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7260 // on the prior `:repo` byte-class arm.
7261 let d = dep_with_fonte(DepSource::Git {
7262 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7263 tag: Some("v0.1.0".into()),
7264 rev: None,
7265 branch: None,
7266 });
7267 let err = d.validate().unwrap_err();
7268 let DepError::FonteRepoShape { reason, .. } = err else {
7269 panic!("expected FonteRepoShape, got other variant");
7270 };
7271 assert!(
7272 reason.contains("must not contain `#`"),
7273 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7274 appears first in value), got {reason:?}"
7275 );
7276 }
7277
7278 #[test]
7279 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7280 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7281 // arm are both per-byte arms inside the same `for &b in
7282 // s.as_bytes()` loop, so the byte that appears first in the
7283 // value's byte order wins. A `:repo
7284 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7285 // the `$` byte appears first, so the var-expansion arm
7286 // fires, surfacing the more self-locating diagnostic on the
7287 // byte the author pasted earliest in the URL. Pins the
7288 // natural-order cascade so a future reorder of the per-byte
7289 // arms surfaces here — `*` is the most recent byte-class
7290 // arm, so the cascade-pin sweep extends to cover the
7291 // immediately prior `$` byte arm firing first when ordered
7292 // ahead of `*` in the value.
7293 let d = dep_with_fonte(DepSource::Git {
7294 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7295 tag: Some("v0.1.0".into()),
7296 rev: None,
7297 branch: None,
7298 });
7299 let err = d.validate().unwrap_err();
7300 let DepError::FonteRepoShape { reason, .. } = err else {
7301 panic!("expected FonteRepoShape, got other variant");
7302 };
7303 assert!(
7304 reason.contains("must not contain `$`"),
7305 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7306 byte appears first in value), got {reason:?}"
7307 );
7308 }
7309
7310 #[test]
7311 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7312 // The fail-before-pass-after pin for the canonical paste-from-
7313 // shell-prompt subshell-grouping footgun on `:repo`. An author
7314 // pastes a doc / README snippet carrying a regex-alternation
7315 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7316 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7317 // `:repo` slot, forgetting to substitute one literal org name.
7318 // Until this arm landed the `(` byte silently passed every
7319 // prior `is_git_repo_url` arm (no whitespace, no control
7320 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7321 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7322 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7323 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7324 // URL spec's special-query percent-encode set maps `(` →
7325 // `%28` and `)` → `%29` on the wire, so the byte rides
7326 // verbatim into the lacre's per-dep BLAKE3 closure but is
7327 // silently rewritten at libcurl's URL-parser layer —
7328 // defeating the THEORY.md §V.2 render-determinism contract on
7329 // the same axis the prior twelve byte-class arms close.
7330 let d = dep_with_fonte(DepSource::Git {
7331 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7332 tag: Some("v0.1.0".into()),
7333 rev: None,
7334 branch: None,
7335 });
7336 let err = d.validate().unwrap_err();
7337 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7338 panic!("expected FonteRepoShape, got other variant");
7339 };
7340 assert_eq!(nome, "caixa-teia");
7341 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7342 assert!(
7343 reason.contains("must not contain `(`"),
7344 "reason must surface the subshell-open-paren arm, got {reason:?}"
7345 );
7346 assert!(
7347 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7348 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7349 got {reason:?}"
7350 );
7351 }
7352
7353 #[test]
7354 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7355 // The symmetric arm pin on the closing `)` byte: an author
7356 // pastes a `$(date)` command-substitution wrapper or a
7357 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7358 // Pinned separately from the opening `(` shape so a future
7359 // diagnostic-surface change that only checked one boundary
7360 // surfaces here. The `(` byte appears earlier in the
7361 // canonical regex / subshell wrapper so the per-byte loop
7362 // fires on `(` first; this test exercises a `:repo` value
7363 // carrying only the closing `)` byte (no opening paren) so
7364 // the `)` arm fires directly — pinning the byte-class arm
7365 // independent of order.
7366 let d = dep_with_fonte(DepSource::Git {
7367 repo: "github:pleme-io/caixa-teia)tail".into(),
7368 tag: Some("v0.1.0".into()),
7369 rev: None,
7370 branch: None,
7371 });
7372 let err = d.validate().unwrap_err();
7373 let DepError::FonteRepoShape { reason, .. } = err else {
7374 panic!("expected FonteRepoShape, got other variant");
7375 };
7376 assert!(
7377 reason.contains("must not contain `)`"),
7378 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7379 got {reason:?}"
7380 );
7381 }
7382
7383 #[test]
7384 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7385 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7386 // are both per-byte arms inside the same `for &b in
7387 // s.as_bytes()` loop, so the byte that appears first in the
7388 // value's byte order wins. A `:repo
7389 // "https://github.com/p/x#readme(tail)"` carries both `#` and
7390 // `(`; the `#` byte appears first, so the fragment-`#` arm
7391 // fires, surfacing the more self-locating diagnostic on the
7392 // byte the author pasted earliest in the URL. Mirrors the
7393 // peer cascade discipline
7394 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7395 // on the prior `:repo` byte-class arm.
7396 let d = dep_with_fonte(DepSource::Git {
7397 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7398 tag: Some("v0.1.0".into()),
7399 rev: None,
7400 branch: None,
7401 });
7402 let err = d.validate().unwrap_err();
7403 let DepError::FonteRepoShape { reason, .. } = err else {
7404 panic!("expected FonteRepoShape, got other variant");
7405 };
7406 assert!(
7407 reason.contains("must not contain `#`"),
7408 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7409 byte appears first in value), got {reason:?}"
7410 );
7411 }
7412
7413 #[test]
7414 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7415 // Cascade pin: the glob-`*` arm (the immediate-predecessor
7416 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7417 // per-byte arms inside the same `for &b in s.as_bytes()`
7418 // loop, so the byte that appears first in the value's byte
7419 // order wins. A `:repo
7420 // "https://github.com/p/x-*-(date)"` carries both `*` and
7421 // `(`; the `*` byte appears first, so the glob arm fires,
7422 // surfacing the more self-locating diagnostic on the byte
7423 // the author pasted earliest in the URL. Pins the natural-
7424 // order cascade so a future reorder of the per-byte arms
7425 // surfaces here — `(` is the most recent byte-class arm,
7426 // so the cascade-pin sweep extends to cover the immediately
7427 // prior `*` byte arm firing first when ordered ahead of `(`
7428 // in the value.
7429 let d = dep_with_fonte(DepSource::Git {
7430 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7431 tag: Some("v0.1.0".into()),
7432 rev: None,
7433 branch: None,
7434 });
7435 let err = d.validate().unwrap_err();
7436 let DepError::FonteRepoShape { reason, .. } = err else {
7437 panic!("expected FonteRepoShape, got other variant");
7438 };
7439 assert!(
7440 reason.contains("must not contain `*`"),
7441 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7442 appears first in value), got {reason:?}"
7443 );
7444 }
7445
7446 #[test]
7447 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7448 // The fail-before-pass-after pin for the canonical paste-from-
7449 // doc-shell-quoting footgun on `:repo`. An author copies a
7450 // README quick-start snippet (`$ git clone "https://github.com/
7451 // foo/bar"`) and keeps the surrounding double-quote bytes when
7452 // pasting into the `:repo` slot — the doc wraps the URL in
7453 // double quotes so the shell doesn't re-lex metachars inside,
7454 // but the typed slot is itself a byte-level string parser, not
7455 // a shell context, so the quote bytes ride into the value
7456 // verbatim. Until this arm landed the `"` byte silently passed
7457 // every prior `is_git_repo_url` arm (no whitespace, no control
7458 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7459 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7460 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7461 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7462 // `` ` ``) every URL parser is required to refuse or percent-
7463 // encode, and the WHATWG URL spec's 'C0 control percent-encode
7464 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7465 // into the lacre's per-dep BLAKE3 closure but is silently
7466 // rewritten at libcurl's URL-parser layer, defeating the
7467 // THEORY.md §V.2 render-determinism contract.
7468 let d = dep_with_fonte(DepSource::Git {
7469 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7470 tag: Some("v0.1.0".into()),
7471 rev: None,
7472 branch: None,
7473 });
7474 let err = d.validate().unwrap_err();
7475 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7476 panic!("expected FonteRepoShape, got other variant");
7477 };
7478 assert_eq!(nome, "caixa-teia");
7479 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7480 assert!(
7481 reason.contains("must not contain `\"`"),
7482 "reason must surface the shell-double-quote arm, got {reason:?}"
7483 );
7484 assert!(
7485 reason.contains("double-quote") || reason.contains("'delims'"),
7486 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7487 got {reason:?}"
7488 );
7489 }
7490
7491 #[test]
7492 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7493 // The symmetric stray-quote tail pin: an author pastes only a
7494 // closing `"` from a shell-history line like `git clone
7495 // "https://github.com/foo/bar" && cd …` (the trim went too
7496 // far in one direction but not the other) into the `:repo`
7497 // slot. Pinned separately from the wrapped-quote shape so a
7498 // future diagnostic-surface change that only checked one
7499 // boundary (only leading, only trailing, only paired) surfaces
7500 // here — the per-byte arm fires anywhere `"` appears.
7501 let d = dep_with_fonte(DepSource::Git {
7502 repo: "github:pleme-io/caixa-teia\"".into(),
7503 tag: Some("v0.1.0".into()),
7504 rev: None,
7505 branch: None,
7506 });
7507 let err = d.validate().unwrap_err();
7508 let DepError::FonteRepoShape { reason, .. } = err else {
7509 panic!("expected FonteRepoShape, got other variant");
7510 };
7511 assert!(
7512 reason.contains("must not contain `\"`"),
7513 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7514 got {reason:?}"
7515 );
7516 }
7517
7518 #[test]
7519 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7520 // Cascade pin: the fragment-`#` arm and the double-quote arm
7521 // are both per-byte arms inside the same `for &b in
7522 // s.as_bytes()` loop, so the byte that appears first in the
7523 // value's byte order wins. A `:repo
7524 // "https://github.com/p/x#readme\"tail"` carries both `#` and
7525 // `"`; the `#` byte appears first, so the fragment-`#` arm
7526 // fires, surfacing the more self-locating diagnostic on the
7527 // byte the author pasted earliest in the URL.
7528 let d = dep_with_fonte(DepSource::Git {
7529 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7530 tag: Some("v0.1.0".into()),
7531 rev: None,
7532 branch: None,
7533 });
7534 let err = d.validate().unwrap_err();
7535 let DepError::FonteRepoShape { reason, .. } = err else {
7536 panic!("expected FonteRepoShape, got other variant");
7537 };
7538 assert!(
7539 reason.contains("must not contain `#`"),
7540 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7541 byte appears first in value), got {reason:?}"
7542 );
7543 }
7544
7545 #[test]
7546 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7547 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7548 // byte-class arm, 3b99147) and the double-quote arm are both
7549 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7550 // so the byte that appears first in the value's byte order
7551 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7552 // and `"`; the `(` byte appears first, so the subshell arm
7553 // fires, surfacing the more self-locating diagnostic on the
7554 // byte the author pasted earliest in the URL. Pins the natural-
7555 // order cascade so a future reorder of the per-byte arms
7556 // surfaces here — `"` is the most recent byte-class arm, so
7557 // the cascade-pin sweep extends to cover the immediately prior
7558 // `(` byte arm firing first when ordered ahead of `"` in the
7559 // value.
7560 let d = dep_with_fonte(DepSource::Git {
7561 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7562 tag: Some("v0.1.0".into()),
7563 rev: None,
7564 branch: None,
7565 });
7566 let err = d.validate().unwrap_err();
7567 let DepError::FonteRepoShape { reason, .. } = err else {
7568 panic!("expected FonteRepoShape, got other variant");
7569 };
7570 assert!(
7571 reason.contains("must not contain `(`"),
7572 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7573 byte appears first in value), got {reason:?}"
7574 );
7575 }
7576
7577 #[test]
7578 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7579 // The fail-before-pass-after pin for the canonical paste-from-
7580 // doc-strong-quoting footgun on `:repo`. An author copies a
7581 // security-conscious README quick-start snippet (`$ git clone
7582 // 'https://github.com/foo/bar'`) and keeps the surrounding
7583 // single-quote bytes when pasting into the `:repo` slot — the
7584 // doc strong-quotes the URL so the shell suppresses every form
7585 // of expansion on the bytes inside (no `$`, no backtick, no
7586 // glob, no word-splitting), but the typed slot is itself a
7587 // byte-level string parser, not a shell context, so the quote
7588 // bytes ride into the value verbatim. Until this arm landed the
7589 // `'` byte silently passed every prior `is_git_repo_url` arm
7590 // (no whitespace, no control chars, no non-ASCII, no `#`, no
7591 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7592 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7593 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7594 // set, peer with the `\"` 'delims' double-quote arm and the
7595 // partner ASCII shell-string-delimiter byte every byte-level
7596 // string parser sharing a value-shape with a shell argument
7597 // must refuse on a URL-shaped slot.
7598 let d = dep_with_fonte(DepSource::Git {
7599 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7600 tag: Some("v0.1.0".into()),
7601 rev: None,
7602 branch: None,
7603 });
7604 let err = d.validate().unwrap_err();
7605 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7606 panic!("expected FonteRepoShape, got other variant");
7607 };
7608 assert_eq!(nome, "caixa-teia");
7609 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7610 assert!(
7611 reason.contains("must not contain `'`"),
7612 "reason must surface the shell-single-quote arm, got {reason:?}"
7613 );
7614 assert!(
7615 reason.contains("single-quote") || reason.contains("strong-quote"),
7616 "reason must name the shell-single-quote / strong-quote rationale, \
7617 got {reason:?}"
7618 );
7619 }
7620
7621 #[test]
7622 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7623 // The symmetric English-typography pin: an author writes
7624 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7625 // from-prose idiom every README / commit-message / chat-thread
7626 // reference to a repo carries) expecting the substrate to
7627 // coerce it to a kebab-case slug — but the byte rides into the
7628 // lacre verbatim. Pinned separately from the wrapped-quote
7629 // shape so a future diagnostic-surface change that only checked
7630 // the boundary positions (only leading, only trailing, only
7631 // paired) surfaces here — the per-byte arm fires anywhere `'`
7632 // appears in the value.
7633 let d = dep_with_fonte(DepSource::Git {
7634 repo: "github:pleme-io/repo's-fork".into(),
7635 tag: Some("v0.1.0".into()),
7636 rev: None,
7637 branch: None,
7638 });
7639 let err = d.validate().unwrap_err();
7640 let DepError::FonteRepoShape { reason, .. } = err else {
7641 panic!("expected FonteRepoShape, got other variant");
7642 };
7643 assert!(
7644 reason.contains("must not contain `'`"),
7645 "reason must surface the shell-single-quote arm on the mid-string \
7646 apostrophe shape, got {reason:?}"
7647 );
7648 }
7649
7650 #[test]
7651 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7652 // Cascade pin: the fragment-`#` arm and the single-quote arm
7653 // are both per-byte arms inside the same `for &b in
7654 // s.as_bytes()` loop, so the byte that appears first in the
7655 // value's byte order wins. A `:repo
7656 // "https://github.com/p/x#readme'tail"` carries both `#` and
7657 // `'`; the `#` byte appears first, so the fragment-`#` arm
7658 // fires, surfacing the more self-locating diagnostic on the
7659 // byte the author pasted earliest in the URL.
7660 let d = dep_with_fonte(DepSource::Git {
7661 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7662 tag: Some("v0.1.0".into()),
7663 rev: None,
7664 branch: None,
7665 });
7666 let err = d.validate().unwrap_err();
7667 let DepError::FonteRepoShape { reason, .. } = err else {
7668 panic!("expected FonteRepoShape, got other variant");
7669 };
7670 assert!(
7671 reason.contains("must not contain `#`"),
7672 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7673 byte appears first in value), got {reason:?}"
7674 );
7675 }
7676
7677 #[test]
7678 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7679 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7680 // byte-class arm, 4267d8b) and the single-quote arm are both
7681 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7682 // so the byte that appears first in the value's byte order
7683 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7684 // `'`; the `"` byte appears first, so the double-quote arm
7685 // fires, surfacing the more self-locating diagnostic on the
7686 // byte the author pasted earliest in the URL. Pins the natural-
7687 // order cascade so a future reorder of the per-byte arms
7688 // surfaces here — `'` is the most recent byte-class arm, so
7689 // the cascade-pin sweep extends to cover the immediately prior
7690 // `"` byte arm firing first when ordered ahead of `'` in the
7691 // value.
7692 let d = dep_with_fonte(DepSource::Git {
7693 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7694 tag: Some("v0.1.0".into()),
7695 rev: None,
7696 branch: None,
7697 });
7698 let err = d.validate().unwrap_err();
7699 let DepError::FonteRepoShape { reason, .. } = err else {
7700 panic!("expected FonteRepoShape, got other variant");
7701 };
7702 assert!(
7703 reason.contains("must not contain `\"`"),
7704 "reason must surface the double-quote arm (fires before single-quote when `\"` \
7705 byte appears first in value), got {reason:?}"
7706 );
7707 }
7708
7709 #[test]
7710 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7711 // The fail-before-pass-after pin for the canonical paste-from-
7712 // shell-history footgun on `:repo`. An author copies a `git
7713 // clone <url>!sudo make install` one-liner from a README's
7714 // quick-start snippet, intending the trailing `!sudo` as a
7715 // shell-history-expansion reference but the typed slot is itself
7716 // a byte-level string parser, not a shell context, so the byte
7717 // rides into the value verbatim. Until this arm landed the `!`
7718 // byte silently passed every prior `is_git_repo_url` arm (no
7719 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7720 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7721 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
7722 // start with `-` or `:`); bash with the default `histexpand`
7723 // mode rewrites `!command` to the most recent history entry
7724 // beginning with `command`, the canonical RCE-class injection
7725 // vector when the byte rides into a shell argument.
7726 let d = dep_with_fonte(DepSource::Git {
7727 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
7728 tag: Some("v0.1.0".into()),
7729 rev: None,
7730 branch: None,
7731 });
7732 let err = d.validate().unwrap_err();
7733 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7734 panic!("expected FonteRepoShape, got other variant");
7735 };
7736 assert_eq!(nome, "caixa-teia");
7737 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
7738 assert!(
7739 reason.contains("must not contain `!`"),
7740 "reason must surface the shell-history-expansion arm, got {reason:?}"
7741 );
7742 assert!(
7743 reason.contains("history-expansion") || reason.contains("bang"),
7744 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
7745 );
7746 }
7747
7748 #[test]
7749 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
7750 // The symmetric `!!` repeat-prior-command pin: an author paste-
7751 // trims a `git clone <url>` retry idiom from shell history that
7752 // expands to the previous command via `!!`. Pinned separately
7753 // from the wrapped `!command` shape so a future diagnostic-
7754 // surface change that only checked the leading or paired-bang
7755 // position surfaces here — the per-byte arm fires anywhere `!`
7756 // appears in the value.
7757 let d = dep_with_fonte(DepSource::Git {
7758 repo: "github:pleme-io/caixa-teia!!".into(),
7759 tag: Some("v0.1.0".into()),
7760 rev: None,
7761 branch: None,
7762 });
7763 let err = d.validate().unwrap_err();
7764 let DepError::FonteRepoShape { reason, .. } = err else {
7765 panic!("expected FonteRepoShape, got other variant");
7766 };
7767 assert!(
7768 reason.contains("must not contain `!`"),
7769 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
7770 got {reason:?}"
7771 );
7772 }
7773
7774 #[test]
7775 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
7776 // Cascade pin: the fragment-`#` arm and the bang arm are both
7777 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7778 // so the byte that appears first in the value's byte order
7779 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
7780 // both `#` and `!`; the `#` byte appears first, so the
7781 // fragment-`#` arm fires, surfacing the more self-locating
7782 // diagnostic on the byte the author pasted earliest in the URL.
7783 let d = dep_with_fonte(DepSource::Git {
7784 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
7785 tag: Some("v0.1.0".into()),
7786 rev: None,
7787 branch: None,
7788 });
7789 let err = d.validate().unwrap_err();
7790 let DepError::FonteRepoShape { reason, .. } = err else {
7791 panic!("expected FonteRepoShape, got other variant");
7792 };
7793 assert!(
7794 reason.contains("must not contain `#`"),
7795 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
7796 appears first in value), got {reason:?}"
7797 );
7798 }
7799
7800 #[test]
7801 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
7802 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
7803 // byte-class arm, e7a109f) and the bang arm are both per-byte
7804 // arms inside the same `for &b in s.as_bytes()` loop, so the
7805 // byte that appears first in the value's byte order wins. A
7806 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
7807 // `'` byte appears first, so the single-quote arm fires,
7808 // surfacing the more self-locating diagnostic on the byte the
7809 // author pasted earliest in the URL. Pins the natural-order
7810 // cascade so a future reorder of the per-byte arms surfaces
7811 // here — `!` is the most recent byte-class arm, so the
7812 // cascade-pin sweep extends to cover the immediately prior `'`
7813 // byte arm firing first when ordered ahead of `!` in the value.
7814 let d = dep_with_fonte(DepSource::Git {
7815 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
7816 tag: Some("v0.1.0".into()),
7817 rev: None,
7818 branch: None,
7819 });
7820 let err = d.validate().unwrap_err();
7821 let DepError::FonteRepoShape { reason, .. } = err else {
7822 panic!("expected FonteRepoShape, got other variant");
7823 };
7824 assert!(
7825 reason.contains("must not contain `'`"),
7826 "reason must surface the single-quote arm (fires before bang when `'` byte \
7827 appears first in value), got {reason:?}"
7828 );
7829 }
7830
7831 #[test]
7832 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
7833 // The fail-before-pass-after pin for the canonical
7834 // list-separator-belongs-to-list-grammar footgun on `:repo`.
7835 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
7836 // one-liner from a multi-repo bootstrap doc, intending the
7837 // comma to separate multiple repo entries but the typed
7838 // `:repo` slot names *one* repo (the list-separator belongs
7839 // to the `:deps` list grammar, not to the value). Until this
7840 // arm landed the `,` byte silently passed every prior
7841 // `is_git_repo_url` arm (no whitespace, no control chars, no
7842 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7843 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
7844 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
7845 // `:`); the byte rode into the lacre's per-dep content-
7846 // address and the resolver's `git clone <repo>` subprocess
7847 // invocation, where no host's repo registry resolved the
7848 // comma-bearing slug.
7849 let d = dep_with_fonte(DepSource::Git {
7850 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
7851 tag: Some("v0.1.0".into()),
7852 rev: None,
7853 branch: None,
7854 });
7855 let err = d.validate().unwrap_err();
7856 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7857 panic!("expected FonteRepoShape, got other variant");
7858 };
7859 assert_eq!(nome, "caixa-teia");
7860 assert_eq!(
7861 repo,
7862 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
7863 );
7864 assert!(
7865 reason.contains("must not contain `,`"),
7866 "reason must surface the list-separator-comma arm, got {reason:?}"
7867 );
7868 assert!(
7869 reason.contains("list-separator") || reason.contains("sub-delims"),
7870 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
7871 got {reason:?}"
7872 );
7873 }
7874
7875 #[test]
7876 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
7877 // The symmetric trailing-`,` paste-from-prose pin: an author
7878 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
7879 // comma every README-prose list-of-projects sentence carries,
7880 // mistakenly retained when the slug is pasted mid-sentence)
7881 // expecting the substrate to coerce it to a kebab-case slug.
7882 // Pinned separately from the wrapped mid-token shape so a
7883 // future diagnostic-surface change that only checked the
7884 // leading or paired-comma position surfaces here — the
7885 // per-byte arm fires anywhere `,` appears in the value.
7886 let d = dep_with_fonte(DepSource::Git {
7887 repo: "github:pleme-io/caixa-feira,".into(),
7888 tag: Some("v0.1.0".into()),
7889 rev: None,
7890 branch: None,
7891 });
7892 let err = d.validate().unwrap_err();
7893 let DepError::FonteRepoShape { reason, .. } = err else {
7894 panic!("expected FonteRepoShape, got other variant");
7895 };
7896 assert!(
7897 reason.contains("must not contain `,`"),
7898 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
7899 got {reason:?}"
7900 );
7901 }
7902
7903 #[test]
7904 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
7905 // Cascade pin: the fragment-`#` arm and the comma arm are
7906 // both per-byte arms inside the same `for &b in s.as_bytes()`
7907 // loop, so the byte that appears first in the value's byte
7908 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
7909 // carries both `#` and `,`; the `#` byte appears first, so
7910 // the fragment-`#` arm fires, surfacing the more self-
7911 // locating diagnostic on the byte the author pasted earliest
7912 // in the URL.
7913 let d = dep_with_fonte(DepSource::Git {
7914 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
7915 tag: Some("v0.1.0".into()),
7916 rev: None,
7917 branch: None,
7918 });
7919 let err = d.validate().unwrap_err();
7920 let DepError::FonteRepoShape { reason, .. } = err else {
7921 panic!("expected FonteRepoShape, got other variant");
7922 };
7923 assert!(
7924 reason.contains("must not contain `#`"),
7925 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
7926 appears first in value), got {reason:?}"
7927 );
7928 }
7929
7930 #[test]
7931 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
7932 // Cascade pin: the bang-`!` arm (the immediate-predecessor
7933 // byte-class arm, 7d53c68) and the comma arm are both
7934 // per-byte arms inside the same `for &b in s.as_bytes()`
7935 // loop, so the byte that appears first in the value's byte
7936 // order wins. A `:repo "github:p/x!mid,tail"` carries both
7937 // `!` and `,`; the `!` byte appears first, so the bang arm
7938 // fires, surfacing the more self-locating diagnostic on the
7939 // byte the author pasted earliest in the URL. Pins the
7940 // natural-order cascade so a future reorder of the per-byte
7941 // arms surfaces here — `,` is the most recent byte-class
7942 // arm, so the cascade-pin sweep extends to cover the
7943 // immediately prior `!` byte arm firing first when ordered
7944 // ahead of `,` in the value.
7945 let d = dep_with_fonte(DepSource::Git {
7946 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
7947 tag: Some("v0.1.0".into()),
7948 rev: None,
7949 branch: None,
7950 });
7951 let err = d.validate().unwrap_err();
7952 let DepError::FonteRepoShape { reason, .. } = err else {
7953 panic!("expected FonteRepoShape, got other variant");
7954 };
7955 assert!(
7956 reason.contains("must not contain `!`"),
7957 "reason must surface the bang arm (fires before comma when `!` byte \
7958 appears first in value), got {reason:?}"
7959 );
7960 }
7961
7962 #[test]
7963 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
7964 // The fail-before-pass-after pin for the canonical
7965 // shell-env-var-assignment-belongs-to-shell-grammar footgun
7966 // on `:repo`. An author copies
7967 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
7968 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
7969 // git clone <url>`, etc. — the canonical
7970 // git-troubleshooting README idiom for a one-shot env-var
7971 // scoped to the `git clone` invocation) from a shell-prompt
7972 // one-liner, intending the `KEY=VALUE` prefix as a shell-
7973 // grammar env-var assignment but the typed `:repo` slot is
7974 // a value parser, not a shell context, so the bytes ride
7975 // into the value verbatim. Until this arm landed the `=`
7976 // byte silently passed every prior `is_git_repo_url` arm
7977 // (no whitespace, no control chars, no non-ASCII, no `#`,
7978 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
7979 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
7980 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
7981 // the byte rode into the lacre's per-dep content-address
7982 // and the resolver's `git clone <repo>` subprocess
7983 // invocation, where the upstream host's git porcelain
7984 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
7985 // path that no host's repo registry resolves.
7986 let d = dep_with_fonte(DepSource::Git {
7987 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
7988 tag: Some("v0.1.0".into()),
7989 rev: None,
7990 branch: None,
7991 });
7992 let err = d.validate().unwrap_err();
7993 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7994 panic!("expected FonteRepoShape, got other variant");
7995 };
7996 assert_eq!(nome, "caixa-teia");
7997 assert_eq!(
7998 repo,
7999 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8000 );
8001 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8002 // appears before the ` ` byte at position 21, so the `=`
8003 // arm fires (not the whitespace arm) — both arms guard
8004 // the slot, but the per-byte for-loop scans left-to-right
8005 // and the first matching byte wins.
8006 assert!(
8007 reason.contains("must not contain `=`"),
8008 "reason must surface the equals-`=` arm on the env-var-assignment \
8009 paste shape, got {reason:?}"
8010 );
8011 assert!(
8012 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8013 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8014 );
8015 }
8016
8017 #[test]
8018 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8019 // The symmetric paste-from-gitconfig pin: an author copies
8020 // `url=https://github.com/p/x` from `git config --get-all
8021 // remote.origin.url` output, a `.gitconfig` `[remote
8022 // "origin"] url = https://…` ini-stanza paste, or a
8023 // `git config remote.origin.url <value>` doc snippet,
8024 // intending the `url=` prefix as the ini-key but the typed
8025 // `:repo` slot is a URL value parser, not a gitconfig
8026 // grammar. With no leading whitespace and no earlier-arm
8027 // bytes in the value, the `=` arm itself fires (rather
8028 // than cascading to the whitespace arm as in the env-var
8029 // paste shape). Pinned separately so a future diagnostic-
8030 // surface change that only checked the whitespace-leading
8031 // shape surfaces here — the per-byte arm fires anywhere
8032 // `=` appears in the value.
8033 let d = dep_with_fonte(DepSource::Git {
8034 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8035 tag: Some("v0.1.0".into()),
8036 rev: None,
8037 branch: None,
8038 });
8039 let err = d.validate().unwrap_err();
8040 let DepError::FonteRepoShape { reason, .. } = err else {
8041 panic!("expected FonteRepoShape, got other variant");
8042 };
8043 assert!(
8044 reason.contains("must not contain `=`"),
8045 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8046 paste shape, got {reason:?}"
8047 );
8048 assert!(
8049 reason.contains("key-value-separator") || reason.contains("sub-delims"),
8050 "reason must name the key-value-separator / RFC-3986-sub-delims \
8051 rationale, got {reason:?}"
8052 );
8053 }
8054
8055 #[test]
8056 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8057 // Cascade pin: the fragment-`#` arm and the `=` arm are
8058 // both per-byte arms inside the same `for &b in s.as_bytes()`
8059 // loop, so the byte that appears first in the value's byte
8060 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8061 // carries both `#` and `=`; the `#` byte appears first, so
8062 // the fragment-`#` arm fires, surfacing the more self-
8063 // locating diagnostic on the byte the author pasted earliest
8064 // in the URL.
8065 let d = dep_with_fonte(DepSource::Git {
8066 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8067 tag: Some("v0.1.0".into()),
8068 rev: None,
8069 branch: None,
8070 });
8071 let err = d.validate().unwrap_err();
8072 let DepError::FonteRepoShape { reason, .. } = err else {
8073 panic!("expected FonteRepoShape, got other variant");
8074 };
8075 assert!(
8076 reason.contains("must not contain `#`"),
8077 "reason must surface the fragment-`#` arm (fires before equals when \
8078 `#` byte appears first in value), got {reason:?}"
8079 );
8080 }
8081
8082 #[test]
8083 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8084 // Cascade pin: the comma-`,` arm (the immediate-predecessor
8085 // byte-class arm, 775b80e) and the `=` arm are both per-byte
8086 // arms inside the same `for &b in s.as_bytes()` loop, so
8087 // the byte that appears first in the value's byte order
8088 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8089 // and `=`; the `,` byte appears first, so the comma arm
8090 // fires, surfacing the more self-locating diagnostic on
8091 // the byte the author pasted earliest in the URL. Pins the
8092 // natural-order cascade so a future reorder of the per-byte
8093 // arms surfaces here — `=` is the most recent byte-class
8094 // arm, so the cascade-pin sweep extends to cover the
8095 // immediately prior `,` byte arm firing first when ordered
8096 // ahead of `=` in the value.
8097 let d = dep_with_fonte(DepSource::Git {
8098 repo: "github:pleme-io/caixa-teia,mid=tail".into(),
8099 tag: Some("v0.1.0".into()),
8100 rev: None,
8101 branch: None,
8102 });
8103 let err = d.validate().unwrap_err();
8104 let DepError::FonteRepoShape { reason, .. } = err else {
8105 panic!("expected FonteRepoShape, got other variant");
8106 };
8107 assert!(
8108 reason.contains("must not contain `,`"),
8109 "reason must surface the comma arm (fires before equals when `,` byte \
8110 appears first in value), got {reason:?}"
8111 );
8112 }
8113
8114 #[test]
8115 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8116 // The fail-before-pass-after pin for the canonical paste-from-
8117 // browser-address-bar percent-encoded-space footgun on `:repo`.
8118 // An author copies `https://github.com/p/x%20test` from a
8119 // browser address bar (or a percent-encoded README hyperlink,
8120 // or a `curl --data-urlencode` shell-pipeline output)
8121 // intending `%20` as the URL encoding of a literal space; the
8122 // typed `:repo` slot already rejects the literal space byte
8123 // (the whitespace arm at the top of `is_git_repo_url`), so an
8124 // author trying to express "I really meant a space" reaches
8125 // for percent-encoding. Until this arm landed the `%` byte
8126 // silently passed every prior `is_git_repo_url` arm and rode
8127 // verbatim into the lacre's per-dep content-address — but
8128 // libcurl re-percent-encodes `%` to `%25` on the wire (since
8129 // `%` is reserved as the escape-sequence lead-in), so the
8130 // wire request becomes `https://github.com/p/x%2520test`, a
8131 // path the lacre's content-address never names. The classic
8132 // render-determinism violation on the encoding-mechanism axis
8133 // itself.
8134 let d = dep_with_fonte(DepSource::Git {
8135 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8136 tag: Some("v0.1.0".into()),
8137 rev: None,
8138 branch: None,
8139 });
8140 let err = d.validate().unwrap_err();
8141 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8142 panic!("expected FonteRepoShape, got other variant");
8143 };
8144 assert_eq!(nome, "caixa-teia");
8145 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8146 assert!(
8147 reason.contains("must not contain `%`"),
8148 "reason must surface the percent-`%` arm on the percent-encoded-space \
8149 paste shape, got {reason:?}"
8150 );
8151 assert!(
8152 reason.contains("percent-encoding") || reason.contains("%25"),
8153 "reason must name the percent-encoding / `%25` re-encoding rationale, \
8154 got {reason:?}"
8155 );
8156 }
8157
8158 #[test]
8159 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8160 // The symmetric over-encoded-path-separator pin: an author
8161 // writes `:repo "https://github.com/p%2Fx"` intending the
8162 // `%2F` as the URL encoding of `/` (the canonical
8163 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8164 // footgun every API client library and OAuth redirect-URI
8165 // documentation surfaces — the `/` is the URL-path-separator
8166 // and some templates percent-encode it to escape interpretation
8167 // as a path separator). The GitHub Smart-HTTP transport
8168 // resolves the URL's path-segment grammar before the
8169 // percent-decoding pass, so the value identifies a different
8170 // resource on the wire than the literal-`/` form the lacre's
8171 // content-address must agree with — two authors whose `:repo`
8172 // values differ only in their `/` vs `%2F` presence lock to
8173 // two distinct BLAKE3 closures for the byte-identical upstream
8174 // `git clone`. Pinned separately so a future diagnostic
8175 // surface that only catches the `%20` shape surfaces here too.
8176 let d = dep_with_fonte(DepSource::Git {
8177 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8178 tag: Some("v0.1.0".into()),
8179 rev: None,
8180 branch: None,
8181 });
8182 let err = d.validate().unwrap_err();
8183 let DepError::FonteRepoShape { reason, .. } = err else {
8184 panic!("expected FonteRepoShape, got other variant");
8185 };
8186 assert!(
8187 reason.contains("must not contain `%`"),
8188 "reason must surface the percent-`%` arm on the over-encoded-path \
8189 shape, got {reason:?}"
8190 );
8191 assert!(
8192 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8193 "reason must name the render-determinism / BLAKE3-closure rationale, \
8194 got {reason:?}"
8195 );
8196 }
8197
8198 #[test]
8199 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8200 // Cascade pin: the fragment-`#` arm and the `%` arm are both
8201 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8202 // so the byte that appears first in the value's byte order
8203 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8204 // both `#` and `%`; the `#` byte appears first, so the
8205 // fragment-`#` arm fires, surfacing the more self-locating
8206 // diagnostic on the byte the author pasted earliest in the URL.
8207 let d = dep_with_fonte(DepSource::Git {
8208 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8209 tag: Some("v0.1.0".into()),
8210 rev: None,
8211 branch: None,
8212 });
8213 let err = d.validate().unwrap_err();
8214 let DepError::FonteRepoShape { reason, .. } = err else {
8215 panic!("expected FonteRepoShape, got other variant");
8216 };
8217 assert!(
8218 reason.contains("must not contain `#`"),
8219 "reason must surface the fragment-`#` arm (fires before percent when \
8220 `#` byte appears first in value), got {reason:?}"
8221 );
8222 }
8223
8224 #[test]
8225 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8226 // Cascade pin: the equals-`=` arm (the immediate-predecessor
8227 // byte-class arm, acf99af) and the `%` arm are both per-byte
8228 // arms inside the same `for &b in s.as_bytes()` loop, so the
8229 // byte that appears first in the value's byte order wins.
8230 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8231 // the `=` byte appears first, so the equals arm fires,
8232 // surfacing the more self-locating diagnostic on the byte the
8233 // author pasted earliest in the URL. Pins the natural-order
8234 // cascade so a future reorder of the per-byte arms surfaces
8235 // here — `%` is the most recent byte-class arm, so the
8236 // cascade-pin sweep extends to cover the immediately prior
8237 // `=` byte arm firing first when ordered ahead of `%` in the
8238 // value.
8239 let d = dep_with_fonte(DepSource::Git {
8240 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8241 tag: Some("v0.1.0".into()),
8242 rev: None,
8243 branch: None,
8244 });
8245 let err = d.validate().unwrap_err();
8246 let DepError::FonteRepoShape { reason, .. } = err else {
8247 panic!("expected FonteRepoShape, got other variant");
8248 };
8249 assert!(
8250 reason.contains("must not contain `=`"),
8251 "reason must surface the equals arm (fires before percent when `=` byte \
8252 appears first in value), got {reason:?}"
8253 );
8254 }
8255
8256 #[test]
8257 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8258 // The fail-before-pass-after pin for the canonical paste-from-
8259 // shell-history footgun on `:repo`. An author copies a
8260 // `git clone <url>` line from their terminal followed by a
8261 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8262 // history shorthand (the `^old^new^` form re-runs the prior
8263 // history entry with the first `old` substituted by `new`,
8264 // bash's default behavior on interactive sessions with
8265 // `set -o histexpand`), forgetting to trim the trailing
8266 // `^...^...` shell-history fragment from the URL value. The
8267 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8268 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8269 // classes), the WHATWG URL spec's 'fragment percent-encode
8270 // set' maps `^` → `%5E` on the wire, so the byte rides
8271 // verbatim into the lacre's per-dep content-address but
8272 // libcurl re-encodes it to `%5E` at `git clone` time — the
8273 // classic render-determinism violation on the same axis the
8274 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8275 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8276 // `#` arms close.
8277 let d = dep_with_fonte(DepSource::Git {
8278 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8279 tag: Some("v0.1.0".into()),
8280 rev: None,
8281 branch: None,
8282 });
8283 let err = d.validate().unwrap_err();
8284 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8285 panic!("expected FonteRepoShape, got other variant");
8286 };
8287 assert_eq!(nome, "caixa-teia");
8288 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8289 assert!(
8290 reason.contains("must not contain `^`"),
8291 "reason must surface the caret-`^` arm on the paste-from-shell-history \
8292 shape, got {reason:?}"
8293 );
8294 assert!(
8295 reason.contains("history-substitution") || reason.contains("%5E"),
8296 "reason must name the shell-history-substitution / `%5E` wire-encoding \
8297 rationale, got {reason:?}"
8298 );
8299 }
8300
8301 #[test]
8302 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8303 // The symmetric paste-from-doc-grep-pipeline footgun: an
8304 // author writes `:repo "github:p/^archived"` after copying a
8305 // `grep '^archived'` regex-anchor / negation idiom from a
8306 // doc / README quick-listing snippet, expecting the substrate
8307 // to coerce it to a literal repo name. The byte rides
8308 // verbatim into the lacre's per-dep content-address and
8309 // diverges from the byte-identical literal `archived` form
8310 // every other author authored — the canonical render-
8311 // determinism violation pin on the second footgun shape the
8312 // caret-`^` arm closes.
8313 let d = dep_with_fonte(DepSource::Git {
8314 repo: "github:pleme-io/^archived".into(),
8315 tag: Some("v0.1.0".into()),
8316 rev: None,
8317 branch: None,
8318 });
8319 let err = d.validate().unwrap_err();
8320 let DepError::FonteRepoShape { reason, .. } = err else {
8321 panic!("expected FonteRepoShape, got other variant");
8322 };
8323 assert!(
8324 reason.contains("must not contain `^`"),
8325 "reason must surface the caret-`^` arm on the regex-anchor shape, \
8326 got {reason:?}"
8327 );
8328 assert!(
8329 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8330 "reason must name the render-determinism / BLAKE3-closure rationale, \
8331 got {reason:?}"
8332 );
8333 }
8334
8335 #[test]
8336 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8337 // Cascade pin: the `%` arm (the immediate-predecessor byte-
8338 // class arm, a323db8) and the `^` arm are both per-byte arms
8339 // inside the same `for &b in s.as_bytes()` loop, so the byte
8340 // that appears first in the value's byte order wins. A
8341 // `:repo "https://github.com/p/x%20mid^tail"` carries both
8342 // `%` and `^`; the `%` byte appears first, so the percent
8343 // arm fires, surfacing the more self-locating diagnostic on
8344 // the byte the author pasted earliest in the URL. Pins the
8345 // natural-order cascade so a future reorder of the per-byte
8346 // arms surfaces here — `^` is the most recent byte-class arm,
8347 // so the cascade-pin sweep extends to cover the immediately
8348 // prior `%` byte arm firing first when ordered ahead of `^`
8349 // in the value.
8350 let d = dep_with_fonte(DepSource::Git {
8351 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8352 tag: Some("v0.1.0".into()),
8353 rev: None,
8354 branch: None,
8355 });
8356 let err = d.validate().unwrap_err();
8357 let DepError::FonteRepoShape { reason, .. } = err else {
8358 panic!("expected FonteRepoShape, got other variant");
8359 };
8360 assert!(
8361 reason.contains("must not contain `%`"),
8362 "reason must surface the percent arm (fires before caret when `%` byte \
8363 appears first in value), got {reason:?}"
8364 );
8365 }
8366
8367 #[test]
8368 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8369 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8370 // (no `github:` prefix, no scheme). Every documented form
8371 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8372 // `file://`, or `git@host:path`); a bare `org/repo` is
8373 // ambiguous (`git clone` reads as a relative filesystem path
8374 // rather than the GitHub-shorthand expansion the author
8375 // probably intended) and the gate rejects the shape upstream.
8376 let d = dep_with_fonte(DepSource::Git {
8377 repo: "pleme-io/caixa-teia".into(),
8378 tag: Some("v0.1.0".into()),
8379 rev: None,
8380 branch: None,
8381 });
8382 let err = d.validate().unwrap_err();
8383 let DepError::FonteRepoShape { reason, .. } = err else {
8384 panic!("expected FonteRepoShape, got other variant");
8385 };
8386 assert!(
8387 reason.contains("must contain a `:`"),
8388 "reason must surface the missing-`:` arm, got {reason:?}"
8389 );
8390 assert!(
8391 reason.contains("github:"),
8392 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8393 );
8394 }
8395
8396 #[test]
8397 fn validate_rejects_git_fonte_with_repo_leading_colon() {
8398 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8399 // scheme that no git porcelain entry-point accepts. Pinned
8400 // separately from the missing-`:` arm because a value with a
8401 // leading `:` does technically contain a `:` separator; the
8402 // shape gate rejects on a dedicated arm so the diagnostic
8403 // names the specific footgun.
8404 let d = dep_with_fonte(DepSource::Git {
8405 repo: ":pleme-io/caixa-teia".into(),
8406 tag: Some("v0.1.0".into()),
8407 rev: None,
8408 branch: None,
8409 });
8410 let err = d.validate().unwrap_err();
8411 let DepError::FonteRepoShape { reason, .. } = err else {
8412 panic!("expected FonteRepoShape, got other variant");
8413 };
8414 assert!(
8415 reason.contains("must not start with `:`"),
8416 "reason must surface the leading-`:` arm, got {reason:?}"
8417 );
8418 }
8419
8420 #[test]
8421 fn validate_rejects_git_fonte_with_repo_too_long() {
8422 // The cap arm — a `:repo` value longer than
8423 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8424 // structurally untenable on every realistic landing site (the
8425 // resolver's `git clone` invocation, the future M4 CR
8426 // materializer's per-dep `repo:` axis); a value of that length
8427 // is almost certainly a paste-from-binary slug.
8428 let too_long = format!(
8429 "github:pleme-io/{}",
8430 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8431 );
8432 let d = dep_with_fonte(DepSource::Git {
8433 repo: too_long.clone(),
8434 tag: Some("v0.1.0".into()),
8435 rev: None,
8436 branch: None,
8437 });
8438 let err = d.validate().unwrap_err();
8439 let DepError::FonteRepoShape { reason, .. } = err else {
8440 panic!("expected FonteRepoShape, got other variant");
8441 };
8442 assert!(
8443 reason.contains("2048"),
8444 "reason must name the cap, got {reason:?}"
8445 );
8446 }
8447
8448 #[test]
8449 fn validate_accepts_canonical_git_fonte_repo_shapes() {
8450 // The positive-control sweep: every documented author shape on
8451 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8452 // must pass the value-shape gate. Pinned so a future tightening
8453 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8454 // here as a structural decision. Each form is exercised with the
8455 // same canonical `:tag` pin so only the `:repo` axis varies.
8456 for repo in [
8457 // The pleme-io registry-shorthand convention — `github:org/repo`.
8458 "github:pleme-io/caixa-teia",
8459 // Other host-aliased shorthands (the resolver's pluggable
8460 // host-prefix table).
8461 "gitlab:pleme-io/caixa-teia",
8462 "codeberg:pleme-io/caixa-teia",
8463 "sourcehut:~pleme-io/caixa-teia",
8464 // Full HTTPS URL with and without `.git` suffix.
8465 "https://github.com/pleme-io/caixa-teia",
8466 "https://github.com/pleme-io/caixa-teia.git",
8467 // HTTP (rare; dev / mirror).
8468 "http://example.com/pleme-io/caixa-teia.git",
8469 // SSH URL.
8470 "ssh://git@github.com/pleme-io/caixa-teia.git",
8471 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8472 // Scp-style SSH — the canonical `git@host:path` short form.
8473 "git@github.com:pleme-io/caixa-teia.git",
8474 "git@git.example.com:team/private.git",
8475 // Anonymous git protocol.
8476 "git://git.example.com/pleme-io/caixa-teia.git",
8477 // Local file URL (dev path).
8478 "file:///tmp/caixa-teia",
8479 ] {
8480 let d = dep_with_fonte(DepSource::Git {
8481 repo: repo.into(),
8482 tag: Some("v0.1.0".into()),
8483 rev: None,
8484 branch: None,
8485 });
8486 d.validate()
8487 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8488 }
8489 }
8490
8491 #[test]
8492 fn fonte_repo_empty_takes_precedence_over_shape() {
8493 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8494 // diagnostic; doesn't try to parse the URL shape) fires before
8495 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8496 // keeps its narrower error message. Mirrors
8497 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8498 // on the ordering layer.
8499 let d = dep_with_fonte(DepSource::Git {
8500 repo: String::new(),
8501 tag: Some("v0.1.0".into()),
8502 rev: None,
8503 branch: None,
8504 });
8505 let err = d.validate().unwrap_err();
8506 assert!(
8507 matches!(err, DepError::FonteRepoEmpty { .. }),
8508 "got {err:?}"
8509 );
8510 }
8511
8512 #[test]
8513 fn fonte_repo_shape_fires_before_pin_missing() {
8514 // Order pin: a malformed `:repo` value on a dep with no pin set
8515 // surfaces the `:repo` shape diagnostic (the more self-locating
8516 // axis — the `:repo` is the load-bearing identity of the source;
8517 // a missing pin is downstream from "do we even know the repo")
8518 // rather than collapsing onto the pin-missing diagnostic. The
8519 // shape gate runs inline before the pin enumeration in
8520 // `DepSource::validate`.
8521 let d = dep_with_fonte(DepSource::Git {
8522 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8523 tag: None,
8524 rev: None,
8525 branch: None,
8526 });
8527 let err = d.validate().unwrap_err();
8528 assert!(
8529 matches!(err, DepError::FonteRepoShape { .. }),
8530 "got {err:?}"
8531 );
8532 }
8533
8534 #[test]
8535 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8536 // The diagnostic-shape pin: the error names the offending
8537 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8538 // so the author can grep their caixa.lisp without re-running
8539 // the build. Mirrors the diagnostic-shape sweep on every prior
8540 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8541 let d = dep_with_fonte(DepSource::Git {
8542 repo: "pleme-io/caixa-teia".into(),
8543 tag: Some("v0.1.0".into()),
8544 rev: None,
8545 branch: None,
8546 });
8547 let err = d.validate().unwrap_err();
8548 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8549 panic!("expected FonteRepoShape, got other variant");
8550 };
8551 assert_eq!(nome, "caixa-teia");
8552 assert_eq!(repo, "pleme-io/caixa-teia");
8553 assert!(
8554 !reason.is_empty(),
8555 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8556 );
8557 }
8558
8559 #[test]
8560 fn validate_rejects_git_fonte_with_no_pin() {
8561 // The fail-before-pass-after pin for the canonical
8562 // `(:tipo git :repo "github:pleme-io/x")` shape with no
8563 // :tag/:rev/:branch — until this gate landed the resolver's
8564 // ResolveError::MissingPin surfaced at fetch time, far from the
8565 // source caixa.lisp. The new gate moves the check to validate
8566 // time and names the offending dep.
8567 let d = dep_with_fonte(DepSource::Git {
8568 repo: "github:pleme-io/caixa-teia".into(),
8569 tag: None,
8570 rev: None,
8571 branch: None,
8572 });
8573 let err = d.validate().unwrap_err();
8574 assert!(
8575 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8576 "got {err:?}"
8577 );
8578 }
8579
8580 #[test]
8581 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8582 // The canonical "pin drift" footgun: an author writes
8583 // `:tag "v1"` and later adds `:branch "main"` without removing
8584 // the :tag, and the resolver silently picks :tag (precedence
8585 // :rev > :tag > :branch). The :branch was dropped with no
8586 // diagnostic. The gate now rejects multi-pin shapes so the
8587 // author makes the precedence explicit at the source.
8588 let d = dep_with_fonte(DepSource::Git {
8589 repo: "github:pleme-io/caixa-teia".into(),
8590 tag: Some("v0.1.0".into()),
8591 rev: None,
8592 branch: Some("main".into()),
8593 });
8594 let err = d.validate().unwrap_err();
8595 let DepError::FontePinAmbiguous { nome, pins } = err else {
8596 panic!("expected FontePinAmbiguous");
8597 };
8598 assert_eq!(nome, "caixa-teia");
8599 assert!(pins.contains(":tag"));
8600 assert!(pins.contains(":branch"));
8601 assert!(!pins.contains(":rev"));
8602 }
8603
8604 #[test]
8605 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8606 // Sibling arm of the pin-drift footgun: :tag + :rev set
8607 // simultaneously. Pinned separately so a future relaxation
8608 // that only catches the (:tag, :branch) pair surfaces here.
8609 let d = dep_with_fonte(DepSource::Git {
8610 repo: "github:pleme-io/caixa-teia".into(),
8611 tag: Some("v0.1.0".into()),
8612 rev: Some("c0ffee".into()),
8613 branch: None,
8614 });
8615 let err = d.validate().unwrap_err();
8616 let DepError::FontePinAmbiguous { nome, pins } = err else {
8617 panic!("expected FontePinAmbiguous");
8618 };
8619 assert_eq!(nome, "caixa-teia");
8620 assert!(pins.contains(":tag"));
8621 assert!(pins.contains(":rev"));
8622 }
8623
8624 #[test]
8625 fn validate_rejects_git_fonte_with_all_three_pins() {
8626 // The maximal ambiguity case — every pin axis set. Pinned so a
8627 // future relaxation that only catches pairs surfaces here. The
8628 // diagnostic must enumerate every offending axis so the author
8629 // sees the full set, not just the first match.
8630 let d = dep_with_fonte(DepSource::Git {
8631 repo: "github:pleme-io/caixa-teia".into(),
8632 tag: Some("v0.1.0".into()),
8633 rev: Some("c0ffee".into()),
8634 branch: Some("main".into()),
8635 });
8636 let err = d.validate().unwrap_err();
8637 let DepError::FontePinAmbiguous { nome, pins } = err else {
8638 panic!("expected FontePinAmbiguous");
8639 };
8640 assert_eq!(nome, "caixa-teia");
8641 assert!(pins.contains(":tag"));
8642 assert!(pins.contains(":rev"));
8643 assert!(pins.contains(":branch"));
8644 }
8645
8646 #[test]
8647 fn validate_rejects_git_fonte_with_empty_tag_pin() {
8648 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8649 // inner string is empty. Distinct from FontePinMissing (where
8650 // every axis is None) — pinned separately so a future
8651 // tightening collapsing them surfaces here as a structural
8652 // decision.
8653 let d = dep_with_fonte(DepSource::Git {
8654 repo: "github:pleme-io/caixa-teia".into(),
8655 tag: Some(String::new()),
8656 rev: None,
8657 branch: None,
8658 });
8659 let err = d.validate().unwrap_err();
8660 let DepError::FontePinEmpty { nome, pin } = err else {
8661 panic!("expected FontePinEmpty");
8662 };
8663 assert_eq!(nome, "caixa-teia");
8664 assert_eq!(pin, ":tag");
8665 }
8666
8667 #[test]
8668 fn validate_rejects_git_fonte_with_empty_rev_pin() {
8669 // Sibling arm — the empty-pin diagnostic names which axis
8670 // carries the empty value, so the author's grep target is
8671 // unambiguous.
8672 let d = dep_with_fonte(DepSource::Git {
8673 repo: "github:pleme-io/caixa-teia".into(),
8674 tag: None,
8675 rev: Some(String::new()),
8676 branch: None,
8677 });
8678 let err = d.validate().unwrap_err();
8679 let DepError::FontePinEmpty { nome, pin } = err else {
8680 panic!("expected FontePinEmpty");
8681 };
8682 assert_eq!(nome, "caixa-teia");
8683 assert_eq!(pin, ":rev");
8684 }
8685
8686 #[test]
8687 fn validate_rejects_path_fonte_with_empty_caminho() {
8688 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8689 // until this gate landed the resolver's
8690 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8691 // fetch time — not actionable. The new gate moves the check to
8692 // validate time and names the offending dep.
8693 let d = dep_with_fonte(DepSource::Path {
8694 caminho: String::new(),
8695 });
8696 let err = d.validate().unwrap_err();
8697 assert!(
8698 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8699 "got {err:?}"
8700 );
8701 }
8702
8703 #[test]
8704 fn validate_rejects_path_fonte_with_absolute_caminho() {
8705 // The fail-before-pass-after pin for the absolute-`:caminho`
8706 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8707 // Until this gate landed an absolute `:caminho` silently
8708 // passed validate; the lacre pipeline embedded the
8709 // host-specific filesystem path verbatim in its
8710 // content-address (`conteudo: format!("path:{caminho}")`,
8711 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8712 // differed per machine — the build succeeded but two CI
8713 // runners with different `${HOME}` layouts emitted two
8714 // distinct lacres for the byte-identical caixa, silently
8715 // breaking the THEORY.md §V.2 render-determinism contract
8716 // far from the source caixa.lisp. The new gate moves the
8717 // check to validate time and names the offending dep +
8718 // caminho verbatim.
8719 let d = dep_with_fonte(DepSource::Path {
8720 caminho: "/home/me/work/caixa-teia".into(),
8721 });
8722 let err = d.validate().unwrap_err();
8723 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
8724 panic!("expected FonteCaminhoAbsolute, got other variant");
8725 };
8726 assert_eq!(nome, "caixa-teia");
8727 assert_eq!(caminho, "/home/me/work/caixa-teia");
8728 }
8729
8730 #[test]
8731 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
8732 // The canonical sibling-workspace dep form
8733 // (`:caminho "../caixa-teia"`) remains accepted. The
8734 // absolute-path gate above is specifically narrower than the
8735 // shared [`crate::render::is_sandboxed_relative_path`]
8736 // predicate (which additionally forbids `..` traversal): a
8737 // local-path dep's canonical author surface is the in-tree
8738 // sibling-workspace path, so a full sandboxed-relative-path
8739 // lift would structurally reject every legitimate path-fonte
8740 // dep. Pinned so a future tightening to the full predicate
8741 // surfaces here as a structural decision, not a silent break.
8742 let d = dep_with_fonte(DepSource::Path {
8743 caminho: "../caixa-teia".into(),
8744 });
8745 d.validate().unwrap();
8746 }
8747
8748 #[test]
8749 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
8750 // A multi-segment relative `:caminho`
8751 // (`"vendor/forks/caixa-teia"`) remains accepted — the
8752 // absolute-path gate brackets the host-layout-leaking shape
8753 // at the leading-`/` boundary only; every relative shape past
8754 // the empty arm continues to pass. Pinned alongside the
8755 // `..`-traversal positive control so a future tightening
8756 // surfaces the full set of legitimate relative forms here
8757 // rather than at a downstream consumer.
8758 let d = dep_with_fonte(DepSource::Path {
8759 caminho: "vendor/forks/caixa-teia".into(),
8760 });
8761 d.validate().unwrap();
8762 }
8763
8764 #[test]
8765 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
8766 // The fail-before-pass-after pin for the tilde-expansion
8767 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
8768 // Until this gate landed the b94fd83 absolute arm let `~/foo`
8769 // through (`Path::is_absolute` returns false on a leading `~`
8770 // — the tilde is a shell-expansion convention, not a POSIX
8771 // path component), so the lacre embedded the value verbatim
8772 // and the resolver folded it through `Path::join` without
8773 // expansion, looking for a literal `./~/work/caixa-teia`
8774 // subdirectory and failing at resolve time with a
8775 // `No such file or directory` error far from the source
8776 // caixa.lisp. The new gate moves the check to validate time
8777 // and names the offending dep + caminho verbatim.
8778 let d = dep_with_fonte(DepSource::Path {
8779 caminho: "~/work/caixa-teia".into(),
8780 });
8781 let err = d.validate().unwrap_err();
8782 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
8783 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
8784 };
8785 assert_eq!(nome, "caixa-teia");
8786 assert_eq!(caminho, "~/work/caixa-teia");
8787 }
8788
8789 #[test]
8790 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
8791 // The bare `~` form (canonical "I meant `$HOME` and forgot
8792 // the rest"): both the leading-tilde arm catches it and the
8793 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
8794 // sweeps through the same arm. Pinned both to ensure the
8795 // gate doesn't narrow to `~/` only.
8796 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
8797 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8798 let err = d.validate().unwrap_err();
8799 assert!(
8800 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8801 "{s:?} → {err:?}",
8802 );
8803 }
8804 }
8805
8806 #[test]
8807 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
8808 // The leading-`~` is the canonical shell-expansion footgun —
8809 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
8810 // backup-file-suffix idiom) is a legitimate POSIX path byte
8811 // with no shell-expansion semantic at the leading position.
8812 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
8813 // sweep that would break every legitimate-shape backup-file
8814 // path.
8815 let d = dep_with_fonte(DepSource::Path {
8816 caminho: "../foo~bar/caixa-teia".into(),
8817 });
8818 d.validate().unwrap();
8819 }
8820
8821 #[test]
8822 fn fonte_caminho_empty_fires_before_tilde_expansion() {
8823 // Cascade pin: the empty arm structurally precedes the
8824 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
8825 // pin establishes the precedence at the diagnostic-shape
8826 // level should a future codec round-trip ever produce a
8827 // probe-as-both value. Mirrors the peer
8828 // `fonte_repo_empty_fires_before_pin_missing` cascade
8829 // discipline.
8830 let d = dep_with_fonte(DepSource::Path {
8831 caminho: String::new(),
8832 });
8833 let err = d.validate().unwrap_err();
8834 assert!(
8835 matches!(err, DepError::FonteCaminhoEmpty { .. }),
8836 "got {err:?}",
8837 );
8838 }
8839
8840 #[test]
8841 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
8842 // Diagnostic-shape pin (peer with
8843 // `validate_rejects_path_fonte_with_absolute_caminho`'s
8844 // payload assertion): the error's Display surfaces both the
8845 // offending `:nome` and the offending `:caminho` verbatim
8846 // so a `feira lint` run can render the diagnostic without
8847 // re-parsing.
8848 let d = dep_with_fonte(DepSource::Path {
8849 caminho: "~alice/dev/caixa-teia".into(),
8850 });
8851 let rendered = d.validate().unwrap_err().to_string();
8852 assert!(
8853 rendered.contains("caixa-teia"),
8854 "diagnostic must name the offending dep: {rendered}",
8855 );
8856 assert!(
8857 rendered.contains("~alice/dev/caixa-teia"),
8858 "diagnostic must quote the offending caminho: {rendered}",
8859 );
8860 assert!(
8861 rendered.contains('~'),
8862 "diagnostic must reference the tilde footgun: {rendered}",
8863 );
8864 }
8865
8866 #[test]
8867 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
8868 // The fail-before-pass-after pin for the shell-variable-
8869 // expansion `:caminho` shape: `(:tipo path :caminho
8870 // "$HOME/work/caixa-teia")`. Until this gate landed the
8871 // b94fd83 absolute arm + the a5c248e tilde arm both let
8872 // `$HOME/foo` through (`Path::is_absolute` returns false on
8873 // a leading `$` — the `$` is a shell convention, not a POSIX
8874 // path component; `starts_with('~')` returns false too), so
8875 // the lacre embedded the value verbatim and the resolver
8876 // folded it through `Path::join` without `$`-expansion,
8877 // looking for a literal `./$HOME/work/caixa-teia`
8878 // subdirectory and failing at resolve time with a
8879 // `No such file or directory` error far from the source
8880 // caixa.lisp. The new gate moves the check to validate time
8881 // and names the offending dep + caminho verbatim.
8882 let d = dep_with_fonte(DepSource::Path {
8883 caminho: "$HOME/work/caixa-teia".into(),
8884 });
8885 let err = d.validate().unwrap_err();
8886 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
8887 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
8888 };
8889 assert_eq!(nome, "caixa-teia");
8890 assert_eq!(caminho, "$HOME/work/caixa-teia");
8891 }
8892
8893 #[test]
8894 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
8895 // Sweep over every leading-`$` shape: the `${VAR}`-braced
8896 // form (canonical "paste-from-CI-manifest" footgun every
8897 // GitHub Actions / GitLab CI / Drone manifest carries on
8898 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
8899 // canonical "I'm referencing a per-user config dir"),
8900 // and the bare `$` (canonical "I meant `$HOME` and forgot
8901 // the rest"). All shapes route through the same gate's
8902 // byte check. Pinned so the gate doesn't narrow to a
8903 // single shape (e.g. `$HOME/` only).
8904 for s in [
8905 "${HOME}/work/caixa-teia",
8906 "${WORKSPACE}/caixa-teia",
8907 "$XDG_CONFIG_HOME/caixa",
8908 "$",
8909 ] {
8910 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
8911 let err = d.validate().unwrap_err();
8912 assert!(
8913 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
8914 "{s:?} → {err:?}",
8915 );
8916 }
8917 }
8918
8919 #[test]
8920 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
8921 // The `$` byte is the canonical shell-variable-expansion /
8922 // command-substitution / arithmetic-expansion sentinel and
8923 // is rejected at *every* position on the `:caminho` axis: the
8924 // leading arm surfaces `FonteCaminhoVarExpansion`, the
8925 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
8926 // (6620f39). Pinned so a future arm doesn't narrow the gate
8927 // back to the leading position and re-open the paste-from-
8928 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
8929 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
8930 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
8931 // the lacre content-address (`path:{caminho}`,
8932 // caixa-resolver/src/resolve.rs:189).
8933 let d = dep_with_fonte(DepSource::Path {
8934 caminho: "../foo$bar/caixa-teia".into(),
8935 });
8936 let err = d.validate().unwrap_err();
8937 assert!(
8938 matches!(
8939 err,
8940 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
8941 ),
8942 "got {err:?}",
8943 );
8944 }
8945
8946 #[test]
8947 fn fonte_caminho_tilde_fires_before_var_expansion() {
8948 // Cascade pin: the tilde arm structurally precedes the var
8949 // arm (the bytes `~` and `$` don't overlap at the leading
8950 // position), but the pin establishes the precedence at the
8951 // diagnostic-shape level should a future codec round-trip
8952 // ever produce a probe-as-both value. Mirrors the peer
8953 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
8954 // discipline on the immediate-predecessor arm.
8955 let d = dep_with_fonte(DepSource::Path {
8956 caminho: "~/work/caixa-teia".into(),
8957 });
8958 let err = d.validate().unwrap_err();
8959 assert!(
8960 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
8961 "got {err:?}",
8962 );
8963 }
8964
8965 #[test]
8966 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
8967 // Diagnostic-shape pin (peer with
8968 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
8969 // payload assertion on the immediate-predecessor arm): the
8970 // error's Display surfaces both the offending `:nome` and
8971 // the offending `:caminho` verbatim plus the `$` footgun
8972 // character itself so a `feira lint` run can render the
8973 // diagnostic without re-parsing.
8974 let d = dep_with_fonte(DepSource::Path {
8975 caminho: "${WORKSPACE}/caixa-teia".into(),
8976 });
8977 let rendered = d.validate().unwrap_err().to_string();
8978 assert!(
8979 rendered.contains("caixa-teia"),
8980 "diagnostic must name the offending dep: {rendered}",
8981 );
8982 assert!(
8983 rendered.contains("${WORKSPACE}/caixa-teia"),
8984 "diagnostic must quote the offending caminho: {rendered}",
8985 );
8986 assert!(
8987 rendered.contains('$'),
8988 "diagnostic must reference the dollar footgun: {rendered}",
8989 );
8990 }
8991
8992 #[test]
8993 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
8994 // The fail-before-pass-after pin for the load-bearing NUL byte:
8995 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
8996 // routes the path through `CString::new` which fails with
8997 // `NulError`); until this gate landed a `:caminho
8998 // "../caixa\0teia"` silently passed validate, the lacre
8999 // pipeline embedded the value verbatim, and the failure
9000 // surfaced at the resolver's `Path::join` → `CString::new`
9001 // boundary with a non-self-locating `NulError` far from the
9002 // source caixa.lisp. The new gate moves the check to validate
9003 // time and names the offending dep + caminho + offending byte
9004 // verbatim.
9005 let d = dep_with_fonte(DepSource::Path {
9006 caminho: "../caixa\0teia".into(),
9007 });
9008 let err = d.validate().unwrap_err();
9009 let DepError::FonteCaminhoControlChar {
9010 nome,
9011 caminho,
9012 byte,
9013 } = err
9014 else {
9015 panic!("expected FonteCaminhoControlChar, got {err:?}");
9016 };
9017 assert_eq!(nome, "caixa-teia");
9018 assert_eq!(caminho, "../caixa\0teia");
9019 assert_eq!(byte, 0x00);
9020 }
9021
9022 #[test]
9023 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9024 // The canonical paste-from-multiline-doc footgun on `:caminho`
9025 // — author copies `"../caixa-teia\n"` (trailing newline) out
9026 // of a multi-line code-fence or, worse, a `:caminho
9027 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9028 // injection sibling on the path axis the `is_git_repo_url`
9029 // control-char arm already closes on `:repo`). Pinned
9030 // separately from the NUL arm so a future relaxation that
9031 // catches one but not the other surfaces here.
9032 let d = dep_with_fonte(DepSource::Path {
9033 caminho: "../caixa-teia\n".into(),
9034 });
9035 let err = d.validate().unwrap_err();
9036 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9037 panic!("expected FonteCaminhoControlChar, got {err:?}");
9038 };
9039 assert_eq!(byte, 0x0A);
9040 }
9041
9042 #[test]
9043 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9044 // The CRLF sibling of the LF arm — Windows-line-ending
9045 // paste-from-multiline-doc on a `\r\n`-terminated buffer
9046 // leaves a stray `\r` mid-string after the LF strip. Pinned
9047 // separately from the LF arm so a future relaxation that
9048 // only catches LF surfaces here.
9049 let d = dep_with_fonte(DepSource::Path {
9050 caminho: "../caixa-teia\r".into(),
9051 });
9052 let err = d.validate().unwrap_err();
9053 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9054 panic!("expected FonteCaminhoControlChar, got {err:?}");
9055 };
9056 assert_eq!(byte, 0x0D);
9057 }
9058
9059 #[test]
9060 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9061 // The canonical paste-from-aligned-table footgun — a `\t`
9062 // mid-`:caminho` is invisible in most editors but rides
9063 // through the lacre's content-address verbatim, so two
9064 // paste-from-distinct-tables (one editor strips tabs, one
9065 // preserves them) yield divergent lacres for the byte-
9066 // identical-looking caixa. Pinned separately from the
9067 // whitespace-shaped LF/CR arms so a future relaxation that
9068 // narrows to line-terminator-only surfaces here.
9069 let d = dep_with_fonte(DepSource::Path {
9070 caminho: "../caixa\tteia".into(),
9071 });
9072 let err = d.validate().unwrap_err();
9073 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9074 panic!("expected FonteCaminhoControlChar, got {err:?}");
9075 };
9076 assert_eq!(byte, 0x09);
9077 }
9078
9079 #[test]
9080 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9081 // The DEL byte (`0x7F`) closes the upper-end paste-from-
9082 // binary-blob footgun — the gate's contract is `b < 0x20 ||
9083 // b == 0x7F`, matching the `is_git_repo_url` /
9084 // `is_git_ref_name` predicates' control-char arms. Pinned
9085 // separately from the lower-range arms so a future narrowing
9086 // to `< 0x20` only surfaces here.
9087 let d = dep_with_fonte(DepSource::Path {
9088 caminho: "../caixa\x7fteia".into(),
9089 });
9090 let err = d.validate().unwrap_err();
9091 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9092 panic!("expected FonteCaminhoControlChar, got {err:?}");
9093 };
9094 assert_eq!(byte, 0x7F);
9095 }
9096
9097 #[test]
9098 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9099 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9100 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9101 // are opaque byte sequences and UTF-8 multi-byte sequences
9102 // are a legitimate filename shape (the `café-teia/foo` idiom).
9103 // Pinned so the gate doesn't widen to a full ASCII-only sweep
9104 // that would break every legitimate-shape UTF-8 path.
9105 let d = dep_with_fonte(DepSource::Path {
9106 caminho: "../café-teia/foo".into(),
9107 });
9108 d.validate().unwrap();
9109 }
9110
9111 #[test]
9112 fn fonte_caminho_var_fires_before_control_char() {
9113 // Cascade pin: the var-expansion arm structurally precedes the
9114 // control-char arm. A value like `"$\n"` probes positive on
9115 // both arms (`starts_with('$')` and contains LF), but the
9116 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9117 // wins so the author sees the more self-locating shell-
9118 // expansion arm first. Mirrors the
9119 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9120 // discipline on the immediate-predecessor arm.
9121 let d = dep_with_fonte(DepSource::Path {
9122 caminho: "$HOME\n".into(),
9123 });
9124 let err = d.validate().unwrap_err();
9125 assert!(
9126 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9127 "got {err:?}",
9128 );
9129 }
9130
9131 #[test]
9132 fn validate_rejects_path_fonte_with_leading_space_caminho() {
9133 // The fail-before-pass-after pin for the leading ASCII space
9134 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9135 // Until this gate landed the b94fd83 absolute arm + the a5c248e
9136 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9137 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9138 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9139 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9140 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9141 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9142 // are caught, but the most common whitespace `0x20` space is
9143 // not). The lacre embedded the value verbatim and the resolver
9144 // folded it through `Path::join` looking for a literal `./ ../
9145 // caixa-teia` subdirectory and failing at resolve time with a
9146 // non-self-locating `No such file or directory` error far from
9147 // the source caixa.lisp. The new gate moves the check to
9148 // validate time and names the offending dep + caminho verbatim.
9149 let d = dep_with_fonte(DepSource::Path {
9150 caminho: " ../caixa-teia".into(),
9151 });
9152 let err = d.validate().unwrap_err();
9153 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9154 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9155 };
9156 assert_eq!(nome, "caixa-teia");
9157 assert_eq!(caminho, " ../caixa-teia");
9158 }
9159
9160 #[test]
9161 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9162 // The aligned-doc paste footgun sweep: more than one leading
9163 // space (`" ../caixa-teia"` — the canonical "I selected the
9164 // aligned column from a four-`:fonte`-entry `:deps` block"
9165 // paste) routes through the same gate's `starts_with(' ')`
9166 // byte check. Pinned so the gate doesn't narrow to a
9167 // single-space prefix.
9168 let d = dep_with_fonte(DepSource::Path {
9169 caminho: " ../caixa-teia".into(),
9170 });
9171 let err = d.validate().unwrap_err();
9172 assert!(
9173 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9174 "got {err:?}",
9175 );
9176 }
9177
9178 #[test]
9179 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9180 // The leading-space is the canonical paste-from-aligned-doc
9181 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9182 // canonical "I have a directory with a space in its name"
9183 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9184 // legitimate path with no whitespace-leak semantic at the
9185 // non-leading position. Pinned so the gate doesn't widen to a
9186 // full no-space-anywhere sweep that would break every
9187 // legitimate-shape space-in-filename path.
9188 let d = dep_with_fonte(DepSource::Path {
9189 caminho: "../my dir/caixa-teia".into(),
9190 });
9191 d.validate().unwrap();
9192 }
9193
9194 #[test]
9195 fn fonte_caminho_var_fires_before_leading_whitespace() {
9196 // Cascade pin: the var-expansion arm structurally precedes the
9197 // leading-whitespace arm. A value like `"$ "` would probe positive
9198 // on var (`starts_with('$')`) but the leading-byte arms walk
9199 // left-to-right so the var arm fires on the leading `$` before
9200 // the leading-whitespace arm probes. Mirrors the
9201 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9202 // discipline on the immediate-predecessor arms.
9203 let d = dep_with_fonte(DepSource::Path {
9204 caminho: "$VAR".into(),
9205 });
9206 let err = d.validate().unwrap_err();
9207 assert!(
9208 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9209 "got {err:?}",
9210 );
9211 }
9212
9213 #[test]
9214 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9215 // Cascade pin: the leading-whitespace arm structurally precedes
9216 // the control-char arm. A value like `" ../foo\n"` probes
9217 // positive on both (starts with space AND contains LF), but
9218 // the narrower leading-byte diagnostic
9219 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9220 // more self-locating paste-from-aligned-doc arm first. Mirrors
9221 // the `fonte_caminho_var_fires_before_control_char` cascade
9222 // discipline on the immediate-predecessor arm.
9223 let d = dep_with_fonte(DepSource::Path {
9224 caminho: " ../foo\n".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_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9235 // Diagnostic-shape pin (peer with
9236 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9237 // payload assertion on the immediate-predecessor arm): the
9238 // error's Display surfaces both the offending `:nome` and the
9239 // offending `:caminho` verbatim, so a `feira lint` run can
9240 // render the diagnostic without re-parsing and the author can
9241 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9242 // one edit.
9243 let d = dep_with_fonte(DepSource::Path {
9244 caminho: " ../caixa-teia".into(),
9245 });
9246 let rendered = d.validate().unwrap_err().to_string();
9247 assert!(
9248 rendered.contains("caixa-teia"),
9249 "diagnostic must name the offending dep: {rendered}",
9250 );
9251 assert!(
9252 rendered.contains(" ../caixa-teia"),
9253 "diagnostic must quote the offending caminho: {rendered}",
9254 );
9255 assert!(
9256 rendered.contains("space"),
9257 "diagnostic must name the space footgun: {rendered}",
9258 );
9259 }
9260
9261 #[test]
9262 fn fonte_caminho_absolute_fires_before_control_char() {
9263 // Cascade pin on the sibling leading-byte arm: a leading `/`
9264 // value with embedded control byte (`"/etc/passwd\n"`) routes
9265 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9266 // — the host-layout-leak diagnostic is the load-bearing axis,
9267 // the control byte is the secondary observation. Same precedence
9268 // logic on every prior leading-byte arm.
9269 let d = dep_with_fonte(DepSource::Path {
9270 caminho: "/etc/passwd\n".into(),
9271 });
9272 let err = d.validate().unwrap_err();
9273 assert!(
9274 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9275 "got {err:?}",
9276 );
9277 }
9278
9279 #[test]
9280 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9281 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9282 // injection `:caminho` shape sweep. Until this gate landed
9283 // every prior leading-byte arm passed a leading-`-` value
9284 // through: `Path::is_absolute` returns false on `-` (the
9285 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9286 // `starts_with('$')` / `starts_with(' ')` all return false,
9287 // and `0x2D` sits outside the control-byte set. The lacre
9288 // embedded the value verbatim and the resolver folded it
9289 // through `Path::join` looking for a literal `./-rf` /
9290 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9291 // `Path::join` time is non-self-locating but harmless, while
9292 // the failure at every downstream `git -C {caminho}` /
9293 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9294 // is arbitrary-CLI-arg-injection because none of those
9295 // porcelains carry a `--` argument-list terminator between
9296 // the flag block and the path argument. The new arm moves the
9297 // rejection to `Caixa::from_lisp` boundary time and names
9298 // the offending dep + caminho verbatim.
9299 //
9300 // Sweep spans the canonical CLI-arg-injection shapes matching
9301 // the peer sweep on the sibling `is_git_ref_name` /
9302 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9303 // `find -rf` reinterpretation vector), `-C` (the `git -C`
9304 // change-directory-config-injection paste), long-flag
9305 // `--upload-pack=cat /etc/passwd` (the canonical
9306 // arbitrary-command-execution vector on every git porcelain
9307 // entry point), git-config-injection `--config=core.merge=ours`,
9308 // and the degenerate single-byte `-` value.
9309 for caminho in [
9310 "-rf",
9311 "-C",
9312 "--upload-pack=cat /etc/passwd",
9313 "--config=core.merge=ours",
9314 "-",
9315 ] {
9316 let d = dep_with_fonte(DepSource::Path {
9317 caminho: caminho.into(),
9318 });
9319 let err = d.validate().unwrap_err();
9320 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9321 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9322 };
9323 assert_eq!(nome, "caixa-teia");
9324 assert_eq!(got, caminho);
9325 }
9326 }
9327
9328 #[test]
9329 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9330 // The leading-`-` is the canonical CLI-arg-injection footgun
9331 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9332 // canonical kebab-separator-between-alphanumeric-segments
9333 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9334 // — a mid-path segment starting with `-`, still a legitimate
9335 // POSIX filename byte at that non-leading position because the
9336 // subprocess reads the whole `{caminho}` value as one positional
9337 // argument, so only the very first byte of the composite path
9338 // string is at the CLI-arg-injection boundary) is a legitimate
9339 // path with no CLI-flag-reinterpretation semantic at the non-
9340 // leading position of the top-level value. Pinned so the gate
9341 // doesn't widen to a full no-`-`-anywhere sweep that would
9342 // break every legitimate-shape kebab-in-filename path (i.e.
9343 // essentially every sibling-workspace caixa dep).
9344 for caminho in [
9345 "../caixa-teia",
9346 "../caixa-teia/-hidden",
9347 "./my-lib",
9348 "../foo-bar/baz",
9349 ] {
9350 let d = dep_with_fonte(DepSource::Path {
9351 caminho: caminho.into(),
9352 });
9353 d.validate()
9354 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9355 }
9356 }
9357
9358 #[test]
9359 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9360 // Cascade pin: the leading-whitespace arm structurally precedes
9361 // the leading-hyphen arm. A value like `" -rf"` probes positive
9362 // on both (leading space AND, one byte in, a `-` — though the
9363 // leading-hyphen arm probes only the very first byte so it
9364 // wouldn't fire on this value; the pin instead documents the
9365 // arm order on the more common "leading space then a hyphen"
9366 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9367 // The narrower leading-space diagnostic (the paste-from-aligned-
9368 // doc footgun) wins so the author sees the more self-locating
9369 // whitespace arm first. Mirrors the
9370 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9371 // discipline on the immediate-predecessor arm.
9372 let d = dep_with_fonte(DepSource::Path {
9373 caminho: " -rf".into(),
9374 });
9375 let err = d.validate().unwrap_err();
9376 assert!(
9377 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9378 "got {err:?}",
9379 );
9380 }
9381
9382 #[test]
9383 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9384 // Cascade pin: the leading-hyphen arm structurally precedes
9385 // the control-char arm. A value like `"-rf\n"` probes positive
9386 // on both (starts with `-` AND contains LF), but the narrower
9387 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9388 // the author sees the more self-locating CLI-arg-injection arm
9389 // first. Mirrors the
9390 // `fonte_caminho_leading_whitespace_fires_before_control_char`
9391 // cascade discipline on the immediate-predecessor arm.
9392 let d = dep_with_fonte(DepSource::Path {
9393 caminho: "-rf\n".into(),
9394 });
9395 let err = d.validate().unwrap_err();
9396 assert!(
9397 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9398 "got {err:?}",
9399 );
9400 }
9401
9402 #[test]
9403 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9404 // Diagnostic-shape pin (peer with
9405 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9406 // payload assertion on the immediate-predecessor arm): the
9407 // error's Display surfaces both the offending `:nome` and the
9408 // offending `:caminho` verbatim plus the CLI-argument-injection
9409 // vocabulary, so a `feira lint` run can render the diagnostic
9410 // without re-parsing and the author can grep their caixa.lisp
9411 // for `:caminho "<value>"` and fix it in one edit.
9412 let d = dep_with_fonte(DepSource::Path {
9413 caminho: "--upload-pack=cat /etc/passwd".into(),
9414 });
9415 let rendered = d.validate().unwrap_err().to_string();
9416 assert!(
9417 rendered.contains("caixa-teia"),
9418 "diagnostic must name the offending dep: {rendered}",
9419 );
9420 assert!(
9421 rendered.contains("--upload-pack=cat /etc/passwd"),
9422 "diagnostic must quote the offending caminho: {rendered}",
9423 );
9424 assert!(
9425 rendered.contains("CLI-argument-injection"),
9426 "diagnostic must name the CLI-argument-injection vector: {rendered}",
9427 );
9428 assert!(
9429 rendered.contains("`-`"),
9430 "diagnostic must name the offending byte: {rendered}",
9431 );
9432 }
9433
9434 #[test]
9435 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9436 // Diagnostic-shape pin (peer with
9437 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9438 // payload assertion on the immediate-predecessor arm): the
9439 // error's Display surfaces the offending `:nome`, the
9440 // offending `:caminho` verbatim, and the offending byte in
9441 // hex form (`0x09` for tab) so a `feira lint` run can render
9442 // the diagnostic without re-parsing.
9443 let d = dep_with_fonte(DepSource::Path {
9444 caminho: "../caixa\tteia".into(),
9445 });
9446 let rendered = d.validate().unwrap_err().to_string();
9447 assert!(
9448 rendered.contains("caixa-teia"),
9449 "diagnostic must name the offending dep: {rendered}",
9450 );
9451 assert!(
9452 rendered.contains("../caixa\tteia"),
9453 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9454 );
9455 assert!(
9456 rendered.contains("0x09"),
9457 "diagnostic must name the offending byte in hex: {rendered:?}",
9458 );
9459 }
9460
9461 #[test]
9462 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9463 // The fail-before-pass-after pin for the canonical Windows-
9464 // path-separator paste footgun: an author who pastes a path
9465 // from Windows-Explorer's `Copy as path`, PowerShell's
9466 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9467 // produces `..\caixa-teia`-shape values that silently passed
9468 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9469 // false; `\` is neither a leading-byte sentinel nor a
9470 // control byte). On POSIX resolvers the value rides through
9471 // `Path::join` as a literal directory name and fails at
9472 // resolve time with `No such file or directory`; on Windows
9473 // resolvers the value resolves to the parent's sibling — two
9474 // distinct directories for the byte-identical caixa.lisp.
9475 // The new arm moves the rejection to validate time and names
9476 // the offending dep + caminho verbatim.
9477 let d = dep_with_fonte(DepSource::Path {
9478 caminho: "..\\caixa-teia".into(),
9479 });
9480 let err = d.validate().unwrap_err();
9481 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9482 panic!("expected FonteCaminhoBackslash, got {err:?}");
9483 };
9484 assert_eq!(nome, "caixa-teia");
9485 assert_eq!(caminho, "..\\caixa-teia");
9486 }
9487
9488 #[test]
9489 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9490 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9491 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9492 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9493 // false (POSIX absolute paths start with `/`, drive letters
9494 // are not a POSIX concept), so the b94fd83 absolute arm
9495 // doesn't fire; the value contains `\` bytes that this arm
9496 // now catches with the more self-locating Windows-path-
9497 // separator diagnostic. Pinned separately from the bare
9498 // `..\caixa-teia` shape so a future arm that targets only
9499 // leading-`..\` doesn't regress the drive-letter coverage.
9500 let d = dep_with_fonte(DepSource::Path {
9501 caminho: "C:\\work\\caixa-teia".into(),
9502 });
9503 let err = d.validate().unwrap_err();
9504 assert!(
9505 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9506 "got {err:?}",
9507 );
9508 }
9509
9510 #[test]
9511 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9512 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9513 // PowerShell tab-completion-on-a-directory append). Pinned
9514 // separately from the embedded-`\` shape so the gate's
9515 // contract is "any `\` anywhere", not "any `\` not at end".
9516 let d = dep_with_fonte(DepSource::Path {
9517 caminho: "..\\caixa-teia\\".into(),
9518 });
9519 let err = d.validate().unwrap_err();
9520 assert!(
9521 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9522 "got {err:?}",
9523 );
9524 }
9525
9526 #[test]
9527 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9528 // The positive-control pin: the gate targets `\` only,
9529 // never `/`. The canonical relative POSIX path
9530 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9531 // so legitimate nested-directory deps aren't broken. Pinned
9532 // so the gate doesn't accidentally widen to a "no path
9533 // separators at all" sweep.
9534 let d = dep_with_fonte(DepSource::Path {
9535 caminho: "../caixa-teia/foo/bar".into(),
9536 });
9537 d.validate().unwrap();
9538 }
9539
9540 #[test]
9541 fn fonte_caminho_control_char_fires_before_backslash() {
9542 // Cascade pin: the control-char arm structurally precedes the
9543 // backslash arm. A value like `"..\caixa\0teia"` probes
9544 // positive on both (`\` byte + NUL byte), but the control-
9545 // char diagnostic wins so the author sees the more self-
9546 // locating POSIX-syscall-rejected-byte diagnostic first
9547 // (NUL outright breaks `CString::new` at every `std::fs`
9548 // syscall boundary; the `\` divergence is the cross-OS-
9549 // separator axis). Mirrors the
9550 // `fonte_caminho_var_fires_before_control_char` cascade
9551 // discipline on the immediate-predecessor arm.
9552 let d = dep_with_fonte(DepSource::Path {
9553 caminho: "..\\caixa\0teia".into(),
9554 });
9555 let err = d.validate().unwrap_err();
9556 assert!(
9557 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9558 "got {err:?}",
9559 );
9560 }
9561
9562 #[test]
9563 fn fonte_caminho_absolute_fires_before_backslash() {
9564 // Cascade pin on the load-bearing leading-byte arm: a leading
9565 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9566 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9567 // — the host-layout-leak diagnostic is the load-bearing
9568 // axis, the `\` byte is the secondary observation. Same
9569 // precedence logic as every prior leading-byte arm.
9570 let d = dep_with_fonte(DepSource::Path {
9571 caminho: "/etc/passwd\\foo".into(),
9572 });
9573 let err = d.validate().unwrap_err();
9574 assert!(
9575 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9576 "got {err:?}",
9577 );
9578 }
9579
9580 #[test]
9581 fn fonte_caminho_var_fires_before_backslash() {
9582 // Cascade pin on the var-expansion arm: a leading-`$` value
9583 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9584 // PowerShell-env-var paste-from-CI-manifest footgun) routes
9585 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9586 // The shell-expansion diagnostic is the more self-locating
9587 // axis since both the leading `$` and the embedded `\`
9588 // are Windows-shell artifacts but the `$` is the root-cause
9589 // surface (an author who removes the `$` is likely to leave
9590 // the `\` too).
9591 let d = dep_with_fonte(DepSource::Path {
9592 caminho: "$WORKSPACE\\caixa-teia".into(),
9593 });
9594 let err = d.validate().unwrap_err();
9595 assert!(
9596 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9597 "got {err:?}",
9598 );
9599 }
9600
9601 #[test]
9602 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9603 // Diagnostic-shape pin (peer with the prior
9604 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9605 // on every preceding arm): the error's Display surfaces the
9606 // offending `:nome` and the offending `:caminho` verbatim
9607 // so a `feira lint` run can render the diagnostic without
9608 // re-parsing.
9609 let d = dep_with_fonte(DepSource::Path {
9610 caminho: "..\\caixa-teia".into(),
9611 });
9612 let rendered = d.validate().unwrap_err().to_string();
9613 assert!(
9614 rendered.contains("caixa-teia"),
9615 "diagnostic must name the offending dep: {rendered}",
9616 );
9617 assert!(
9618 rendered.contains("..\\caixa-teia"),
9619 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9620 );
9621 assert!(
9622 rendered.contains('\\'),
9623 "diagnostic must reference the backslash footgun: {rendered:?}",
9624 );
9625 }
9626
9627 #[test]
9628 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9629 // The fail-before-pass-after pin for the canonical trailing-`/`
9630 // paste footgun: an author who shell-tab-completes a sibling
9631 // directory (every interactive shell — bash/zsh/fish/nushell —
9632 // appends `/` on tab-completing a directory) produces
9633 // `"../caixa-teia/"`-shape values that silently passed every
9634 // prior arm (the leading byte is `.`, no control bytes, no
9635 // backslash). `Path::join` resolves both shapes to the same
9636 // directory at the resolver, but the lacre embeds the value
9637 // verbatim and the BLAKE3 closures diverge across two
9638 // workstations whose authors differ only in tab-completion
9639 // habits.
9640 let d = dep_with_fonte(DepSource::Path {
9641 caminho: "../caixa-teia/".into(),
9642 });
9643 let err = d.validate().unwrap_err();
9644 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9645 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9646 };
9647 assert_eq!(nome, "caixa-teia");
9648 assert_eq!(caminho, "../caixa-teia/");
9649 }
9650
9651 #[test]
9652 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9653 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9654 // directory and tab-completed it" footgun). Pinned separately
9655 // from the canonical `"../caixa-teia/"` shape so the gate's
9656 // contract is "any trailing `/`", not "trailing `/` after a leaf
9657 // name".
9658 let d = dep_with_fonte(DepSource::Path {
9659 caminho: "./".into(),
9660 });
9661 let err = d.validate().unwrap_err();
9662 assert!(
9663 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9664 "got {err:?}",
9665 );
9666 }
9667
9668 #[test]
9669 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9670 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9671 // that double-templated `${VAR}/` over an already-`/`-suffixed
9672 // path" footgun). The gate fires on the last byte being `/`
9673 // regardless of how many `/` precede it; the arm contract is
9674 // "the value ends with `/`", structurally.
9675 let d = dep_with_fonte(DepSource::Path {
9676 caminho: "../caixa-teia//".into(),
9677 });
9678 let err = d.validate().unwrap_err();
9679 assert!(
9680 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9681 "got {err:?}",
9682 );
9683 }
9684
9685 #[test]
9686 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9687 // The `"../"` shape (the canonical "I want the parent" tab-
9688 // completion footgun on a bare `..` path). Pinned separately so
9689 // the gate doesn't accidentally narrow to "trailing `/` only on
9690 // multi-segment paths".
9691 let d = dep_with_fonte(DepSource::Path {
9692 caminho: "../".into(),
9693 });
9694 let err = d.validate().unwrap_err();
9695 assert!(
9696 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9697 "got {err:?}",
9698 );
9699 }
9700
9701 #[test]
9702 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9703 // The positive-control pin: the gate targets the trailing byte
9704 // only, never internal `/` separators. The canonical nested
9705 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9706 // to validate cleanly so legitimate deeply-nested deps aren't
9707 // broken. Pinned so the gate doesn't accidentally widen to a
9708 // "no `/` separators anywhere" sweep that would defeat the
9709 // entire path-fonte author surface.
9710 let d = dep_with_fonte(DepSource::Path {
9711 caminho: "../caixa-teia/foo/bar".into(),
9712 });
9713 d.validate().unwrap();
9714 }
9715
9716 #[test]
9717 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9718 // The positive-control pin on the degenerate single-`.` shape
9719 // (the canonical "the caixa.lisp's own directory" idiom). The
9720 // gate fires on the trailing byte being `/`, not on the path
9721 // being short, so `"."` (one byte, not `/`) must continue to
9722 // validate cleanly.
9723 let d = dep_with_fonte(DepSource::Path {
9724 caminho: ".".into(),
9725 });
9726 d.validate().unwrap();
9727 }
9728
9729 #[test]
9730 fn fonte_caminho_control_char_fires_before_trailing_slash() {
9731 // Cascade pin: the control-char arm structurally precedes the
9732 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
9733 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
9734 // (control bytes are the paste-from-multiline-doc footgun the
9735 // d624c8d arm already closes). Mirrors the
9736 // `fonte_caminho_control_char_fires_before_backslash` cascade
9737 // discipline on the immediate-predecessor arm.
9738 let d = dep_with_fonte(DepSource::Path {
9739 caminho: "../foo\n/".into(),
9740 });
9741 let err = d.validate().unwrap_err();
9742 assert!(
9743 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9744 "got {err:?}",
9745 );
9746 }
9747
9748 #[test]
9749 fn fonte_caminho_backslash_fires_before_trailing_slash() {
9750 // Cascade pin on the backslash arm: a value like `"..\foo/"`
9751 // ends in `/` but the embedded `\` is the load-bearing
9752 // diagnostic (the cross-host-OS-separator divergence vector
9753 // the 3a4e1d7 arm closes). Same precedence logic as the prior
9754 // narrower-diagnostic-first cascade.
9755 let d = dep_with_fonte(DepSource::Path {
9756 caminho: "..\\caixa-teia/".into(),
9757 });
9758 let err = d.validate().unwrap_err();
9759 assert!(
9760 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9761 "got {err:?}",
9762 );
9763 }
9764
9765 #[test]
9766 fn fonte_caminho_absolute_fires_before_trailing_slash() {
9767 // Cascade pin on the load-bearing leading-byte arm: a leading
9768 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
9769 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
9770 // — the host-layout-leak diagnostic is the load-bearing axis,
9771 // the trailing `/` is the secondary observation. Same
9772 // precedence logic as every prior leading-byte arm.
9773 let d = dep_with_fonte(DepSource::Path {
9774 caminho: "/etc/passwd/".into(),
9775 });
9776 let err = d.validate().unwrap_err();
9777 assert!(
9778 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9779 "got {err:?}",
9780 );
9781 }
9782
9783 #[test]
9784 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
9785 // Diagnostic-shape pin (peer with the prior
9786 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
9787 // every preceding arm): the error's Display surfaces the
9788 // offending `:nome` and the offending `:caminho` verbatim so a
9789 // `feira lint` run can render the diagnostic without re-parsing.
9790 let d = dep_with_fonte(DepSource::Path {
9791 caminho: "../caixa-teia/".into(),
9792 });
9793 let rendered = d.validate().unwrap_err().to_string();
9794 assert!(
9795 rendered.contains("caixa-teia"),
9796 "diagnostic must name the offending dep: {rendered}",
9797 );
9798 assert!(
9799 rendered.contains("../caixa-teia/"),
9800 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9801 );
9802 assert!(
9803 rendered.contains("trailing"),
9804 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
9805 );
9806 }
9807
9808 // -- :caminho shell-redirection metacharacter arm -----------------------
9809
9810 #[test]
9811 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
9812 // The fail-before-pass-after pin for the canonical output-redirection
9813 // paste footgun: an author copies a shell pipeline tail
9814 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
9815 // line including the `> build.log` redirect" idiom) and silently
9816 // passed every prior arm (`Path::is_absolute` false on `..`, no
9817 // control bytes, no backslash, doesn't end in `/`). The lacre
9818 // embedded the value verbatim, the resolver folded it through
9819 // `Path::join` looking for a literal `./../caixa-teia>build.log`
9820 // subdirectory, and the failure surfaced at resolve time with a
9821 // non-self-locating `No such file or directory` error. The new arm
9822 // moves the rejection to validate time and names the offending dep
9823 // + caminho + byte verbatim.
9824 let d = dep_with_fonte(DepSource::Path {
9825 caminho: "../caixa-teia>build.log".into(),
9826 });
9827 let err = d.validate().unwrap_err();
9828 let DepError::FonteCaminhoShellRedirection {
9829 nome,
9830 caminho,
9831 byte,
9832 } = err
9833 else {
9834 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9835 };
9836 assert_eq!(nome, "caixa-teia");
9837 assert_eq!(caminho, "../caixa-teia>build.log");
9838 assert_eq!(byte, b'>');
9839 }
9840
9841 #[test]
9842 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
9843 // The symmetric input-redirection paste shape
9844 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
9845 // `command < input.lisp` line from a tatara-lisp REPL log"
9846 // idiom). Pinned separately from the `>` shape so the gate's
9847 // contract is "any `<` or `>` anywhere", not single-byte coverage.
9848 let d = dep_with_fonte(DepSource::Path {
9849 caminho: "../caixa-teia<input.lisp".into(),
9850 });
9851 let err = d.validate().unwrap_err();
9852 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
9853 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
9854 };
9855 assert_eq!(byte, b'<');
9856 }
9857
9858 #[test]
9859 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
9860 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
9861 // "I forgot the source side of the redirect" idiom). Pinned
9862 // separately from the embedded-byte shapes so the gate covers
9863 // every position, not only mid-path.
9864 let d = dep_with_fonte(DepSource::Path {
9865 caminho: ">../caixa-teia".into(),
9866 });
9867 let err = d.validate().unwrap_err();
9868 assert!(
9869 matches!(
9870 err,
9871 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9872 ),
9873 "got {err:?}",
9874 );
9875 }
9876
9877 #[test]
9878 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
9879 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
9880 // the canonical "I copied a `>>` append redirect" idiom). The arm
9881 // fires on the first `>` encountered; pinned so a future arm that
9882 // tries to distinguish `>` from `>>` doesn't break the broader
9883 // contract.
9884 let d = dep_with_fonte(DepSource::Path {
9885 caminho: "../caixa-teia>>build.log".into(),
9886 });
9887 let err = d.validate().unwrap_err();
9888 assert!(
9889 matches!(
9890 err,
9891 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9892 ),
9893 "got {err:?}",
9894 );
9895 }
9896
9897 #[test]
9898 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
9899 // The positive-control pin: the gate targets only `<` / `>`,
9900 // never adjacent printable ASCII or POSIX-valid bytes. The
9901 // canonical relative POSIX path (`"../caixa-teia"`) and a
9902 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
9903 // continue to validate cleanly so the gate doesn't widen to a
9904 // "no printable punctuation anywhere" sweep that would defeat
9905 // the entire path-fonte author surface.
9906 let d = dep_with_fonte(DepSource::Path {
9907 caminho: "../caixa-teia/foo/bar".into(),
9908 });
9909 d.validate().unwrap();
9910 }
9911
9912 #[test]
9913 fn fonte_caminho_backslash_fires_before_shell_redirection() {
9914 // Cascade pin on the immediate-predecessor arm: a value carrying
9915 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
9916 // canonical "I pasted a Windows-shell command with output
9917 // redirect" footgun) routes through `FonteCaminhoBackslash` not
9918 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
9919 // divergence is the load-bearing axis (an author who removes
9920 // the `\` is the root-cause edit; the `>` falls away in the
9921 // same edit since it's downstream of the Windows-shell
9922 // convention).
9923 let d = dep_with_fonte(DepSource::Path {
9924 caminho: "..\\caixa-teia>build.log".into(),
9925 });
9926 let err = d.validate().unwrap_err();
9927 assert!(
9928 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9929 "got {err:?}",
9930 );
9931 }
9932
9933 #[test]
9934 fn fonte_caminho_control_char_fires_before_shell_redirection() {
9935 // Cascade pin on the embedded-control-byte arm: a value carrying
9936 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
9937 // canonical paste-from-multiline-doc footgun where a newline
9938 // landed mid-caminho) routes through `FonteCaminhoControlChar`
9939 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
9940 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
9941 // load-bearing axis on every value that probes positive for
9942 // both — mirrors the cascade discipline on every prior arm.
9943 let d = dep_with_fonte(DepSource::Path {
9944 caminho: "../foo\n>bar".into(),
9945 });
9946 let err = d.validate().unwrap_err();
9947 assert!(
9948 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9949 "got {err:?}",
9950 );
9951 }
9952
9953 #[test]
9954 fn fonte_caminho_absolute_fires_before_shell_redirection() {
9955 // Cascade pin on the load-bearing leading-byte arm: a leading
9956 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
9957 // routes through `FonteCaminhoAbsolute` not
9958 // `FonteCaminhoShellRedirection` — the host-layout-leak
9959 // diagnostic is the load-bearing axis, the `>` byte is the
9960 // secondary observation. Same precedence logic as every prior
9961 // leading-byte arm.
9962 let d = dep_with_fonte(DepSource::Path {
9963 caminho: "/etc/passwd>out".into(),
9964 });
9965 let err = d.validate().unwrap_err();
9966 assert!(
9967 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9968 "got {err:?}",
9969 );
9970 }
9971
9972 #[test]
9973 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
9974 // Cascade pin on the immediate-successor arm: a value carrying
9975 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
9976 // canonical "I tab-completed a path that already had a
9977 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
9978 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
9979 // the more semantic-locating axis (an author who removes the
9980 // `<` / `>` typically also drops the trailing separator since
9981 // both are paste-from-shell artifacts).
9982 let d = dep_with_fonte(DepSource::Path {
9983 caminho: "../foo></".into(),
9984 });
9985 let err = d.validate().unwrap_err();
9986 assert!(
9987 matches!(
9988 err,
9989 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
9990 ),
9991 "got {err:?}",
9992 );
9993 }
9994
9995 #[test]
9996 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
9997 // Diagnostic-shape pin (peer with
9998 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
9999 // payload assertion on the closest peer arm that also carries a
10000 // `byte` field): the error's Display surfaces the offending
10001 // `:nome`, the offending `:caminho` verbatim, and the offending
10002 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10003 // run can render the diagnostic without re-parsing.
10004 let d = dep_with_fonte(DepSource::Path {
10005 caminho: "../caixa-teia>build.log".into(),
10006 });
10007 let rendered = d.validate().unwrap_err().to_string();
10008 assert!(
10009 rendered.contains("caixa-teia"),
10010 "diagnostic must name the offending dep: {rendered}",
10011 );
10012 assert!(
10013 rendered.contains("../caixa-teia>build.log"),
10014 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10015 );
10016 assert!(
10017 rendered.contains("0x3e"),
10018 "diagnostic must name the offending byte in hex: {rendered:?}",
10019 );
10020 assert!(
10021 rendered.contains("redirection"),
10022 "diagnostic must name the shell-redirection footgun: {rendered:?}",
10023 );
10024 }
10025
10026 // -- :caminho shell-pipe metacharacter arm ----------------------------
10027
10028 #[test]
10029 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10030 // The fail-before-pass-after pin for the canonical shell-pipe
10031 // paste footgun: an author copies a shell-history line
10032 // (`"../caixa-teia | grep foo"` — the canonical "I selected
10033 // the whole `ls dir | grep` line out of zsh history") and
10034 // silently passed every prior arm (`Path::is_absolute` false
10035 // on `..`, no control bytes, no backslash, no `<` / `>`,
10036 // doesn't end in `/`). The lacre embedded the value verbatim,
10037 // the resolver folded it through `Path::join` looking for a
10038 // literal `./../caixa-teia | grep foo` subdirectory, and the
10039 // failure surfaced at resolve time with a non-self-locating
10040 // `No such file or directory` error. The new arm moves the
10041 // rejection to validate time and names the offending dep +
10042 // caminho verbatim.
10043 let d = dep_with_fonte(DepSource::Path {
10044 caminho: "../caixa-teia | grep foo".into(),
10045 });
10046 let err = d.validate().unwrap_err();
10047 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10048 panic!("expected FonteCaminhoShellPipe, got {err:?}");
10049 };
10050 assert_eq!(nome, "caixa-teia");
10051 assert_eq!(caminho, "../caixa-teia | grep foo");
10052 }
10053
10054 #[test]
10055 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10056 // Leading-position `|` shape (`"|../caixa-teia"` — the
10057 // degenerate "I forgot the source side of the pipe" idiom).
10058 // Pinned separately from the embedded-byte shape so the gate
10059 // covers every position, not only mid-path.
10060 let d = dep_with_fonte(DepSource::Path {
10061 caminho: "|../caixa-teia".into(),
10062 });
10063 let err = d.validate().unwrap_err();
10064 assert!(
10065 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10066 "got {err:?}",
10067 );
10068 }
10069
10070 #[test]
10071 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10072 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10073 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10074 // idiom). The arm fires on the first `|` encountered; pinned
10075 // so a future arm that tries to distinguish `|` from `||`
10076 // doesn't break the broader contract.
10077 let d = dep_with_fonte(DepSource::Path {
10078 caminho: "../caixa-teia||fallback".into(),
10079 });
10080 let err = d.validate().unwrap_err();
10081 assert!(
10082 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10083 "got {err:?}",
10084 );
10085 }
10086
10087 #[test]
10088 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10089 // The positive-control pin: the gate targets only `|`, never
10090 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10091 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10092 // pathed variant with adjacent printable punctuation
10093 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10094 // cleanly so the gate doesn't widen to a "no printable
10095 // punctuation anywhere" sweep that would defeat the entire
10096 // path-fonte author surface.
10097 let d = dep_with_fonte(DepSource::Path {
10098 caminho: "../caixa-teia/sub-dir.v2".into(),
10099 });
10100 d.validate().unwrap();
10101 }
10102
10103 #[test]
10104 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10105 // Cascade pin on the immediate-predecessor arm: a value carrying
10106 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10107 // canonical "I pasted a `cmd < input | tee` pipeline tail"
10108 // footgun) routes through `FonteCaminhoShellRedirection` not
10109 // `FonteCaminhoShellPipe`. The input/output redirection
10110 // metachar carries the more self-locating `byte: u8` payload
10111 // (it names which of `<` or `>` triggered), so the prior arm
10112 // wins on every probe-as-both value — same cascade discipline
10113 // every prior `:caminho` arm establishes.
10114 let d = dep_with_fonte(DepSource::Path {
10115 caminho: "../caixa-teia<input|tee".into(),
10116 });
10117 let err = d.validate().unwrap_err();
10118 assert!(
10119 matches!(
10120 err,
10121 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10122 ),
10123 "got {err:?}",
10124 );
10125 }
10126
10127 #[test]
10128 fn fonte_caminho_backslash_fires_before_shell_pipe() {
10129 // Cascade pin on the upstream backslash arm: a value carrying
10130 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10131 // "I pasted a Windows-shell command with pipe to tee"
10132 // footgun) routes through `FonteCaminhoBackslash` not
10133 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10134 // divergence is the load-bearing axis on every probe-as-both
10135 // value (an author who removes the `\` is the root-cause edit;
10136 // the `|` falls away in the same edit since it's downstream of
10137 // the Windows-shell convention).
10138 let d = dep_with_fonte(DepSource::Path {
10139 caminho: "..\\caixa-teia|tee".into(),
10140 });
10141 let err = d.validate().unwrap_err();
10142 assert!(
10143 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10144 "got {err:?}",
10145 );
10146 }
10147
10148 #[test]
10149 fn fonte_caminho_control_char_fires_before_shell_pipe() {
10150 // Cascade pin on the embedded-control-byte arm: a value
10151 // carrying both a control byte and `|` (`"../foo\n|bar"` —
10152 // the canonical paste-from-multiline-doc footgun where a
10153 // newline landed mid-caminho) routes through
10154 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10155 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10156 // diagnostic is the load-bearing axis on every value that
10157 // probes positive for both — mirrors the cascade discipline
10158 // on every prior arm.
10159 let d = dep_with_fonte(DepSource::Path {
10160 caminho: "../foo\n|bar".into(),
10161 });
10162 let err = d.validate().unwrap_err();
10163 assert!(
10164 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10165 "got {err:?}",
10166 );
10167 }
10168
10169 #[test]
10170 fn fonte_caminho_absolute_fires_before_shell_pipe() {
10171 // Cascade pin on the load-bearing leading-byte arm: a leading
10172 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10173 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10174 // — the host-layout-leak diagnostic is the load-bearing axis,
10175 // the `|` byte is the secondary observation. Same precedence
10176 // logic as every prior leading-byte arm.
10177 let d = dep_with_fonte(DepSource::Path {
10178 caminho: "/etc/passwd|tee".into(),
10179 });
10180 let err = d.validate().unwrap_err();
10181 assert!(
10182 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10183 "got {err:?}",
10184 );
10185 }
10186
10187 #[test]
10188 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10189 // Cascade pin on the immediate-successor arm: a value carrying
10190 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10191 // "I tab-completed a path that already had a pipeline tail"
10192 // footgun) routes through `FonteCaminhoShellPipe` not
10193 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10194 // the more semantic-locating axis (an author who removes the
10195 // `|` typically also drops the trailing separator since both
10196 // are paste-from-shell artifacts).
10197 let d = dep_with_fonte(DepSource::Path {
10198 caminho: "../foo|tee/".into(),
10199 });
10200 let err = d.validate().unwrap_err();
10201 assert!(
10202 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10203 "got {err:?}",
10204 );
10205 }
10206
10207 #[test]
10208 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10209 // Diagnostic-shape pin (peer with
10210 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10211 // on the closest single-byte peer arm): the error's Display
10212 // surfaces the offending `:nome` and the offending `:caminho`
10213 // verbatim, and names the shell-pipe footgun explicitly so a
10214 // `feira lint` run can render the diagnostic without
10215 // re-parsing.
10216 let d = dep_with_fonte(DepSource::Path {
10217 caminho: "../caixa-teia | grep foo".into(),
10218 });
10219 let rendered = d.validate().unwrap_err().to_string();
10220 assert!(
10221 rendered.contains("caixa-teia"),
10222 "diagnostic must name the offending dep: {rendered}",
10223 );
10224 assert!(
10225 rendered.contains("../caixa-teia | grep foo"),
10226 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10227 );
10228 assert!(
10229 rendered.contains('|'),
10230 "diagnostic must reference the pipe footgun: {rendered:?}",
10231 );
10232 assert!(
10233 rendered.contains("pipe"),
10234 "diagnostic must name the shell-pipe footgun: {rendered:?}",
10235 );
10236 }
10237
10238 // -- :caminho shell-command-separator metacharacter arm ---------------
10239
10240 #[test]
10241 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10242 // The fail-before-pass-after pin for the canonical shell-command-
10243 // separator paste footgun: an author copies a shell one-liner
10244 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10245 // whole `cd path; do-thing` chain out of a shell-history block")
10246 // and silently passed every prior arm (`Path::is_absolute` false
10247 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10248 // doesn't end in `/`). The lacre embedded the value verbatim, the
10249 // resolver folded it through `Path::join` looking for a literal
10250 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10251 // surfaced at resolve time with a non-self-locating `No such file
10252 // or directory` error. The new arm moves the rejection to validate
10253 // time and names the offending dep + caminho verbatim.
10254 let d = dep_with_fonte(DepSource::Path {
10255 caminho: "../caixa-teia; rm -rf build".into(),
10256 });
10257 let err = d.validate().unwrap_err();
10258 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10259 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10260 };
10261 assert_eq!(nome, "caixa-teia");
10262 assert_eq!(caminho, "../caixa-teia; rm -rf build");
10263 }
10264
10265 #[test]
10266 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10267 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10268 // "I forgot the prior command side of the separator" idiom).
10269 // Pinned separately from the embedded-byte shape so the gate
10270 // covers every position, not only mid-path.
10271 let d = dep_with_fonte(DepSource::Path {
10272 caminho: ";../caixa-teia".into(),
10273 });
10274 let err = d.validate().unwrap_err();
10275 assert!(
10276 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10277 "got {err:?}",
10278 );
10279 }
10280
10281 #[test]
10282 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10283 // The POSIX `case` arm `;;` terminator shape
10284 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10285 // arm tail" idiom). The arm fires on the first `;` encountered;
10286 // pinned so a future arm that tries to distinguish `;` from `;;`
10287 // doesn't break the broader contract.
10288 let d = dep_with_fonte(DepSource::Path {
10289 caminho: "../caixa-teia;;next".into(),
10290 });
10291 let err = d.validate().unwrap_err();
10292 assert!(
10293 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10294 "got {err:?}",
10295 );
10296 }
10297
10298 #[test]
10299 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10300 // The positive-control pin: the gate targets only `;`, never
10301 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10302 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10303 // pathed variant with adjacent printable punctuation
10304 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10305 // cleanly so the gate doesn't widen to a "no printable
10306 // punctuation anywhere" sweep that would defeat the entire
10307 // path-fonte author surface.
10308 let d = dep_with_fonte(DepSource::Path {
10309 caminho: "../caixa-teia/sub-dir.v2".into(),
10310 });
10311 d.validate().unwrap();
10312 }
10313
10314 #[test]
10315 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10316 // Cascade pin on the immediate-predecessor arm: a value carrying
10317 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10318 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10319 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10320 // pipeline-tail paste is the load-bearing root-cause edit on
10321 // every probe-as-both value (an author who removes the `|`
10322 // typically also drops the trailing `; cleanup` since both are
10323 // the same paste-from-shell-history artifact) — same cascade
10324 // discipline every prior `:caminho` arm establishes.
10325 let d = dep_with_fonte(DepSource::Path {
10326 caminho: "../caixa-teia | tee; rm".into(),
10327 });
10328 let err = d.validate().unwrap_err();
10329 assert!(
10330 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10331 "got {err:?}",
10332 );
10333 }
10334
10335 #[test]
10336 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10337 // Cascade pin on the upstream shell-redirection arm: a value
10338 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10339 // the canonical "I pasted a `cmd > log; cleanup` chain"
10340 // footgun) routes through `FonteCaminhoShellRedirection` not
10341 // `FonteCaminhoShellSemicolon`. The input/output redirection
10342 // metachar carries the more self-locating `byte: u8` payload
10343 // (it names which of `<` or `>` triggered), so the prior arm
10344 // wins on every probe-as-both value.
10345 let d = dep_with_fonte(DepSource::Path {
10346 caminho: "../caixa-teia>log; rm".into(),
10347 });
10348 let err = d.validate().unwrap_err();
10349 assert!(
10350 matches!(
10351 err,
10352 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10353 ),
10354 "got {err:?}",
10355 );
10356 }
10357
10358 #[test]
10359 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10360 // Cascade pin on the upstream backslash arm: a value carrying
10361 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10362 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10363 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10364 // The cross-host-OS-separator divergence is the load-bearing axis
10365 // on every probe-as-both value (an author who removes the `\` is
10366 // the root-cause edit; the `;` falls away in the same edit since
10367 // it's downstream of the Windows-shell convention).
10368 let d = dep_with_fonte(DepSource::Path {
10369 caminho: "..\\caixa-teia;rm".into(),
10370 });
10371 let err = d.validate().unwrap_err();
10372 assert!(
10373 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10374 "got {err:?}",
10375 );
10376 }
10377
10378 #[test]
10379 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10380 // Cascade pin on the embedded-control-byte arm: a value carrying
10381 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10382 // paste-from-multiline-doc footgun where a newline landed mid-
10383 // caminho) routes through `FonteCaminhoControlChar` not
10384 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10385 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10386 // on every value that probes positive for both — mirrors the
10387 // cascade discipline on every prior arm.
10388 let d = dep_with_fonte(DepSource::Path {
10389 caminho: "../foo\n;bar".into(),
10390 });
10391 let err = d.validate().unwrap_err();
10392 assert!(
10393 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10394 "got {err:?}",
10395 );
10396 }
10397
10398 #[test]
10399 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10400 // Cascade pin on the load-bearing leading-byte arm: a leading
10401 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10402 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10403 // — the host-layout-leak diagnostic is the load-bearing axis,
10404 // the `;` byte is the secondary observation. Same precedence
10405 // logic as every prior leading-byte arm.
10406 let d = dep_with_fonte(DepSource::Path {
10407 caminho: "/etc/passwd;rm".into(),
10408 });
10409 let err = d.validate().unwrap_err();
10410 assert!(
10411 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10412 "got {err:?}",
10413 );
10414 }
10415
10416 #[test]
10417 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10418 // Cascade pin on the immediate-successor arm: a value carrying
10419 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10420 // "I tab-completed a path that already had a `; cleanup` tail"
10421 // footgun) routes through `FonteCaminhoShellSemicolon` not
10422 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10423 // the more semantic-locating axis (an author who removes the
10424 // `;` typically also drops the trailing separator since both
10425 // are paste-from-shell artifacts).
10426 let d = dep_with_fonte(DepSource::Path {
10427 caminho: "../foo;rm/".into(),
10428 });
10429 let err = d.validate().unwrap_err();
10430 assert!(
10431 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10432 "got {err:?}",
10433 );
10434 }
10435
10436 #[test]
10437 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10438 // Diagnostic-shape pin (peer with
10439 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10440 // on the closest single-byte peer arm): the error's Display
10441 // surfaces the offending `:nome` and the offending `:caminho`
10442 // verbatim, and names the shell-command-separator footgun
10443 // explicitly so a `feira lint` run can render the diagnostic
10444 // without re-parsing.
10445 let d = dep_with_fonte(DepSource::Path {
10446 caminho: "../caixa-teia; rm -rf build".into(),
10447 });
10448 let rendered = d.validate().unwrap_err().to_string();
10449 assert!(
10450 rendered.contains("caixa-teia"),
10451 "diagnostic must name the offending dep: {rendered}",
10452 );
10453 assert!(
10454 rendered.contains("../caixa-teia; rm -rf build"),
10455 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10456 );
10457 assert!(
10458 rendered.contains(';'),
10459 "diagnostic must reference the semicolon footgun: {rendered:?}",
10460 );
10461 assert!(
10462 rendered.contains("command-separator"),
10463 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10464 );
10465 }
10466
10467 #[test]
10468 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10469 // The fail-before-pass-after pin for the canonical shell-
10470 // background-task paste footgun: an author copies a shell one-
10471 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10472 // the whole `cd path & sleep 1` background-launch out of a
10473 // shell-history block") and silently passed every prior arm
10474 // (`Path::is_absolute` false on `..`, no control bytes, no
10475 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10476 // The lacre embedded the value verbatim, the resolver folded it
10477 // through `Path::join` looking for a literal `./../caixa-teia &
10478 // sleep 1` subdirectory, and the failure surfaced at resolve
10479 // time with a non-self-locating `No such file or directory`
10480 // error. The new arm moves the rejection to validate time and
10481 // names the offending dep + caminho verbatim.
10482 let d = dep_with_fonte(DepSource::Path {
10483 caminho: "../caixa-teia & sleep 1".into(),
10484 });
10485 let err = d.validate().unwrap_err();
10486 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10487 panic!("expected FonteCaminhoShellBackground, got {err:?}");
10488 };
10489 assert_eq!(nome, "caixa-teia");
10490 assert_eq!(caminho, "../caixa-teia & sleep 1");
10491 }
10492
10493 #[test]
10494 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10495 // Leading-position `&` shape (`"&../caixa-teia"` — the
10496 // degenerate "I forgot the prior command side of the
10497 // background terminator" idiom). Pinned separately from the
10498 // embedded-byte shape so the gate covers every position, not
10499 // only mid-path.
10500 let d = dep_with_fonte(DepSource::Path {
10501 caminho: "&../caixa-teia".into(),
10502 });
10503 let err = d.validate().unwrap_err();
10504 assert!(
10505 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10506 "got {err:?}",
10507 );
10508 }
10509
10510 #[test]
10511 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10512 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10513 // canonical "I copied a `cd path && make` build chain" idiom
10514 // every Makefile / shell-script wraps). The arm fires on the
10515 // first `&` encountered; pinned so a future arm that tries to
10516 // distinguish `&` from `&&` doesn't break the broader contract.
10517 let d = dep_with_fonte(DepSource::Path {
10518 caminho: "../caixa-teia && make".into(),
10519 });
10520 let err = d.validate().unwrap_err();
10521 assert!(
10522 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10523 "got {err:?}",
10524 );
10525 }
10526
10527 #[test]
10528 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10529 // The positive-control pin: the gate targets only `&`, never
10530 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10531 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10532 // pathed variant with adjacent printable punctuation
10533 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10534 // cleanly so the gate doesn't widen to a "no printable
10535 // punctuation anywhere" sweep that would defeat the entire
10536 // path-fonte author surface.
10537 let d = dep_with_fonte(DepSource::Path {
10538 caminho: "../caixa-teia/sub-dir.v2".into(),
10539 });
10540 d.validate().unwrap();
10541 }
10542
10543 #[test]
10544 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10545 // Cascade pin on the immediate-predecessor arm: a value carrying
10546 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10547 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10548 // routes through `FonteCaminhoShellSemicolon` not
10549 // `FonteCaminhoShellBackground`. The sequential-command-
10550 // separator paste is the more common shell-history paste idiom
10551 // on every probe-as-both value (an author who removes the `;`
10552 // typically also drops the trailing `& sleep` since both are
10553 // paste-from-shell-history artifacts) — same cascade discipline
10554 // every prior `:caminho` arm establishes.
10555 let d = dep_with_fonte(DepSource::Path {
10556 caminho: "../caixa-teia; rm & sleep".into(),
10557 });
10558 let err = d.validate().unwrap_err();
10559 assert!(
10560 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10561 "got {err:?}",
10562 );
10563 }
10564
10565 #[test]
10566 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10567 // Cascade pin on the upstream shell-pipe arm: a value carrying
10568 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10569 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10570 // chain" footgun) routes through `FonteCaminhoShellPipe` not
10571 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10572 // load-bearing root-cause edit on every probe-as-both value.
10573 let d = dep_with_fonte(DepSource::Path {
10574 caminho: "../caixa-teia | tee & sleep".into(),
10575 });
10576 let err = d.validate().unwrap_err();
10577 assert!(
10578 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10579 "got {err:?}",
10580 );
10581 }
10582
10583 #[test]
10584 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10585 // Cascade pin on the upstream shell-redirection arm: a value
10586 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10587 // the canonical "I pasted a `cmd > log & sleep` background-
10588 // redirect chain" footgun) routes through
10589 // `FonteCaminhoShellRedirection` not
10590 // `FonteCaminhoShellBackground`. The input/output redirection
10591 // metachar carries the more self-locating `byte: u8` payload
10592 // (it names which of `<` or `>` triggered), so the prior arm
10593 // wins on every probe-as-both value.
10594 let d = dep_with_fonte(DepSource::Path {
10595 caminho: "../caixa-teia>log & sleep".into(),
10596 });
10597 let err = d.validate().unwrap_err();
10598 assert!(
10599 matches!(
10600 err,
10601 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10602 ),
10603 "got {err:?}",
10604 );
10605 }
10606
10607 #[test]
10608 fn fonte_caminho_backslash_fires_before_shell_background() {
10609 // Cascade pin on the upstream backslash arm: a value carrying
10610 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10611 // "I pasted a Windows-shell `cd ..\path & sleep` background-
10612 // launch chain") routes through `FonteCaminhoBackslash` not
10613 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10614 // divergence is the load-bearing axis on every probe-as-both
10615 // value (an author who removes the `\` is the root-cause edit;
10616 // the `&` falls away in the same edit since it's downstream of
10617 // the Windows-shell convention).
10618 let d = dep_with_fonte(DepSource::Path {
10619 caminho: "..\\caixa-teia & sleep".into(),
10620 });
10621 let err = d.validate().unwrap_err();
10622 assert!(
10623 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10624 "got {err:?}",
10625 );
10626 }
10627
10628 #[test]
10629 fn fonte_caminho_control_char_fires_before_shell_background() {
10630 // Cascade pin on the embedded-control-byte arm: a value
10631 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10632 // the canonical paste-from-multiline-doc footgun where a
10633 // newline landed mid-caminho) routes through
10634 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10635 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10636 // diagnostic is the load-bearing axis on every value that
10637 // probes positive for both — mirrors the cascade discipline on
10638 // every prior arm.
10639 let d = dep_with_fonte(DepSource::Path {
10640 caminho: "../foo\n&sleep".into(),
10641 });
10642 let err = d.validate().unwrap_err();
10643 assert!(
10644 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10645 "got {err:?}",
10646 );
10647 }
10648
10649 #[test]
10650 fn fonte_caminho_absolute_fires_before_shell_background() {
10651 // Cascade pin on the load-bearing leading-byte arm: a leading
10652 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10653 // through `FonteCaminhoAbsolute` not
10654 // `FonteCaminhoShellBackground` — the host-layout-leak
10655 // diagnostic is the load-bearing axis, the `&` byte is the
10656 // secondary observation. Same precedence logic as every prior
10657 // leading-byte arm.
10658 let d = dep_with_fonte(DepSource::Path {
10659 caminho: "/etc/passwd & sleep".into(),
10660 });
10661 let err = d.validate().unwrap_err();
10662 assert!(
10663 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10664 "got {err:?}",
10665 );
10666 }
10667
10668 #[test]
10669 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10670 // Cascade pin on the immediate-successor arm: a value carrying
10671 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10672 // canonical "I tab-completed a path that already had a `&
10673 // sleep` background-launch tail" footgun) routes through
10674 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10675 // The embedded shell-metachar is the more semantic-locating
10676 // axis (an author who removes the `&` typically also drops
10677 // the trailing separator since both are paste-from-shell
10678 // artifacts).
10679 let d = dep_with_fonte(DepSource::Path {
10680 caminho: "../foo&sleep/".into(),
10681 });
10682 let err = d.validate().unwrap_err();
10683 assert!(
10684 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10685 "got {err:?}",
10686 );
10687 }
10688
10689 #[test]
10690 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10691 // Diagnostic-shape pin (peer with
10692 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10693 // on the closest single-byte peer arm): the error's Display
10694 // surfaces the offending `:nome` and the offending `:caminho`
10695 // verbatim, and names the shell-background / logical-AND
10696 // footgun explicitly so a `feira lint` run can render the
10697 // diagnostic without re-parsing.
10698 let d = dep_with_fonte(DepSource::Path {
10699 caminho: "../caixa-teia & sleep 1".into(),
10700 });
10701 let rendered = d.validate().unwrap_err().to_string();
10702 assert!(
10703 rendered.contains("caixa-teia"),
10704 "diagnostic must name the offending dep: {rendered}",
10705 );
10706 assert!(
10707 rendered.contains("../caixa-teia & sleep 1"),
10708 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10709 );
10710 assert!(
10711 rendered.contains('&'),
10712 "diagnostic must reference the ampersand footgun: {rendered:?}",
10713 );
10714 assert!(
10715 rendered.contains("background") || rendered.contains("list-AND"),
10716 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10717 );
10718 }
10719
10720 #[test]
10721 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
10722 // The fail-before-pass-after pin for the canonical shell-
10723 // command-substitution paste footgun: an author copies a
10724 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
10725 // — the canonical "I pasted a path that included a `pwd`
10726 // / `whoami` / `date` legacy command-substitution expansion
10727 // out of a shell-history block") and silently passed every
10728 // prior arm (`Path::is_absolute` false on `..`, no control
10729 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
10730 // end in `/`). The lacre embedded the value verbatim, the
10731 // resolver folded it through `Path::join` looking for a
10732 // literal `./../caixa-teia/`whoami`` subdirectory, and the
10733 // failure surfaced at resolve time with a non-self-locating
10734 // `No such file or directory` error. The new arm moves the
10735 // rejection to validate time and names the offending dep +
10736 // caminho verbatim.
10737 let d = dep_with_fonte(DepSource::Path {
10738 caminho: "../caixa-teia/`whoami`".into(),
10739 });
10740 let err = d.validate().unwrap_err();
10741 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
10742 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
10743 };
10744 assert_eq!(nome, "caixa-teia");
10745 assert_eq!(caminho, "../caixa-teia/`whoami`");
10746 }
10747
10748 #[test]
10749 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
10750 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
10751 // the canonical `<backtick>pwd<backtick>/path` working-
10752 // directory expansion shape every shell-side path-composition
10753 // idiom carries). Pinned separately from the embedded-byte
10754 // shape so the gate covers every position, not only mid-path.
10755 let d = dep_with_fonte(DepSource::Path {
10756 caminho: "`pwd`/caixa-teia".into(),
10757 });
10758 let err = d.validate().unwrap_err();
10759 assert!(
10760 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10761 "got {err:?}",
10762 );
10763 }
10764
10765 #[test]
10766 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
10767 // Trailing-position backtick shape (`"../caixa-teia`"` — the
10768 // degenerate "I selected an unbalanced backtick out of a
10769 // shell-history block" idiom that probes for the cascade's
10770 // last-byte handling). The trailing-`/` arm fires only on
10771 // last-byte `/`; an unbalanced trailing backtick must route
10772 // through this arm regardless of position.
10773 let d = dep_with_fonte(DepSource::Path {
10774 caminho: "../caixa-teia`".into(),
10775 });
10776 let err = d.validate().unwrap_err();
10777 assert!(
10778 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10779 "got {err:?}",
10780 );
10781 }
10782
10783 #[test]
10784 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
10785 // The canonical balanced-pair shape (``"../<backtick>cat
10786 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
10787 // command-injection paste idiom every shell-side hardening
10788 // guide enumerates first). The arm fires on the first
10789 // backtick encountered; pinned so a future arm that tries to
10790 // distinguish the opening from the closing byte doesn't break
10791 // the broader contract.
10792 let d = dep_with_fonte(DepSource::Path {
10793 caminho: "../`cat /etc/passwd`".into(),
10794 });
10795 let err = d.validate().unwrap_err();
10796 assert!(
10797 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10798 "got {err:?}",
10799 );
10800 }
10801
10802 #[test]
10803 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
10804 // The positive-control pin: the gate targets only the
10805 // backtick byte, never adjacent printable ASCII or POSIX-
10806 // valid bytes. The canonical relative POSIX path
10807 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
10808 // adjacent printable punctuation
10809 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10810 // cleanly so the gate doesn't widen to a "no printable
10811 // punctuation anywhere" sweep that would defeat the entire
10812 // path-fonte author surface.
10813 let d = dep_with_fonte(DepSource::Path {
10814 caminho: "../caixa-teia/sub-dir.v2".into(),
10815 });
10816 d.validate().unwrap();
10817 }
10818
10819 #[test]
10820 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
10821 // Cascade pin on the immediate-predecessor arm: a value
10822 // carrying both `&` and a backtick (``"../caixa-teia &
10823 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
10824 // `cmd & <backtick>sleep N<backtick>` background-launch +
10825 // command-substitution chain" footgun) routes through
10826 // `FonteCaminhoShellBackground` not
10827 // `FonteCaminhoShellCommandSubstitution`. The background-
10828 // launch tail is the more common shell-history paste idiom
10829 // on every probe-as-both value — same cascade discipline
10830 // every prior `:caminho` arm establishes.
10831 let d = dep_with_fonte(DepSource::Path {
10832 caminho: "../caixa-teia & `sleep 1`".into(),
10833 });
10834 let err = d.validate().unwrap_err();
10835 assert!(
10836 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10837 "got {err:?}",
10838 );
10839 }
10840
10841 #[test]
10842 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
10843 // Cascade pin on the upstream shell-semicolon arm: a value
10844 // carrying both `;` and a backtick (``"../caixa-teia;
10845 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10846 // `cmd; <backtick>follow-up<backtick>` sequential-chain
10847 // footgun) routes through `FonteCaminhoShellSemicolon` not
10848 // `FonteCaminhoShellCommandSubstitution`. The sequential-
10849 // command-separator paste is the load-bearing root-cause
10850 // edit on every probe-as-both value.
10851 let d = dep_with_fonte(DepSource::Path {
10852 caminho: "../caixa-teia; `whoami`".into(),
10853 });
10854 let err = d.validate().unwrap_err();
10855 assert!(
10856 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10857 "got {err:?}",
10858 );
10859 }
10860
10861 #[test]
10862 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
10863 // Cascade pin on the upstream shell-pipe arm: a value
10864 // carrying both `|` and a backtick (``"../caixa-teia |
10865 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
10866 // command-substitution paste idiom) routes through
10867 // `FonteCaminhoShellPipe` not
10868 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
10869 // paste is the load-bearing root-cause edit on every
10870 // probe-as-both value.
10871 let d = dep_with_fonte(DepSource::Path {
10872 caminho: "../caixa-teia | `tee log`".into(),
10873 });
10874 let err = d.validate().unwrap_err();
10875 assert!(
10876 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10877 "got {err:?}",
10878 );
10879 }
10880
10881 #[test]
10882 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
10883 // Cascade pin on the upstream shell-redirection arm: a value
10884 // carrying both `>` and a backtick (``"../caixa-teia>log
10885 // <backtick>date<backtick>"`` — the canonical "I pasted a
10886 // `cmd > log <backtick>date<backtick>` redirect-plus-
10887 // substitution chain" footgun) routes through
10888 // `FonteCaminhoShellRedirection` not
10889 // `FonteCaminhoShellCommandSubstitution`. The input/output
10890 // redirection metachar carries the more self-locating `byte`
10891 // payload (it names which of `<` or `>` triggered), so the
10892 // prior arm wins on every probe-as-both value.
10893 let d = dep_with_fonte(DepSource::Path {
10894 caminho: "../caixa-teia>log `date`".into(),
10895 });
10896 let err = d.validate().unwrap_err();
10897 assert!(
10898 matches!(
10899 err,
10900 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10901 ),
10902 "got {err:?}",
10903 );
10904 }
10905
10906 #[test]
10907 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
10908 // Cascade pin on the upstream backslash arm: a value
10909 // carrying both `\` and a backtick (``"..\caixa-teia
10910 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
10911 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
10912 // chain") routes through `FonteCaminhoBackslash` not
10913 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
10914 // separator divergence is the load-bearing axis on every
10915 // probe-as-both value (an author who removes the `\` is the
10916 // root-cause edit; the backtick falls away in the same edit
10917 // since it's downstream of the Windows-shell convention).
10918 let d = dep_with_fonte(DepSource::Path {
10919 caminho: "..\\caixa-teia `whoami`".into(),
10920 });
10921 let err = d.validate().unwrap_err();
10922 assert!(
10923 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10924 "got {err:?}",
10925 );
10926 }
10927
10928 #[test]
10929 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
10930 // Cascade pin on the embedded-control-byte arm: a value
10931 // carrying both a control byte and a backtick (`"../foo\n
10932 // `whoami`"` — the canonical paste-from-multiline-doc
10933 // footgun where a newline landed mid-caminho between two
10934 // paste fragments) routes through `FonteCaminhoControlChar`
10935 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
10936 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
10937 // is the load-bearing axis on every value that probes
10938 // positive for both — mirrors the cascade discipline on
10939 // every prior arm.
10940 let d = dep_with_fonte(DepSource::Path {
10941 caminho: "../foo\n`whoami`".into(),
10942 });
10943 let err = d.validate().unwrap_err();
10944 assert!(
10945 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10946 "got {err:?}",
10947 );
10948 }
10949
10950 #[test]
10951 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
10952 // Cascade pin on the load-bearing leading-byte arm: a
10953 // leading `/` value with embedded backtick (``"/etc/passwd
10954 // <backtick>whoami<backtick>"``) routes through
10955 // `FonteCaminhoAbsolute` not
10956 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
10957 // leak diagnostic is the load-bearing axis, the backtick
10958 // byte is the secondary observation. Same precedence logic
10959 // as every prior leading-byte arm.
10960 let d = dep_with_fonte(DepSource::Path {
10961 caminho: "/etc/passwd `whoami`".into(),
10962 });
10963 let err = d.validate().unwrap_err();
10964 assert!(
10965 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10966 "got {err:?}",
10967 );
10968 }
10969
10970 #[test]
10971 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
10972 // Cascade pin on the immediate-successor arm: a value
10973 // carrying both a backtick and a trailing `/`
10974 // (``"../`whoami`/"`` — the canonical "I tab-completed a
10975 // path that already had a backticked `whoami` substitution
10976 // tail" footgun) routes through
10977 // `FonteCaminhoShellCommandSubstitution` not
10978 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
10979 // is the more semantic-locating axis (an author who removes
10980 // the backtick typically also drops the trailing separator
10981 // since both are paste-from-shell artifacts).
10982 let d = dep_with_fonte(DepSource::Path {
10983 caminho: "../`whoami`/".into(),
10984 });
10985 let err = d.validate().unwrap_err();
10986 assert!(
10987 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
10988 "got {err:?}",
10989 );
10990 }
10991
10992 #[test]
10993 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
10994 // Diagnostic-shape pin (peer with
10995 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
10996 // on the closest single-byte peer arm): the error's Display
10997 // surfaces the offending `:nome` and the offending `:caminho`
10998 // verbatim, and names the shell-command-substitution footgun
10999 // explicitly so a `feira lint` run can render the diagnostic
11000 // without re-parsing.
11001 let d = dep_with_fonte(DepSource::Path {
11002 caminho: "../caixa-teia/`whoami`".into(),
11003 });
11004 let rendered = d.validate().unwrap_err().to_string();
11005 assert!(
11006 rendered.contains("caixa-teia"),
11007 "diagnostic must name the offending dep: {rendered}",
11008 );
11009 assert!(
11010 rendered.contains("../caixa-teia/`whoami`"),
11011 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11012 );
11013 assert!(
11014 rendered.contains('`'),
11015 "diagnostic must reference the backtick footgun: {rendered:?}",
11016 );
11017 assert!(
11018 rendered.contains("command-substitution"),
11019 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11020 );
11021 }
11022
11023 #[test]
11024 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11025 // The fail-before-pass-after pin for the canonical pathname-
11026 // expansion paste footgun: an author copies an `ls
11027 // ../caixa-teia/*` shell-listing tail into the `:caminho`
11028 // slot and silently passes every prior arm
11029 // (`Path::is_absolute` false on `..`, no control bytes, no
11030 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11031 // doesn't end in `/`). The lacre embedded the value
11032 // verbatim, the resolver folded it through `Path::join`
11033 // looking for a literal `./../caixa-teia/*` subdirectory,
11034 // and the failure surfaced at resolve time with a non-self-
11035 // locating `No such file or directory` error. The new arm
11036 // moves the rejection to validate time and names the
11037 // offending dep + caminho + byte verbatim.
11038 let d = dep_with_fonte(DepSource::Path {
11039 caminho: "../caixa-teia/*".into(),
11040 });
11041 let err = d.validate().unwrap_err();
11042 let DepError::FonteCaminhoShellGlob {
11043 nome,
11044 caminho,
11045 byte,
11046 } = err
11047 else {
11048 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11049 };
11050 assert_eq!(nome, "caixa-teia");
11051 assert_eq!(caminho, "../caixa-teia/*");
11052 assert_eq!(byte, b'*');
11053 }
11054
11055 #[test]
11056 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11057 // The symmetric single-char-wildcard paste shape
11058 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11059 // out of shell history" idiom). Pinned separately from the
11060 // `*` shape so the gate's contract is "any `*` or `?`
11061 // anywhere", not single-byte coverage.
11062 let d = dep_with_fonte(DepSource::Path {
11063 caminho: "../foo?".into(),
11064 });
11065 let err = d.validate().unwrap_err();
11066 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11067 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11068 };
11069 assert_eq!(byte, b'?');
11070 }
11071
11072 #[test]
11073 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11074 // Leading-position `*` shape (`"*/caixa-teia"` — the
11075 // degenerate "I selected only the wildcard prefix out of a
11076 // shell-glob expression" idiom). Pinned separately from the
11077 // embedded-byte shapes so the gate covers every position,
11078 // not only mid-path.
11079 let d = dep_with_fonte(DepSource::Path {
11080 caminho: "*/caixa-teia".into(),
11081 });
11082 let err = d.validate().unwrap_err();
11083 assert!(
11084 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11085 "got {err:?}",
11086 );
11087 }
11088
11089 #[test]
11090 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11091 // The bash/zsh `globstar` recursive-glob shape
11092 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11093 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11094 // The arm fires on the first `*` encountered; pinned so a
11095 // future arm that tries to distinguish single `*` from
11096 // double `**` doesn't break the broader contract.
11097 let d = dep_with_fonte(DepSource::Path {
11098 caminho: "../caixa-teia/**/foo".into(),
11099 });
11100 let err = d.validate().unwrap_err();
11101 assert!(
11102 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11103 "got {err:?}",
11104 );
11105 }
11106
11107 #[test]
11108 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11109 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11110 // — the "I selected `*.lisp` to mean every Lisp source file
11111 // in the dep root" footgun the prior arms structurally
11112 // cannot catch since `.` is a POSIX-valid path-component
11113 // byte). Pinned so the gate's contract covers the most
11114 // idiomatic glob-paste shape every author meets first.
11115 let d = dep_with_fonte(DepSource::Path {
11116 caminho: "../caixa-teia/*.lisp".into(),
11117 });
11118 let err = d.validate().unwrap_err();
11119 assert!(
11120 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11121 "got {err:?}",
11122 );
11123 }
11124
11125 #[test]
11126 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11127 // The positive-control pin: the gate targets only `*` /
11128 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11129 // The canonical relative POSIX path (`"../caixa-teia"`) and
11130 // a nested deeply-pathed variant with adjacent printable
11131 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11132 // to validate cleanly so the gate doesn't widen to a "no
11133 // printable punctuation anywhere" sweep that would defeat
11134 // the entire path-fonte author surface.
11135 let d = dep_with_fonte(DepSource::Path {
11136 caminho: "../caixa-teia/sub-dir.v2".into(),
11137 });
11138 d.validate().unwrap();
11139 }
11140
11141 #[test]
11142 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11143 // Cascade pin on the immediate-predecessor arm: a value
11144 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11145 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11146 // command-substitution + glob chain") routes through
11147 // `FonteCaminhoShellCommandSubstitution` not
11148 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11149 // injection vector is the load-bearing root-cause edit on
11150 // every probe-as-both value — same cascade discipline every
11151 // prior `:caminho` arm establishes.
11152 let d = dep_with_fonte(DepSource::Path {
11153 caminho: "../`whoami`/*".into(),
11154 });
11155 let err = d.validate().unwrap_err();
11156 assert!(
11157 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11158 "got {err:?}",
11159 );
11160 }
11161
11162 #[test]
11163 fn fonte_caminho_shell_background_fires_before_shell_glob() {
11164 // Cascade pin on the upstream shell-background arm: a value
11165 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11166 // canonical "I pasted a `cmd & ls /*` background + glob
11167 // chain" footgun) routes through `FonteCaminhoShellBackground`
11168 // not `FonteCaminhoShellGlob`. The background-launch tail is
11169 // the load-bearing root-cause edit on every probe-as-both
11170 // value.
11171 let d = dep_with_fonte(DepSource::Path {
11172 caminho: "../caixa-teia & ls /*".into(),
11173 });
11174 let err = d.validate().unwrap_err();
11175 assert!(
11176 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11177 "got {err:?}",
11178 );
11179 }
11180
11181 #[test]
11182 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11183 // Cascade pin on the upstream shell-semicolon arm: a value
11184 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11185 // canonical sequential-cleanup + glob paste idiom) routes
11186 // through `FonteCaminhoShellSemicolon` not
11187 // `FonteCaminhoShellGlob`. The sequential-command-separator
11188 // paste is the load-bearing root-cause edit on every
11189 // probe-as-both value.
11190 let d = dep_with_fonte(DepSource::Path {
11191 caminho: "../caixa-teia; rm *".into(),
11192 });
11193 let err = d.validate().unwrap_err();
11194 assert!(
11195 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11196 "got {err:?}",
11197 );
11198 }
11199
11200 #[test]
11201 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11202 // Cascade pin on the upstream shell-pipe arm: a value
11203 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11204 // canonical pipeline-to-glob paste idiom) routes through
11205 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11206 // pipeline-tail paste is the load-bearing root-cause edit
11207 // on every probe-as-both value.
11208 let d = dep_with_fonte(DepSource::Path {
11209 caminho: "../caixa-teia | ls *".into(),
11210 });
11211 let err = d.validate().unwrap_err();
11212 assert!(
11213 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11214 "got {err:?}",
11215 );
11216 }
11217
11218 #[test]
11219 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11220 // Cascade pin on the upstream shell-redirection arm: a value
11221 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11222 // canonical "I pasted a `cmd > log *` redirect-plus-glob
11223 // chain" footgun) routes through
11224 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11225 // The input/output redirection metachar carries the more
11226 // self-locating `byte` payload (it names which of `<` or `>`
11227 // triggered), so the prior arm wins on every probe-as-both
11228 // value.
11229 let d = dep_with_fonte(DepSource::Path {
11230 caminho: "../caixa-teia>log *".into(),
11231 });
11232 let err = d.validate().unwrap_err();
11233 assert!(
11234 matches!(
11235 err,
11236 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11237 ),
11238 "got {err:?}",
11239 );
11240 }
11241
11242 #[test]
11243 fn fonte_caminho_backslash_fires_before_shell_glob() {
11244 // Cascade pin on the upstream backslash arm: a value
11245 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11246 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11247 // expression" footgun) routes through
11248 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11249 // cross-host-OS-separator divergence is the load-bearing
11250 // axis on every probe-as-both value (an author who removes
11251 // the `\` is the root-cause edit; the `*` falls away in the
11252 // same edit since it's downstream of the Windows-shell
11253 // convention).
11254 let d = dep_with_fonte(DepSource::Path {
11255 caminho: "..\\caixa-teia\\*".into(),
11256 });
11257 let err = d.validate().unwrap_err();
11258 assert!(
11259 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11260 "got {err:?}",
11261 );
11262 }
11263
11264 #[test]
11265 fn fonte_caminho_control_char_fires_before_shell_glob() {
11266 // Cascade pin on the embedded-control-byte arm: a value
11267 // carrying both a control byte and `*` (`"../foo\n*"` — the
11268 // canonical paste-from-multiline-doc footgun where a
11269 // newline landed mid-caminho between two paste fragments)
11270 // routes through `FonteCaminhoControlChar` not
11271 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11272 // NUL-`CString::new`-fail diagnostic is the load-bearing
11273 // axis on every value that probes positive for both —
11274 // mirrors the cascade discipline on every prior arm.
11275 let d = dep_with_fonte(DepSource::Path {
11276 caminho: "../foo\n*".into(),
11277 });
11278 let err = d.validate().unwrap_err();
11279 assert!(
11280 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11281 "got {err:?}",
11282 );
11283 }
11284
11285 #[test]
11286 fn fonte_caminho_absolute_fires_before_shell_glob() {
11287 // Cascade pin on the load-bearing leading-byte arm: a
11288 // leading `/` value with embedded `*` (`"/etc/*"`) routes
11289 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11290 // — the host-layout-leak diagnostic is the load-bearing
11291 // axis, the glob byte is the secondary observation. Same
11292 // precedence logic as every prior leading-byte arm.
11293 let d = dep_with_fonte(DepSource::Path {
11294 caminho: "/etc/*".into(),
11295 });
11296 let err = d.validate().unwrap_err();
11297 assert!(
11298 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11299 "got {err:?}",
11300 );
11301 }
11302
11303 #[test]
11304 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11305 // Cascade pin on the immediate-successor arm: a value
11306 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11307 // canonical "I tab-completed a path that already had a
11308 // glob-expansion tail" footgun) routes through
11309 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11310 // The embedded shell-metachar is the more semantic-locating
11311 // axis (an author who removes the `*` typically also drops
11312 // the trailing separator since both are paste-from-shell
11313 // artifacts).
11314 let d = dep_with_fonte(DepSource::Path {
11315 caminho: "../foo*/".into(),
11316 });
11317 let err = d.validate().unwrap_err();
11318 assert!(
11319 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11320 "got {err:?}",
11321 );
11322 }
11323
11324 #[test]
11325 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11326 // Diagnostic-shape pin (peer with
11327 // `fonte_caminho_shell_redirection_diagnostic_*` on the
11328 // closest two-byte peer arm): the error's Display surfaces
11329 // the offending `:nome`, the offending `:caminho` verbatim,
11330 // the offending byte's hex / character form, and names the
11331 // shell-glob / pathname-expansion footgun explicitly so a
11332 // `feira lint` run can render the diagnostic without
11333 // re-parsing.
11334 let d = dep_with_fonte(DepSource::Path {
11335 caminho: "../caixa-teia/*.lisp".into(),
11336 });
11337 let rendered = d.validate().unwrap_err().to_string();
11338 assert!(
11339 rendered.contains("caixa-teia"),
11340 "diagnostic must name the offending dep: {rendered}",
11341 );
11342 assert!(
11343 rendered.contains("../caixa-teia/*.lisp"),
11344 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11345 );
11346 assert!(
11347 rendered.contains("0x2a"),
11348 "diagnostic must surface the offending byte hex: {rendered:?}",
11349 );
11350 assert!(
11351 rendered.contains("glob"),
11352 "diagnostic must name the shell-glob footgun: {rendered:?}",
11353 );
11354 assert!(
11355 rendered.contains("pathname-expansion"),
11356 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11357 );
11358 }
11359
11360 #[test]
11361 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11362 // The fail-before-pass-after pin for the canonical modern-Bourne
11363 // command-substitution paste footgun: an author copies a
11364 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11365 // `$(<cmd>)` expansion would land the current date as a
11366 // subdirectory name and silently passed every prior arm
11367 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11368 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11369 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11370 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11371 // sits mid-path). The lacre embedded the value verbatim, the
11372 // resolver folded it through `Path::join` looking for a literal
11373 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11374 // surfaced at resolve time with a non-self-locating `No such
11375 // file or directory` error. The new arm moves the rejection to
11376 // validate time and names the offending dep + caminho + byte
11377 // verbatim. The arm fires on the first `(` encountered (the
11378 // opening byte of `$(date)`).
11379 let d = dep_with_fonte(DepSource::Path {
11380 caminho: "../caixa-teia/$(date)/build".into(),
11381 });
11382 let err = d.validate().unwrap_err();
11383 let DepError::FonteCaminhoShellSubshellGrouping {
11384 nome,
11385 caminho,
11386 byte,
11387 } = err
11388 else {
11389 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11390 };
11391 assert_eq!(nome, "caixa-teia");
11392 assert_eq!(caminho, "../caixa-teia/$(date)/build");
11393 assert_eq!(byte, b'(');
11394 }
11395
11396 #[test]
11397 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11398 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11399 // the degenerate "I selected an unbalanced closing paren out of
11400 // a shell-history block" idiom that probes for the cascade's
11401 // last-byte handling on a value carrying only the closing byte).
11402 // Pinned separately from the open-paren shape so the gate's
11403 // contract is "any `(` or `)` anywhere", not single-byte
11404 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11405 // caminho_carrying_question_glob` shape on the immediate-
11406 // predecessor `FonteCaminhoShellGlob` arm.
11407 let d = dep_with_fonte(DepSource::Path {
11408 caminho: "../caixa-teia)".into(),
11409 });
11410 let err = d.validate().unwrap_err();
11411 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11412 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11413 };
11414 assert_eq!(byte, b')');
11415 }
11416
11417 #[test]
11418 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11419 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11420 // canonical "I selected a `(cd foo)` subshell-grouping prefix
11421 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11422 // Pinned separately from the embedded-byte shape so the gate
11423 // covers every position, not only mid-path.
11424 let d = dep_with_fonte(DepSource::Path {
11425 caminho: "(cd foo)/caixa-teia".into(),
11426 });
11427 let err = d.validate().unwrap_err();
11428 assert!(
11429 matches!(
11430 err,
11431 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11432 ),
11433 "got {err:?}",
11434 );
11435 }
11436
11437 #[test]
11438 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11439 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11440 // — the canonical "I copied a `(pwd)` working-directory-probe
11441 // subshell-grouping idiom every shell-history block carries"
11442 // footgun). The value carries no other cascade-preceding
11443 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11444 // `*` / `?`) so the arm fires on the first `(` encountered;
11445 // pinned so a future arm that tries to distinguish the
11446 // opening from the closing byte doesn't break the broader
11447 // contract. Mirrors the peer
11448 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11449 // backtick_pair` shape on the upstream `FonteCaminhoShell\
11450 // CommandSubstitution` arm.
11451 let d = dep_with_fonte(DepSource::Path {
11452 caminho: "../(pwd)/caixa-teia".into(),
11453 });
11454 let err = d.validate().unwrap_err();
11455 assert!(
11456 matches!(
11457 err,
11458 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11459 ),
11460 "got {err:?}",
11461 );
11462 }
11463
11464 #[test]
11465 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11466 // The positive-control pin: the gate targets only `(` / `)`,
11467 // never adjacent printable ASCII or POSIX-valid bytes. The
11468 // canonical relative POSIX path (`"../caixa-teia"`) and a
11469 // nested deeply-pathed variant with adjacent printable
11470 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11471 // validate cleanly so the gate doesn't widen to a "no printable
11472 // punctuation anywhere" sweep that would defeat the entire
11473 // path-fonte author surface.
11474 let d = dep_with_fonte(DepSource::Path {
11475 caminho: "../caixa-teia/sub-dir.v2".into(),
11476 });
11477 d.validate().unwrap();
11478 }
11479
11480 #[test]
11481 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11482 // Cascade pin on the immediate-predecessor arm: a value
11483 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11484 // canonical "I pasted a glob expansion followed by a
11485 // subshell-grouping tail" footgun) routes through
11486 // `FonteCaminhoShellGlob` not
11487 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11488 // shape is the more common shell-history paste idiom on every
11489 // probe-as-both value — same cascade discipline every prior
11490 // `:caminho` arm establishes.
11491 let d = dep_with_fonte(DepSource::Path {
11492 caminho: "../caixa-teia/*(date)".into(),
11493 });
11494 let err = d.validate().unwrap_err();
11495 assert!(
11496 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11497 "got {err:?}",
11498 );
11499 }
11500
11501 #[test]
11502 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11503 // Cascade pin on the upstream shell-command-substitution arm: a
11504 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11505 // — the canonical "I pasted a legacy-backtick + modern-paren
11506 // command-substitution chain" footgun) routes through
11507 // `FonteCaminhoShellCommandSubstitution` not
11508 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11509 // command-injection vector is the load-bearing root-cause edit
11510 // on every probe-as-both value.
11511 let d = dep_with_fonte(DepSource::Path {
11512 caminho: "../`whoami`/$(date)".into(),
11513 });
11514 let err = d.validate().unwrap_err();
11515 assert!(
11516 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11517 "got {err:?}",
11518 );
11519 }
11520
11521 #[test]
11522 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11523 // Cascade pin on the upstream shell-background arm: a value
11524 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11525 // the canonical "I pasted a `cmd & (cd foo)` background-launch
11526 // + subshell-grouping chain" footgun) routes through
11527 // `FonteCaminhoShellBackground` not
11528 // `FonteCaminhoShellSubshellGrouping`. The background-launch
11529 // tail is the load-bearing root-cause edit on every probe-as-
11530 // both value.
11531 let d = dep_with_fonte(DepSource::Path {
11532 caminho: "../caixa-teia & (cd foo)".into(),
11533 });
11534 let err = d.validate().unwrap_err();
11535 assert!(
11536 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11537 "got {err:?}",
11538 );
11539 }
11540
11541 #[test]
11542 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11543 // Cascade pin on the upstream shell-semicolon arm: a value
11544 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11545 // the canonical sequential-cleanup + subshell-grouping paste
11546 // idiom) routes through `FonteCaminhoShellSemicolon` not
11547 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11548 // separator paste is the load-bearing root-cause edit on
11549 // every probe-as-both value.
11550 let d = dep_with_fonte(DepSource::Path {
11551 caminho: "../caixa-teia; (cd foo)".into(),
11552 });
11553 let err = d.validate().unwrap_err();
11554 assert!(
11555 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11556 "got {err:?}",
11557 );
11558 }
11559
11560 #[test]
11561 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11562 // Cascade pin on the upstream shell-pipe arm: a value carrying
11563 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11564 // canonical pipeline-to-subshell-grouping paste idiom) routes
11565 // through `FonteCaminhoShellPipe` not
11566 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11567 // is the load-bearing root-cause edit on every probe-as-both
11568 // value.
11569 let d = dep_with_fonte(DepSource::Path {
11570 caminho: "../caixa-teia | (tee log)".into(),
11571 });
11572 let err = d.validate().unwrap_err();
11573 assert!(
11574 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11575 "got {err:?}",
11576 );
11577 }
11578
11579 #[test]
11580 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11581 // Cascade pin on the upstream shell-redirection arm: a value
11582 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11583 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11584 // plus-subshell-grouping chain" footgun) routes through
11585 // `FonteCaminhoShellRedirection` not
11586 // `FonteCaminhoShellSubshellGrouping`. The input/output
11587 // redirection metachar carries the more self-locating `byte`
11588 // payload (it names which of `<` or `>` triggered), so the
11589 // prior arm wins on every probe-as-both value.
11590 let d = dep_with_fonte(DepSource::Path {
11591 caminho: "../caixa-teia>log (cd foo)".into(),
11592 });
11593 let err = d.validate().unwrap_err();
11594 assert!(
11595 matches!(
11596 err,
11597 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11598 ),
11599 "got {err:?}",
11600 );
11601 }
11602
11603 #[test]
11604 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11605 // Cascade pin on the upstream backslash arm: a value carrying
11606 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11607 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11608 // through `FonteCaminhoBackslash` not
11609 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11610 // separator divergence is the load-bearing axis on every
11611 // probe-as-both value (an author who removes the `\` is the
11612 // root-cause edit; the `(` falls away in the same edit since
11613 // it's downstream of the Windows-shell convention).
11614 let d = dep_with_fonte(DepSource::Path {
11615 caminho: "..\\caixa-teia\\(cd foo)".into(),
11616 });
11617 let err = d.validate().unwrap_err();
11618 assert!(
11619 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11620 "got {err:?}",
11621 );
11622 }
11623
11624 #[test]
11625 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11626 // Cascade pin on the embedded-control-byte arm: a value
11627 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11628 // the canonical paste-from-multiline-doc footgun where a
11629 // newline landed mid-caminho between two paste fragments)
11630 // routes through `FonteCaminhoControlChar` not
11631 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11632 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11633 // load-bearing axis on every value that probes positive for
11634 // both — mirrors the cascade discipline on every prior arm.
11635 let d = dep_with_fonte(DepSource::Path {
11636 caminho: "../foo\n(cd bar)".into(),
11637 });
11638 let err = d.validate().unwrap_err();
11639 assert!(
11640 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11641 "got {err:?}",
11642 );
11643 }
11644
11645 #[test]
11646 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11647 // Cascade pin on the load-bearing leading-byte arm: a leading
11648 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11649 // through `FonteCaminhoAbsolute` not
11650 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11651 // diagnostic is the load-bearing axis, the subshell-grouping
11652 // byte is the secondary observation. Same precedence logic as
11653 // every prior leading-byte arm.
11654 let d = dep_with_fonte(DepSource::Path {
11655 caminho: "/etc/(cd foo)".into(),
11656 });
11657 let err = d.validate().unwrap_err();
11658 assert!(
11659 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11660 "got {err:?}",
11661 );
11662 }
11663
11664 #[test]
11665 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11666 // Cascade pin on the upstream leading-`$` var-expansion arm: a
11667 // value carrying both a leading `$` and a `(` (`"$(date)/\
11668 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11669 // command-substitution at the head of a sibling-workspace
11670 // path" footgun) routes through `FonteCaminhoVarExpansion` not
11671 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11672 // shell-variable-expansion is the more self-locating diagnostic
11673 // on values that probe as both — same load-bearing-leading-
11674 // byte cascade discipline every prior `:caminho` arm
11675 // establishes. Closing both halves of `$(<cmd>)` structurally
11676 // (leading `$` here, trailing `)` on the new arm) excludes the
11677 // entire modern Bourne command-substitution surface from the
11678 // typed `:caminho` accepted set; the cascade preserves the
11679 // narrower leading-byte diagnostic on values that probe both
11680 // halves at the canonical leading position.
11681 let d = dep_with_fonte(DepSource::Path {
11682 caminho: "$(date)/caixa-teia".into(),
11683 });
11684 let err = d.validate().unwrap_err();
11685 assert!(
11686 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11687 "got {err:?}",
11688 );
11689 }
11690
11691 #[test]
11692 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11693 // Cascade pin on the immediate-successor arm: a value carrying
11694 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11695 // "I tab-completed a path that already had a subshell-grouping
11696 // expansion tail" footgun) routes through
11697 // `FonteCaminhoShellSubshellGrouping` not
11698 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11699 // the more semantic-locating axis (an author who removes the
11700 // `(` typically also drops the trailing separator since both
11701 // are paste-from-shell artifacts).
11702 let d = dep_with_fonte(DepSource::Path {
11703 caminho: "../(cd foo)/".into(),
11704 });
11705 let err = d.validate().unwrap_err();
11706 assert!(
11707 matches!(
11708 err,
11709 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11710 ),
11711 "got {err:?}",
11712 );
11713 }
11714
11715 #[test]
11716 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11717 // Diagnostic-shape pin (peer with
11718 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11719 // on the closest two-byte peer arm): the error's Display
11720 // surfaces the offending `:nome`, the offending `:caminho`
11721 // verbatim, the offending byte's hex / character form, and
11722 // names the shell-subshell-grouping footgun explicitly so a
11723 // `feira lint` run can render the diagnostic without re-
11724 // parsing.
11725 let d = dep_with_fonte(DepSource::Path {
11726 caminho: "../caixa-teia/$(date)/build".into(),
11727 });
11728 let rendered = d.validate().unwrap_err().to_string();
11729 assert!(
11730 rendered.contains("caixa-teia"),
11731 "diagnostic must name the offending dep: {rendered}",
11732 );
11733 assert!(
11734 rendered.contains("../caixa-teia/$(date)/build"),
11735 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11736 );
11737 assert!(
11738 rendered.contains("0x28"),
11739 "diagnostic must surface the offending byte hex: {rendered:?}",
11740 );
11741 assert!(
11742 rendered.contains("subshell-grouping"),
11743 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
11744 );
11745 assert!(
11746 rendered.contains("command-substitution"),
11747 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
11748 {rendered:?}",
11749 );
11750 }
11751
11752 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
11753 //
11754 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
11755 // `)`) byte-pair arm: the same per-byte cascade with the same
11756 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
11757 // `}` brace-expansion / URI-Template placeholder axis. The peer
11758 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
11759 // byte pair on the sibling `:fonte :repo` axis under the same
11760 // banner.
11761
11762 #[test]
11763 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
11764 // The fail-before-pass-after pin for the canonical paste-from-
11765 // shell-history brace-expansion footgun: an author copies a
11766 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
11767 // liner whose `{a,b}` brace expansion fans across two siblings
11768 // and silently passed every prior arm (`Path::is_absolute`
11769 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
11770 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
11771 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
11772 // `FonteCaminhoVarExpansion` arm doesn't fire because the
11773 // value starts with `..` not `$`). The lacre embedded the
11774 // value verbatim, the resolver folded it through `Path::join`
11775 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
11776 // subdirectory, and the failure surfaced at resolve time with
11777 // a non-self-locating `No such file or directory` error. The
11778 // new arm moves the rejection to validate time and names the
11779 // offending dep + caminho + byte verbatim. The arm fires on
11780 // the first `{` encountered.
11781 let d = dep_with_fonte(DepSource::Path {
11782 caminho: "../{caixa-teia,caixa-helm}/build".into(),
11783 });
11784 let err = d.validate().unwrap_err();
11785 let DepError::FonteCaminhoShellBraceExpansion {
11786 nome,
11787 caminho,
11788 byte,
11789 } = err
11790 else {
11791 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11792 };
11793 assert_eq!(nome, "caixa-teia");
11794 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
11795 assert_eq!(byte, b'{');
11796 }
11797
11798 #[test]
11799 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
11800 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
11801 // the degenerate "I selected an unbalanced closing brace out
11802 // of a shell-history block" idiom that probes for the
11803 // cascade's last-byte handling on a value carrying only the
11804 // closing byte). Pinned separately from the open-brace shape
11805 // so the gate's contract is "any `{` or `}` anywhere", not
11806 // single-byte coverage. Mirrors the peer
11807 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
11808 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
11809 // arm.
11810 let d = dep_with_fonte(DepSource::Path {
11811 caminho: "../caixa-teia}".into(),
11812 });
11813 let err = d.validate().unwrap_err();
11814 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
11815 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
11816 };
11817 assert_eq!(byte, b'}');
11818 }
11819
11820 #[test]
11821 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
11822 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
11823 // — the canonical "I selected a `{a,b}` brace-expansion prefix
11824 // out of a shell-history one-liner" idiom). Pinned separately
11825 // from the embedded-byte shape so the gate covers every
11826 // position, not only mid-path.
11827 let d = dep_with_fonte(DepSource::Path {
11828 caminho: "{caixa-teia,caixa-helm}/build".into(),
11829 });
11830 let err = d.validate().unwrap_err();
11831 assert!(
11832 matches!(
11833 err,
11834 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11835 ),
11836 "got {err:?}",
11837 );
11838 }
11839
11840 #[test]
11841 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
11842 // The canonical URI-Template / Mustache / Helm doubled-brace
11843 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
11844 // "I copied a `https://github.com/{{org}}/caixa-teia` README
11845 // quick-start / OpenAPI spec / Helm chart `home:` template
11846 // and forgot to substitute the placeholder" footgun). The arm
11847 // fires on the first `{` encountered; pinned so the gate's
11848 // coverage extends from the bare-brace shell-history shape to
11849 // the doubled-brace URI-Template / templating-engine shape.
11850 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
11851 // sibling `:fonte :repo` axis.
11852 let d = dep_with_fonte(DepSource::Path {
11853 caminho: "../{{org}}/caixa-teia".into(),
11854 });
11855 let err = d.validate().unwrap_err();
11856 assert!(
11857 matches!(
11858 err,
11859 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11860 ),
11861 "got {err:?}",
11862 );
11863 }
11864
11865 #[test]
11866 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
11867 // The canonical bash brace-range-expansion shape (`"../caixa-
11868 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
11869 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
11870 // sequence-range form to the `{a,b,c}` comma-separated form).
11871 // The arm fires on the first `{` encountered; pinned so the
11872 // gate's coverage extends from the comma-separated form to
11873 // the integer-range form.
11874 let d = dep_with_fonte(DepSource::Path {
11875 caminho: "../caixa-v{1..10}".into(),
11876 });
11877 let err = d.validate().unwrap_err();
11878 assert!(
11879 matches!(
11880 err,
11881 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
11882 ),
11883 "got {err:?}",
11884 );
11885 }
11886
11887 #[test]
11888 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
11889 // The positive-control pin: the gate targets only `{` / `}`,
11890 // never adjacent printable ASCII or POSIX-valid bytes. The
11891 // canonical relative POSIX path (`"../caixa-teia"`) and a
11892 // nested deeply-pathed variant with adjacent printable
11893 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11894 // validate cleanly so the gate doesn't widen to a "no
11895 // printable punctuation anywhere" sweep that would defeat
11896 // the entire path-fonte author surface. Peer with
11897 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
11898 // on the immediate-predecessor arm.
11899 let d = dep_with_fonte(DepSource::Path {
11900 caminho: "../caixa-teia/sub-dir.v2".into(),
11901 });
11902 d.validate().unwrap();
11903 }
11904
11905 #[test]
11906 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
11907 // Cascade pin on the immediate-predecessor arm: a value
11908 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
11909 // canonical "I pasted a subshell-grouping followed by a
11910 // brace-expansion tail" footgun) routes through
11911 // `FonteCaminhoShellSubshellGrouping` not
11912 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
11913 // shape is the more semantic-locating axis on every probe-
11914 // as-both value because it closes both halves of the modern
11915 // Bourne `$(<cmd>)` command-substitution surface — same
11916 // cascade discipline every prior `:caminho` arm establishes.
11917 let d = dep_with_fonte(DepSource::Path {
11918 caminho: "../(cd foo)/{a,b}".into(),
11919 });
11920 let err = d.validate().unwrap_err();
11921 assert!(
11922 matches!(
11923 err,
11924 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11925 ),
11926 "got {err:?}",
11927 );
11928 }
11929
11930 #[test]
11931 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
11932 // Cascade pin on the upstream shell-glob arm: a value carrying
11933 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
11934 // "I pasted a glob expansion followed by a brace-expansion
11935 // tail" footgun) routes through `FonteCaminhoShellGlob` not
11936 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
11937 // shape is the load-bearing root-cause edit on every
11938 // probe-as-both value.
11939 let d = dep_with_fonte(DepSource::Path {
11940 caminho: "../caixa-teia/*{a,b}".into(),
11941 });
11942 let err = d.validate().unwrap_err();
11943 assert!(
11944 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11945 "got {err:?}",
11946 );
11947 }
11948
11949 #[test]
11950 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
11951 // Cascade pin on the upstream shell-command-substitution arm:
11952 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
11953 // — the canonical "I pasted a legacy-backtick command-
11954 // substitution followed by a brace-expansion fan-out" footgun)
11955 // routes through `FonteCaminhoShellCommandSubstitution` not
11956 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
11957 // command-injection vector is the load-bearing root-cause
11958 // edit on every probe-as-both value.
11959 let d = dep_with_fonte(DepSource::Path {
11960 caminho: "../`whoami`/{a,b}".into(),
11961 });
11962 let err = d.validate().unwrap_err();
11963 assert!(
11964 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11965 "got {err:?}",
11966 );
11967 }
11968
11969 #[test]
11970 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
11971 // Cascade pin on the upstream shell-background arm: a value
11972 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
11973 // canonical "I pasted a `cmd & {fork-fan}` background-launch
11974 // + brace-expansion chain" footgun) routes through
11975 // `FonteCaminhoShellBackground` not
11976 // `FonteCaminhoShellBraceExpansion`. The background-launch
11977 // tail is the load-bearing root-cause edit on every
11978 // probe-as-both value.
11979 let d = dep_with_fonte(DepSource::Path {
11980 caminho: "../caixa-teia & {a,b}".into(),
11981 });
11982 let err = d.validate().unwrap_err();
11983 assert!(
11984 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11985 "got {err:?}",
11986 );
11987 }
11988
11989 #[test]
11990 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
11991 // Cascade pin on the upstream shell-semicolon arm: a value
11992 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
11993 // canonical sequential-cleanup + brace-expansion paste
11994 // idiom) routes through `FonteCaminhoShellSemicolon` not
11995 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
11996 // separator paste is the load-bearing root-cause edit on
11997 // every probe-as-both value.
11998 let d = dep_with_fonte(DepSource::Path {
11999 caminho: "../caixa-teia; {a,b}".into(),
12000 });
12001 let err = d.validate().unwrap_err();
12002 assert!(
12003 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12004 "got {err:?}",
12005 );
12006 }
12007
12008 #[test]
12009 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12010 // Cascade pin on the upstream shell-pipe arm: a value
12011 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12012 // — the canonical pipeline-to-brace-expansion paste idiom)
12013 // routes through `FonteCaminhoShellPipe` not
12014 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12015 // is the load-bearing root-cause edit on every probe-as-
12016 // both value.
12017 let d = dep_with_fonte(DepSource::Path {
12018 caminho: "../caixa-teia | {tee,cat}".into(),
12019 });
12020 let err = d.validate().unwrap_err();
12021 assert!(
12022 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12023 "got {err:?}",
12024 );
12025 }
12026
12027 #[test]
12028 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12029 // Cascade pin on the upstream shell-redirection arm: a value
12030 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12031 // the canonical "I pasted a `cmd > log {a,b}` redirect-
12032 // plus-brace-expansion chain" footgun) routes through
12033 // `FonteCaminhoShellRedirection` not
12034 // `FonteCaminhoShellBraceExpansion`. The input/output
12035 // redirection metachar carries the more self-locating
12036 // `byte` payload, so the prior arm wins on every probe-
12037 // as-both value.
12038 let d = dep_with_fonte(DepSource::Path {
12039 caminho: "../caixa-teia>log {a,b}".into(),
12040 });
12041 let err = d.validate().unwrap_err();
12042 assert!(
12043 matches!(
12044 err,
12045 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12046 ),
12047 "got {err:?}",
12048 );
12049 }
12050
12051 #[test]
12052 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12053 // Cascade pin on the upstream backslash arm: a value
12054 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12055 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12056 // chain") routes through `FonteCaminhoBackslash` not
12057 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12058 // separator divergence is the load-bearing axis on every
12059 // probe-as-both value.
12060 let d = dep_with_fonte(DepSource::Path {
12061 caminho: "..\\caixa-teia\\{a,b}".into(),
12062 });
12063 let err = d.validate().unwrap_err();
12064 assert!(
12065 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12066 "got {err:?}",
12067 );
12068 }
12069
12070 #[test]
12071 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12072 // Cascade pin on the embedded-control-byte arm: a value
12073 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12074 // the canonical paste-from-multiline-doc footgun where a
12075 // newline landed mid-caminho between two paste fragments)
12076 // routes through `FonteCaminhoControlChar` not
12077 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12078 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12079 // load-bearing axis on every value that probes positive for
12080 // both — mirrors the cascade discipline on every prior arm.
12081 let d = dep_with_fonte(DepSource::Path {
12082 caminho: "../foo\n{a,b}".into(),
12083 });
12084 let err = d.validate().unwrap_err();
12085 assert!(
12086 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12087 "got {err:?}",
12088 );
12089 }
12090
12091 #[test]
12092 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12093 // Cascade pin on the load-bearing leading-byte arm: a
12094 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12095 // routes through `FonteCaminhoAbsolute` not
12096 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12097 // diagnostic is the load-bearing axis, the brace-expansion
12098 // byte is the secondary observation. Same precedence logic
12099 // as every prior leading-byte arm.
12100 let d = dep_with_fonte(DepSource::Path {
12101 caminho: "/etc/{a,b}".into(),
12102 });
12103 let err = d.validate().unwrap_err();
12104 assert!(
12105 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12106 "got {err:?}",
12107 );
12108 }
12109
12110 #[test]
12111 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12112 // Cascade pin on the upstream leading-`$` var-expansion
12113 // arm: a value carrying both a leading `$` and a `{`
12114 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12115 // `${ORG}` shell-variable + curly-brace expansion at the
12116 // head of a sibling-workspace path" footgun) routes through
12117 // `FonteCaminhoVarExpansion` not
12118 // `FonteCaminhoShellBraceExpansion`. The leading-byte
12119 // shell-variable-expansion is the more self-locating
12120 // diagnostic on values that probe as both — same
12121 // load-bearing-leading-byte cascade discipline every prior
12122 // `:caminho` arm establishes.
12123 let d = dep_with_fonte(DepSource::Path {
12124 caminho: "${ORG}/caixa-teia".into(),
12125 });
12126 let err = d.validate().unwrap_err();
12127 assert!(
12128 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12129 "got {err:?}",
12130 );
12131 }
12132
12133 #[test]
12134 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12135 // Cascade pin on the immediate-successor arm: a value
12136 // carrying both `{` and a trailing `/`
12137 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12138 // tab-completed a path that already had a brace-expansion
12139 // expansion tail" footgun) routes through
12140 // `FonteCaminhoShellBraceExpansion` not
12141 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12142 // is the more semantic-locating axis (an author who removes
12143 // the `{` typically also drops the trailing separator since
12144 // both are paste-from-shell artifacts).
12145 let d = dep_with_fonte(DepSource::Path {
12146 caminho: "../{caixa-teia,caixa-helm}/".into(),
12147 });
12148 let err = d.validate().unwrap_err();
12149 assert!(
12150 matches!(
12151 err,
12152 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12153 ),
12154 "got {err:?}",
12155 );
12156 }
12157
12158 #[test]
12159 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12160 // Diagnostic-shape pin (peer with
12161 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12162 // on the closest two-byte peer arm): the error's Display
12163 // surfaces the offending `:nome`, the offending `:caminho`
12164 // verbatim, the offending byte's hex / character form, and
12165 // names the shell-brace-expansion / URI-Template footgun
12166 // explicitly so a `feira lint` run can render the diagnostic
12167 // without re-parsing.
12168 let d = dep_with_fonte(DepSource::Path {
12169 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12170 });
12171 let rendered = d.validate().unwrap_err().to_string();
12172 assert!(
12173 rendered.contains("caixa-teia"),
12174 "diagnostic must name the offending dep: {rendered}",
12175 );
12176 assert!(
12177 rendered.contains("../{caixa-teia,caixa-helm}/build"),
12178 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12179 );
12180 assert!(
12181 rendered.contains("0x7b"),
12182 "diagnostic must surface the offending byte hex: {rendered:?}",
12183 );
12184 assert!(
12185 rendered.contains("brace-expansion"),
12186 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12187 );
12188 assert!(
12189 rendered.contains("URI Template"),
12190 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12191 {rendered:?}",
12192 );
12193 }
12194
12195 #[test]
12196 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12197 // The canonical paste-from-shell-history bracket-glob /
12198 // character-class footgun: an author copies a
12199 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12200 // `[a-z]` POSIX glob character-class matches every lowercase-
12201 // ASCII-suffix sibling caixa directory and silently passed
12202 // every prior arm (`Path::is_absolute` false on `..`, no
12203 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12204 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12205 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12206 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12207 // value starts with `..` not `$`). The lacre embedded the
12208 // value verbatim, the resolver folded it through
12209 // `Path::join` looking for a literal `./../caixa-[a-z]/
12210 // build` subdirectory, and the failure surfaced at resolve
12211 // time with a non-self-locating `No such file or directory`
12212 // error. The new arm moves the rejection to validate time
12213 // and names the offending dep + caminho + byte verbatim.
12214 // The arm fires on the first `[` encountered.
12215 let d = dep_with_fonte(DepSource::Path {
12216 caminho: "../caixa-[a-z]/build".into(),
12217 });
12218 let err = d.validate().unwrap_err();
12219 let DepError::FonteCaminhoShellBracketExpansion {
12220 nome,
12221 caminho,
12222 byte,
12223 } = err
12224 else {
12225 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12226 };
12227 assert_eq!(nome, "caixa-teia");
12228 assert_eq!(caminho, "../caixa-[a-z]/build");
12229 assert_eq!(byte, b'[');
12230 }
12231
12232 #[test]
12233 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12234 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12235 // — the degenerate "I selected an unbalanced closing bracket
12236 // out of a glob character-class block" idiom that probes for
12237 // the cascade's last-byte handling on a value carrying only
12238 // the closing byte). Pinned separately from the open-bracket
12239 // shape so the gate's contract is "any `[` or `]` anywhere",
12240 // not single-byte coverage. Mirrors the peer
12241 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12242 // shape on the immediate-predecessor
12243 // `FonteCaminhoShellBraceExpansion` arm.
12244 let d = dep_with_fonte(DepSource::Path {
12245 caminho: "../caixa-teia]".into(),
12246 });
12247 let err = d.validate().unwrap_err();
12248 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12249 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12250 };
12251 assert_eq!(byte, b']');
12252 }
12253
12254 #[test]
12255 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12256 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12257 // canonical "I selected a `[caixa-teia]` TOML-table-header /
12258 // glob-character-class prefix out of an aligned config /
12259 // shell-history one-liner" idiom). Pinned separately from
12260 // the embedded-byte shape so the gate covers every position,
12261 // not only mid-path.
12262 let d = dep_with_fonte(DepSource::Path {
12263 caminho: "[caixa-teia]/build".into(),
12264 });
12265 let err = d.validate().unwrap_err();
12266 assert!(
12267 matches!(
12268 err,
12269 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12270 ),
12271 "got {err:?}",
12272 );
12273 }
12274
12275 #[test]
12276 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12277 // The canonical TOML inline-array / YAML flow-sequence
12278 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12279 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12280 // inline-array out of a sibling-Cargo manifest" cross-idiom
12281 // leak; the symmetric YAML flow-sequence form `paths: [/a,
12282 // /b]` paste-from-values.yaml shape carries the same
12283 // bracket pair). The arm fires on the first `[` encountered;
12284 // pinned so the gate's coverage extends from the bare-
12285 // bracket glob-character-class shape to the TOML / YAML /
12286 // JSON array-literal shape.
12287 let d = dep_with_fonte(DepSource::Path {
12288 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12289 });
12290 let err = d.validate().unwrap_err();
12291 assert!(
12292 matches!(
12293 err,
12294 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12295 ),
12296 "got {err:?}",
12297 );
12298 }
12299
12300 #[test]
12301 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12302 // The canonical POSIX `test` / `[` builtin command paste
12303 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12304 // script conditional every paste-from-shell-script idiom
12305 // carries; bash's `[[ <expr> ]]` extended-test grammar
12306 // would surface the same byte pair). The arm fires on the
12307 // first `[` encountered; pinned so the gate's coverage
12308 // extends from the embedded-glob-character-class shape to
12309 // the leading-`test`-builtin / extended-test form.
12310 let d = dep_with_fonte(DepSource::Path {
12311 caminho: "../[ -d caixa-teia ]".into(),
12312 });
12313 let err = d.validate().unwrap_err();
12314 assert!(
12315 matches!(
12316 err,
12317 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12318 ),
12319 "got {err:?}",
12320 );
12321 }
12322
12323 #[test]
12324 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12325 // The positive-control pin: the gate targets only `[` /
12326 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12327 // The canonical relative POSIX path (`"../caixa-teia"`) and
12328 // a nested deeply-pathed variant with adjacent printable
12329 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12330 // to validate cleanly so the gate doesn't widen to a "no
12331 // printable punctuation anywhere" sweep that would defeat
12332 // the entire path-fonte author surface. Peer with
12333 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12334 // on the immediate-predecessor arm.
12335 let d = dep_with_fonte(DepSource::Path {
12336 caminho: "../caixa-teia/sub-dir.v2".into(),
12337 });
12338 d.validate().unwrap();
12339 }
12340
12341 #[test]
12342 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12343 // Cascade pin on the immediate-predecessor arm: a value
12344 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12345 // canonical "I pasted a brace-expansion fan followed by a
12346 // glob-character-class tail" footgun) routes through
12347 // `FonteCaminhoShellBraceExpansion` not
12348 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12349 // fan is the load-bearing root-cause edit on every
12350 // probe-as-both value because the bracket-class tail
12351 // typically rides on a prior brace-expansion expansion;
12352 // same cascade discipline every prior `:caminho` arm
12353 // establishes.
12354 let d = dep_with_fonte(DepSource::Path {
12355 caminho: "../{a,b}[ch]".into(),
12356 });
12357 let err = d.validate().unwrap_err();
12358 assert!(
12359 matches!(
12360 err,
12361 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12362 ),
12363 "got {err:?}",
12364 );
12365 }
12366
12367 #[test]
12368 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12369 // Cascade pin on the upstream shell-subshell-grouping arm:
12370 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12371 // the canonical "I pasted a subshell-grouping followed by
12372 // a glob-character-class tail" footgun) routes through
12373 // `FonteCaminhoShellSubshellGrouping` not
12374 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12375 // `$(<cmd>)` command-substitution boundary is the load-
12376 // bearing axis on every probe-as-both value.
12377 let d = dep_with_fonte(DepSource::Path {
12378 caminho: "../(cd foo)/[ch]".into(),
12379 });
12380 let err = d.validate().unwrap_err();
12381 assert!(
12382 matches!(
12383 err,
12384 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12385 ),
12386 "got {err:?}",
12387 );
12388 }
12389
12390 #[test]
12391 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12392 // Cascade pin on the upstream shell-glob arm: a value
12393 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12394 // canonical "I pasted a `*.[ch]` C-source-file glob whose
12395 // unbounded `*` precedes the bracket character-class"
12396 // footgun) routes through `FonteCaminhoShellGlob` not
12397 // `FonteCaminhoShellBracketExpansion`. The unbounded
12398 // pathname-expansion sentinel is the load-bearing root-
12399 // cause edit on every probe-as-both value — the unbounded
12400 // `*` carries the more aggressive expansion vector than
12401 // the bounded `[ch]` class, so the prior arm wins.
12402 let d = dep_with_fonte(DepSource::Path {
12403 caminho: "../caixa-teia/*[ch]".into(),
12404 });
12405 let err = d.validate().unwrap_err();
12406 assert!(
12407 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12408 "got {err:?}",
12409 );
12410 }
12411
12412 #[test]
12413 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12414 // Cascade pin on the upstream shell-command-substitution
12415 // arm: a value carrying both a backtick and `[`
12416 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12417 // legacy-backtick command-substitution followed by a
12418 // glob-character-class tail" footgun) routes through
12419 // `FonteCaminhoShellCommandSubstitution` not
12420 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12421 // command-injection vector is the load-bearing root-cause
12422 // edit on every probe-as-both value.
12423 let d = dep_with_fonte(DepSource::Path {
12424 caminho: "../`whoami`/[ch]".into(),
12425 });
12426 let err = d.validate().unwrap_err();
12427 assert!(
12428 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12429 "got {err:?}",
12430 );
12431 }
12432
12433 #[test]
12434 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12435 // Cascade pin on the upstream shell-background arm: a
12436 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12437 // — the canonical "I pasted a `cmd & [glob]` background-
12438 // launch + bracket-class chain" footgun) routes through
12439 // `FonteCaminhoShellBackground` not
12440 // `FonteCaminhoShellBracketExpansion`. The background-
12441 // launch tail is the load-bearing root-cause edit on
12442 // every probe-as-both value.
12443 let d = dep_with_fonte(DepSource::Path {
12444 caminho: "../caixa-teia & [ch]".into(),
12445 });
12446 let err = d.validate().unwrap_err();
12447 assert!(
12448 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12449 "got {err:?}",
12450 );
12451 }
12452
12453 #[test]
12454 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12455 // Cascade pin on the upstream shell-semicolon arm: a value
12456 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12457 // canonical sequential-cleanup + bracket-class paste
12458 // idiom) routes through `FonteCaminhoShellSemicolon` not
12459 // `FonteCaminhoShellBracketExpansion`. The sequential-
12460 // command-separator paste is the load-bearing root-cause
12461 // edit on every probe-as-both value.
12462 let d = dep_with_fonte(DepSource::Path {
12463 caminho: "../caixa-teia; [ch]".into(),
12464 });
12465 let err = d.validate().unwrap_err();
12466 assert!(
12467 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12468 "got {err:?}",
12469 );
12470 }
12471
12472 #[test]
12473 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12474 // Cascade pin on the upstream shell-pipe arm: a value
12475 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12476 // the canonical pipeline-to-bracket-class paste idiom)
12477 // routes through `FonteCaminhoShellPipe` not
12478 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12479 // paste is the load-bearing root-cause edit on every
12480 // probe-as-both value.
12481 let d = dep_with_fonte(DepSource::Path {
12482 caminho: "../caixa-teia | [tee]".into(),
12483 });
12484 let err = d.validate().unwrap_err();
12485 assert!(
12486 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12487 "got {err:?}",
12488 );
12489 }
12490
12491 #[test]
12492 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12493 // Cascade pin on the upstream shell-redirection arm: a
12494 // value carrying both `>` and `[` (`"../caixa-teia>log
12495 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12496 // redirect-plus-bracket chain" footgun) routes through
12497 // `FonteCaminhoShellRedirection` not
12498 // `FonteCaminhoShellBracketExpansion`. The input/output
12499 // redirection metachar carries the more self-locating
12500 // `byte` payload, so the prior arm wins on every
12501 // probe-as-both value.
12502 let d = dep_with_fonte(DepSource::Path {
12503 caminho: "../caixa-teia>log [ch]".into(),
12504 });
12505 let err = d.validate().unwrap_err();
12506 assert!(
12507 matches!(
12508 err,
12509 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12510 ),
12511 "got {err:?}",
12512 );
12513 }
12514
12515 #[test]
12516 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12517 // Cascade pin on the upstream backslash arm: a value
12518 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12519 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12520 // chain") routes through `FonteCaminhoBackslash` not
12521 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12522 // separator divergence is the load-bearing axis on every
12523 // probe-as-both value.
12524 let d = dep_with_fonte(DepSource::Path {
12525 caminho: "..\\caixa-teia\\[ch]".into(),
12526 });
12527 let err = d.validate().unwrap_err();
12528 assert!(
12529 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12530 "got {err:?}",
12531 );
12532 }
12533
12534 #[test]
12535 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12536 // Cascade pin on the embedded-control-byte arm: a value
12537 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12538 // the canonical paste-from-multiline-doc footgun where a
12539 // newline landed mid-caminho between two paste fragments)
12540 // routes through `FonteCaminhoControlChar` not
12541 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12542 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12543 // the load-bearing axis on every value that probes
12544 // positive for both — mirrors the cascade discipline on
12545 // every prior arm.
12546 let d = dep_with_fonte(DepSource::Path {
12547 caminho: "../foo\n[ch]".into(),
12548 });
12549 let err = d.validate().unwrap_err();
12550 assert!(
12551 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12552 "got {err:?}",
12553 );
12554 }
12555
12556 #[test]
12557 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12558 // Cascade pin on the load-bearing leading-byte arm: a
12559 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12560 // routes through `FonteCaminhoAbsolute` not
12561 // `FonteCaminhoShellBracketExpansion` — the host-layout-
12562 // leak diagnostic is the load-bearing axis, the bracket-
12563 // expansion byte is the secondary observation. Same
12564 // precedence logic as every prior leading-byte arm.
12565 let d = dep_with_fonte(DepSource::Path {
12566 caminho: "/etc/[ch]".into(),
12567 });
12568 let err = d.validate().unwrap_err();
12569 assert!(
12570 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12571 "got {err:?}",
12572 );
12573 }
12574
12575 #[test]
12576 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12577 // Cascade pin on the upstream leading-`$` var-expansion
12578 // arm: a value carrying both a leading `$` and a `[`
12579 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12580 // variable + bracket-class at the head of a sibling-
12581 // workspace path" footgun) routes through
12582 // `FonteCaminhoVarExpansion` not
12583 // `FonteCaminhoShellBracketExpansion`. The leading-byte
12584 // shell-variable-expansion is the more self-locating
12585 // diagnostic on values that probe as both — same
12586 // load-bearing-leading-byte cascade discipline every
12587 // prior `:caminho` arm establishes.
12588 let d = dep_with_fonte(DepSource::Path {
12589 caminho: "$DIR/[ch]".into(),
12590 });
12591 let err = d.validate().unwrap_err();
12592 assert!(
12593 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12594 "got {err:?}",
12595 );
12596 }
12597
12598 #[test]
12599 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12600 // Cascade pin on the immediate-successor arm: a value
12601 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12602 // the canonical "I tab-completed a path that already had
12603 // a bracket-glob-character-class expansion tail" footgun)
12604 // routes through `FonteCaminhoShellBracketExpansion` not
12605 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12606 // is the more semantic-locating axis (an author who
12607 // removes the `[` typically also drops the trailing
12608 // separator since both are paste-from-shell artifacts).
12609 let d = dep_with_fonte(DepSource::Path {
12610 caminho: "../[a-z]/".into(),
12611 });
12612 let err = d.validate().unwrap_err();
12613 assert!(
12614 matches!(
12615 err,
12616 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12617 ),
12618 "got {err:?}",
12619 );
12620 }
12621
12622 #[test]
12623 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12624 // Diagnostic-shape pin (peer with
12625 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12626 // on the closest two-byte peer arm): the error's Display
12627 // surfaces the offending `:nome`, the offending `:caminho`
12628 // verbatim, the offending byte's hex / character form, and
12629 // names the shell-bracket-expansion / glob-character-class
12630 // footgun explicitly so a `feira lint` run can render the
12631 // diagnostic without re-parsing.
12632 let d = dep_with_fonte(DepSource::Path {
12633 caminho: "../caixa-[a-z]/build".into(),
12634 });
12635 let rendered = d.validate().unwrap_err().to_string();
12636 assert!(
12637 rendered.contains("caixa-teia"),
12638 "diagnostic must name the offending dep: {rendered}",
12639 );
12640 assert!(
12641 rendered.contains("../caixa-[a-z]/build"),
12642 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12643 );
12644 assert!(
12645 rendered.contains("0x5b"),
12646 "diagnostic must surface the offending byte hex: {rendered:?}",
12647 );
12648 assert!(
12649 rendered.contains("bracket-expansion"),
12650 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12651 );
12652 assert!(
12653 rendered.contains("glob-character-class"),
12654 "diagnostic must reference the POSIX glob-character-class vocabulary: \
12655 {rendered:?}",
12656 );
12657 }
12658
12659 #[test]
12660 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12661 // The canonical paste-from-shell-history strong-quoted
12662 // sibling-workspace-path footgun: an author copies a
12663 // `cd '../caixa-teia'` shell-history one-liner whose strong-
12664 // quoting preserved the path across a whitespace paste
12665 // boundary and silently passed every prior arm
12666 // (`Path::is_absolute` false on `'..`, no control bytes, no
12667 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12668 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12669 // doesn't end in `/`; the leading-`$` f4efe9c
12670 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12671 // value starts with `'` not `$`). The lacre embedded the
12672 // value verbatim, the resolver folded it through
12673 // `Path::join` looking for a literal `./'../caixa-teia'`
12674 // subdirectory, and the failure surfaced at resolve time
12675 // with a non-self-locating `No such file or directory`
12676 // error. The new arm moves the rejection to validate time
12677 // and names the offending dep + caminho + byte verbatim.
12678 // The arm fires on the first `'` encountered.
12679 let d = dep_with_fonte(DepSource::Path {
12680 caminho: "'../caixa-teia'".into(),
12681 });
12682 let err = d.validate().unwrap_err();
12683 let DepError::FonteCaminhoShellQuoteGrouping {
12684 nome,
12685 caminho,
12686 byte,
12687 } = err
12688 else {
12689 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12690 };
12691 assert_eq!(nome, "caixa-teia");
12692 assert_eq!(caminho, "'../caixa-teia'");
12693 assert_eq!(byte, b'\'');
12694 }
12695
12696 #[test]
12697 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12698 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12699 // — the canonical paste-from-JSON-config / paste-from-YAML-
12700 // flow-scalar / paste-from-TOML-basic-string / paste-from-
12701 // tatara-lisp-string-literal cross-idiom leak). Pinned
12702 // separately from the single-quote shape so the gate's
12703 // contract is "any `'` or `\"` anywhere", not single-byte
12704 // coverage. Mirrors the peer
12705 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12706 // shape on the immediate-predecessor
12707 // `FonteCaminhoShellBracketExpansion` arm.
12708 let d = dep_with_fonte(DepSource::Path {
12709 caminho: "\"../caixa-teia\"".into(),
12710 });
12711 let err = d.validate().unwrap_err();
12712 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12713 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12714 };
12715 assert_eq!(byte, b'"');
12716 }
12717
12718 #[test]
12719 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12720 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
12721 // canonical "I pasted a JSON key-value pair fragment into
12722 // the middle of the path" idiom). Pinned separately from
12723 // the leading-byte shape so the gate covers every position,
12724 // not only leading.
12725 let d = dep_with_fonte(DepSource::Path {
12726 caminho: "../\"caixa-teia\"".into(),
12727 });
12728 let err = d.validate().unwrap_err();
12729 assert!(
12730 matches!(
12731 err,
12732 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12733 ),
12734 "got {err:?}",
12735 );
12736 }
12737
12738 #[test]
12739 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
12740 // The canonical YAML double-quoted flow-scalar cross-idiom
12741 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
12742 // `path: \"...\"` YAML flow-scalar entry out of an aligned
12743 // values.yaml / K8s manifest and dropped it verbatim into
12744 // the `:caminho` slot including the `path: ` key prefix"
12745 // paste-idiom). The arm fires on the first `"` encountered;
12746 // pinned so the gate's coverage extends from the bare-quote
12747 // paste shape to the aligned-YAML-manifest cross-idiom-leak
12748 // shape.
12749 let d = dep_with_fonte(DepSource::Path {
12750 caminho: "path: \"../caixa-teia\"".into(),
12751 });
12752 let err = d.validate().unwrap_err();
12753 assert!(
12754 matches!(
12755 err,
12756 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
12757 ),
12758 "got {err:?}",
12759 );
12760 }
12761
12762 #[test]
12763 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
12764 // The positive-control pin: the gate targets only `'` /
12765 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
12766 // The canonical relative POSIX path (`"../caixa-teia"`) and
12767 // a nested deeply-pathed variant with adjacent printable
12768 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12769 // to validate cleanly so the gate doesn't widen to a "no
12770 // printable punctuation anywhere" sweep that would defeat
12771 // the entire path-fonte author surface. Peer with
12772 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
12773 // on the immediate-predecessor arm.
12774 let d = dep_with_fonte(DepSource::Path {
12775 caminho: "../caixa-teia/sub-dir.v2".into(),
12776 });
12777 d.validate().unwrap();
12778 }
12779
12780 #[test]
12781 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
12782 // Cascade pin on the immediate-predecessor arm: a value
12783 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
12784 // "I pasted a glob-character-class followed by a strong-
12785 // quoted literal tail" footgun) routes through
12786 // `FonteCaminhoShellBracketExpansion` not
12787 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
12788 // expansion is the load-bearing root-cause edit on every
12789 // probe-as-both value; same cascade discipline every prior
12790 // `:caminho` arm establishes.
12791 let d = dep_with_fonte(DepSource::Path {
12792 caminho: "../[a-z]'x'".into(),
12793 });
12794 let err = d.validate().unwrap_err();
12795 assert!(
12796 matches!(
12797 err,
12798 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12799 ),
12800 "got {err:?}",
12801 );
12802 }
12803
12804 #[test]
12805 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
12806 // Cascade pin on the upstream shell-brace-expansion arm: a
12807 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
12808 // canonical "I pasted a brace-expansion fan followed by a
12809 // strong-quoted literal tail" footgun) routes through
12810 // `FonteCaminhoShellBraceExpansion` not
12811 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
12812 // is the load-bearing root-cause edit on every probe-as-
12813 // both value.
12814 let d = dep_with_fonte(DepSource::Path {
12815 caminho: "../{a,b}'x'".into(),
12816 });
12817 let err = d.validate().unwrap_err();
12818 assert!(
12819 matches!(
12820 err,
12821 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12822 ),
12823 "got {err:?}",
12824 );
12825 }
12826
12827 #[test]
12828 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
12829 // Cascade pin on the upstream shell-subshell-grouping arm:
12830 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
12831 // the canonical "I pasted a subshell-grouping followed by
12832 // a strong-quoted literal tail" footgun) routes through
12833 // `FonteCaminhoShellSubshellGrouping` not
12834 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
12835 // `$(<cmd>)` command-substitution boundary is the load-
12836 // bearing axis on every probe-as-both value.
12837 let d = dep_with_fonte(DepSource::Path {
12838 caminho: "../(cd foo)/'x'".into(),
12839 });
12840 let err = d.validate().unwrap_err();
12841 assert!(
12842 matches!(
12843 err,
12844 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12845 ),
12846 "got {err:?}",
12847 );
12848 }
12849
12850 #[test]
12851 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
12852 // Cascade pin on the upstream shell-glob arm: a value
12853 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
12854 // canonical "I pasted a `*` unbounded pathname-expansion
12855 // followed by a strong-quoted literal tail" footgun) routes
12856 // through `FonteCaminhoShellGlob` not
12857 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
12858 // expansion sentinel is the load-bearing root-cause edit
12859 // on every probe-as-both value.
12860 let d = dep_with_fonte(DepSource::Path {
12861 caminho: "../caixa-teia/*'x'".into(),
12862 });
12863 let err = d.validate().unwrap_err();
12864 assert!(
12865 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12866 "got {err:?}",
12867 );
12868 }
12869
12870 #[test]
12871 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
12872 // Cascade pin on the upstream shell-command-substitution
12873 // arm: a value carrying both a backtick and `'`
12874 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
12875 // legacy-backtick command-substitution followed by a
12876 // strong-quoted literal tail" footgun) routes through
12877 // `FonteCaminhoShellCommandSubstitution` not
12878 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
12879 // command-injection vector is the load-bearing root-cause
12880 // edit on every probe-as-both value.
12881 let d = dep_with_fonte(DepSource::Path {
12882 caminho: "../`whoami`/'x'".into(),
12883 });
12884 let err = d.validate().unwrap_err();
12885 assert!(
12886 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12887 "got {err:?}",
12888 );
12889 }
12890
12891 #[test]
12892 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
12893 // Cascade pin on the upstream shell-background arm: a value
12894 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
12895 // canonical "I pasted a `cmd & 'literal'` background-launch
12896 // + quote chain" footgun) routes through
12897 // `FonteCaminhoShellBackground` not
12898 // `FonteCaminhoShellQuoteGrouping`. The background-launch
12899 // tail is the load-bearing root-cause edit on every
12900 // probe-as-both value.
12901 let d = dep_with_fonte(DepSource::Path {
12902 caminho: "../caixa-teia & 'x'".into(),
12903 });
12904 let err = d.validate().unwrap_err();
12905 assert!(
12906 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12907 "got {err:?}",
12908 );
12909 }
12910
12911 #[test]
12912 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
12913 // Cascade pin on the upstream shell-semicolon arm: a value
12914 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
12915 // canonical sequential-cleanup + quote paste idiom) routes
12916 // through `FonteCaminhoShellSemicolon` not
12917 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
12918 // separator paste is the load-bearing root-cause edit on
12919 // every probe-as-both value.
12920 let d = dep_with_fonte(DepSource::Path {
12921 caminho: "../caixa-teia; 'x'".into(),
12922 });
12923 let err = d.validate().unwrap_err();
12924 assert!(
12925 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12926 "got {err:?}",
12927 );
12928 }
12929
12930 #[test]
12931 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
12932 // Cascade pin on the upstream shell-pipe arm: a value
12933 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
12934 // canonical pipeline-to-quoted-literal paste idiom) routes
12935 // through `FonteCaminhoShellPipe` not
12936 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
12937 // is the load-bearing root-cause edit on every probe-as-
12938 // both value.
12939 let d = dep_with_fonte(DepSource::Path {
12940 caminho: "../caixa-teia | 'x'".into(),
12941 });
12942 let err = d.validate().unwrap_err();
12943 assert!(
12944 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12945 "got {err:?}",
12946 );
12947 }
12948
12949 #[test]
12950 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
12951 // Cascade pin on the upstream shell-redirection arm: a
12952 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
12953 // — the canonical "I pasted a `cmd > log 'literal'`
12954 // redirect-plus-quote chain" footgun) routes through
12955 // `FonteCaminhoShellRedirection` not
12956 // `FonteCaminhoShellQuoteGrouping`. The input/output
12957 // redirection metachar carries the more self-locating
12958 // `byte` payload, so the prior arm wins on every probe-as-
12959 // both value.
12960 let d = dep_with_fonte(DepSource::Path {
12961 caminho: "../caixa-teia>log 'x'".into(),
12962 });
12963 let err = d.validate().unwrap_err();
12964 assert!(
12965 matches!(
12966 err,
12967 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12968 ),
12969 "got {err:?}",
12970 );
12971 }
12972
12973 #[test]
12974 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
12975 // Cascade pin on the upstream backslash arm: a value
12976 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
12977 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
12978 // chain" footgun) routes through `FonteCaminhoBackslash`
12979 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
12980 // separator divergence is the load-bearing axis on every
12981 // probe-as-both value.
12982 let d = dep_with_fonte(DepSource::Path {
12983 caminho: "..\\caixa-teia\\'x'".into(),
12984 });
12985 let err = d.validate().unwrap_err();
12986 assert!(
12987 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12988 "got {err:?}",
12989 );
12990 }
12991
12992 #[test]
12993 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
12994 // Cascade pin on the embedded-control-byte arm: a value
12995 // carrying both a control byte and `'` (`"../foo\n'x'"` —
12996 // the canonical paste-from-multiline-doc footgun where a
12997 // newline landed mid-caminho between two paste fragments)
12998 // routes through `FonteCaminhoControlChar` not
12999 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13000 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13001 // the load-bearing axis on every value that probes
13002 // positive for both — mirrors the cascade discipline on
13003 // every prior arm.
13004 let d = dep_with_fonte(DepSource::Path {
13005 caminho: "../foo\n'x'".into(),
13006 });
13007 let err = d.validate().unwrap_err();
13008 assert!(
13009 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13010 "got {err:?}",
13011 );
13012 }
13013
13014 #[test]
13015 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13016 // Cascade pin on the load-bearing leading-byte arm: a
13017 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13018 // through `FonteCaminhoAbsolute` not
13019 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13020 // diagnostic is the load-bearing axis, the quote byte is
13021 // the secondary observation. Same precedence logic as every
13022 // prior leading-byte arm.
13023 let d = dep_with_fonte(DepSource::Path {
13024 caminho: "/etc/'x'".into(),
13025 });
13026 let err = d.validate().unwrap_err();
13027 assert!(
13028 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13029 "got {err:?}",
13030 );
13031 }
13032
13033 #[test]
13034 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13035 // Cascade pin on the upstream leading-`$` var-expansion
13036 // arm: a value carrying both a leading `$` and a `'`
13037 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13038 // variable + quoted literal at the head of a sibling-
13039 // workspace path" footgun) routes through
13040 // `FonteCaminhoVarExpansion` not
13041 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13042 // shell-variable-expansion is the more self-locating
13043 // diagnostic on values that probe as both — same
13044 // load-bearing-leading-byte cascade discipline every
13045 // prior `:caminho` arm establishes.
13046 let d = dep_with_fonte(DepSource::Path {
13047 caminho: "$DIR/'x'".into(),
13048 });
13049 let err = d.validate().unwrap_err();
13050 assert!(
13051 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13052 "got {err:?}",
13053 );
13054 }
13055
13056 #[test]
13057 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13058 // Cascade pin on the immediate-successor arm: a value
13059 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13060 // — the canonical "I tab-completed a path whose strong-
13061 // quoted body already carried the quoting from a shell-
13062 // history paste" footgun) routes through
13063 // `FonteCaminhoShellQuoteGrouping` not
13064 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13065 // is the more semantic-locating axis (an author who removes
13066 // the `'` typically also drops the trailing separator since
13067 // both are paste-from-shell artifacts).
13068 let d = dep_with_fonte(DepSource::Path {
13069 caminho: "../'caixa-teia'/".into(),
13070 });
13071 let err = d.validate().unwrap_err();
13072 assert!(
13073 matches!(
13074 err,
13075 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13076 ),
13077 "got {err:?}",
13078 );
13079 }
13080
13081 #[test]
13082 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13083 // Diagnostic-shape pin (peer with
13084 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13085 // on the closest two-byte peer arm): the error's Display
13086 // surfaces the offending `:nome`, the offending `:caminho`
13087 // verbatim, the offending byte's hex / character form, and
13088 // names the shell-quote-grouping / cross-config-DSL-string-
13089 // literal-delimiter footgun explicitly so a `feira lint`
13090 // run can render the diagnostic without re-parsing.
13091 let d = dep_with_fonte(DepSource::Path {
13092 caminho: "'../caixa-teia'".into(),
13093 });
13094 let rendered = d.validate().unwrap_err().to_string();
13095 assert!(
13096 rendered.contains("caixa-teia"),
13097 "diagnostic must name the offending dep: {rendered}",
13098 );
13099 assert!(
13100 rendered.contains("'../caixa-teia'"),
13101 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13102 );
13103 assert!(
13104 rendered.contains("0x27"),
13105 "diagnostic must surface the offending byte hex: {rendered:?}",
13106 );
13107 assert!(
13108 rendered.contains("quote-grouping"),
13109 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13110 );
13111 assert!(
13112 rendered.contains("string-literal"),
13113 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13114 vocabulary: {rendered:?}",
13115 );
13116 }
13117
13118 #[test]
13119 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13120 // The canonical paste-from-shell-history-with-trailing-
13121 // annotation footgun: an author pastes a `cd ../caixa-teia
13122 // # legacy sibling` shell-history one-liner whose unquoted `#`
13123 // comment-lead separates the path from an inline annotation.
13124 // The POSIX shell trims the annotation to `../caixa-teia`
13125 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13126 // `Path::is_absolute` returns false on `..`, `#` is neither
13127 // a leading-byte sentinel nor a control byte nor `\` nor
13128 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13129 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13130 // `"`, and the value's last byte isn't `/` — so the value
13131 // silently passed every prior arm. The resolver folded the
13132 // value through `Path::join` looking for a literal
13133 // `./../caixa-teia # legacy sibling` subdirectory and the
13134 // failure surfaced at resolve time with a non-self-locating
13135 // `No such file or directory` error. The new arm moves the
13136 // rejection to validate time and names the offending dep +
13137 // caminho + byte verbatim.
13138 let d = dep_with_fonte(DepSource::Path {
13139 caminho: "../caixa-teia # legacy sibling".into(),
13140 });
13141 let err = d.validate().unwrap_err();
13142 let DepError::FonteCaminhoShellComment {
13143 nome,
13144 caminho,
13145 byte,
13146 } = err
13147 else {
13148 panic!("expected FonteCaminhoShellComment, got {err:?}");
13149 };
13150 assert_eq!(nome, "caixa-teia");
13151 assert_eq!(caminho, "../caixa-teia # legacy sibling");
13152 assert_eq!(byte, b'#');
13153 }
13154
13155 #[test]
13156 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13157 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13158 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
13159 // canonical "I copied a `path: ../caixa-teia # pin` YAML
13160 // scalar-plus-comment entry out of an aligned values.yaml and
13161 // dropped it verbatim into the `:caminho` slot" paste-idiom).
13162 // Pinned separately from the shell-history shape so the
13163 // gate's coverage extends from the single-space `#` shape to
13164 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
13165 // requires the `#` to be preceded by whitespace to lex as a
13166 // comment (bare `foo#bar` is a single scalar); the double-
13167 // space paste from an aligned manifest is the canonical
13168 // shape.
13169 let d = dep_with_fonte(DepSource::Path {
13170 caminho: "../caixa-teia # pin".into(),
13171 });
13172 let err = d.validate().unwrap_err();
13173 assert!(
13174 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13175 "got {err:?}",
13176 );
13177 }
13178
13179 #[test]
13180 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13181 // The URL-fragment-identifier paste shape
13182 // (`"../caixa-teia#readme"` — the canonical
13183 // paste-from-browser-address-bar permalink shape where the
13184 // browser preserved the `#anchor` tail on the copy). Pinned
13185 // separately from the whitespace-separated shell / YAML
13186 // comment shapes so the gate covers the unpadded RFC 3986
13187 // §3.5 fragment-delimiter position too, not only positions
13188 // preceded by unquoted whitespace. Peer with the immediate-
13189 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13190 // (a68f818) which closes the same byte under the same URL-
13191 // fragment-identifier banner.
13192 let d = dep_with_fonte(DepSource::Path {
13193 caminho: "../caixa-teia#readme".into(),
13194 });
13195 let err = d.validate().unwrap_err();
13196 assert!(
13197 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13198 "got {err:?}",
13199 );
13200 }
13201
13202 #[test]
13203 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13204 // Leading-position `#` shape (`"#../caixa-teia"` — the
13205 // "I copied a shell-comment-out entry from a commented-out
13206 // dep row" footgun). Pinned separately from the embedded
13207 // shapes so the gate covers every position, not only
13208 // whitespace-preceded / mid-value.
13209 let d = dep_with_fonte(DepSource::Path {
13210 caminho: "#../caixa-teia".into(),
13211 });
13212 let err = d.validate().unwrap_err();
13213 assert!(
13214 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13215 "got {err:?}",
13216 );
13217 }
13218
13219 #[test]
13220 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13221 // The positive-control pin: the gate targets only `#`,
13222 // never adjacent printable ASCII or POSIX-valid bytes. The
13223 // canonical relative POSIX path (`"../caixa-teia"`) and a
13224 // nested deeply-pathed variant with adjacent printable
13225 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13226 // to validate cleanly so the gate doesn't widen to a "no
13227 // printable punctuation anywhere" sweep that would defeat
13228 // the entire path-fonte author surface. Peer with
13229 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13230 // on the immediate-predecessor arm.
13231 let d = dep_with_fonte(DepSource::Path {
13232 caminho: "../caixa-teia/sub-dir.v2".into(),
13233 });
13234 d.validate().unwrap();
13235 }
13236
13237 #[test]
13238 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13239 // Cascade pin on the immediate-predecessor arm: a value
13240 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13241 // "I pasted a strong-quoted literal followed by a URL-
13242 // fragment permalink tail" footgun) routes through
13243 // `FonteCaminhoShellQuoteGrouping` not
13244 // `FonteCaminhoShellComment`. The shell-string-literal-
13245 // delimiter is the load-bearing root-cause edit on every
13246 // probe-as-both value; same cascade discipline every prior
13247 // `:caminho` arm establishes.
13248 let d = dep_with_fonte(DepSource::Path {
13249 caminho: "../'x'#pin".into(),
13250 });
13251 let err = d.validate().unwrap_err();
13252 assert!(
13253 matches!(
13254 err,
13255 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13256 ),
13257 "got {err:?}",
13258 );
13259 }
13260
13261 #[test]
13262 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13263 // Cascade pin on the upstream shell-bracket-expansion arm:
13264 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13265 // canonical "I pasted a glob-character-class followed by a
13266 // URL-fragment tail" footgun) routes through
13267 // `FonteCaminhoShellBracketExpansion` not
13268 // `FonteCaminhoShellComment`. The glob-character-class
13269 // expansion is the load-bearing root-cause edit on every
13270 // probe-as-both value.
13271 let d = dep_with_fonte(DepSource::Path {
13272 caminho: "../[a-z]#pin".into(),
13273 });
13274 let err = d.validate().unwrap_err();
13275 assert!(
13276 matches!(
13277 err,
13278 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13279 ),
13280 "got {err:?}",
13281 );
13282 }
13283
13284 #[test]
13285 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13286 // Cascade pin on the upstream shell-brace-expansion arm: a
13287 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13288 // canonical "I pasted a brace-expansion fan followed by a
13289 // URL-fragment tail" footgun) routes through
13290 // `FonteCaminhoShellBraceExpansion` not
13291 // `FonteCaminhoShellComment`. The brace-expansion fan is the
13292 // load-bearing root-cause edit on every probe-as-both value.
13293 let d = dep_with_fonte(DepSource::Path {
13294 caminho: "../{a,b}#pin".into(),
13295 });
13296 let err = d.validate().unwrap_err();
13297 assert!(
13298 matches!(
13299 err,
13300 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13301 ),
13302 "got {err:?}",
13303 );
13304 }
13305
13306 #[test]
13307 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13308 // Cascade pin on the upstream shell-subshell-grouping arm:
13309 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13310 // the canonical "I pasted a subshell-grouping followed by a
13311 // URL-fragment tail" footgun) routes through
13312 // `FonteCaminhoShellSubshellGrouping` not
13313 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13314 // command-substitution boundary is the load-bearing axis on
13315 // every probe-as-both value.
13316 let d = dep_with_fonte(DepSource::Path {
13317 caminho: "../(cd foo)#pin".into(),
13318 });
13319 let err = d.validate().unwrap_err();
13320 assert!(
13321 matches!(
13322 err,
13323 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13324 ),
13325 "got {err:?}",
13326 );
13327 }
13328
13329 #[test]
13330 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13331 // Cascade pin on the upstream shell-glob arm: a value
13332 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13333 // canonical "I pasted a `*` unbounded pathname-expansion
13334 // followed by a URL-fragment tail" footgun) routes through
13335 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13336 // The unbounded pathname-expansion sentinel is the load-
13337 // bearing root-cause edit on every probe-as-both value.
13338 let d = dep_with_fonte(DepSource::Path {
13339 caminho: "../caixa-teia/*#pin".into(),
13340 });
13341 let err = d.validate().unwrap_err();
13342 assert!(
13343 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13344 "got {err:?}",
13345 );
13346 }
13347
13348 #[test]
13349 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13350 // Cascade pin on the upstream shell-command-substitution
13351 // arm: a value carrying both a backtick and `#`
13352 // (``"../`whoami`#pin"`` — the canonical "I pasted a
13353 // legacy-backtick command-substitution followed by a URL-
13354 // fragment tail" footgun) routes through
13355 // `FonteCaminhoShellCommandSubstitution` not
13356 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13357 // injection vector is the load-bearing root-cause edit on
13358 // every probe-as-both value.
13359 let d = dep_with_fonte(DepSource::Path {
13360 caminho: "../`whoami`#pin".into(),
13361 });
13362 let err = d.validate().unwrap_err();
13363 assert!(
13364 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13365 "got {err:?}",
13366 );
13367 }
13368
13369 #[test]
13370 fn fonte_caminho_shell_background_fires_before_shell_comment() {
13371 // Cascade pin on the upstream shell-background arm: a value
13372 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13373 // the canonical "I pasted a `cmd &` background-launch
13374 // followed by a URL-fragment tail" footgun) routes through
13375 // `FonteCaminhoShellBackground` not
13376 // `FonteCaminhoShellComment`. The background-launch tail is
13377 // the load-bearing root-cause edit on every probe-as-both
13378 // value.
13379 let d = dep_with_fonte(DepSource::Path {
13380 caminho: "../caixa-teia&pin#tail".into(),
13381 });
13382 let err = d.validate().unwrap_err();
13383 assert!(
13384 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13385 "got {err:?}",
13386 );
13387 }
13388
13389 #[test]
13390 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13391 // Cascade pin on the upstream shell-semicolon arm: a value
13392 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13393 // the canonical sequential-cleanup + URL-fragment paste
13394 // idiom) routes through `FonteCaminhoShellSemicolon` not
13395 // `FonteCaminhoShellComment`. The sequential-command-
13396 // separator paste is the load-bearing root-cause edit on
13397 // every probe-as-both value.
13398 let d = dep_with_fonte(DepSource::Path {
13399 caminho: "../caixa-teia;pin#tail".into(),
13400 });
13401 let err = d.validate().unwrap_err();
13402 assert!(
13403 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13404 "got {err:?}",
13405 );
13406 }
13407
13408 #[test]
13409 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13410 // Cascade pin on the upstream shell-pipe arm: a value
13411 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13412 // the canonical pipeline-to-URL-fragment paste idiom) routes
13413 // through `FonteCaminhoShellPipe` not
13414 // `FonteCaminhoShellComment`. The pipeline-tail paste is
13415 // the load-bearing root-cause edit on every probe-as-both
13416 // value.
13417 let d = dep_with_fonte(DepSource::Path {
13418 caminho: "../caixa-teia|pin#tail".into(),
13419 });
13420 let err = d.validate().unwrap_err();
13421 assert!(
13422 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13423 "got {err:?}",
13424 );
13425 }
13426
13427 #[test]
13428 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13429 // Cascade pin on the upstream shell-redirection arm: a
13430 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13431 // — the canonical "I pasted a `cmd > log` redirect followed
13432 // by a URL-fragment tail" footgun) routes through
13433 // `FonteCaminhoShellRedirection` not
13434 // `FonteCaminhoShellComment`. The input/output redirection
13435 // metachar carries the more self-locating `byte` payload,
13436 // so the prior arm wins on every probe-as-both value.
13437 let d = dep_with_fonte(DepSource::Path {
13438 caminho: "../caixa-teia>log#pin".into(),
13439 });
13440 let err = d.validate().unwrap_err();
13441 assert!(
13442 matches!(
13443 err,
13444 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13445 ),
13446 "got {err:?}",
13447 );
13448 }
13449
13450 #[test]
13451 fn fonte_caminho_backslash_fires_before_shell_comment() {
13452 // Cascade pin on the upstream backslash arm: a value
13453 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13454 // canonical "I pasted a Windows-shell path followed by a
13455 // URL-fragment tail" footgun) routes through
13456 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13457 // The cross-host-OS-separator divergence is the load-
13458 // bearing axis on every probe-as-both value.
13459 let d = dep_with_fonte(DepSource::Path {
13460 caminho: "..\\caixa-teia#pin".into(),
13461 });
13462 let err = d.validate().unwrap_err();
13463 assert!(
13464 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13465 "got {err:?}",
13466 );
13467 }
13468
13469 #[test]
13470 fn fonte_caminho_control_char_fires_before_shell_comment() {
13471 // Cascade pin on the embedded-control-byte arm: a value
13472 // carrying both a control byte and `#` (`"../foo\n#pin"` —
13473 // the canonical paste-from-multiline-doc footgun where a
13474 // newline landed mid-caminho between the path and an
13475 // annotation) routes through `FonteCaminhoControlChar` not
13476 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13477 // byte diagnostic is the load-bearing axis on every value
13478 // that probes positive for both — mirrors the cascade
13479 // discipline on every prior arm.
13480 let d = dep_with_fonte(DepSource::Path {
13481 caminho: "../foo\n#pin".into(),
13482 });
13483 let err = d.validate().unwrap_err();
13484 assert!(
13485 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13486 "got {err:?}",
13487 );
13488 }
13489
13490 #[test]
13491 fn fonte_caminho_absolute_fires_before_shell_comment() {
13492 // Cascade pin on the load-bearing leading-byte arm: a
13493 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13494 // routes through `FonteCaminhoAbsolute` not
13495 // `FonteCaminhoShellComment` — the host-layout-leak
13496 // diagnostic is the load-bearing axis, the fragment byte is
13497 // the secondary observation. Same precedence logic as every
13498 // prior leading-byte arm.
13499 let d = dep_with_fonte(DepSource::Path {
13500 caminho: "/etc/foo#pin".into(),
13501 });
13502 let err = d.validate().unwrap_err();
13503 assert!(
13504 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13505 "got {err:?}",
13506 );
13507 }
13508
13509 #[test]
13510 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13511 // Cascade pin on the upstream leading-`$` var-expansion
13512 // arm: a value carrying both a leading `$` and a `#`
13513 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13514 // shell-variable at the head of a sibling-workspace path
13515 // followed by a URL-fragment tail" footgun) routes through
13516 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13517 // The leading-byte shell-variable-expansion is the more
13518 // self-locating diagnostic on values that probe as both.
13519 let d = dep_with_fonte(DepSource::Path {
13520 caminho: "$DIR/foo#pin".into(),
13521 });
13522 let err = d.validate().unwrap_err();
13523 assert!(
13524 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13525 "got {err:?}",
13526 );
13527 }
13528
13529 #[test]
13530 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13531 // Cascade pin on the immediate-successor arm: a value
13532 // carrying both `#` and a trailing `/`
13533 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13534 // a URL-fragment-carrying path" footgun) routes through
13535 // `FonteCaminhoShellComment` not
13536 // `FonteCaminhoTrailingSlash`. The embedded fragment /
13537 // comment-lead byte is the more semantic-locating axis (an
13538 // author who removes the `#pin` fragment typically also
13539 // drops the trailing separator since both are paste-from-
13540 // URL / paste-from-shell-tab-completion artifacts).
13541 let d = dep_with_fonte(DepSource::Path {
13542 caminho: "../caixa-teia#pin/".into(),
13543 });
13544 let err = d.validate().unwrap_err();
13545 assert!(
13546 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13547 "got {err:?}",
13548 );
13549 }
13550
13551 #[test]
13552 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13553 // Diagnostic-shape pin (peer with
13554 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13555 // on the immediate-predecessor arm): the error's Display
13556 // surfaces the offending `:nome`, the offending `:caminho`
13557 // verbatim, the offending byte's hex / character form, and
13558 // names the shell-comment / URL-fragment-identifier /
13559 // YAML-comment cross-config-DSL footgun explicitly so a
13560 // `feira lint` run can render the diagnostic without
13561 // re-parsing.
13562 let d = dep_with_fonte(DepSource::Path {
13563 caminho: "../caixa-teia#readme".into(),
13564 });
13565 let rendered = d.validate().unwrap_err().to_string();
13566 assert!(
13567 rendered.contains("caixa-teia"),
13568 "diagnostic must name the offending dep: {rendered}",
13569 );
13570 assert!(
13571 rendered.contains("../caixa-teia#readme"),
13572 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13573 );
13574 assert!(
13575 rendered.contains("0x23"),
13576 "diagnostic must surface the offending byte hex: {rendered:?}",
13577 );
13578 assert!(
13579 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13580 "diagnostic must name the shell-comment footgun: {rendered:?}",
13581 );
13582 assert!(
13583 rendered.contains("fragment") || rendered.contains("URL-fragment"),
13584 "diagnostic must reference the URL-fragment-identifier vocabulary: \
13585 {rendered:?}",
13586 );
13587 }
13588
13589 #[test]
13590 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13591 // The canonical paste-from-browser-address-bar percent-
13592 // encoded-space footgun: an author copies `../caixa%20teia`
13593 // out of a URL-encoded README hyperlink / browser address
13594 // bar / percent-encoded permalink expecting `%20` to decode
13595 // to a literal space at the filesystem layer. POSIX
13596 // `std::path::Path` treats `%` as a literal path-component
13597 // byte, so `Path::join` looks for a literal
13598 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13599 // returns false on `..`, `%` is neither a leading-byte
13600 // sentinel nor a control byte nor `\` nor `<` / `>` nor
13601 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13602 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13603 // and the value's last byte isn't `/` — so the value
13604 // silently passed every prior arm. The new arm moves the
13605 // rejection to validate time and names the offending dep +
13606 // caminho + byte verbatim.
13607 let d = dep_with_fonte(DepSource::Path {
13608 caminho: "../caixa%20teia".into(),
13609 });
13610 let err = d.validate().unwrap_err();
13611 let DepError::FonteCaminhoUrlPercentEncoding {
13612 nome,
13613 caminho,
13614 byte,
13615 } = err
13616 else {
13617 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13618 };
13619 assert_eq!(nome, "caixa-teia");
13620 assert_eq!(caminho, "../caixa%20teia");
13621 assert_eq!(byte, b'%');
13622 }
13623
13624 #[test]
13625 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13626 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13627 // intending the `%2F` as the URL encoding of `/`) locks a
13628 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13629 // the byte-identical `path:../caixa/teia` form. Pinned
13630 // separately from the space-encoded shape so the gate's
13631 // coverage extends past the single canonical `%20` example
13632 // to any two-hex-digit percent-encoded sequence.
13633 let d = dep_with_fonte(DepSource::Path {
13634 caminho: "../caixa%2Fteia".into(),
13635 });
13636 let err = d.validate().unwrap_err();
13637 assert!(
13638 matches!(
13639 err,
13640 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13641 ),
13642 "got {err:?}",
13643 );
13644 }
13645
13646 #[test]
13647 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13648 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13649 // where `%` isn't followed by two hex digits) — every
13650 // WHATWG-conformant URL parser rejects the value at parse
13651 // time per RFC 3986 §2.1, but the byte would silently ride
13652 // into the lacre before the resolver subprocess crosses the
13653 // URL-parser boundary. Pinned separately from the well-
13654 // formed `%HH` shapes so the gate covers every percent-
13655 // occurrence, not only strictly-conformant escapes.
13656 let d = dep_with_fonte(DepSource::Path {
13657 caminho: "../caixa-teia%foo".into(),
13658 });
13659 let err = d.validate().unwrap_err();
13660 assert!(
13661 matches!(
13662 err,
13663 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13664 ),
13665 "got {err:?}",
13666 );
13667 }
13668
13669 #[test]
13670 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13671 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13672 // — the canonical paste-from-top-of-doc YAML directive
13673 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13674 // separately from embedded shapes so the gate covers the
13675 // leading-position `%` too, not only mid-value occurrences.
13676 let d = dep_with_fonte(DepSource::Path {
13677 caminho: "%YAML/../caixa-teia".into(),
13678 });
13679 let err = d.validate().unwrap_err();
13680 assert!(
13681 matches!(
13682 err,
13683 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13684 ),
13685 "got {err:?}",
13686 );
13687 }
13688
13689 #[test]
13690 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13691 // The printf-format-specifier paste shape
13692 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13693 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13694 // 134 format-string-injection vector). Pinned separately
13695 // from the URL-encoding shapes so the gate's rationale
13696 // extends past the RFC 3986 axis to the C / POSIX printf
13697 // format-directive-lead axis.
13698 let d = dep_with_fonte(DepSource::Path {
13699 caminho: "../caixa-%s-teia".into(),
13700 });
13701 let err = d.validate().unwrap_err();
13702 assert!(
13703 matches!(
13704 err,
13705 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13706 ),
13707 "got {err:?}",
13708 );
13709 }
13710
13711 #[test]
13712 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13713 // The positive-control pin: the gate targets only `%`,
13714 // never adjacent printable ASCII or POSIX-valid bytes. The
13715 // canonical relative POSIX path (`"../caixa-teia"`) and a
13716 // nested deeply-pathed variant with adjacent printable
13717 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13718 // to validate cleanly so the gate doesn't widen to a "no
13719 // printable punctuation anywhere" sweep that would defeat
13720 // the entire path-fonte author surface. Peer with
13721 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
13722 // on the immediate-predecessor arm.
13723 let d = dep_with_fonte(DepSource::Path {
13724 caminho: "../caixa-teia/sub-dir.v2".into(),
13725 });
13726 d.validate().unwrap();
13727 }
13728
13729 #[test]
13730 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
13731 // Cascade pin on the immediate-predecessor arm: a value
13732 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
13733 // canonical "I pasted a URL-fragment permalink followed by a
13734 // percent-encoded space tail" footgun) routes through
13735 // `FonteCaminhoShellComment` not
13736 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
13737 // identifier is the load-bearing downstream-truncation edit
13738 // on every probe-as-both value; same cascade discipline
13739 // every prior `:caminho` arm establishes.
13740 let d = dep_with_fonte(DepSource::Path {
13741 caminho: "../caixa-teia#pin%20".into(),
13742 });
13743 let err = d.validate().unwrap_err();
13744 assert!(
13745 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13746 "got {err:?}",
13747 );
13748 }
13749
13750 #[test]
13751 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
13752 // Cascade pin on the upstream shell-quote-grouping arm: a
13753 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
13754 // canonical "I pasted a strong-quoted literal followed by
13755 // a percent-encoded space" footgun) routes through
13756 // `FonteCaminhoShellQuoteGrouping` not
13757 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
13758 // literal-delimiter is the load-bearing root-cause edit on
13759 // every probe-as-both value.
13760 let d = dep_with_fonte(DepSource::Path {
13761 caminho: "../'x'%20teia".into(),
13762 });
13763 let err = d.validate().unwrap_err();
13764 assert!(
13765 matches!(
13766 err,
13767 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13768 ),
13769 "got {err:?}",
13770 );
13771 }
13772
13773 #[test]
13774 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
13775 // Cascade pin on the upstream backslash arm: a value
13776 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
13777 // canonical "I pasted a Windows-shell path followed by a
13778 // percent-encoded space" footgun) routes through
13779 // `FonteCaminhoBackslash` not
13780 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
13781 // separator divergence is the load-bearing root-cause edit
13782 // on every probe-as-both value.
13783 let d = dep_with_fonte(DepSource::Path {
13784 caminho: "..\\caixa%20teia".into(),
13785 });
13786 let err = d.validate().unwrap_err();
13787 assert!(
13788 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13789 "got {err:?}",
13790 );
13791 }
13792
13793 #[test]
13794 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
13795 // Cascade pin on the upstream control-char arm: a value
13796 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
13797 // the canonical "I pasted a paste-from-binary-blob path
13798 // followed by a percent-encoded space" footgun) routes
13799 // through `FonteCaminhoControlChar` not
13800 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
13801 // rejected byte is the load-bearing root-cause edit on
13802 // every probe-as-both value.
13803 let d = dep_with_fonte(DepSource::Path {
13804 caminho: "../caixa\0%20teia".into(),
13805 });
13806 let err = d.validate().unwrap_err();
13807 assert!(
13808 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
13809 "got {err:?}",
13810 );
13811 }
13812
13813 #[test]
13814 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
13815 // Cascade pin on the upstream absolute-path arm: a value
13816 // that's both absolute and carries `%` (`"/etc/passwd%20"`
13817 // — the canonical "I pasted an absolute path with a
13818 // percent-encoded space tail" footgun) routes through
13819 // `FonteCaminhoAbsolute` not
13820 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
13821 // the load-bearing root-cause edit on every probe-as-both
13822 // value.
13823 let d = dep_with_fonte(DepSource::Path {
13824 caminho: "/etc/passwd%20".into(),
13825 });
13826 let err = d.validate().unwrap_err();
13827 assert!(
13828 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13829 "got {err:?}",
13830 );
13831 }
13832
13833 #[test]
13834 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
13835 // Cascade pin on the upstream var-expansion arm: a value
13836 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
13837 // — the canonical "I pasted a `$HOME`-rooted path with a
13838 // percent-encoded space" footgun) routes through
13839 // `FonteCaminhoVarExpansion` not
13840 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
13841 // expansion is the load-bearing root-cause edit on every
13842 // probe-as-both value.
13843 let d = dep_with_fonte(DepSource::Path {
13844 caminho: "$HOME/caixa%20teia".into(),
13845 });
13846 let err = d.validate().unwrap_err();
13847 assert!(
13848 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13849 "got {err:?}",
13850 );
13851 }
13852
13853 #[test]
13854 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
13855 // Cascade pin on the immediate-successor arm: a value
13856 // carrying both `%` and a trailing `/`
13857 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
13858 // percent-encoded-space-carrying path" footgun) routes
13859 // through `FonteCaminhoUrlPercentEncoding` not
13860 // `FonteCaminhoTrailingSlash`. The embedded percent-
13861 // encoding-escape byte is the more semantic-locating axis
13862 // (an author who decodes the `%20` to a literal space is
13863 // likely to also tab-strip the trailing separator since
13864 // both are paste-from-URL / paste-from-shell-tab-completion
13865 // artifacts).
13866 let d = dep_with_fonte(DepSource::Path {
13867 caminho: "../caixa%20teia/".into(),
13868 });
13869 let err = d.validate().unwrap_err();
13870 assert!(
13871 matches!(
13872 err,
13873 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13874 ),
13875 "got {err:?}",
13876 );
13877 }
13878
13879 #[test]
13880 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
13881 // Diagnostic-shape pin (peer with
13882 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
13883 // on the immediate-predecessor arm): the error's Display
13884 // surfaces the offending `:nome`, the offending `:caminho`
13885 // verbatim, the offending byte's hex / character form, and
13886 // names the URL-percent-encoding-escape / printf-format-
13887 // specifier footgun explicitly so a `feira lint` run can
13888 // render the diagnostic without re-parsing.
13889 let d = dep_with_fonte(DepSource::Path {
13890 caminho: "../caixa%20teia".into(),
13891 });
13892 let rendered = d.validate().unwrap_err().to_string();
13893 assert!(
13894 rendered.contains("caixa-teia"),
13895 "diagnostic must name the offending dep: {rendered}",
13896 );
13897 assert!(
13898 rendered.contains("../caixa%20teia"),
13899 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13900 );
13901 assert!(
13902 rendered.contains("0x25"),
13903 "diagnostic must surface the offending byte hex: {rendered:?}",
13904 );
13905 assert!(
13906 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
13907 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
13908 );
13909 assert!(
13910 rendered.contains("printf") || rendered.contains("format-specifier"),
13911 "diagnostic must reference the printf-format-specifier vocabulary: \
13912 {rendered:?}",
13913 );
13914 }
13915
13916 #[test]
13917 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
13918 // The canonical embedded-`$` shell-variable-expansion paste
13919 // shape (`"../foo$HOME/bar"` — an author copies a partially-
13920 // substituted shell one-liner where the leading segment is a
13921 // literal `../foo` while the mid segment carries the un-
13922 // substituted `$HOME` template). The leading-`$` position is
13923 // already gated by the f4efe9c leading-byte arm which routes
13924 // through `FonteCaminhoVarExpansion`; this arm closes the
13925 // last positional gap on `$` — every position on the axis is
13926 // structurally rejected.
13927 let d = dep_with_fonte(DepSource::Path {
13928 caminho: "../foo$HOME/bar".into(),
13929 });
13930 let err = d.validate().unwrap_err();
13931 let DepError::FonteCaminhoShellVariableExpansion {
13932 nome,
13933 caminho,
13934 byte,
13935 } = err
13936 else {
13937 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
13938 };
13939 assert_eq!(nome, "caixa-teia");
13940 assert_eq!(caminho, "../foo$HOME/bar");
13941 assert_eq!(byte, b'$');
13942 }
13943
13944 #[test]
13945 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
13946 // The symmetric braced-CI-manifest paste shape
13947 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
13948 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
13949 // footgun). Pinned separately from the bare-`$VAR` shape so
13950 // the gate covers both POSIX shell §2.6 Parameter Expansion
13951 // syntactic forms, not only the unbraced variant. The
13952 // embedded `{` byte in `${...}` is also caught by the 598b770
13953 // shell-brace-expansion arm but that arm fires earlier in
13954 // the cascade — the `$` arm's coverage extends to `${...}`
13955 // structurally, so the diagnostic asserted here is the
13956 // brace-expansion one (which is a valid outcome; the point
13957 // of the pin is that the value never survives validation).
13958 let d = dep_with_fonte(DepSource::Path {
13959 caminho: "../foo${WORKSPACE}/bar".into(),
13960 });
13961 let err = d.validate().unwrap_err();
13962 assert!(
13963 matches!(
13964 err,
13965 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
13966 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13967 ),
13968 "got {err:?}",
13969 );
13970 }
13971
13972 #[test]
13973 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
13974 // The paste-from-shell-prompt command-substitution idiom
13975 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
13976 // `$VAR` shape so the gate's rationale extends to POSIX shell
13977 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
13978 // legacy `` `<cmd>` `` form is already closed by the c370458
13979 // backtick arm). The embedded `(` byte in `$(...)` is also
13980 // caught structurally by the 0633c91 shell-subshell-grouping
13981 // arm which fires earlier in the cascade — the diagnostic
13982 // asserted here is either outcome, since both structurally
13983 // reject the value; the point of the pin is that the value
13984 // never survives validation.
13985 let d = dep_with_fonte(DepSource::Path {
13986 caminho: "../foo$(whoami)/bar".into(),
13987 });
13988 let err = d.validate().unwrap_err();
13989 assert!(
13990 matches!(
13991 err,
13992 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
13993 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
13994 ),
13995 "got {err:?}",
13996 );
13997 }
13998
13999 #[test]
14000 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14001 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14002 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14003 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14004 // idiom copied into a caminho template). None of the prior
14005 // shell-metachar arms cover this shape (`1` is a bare digit;
14006 // no `(` / `{` / letter follows the `$`), so the arm is the
14007 // sole gate on the shape.
14008 let d = dep_with_fonte(DepSource::Path {
14009 caminho: "../foo$1/bar".into(),
14010 });
14011 let err = d.validate().unwrap_err();
14012 assert!(
14013 matches!(
14014 err,
14015 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14016 ),
14017 "got {err:?}",
14018 );
14019 }
14020
14021 #[test]
14022 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14023 // The positive-control pin (peer with
14024 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14025 // on the immediate-predecessor arm): the gate targets only
14026 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14027 // A relative POSIX path carrying dashes / dots / slashes /
14028 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14029 // validate cleanly so the gate doesn't widen to a "no
14030 // printable punctuation anywhere" sweep that would defeat
14031 // the entire path-fonte author surface.
14032 let d = dep_with_fonte(DepSource::Path {
14033 caminho: "../caixa-teia/sub-dir.v2".into(),
14034 });
14035 d.validate().unwrap();
14036 }
14037
14038 #[test]
14039 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14040 // Cascade pin on the leading-`$` sibling arm at line 540: a
14041 // value starting with `$` and carrying an embedded `$` too
14042 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14043 // fully-templated CI path with two un-substituted variables")
14044 // routes through `FonteCaminhoVarExpansion` not
14045 // `FonteCaminhoShellVariableExpansion`. The leading-byte
14046 // host-layout-leak is the load-bearing self-locating axis
14047 // (the leading position dominates the semantic-locating
14048 // rationale on every probe-as-both value); the embedded
14049 // arm's positional-agnostic sweep catches only values whose
14050 // leading byte doesn't route through the earlier leading-
14051 // byte arms.
14052 let d = dep_with_fonte(DepSource::Path {
14053 caminho: "$HOME/foo$WORKSPACE/bar".into(),
14054 });
14055 let err = d.validate().unwrap_err();
14056 assert!(
14057 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14058 "got {err:?}",
14059 );
14060 }
14061
14062 #[test]
14063 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14064 // Cascade pin on the immediate-predecessor arm: a value
14065 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14066 // — the canonical "I pasted a percent-encoded space adjacent
14067 // to a `$HOME` template") routes through
14068 // `FonteCaminhoUrlPercentEncoding` not
14069 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14070 // encoding-escape byte is the more semantic-locating axis
14071 // (the paste-from-browser-address-bar shape is the load-
14072 // bearing self-locating edit); same cascade discipline every
14073 // prior `:caminho` arm establishes.
14074 let d = dep_with_fonte(DepSource::Path {
14075 caminho: "../foo%20$HOME/bar".into(),
14076 });
14077 let err = d.validate().unwrap_err();
14078 assert!(
14079 matches!(
14080 err,
14081 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14082 ),
14083 "got {err:?}",
14084 );
14085 }
14086
14087 #[test]
14088 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14089 // Cascade pin on the immediate-successor arm: a value
14090 // carrying both embedded `$` and a trailing `/`
14091 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14092 // `$HOME`-template-carrying path") routes through
14093 // `FonteCaminhoShellVariableExpansion` not
14094 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14095 // expansion byte is the more semantic-locating axis on
14096 // probe-as-both values (an author who substitutes the
14097 // `$HOME` template with a literal value is likely to also
14098 // tab-strip the trailing separator).
14099 let d = dep_with_fonte(DepSource::Path {
14100 caminho: "../foo$HOME/bar/".into(),
14101 });
14102 let err = d.validate().unwrap_err();
14103 assert!(
14104 matches!(
14105 err,
14106 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14107 ),
14108 "got {err:?}",
14109 );
14110 }
14111
14112 #[test]
14113 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14114 // Diagnostic-shape pin (peer with
14115 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14116 // on the immediate-predecessor arm): the error's Display
14117 // surfaces the offending `:nome`, the offending `:caminho`
14118 // verbatim, the offending byte's hex / character form, and
14119 // names the shell-variable-expansion / command-substitution
14120 // footgun explicitly so a `feira lint` run can render the
14121 // diagnostic without re-parsing.
14122 let d = dep_with_fonte(DepSource::Path {
14123 caminho: "../foo$HOME/bar".into(),
14124 });
14125 let rendered = d.validate().unwrap_err().to_string();
14126 assert!(
14127 rendered.contains("caixa-teia"),
14128 "diagnostic must name the offending dep: {rendered}",
14129 );
14130 assert!(
14131 rendered.contains("../foo$HOME/bar"),
14132 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14133 );
14134 assert!(
14135 rendered.contains("0x24"),
14136 "diagnostic must surface the offending byte hex: {rendered:?}",
14137 );
14138 assert!(
14139 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14140 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14141 );
14142 assert!(
14143 rendered.contains("command-substitution") || rendered.contains("command substitution"),
14144 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14145 );
14146 }
14147
14148 #[test]
14149 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14150 // The fail-before-pass-after pin for the canonical paste-from-
14151 // shell-history footgun on `:caminho`. An author copies a `cd
14152 // ../caixa-teia && !sudo make install` one-liner from a quick-
14153 // start README, intending the trailing `!sudo` as a shell-
14154 // history-expansion reference but the typed slot is itself a
14155 // byte-level string parser, not a shell context, so the byte
14156 // rides into the value verbatim. Until this arm landed the `!`
14157 // byte silently passed every prior `:caminho` cascade arm
14158 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14159 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14160 // `#` / `%` / `$`); bash with the default `histexpand` mode
14161 // rewrites `!command` to the most recent history entry
14162 // beginning with `command`, the canonical RCE-class injection
14163 // vector when the byte rides into a shell argument executed
14164 // under `bash -i` (the operator-notebook interactive shell).
14165 let d = dep_with_fonte(DepSource::Path {
14166 caminho: "../caixa-teia!sudo".into(),
14167 });
14168 let err = d.validate().unwrap_err();
14169 let DepError::FonteCaminhoShellHistoryExpansion {
14170 nome,
14171 caminho,
14172 byte,
14173 } = err
14174 else {
14175 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14176 };
14177 assert_eq!(nome, "caixa-teia");
14178 assert_eq!(caminho, "../caixa-teia!sudo");
14179 assert_eq!(byte, b'!');
14180 }
14181
14182 #[test]
14183 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14184 // The symmetric `!!` repeat-prior-command paste idiom (peer with
14185 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14186 // on `is_git_repo_url`). Pinned separately from the wrapped
14187 // `!command` shape so a future diagnostic-surface change that
14188 // only checked the leading or paired-bang position surfaces
14189 // here — the per-byte arm fires anywhere `!` appears in the
14190 // value, including at consecutive positions in the middle.
14191 let d = dep_with_fonte(DepSource::Path {
14192 caminho: "../foo!!/bar".into(),
14193 });
14194 let err = d.validate().unwrap_err();
14195 assert!(
14196 matches!(
14197 err,
14198 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14199 ),
14200 "got {err:?}",
14201 );
14202 }
14203
14204 #[test]
14205 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14206 // The English-typography enthusiasm-form paste-from-prose
14207 // idiom: an author writes `:caminho "../caixa-teia!"`
14208 // expecting the substrate to coerce it to a kebab-case slug.
14209 // Pinned separately from the `!<word>` shell-history shape so
14210 // the gate's rationale extends to the paste-from-prose surface
14211 // (the same rationale the peer `is_git_repo_url` bang arm at
14212 // 7d53c68 covers). None of the prior shell-metachar arms cover
14213 // this shape (no `!<word>` reference and no `!!` repeat), so
14214 // the arm is the sole gate on the shape.
14215 let d = dep_with_fonte(DepSource::Path {
14216 caminho: "../caixa-teia!".into(),
14217 });
14218 let err = d.validate().unwrap_err();
14219 assert!(
14220 matches!(
14221 err,
14222 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14223 ),
14224 "got {err:?}",
14225 );
14226 }
14227
14228 #[test]
14229 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14230 // The positive-control pin (peer with
14231 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14232 // on the immediate-predecessor arm): the gate targets only
14233 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14234 // A relative POSIX path carrying dashes / dots / slashes /
14235 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14236 // validate cleanly so the gate doesn't widen to a "no
14237 // printable punctuation anywhere" sweep that would defeat
14238 // the entire path-fonte author surface.
14239 let d = dep_with_fonte(DepSource::Path {
14240 caminho: "../caixa-teia/sub-dir.v2".into(),
14241 });
14242 d.validate().unwrap();
14243 }
14244
14245 #[test]
14246 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14247 // Cascade pin on the immediate-predecessor arm: a value
14248 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14249 // — the canonical "I pasted a `$HOME`-templated path adjacent
14250 // to a trailing `!sudo` history-expansion") routes through
14251 // `FonteCaminhoShellVariableExpansion` not
14252 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14253 // expansion byte is the more semantic-locating axis on
14254 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14255 // template shape is the load-bearing self-locating edit);
14256 // same cascade discipline every prior `:caminho` arm
14257 // establishes.
14258 let d = dep_with_fonte(DepSource::Path {
14259 caminho: "../foo$HOME/bar!sudo".into(),
14260 });
14261 let err = d.validate().unwrap_err();
14262 assert!(
14263 matches!(
14264 err,
14265 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14266 ),
14267 "got {err:?}",
14268 );
14269 }
14270
14271 #[test]
14272 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14273 // Cascade pin on the immediate-successor arm: a value carrying
14274 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14275 // — the canonical "I tab-completed a `!sudo`-carrying path")
14276 // routes through `FonteCaminhoShellHistoryExpansion` not
14277 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14278 // expansion byte is the more semantic-locating axis on probe-
14279 // as-both values (an author who removes the `!sudo` history
14280 // reference is likely to also tab-strip the trailing separator).
14281 let d = dep_with_fonte(DepSource::Path {
14282 caminho: "../caixa-teia!sudo/".into(),
14283 });
14284 let err = d.validate().unwrap_err();
14285 assert!(
14286 matches!(
14287 err,
14288 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14289 ),
14290 "got {err:?}",
14291 );
14292 }
14293
14294 #[test]
14295 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14296 // Diagnostic-shape pin (peer with
14297 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14298 // on the immediate-predecessor arm): the error's Display
14299 // surfaces the offending `:nome`, the offending `:caminho`
14300 // verbatim, the offending byte's hex / character form, and
14301 // names the shell-history-expansion / bang-operator footgun
14302 // explicitly so a `feira lint` run can render the diagnostic
14303 // without re-parsing.
14304 let d = dep_with_fonte(DepSource::Path {
14305 caminho: "../caixa-teia!sudo".into(),
14306 });
14307 let rendered = d.validate().unwrap_err().to_string();
14308 assert!(
14309 rendered.contains("caixa-teia"),
14310 "diagnostic must name the offending dep: {rendered}",
14311 );
14312 assert!(
14313 rendered.contains("../caixa-teia!sudo"),
14314 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14315 );
14316 assert!(
14317 rendered.contains("0x21"),
14318 "diagnostic must surface the offending byte hex: {rendered:?}",
14319 );
14320 assert!(
14321 rendered.contains("history-expansion") || rendered.contains("history expansion"),
14322 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14323 );
14324 assert!(
14325 rendered.contains("bang"),
14326 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14327 );
14328 }
14329
14330 #[test]
14331 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14332 // The fail-before-pass-after pin for the canonical paste-from-
14333 // shell-history-quick-substitution footgun on `:caminho`. An
14334 // author copies a `git clone <bad-url>` line from their terminal,
14335 // corrects it via bash's `^bad^good` quick-substitution history
14336 // operator (bash reference §9.3, `set -o histexpand` mode's
14337 // default for interactive sessions), and pastes the trailing
14338 // `^bad^good` substitution fragment into a `:caminho` value
14339 // without trimming the leading `git clone` prefix — the byte
14340 // rides into the manifest verbatim. Until this arm landed the
14341 // `^` byte silently passed every prior `:caminho` cascade arm
14342 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14343 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14344 // `%` / `$` / `!`); bash with the default `histexpand` mode
14345 // rewrites the prior command's `bad` string to `good` and re-
14346 // executes it, the paired-operator half of the `set -o
14347 // histexpand` feature the peer `!` arm already closes the prefix
14348 // half of. The peer `is_git_repo_url` axis rejects the byte at
14349 // 49e142f under the same shell-history-substitution / RFC-3986-
14350 // unwise banner.
14351 let d = dep_with_fonte(DepSource::Path {
14352 caminho: "../foo^bad^good".into(),
14353 });
14354 let err = d.validate().unwrap_err();
14355 let DepError::FonteCaminhoShellHistorySubstitution {
14356 nome,
14357 caminho,
14358 byte,
14359 } = err
14360 else {
14361 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14362 };
14363 assert_eq!(nome, "caixa-teia");
14364 assert_eq!(caminho, "../foo^bad^good");
14365 assert_eq!(byte, b'^');
14366 }
14367
14368 #[test]
14369 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14370 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14371 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14372 // on `is_git_repo_url`). An author copies a `grep '^archived'`
14373 // regex-anchor / negation idiom from a doc snippet and the byte
14374 // rides in verbatim. Pinned separately from the `^old^new^`
14375 // quick-substitution shape so a future diagnostic-surface change
14376 // that only checked the paired-caret history-substitution
14377 // position surfaces here — the per-byte arm fires anywhere `^`
14378 // appears in the value, including at a solitary leading-of-
14379 // segment position.
14380 let d = dep_with_fonte(DepSource::Path {
14381 caminho: "../foo/^archived".into(),
14382 });
14383 let err = d.validate().unwrap_err();
14384 assert!(
14385 matches!(
14386 err,
14387 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14388 ),
14389 "got {err:?}",
14390 );
14391 }
14392
14393 #[test]
14394 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14395 // The trailing-`^` history-substitution-open shape — an author
14396 // starts typing a `^bad^good` quick-substitution but pastes only
14397 // the leading `^` sentinel before context-switching (a bash-
14398 // reference §9.3 valid histexpand prefix on its own — even a
14399 // solitary `^` on the prior command's whole re-execution shape).
14400 // Pinned separately from the `^old^new^` full-form and the leading-
14401 // of-segment `^archived` regex-anchor shape so the gate's
14402 // rationale extends to the paste-from-shell-history-with-only-
14403 // the-first-byte-selected surface. None of the prior shell-
14404 // metachar arms cover this shape.
14405 let d = dep_with_fonte(DepSource::Path {
14406 caminho: "../caixa-teia^".into(),
14407 });
14408 let err = d.validate().unwrap_err();
14409 assert!(
14410 matches!(
14411 err,
14412 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14413 ),
14414 "got {err:?}",
14415 );
14416 }
14417
14418 #[test]
14419 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14420 // The positive-control pin (peer with
14421 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14422 // on the immediate-predecessor arm): the gate targets only
14423 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14424 // A relative POSIX path carrying dashes / dots / slashes /
14425 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14426 // continue to validate cleanly so the gate doesn't widen to
14427 // a "no printable punctuation anywhere" sweep that would
14428 // defeat the entire path-fonte author surface.
14429 let d = dep_with_fonte(DepSource::Path {
14430 caminho: "../caixa-teia/sub_v2.rc".into(),
14431 });
14432 d.validate().unwrap();
14433 }
14434
14435 #[test]
14436 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14437 // Cascade pin on the immediate-predecessor arm: a value carrying
14438 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14439 // canonical "I pasted a `!sudo` history-reference next to a
14440 // `^bad^good` quick-substitution") routes through
14441 // `FonteCaminhoShellHistoryExpansion` not
14442 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14443 // the more semantic-locating axis on probe-as-both values (an
14444 // author who removes the `!sudo` reference is likely to also
14445 // strip the paired `^` substitution fragment); same cascade
14446 // discipline every prior `:caminho` arm establishes.
14447 let d = dep_with_fonte(DepSource::Path {
14448 caminho: "../foo!sudo^bad^good".into(),
14449 });
14450 let err = d.validate().unwrap_err();
14451 assert!(
14452 matches!(
14453 err,
14454 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14455 ),
14456 "got {err:?}",
14457 );
14458 }
14459
14460 #[test]
14461 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14462 // Cascade pin on the immediate-successor arm: a value carrying
14463 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14464 // the canonical "I tab-completed a `^bad^good`-carrying path")
14465 // routes through `FonteCaminhoShellHistorySubstitution` not
14466 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14467 // substitution byte is the more semantic-locating axis on probe-
14468 // as-both values (an author who removes the `^bad^good`
14469 // substitution fragment is likely to also tab-strip the trailing
14470 // separator).
14471 let d = dep_with_fonte(DepSource::Path {
14472 caminho: "../foo^bad^good/".into(),
14473 });
14474 let err = d.validate().unwrap_err();
14475 assert!(
14476 matches!(
14477 err,
14478 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14479 ),
14480 "got {err:?}",
14481 );
14482 }
14483
14484 #[test]
14485 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14486 {
14487 // Diagnostic-shape pin (peer with
14488 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14489 // on the immediate-predecessor arm): the error's Display
14490 // surfaces the offending `:nome`, the offending `:caminho`
14491 // verbatim, the offending byte's hex form, and names the
14492 // shell-history-substitution / RFC-3986-'unwise' / regex-
14493 // negation footgun explicitly so a `feira lint` run can render
14494 // the diagnostic without re-parsing.
14495 let d = dep_with_fonte(DepSource::Path {
14496 caminho: "../foo^bad^good".into(),
14497 });
14498 let rendered = d.validate().unwrap_err().to_string();
14499 assert!(
14500 rendered.contains("caixa-teia"),
14501 "diagnostic must name the offending dep: {rendered}",
14502 );
14503 assert!(
14504 rendered.contains("../foo^bad^good"),
14505 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14506 );
14507 assert!(
14508 rendered.contains("0x5e") || rendered.contains("0x5E"),
14509 "diagnostic must surface the offending byte hex: {rendered:?}",
14510 );
14511 assert!(
14512 rendered.contains("history-substitution") || rendered.contains("history substitution"),
14513 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14514 );
14515 assert!(
14516 rendered.contains("unwise"),
14517 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14518 );
14519 }
14520
14521 #[test]
14522 fn fonte_repo_empty_fires_before_pin_missing() {
14523 // Order pin: empty `:repo` is the more self-locating diagnostic
14524 // (every git source needs a repo; the pin discussion is
14525 // secondary), so it fires before the pin-missing arm even when
14526 // both are violated. Mirrors the
14527 // `nome_empty_takes_precedence_over_versao_invalid` ordering
14528 // discipline on the per-entry layer.
14529 let d = dep_with_fonte(DepSource::Git {
14530 repo: String::new(),
14531 tag: None,
14532 rev: None,
14533 branch: None,
14534 });
14535 let err = d.validate().unwrap_err();
14536 assert!(
14537 matches!(err, DepError::FonteRepoEmpty { .. }),
14538 "got {err:?}"
14539 );
14540 }
14541
14542 #[test]
14543 fn fonte_pin_missing_fires_before_pin_empty() {
14544 // Order pin: a fully-None pin set is structurally distinct from
14545 // a Some(empty) pin — the first surfaces as FontePinMissing
14546 // (no axis chosen), the second as FontePinEmpty (axis chosen
14547 // but value blank). Pin the disjoint relationship so a future
14548 // unification collapses to one variant only as a structural
14549 // decision.
14550 let d = dep_with_fonte(DepSource::Git {
14551 repo: "github:pleme-io/caixa-teia".into(),
14552 tag: None,
14553 rev: None,
14554 branch: None,
14555 });
14556 assert!(matches!(
14557 d.validate().unwrap_err(),
14558 DepError::FontePinMissing { .. }
14559 ));
14560 }
14561
14562 #[test]
14563 fn nome_empty_takes_precedence_over_fonte_invalid() {
14564 // Order pin: a per-entry diagnostic without a non-empty :nome
14565 // can't be self-locating, so :nome "" fires first even when
14566 // :fonte is also malformed. Mirrors
14567 // `nome_empty_takes_precedence_over_versao_invalid` on the
14568 // adjacent axis.
14569 let mut d = dep_with_fonte(DepSource::Git {
14570 repo: String::new(),
14571 tag: None,
14572 rev: None,
14573 branch: None,
14574 });
14575 d.nome = String::new();
14576 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14577 }
14578
14579 #[test]
14580 fn versao_invalid_takes_precedence_over_fonte_invalid() {
14581 // Order pin: the :versao parse-side diagnostic is narrower than
14582 // the :fonte shape diagnostic — a malformed :versao always names
14583 // the parser's reason, which is more actionable than the
14584 // :fonte gate's "the pins are wrong" wording. Pin the ordering
14585 // so a re-ordering surfaces here.
14586 let mut d = dep_with_fonte(DepSource::Git {
14587 repo: String::new(),
14588 tag: None,
14589 rev: None,
14590 branch: None,
14591 });
14592 d.versao = "v0.1".into();
14593 let err = d.validate().unwrap_err();
14594 assert!(
14595 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14596 "got {err:?}"
14597 );
14598 }
14599
14600 #[test]
14601 fn fonte_invalid_diagnostic_carries_offending_nome() {
14602 // The diagnostic-shape pin: every :fonte error variant names
14603 // the offending dep's :nome verbatim, so the author can grep
14604 // caixa.lisp for the `:nome "<n>"` block and fix it in one
14605 // edit. Cover all seven variants so a future variant addition
14606 // forces a parallel diagnostic-shape decision.
14607 for (case, fonte) in [
14608 (
14609 "repo-empty",
14610 DepSource::Git {
14611 repo: String::new(),
14612 tag: Some("v1".into()),
14613 rev: None,
14614 branch: None,
14615 },
14616 ),
14617 (
14618 "repo-shape",
14619 DepSource::Git {
14620 repo: "github:p/x ".into(),
14621 tag: Some("v1".into()),
14622 rev: None,
14623 branch: None,
14624 },
14625 ),
14626 (
14627 "pin-missing",
14628 DepSource::Git {
14629 repo: "github:p/x".into(),
14630 tag: None,
14631 rev: None,
14632 branch: None,
14633 },
14634 ),
14635 (
14636 "pin-ambiguous",
14637 DepSource::Git {
14638 repo: "github:p/x".into(),
14639 tag: Some("v1".into()),
14640 rev: None,
14641 branch: Some("main".into()),
14642 },
14643 ),
14644 (
14645 "pin-empty",
14646 DepSource::Git {
14647 repo: "github:p/x".into(),
14648 tag: Some(String::new()),
14649 rev: None,
14650 branch: None,
14651 },
14652 ),
14653 (
14654 "caminho-empty",
14655 DepSource::Path {
14656 caminho: String::new(),
14657 },
14658 ),
14659 (
14660 "caminho-absolute",
14661 DepSource::Path {
14662 caminho: "/home/me/work/caixa-teia".into(),
14663 },
14664 ),
14665 ] {
14666 let d = dep_with_fonte(fonte);
14667 let msg = d
14668 .validate()
14669 .expect_err(&format!("{case}: expected fonte error"))
14670 .to_string();
14671 assert!(
14672 msg.contains("\"caixa-teia\""),
14673 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14674 );
14675 }
14676 }
14677
14678 // -- :tag / :branch value-shape gate ----------------------------------
14679
14680 #[test]
14681 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14682 // The canonical paste-from-doc footgun on `:tag` — author
14683 // copies `"v0.1.0 "` (trailing space) out of a release-notes
14684 // paragraph. Until this gate landed the empty-pin arm passed
14685 // (the string isn't empty), the resolver issued
14686 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14687 // surfaced at clone time with a quoting-confused git error
14688 // far from the source caixa.lisp. The new gate moves the
14689 // check to caixa-build time and names the offending dep +
14690 // pin + value verbatim.
14691 let d = dep_with_fonte(DepSource::Git {
14692 repo: "github:pleme-io/caixa-teia".into(),
14693 tag: Some("v0.1.0 ".into()),
14694 rev: None,
14695 branch: None,
14696 });
14697 let err = d.validate().unwrap_err();
14698 let DepError::FontePinShape {
14699 nome,
14700 pin,
14701 value,
14702 reason,
14703 } = err
14704 else {
14705 panic!("expected FontePinShape, got other variant");
14706 };
14707 assert_eq!(nome, "caixa-teia");
14708 assert_eq!(pin, ":tag");
14709 assert_eq!(value, "v0.1.0 ");
14710 assert!(
14711 reason.contains("whitespace"),
14712 "reason must surface the whitespace arm, got {reason:?}"
14713 );
14714 }
14715
14716 #[test]
14717 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14718 // The `.lock` suffix is git's atomic-rename guard for
14719 // in-flight ref updates — a refname ending in `.lock` is
14720 // unwritable on disk. Pinned separately from the whitespace
14721 // arm so a future relaxation that admits one but not the
14722 // other surfaces here.
14723 let d = dep_with_fonte(DepSource::Git {
14724 repo: "github:pleme-io/caixa-teia".into(),
14725 tag: Some("v0.1.0.lock".into()),
14726 rev: None,
14727 branch: None,
14728 });
14729 let err = d.validate().unwrap_err();
14730 let DepError::FontePinShape {
14731 pin, value, reason, ..
14732 } = err
14733 else {
14734 panic!("expected FontePinShape, got other variant");
14735 };
14736 assert_eq!(pin, ":tag");
14737 assert_eq!(value, "v0.1.0.lock");
14738 assert!(
14739 reason.contains(".lock"),
14740 "reason must surface the .lock arm, got {reason:?}"
14741 );
14742 }
14743
14744 #[test]
14745 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
14746 // The canonical "branch name with spaces" footgun (`feature
14747 // foo`, `release branch`) — git's refname parser rejects raw
14748 // whitespace, and the failure surfaces at `git checkout
14749 // 'feature foo'` time with a quoting-confused error far from
14750 // the source caixa.lisp. Pinned on the `:branch` axis so the
14751 // gate-applies-to-both-:tag-and-:branch contract is a build-
14752 // error to relax.
14753 let d = dep_with_fonte(DepSource::Git {
14754 repo: "github:pleme-io/caixa-teia".into(),
14755 tag: None,
14756 rev: None,
14757 branch: Some("feature/foo bar".into()),
14758 });
14759 let err = d.validate().unwrap_err();
14760 let DepError::FontePinShape {
14761 pin, value, reason, ..
14762 } = err
14763 else {
14764 panic!("expected FontePinShape, got other variant");
14765 };
14766 assert_eq!(pin, ":branch");
14767 assert_eq!(value, "feature/foo bar");
14768 assert!(
14769 reason.contains("whitespace"),
14770 "reason must surface the whitespace arm, got {reason:?}"
14771 );
14772 }
14773
14774 #[test]
14775 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
14776 // The `refs/heads/main` shape — the canonical "I copied the
14777 // fully-qualified ref out of `git show-ref` instead of the
14778 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
14779 // at clone time, so this resolves to a literal ref named
14780 // `refs/heads/refs/heads/main` on disk; the silent double-
14781 // prefix is the load-bearing reason to gate at validate.
14782 // The diagnostic must enumerate the leaf the author probably
14783 // meant (`"main"`) so the fix is one edit.
14784 let d = dep_with_fonte(DepSource::Git {
14785 repo: "github:pleme-io/caixa-teia".into(),
14786 tag: None,
14787 rev: None,
14788 branch: Some("refs/heads/main".into()),
14789 });
14790 let err = d.validate().unwrap_err();
14791 let DepError::FontePinShape {
14792 pin, value, reason, ..
14793 } = err
14794 else {
14795 panic!("expected FontePinShape, got other variant");
14796 };
14797 assert_eq!(pin, ":branch");
14798 assert_eq!(value, "refs/heads/main");
14799 assert!(
14800 reason.contains("fully-qualified"),
14801 "reason must surface the qualified-prefix arm, got {reason:?}"
14802 );
14803 assert!(
14804 reason.contains("\"main\""),
14805 "reason must quote the leaf the author probably meant, got {reason:?}"
14806 );
14807 }
14808
14809 #[test]
14810 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
14811 // Sibling arm of the qualified-prefix gate on the `:tag`
14812 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
14813 // footgun). Pinned separately so a future relaxation that
14814 // only catches the `:branch` arm surfaces here.
14815 let d = dep_with_fonte(DepSource::Git {
14816 repo: "github:pleme-io/caixa-teia".into(),
14817 tag: Some("refs/tags/v0.1.0".into()),
14818 rev: None,
14819 branch: None,
14820 });
14821 let err = d.validate().unwrap_err();
14822 let DepError::FontePinShape {
14823 pin, value, reason, ..
14824 } = err
14825 else {
14826 panic!("expected FontePinShape, got other variant");
14827 };
14828 assert_eq!(pin, ":tag");
14829 assert_eq!(value, "refs/tags/v0.1.0");
14830 assert!(
14831 reason.contains("fully-qualified"),
14832 "reason must surface the qualified-prefix arm, got {reason:?}"
14833 );
14834 assert!(
14835 reason.contains("\"v0.1.0\""),
14836 "reason must quote the leaf the author probably meant, got {reason:?}"
14837 );
14838 }
14839
14840 #[test]
14841 fn validate_rejects_git_fonte_with_branch_named_at() {
14842 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
14843 // unsourceable. Pinned so a future relaxation that admits
14844 // any single-character refname surfaces here.
14845 let d = dep_with_fonte(DepSource::Git {
14846 repo: "github:pleme-io/caixa-teia".into(),
14847 tag: None,
14848 rev: None,
14849 branch: Some("@".into()),
14850 });
14851 let err = d.validate().unwrap_err();
14852 let DepError::FontePinShape { pin, value, .. } = err else {
14853 panic!("expected FontePinShape, got other variant");
14854 };
14855 assert_eq!(pin, ":branch");
14856 assert_eq!(value, "@");
14857 }
14858
14859 #[test]
14860 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
14861 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
14862 // a `:tag "../escape"` (path-traversal-shaped slug) silently
14863 // passes parse and surfaces as a refname-parse error or, on
14864 // older git, a literal `../escape` checkout that escapes the
14865 // refs/ directory tree. Pinned separately from the
14866 // qualified-prefix arm so a future relaxation that catches
14867 // one but not the other surfaces here.
14868 let d = dep_with_fonte(DepSource::Git {
14869 repo: "github:pleme-io/caixa-teia".into(),
14870 tag: Some("../escape".into()),
14871 rev: None,
14872 branch: None,
14873 });
14874 let err = d.validate().unwrap_err();
14875 let DepError::FontePinShape { pin, value, .. } = err else {
14876 panic!("expected FontePinShape, got other variant");
14877 };
14878 assert_eq!(pin, ":tag");
14879 assert_eq!(value, "../escape");
14880 }
14881
14882 #[test]
14883 fn validate_accepts_git_fonte_with_hierarchical_branch() {
14884 // The positive-control pin: hierarchical refnames with one or
14885 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
14886 // canonical idiom) round-trip through the gate. Pinned
14887 // separately from the leaf-`"main"` positive control so a
14888 // future tightening that rejects all multi-component refnames
14889 // surfaces here.
14890 let d = dep_with_fonte(DepSource::Git {
14891 repo: "github:pleme-io/caixa-teia".into(),
14892 tag: None,
14893 rev: None,
14894 branch: Some("feature/checkout-rewrite".into()),
14895 });
14896 d.validate().unwrap();
14897 }
14898
14899 #[test]
14900 fn validate_accepts_git_fonte_with_prerelease_tag() {
14901 // The positive-control pin: semver pre-release shape
14902 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
14903 // (only consecutive `..` and trailing `.` are rejected), the
14904 // mid-component hyphen is allowed. Pinned separately from
14905 // the bare-`"v0.1.0"` positive control so a future tightening
14906 // that rejects pre-release tags surfaces here.
14907 let d = dep_with_fonte(DepSource::Git {
14908 repo: "github:pleme-io/caixa-teia".into(),
14909 tag: Some("v0.1.0-alpha.1".into()),
14910 rev: None,
14911 branch: None,
14912 });
14913 d.validate().unwrap();
14914 }
14915
14916 #[test]
14917 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
14918 // The `:rev` axis is routed through `crate::render::is_git_oid`
14919 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
14920 // value with refname-shape punctuation (here, a `:` mid-string
14921 // — would be a refname violation under `is_git_ref_name` too)
14922 // is rejected at the OID-shape gate. The two predicates
14923 // partition the `:fonte` pin axes structurally: an `:rev` value
14924 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
14925 // *still* rejected here because every refname character outside
14926 // `[0-9a-f]` fails the OID gate. Same shape as
14927 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
14928 // on the refname-shaped axes — the diagnostic names the
14929 // offending dep + pin + value verbatim. The flip-from-accept
14930 // case the prior `:tag`/`:branch` gate left as a "future axis"
14931 // (e70d213) — now landed.
14932 let d = dep_with_fonte(DepSource::Git {
14933 repo: "github:pleme-io/caixa-teia".into(),
14934 tag: None,
14935 rev: Some("c0ffee:notarefname".into()),
14936 branch: None,
14937 });
14938 let err = d.validate().unwrap_err();
14939 let DepError::FontePinShape {
14940 nome,
14941 pin,
14942 value,
14943 reason,
14944 } = err
14945 else {
14946 panic!("expected FontePinShape, got other variant");
14947 };
14948 assert_eq!(nome, "caixa-teia");
14949 assert_eq!(pin, ":rev");
14950 assert_eq!(value, "c0ffee:notarefname");
14951 assert!(
14952 !reason.is_empty(),
14953 "FontePinShape `reason` must carry the predicate's wording verbatim"
14954 );
14955 }
14956
14957 #[test]
14958 fn validate_accepts_git_fonte_with_rev_full_sha1() {
14959 // The positive-control pin on the SHA-1 OID width: exactly 40
14960 // lowercase hex characters — the canonical `git rev-parse HEAD`
14961 // emission on a SHA-1-hashed repository (the default on every
14962 // pre-2.42 git and the canonical pleme-io substrate hash).
14963 // Pinned separately from the SHA-256 positive control so a
14964 // future tightening that only admits one width surfaces here.
14965 let d = dep_with_fonte(DepSource::Git {
14966 repo: "github:pleme-io/caixa-teia".into(),
14967 tag: None,
14968 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
14969 branch: None,
14970 });
14971 d.validate().unwrap();
14972 }
14973
14974 #[test]
14975 fn validate_accepts_git_fonte_with_rev_full_sha256() {
14976 // The positive-control pin on the SHA-256 OID width: exactly
14977 // 64 lowercase hex characters — `git`'s
14978 // `extensions.objectFormat = sha256` emission (GA since Git
14979 // 2.42 / Oct 2023). The substrate admits either canonical
14980 // width so an `:rev` authored against a SHA-256-hashed
14981 // upstream round-trips through the gate without per-repo
14982 // configuration. Pinned separately from the SHA-1 positive
14983 // control so a future tightening that drops one width surfaces
14984 // here as a structural decision.
14985 let d = dep_with_fonte(DepSource::Git {
14986 repo: "github:pleme-io/caixa-teia".into(),
14987 tag: None,
14988 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
14989 branch: None,
14990 });
14991 d.validate().unwrap();
14992 }
14993
14994 #[test]
14995 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
14996 // The canonical `git log --short` / `git rev-parse --short HEAD`
14997 // paste-from-release-notes footgun: a 7-char prefix (git's
14998 // default `core.abbrev`) silently passes string emptiness
14999 // checks and resolves to one commit today, but becomes ambiguous
15000 // tomorrow as the repo grows. Until this gate landed the empty-
15001 // pin arm passed (the string isn't empty) and the resolver
15002 // accepted the prefix through git's separate prefix-lookup pass
15003 // — defeating the reproducibility contract `:rev` carries vs.
15004 // `:tag` / `:branch`. The new gate moves the check to caixa-
15005 // build time and names the offending dep + pin + value verbatim.
15006 let d = dep_with_fonte(DepSource::Git {
15007 repo: "github:pleme-io/caixa-teia".into(),
15008 tag: None,
15009 rev: Some("c0ffee0".into()),
15010 branch: None,
15011 });
15012 let err = d.validate().unwrap_err();
15013 let DepError::FontePinShape {
15014 pin, value, reason, ..
15015 } = err
15016 else {
15017 panic!("expected FontePinShape, got other variant");
15018 };
15019 assert_eq!(pin, ":rev");
15020 assert_eq!(value, "c0ffee0");
15021 assert!(
15022 reason.contains("abbreviated") || reason.contains("ambiguous"),
15023 "reason must surface the abbreviation arm, got {reason:?}"
15024 );
15025 }
15026
15027 #[test]
15028 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15029 // The canonical "I pasted the SHA in uppercase" footgun: `git
15030 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15031 // bearing `:rev` round-trips inconsistently across the
15032 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15033 // equality-check pipeline and fails the lacre's content-
15034 // addressing probe with a confusing case-only diff. Pinned
15035 // separately from the non-hex arm so a future relaxation that
15036 // admits one but not the other surfaces here.
15037 let d = dep_with_fonte(DepSource::Git {
15038 repo: "github:pleme-io/caixa-teia".into(),
15039 tag: None,
15040 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15041 branch: None,
15042 });
15043 let err = d.validate().unwrap_err();
15044 let DepError::FontePinShape {
15045 pin, value, reason, ..
15046 } = err
15047 else {
15048 panic!("expected FontePinShape, got other variant");
15049 };
15050 assert_eq!(pin, ":rev");
15051 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15052 assert!(
15053 reason.contains("uppercase"),
15054 "reason must surface the uppercase arm, got {reason:?}"
15055 );
15056 }
15057
15058 #[test]
15059 fn validate_rejects_git_fonte_with_rev_refname_value() {
15060 // The cross-axis mis-slot footgun: `:rev "main"` — the author
15061 // conflated `:rev` (hex commit ID, immutable) and `:branch`
15062 // (mutable ref pointing at whatever HEAD is today). Until this
15063 // gate landed the resolver silently dispatched on the value
15064 // shape ("`main` doesn't look like a SHA, fall back to
15065 // refname"), defeating the `:rev` reproducibility contract.
15066 // The new gate rejects every non-hex value on the `:rev` axis,
15067 // so the `:rev`/`:branch` boundary is structurally enforced —
15068 // a refname in the `:rev` slot is a build error, not a
15069 // resolver-time silent reinterpretation.
15070 let d = dep_with_fonte(DepSource::Git {
15071 repo: "github:pleme-io/caixa-teia".into(),
15072 tag: None,
15073 rev: Some("main".into()),
15074 branch: None,
15075 });
15076 let err = d.validate().unwrap_err();
15077 let DepError::FontePinShape {
15078 pin, value, reason, ..
15079 } = err
15080 else {
15081 panic!("expected FontePinShape, got other variant");
15082 };
15083 assert_eq!(pin, ":rev");
15084 assert_eq!(value, "main");
15085 // 4 chars `main` fails the length arm before the character arm,
15086 // so the diagnostic surfaces the abbreviation wording (same
15087 // path the `c0ffee0` 7-char fixture lands on); the structural
15088 // assertion is just that the `:rev "main"` value is rejected.
15089 assert!(
15090 !reason.is_empty(),
15091 "FontePinShape reason must be non-empty for refname-shaped :rev"
15092 );
15093 }
15094
15095 #[test]
15096 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15097 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15098 // conflated `:rev` and `:tag`. Pinned separately from the
15099 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15100 // that catches one but not the other surfaces here. The
15101 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15102 // assertion is just that the cross-axis mis-slot is a build
15103 // error, regardless of which sub-arm surfaces the diagnostic
15104 // (`is_git_oid` rejects at the first violation; longer
15105 // tag-shape values would hit the non-hex arm instead).
15106 let d = dep_with_fonte(DepSource::Git {
15107 repo: "github:pleme-io/caixa-teia".into(),
15108 tag: None,
15109 rev: Some("v0.1.0".into()),
15110 branch: None,
15111 });
15112 let err = d.validate().unwrap_err();
15113 let DepError::FontePinShape {
15114 pin, value, reason, ..
15115 } = err
15116 else {
15117 panic!("expected FontePinShape, got other variant");
15118 };
15119 assert_eq!(pin, ":rev");
15120 assert_eq!(value, "v0.1.0");
15121 assert!(
15122 !reason.is_empty(),
15123 "FontePinShape reason must be non-empty for tag-shaped :rev"
15124 );
15125 }
15126
15127 #[test]
15128 fn validate_rejects_git_fonte_with_rev_too_long() {
15129 // Boundary case on the upper end: 41 hex chars — one past the
15130 // SHA-1 width, well below the SHA-256 width. Pin so a future
15131 // relaxation that admits "long enough to be a SHA" without
15132 // matching either canonical width surfaces here. The diagnostic
15133 // names the offending length verbatim so the author's grep
15134 // target is unambiguous (either trim one char or paste the
15135 // full SHA-256).
15136 let too_long: String = "0".repeat(41);
15137 let d = dep_with_fonte(DepSource::Git {
15138 repo: "github:pleme-io/caixa-teia".into(),
15139 tag: None,
15140 rev: Some(too_long.clone()),
15141 branch: None,
15142 });
15143 let err = d.validate().unwrap_err();
15144 let DepError::FontePinShape {
15145 pin, value, reason, ..
15146 } = err
15147 else {
15148 panic!("expected FontePinShape, got other variant");
15149 };
15150 assert_eq!(pin, ":rev");
15151 assert_eq!(value, too_long);
15152 assert!(
15153 reason.contains("41"),
15154 "reason must surface the offending length verbatim, got {reason:?}"
15155 );
15156 }
15157
15158 #[test]
15159 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15160 // The canonical paste-from-doc footgun on `:rev` — author
15161 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15162 // commit-message paragraph. Until this gate landed the empty-
15163 // pin arm passed (the string isn't empty), the resolver issued
15164 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15165 // clone time with a quoting-confused git error far from the
15166 // source caixa.lisp. The new gate moves the check to caixa-
15167 // build time. Length is 41 (40 hex + space) so the length arm
15168 // fires first — pinned separately from the pure-length arm to
15169 // ensure the diagnostic surfaces *some* parser wording, not
15170 // silently pass through.
15171 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15172 let d = dep_with_fonte(DepSource::Git {
15173 repo: "github:pleme-io/caixa-teia".into(),
15174 tag: None,
15175 rev: Some(with_space.clone()),
15176 branch: None,
15177 });
15178 let err = d.validate().unwrap_err();
15179 let DepError::FontePinShape {
15180 pin, value, reason, ..
15181 } = err
15182 else {
15183 panic!("expected FontePinShape, got other variant");
15184 };
15185 assert_eq!(pin, ":rev");
15186 assert_eq!(value, with_space);
15187 assert!(
15188 !reason.is_empty(),
15189 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15190 );
15191 }
15192
15193 #[test]
15194 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15195 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15196 // variant on this axis names the offending dep's `:nome` + the
15197 // `:rev` axis + the offending value verbatim, so the author's
15198 // grep target is the literal `:rev "<value>"` block in
15199 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15200 // carries_offending_nome_pin_value` test on the refname-shaped
15201 // (`:tag` / `:branch`) axes.
15202 let d = dep_with_fonte(DepSource::Git {
15203 repo: "github:p/x".into(),
15204 tag: None,
15205 rev: Some("not-a-sha".into()),
15206 branch: None,
15207 });
15208 let msg = d
15209 .validate()
15210 .expect_err(":rev: expected FontePinShape")
15211 .to_string();
15212 assert!(
15213 msg.contains("\"caixa-teia\""),
15214 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15215 );
15216 assert!(
15217 msg.contains(":rev"),
15218 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15219 );
15220 assert!(
15221 msg.contains("not-a-sha"),
15222 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15223 );
15224 }
15225
15226 #[test]
15227 fn fonte_pin_empty_fires_before_pin_shape() {
15228 // Order pin: a `Some("")` `:tag` is the more self-locating
15229 // diagnostic (the author chose an axis but left it blank;
15230 // grep is unambiguous), so it fires before the shape gate
15231 // even when both arms would match. Pinned so a future
15232 // reordering surfaces here. Mirrors the
15233 // `fonte_repo_empty_fires_before_pin_missing` ordering
15234 // discipline on the peer per-axis arms.
15235 let d = dep_with_fonte(DepSource::Git {
15236 repo: "github:pleme-io/caixa-teia".into(),
15237 tag: Some(String::new()),
15238 rev: None,
15239 branch: None,
15240 });
15241 assert!(matches!(
15242 d.validate().unwrap_err(),
15243 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15244 ));
15245 }
15246
15247 #[test]
15248 fn fonte_pin_shape_fires_after_repo_empty() {
15249 // Order pin: `:repo ""` is the more self-locating axis
15250 // (every git source needs a repo; the per-pin shape gate is
15251 // secondary), so the repo-empty arm fires before the
15252 // per-pin shape arm even when both are violated. Pinned so
15253 // a future reordering surfaces here. Mirrors
15254 // `fonte_repo_empty_fires_before_pin_missing` on the
15255 // adjacent axis pair.
15256 let d = dep_with_fonte(DepSource::Git {
15257 repo: String::new(),
15258 tag: Some("v0.1.0 ".into()),
15259 rev: None,
15260 branch: None,
15261 });
15262 assert!(matches!(
15263 d.validate().unwrap_err(),
15264 DepError::FonteRepoEmpty { .. }
15265 ));
15266 }
15267
15268 #[test]
15269 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15270 // Diagnostic-shape pin across both refname-shaped axes
15271 // (`:tag` + `:branch`): every `FontePinShape` variant names
15272 // the offending dep's `:nome` + the offending pin axis + the
15273 // offending value verbatim, so the author's grep target is
15274 // unambiguous (the literal `:tag "<value>"` / `:branch
15275 // "<value>"` lands in caixa.lisp with quotes). Cover both
15276 // pin axes so a future variant addition forces a parallel
15277 // diagnostic-shape decision.
15278 for (pin_label, fonte) in [
15279 (
15280 ":tag",
15281 DepSource::Git {
15282 repo: "github:p/x".into(),
15283 tag: Some("v0.1.0~1".into()),
15284 rev: None,
15285 branch: None,
15286 },
15287 ),
15288 (
15289 ":branch",
15290 DepSource::Git {
15291 repo: "github:p/x".into(),
15292 tag: None,
15293 rev: None,
15294 branch: Some("feature/foo*".into()),
15295 },
15296 ),
15297 ] {
15298 let d = dep_with_fonte(fonte);
15299 let msg = d
15300 .validate()
15301 .expect_err(&format!("{pin_label}: expected FontePinShape"))
15302 .to_string();
15303 assert!(
15304 msg.contains("\"caixa-teia\""),
15305 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15306 );
15307 assert!(
15308 msg.contains(pin_label),
15309 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15310 );
15311 }
15312 }
15313
15314 #[test]
15315 fn git_source_json_round_trip() {
15316 let src = DepSource::Git {
15317 repo: "github:pleme-io/caixa-teia".into(),
15318 tag: Some("v0.1.0".into()),
15319 rev: None,
15320 branch: None,
15321 };
15322 let s = serde_json::to_string(&src).unwrap();
15323 assert!(s.contains(&format!(
15324 r#""{tipo}":"{git}""#,
15325 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15326 git = crate::render::DEP_SOURCE_TIPO_GIT,
15327 )));
15328 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15329 assert!(s.contains(r#""tag":"v0.1.0""#));
15330 assert!(!s.contains("rev"));
15331 assert!(!s.contains("branch"));
15332 let round: DepSource = serde_json::from_str(&s).unwrap();
15333 assert_eq!(round, src);
15334 }
15335
15336 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15337 //
15338 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15339 // attribute on [`DepSource`] pins three load-bearing byte-sequences
15340 // that flow into every serialized `Dep.fonte` block: the outer
15341 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15342 // the two admitted variant-tag values `"git"` / `"path"` the
15343 // `rename_all = "lowercase"` attribute pins as the discriminator's
15344 // closed-set arms. The three pin tests below round-trip a
15345 // fully-populated variant of each arm through
15346 // [`serde_json::to_value`] and assert each canonical byte-sequence
15347 // appears at its axis — pins a hypothetical future
15348 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15349 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15350 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15351 // at build time rather than at fetch time when the resolver's
15352 // `Dep.fonte` dispatch silently fails to match on the drifted
15353 // discriminator. Same "serialize-and-check" discipline the peer
15354 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15355 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15356 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15357 // family in caixa-core lacking a lifted peer.
15358
15359 #[test]
15360 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15361 // Fail-before-pass-after: a future `tag = "type"` at the derive
15362 // attribute would serialize under `"type":"git"`, and this test
15363 // would trip because `"tipo"` no longer appears at the emitted
15364 // discriminator key. A future `rename_all = "kebab-case"` /
15365 // `"snake_case"` (both no-ops on `Git` since it lacks internal
15366 // word boundaries) is caught by the sibling
15367 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15368 // pin below (Path has no internal boundary either but the pair
15369 // catches any per-arm inconsistency). A future variant rename
15370 // `Git` → `Repository` would emit `"tipo":"repository"` and
15371 // trip this pin.
15372 let src = DepSource::Git {
15373 repo: "github:pleme-io/caixa-teia".into(),
15374 tag: Some("v0.1.0".into()),
15375 rev: None,
15376 branch: None,
15377 };
15378 let json = serde_json::to_value(&src).unwrap();
15379 let obj = json.as_object().expect("Git serializes as a JSON object");
15380 assert_eq!(
15381 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15382 .and_then(serde_json::Value::as_str),
15383 Some(crate::render::DEP_SOURCE_TIPO_GIT),
15384 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15385 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15386 detected in {json}"
15387 );
15388 }
15389
15390 #[test]
15391 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15392 // Fail-before-pass-after: a future variant rename `Path` →
15393 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15394 // this pin. A per-consumer disambiguation as the `defcaixa`
15395 // macro stabilizes ("caminho" → "path" for English-uniformity)
15396 // is scoped to the inner field key, not the discriminator; this
15397 // pin is orthogonal to that and catches only the outer
15398 // discriminator drift.
15399 let src = DepSource::Path {
15400 caminho: "../caixa-teia".into(),
15401 };
15402 let json = serde_json::to_value(&src).unwrap();
15403 let obj = json.as_object().expect("Path serializes as a JSON object");
15404 assert_eq!(
15405 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15406 .and_then(serde_json::Value::as_str),
15407 Some(crate::render::DEP_SOURCE_TIPO_PATH),
15408 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15409 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15410 detected in {json}"
15411 );
15412 }
15413
15414 #[test]
15415 fn dep_source_key_consts_are_pairwise_distinct() {
15416 // Cross-axis collapse detector: a hypothetical future edit that
15417 // accidentally set two of the three consts to the same byte
15418 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15419 // pass every per-arm serialize pin above but silently collapse
15420 // the discriminator's closed-set arms onto one another; this pin
15421 // catches the collapse at build time.
15422 assert_ne!(
15423 crate::render::DEP_SOURCE_KEY_TIPO,
15424 crate::render::DEP_SOURCE_TIPO_GIT,
15425 );
15426 assert_ne!(
15427 crate::render::DEP_SOURCE_KEY_TIPO,
15428 crate::render::DEP_SOURCE_TIPO_PATH,
15429 );
15430 assert_ne!(
15431 crate::render::DEP_SOURCE_TIPO_GIT,
15432 crate::render::DEP_SOURCE_TIPO_PATH,
15433 );
15434 }
15435
15436 #[test]
15437 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15438 // Shape pin against `rename_all` drift: the two variant-tag
15439 // consts must be ASCII-lowercase-only to match the
15440 // `rename_all = "lowercase"` attribute the derive uses; a future
15441 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15442 // would emit `"GIT"` / `"Git"` instead and trip this pin.
15443 for (label, s) in [
15444 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15445 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15446 ] {
15447 assert!(!s.is_empty(), "{label} must not be empty");
15448 assert!(
15449 s.bytes().all(|b| b.is_ascii_lowercase()),
15450 "{label} must be ASCII-lowercase-only (matching \
15451 rename_all = \"lowercase\"), got {s:?}",
15452 );
15453 }
15454 }
15455
15456 // ── per-entry :caracteristicas set-not-multiset gate ────────────
15457 //
15458 // Every Vec-keyed-by-name authoring surface on the typed Caixa
15459 // surface that identifies its entries by a name field now uniformly
15460 // closes the set-not-multiset discipline at build time (cite
15461 // `validate_caracteristicas`'s peer-axis enumeration). The
15462 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15463 // set-shaped (a feature is either enabled or not — there is no
15464 // `feature × 2` semantic), so two entries naming the same feature
15465 // are a redundant declaration the caixa-resolver's lacre pipeline
15466 // would silently dedup at resolve time. The empty-feature arm
15467 // closes the parallel "operationally-meaningless value" axis on
15468 // the same slot. Same linear-walk + `HashSet` + first-collision
15469 // shape every peer set gate uses; same empty-first cascade every
15470 // peer per-entry shape + duplicate gate uses (the empty-feature
15471 // axis is the more-actionable defect since two `""` entries would
15472 // both report `caracteristica: ""` under a duplicate-first
15473 // ordering, with no way to distinguish the offending site).
15474
15475 fn dep_with_features(features: &[&str]) -> Dep {
15476 Dep {
15477 nome: "caixa-teia".into(),
15478 versao: "^0.1".into(),
15479 fonte: None,
15480 opcional: false,
15481 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15482 }
15483 }
15484
15485 #[test]
15486 fn validate_rejects_empty_caracteristica() {
15487 // Fail-before-pass-after pin: every pre-gate codebase accepted
15488 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15489 // imposed no per-entry shape contract), the dep validated, and
15490 // the empty feature would have reached the future caixa-resolver
15491 // lacre pipeline as a no-op feature enable — silently dropping
15492 // the author's intent far from the source `caixa.lisp`. The new
15493 // gate surfaces the structural defect at the typed-validate
15494 // surface with a self-locating diagnostic naming the offending
15495 // dep's `:nome`.
15496 let d = dep_with_features(&[""]);
15497 assert!(
15498 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15499 "expected CaracteristicaEmpty, got {:?}",
15500 d.validate(),
15501 );
15502 }
15503
15504 #[test]
15505 fn validate_rejects_duplicate_caracteristica() {
15506 // Fail-before-pass-after pin on the set-not-multiset arm: the
15507 // feature-toggle slot is set-shaped, so `(:caracteristicas
15508 // ("http" "http"))` is a redundant declaration the lacre
15509 // pipeline dedupes silently at resolve time. The diagnostic
15510 // names the offending dep + the colliding feature verbatim so
15511 // the author can grep their caixa.lisp for `:caracteristicas`
15512 // and fix it in one edit. First-collision determinism is
15513 // pinned separately below.
15514 let d = dep_with_features(&["http", "http"]);
15515 assert!(
15516 matches!(
15517 d.validate().unwrap_err(),
15518 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15519 if nome == "caixa-teia" && caracteristica == "http"
15520 ),
15521 "expected CaracteristicaDuplicate, got {:?}",
15522 d.validate(),
15523 );
15524 }
15525
15526 #[test]
15527 fn validate_accepts_distinct_caracteristicas() {
15528 // The canonical authoring shape — every feature distinct — must
15529 // remain a clean pass (positive control sweep). Covers the
15530 // canonical kebab-case feature names a target caixa typically
15531 // declares.
15532 dep_with_features(&["http", "json", "tls"])
15533 .validate()
15534 .unwrap();
15535 }
15536
15537 #[test]
15538 fn validate_accepts_single_caracteristica() {
15539 // Single-element list is the minimum non-empty shape; passes
15540 // the gate as the identity of the duplicate check (no second
15541 // entry to collide with).
15542 dep_with_features(&["http"]).validate().unwrap();
15543 }
15544
15545 #[test]
15546 fn validate_accepts_empty_caracteristicas_list() {
15547 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15548 // produces `caracteristicas: Vec::new()`; the empty list is
15549 // the gate's empty-set identity and passes vacuously. Pin
15550 // this so a future tightening that requires ≥1 feature
15551 // surfaces here as a test failure rather than a silent
15552 // contract narrowing.
15553 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15554 assert!(dep_with_features(&[]).validate().is_ok());
15555 }
15556
15557 #[test]
15558 fn validate_caracteristica_empty_fires_before_duplicate() {
15559 // Empty-first cascade: an entry with an empty feature *and*
15560 // duplicate entries surfaces the empty diagnostic first. The
15561 // empty-feature axis is the more-actionable defect since
15562 // `caracteristica: ""` is unambiguous; under duplicate-first
15563 // ordering the diagnostic could report the empty string from
15564 // either of two empty entries with no way to distinguish.
15565 // Mirrors the peer empty-before-duplicate ordering
15566 // discipline every per-entry shape + duplicate gate establishes
15567 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15568 // `DuplicateChildCaixa`, `validate_membros`'s
15569 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15570 let d = dep_with_features(&["", "http", "http"]);
15571 assert!(matches!(
15572 d.validate().unwrap_err(),
15573 DepError::CaracteristicaEmpty { .. }
15574 ));
15575 }
15576
15577 #[test]
15578 fn validate_caracteristica_duplicate_first_collision_determinism() {
15579 // Three matching entries: the second occurrence surfaces the
15580 // diagnostic (the second is the first *collision* — the first
15581 // entry is the establishing one, not a duplicate). Mirrors
15582 // every peer first-collision posture
15583 // (`SupervisorError::DuplicateChildCaixa` reports the second
15584 // collision, `AplicacaoError::MembroDuplicate` reports the
15585 // second, `DepError::DuplicateNome` reports the second).
15586 // Pinning this so a future shortcut that flips to last-
15587 // collision (or non-deterministic) surfaces here.
15588 let d = dep_with_features(&["http", "http", "http"]);
15589 assert!(matches!(
15590 d.validate().unwrap_err(),
15591 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15592 ));
15593 }
15594
15595 #[test]
15596 fn validate_per_entry_shape_fires_before_caracteristicas() {
15597 // Per-entry shape precedence: a dep with a malformed `:nome`
15598 // (uppercase) AND duplicate `:caracteristicas` surfaces the
15599 // narrower `NomeInvalid` diagnostic first, not the set-gate
15600 // diagnostic. The `:nome` is the self-locating axis (every
15601 // diagnostic from the caracteristicas gate quotes the
15602 // offending dep's `:nome` to anchor the grep target —
15603 // surfacing the malformed name first keeps that anchor
15604 // valid). Same precedence shape every peer per-entry-shape
15605 // arm establishes against its peer set-gate
15606 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15607 // on the cross-entry `:nome` axis).
15608 let d = Dep {
15609 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15610 versao: "^0.1".into(),
15611 fonte: None,
15612 opcional: false,
15613 caracteristicas: vec!["http".into(), "http".into()],
15614 };
15615 assert!(matches!(
15616 d.validate().unwrap_err(),
15617 DepError::NomeInvalid { .. }
15618 ));
15619 }
15620
15621 // ── per-entry :caracteristicas value-shape gate ──────────────────
15622 //
15623 // Until this gate landed `:caracteristicas` only refused the empty
15624 // string and cross-entry duplicates: a non-empty distinct but
15625 // structurally invalid feature name silently passed validate and the
15626 // failure surfaced at `cargo metadata` time as Cargo's
15627 // `restricted_names::validate_feature_name` parser rejection, far from
15628 // the source `caixa.lisp` with no field naming which `:deps` entry's
15629 // `:caracteristicas` carried the typo. The lifted predicate makes the
15630 // Cargo-feature-name-grammar intersection-floor a substrate-level
15631 // invariant at validate time. Same trajectory as the eight peer
15632 // value-shape predicates each typed surface downstream of a structured
15633 // grammar already follows.
15634
15635 #[test]
15636 fn validate_rejects_caracteristica_with_leading_plus() {
15637 // Fail-before-pass-after pin on the canonical Cargo
15638 // `+<feature>` activation-form-in-feature-name-slot footgun.
15639 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15640 // `+optional-feature` as an enablement of a previously-disabled
15641 // feature; pasting that activation form into `:caracteristicas`
15642 // (which names the feature itself) silently passed pre-gate and
15643 // failed at `cargo metadata` parse time.
15644 let d = dep_with_features(&["+http"]);
15645 let err = d.validate().unwrap_err();
15646 assert!(
15647 matches!(
15648 err,
15649 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15650 if nome == "caixa-teia" && caracteristica == "+http"
15651 ),
15652 "expected CaracteristicaInvalid, got {err:?}"
15653 );
15654 }
15655
15656 #[test]
15657 fn validate_rejects_caracteristica_with_leading_hyphen() {
15658 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15659 // is a legitimate continuation character (kebab-case feature
15660 // names like `runtime-tokio` pass) but Cargo rejects it at the
15661 // start; the structural defect — and its CLI-argument-injection
15662 // adjacency at any downstream Cargo subprocess invocation — is
15663 // closed at validate time, not at `cargo metadata` time.
15664 let d = dep_with_features(&["-json"]);
15665 let err = d.validate().unwrap_err();
15666 assert!(
15667 matches!(
15668 err,
15669 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15670 ),
15671 "expected CaracteristicaInvalid, got {err:?}"
15672 );
15673 }
15674
15675 #[test]
15676 fn validate_rejects_caracteristica_with_leading_dot() {
15677 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15678 // a legitimate continuation character (version-suffix shapes
15679 // like `feat.v2` pass) but the leading-dot form is the
15680 // canonical dotted-version-suffix-as-feature-name confusion.
15681 let d = dep_with_features(&[".feat"]);
15682 let err = d.validate().unwrap_err();
15683 assert!(matches!(
15684 err,
15685 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15686 ));
15687 }
15688
15689 #[test]
15690 fn validate_rejects_caracteristica_with_whitespace() {
15691 // Fail-before-pass-after pin on the embedded-whitespace footgun:
15692 // a feature name with a space inside is structurally a multi-
15693 // token blob (the canonical paste-from-doc footgun, or an
15694 // accidental `"http server"` where the author meant
15695 // `"http-server"`).
15696 let d = dep_with_features(&["http feature"]);
15697 let err = d.validate().unwrap_err();
15698 assert!(matches!(
15699 err,
15700 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15701 ));
15702 }
15703
15704 #[test]
15705 fn validate_rejects_caracteristica_with_comma() {
15706 // Fail-before-pass-after pin on the embedded-comma footgun:
15707 // the list-separator-belongs-to-the-list-grammar
15708 // miscomprehension where the author writes
15709 // `:caracteristicas ("http,json")` intending two features but
15710 // the `Vec<String>` field consumes the bare token as one entry.
15711 let d = dep_with_features(&["http,json"]);
15712 let err = d.validate().unwrap_err();
15713 assert!(matches!(
15714 err,
15715 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15716 ));
15717 }
15718
15719 #[test]
15720 fn validate_rejects_caracteristica_with_slash() {
15721 // Fail-before-pass-after pin on the embedded-slash footgun:
15722 // Cargo's `dep/feat` namespaced-dep syntax applies inside
15723 // `[dependencies.<dep>.features]` list entries that already
15724 // name the parent dep (so the syntax says "enable feature
15725 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
15726 // per-dep already (a sibling slot on the `Dep` itself), so the
15727 // segment separator within an entry must be `-`, `_`, `+`,
15728 // or `.`. The diagnostic remediation points at the canonical
15729 // Cargo namespaced-dep discipline.
15730 let d = dep_with_features(&["http/json"]);
15731 let err = d.validate().unwrap_err();
15732 assert!(matches!(
15733 err,
15734 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
15735 ));
15736 }
15737
15738 #[test]
15739 fn validate_rejects_caracteristica_with_non_ascii() {
15740 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
15741 // byte footgun: NFC-vs-NFD normalization across filesystems
15742 // silently rewrites the feature-key, breaking the lacre's
15743 // content-addressing invariant. Pinned at a canonical
15744 // smart-quote-paste shape (`café`) where the raw `é` byte is the
15745 // documented APFS round-trip break.
15746 let d = dep_with_features(&["caf\u{e9}"]);
15747 let err = d.validate().unwrap_err();
15748 assert!(matches!(
15749 err,
15750 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
15751 ));
15752 }
15753
15754 #[test]
15755 fn validate_rejects_caracteristica_with_control_character() {
15756 // Fail-before-pass-after pin on the embedded-control-character
15757 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
15758 // feature name is the canonical paste-from-multiline-doc
15759 // footgun the predicate's reason wording specifically calls out.
15760 let d = dep_with_features(&["http\njson"]);
15761 let err = d.validate().unwrap_err();
15762 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
15763 }
15764
15765 #[test]
15766 fn validate_accepts_canonical_caracteristicas_shapes() {
15767 // Positive control sweep: every canonical Cargo feature name
15768 // shape the pleme-io ecosystem uses must still pass. Mirrors
15769 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
15770 // sweep — drift between either landing site and the predicate's
15771 // accepted set is a build error visible at this pair of tests,
15772 // not a per-renderer "this passed validate but failed at
15773 // cargo metadata time" surprise on the next acceptance.
15774 for s in [
15775 "http",
15776 "json",
15777 "derive",
15778 "serde_json",
15779 "runtime-tokio",
15780 "tokio.full",
15781 "v0.1",
15782 "http+json",
15783 "_internal",
15784 "__private",
15785 "default",
15786 "rt-multi-thread",
15787 "feat.v2",
15788 ] {
15789 let d = dep_with_features(&[s]);
15790 d.validate().unwrap_or_else(|e| {
15791 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
15792 });
15793 }
15794 }
15795
15796 #[test]
15797 fn validate_caracteristica_empty_fires_before_invalid() {
15798 // Cascade precedence pin: an entry list with both an empty
15799 // feature AND an invalid-shape feature surfaces the
15800 // `CaracteristicaEmpty` arm first (the empty value carries no
15801 // self-locating data — `caracteristica: ""` is the diagnostic
15802 // with no way to anchor a grep target — so closing the empty
15803 // axis first preserves the per-entry-shape diagnostic's
15804 // self-locating discipline). Same empty-first cascade every
15805 // peer per-entry shape gate establishes
15806 // (`SupervisorSpec::validate`'s `EmptyChildName` before
15807 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
15808 // before `MembroCaixaInvalid`).
15809 let d = dep_with_features(&["", "+http"]);
15810 assert!(matches!(
15811 d.validate().unwrap_err(),
15812 DepError::CaracteristicaEmpty { .. }
15813 ));
15814 }
15815
15816 #[test]
15817 fn validate_caracteristica_invalid_fires_before_duplicate() {
15818 // Per-entry-shape precedence pin: an entry list with the same
15819 // invalid feature shape declared twice surfaces the
15820 // `CaracteristicaInvalid` diagnostic on the first entry, not
15821 // the `CaracteristicaDuplicate` on the second collision. The
15822 // per-entry shape gate fires before the cross-entry set gate
15823 // — same precedence shape every peer two-arm-plus-set gate
15824 // establishes (`SupervisorSpec::validate`'s
15825 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
15826 // `validate_membros`'s `MembroCaixaInvalid` before
15827 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
15828 // cross-list `DuplicateNome`).
15829 let d = dep_with_features(&["+http", "+http"]);
15830 assert!(matches!(
15831 d.validate().unwrap_err(),
15832 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
15833 ));
15834 }
15835
15836 #[test]
15837 fn validate_rejects_caracteristica_at_65_byte_boundary() {
15838 // Boundary pin on the 64-byte cap — both the boundary-accepting
15839 // case and the boundary-exceeding case in one place, so a
15840 // future cap shift surfaces both arms simultaneously, mirroring
15841 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
15842 // predicate-level pin at the dep-axis landing site.
15843 let max_ok = "a".repeat(64);
15844 dep_with_features(&[&max_ok])
15845 .validate()
15846 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
15847 let too_long = "a".repeat(65);
15848 let d = dep_with_features(&[&too_long]);
15849 assert!(matches!(
15850 d.validate().unwrap_err(),
15851 DepError::CaracteristicaInvalid { .. }
15852 ));
15853 }
15854
15855 // ── self-dep cross-slot gate ─────────────────────────────────────
15856
15857 #[test]
15858 fn validate_no_self_dep_rejects_self_in_deps() {
15859 // A caixa whose `:deps` lists its own `:nome` is a one-node
15860 // cycle in the lacre closure's dep-graph traversal — rejected,
15861 // naming the parent and the offending list tag.
15862 let deps = vec![
15863 Dep::simple("caixa-teia", "^0.1"),
15864 Dep::simple("orquestra", "^0.1"),
15865 ];
15866 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
15867 assert!(
15868 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15869 "got {err:?}"
15870 );
15871 }
15872
15873 #[test]
15874 fn validate_no_self_dep_rejects_self_in_deps_dev() {
15875 // Same gate on the `:deps-dev` axis — neither dep list is a
15876 // second-class citizen on the self-edge invariant.
15877 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15878 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
15879 assert!(
15880 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15881 "got {err:?}"
15882 );
15883 }
15884
15885 #[test]
15886 fn validate_no_self_dep_deps_fires_before_deps_dev() {
15887 // Walk order pin: a caixa that self-references on both lists
15888 // surfaces the `:deps` arm first — the load-bearing axis the
15889 // lacre closure resolves at every build. Mirrors the canonical
15890 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
15891 let deps = vec![Dep::simple("orquestra", "^0.1")];
15892 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
15893 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
15894 assert!(
15895 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
15896 "got {err:?}"
15897 );
15898 }
15899
15900 #[test]
15901 fn validate_no_self_dep_accepts_distinct_names() {
15902 // Positive control: every dep names a distinct caixa. The
15903 // canonical author surface — peer of
15904 // [`validate_no_self_supervision_accepts_distinct_children`].
15905 let deps = vec![
15906 Dep::simple("caixa-teia", "^0.1"),
15907 Dep::simple("caixa-arch", "^0.1"),
15908 ];
15909 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
15910 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
15911 }
15912
15913 #[test]
15914 fn validate_no_self_dep_empty_lists_pass() {
15915 // A caixa with no declared deps has nothing to self-reference —
15916 // the gate is vacuously satisfied. Peer of
15917 // [`validate_no_self_supervision_empty_children_is_ok`].
15918 validate_no_self_dep(&[], &[], "orquestra").unwrap();
15919 }
15920
15921 #[test]
15922 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
15923 // Diagnostic-shape pin (peer with
15924 // [`validate_no_self_supervision`]'s diagnostic): the error's
15925 // Display surfaces both the offending list tag and the
15926 // parent's `:nome` verbatim, so the author can grep their
15927 // caixa.lisp for the offending block in one edit. Names
15928 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
15929 // surface — every legitimate "I want to use code from this
15930 // caixa" intent routes through one of those three slots.
15931 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
15932 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
15933 .unwrap_err()
15934 .to_string();
15935 assert!(
15936 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
15937 "diagnostic must name the offending list tag: {rendered}",
15938 );
15939 assert!(
15940 rendered.contains("orquestra"),
15941 "diagnostic must quote the parent caixa name: {rendered}",
15942 );
15943 assert!(
15944 rendered.contains(":bibliotecas"),
15945 "diagnostic must point at the corrective code-surface slot: {rendered}",
15946 );
15947 }
15948
15949 #[test]
15950 fn validate_no_self_dep_accepts_coincidental_substring_match() {
15951 // Identity is exact-string equality, not substring — a dep
15952 // named `"orquestra-helper"` is a distinct caixa even when the
15953 // parent is `"orquestra"`. Pin the exact-match discipline so a
15954 // future relaxation that uses `contains` surfaces here, peer
15955 // with the supervision-tree and Aplicacao-membership gates
15956 // which all use exact-string equality on the typed identity.
15957 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
15958 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
15959 }
15960
15961 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
15962
15963 #[test]
15964 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
15965 // Scalar-value pin: the two author-facing kebab-case labels the
15966 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
15967 // the two-list dep-graph slot axis, one arm per typed slot.
15968 // Mirrors the peer scalar-value pin the sibling
15969 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
15970 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
15971 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
15972 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
15973 // (882f498) M3 top-level author-labels, and
15974 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
15975 // Supervisor top-level author-labels carry, so every kind-scoped
15976 // typed-slot-family axis routes through one canonical per-arm
15977 // declaration.
15978 //
15979 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
15980 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
15981 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
15982 // for symmetry) lands as an edit to exactly one const, and
15983 // every consumer that reaches for the label picks it up at
15984 // build time rather than at runtime as a downstream mismatch on
15985 // a `DepError::DuplicateNome { list: … }` diagnostic far from
15986 // the rename's commit.
15987 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
15988 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
15989 }
15990
15991 #[test]
15992 fn dep_author_key_consts_are_pairwise_distinct() {
15993 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
15994 // must not collapse onto one byte-string. A future copy-paste
15995 // slip that renamed both consts to the same value (or a rebrand
15996 // that dropped the `-dev` suffix from one but not the other)
15997 // would leave every `DepError::DuplicateNome { list: … }`
15998 // diagnostic naming an unattributable list — the linter would
15999 // route the author to the wrong caixa.lisp block, or the
16000 // cross-list precedence gate
16001 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16002 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16003 // duplicate. Peer of the sibling
16004 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16005 // other top-level kind-scoped slot-family axes carry
16006 // (implicitly held by their different byte-values today).
16007 assert_ne!(
16008 crate::render::DEP_AUTHOR_KEY_DEPS,
16009 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16010 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16011 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16012 self-locates the offending block in the author's caixa.lisp",
16013 );
16014 }
16015
16016 #[test]
16017 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16018 // Production-through-const pin: the two per-arm list tags
16019 // [`validate_no_self_dep`] threads onto the `list:` field of a
16020 // returned [`DepError::DepIsSelf`] route through the lifted
16021 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16022 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16023 // the walker (a rename that reaches one arm but not the const,
16024 // or vice versa) surfaces here at build time rather than at
16025 // runtime as a `feira lint` diagnostic naming the wrong list
16026 // tag. Mirror of the peer
16027 // [`crate::Caixa::declared_servico_slots`] production tagger
16028 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16029 // onto the two-list dep-graph gate.
16030 let deps = vec![Dep::simple("orquestra", "^0.1")];
16031 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16032 let DepError::DepIsSelf { list, .. } = err else {
16033 panic!("expected DepIsSelf from :deps walk");
16034 };
16035 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16036
16037 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16038 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16039 let DepError::DepIsSelf { list, .. } = err else {
16040 panic!("expected DepIsSelf from :deps-dev walk");
16041 };
16042 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16043 }
16044
16045 // ── Dep::nome accessor pins ───────────────────────────────────────
16046 //
16047 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16048 // projection over the plain-shorthand / explicit-git / explicit-path
16049 // fixture triad the [`Dep`] docstring lists (so the accessor's
16050 // accept-set is exercised across every author-surface `:fonte`
16051 // shape); by-borrow pointer identity so the projection stays
16052 // zero-copy at every consumer site; and validate-composition through
16053 // the [`validate_no_self_dep`] cross-slot gate reading its
16054 // parent-name equality check through the lifted accessor rather than
16055 // the raw field.
16056
16057 #[test]
16058 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16059 // Plain-shorthand form (`:fonte None`).
16060 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16061 // Explicit git-source form with a tag pin — same accessor path.
16062 assert_eq!(
16063 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16064 "caixa-teia",
16065 );
16066 // Explicit path-source form.
16067 assert_eq!(
16068 Dep {
16069 nome: "caixa-teia".to_string(),
16070 versao: "0.1.0".to_string(),
16071 fonte: Some(DepSource::Path {
16072 caminho: "../caixa-teia".to_string(),
16073 }),
16074 opcional: false,
16075 caracteristicas: Vec::new(),
16076 }
16077 .nome(),
16078 "caixa-teia",
16079 );
16080 // The empty-string `:nome` sentinel (which [`Dep::validate`]
16081 // refuses through the [`DepError::NomeEmpty`] arm) still round-
16082 // trips as an empty `&str` through the accessor — the accessor is
16083 // a projection, not a gate; the gate is [`Dep::validate`].
16084 assert_eq!(Dep::simple("", "^0.1").nome(), "");
16085 }
16086
16087 #[test]
16088 fn dep_nome_is_by_borrow_pointer_identity() {
16089 // Zero-copy pin: the accessor must borrow into the field's own
16090 // storage, not clone. If a future rewrite regresses to
16091 // `self.nome.clone().leak()` or an owned-buffer shape, the two
16092 // pointers diverge and this pin fails at build time.
16093 let d = Dep::simple("caixa-teia", "^0.1");
16094 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16095 }
16096
16097 // ── Dep::versao_requirement accessor pins ─────────────────────────
16098 //
16099 // Three coherence pins on the lifted `Dep::versao_requirement`
16100 // accessor: byte-equal projection over the plain-shorthand /
16101 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16102 // lists plus the empty-sentinel that round-trips as `""` (the accessor
16103 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16104 // borrow pointer identity so the projection stays zero-copy at every
16105 // consumer site; and validate-composition through the
16106 // [`crate::render::require_valid_versao_requirement`] cascade reading
16107 // its requirement-shape check through the lifted accessor rather than
16108 // the raw field.
16109 #[test]
16110 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16111 // Plain-shorthand form (`:fonte None`).
16112 assert_eq!(
16113 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16114 "^0.1",
16115 );
16116 // Explicit git-source form with a tag pin — same accessor path.
16117 assert_eq!(
16118 Dep::git(
16119 "caixa-teia",
16120 "~0.1.2",
16121 "github:pleme-io/caixa-teia",
16122 "v0.1.0"
16123 )
16124 .versao_requirement(),
16125 "~0.1.2",
16126 );
16127 // Explicit path-source form.
16128 assert_eq!(
16129 Dep {
16130 nome: "caixa-teia".to_string(),
16131 versao: "0.1.0".to_string(),
16132 fonte: Some(DepSource::Path {
16133 caminho: "../caixa-teia".to_string(),
16134 }),
16135 opcional: false,
16136 caracteristicas: Vec::new(),
16137 }
16138 .versao_requirement(),
16139 "0.1.0",
16140 );
16141 // The wildcard requirement (`"*"`) — the shorthand
16142 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16143 // verbatim through the accessor as `"*"`, same byte-shape the
16144 // author wrote.
16145 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16146 // The empty-string `:versao` sentinel (which [`Dep::validate`]
16147 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16148 // trips as an empty `&str` through the accessor — the accessor is
16149 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16150 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16151 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16152 }
16153
16154 #[test]
16155 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16156 // Zero-copy pin: the accessor must borrow into the field's own
16157 // storage, not clone. If a future rewrite regresses to
16158 // `self.versao.clone().leak()` or an owned-buffer shape, the two
16159 // pointers diverge and this pin fails at build time. Peer of the
16160 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16161 // discipline extended onto the requirement-carrying axis.
16162 let d = Dep::simple("caixa-teia", "^0.1");
16163 assert!(std::ptr::eq(
16164 d.versao_requirement().as_ptr(),
16165 d.versao.as_ptr(),
16166 ));
16167 }
16168
16169 #[test]
16170 fn dep_validate_reads_requirement_through_accessor() {
16171 // Composition pin: the [`Dep::validate`]
16172 // [`crate::render::require_valid_versao_requirement`] cascade
16173 // consumes the requirement string through the lifted accessor —
16174 // both the requirement-gate input and the
16175 // [`DepError::VersaoInvalid`] error-body carrier route through
16176 // `self.versao_requirement()`. A valid requirement passes
16177 // (positive control); a malformed-but-non-empty requirement fails
16178 // and the diagnostic quotes the offending byte-string verbatim
16179 // (same shape the accessor projects), so a future regression that
16180 // detoured the requirement carrier through a different byte-
16181 // string (say the parsed `VersionReq`'s `Display`, or a
16182 // normalized rewrite) would surface here at build time. The
16183 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16184 // ahead of the parse arm, pinning the empty-first cascade the
16185 // accessor's `""` sentinel round-trip acknowledges.
16186 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16187 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16188 assert!(
16189 matches!(
16190 &err,
16191 DepError::VersaoInvalid {
16192 nome,
16193 versao,
16194 ..
16195 } if nome == "caixa-teia" && versao == "v0.1",
16196 ),
16197 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16198 );
16199 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16200 assert!(
16201 matches!(
16202 &err,
16203 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16204 ),
16205 "expected VersaoEmpty from the empty-first arm, got {err:?}",
16206 );
16207 }
16208
16209 // ── Dep::fonte accessor pins ──────────────────────────────────────
16210 //
16211 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16212 // equal projection over the plain-shorthand (`:fonte None`) /
16213 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16214 // docstring lists (so the accessor's accept-set is exercised across
16215 // every author-surface `:fonte` shape and both `DepSource` variants);
16216 // pointer identity so the borrowed reference points into the field's
16217 // own `Option<DepSource>` storage (not a cloned side-buffer); and
16218 // validate-composition through the [`Dep::validate`] gate reading
16219 // its per-`:fonte` [`DepSource::validate`] delegation through the
16220 // lifted accessor rather than the raw `if let Some(ref fonte) =
16221 // self.fonte` bracket.
16222
16223 #[test]
16224 fn dep_fonte_returns_declared_source_across_shapes() {
16225 // Plain-shorthand form — `:fonte` omitted, accessor projects
16226 // the `None` partition the resolver-side default-fill treats
16227 // as "resolve through `github:<default-org>/<nome>`".
16228 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16229 // Explicit git-source form with a tag pin — same accessor path.
16230 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16231 match git.fonte() {
16232 Some(DepSource::Git {
16233 repo,
16234 tag,
16235 rev,
16236 branch,
16237 }) => {
16238 assert_eq!(repo, "github:pleme-io/caixa-teia");
16239 assert_eq!(tag.as_deref(), Some("v0.1.0"));
16240 assert!(rev.is_none());
16241 assert!(branch.is_none());
16242 }
16243 other => panic!("expected explicit git :fonte, got {other:?}"),
16244 }
16245 // Explicit path-source form — the dev-only local-filesystem
16246 // arm the [`Dep`] docstring's third fixture carries.
16247 let path = Dep {
16248 nome: "caixa-teia".to_string(),
16249 versao: "0.1.0".to_string(),
16250 fonte: Some(DepSource::Path {
16251 caminho: "../caixa-teia".to_string(),
16252 }),
16253 opcional: false,
16254 caracteristicas: Vec::new(),
16255 };
16256 match path.fonte() {
16257 Some(DepSource::Path { caminho }) => {
16258 assert_eq!(caminho, "../caixa-teia");
16259 }
16260 other => panic!("expected explicit path :fonte, got {other:?}"),
16261 }
16262 }
16263
16264 #[test]
16265 fn dep_fonte_is_by_borrow_pointer_identity() {
16266 // Zero-copy pin: the accessor must borrow into the field's own
16267 // `Option<DepSource>` storage, not clone into a side buffer. If
16268 // a future rewrite regresses to `self.fonte.clone()` or an
16269 // owned-buffer shape, the two pointers diverge and this pin
16270 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16271 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16272 // identity pins — same by-borrow discipline extended onto the
16273 // outer-`Dep` `Option<&Composite>` composite-reference axis.
16274 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16275 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16276 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16277 assert!(std::ptr::eq(accessed, raw));
16278 }
16279
16280 #[test]
16281 fn dep_validate_reads_fonte_through_accessor() {
16282 // Composition pin: [`Dep::validate`]'s per-`:fonte`
16283 // [`DepSource::validate`] delegation consumes the typed slot
16284 // through the lifted accessor — an author-omitted `:fonte`
16285 // still passes the outer gate (positive control), an explicit
16286 // well-formed git source with exactly one pin passes, and a
16287 // malformed git source (empty `:repo`) surfaces the
16288 // [`DepError::FonteRepoEmpty`] variant quoting the offending
16289 // dep's `:nome` verbatim so a future regression that detoured
16290 // the `:fonte` delegation through a different path (say a
16291 // per-scope override projector) would surface here at build
16292 // time. Peer of the sibling
16293 // `dep_validate_reads_requirement_through_accessor` composition
16294 // pin on the `:versao` axis.
16295 // Positive control 1: no `:fonte` at all.
16296 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16297 // Positive control 2: well-formed git source.
16298 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16299 .validate()
16300 .unwrap();
16301 // Negative control: empty `:repo` — the accessor still returns
16302 // `Some(&DepSource::Git { repo: "", … })` and the delegated
16303 // `DepSource::validate` gate raises the typed carrier.
16304 let bad = Dep {
16305 nome: "caixa-teia".to_string(),
16306 versao: "^0.1".to_string(),
16307 fonte: Some(DepSource::Git {
16308 repo: String::new(),
16309 tag: Some("v0.1.0".to_string()),
16310 rev: None,
16311 branch: None,
16312 }),
16313 opcional: false,
16314 caracteristicas: Vec::new(),
16315 };
16316 let err = bad.validate().unwrap_err();
16317 assert!(
16318 matches!(
16319 &err,
16320 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16321 ),
16322 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16323 );
16324 }
16325
16326 #[test]
16327 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16328 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16329 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16330 // own `:nome` through the lifted accessor rather than the raw
16331 // field. Fails-before-passes-after: with the accessor lifted the
16332 // gate reads its equality check through `dep.nome() ==
16333 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16334 // the diagnostic still names the offending list tag as expected.
16335 let deps = vec![Dep::simple("orquestra", "^0.1")];
16336 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16337 assert!(matches!(
16338 err,
16339 DepError::DepIsSelf {
16340 ref nome,
16341 list,
16342 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16343 ));
16344 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16345 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16346 assert!(matches!(
16347 err,
16348 DepError::DepIsSelf {
16349 ref nome,
16350 list,
16351 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16352 ));
16353 // A non-matching `:nome` passes through the accessor gate.
16354 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16355 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16356 }
16357
16358 // ── Dep::caracteristicas accessor pins ────────────────────────────
16359 //
16360 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16361 // byte-equal projection over the default-empty / single-entry /
16362 // multi-entry fixture triad (so the accessor's accept-set is
16363 // exercised across every author-surface `:caracteristicas` shape,
16364 // matching the peer sibling family's fixture-triad discipline); by-
16365 // borrow pointer identity so the projection stays zero-copy at every
16366 // consumer site; and validate-composition through the
16367 // [`Dep::validate_caracteristicas`] gate reading its per-entry
16368 // linear walk through the lifted accessor rather than the raw
16369 // `for c in &self.caracteristicas` bracket.
16370
16371 #[test]
16372 fn dep_caracteristicas_returns_declared_features_across_shapes() {
16373 // Default-empty form — the [`Dep::simple`] constructor's
16374 // `Vec::new()` fill; the accessor projects the empty slice
16375 // verbatim (no `None` collapse).
16376 assert!(
16377 Dep::simple("caixa-teia", "^0.1")
16378 .caracteristicas()
16379 .is_empty(),
16380 );
16381 // Single-entry form — the canonical Cargo-shaped one-feature
16382 // enable ([`crate::render::is_cargo_feature_name`] accepts the
16383 // `"http"` byte-string as a valid feature name).
16384 let one = Dep {
16385 nome: "caixa-teia".to_string(),
16386 versao: "^0.1".to_string(),
16387 fonte: None,
16388 opcional: false,
16389 caracteristicas: vec!["http".to_string()],
16390 };
16391 assert_eq!(one.caracteristicas(), &["http".to_string()]);
16392 // Multi-entry form — the substrate's set-shaped multi-feature
16393 // enable, exercising the accessor over a length-two slice with
16394 // no duplicate collapse.
16395 let two = Dep {
16396 nome: "caixa-teia".to_string(),
16397 versao: "^0.1".to_string(),
16398 fonte: None,
16399 opcional: false,
16400 caracteristicas: vec!["http".to_string(), "json".to_string()],
16401 };
16402 assert_eq!(
16403 two.caracteristicas(),
16404 &["http".to_string(), "json".to_string()],
16405 );
16406 }
16407
16408 #[test]
16409 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16410 // Zero-copy pin: the accessor must borrow into the field's own
16411 // `Vec<String>` storage, not clone into a side buffer. If a
16412 // future rewrite regresses to `self.caracteristicas.clone()` or
16413 // an owned-buffer shape, the two pointers diverge and this pin
16414 // fails at build time. Peer of the sibling per-`Dep`
16415 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16416 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16417 // borrow discipline extended onto the outer-`Dep` `&[String]`
16418 // slice-projection axis.
16419 let d = Dep {
16420 nome: "caixa-teia".to_string(),
16421 versao: "^0.1".to_string(),
16422 fonte: None,
16423 opcional: false,
16424 caracteristicas: vec!["http".to_string(), "json".to_string()],
16425 };
16426 assert!(std::ptr::eq(
16427 d.caracteristicas().as_ptr(),
16428 d.caracteristicas.as_ptr(),
16429 ));
16430 }
16431
16432 #[test]
16433 fn dep_validate_reads_caracteristicas_through_accessor() {
16434 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16435 // linear walk consumes the feature-toggle list through the
16436 // lifted accessor — a well-formed `:caracteristicas` set passes
16437 // (positive control), an empty-string entry surfaces the
16438 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16439 // `Dep::nome`, and a within-list duplicate surfaces the
16440 // [`DepError::CaracteristicaDuplicate`] variant so a future
16441 // regression that detoured the walk through a different byte-
16442 // string list (say a per-scope override projector) would surface
16443 // here at build time. Peer of the sibling
16444 // `dep_validate_reads_fonte_through_accessor` /
16445 // `dep_validate_reads_requirement_through_accessor` composition
16446 // pins on the `:fonte` / `:versao` axes.
16447 // Positive control: two distinct well-formed feature names pass.
16448 Dep {
16449 nome: "caixa-teia".to_string(),
16450 versao: "^0.1".to_string(),
16451 fonte: None,
16452 opcional: false,
16453 caracteristicas: vec!["http".to_string(), "json".to_string()],
16454 }
16455 .validate()
16456 .unwrap();
16457 // Negative control 1: empty-string feature-name entry — the
16458 // accessor still returns `&[""]` and the walk raises the typed
16459 // empty-first carrier.
16460 let err = Dep {
16461 nome: "caixa-teia".to_string(),
16462 versao: "^0.1".to_string(),
16463 fonte: None,
16464 opcional: false,
16465 caracteristicas: vec![String::new()],
16466 }
16467 .validate()
16468 .unwrap_err();
16469 assert!(
16470 matches!(
16471 &err,
16472 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16473 ),
16474 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16475 );
16476 // Negative control 2: within-list duplicate — the accessor's
16477 // slice view carries both entries, and the walk's dedup arm
16478 // raises the typed duplicate carrier quoting the offending
16479 // feature name verbatim.
16480 let err = Dep {
16481 nome: "caixa-teia".to_string(),
16482 versao: "^0.1".to_string(),
16483 fonte: None,
16484 opcional: false,
16485 caracteristicas: vec!["http".to_string(), "http".to_string()],
16486 }
16487 .validate()
16488 .unwrap_err();
16489 assert!(
16490 matches!(
16491 &err,
16492 DepError::CaracteristicaDuplicate {
16493 nome,
16494 caracteristica,
16495 } if nome == "caixa-teia" && caracteristica == "http",
16496 ),
16497 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16498 );
16499 }
16500
16501 // ── Dep::opcional accessor pins ───────────────────────────────────
16502 //
16503 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16504 // equal projection over the default-`false` / explicit-`true`
16505 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16506 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16507 // exercising the accessor's accept-set over every author-surface
16508 // `:fonte` shape × every author-surface `:opcional` shape; and by-
16509 // `Copy` idempotency so the projection stays value-return (no
16510 // silent detour to a fresh `&bool` borrow that would introduce a
16511 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16512 // shape elides). No composition pin — `:opcional` does not
16513 // participate in [`Dep::validate`] (an opcional dep with any bool
16514 // value is validate-accepted; the missing-source arm is a resolver-
16515 // side runtime dispatch, not a build-time refusal), so the axis
16516 // reduces to the value-shape + `Copy` pin pair the peer
16517 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16518 // outer-`Option<Copy>` accessor pins already carry.
16519
16520 #[test]
16521 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16522 // Default-`false` form via the [`Dep::simple`] constructor —
16523 // the accessor projects the `false` bit the default-fill sets.
16524 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16525 // Default-`false` form via the [`Dep::git`] constructor — same
16526 // default fill; the accessor projects `false` regardless of the
16527 // `:fonte` arm.
16528 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16529 // Explicit-`true` form × plain-shorthand `:fonte` — the
16530 // canonical author-surface "this dep may be missing" shape.
16531 let plain_true = Dep {
16532 nome: "caixa-teia".to_string(),
16533 versao: "^0.1".to_string(),
16534 fonte: None,
16535 opcional: true,
16536 caracteristicas: Vec::new(),
16537 };
16538 assert!(plain_true.opcional());
16539 // Explicit-`true` form × explicit git-source — the accessor
16540 // projects the bit verbatim regardless of the `:fonte` arm.
16541 let git_true = Dep {
16542 nome: "caixa-teia".to_string(),
16543 versao: "^0.1".to_string(),
16544 fonte: Some(DepSource::Git {
16545 repo: "github:pleme-io/caixa-teia".to_string(),
16546 tag: Some("v0.1.0".to_string()),
16547 rev: None,
16548 branch: None,
16549 }),
16550 opcional: true,
16551 caracteristicas: Vec::new(),
16552 };
16553 assert!(git_true.opcional());
16554 // Explicit-`true` form × explicit path-source — the dev-only
16555 // local-filesystem arm the [`Dep`] docstring's third fixture
16556 // carries.
16557 let path_true = Dep {
16558 nome: "caixa-teia".to_string(),
16559 versao: "0.1.0".to_string(),
16560 fonte: Some(DepSource::Path {
16561 caminho: "../caixa-teia".to_string(),
16562 }),
16563 opcional: true,
16564 caracteristicas: Vec::new(),
16565 };
16566 assert!(path_true.opcional());
16567 }
16568
16569 #[test]
16570 fn dep_opcional_projects_bool_by_copy() {
16571 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16572 // (`bool: Copy`) — the accessor does not borrow `&self` past
16573 // the call (no lifetime on the return type), and calling the
16574 // accessor twice on the same [`Dep`] must yield discriminant-
16575 // equal values (idempotent, no side effects on `&self`). Peer
16576 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16577 // `max_restarts_projects_option_by_copy` (eba5211) /
16578 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16579 // outer-`Caixa` altitude — extended here to the outer-`Dep`
16580 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16581 // replaces the pointer-equality claim the sibling per-`Dep`
16582 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16583 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16584 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16585 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16586 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16587 // the same discriminant, so the axis reduces to discriminant
16588 // equality).
16589 //
16590 // Pins against a future silent detour that returned a fresh
16591 // `&bool` reference (which would type-check but silently
16592 // introduce a borrow of `&self` past the call, collapsing the
16593 // load-bearing "no lifetime on the return type" `Copy`
16594 // projection the plain-`Copy`-scalar axis's `bool` shape
16595 // carries) or a stale-read side effect that flipped the outer
16596 // discriminant on successive calls.
16597 for opcional in [false, true] {
16598 let d = Dep {
16599 nome: "caixa-teia".to_string(),
16600 versao: "^0.1".to_string(),
16601 fonte: None,
16602 opcional,
16603 caracteristicas: Vec::new(),
16604 };
16605 let first = d.opcional();
16606 let second = d.opcional();
16607 assert_eq!(
16608 first, second,
16609 "Dep::opcional must be idempotent — two successive calls \
16610 on the same &self must return the same bool",
16611 );
16612 assert_eq!(
16613 first, opcional,
16614 "Dep::opcional must return :opcional verbatim by Copy — \
16615 got {first}, expected {opcional}",
16616 );
16617 assert_eq!(
16618 d.opcional(),
16619 d.opcional,
16620 "Dep::opcional accessor and self.opcional field access \
16621 must byte-equal — a bit-flip drift would silently split \
16622 the paired resolver-side drop-vs-error dispatch from \
16623 the storage-side default-fill the [`Dep::simple`] / \
16624 [`Dep::git`] constructor pair carries",
16625 );
16626 }
16627 }
16628
16629 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16630
16631 #[test]
16632 fn sole_pin_returns_none_for_path_source() {
16633 // A path source carries no git-ref, so `sole_pin()` returns
16634 // `None` structurally — the sibling arm every git-fetching
16635 // consumer partitions off before reaching for a git-ref. Pins
16636 // the Path-arm branch of the accessor against a future silent
16637 // detour that treats a `Self::Path` as an unpinned-git source
16638 // and returns the wrong "no pin" signal (e.g. the empty string,
16639 // or a hard-coded `Some("HEAD")` matching the caixa-crd
16640 // path-arm `git_ref` fill).
16641 let s = DepSource::Path {
16642 caminho: "../local-caixa".to_string(),
16643 };
16644 assert_eq!(s.sole_pin(), None);
16645 }
16646
16647 #[test]
16648 fn sole_pin_returns_none_for_unpinned_git_source() {
16649 // The [`DepSource::default_github`] shorthand shape carries no
16650 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16651 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16652 // materializes when the author omits `:fonte` entirely, then
16653 // hands to `fetch_git` which raises `ResolveError::MissingPin`
16654 // on the `None` arm — the accessor's return matches the arm
16655 // the resolver's diagnostic keys off.
16656 let s = DepSource::default_github("pleme-io", "caixa-teia");
16657 assert_eq!(s.sole_pin(), None);
16658 }
16659
16660 #[test]
16661 fn sole_pin_returns_rev_when_only_rev_is_set() {
16662 let s = DepSource::Git {
16663 repo: "github:o/x".into(),
16664 tag: None,
16665 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16666 branch: None,
16667 };
16668 assert_eq!(
16669 s.sole_pin(),
16670 Some("deadbeefcafebabe1234567890abcdef12345678")
16671 );
16672 }
16673
16674 #[test]
16675 fn sole_pin_returns_tag_when_only_tag_is_set() {
16676 let s = DepSource::Git {
16677 repo: "github:o/x".into(),
16678 tag: Some("v0.1.0".into()),
16679 rev: None,
16680 branch: None,
16681 };
16682 assert_eq!(s.sole_pin(), Some("v0.1.0"));
16683 }
16684
16685 #[test]
16686 fn sole_pin_returns_branch_when_only_branch_is_set() {
16687 let s = DepSource::Git {
16688 repo: "github:o/x".into(),
16689 tag: None,
16690 rev: None,
16691 branch: Some("main".into()),
16692 };
16693 assert_eq!(s.sole_pin(), Some("main"));
16694 }
16695
16696 #[test]
16697 fn sole_pin_precedence_rev_beats_tag_and_branch() {
16698 // Precedence: rev > tag > branch. Validate() rejects
16699 // multiple-pin shapes, but the accessor's precedence is defined
16700 // for pre-validate consumers (the resolver's `MissingPin`
16701 // diagnostic path, the caixa-crd round-trip's default `"main"`
16702 // fallback) and as defense-in-depth if the gate is ever
16703 // bypassed. Pins the same precedence caixa-resolver's
16704 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16705 // inline.
16706 let s = DepSource::Git {
16707 repo: "github:o/x".into(),
16708 tag: Some("v1".into()),
16709 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16710 branch: Some("main".into()),
16711 };
16712 assert_eq!(
16713 s.sole_pin(),
16714 Some("deadbeefcafebabe1234567890abcdef12345678")
16715 );
16716 }
16717
16718 #[test]
16719 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16720 let s = DepSource::Git {
16721 repo: "github:o/x".into(),
16722 tag: Some("v1".into()),
16723 rev: None,
16724 branch: Some("main".into()),
16725 };
16726 assert_eq!(s.sole_pin(), Some("v1"));
16727 }
16728
16729 #[test]
16730 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
16731 // Fail-before-pass-after byte-parity pin: the substrate accessor
16732 // must return byte-identical to the inline
16733 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
16734 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
16735 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
16736 // time if the accessor's precedence silently drifts from the
16737 // consumer-side cascade — the exact drift this lift converges
16738 // to one substrate primitive to close structurally.
16739 //
16740 // Iterates through the 2^3 = 8 combinations of (tag, rev,
16741 // branch) each-either-`None`-or-`Some`, so every arm of the
16742 // precedence cascade lands under the pin. `validate()` refuses
16743 // the 4 multi-pin combinations, but the accessor's return is
16744 // defined on all 8.
16745 let vals = [Some("R".to_string()), None];
16746 for tag in &vals {
16747 for rev in &vals {
16748 for branch in &vals {
16749 let s = DepSource::Git {
16750 repo: "github:o/x".into(),
16751 tag: tag.clone(),
16752 rev: rev.clone(),
16753 branch: branch.clone(),
16754 };
16755 // The exact inline cascade the two pre-lift
16756 // consumer sites hand-rolled, byte-for-byte.
16757 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
16758 assert_eq!(
16759 s.sole_pin(),
16760 expected,
16761 "sole_pin() must byte-equal \
16762 rev.or(tag).or(branch) for \
16763 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
16764 a drift would silently split caixa-resolver's \
16765 fetch_git checkout target from caixa-crd's \
16766 dep_into_ref git_ref fill",
16767 );
16768 }
16769 }
16770 }
16771 }
16772
16773 // Fail-before-pass-after pins on the eleven
16774 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
16775 // constructors folded from the [`DepSource::validate_caminho`]
16776 // wire-up sites. Each pins the generated ctor's output to the
16777 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
16778 // any wrapper-side lowercase / trim / re-order / silent-field-swap
16779 // regression on the two-field `{ nome: nome.to_string(), caminho:
16780 // caminho.to_string() }` construction surfaces here rather than at
16781 // a downstream diagnostic-shape mismatch. Peer of the sibling
16782 // `empty_child_version_ctor_matches_struct_literal_wrap` /
16783 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
16784 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
16785 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
16786 // pins on the peer `SupervisorError` / `AplicacaoError` /
16787 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
16788
16789 #[test]
16790 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
16791 assert_eq!(
16792 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
16793 DepError::FonteCaminhoAbsolute {
16794 nome: "caixa-teia".to_string(),
16795 caminho: "/home/me/work/caixa-teia".to_string(),
16796 },
16797 "generated fonte_caminho_absolute ctor must produce byte-equal \
16798 DepError to the open-coded struct-literal wrap on the same \
16799 (&str, &str) fixture",
16800 );
16801 }
16802
16803 #[test]
16804 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
16805 assert_eq!(
16806 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
16807 DepError::FonteCaminhoTildeExpansion {
16808 nome: "caixa-teia".to_string(),
16809 caminho: "~/work/caixa-teia".to_string(),
16810 },
16811 );
16812 }
16813
16814 #[test]
16815 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
16816 assert_eq!(
16817 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
16818 DepError::FonteCaminhoVarExpansion {
16819 nome: "caixa-teia".to_string(),
16820 caminho: "$HOME/work/caixa-teia".to_string(),
16821 },
16822 );
16823 }
16824
16825 #[test]
16826 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
16827 assert_eq!(
16828 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
16829 DepError::FonteCaminhoLeadingWhitespace {
16830 nome: "caixa-teia".to_string(),
16831 caminho: " ../caixa-teia".to_string(),
16832 },
16833 );
16834 }
16835
16836 #[test]
16837 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
16838 assert_eq!(
16839 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
16840 DepError::FonteCaminhoLeadingHyphen {
16841 nome: "caixa-teia".to_string(),
16842 caminho: "-rf".to_string(),
16843 },
16844 );
16845 }
16846
16847 #[test]
16848 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
16849 assert_eq!(
16850 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
16851 DepError::FonteCaminhoBackslash {
16852 nome: "caixa-teia".to_string(),
16853 caminho: "..\\caixa-teia".to_string(),
16854 },
16855 );
16856 }
16857
16858 #[test]
16859 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
16860 assert_eq!(
16861 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
16862 DepError::FonteCaminhoShellPipe {
16863 nome: "caixa-teia".to_string(),
16864 caminho: "../caixa-teia|evil".to_string(),
16865 },
16866 );
16867 }
16868
16869 #[test]
16870 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
16871 assert_eq!(
16872 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
16873 DepError::FonteCaminhoShellSemicolon {
16874 nome: "caixa-teia".to_string(),
16875 caminho: "../caixa-teia;evil".to_string(),
16876 },
16877 );
16878 }
16879
16880 #[test]
16881 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
16882 assert_eq!(
16883 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
16884 DepError::FonteCaminhoShellBackground {
16885 nome: "caixa-teia".to_string(),
16886 caminho: "../caixa-teia&".to_string(),
16887 },
16888 );
16889 }
16890
16891 #[test]
16892 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
16893 assert_eq!(
16894 DepError::fonte_caminho_shell_command_substitution(
16895 "caixa-teia",
16896 "../caixa-teia`whoami`",
16897 ),
16898 DepError::FonteCaminhoShellCommandSubstitution {
16899 nome: "caixa-teia".to_string(),
16900 caminho: "../caixa-teia`whoami`".to_string(),
16901 },
16902 );
16903 }
16904
16905 #[test]
16906 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
16907 assert_eq!(
16908 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
16909 DepError::FonteCaminhoTrailingSlash {
16910 nome: "caixa-teia".to_string(),
16911 caminho: "../caixa-teia/".to_string(),
16912 },
16913 );
16914 }
16915
16916 #[test]
16917 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
16918 // Cross-axis pin: sweep the two constructor input axes
16919 // (`nome: &str`, `caminho: &str`) through a non-default fixture
16920 // pair against every generated arm in the
16921 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
16922 // / trim / truncate / re-order on the two-field
16923 // `{ nome, caminho }` construction — or a silent field swap
16924 // between the two axes at codegen time — surfaces here rather
16925 // than at a downstream diagnostic-shape mismatch. Peer of the
16926 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
16927 // to_string` cross-axis routing pin on the peer
16928 // `SupervisorError` envelope, extended here onto the
16929 // `DepError` `{ nome: String, caminho: String }` envelope so
16930 // every substrate-primitive ctor family in caixa-core
16931 // guarantees each `&str`-field construction routes the
16932 // caller's `&str` verbatim through `.to_string()`.
16933 let nome = "sibling-teia";
16934 let caminho = "../workspace/sibling";
16935 let cases: [(DepError, DepError); 11] = [
16936 (
16937 DepError::fonte_caminho_absolute(nome, caminho),
16938 DepError::FonteCaminhoAbsolute {
16939 nome: nome.to_string(),
16940 caminho: caminho.to_string(),
16941 },
16942 ),
16943 (
16944 DepError::fonte_caminho_tilde_expansion(nome, caminho),
16945 DepError::FonteCaminhoTildeExpansion {
16946 nome: nome.to_string(),
16947 caminho: caminho.to_string(),
16948 },
16949 ),
16950 (
16951 DepError::fonte_caminho_var_expansion(nome, caminho),
16952 DepError::FonteCaminhoVarExpansion {
16953 nome: nome.to_string(),
16954 caminho: caminho.to_string(),
16955 },
16956 ),
16957 (
16958 DepError::fonte_caminho_leading_whitespace(nome, caminho),
16959 DepError::FonteCaminhoLeadingWhitespace {
16960 nome: nome.to_string(),
16961 caminho: caminho.to_string(),
16962 },
16963 ),
16964 (
16965 DepError::fonte_caminho_leading_hyphen(nome, caminho),
16966 DepError::FonteCaminhoLeadingHyphen {
16967 nome: nome.to_string(),
16968 caminho: caminho.to_string(),
16969 },
16970 ),
16971 (
16972 DepError::fonte_caminho_backslash(nome, caminho),
16973 DepError::FonteCaminhoBackslash {
16974 nome: nome.to_string(),
16975 caminho: caminho.to_string(),
16976 },
16977 ),
16978 (
16979 DepError::fonte_caminho_shell_pipe(nome, caminho),
16980 DepError::FonteCaminhoShellPipe {
16981 nome: nome.to_string(),
16982 caminho: caminho.to_string(),
16983 },
16984 ),
16985 (
16986 DepError::fonte_caminho_shell_semicolon(nome, caminho),
16987 DepError::FonteCaminhoShellSemicolon {
16988 nome: nome.to_string(),
16989 caminho: caminho.to_string(),
16990 },
16991 ),
16992 (
16993 DepError::fonte_caminho_shell_background(nome, caminho),
16994 DepError::FonteCaminhoShellBackground {
16995 nome: nome.to_string(),
16996 caminho: caminho.to_string(),
16997 },
16998 ),
16999 (
17000 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17001 DepError::FonteCaminhoShellCommandSubstitution {
17002 nome: nome.to_string(),
17003 caminho: caminho.to_string(),
17004 },
17005 ),
17006 (
17007 DepError::fonte_caminho_trailing_slash(nome, caminho),
17008 DepError::FonteCaminhoTrailingSlash {
17009 nome: nome.to_string(),
17010 caminho: caminho.to_string(),
17011 },
17012 ),
17013 ];
17014 for (via_ctor, via_struct_literal) in cases {
17015 assert_eq!(
17016 via_ctor, via_struct_literal,
17017 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17018 through `.to_string()` in declared field order — a field-swap or \
17019 silent-conversion regression surfaces here rather than at a \
17020 downstream diagnostic-shape mismatch",
17021 );
17022 }
17023 }
17024
17025 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17026 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17027 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17028 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17029 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17030
17031 #[test]
17032 fn versao_empty_ctor_matches_struct_literal_wrap() {
17033 assert_eq!(
17034 DepError::versao_empty("caixa-teia"),
17035 DepError::VersaoEmpty {
17036 nome: "caixa-teia".to_string(),
17037 },
17038 );
17039 }
17040
17041 #[test]
17042 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17043 assert_eq!(
17044 DepError::fonte_repo_empty("caixa-teia"),
17045 DepError::FonteRepoEmpty {
17046 nome: "caixa-teia".to_string(),
17047 },
17048 );
17049 }
17050
17051 #[test]
17052 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17053 assert_eq!(
17054 DepError::fonte_pin_missing("caixa-teia"),
17055 DepError::FontePinMissing {
17056 nome: "caixa-teia".to_string(),
17057 },
17058 );
17059 }
17060
17061 #[test]
17062 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17063 assert_eq!(
17064 DepError::fonte_caminho_empty("caixa-teia"),
17065 DepError::FonteCaminhoEmpty {
17066 nome: "caixa-teia".to_string(),
17067 },
17068 );
17069 }
17070
17071 #[test]
17072 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17073 assert_eq!(
17074 DepError::caracteristica_empty("caixa-teia"),
17075 DepError::CaracteristicaEmpty {
17076 nome: "caixa-teia".to_string(),
17077 },
17078 );
17079 }
17080
17081 #[test]
17082 fn dep_nome_only_ctors_route_nome_through_to_string() {
17083 // Cross-axis routing pin: sweep the single constructor input
17084 // axis (`nome: &str`) through a non-default fixture against
17085 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17086 // any wrapper-side lowercase / trim / truncate at codegen time
17087 // — or a silent field re-name away from the canonical `nome`
17088 // axis on any one variant — surfaces here rather than at a
17089 // downstream diagnostic-shape mismatch. Peer of the sibling
17090 // `fonte_caminho_ctors_route_nome_and_caminho_through_
17091 // to_string` cross-axis routing pin on the same envelope's
17092 // two-slot family (f85f145) and of the peer
17093 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17094 // pin on the `SupervisorError` single-slot family (db09650).
17095 let nome = "sibling-teia";
17096 let cases: [(DepError, DepError); 5] = [
17097 (
17098 DepError::versao_empty(nome),
17099 DepError::VersaoEmpty {
17100 nome: nome.to_string(),
17101 },
17102 ),
17103 (
17104 DepError::fonte_repo_empty(nome),
17105 DepError::FonteRepoEmpty {
17106 nome: nome.to_string(),
17107 },
17108 ),
17109 (
17110 DepError::fonte_pin_missing(nome),
17111 DepError::FontePinMissing {
17112 nome: nome.to_string(),
17113 },
17114 ),
17115 (
17116 DepError::fonte_caminho_empty(nome),
17117 DepError::FonteCaminhoEmpty {
17118 nome: nome.to_string(),
17119 },
17120 ),
17121 (
17122 DepError::caracteristica_empty(nome),
17123 DepError::CaracteristicaEmpty {
17124 nome: nome.to_string(),
17125 },
17126 ),
17127 ];
17128 for (via_ctor, via_struct_literal) in cases {
17129 assert_eq!(
17130 via_ctor, via_struct_literal,
17131 "dep_nome_only_ctors!-generated ctor must route `nome` \
17132 through `.to_string()` onto the canonical `nome` field \
17133 — a field-rename or silent-conversion regression surfaces \
17134 here rather than at a downstream diagnostic-shape mismatch",
17135 );
17136 }
17137 }
17138
17139 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17140 // &'static str }` two-slot envelope on `DepError`, strict
17141 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17142 // same envelope's `{ nome: String }` one-slot shape and of the
17143 // peer `supervisor_caixa_only_ctors!` (db09650) on the
17144 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17145
17146 #[test]
17147 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17148 assert_eq!(
17149 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17150 DepError::DuplicateNome {
17151 nome: "caixa-teia".to_string(),
17152 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17153 },
17154 "generated duplicate_nome ctor must produce byte-equal \
17155 `DepError::DuplicateNome` to the pre-lift struct-literal \
17156 wrap on the same scalar fixtures",
17157 );
17158 }
17159
17160 #[test]
17161 fn dep_is_self_ctor_matches_struct_literal_wrap() {
17162 assert_eq!(
17163 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17164 DepError::DepIsSelf {
17165 nome: "orquestra".to_string(),
17166 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17167 },
17168 "generated dep_is_self ctor must produce byte-equal \
17169 `DepError::DepIsSelf` to the pre-lift struct-literal \
17170 wrap on the same scalar fixtures",
17171 );
17172 }
17173
17174 #[test]
17175 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17176 // Cross-axis routing pin: sweep the two constructor input axes
17177 // (`nome: &str`, `list: &'static str`) through non-default
17178 // fixtures against every generated arm in the
17179 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17180 // lowercase / trim / truncate at codegen time — or a silent
17181 // field re-name away from the canonical `nome` / `list` axes
17182 // on any one variant, or a `list` axis silently rerouted
17183 // through `.to_string()` instead of passed as `&'static str`
17184 // verbatim — surfaces here rather than at a downstream
17185 // diagnostic-shape mismatch. Peer of the sibling
17186 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17187 // (792aa92) on the same envelope's one-slot family, and of the
17188 // peer
17189 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17190 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17191 // two-slot `{ caixa: String, reason: String }` shape.
17192 let nome = "sibling-teia";
17193 let cases: [(DepError, DepError); 4] = [
17194 (
17195 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17196 DepError::DuplicateNome {
17197 nome: nome.to_string(),
17198 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17199 },
17200 ),
17201 (
17202 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17203 DepError::DuplicateNome {
17204 nome: nome.to_string(),
17205 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17206 },
17207 ),
17208 (
17209 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17210 DepError::DepIsSelf {
17211 nome: nome.to_string(),
17212 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17213 },
17214 ),
17215 (
17216 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17217 DepError::DepIsSelf {
17218 nome: nome.to_string(),
17219 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17220 },
17221 ),
17222 ];
17223 for (via_ctor, via_struct_literal) in cases {
17224 assert_eq!(
17225 via_ctor, via_struct_literal,
17226 "dep_nome_list_ctors!-generated ctor must route `nome` \
17227 through `.to_string()` onto the canonical `nome` field \
17228 and pass `list` verbatim onto the canonical `&'static str` \
17229 `list` field — a field-rename, silent-conversion, or \
17230 axis-swap regression surfaces here rather than at a \
17231 downstream diagnostic-shape mismatch",
17232 );
17233 }
17234 }
17235
17236 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17237 // value: String, reason: String }` four-slot envelope on
17238 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17239 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17240 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17241 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
17242 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
17243 // envelope. Single-variant lift closing the last open-coded ctor
17244 // site on the `:fonte (:tipo git …)` value-shape trajectory.
17245
17246 #[test]
17247 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17248 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17249 // ctor: sweep both wire-up-shape arms (the refname-pin arm
17250 // routing `":tag"` / `":branch"` value through
17251 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17252 // routing `":rev"` through [`crate::render::is_git_oid`]) and
17253 // assert byte-equal `PartialEq` against the pre-lift
17254 // struct-literal, so any wrapper-side field-rename /
17255 // silent-conversion regression surfaces here rather than at a
17256 // downstream diagnostic-shape mismatch. Peer of the sibling
17257 // per-envelope byte-equal ctor pins
17258 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17259 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17260 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17261 assert_eq!(
17262 DepError::fonte_pin_shape(
17263 "caixa-teia",
17264 ":tag",
17265 "v0.1.0 ",
17266 "trailing whitespace".to_string(),
17267 ),
17268 DepError::FontePinShape {
17269 nome: "caixa-teia".to_string(),
17270 pin: ":tag".to_string(),
17271 value: "v0.1.0 ".to_string(),
17272 reason: "trailing whitespace".to_string(),
17273 },
17274 "fonte_pin_shape ctor must produce byte-equal \
17275 `DepError::FontePinShape` to the pre-lift struct-literal \
17276 wrap on a refname-pin (`:tag` / `:branch`) fixture",
17277 );
17278 assert_eq!(
17279 DepError::fonte_pin_shape(
17280 "caixa-teia",
17281 ":rev",
17282 "DEADBEEF",
17283 "abbreviated OID rejected".to_string(),
17284 ),
17285 DepError::FontePinShape {
17286 nome: "caixa-teia".to_string(),
17287 pin: ":rev".to_string(),
17288 value: "DEADBEEF".to_string(),
17289 reason: "abbreviated OID rejected".to_string(),
17290 },
17291 "fonte_pin_shape ctor must produce byte-equal \
17292 `DepError::FontePinShape` to the pre-lift struct-literal \
17293 wrap on a hex-OID-pin (`:rev`) fixture",
17294 );
17295 }
17296
17297 #[test]
17298 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17299 // Cross-axis routing pin: sweep every one of the four
17300 // constructor input axes (`nome: &str`, `pin: &str`,
17301 // `value: &str`, `reason: String`) through non-default
17302 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17303 // any wrapper-side lowercase / trim / truncate at codegen time
17304 // — or a silent field re-name / axis-swap on any one of the
17305 // four fields, or a `reason` axis silently routed through
17306 // `.to_string()` instead of forwarded owned — surfaces here
17307 // rather than at a downstream diagnostic-shape mismatch. Peer
17308 // of the sibling
17309 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17310 // (792aa92) and
17311 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17312 // pin (6f5e0cd) on the same envelope's one- and two-slot
17313 // families. Distinct-per-axis fixtures rule out any two-axis
17314 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17315 // etc.) that would still pass a same-fixture-per-axis pin.
17316 let nome = "sibling-teia";
17317 let pin = ":branch";
17318 let value = "feature/bar";
17319 let reason = "embedded space".to_string();
17320 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17321 let via_struct_literal = DepError::FontePinShape {
17322 nome: nome.to_string(),
17323 pin: pin.to_string(),
17324 value: value.to_string(),
17325 reason: reason.clone(),
17326 };
17327 assert_eq!(
17328 via_ctor, via_struct_literal,
17329 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17330 through `.to_string()` onto their canonical fields and \
17331 forward `reason` owned onto the canonical `reason` field \
17332 — a field-rename, silent-conversion, or axis-swap \
17333 regression surfaces here rather than at a downstream \
17334 diagnostic-shape mismatch",
17335 );
17336 let DepError::FontePinShape {
17337 nome: n,
17338 pin: p,
17339 value: v,
17340 reason: r,
17341 } = via_ctor
17342 else {
17343 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17344 };
17345 assert_eq!(n, nome);
17346 assert_eq!(p, pin);
17347 assert_eq!(v, value);
17348 assert_eq!(r, reason);
17349 }
17350
17351 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17352 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17353 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17354 // the same envelope's `{ nome: String, caminho: String }` two-slot
17355 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17356 // same envelope's `{ nome: String }` one-slot shape.
17357
17358 #[test]
17359 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17360 assert_eq!(
17361 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17362 DepError::FonteCaminhoControlChar {
17363 nome: "caixa-teia".to_string(),
17364 caminho: "../caixa-teia\x00foo".to_string(),
17365 byte: 0x00,
17366 },
17367 );
17368 }
17369
17370 #[test]
17371 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17372 assert_eq!(
17373 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17374 DepError::FonteCaminhoShellRedirection {
17375 nome: "caixa-teia".to_string(),
17376 caminho: "../caixa-teia>log".to_string(),
17377 byte: b'>',
17378 },
17379 );
17380 }
17381
17382 #[test]
17383 #[allow(
17384 clippy::too_many_lines,
17385 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17386 byte-classification arm on the {nome,caminho,byte} envelope; \
17387 the linear per-variant repetition is exactly what the sweep \
17388 is pinning — a helper macro would hide the shape the fold is \
17389 keying on"
17390 )]
17391 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17392 // Cross-axis routing pin: sweep the three constructor input axes
17393 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17394 // non-default fixture triple against every generated arm in the
17395 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17396 // lowercase / trim / truncate on the two `&str` axes — a silent
17397 // field swap between `nome` and `caminho`, or a silent
17398 // re-classification of the offending byte — surfaces here rather
17399 // than at a downstream diagnostic-shape mismatch. Peer of the
17400 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17401 // to_string` cross-axis routing pin on the same envelope's
17402 // two-slot family (f85f145) and of the sibling
17403 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17404 // same envelope's one-slot family (792aa92), extended here onto
17405 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17406 // envelope so every substrate-primitive ctor family in
17407 // caixa-core's `DepError` envelope guarantees each field routes
17408 // the caller's value verbatim through `.to_string()` (or byte-
17409 // identity for `byte: u8`) in declared field order.
17410 let nome = "sibling-teia";
17411 let caminho = "../workspace/sibling";
17412 let byte = 0x2A_u8;
17413 let cases: [(DepError, DepError); 12] = [
17414 (
17415 DepError::fonte_caminho_control_char(nome, caminho, byte),
17416 DepError::FonteCaminhoControlChar {
17417 nome: nome.to_string(),
17418 caminho: caminho.to_string(),
17419 byte,
17420 },
17421 ),
17422 (
17423 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17424 DepError::FonteCaminhoShellRedirection {
17425 nome: nome.to_string(),
17426 caminho: caminho.to_string(),
17427 byte,
17428 },
17429 ),
17430 (
17431 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17432 DepError::FonteCaminhoShellGlob {
17433 nome: nome.to_string(),
17434 caminho: caminho.to_string(),
17435 byte,
17436 },
17437 ),
17438 (
17439 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17440 DepError::FonteCaminhoShellSubshellGrouping {
17441 nome: nome.to_string(),
17442 caminho: caminho.to_string(),
17443 byte,
17444 },
17445 ),
17446 (
17447 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17448 DepError::FonteCaminhoShellBraceExpansion {
17449 nome: nome.to_string(),
17450 caminho: caminho.to_string(),
17451 byte,
17452 },
17453 ),
17454 (
17455 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17456 DepError::FonteCaminhoShellBracketExpansion {
17457 nome: nome.to_string(),
17458 caminho: caminho.to_string(),
17459 byte,
17460 },
17461 ),
17462 (
17463 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17464 DepError::FonteCaminhoShellQuoteGrouping {
17465 nome: nome.to_string(),
17466 caminho: caminho.to_string(),
17467 byte,
17468 },
17469 ),
17470 (
17471 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17472 DepError::FonteCaminhoShellComment {
17473 nome: nome.to_string(),
17474 caminho: caminho.to_string(),
17475 byte,
17476 },
17477 ),
17478 (
17479 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17480 DepError::FonteCaminhoUrlPercentEncoding {
17481 nome: nome.to_string(),
17482 caminho: caminho.to_string(),
17483 byte,
17484 },
17485 ),
17486 (
17487 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17488 DepError::FonteCaminhoShellVariableExpansion {
17489 nome: nome.to_string(),
17490 caminho: caminho.to_string(),
17491 byte,
17492 },
17493 ),
17494 (
17495 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17496 DepError::FonteCaminhoShellHistoryExpansion {
17497 nome: nome.to_string(),
17498 caminho: caminho.to_string(),
17499 byte,
17500 },
17501 ),
17502 (
17503 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17504 DepError::FonteCaminhoShellHistorySubstitution {
17505 nome: nome.to_string(),
17506 caminho: caminho.to_string(),
17507 byte,
17508 },
17509 ),
17510 ];
17511 for (via_ctor, via_struct_literal) in cases {
17512 assert_eq!(
17513 via_ctor, via_struct_literal,
17514 "fonte_caminho_byte_ctors!-generated ctor must route \
17515 (nome, caminho, byte) through `.to_string()` / byte-\
17516 identity in declared field order — a field-swap or \
17517 silent-conversion regression surfaces here rather than \
17518 at a downstream diagnostic-shape mismatch",
17519 );
17520 }
17521 }
17522
17523 #[test]
17524 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17525 // Fail-before-pass-after byte-parity pin on the lifted
17526 // `impl AsRef<str> for DepList` — asserts the standard-
17527 // library trait impl and the substrate-primitive
17528 // [`super::DepList::as_str`] `pub const fn` accessor resolve
17529 // to the same `&str` per instance across the two-arm closed
17530 // set, so any future silent detour that routes the impl
17531 // through a divergent projection (a per-arm inline
17532 // `match self { DepList::Prod => ":deps", … }` re-inlining
17533 // that opens a compile-time link to the un-lifted arm-literal,
17534 // a swap onto a second projection axis) trips at caixa-core
17535 // test time under `PartialEq` rather than at a downstream
17536 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17537 // every one of the two arms [`super::DepList::ALL`] carries
17538 // so no arm's projection is covered only by the sibling
17539 // `Display` path. Peer of the sibling
17540 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17541 // (1723611) on the top-level dialect-classification closed-
17542 // set typed enum, and the peer
17543 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17544 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17545 // typed enum — the pins together close the substrate
17546 // primitive's `AsRef<str>` projection axis onto the seventh
17547 // (and last unlifted) closed-set typed enum on the caixa
17548 // surface.
17549 for &list in super::DepList::ALL {
17550 assert_eq!(
17551 <super::DepList as AsRef<str>>::as_ref(&list),
17552 list.as_str(),
17553 "AsRef<str> impl on DepList::{list:?} must byte-equal \
17554 DepList::as_str on the same instance — divergence \
17555 signals a silent detour off the substrate-primitive \
17556 accessor"
17557 );
17558 }
17559 }
17560
17561 #[test]
17562 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17563 // Fail-before-pass-after byte-parity pin on the three-path
17564 // convergence discipline the [`super::DepList`] two-list
17565 // dep-graph closed-set typed enum now carries on the `&str`-
17566 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17567 // newly lifted impl), `format!("{v}")` (the pre-existing
17568 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17569 // primitive `pub const fn` accessor both trait impls delegate
17570 // through) must resolve to the same byte-string on every
17571 // instance across the two-arm closed set. Refuses any future
17572 // divergence between the two trait impls (a stray
17573 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17574 // rather than delegating through the shared accessor; a
17575 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17576 // literal cascade) that would silently split the two
17577 // projection paths of the same closed-set typed enum. Mirrors
17578 // the sibling three-path-convergence discipline the peer
17579 // [`crate::CaixaDialeto`] typed enum carries
17580 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17581 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17582 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17583 // d8136db), the peer [`crate::CaixaKind`] triple
17584 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17585 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17586 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17587 // 16d5c7e).
17588 for &list in super::DepList::ALL {
17589 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17590 let via_display: String = format!("{list}");
17591 let via_accessor: &str = list.as_str();
17592 assert_eq!(via_as_ref, via_accessor);
17593 assert_eq!(via_display, via_accessor);
17594 assert_eq!(via_as_ref, via_display.as_str());
17595 }
17596 }
17597
17598 #[test]
17599 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
17600 // Fail-before-pass-after byte-parity pin on the newly lifted
17601 // `impl TryFrom<&str> for DepList` — asserts the standard-
17602 // library trait impl and the substrate-primitive
17603 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
17604 // to the same two-arm accept-set across every arm the
17605 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
17606 // the sibling
17607 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
17608 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
17609 // and the 12 other substrate-wide trait-idiomatic reverse-
17610 // projection routes-through pins — closes the campaign's
17611 // completeness gap on the two-list dep-graph closed-set enum.
17612 for &list in super::DepList::ALL {
17613 let wire = list.as_str();
17614 assert_eq!(
17615 <super::DepList as TryFrom<&str>>::try_from(wire),
17616 Ok(list),
17617 "TryFrom<&str> impl on DepList must round-trip \
17618 DepList::{list:?}.as_str() = {wire:?} back to \
17619 Ok(DepList::{list:?}) — divergence from \
17620 DepList::from_wire signals a silent detour off the \
17621 substrate-primitive accessor"
17622 );
17623 assert_eq!(
17624 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
17625 super::DepList::from_wire(wire),
17626 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
17627 DepList::from_wire on the same input"
17628 );
17629 }
17630 }
17631
17632 #[test]
17633 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
17634 // Rejection witness on the `impl TryFrom<&str> for DepList` —
17635 // sweeps candidate byte-strings outside the two-arm accept-set
17636 // the sibling [`super::DepList::as_str`] emits (`:deps` /
17637 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
17638 // future accidental widening of the trait impl's accept-set (a
17639 // stray case-fold path, a silent inclusion of a rebrand alias
17640 // like `":packages"`, an English rebrand `":dev-deps"` in
17641 // reverse arm-order that would silently swap the two arms) trips
17642 // at caixa-core test time. Peer of the sibling
17643 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
17644 // (5b828ed) rejection witness.
17645 let rejected: &[&str] = &[
17646 "",
17647 " ",
17648 "\t",
17649 "\n",
17650 ":deps ",
17651 " :deps",
17652 ":DEPS",
17653 ":Deps",
17654 ":Deps-Dev",
17655 ":deps_dev",
17656 ":deps-development",
17657 ":dev-deps",
17658 ":packages",
17659 ":packages-dev",
17660 "deps",
17661 "deps-dev",
17662 "Prod",
17663 "Dev",
17664 "prod",
17665 "dev",
17666 "\":deps\"",
17667 "\":deps-dev\"",
17668 ":deps\n",
17669 ":deps-dev\n",
17670 ];
17671 for &input in rejected {
17672 assert_eq!(
17673 <super::DepList as TryFrom<&str>>::try_from(input),
17674 Err(()),
17675 "TryFrom<&str> impl on DepList must reject unknown \
17676 byte-string {input:?} — divergence from \
17677 DepList::from_wire on the same input signals a silent \
17678 accept-set widening past the two lifted \
17679 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
17680 );
17681 assert_eq!(
17682 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
17683 super::DepList::from_wire(input),
17684 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
17685 DepList::from_wire on the same input — divergence signals \
17686 the two reverse-projection paths have drifted onto \
17687 different accept-sets"
17688 );
17689 }
17690 }
17691
17692 #[test]
17693 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
17694 // Fail-before-pass-after byte-parity pin on the newly lifted
17695 // `impl From<DepList> for &'static str` — asserts the standard-
17696 // library trait impl and the substrate-primitive
17697 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17698 // the same two-arm emit-set across every arm the exhaustive
17699 // [`super::DepList::ALL`] slice enumerates. Materializes the
17700 // `<&'static str as From<DepList>>::from` output in a
17701 // `const`-shape binding to make the `'static` lifetime promise
17702 // a build-time invariant — a future accidental downgrade of
17703 // either arm to a non-`&'static str` (a `String::leak()`-
17704 // produced return, a `Box::leak`-cast) trips at caixa-core
17705 // build time rather than at a downstream `'static`-bound
17706 // consumer. Peer of the sibling
17707 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
17708 // (523157d) and the 13 other substrate-wide forward-projection
17709 // routes-through pins.
17710 const PROD: &str = super::DepList::Prod.as_str();
17711 const DEV: &str = super::DepList::Dev.as_str();
17712 for &list in super::DepList::ALL {
17713 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17714 let via_method: &'static str = list.as_str();
17715 assert_eq!(
17716 via_trait, via_method,
17717 "From<DepList> for &'static str impl must round-trip \
17718 DepList::{list:?} to the same lifted \
17719 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17720 DepList::as_str returns — divergence signals a silent \
17721 detour off the substrate-primitive accessor"
17722 );
17723 let via_into: &'static str = list.into();
17724 assert_eq!(
17725 via_into, via_method,
17726 "Into<&'static str>::into on DepList::{list:?} must \
17727 byte-equal DepList::as_str on the same input — the \
17728 blanket-derived Into shape must resolve to the same \
17729 as_str dispatch as the explicit From impl"
17730 );
17731 }
17732 assert_eq!(
17733 [PROD, DEV],
17734 [
17735 crate::render::DEP_AUTHOR_KEY_DEPS,
17736 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17737 ],
17738 "const-context DepList::as_str must resolve to the two lifted \
17739 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
17740 of either arm to a non-const or non-static byte-string breaks \
17741 the `&'static str`-lifetime promise the paired \
17742 From<DepList> for &'static str impl carries by construction"
17743 );
17744 }
17745
17746 #[test]
17747 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
17748 // Cross-axis partition pin: the paired trait-idiomatic
17749 // `From<DepList> for &'static str` forward projection and the
17750 // method-named [`super::DepList::as_str`] forward projection
17751 // must resolve identically on every arm, locking the two paths
17752 // together so any future detour trips at caixa-core test time.
17753 // Then a round-trip witness: every arm's forward `From` output
17754 // re-parses through the paired trait-idiomatic reverse
17755 // `TryFrom<&str>` back to the original variant, closing the
17756 // two-way `DepList ↔ &'static str` round-trip on the trait-
17757 // idiomatic axis pair, mirroring the pre-existing method-named
17758 // `as_str` + `from_wire` round-trip. Peer of the sibling
17759 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
17760 // (523157d).
17761 for &list in super::DepList::ALL {
17762 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17763 let via_method: &'static str = list.as_str();
17764 assert_eq!(
17765 via_trait, via_method,
17766 "From<DepList> for &'static str and DepList::as_str must \
17767 resolve identically on DepList::{list:?} — divergence \
17768 signals the two forward-projection paths have drifted \
17769 onto different emit-sets"
17770 );
17771 }
17772 for &list in super::DepList::ALL {
17773 let emitted: &'static str = list.into();
17774 let re_parsed: Result<super::DepList, ()> =
17775 <super::DepList as TryFrom<&str>>::try_from(emitted);
17776 assert_eq!(
17777 re_parsed,
17778 Ok(list),
17779 "trait-idiomatic axis pair must round-trip \
17780 DepList::{list:?} through `.into::<&'static str>()` and \
17781 back through `TryFrom<&str>` — a break signals the \
17782 forward-emit and reverse-parse axes have drifted onto \
17783 different vocabularies"
17784 );
17785 }
17786 }
17787
17788 #[test]
17789 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
17790 // Fail-before-pass-after byte-parity pin on the newly lifted
17791 // `impl From<&DepList> for &'static str` — asserts the borrowed-
17792 // input standard-library trait impl and the substrate-primitive
17793 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17794 // the same two-arm emit-set across every arm the exhaustive
17795 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
17796 // does not auto-derive the borrowed-input sibling from a paired
17797 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
17798 // U: From<T>` blanket in `core`), so the borrowed-input axis is
17799 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
17800 // shape over [`super::DepList::ALL`] (whose iterator yields
17801 // `&DepList`, not `DepList`) reaches through this impl and no
17802 // other — the paired owned-input [`From<DepList>`] impl requires
17803 // an explicit `.copied()` / dereference before the trait fires.
17804 // Materializes the `<&'static str as From<&DepList>>::from`
17805 // output in a `const`-shape binding to make the `'static`
17806 // lifetime promise a build-time invariant.
17807 const PROD: &str = super::DepList::Prod.as_str();
17808 const DEV: &str = super::DepList::Dev.as_str();
17809 for list in super::DepList::ALL {
17810 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
17811 let via_method: &'static str = list.as_str();
17812 assert_eq!(
17813 via_trait, via_method,
17814 "From<&DepList> for &'static str impl must round-trip \
17815 &DepList::{list:?} to the same lifted \
17816 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17817 DepList::as_str returns — divergence signals a silent \
17818 detour off the substrate-primitive accessor"
17819 );
17820 let via_into: &'static str = list.into();
17821 assert_eq!(
17822 via_into, via_method,
17823 "Into<&'static str>::into on &DepList::{list:?} must \
17824 byte-equal DepList::as_str on the same input — the \
17825 blanket-derived Into shape must resolve to the same \
17826 as_str dispatch as the explicit From impl"
17827 );
17828 }
17829 assert_eq!(
17830 [PROD, DEV],
17831 [
17832 crate::render::DEP_AUTHOR_KEY_DEPS,
17833 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17834 ],
17835 "const-context DepList::as_str must resolve to the two lifted \
17836 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
17837 From<&DepList> for &'static str impl inherits its `'static` \
17838 lifetime promise from the same accessor the owned-input \
17839 sibling routes through"
17840 );
17841 }
17842
17843 #[test]
17844 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
17845 // Cross-axis partition pin: the paired trait-idiomatic
17846 // owned-input `From<DepList> for &'static str` (523157d
17847 // campaign-shape) and borrowed-input `From<&DepList> for
17848 // &'static str` (this lift) forward projections must resolve
17849 // identically on every arm, locking the two input-shape paths
17850 // together so any future detour trips at caixa-core test time.
17851 // Then a witness that a `.iter().map(Into::into)` pipe over
17852 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
17853 // materializes the two-arm accept-set through the borrowed-
17854 // input axis alone — the exact shape a future M4 admission-
17855 // webhook rejection body composer, a future substrate-wide
17856 // per-arm diagnostic column, or a
17857 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
17858 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
17859 // through — closing the two-way owned/borrowed input-shape
17860 // symmetry on the forward-projection trait-idiomatic axis.
17861 for &list in super::DepList::ALL {
17862 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
17863 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
17864 assert_eq!(
17865 owned, borrowed,
17866 "From<DepList> and From<&DepList> for &'static str must \
17867 resolve identically on DepList::{list:?} — divergence \
17868 signals the owned-input and borrowed-input forward-\
17869 projection paths have drifted onto different emit-sets"
17870 );
17871 }
17872 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
17873 let via_method: Vec<&'static str> =
17874 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
17875 assert_eq!(
17876 via_iter, via_method,
17877 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
17878 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
17879 input `From<&DepList> for &'static str` axis is what makes \
17880 the `.iter().map(Into::into)` shape route through the \
17881 substrate-primitive `DepList::as_str` accessor rather than \
17882 through a per-call-site `.copied()` / dereference detour"
17883 );
17884 }
17885}
17886
17887#[cfg(test)]
17888mod dep_source_is_variant_tests {
17889 use super::*;
17890
17891 fn all_variants() -> Vec<(DepSource, &'static str)> {
17892 vec![
17893 (
17894 DepSource::Git {
17895 repo: "github:pleme-io/caixa-teia".into(),
17896 tag: Some("v0.1.0".into()),
17897 rev: None,
17898 branch: None,
17899 },
17900 "Git",
17901 ),
17902 (
17903 DepSource::Path {
17904 caminho: "../caixa-teia".into(),
17905 },
17906 "Path",
17907 ),
17908 ]
17909 }
17910
17911 fn predicate_row(s: &DepSource) -> [bool; 2] {
17912 [s.is_git(), s.is_path()]
17913 }
17914
17915 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
17916 // derive-generated per-arm predicate partition — for every variant
17917 // in `all_variants()`, the observed 2-slot predicate row must equal
17918 // a one-hot row with the `true` at exactly the same index as the
17919 // variant's declaration order. Expected rows are generated live
17920 // from the enumeration rather than transcribed by hand, so a
17921 // copy-paste flip that reroutes one arm through the wrong predicate
17922 // lane trips at the identity-diagonal assertion the way every peer
17923 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
17924 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
17925 // / [`crate::upgrade::UpgradeInstruction`] /
17926 // [`crate::aplicacao::PlacementStrategy`] /
17927 // [`crate::aplicacao::RateLimitUnit`] /
17928 // [`crate::aplicacao::WitTarget`] /
17929 // [`crate::render::PathShapeViolation`] partition pin already does.
17930 #[test]
17931 fn dep_source_is_variant_predicates_partition_the_arm_set() {
17932 let variants = all_variants();
17933 for (idx, (variant, name)) in variants.iter().enumerate() {
17934 let observed = predicate_row(variant);
17935 let mut expected = [false; 2];
17936 expected[idx] = true;
17937 assert_eq!(
17938 observed, expected,
17939 "DepSource::{name} at declaration-order slot {idx} must \
17940 satisfy exactly one is_* predicate (its own); observed \
17941 row must equal the one-hot expected row — a drift \
17942 would silently reroute one `:fonte`-arm consumer \
17943 through the wrong predicate lane"
17944 );
17945 }
17946 }
17947
17948 // Byte-parity pin on the two field-agnostic `matches!` shapes the
17949 // per-arm arm-discriminator predicates replace at any future
17950 // consumer site (a `:fonte`-shape-only lint rule that flags path
17951 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
17952 // a future admission-webhook that rejects `:fonte` shapes outside
17953 // the `is_git()` accept-set, a caixa-lacre indexing pass that
17954 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
17955 // Refuses a future accidental split between the derived predicate
17956 // and its `matches!` shape — a hand-rolled shadow impl that
17957 // overrides one path, an accidental rebrand that leaves one
17958 // consumer on the raw `matches!` form — on the two load-bearing
17959 // `:fonte`-arm-discriminator axes every downstream substrate
17960 // consumer of the dep-source axis keys off.
17961 #[test]
17962 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
17963 for (variant, name) in all_variants() {
17964 let via_matches_git = matches!(variant, DepSource::Git { .. });
17965 let via_predicate_git = variant.is_git();
17966 assert_eq!(
17967 via_predicate_git, via_matches_git,
17968 "DepSource::{name}.is_git() must byte-equal \
17969 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
17970 future converged consumer site would silently \
17971 disagree with its pre-lift shape"
17972 );
17973 let via_matches_path = matches!(variant, DepSource::Path { .. });
17974 let via_predicate_path = variant.is_path();
17975 assert_eq!(
17976 via_predicate_path, via_matches_path,
17977 "DepSource::{name}.is_path() must byte-equal \
17978 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
17979 future converged consumer site would silently \
17980 disagree with its pre-lift shape"
17981 );
17982 }
17983 }
17984
17985 // Cross-pin against every constructor path that materializes a
17986 // [`DepSource`] shape today (the [`DepSource::default_github`]
17987 // resolver-side fallback that materializes an unpinned
17988 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
17989 // surface constructor that materializes a pinned `:tag`-carrying
17990 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
17991 // fixture family builds inline). Every constructor's return must
17992 // satisfy the arm-discriminator predicate the constructor's
17993 // variant name matches — a future constructor addition (an
17994 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
17995 // enclosing docstring already names as a trajectory item) surfaces
17996 // as a build-time failure that names the offending drift when its
17997 // return arm doesn't route through the paired predicate.
17998 #[test]
17999 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
18000 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
18001 assert!(
18002 via_default_github.is_git(),
18003 "DepSource::default_github must materialize a Git-arm shape — \
18004 a future constructor that routed through a non-Git arm \
18005 (a registry-fetch pin, a `DepSource::Feira` promotion) \
18006 would silently split the resolver's unpinned-shorthand \
18007 materializer from the sole_pin() precedence cascade"
18008 );
18009 assert!(
18010 !via_default_github.is_path(),
18011 "DepSource::default_github must NOT materialize a Path-arm \
18012 shape — the paired negation pin"
18013 );
18014
18015 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
18016 .fonte
18017 .expect("Dep::git materializes a Some(fonte)");
18018 assert!(
18019 via_dep_git.is_git(),
18020 "Dep::git's `:fonte` materialization must land on the Git \
18021 arm — the author-surface pinned-git constructor's return \
18022 must route through the paired predicate"
18023 );
18024 assert!(!via_dep_git.is_path(), "paired negation pin");
18025
18026 let via_path = DepSource::Path {
18027 caminho: "../caixa-teia".into(),
18028 };
18029 assert!(
18030 via_path.is_path(),
18031 "the dev-mode Path-arm materialization must satisfy is_path()"
18032 );
18033 assert!(!via_path.is_git(), "paired negation pin");
18034 }
18035
18036 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
18037 // String, reason: String }` three-slot envelope on `DepError`,
18038 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
18039 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
18040 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
18041 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
18042 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
18043 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
18044
18045 #[test]
18046 fn versao_invalid_ctor_matches_struct_literal_wrap() {
18047 assert_eq!(
18048 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
18049 DepError::VersaoInvalid {
18050 nome: "caixa-teia".to_string(),
18051 versao: "^0..1".to_string(),
18052 reason: "invalid comparator".to_string(),
18053 },
18054 "versao_invalid ctor must produce byte-equal \
18055 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
18056 );
18057 }
18058
18059 #[test]
18060 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
18061 assert_eq!(
18062 DepError::fonte_repo_shape(
18063 "caixa-teia",
18064 "-upload-pack=evil",
18065 "leading dash rejected".to_string(),
18066 ),
18067 DepError::FonteRepoShape {
18068 nome: "caixa-teia".to_string(),
18069 repo: "-upload-pack=evil".to_string(),
18070 reason: "leading dash rejected".to_string(),
18071 },
18072 "fonte_repo_shape ctor must produce byte-equal \
18073 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
18074 );
18075 }
18076
18077 #[test]
18078 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
18079 assert_eq!(
18080 DepError::caracteristica_invalid(
18081 "caixa-teia",
18082 "bad feature!",
18083 "embedded space rejected".to_string(),
18084 ),
18085 DepError::CaracteristicaInvalid {
18086 nome: "caixa-teia".to_string(),
18087 caracteristica: "bad feature!".to_string(),
18088 reason: "embedded space rejected".to_string(),
18089 },
18090 "caracteristica_invalid ctor must produce byte-equal \
18091 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
18092 );
18093 }
18094
18095 #[test]
18096 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
18097 // Cross-axis routing pin: sweep the three constructor input axes
18098 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
18099 // distinct-per-axis fixtures against every generated arm in the
18100 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
18101 // lowercase / trim / truncate on the two `&str` axes — a silent
18102 // field swap between `nome`, the middle `<axis>` field, and
18103 // `reason`, or a `reason` axis silently rerouted through
18104 // `.to_string()` instead of forwarded owned — surfaces here rather
18105 // than at a downstream diagnostic-shape mismatch. Peer of the
18106 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
18107 // through_to_string` (0e35793) cross-axis routing pin on the same
18108 // envelope's `{ nome, caminho, byte }` three-slot family and of
18109 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
18110 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
18111 // — extended here onto the `{ nome, <axis>: String, reason:
18112 // String }` three-slot envelope so every substrate-primitive ctor
18113 // family in caixa-core's `DepError` envelope guarantees each field
18114 // routes the caller's value verbatim through `.to_string()` (or
18115 // owned-forward for `reason: String`) in declared field order.
18116 // Distinct-per-axis fixtures rule out any two-axis swap
18117 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
18118 // same-fixture-per-axis pin.
18119 let nome = "sibling-teia";
18120 let axis = "distinct-axis-value";
18121 let reason = "distinct rejection sentence".to_string();
18122 assert_eq!(
18123 DepError::versao_invalid(nome, axis, reason.clone()),
18124 DepError::VersaoInvalid {
18125 nome: nome.to_string(),
18126 versao: axis.to_string(),
18127 reason: reason.clone(),
18128 },
18129 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
18130 `reason` → `reason` in declared field order",
18131 );
18132 assert_eq!(
18133 DepError::fonte_repo_shape(nome, axis, reason.clone()),
18134 DepError::FonteRepoShape {
18135 nome: nome.to_string(),
18136 repo: axis.to_string(),
18137 reason: reason.clone(),
18138 },
18139 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
18140 `reason` → `reason` in declared field order",
18141 );
18142 assert_eq!(
18143 DepError::caracteristica_invalid(nome, axis, reason.clone()),
18144 DepError::CaracteristicaInvalid {
18145 nome: nome.to_string(),
18146 caracteristica: axis.to_string(),
18147 reason: reason.clone(),
18148 },
18149 "caracteristica_invalid must route `nome` → `nome`, \
18150 `axis` → `caracteristica`, `reason` → `reason` in declared \
18151 field order",
18152 );
18153 }
18154
18155 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
18156 // two-slot envelope on `DepError`, missing rung between
18157 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
18158 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
18159 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
18160 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
18161 // two-slot `{ nome, list: &'static str }` envelope (same slot
18162 // count, `&'static str` axis instead of owned `String` axis).
18163
18164 #[test]
18165 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
18166 assert_eq!(
18167 DepError::fonte_pin_empty("caixa-teia", ":tag"),
18168 DepError::FontePinEmpty {
18169 nome: "caixa-teia".to_string(),
18170 pin: ":tag".to_string(),
18171 },
18172 "fonte_pin_empty ctor must produce byte-equal \
18173 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
18174 on the same `(&str, &str)` fixture",
18175 );
18176 }
18177
18178 #[test]
18179 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
18180 assert_eq!(
18181 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
18182 DepError::FontePinAmbiguous {
18183 nome: "caixa-teia".to_string(),
18184 pins: ":tag, :rev".to_string(),
18185 },
18186 "fonte_pin_ambiguous ctor must produce byte-equal \
18187 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
18188 wrap on the same `(&str, &str)` fixture",
18189 );
18190 }
18191
18192 #[test]
18193 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
18194 assert_eq!(
18195 DepError::caracteristica_duplicate("caixa-teia", "http"),
18196 DepError::CaracteristicaDuplicate {
18197 nome: "caixa-teia".to_string(),
18198 caracteristica: "http".to_string(),
18199 },
18200 "caracteristica_duplicate ctor must produce byte-equal \
18201 `DepError::CaracteristicaDuplicate` to the pre-lift \
18202 struct-literal wrap on the same `(&str, &str)` fixture",
18203 );
18204 }
18205
18206 #[test]
18207 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
18208 // Owned-`String` routing pin: thread the real
18209 // `set.join(", ")` `String` carrier through the ctor's
18210 // `&str`-parameter Deref coercion, so the ambiguity-arm
18211 // wire-up site's actual `&set.join(", ")` shape stays
18212 // byte-equal to a direct `":tag, :rev"` literal. A future
18213 // parameter-shape change silently dropping the Deref
18214 // coercion route (e.g., a switch to `impl Into<String>`)
18215 // surfaces here rather than at the wire-up's compile
18216 // error far from the ctor definition.
18217 let set: Vec<&'static str> = vec![":tag", ":rev"];
18218 let joined: String = set.join(", ");
18219 assert_eq!(
18220 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
18221 DepError::FontePinAmbiguous {
18222 nome: "caixa-teia".to_string(),
18223 pins: ":tag, :rev".to_string(),
18224 },
18225 "fonte_pin_ambiguous ctor must accept an owned-`String` \
18226 `&set.join(\", \")` carrier via Deref coercion — the exact \
18227 shape the ambiguity-arm wire-up site passes into it",
18228 );
18229 }
18230
18231 #[test]
18232 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
18233 // Cross-axis routing pin: sweep the two constructor input axes
18234 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
18235 // fixtures against every generated arm in the
18236 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
18237 // trim / truncate at codegen time — a silent field swap between
18238 // `nome` and the middle `<axis>` field, or a `<axis>` axis
18239 // silently rerouted through the wrong field on any one variant
18240 // — surfaces here rather than at a downstream diagnostic-shape
18241 // mismatch. Peer of the sibling
18242 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
18243 // (6f5e0cd) pin on the same envelope's peer two-slot family
18244 // (`{ nome, list: &'static str }`) and of the sibling
18245 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18246 // (5621f8a) pin on the same envelope's three-slot `{ nome,
18247 // <axis>: String, reason: String }` family — extended here onto
18248 // the `{ nome, <axis>: String }` two-slot envelope so the last
18249 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
18250 // ladder guarantees each field routes the caller's value
18251 // verbatim through `.to_string()` in declared field order.
18252 // Distinct-per-axis fixtures rule out any two-axis swap
18253 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
18254 // per-axis pin.
18255 let nome = "sibling-teia";
18256 let axis = "distinct-axis-value";
18257 assert_eq!(
18258 DepError::fonte_pin_empty(nome, axis),
18259 DepError::FontePinEmpty {
18260 nome: nome.to_string(),
18261 pin: axis.to_string(),
18262 },
18263 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
18264 in declared field order",
18265 );
18266 assert_eq!(
18267 DepError::fonte_pin_ambiguous(nome, axis),
18268 DepError::FontePinAmbiguous {
18269 nome: nome.to_string(),
18270 pins: axis.to_string(),
18271 },
18272 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
18273 in declared field order",
18274 );
18275 assert_eq!(
18276 DepError::caracteristica_duplicate(nome, axis),
18277 DepError::CaracteristicaDuplicate {
18278 nome: nome.to_string(),
18279 caracteristica: axis.to_string(),
18280 },
18281 "caracteristica_duplicate must route `nome` → `nome`, \
18282 `axis` → `caracteristica` in declared field order",
18283 );
18284 }
18285
18286 #[test]
18287 fn nome_invalid_ctor_matches_struct_literal_wrap() {
18288 // Equivalence pin: the ctor produces byte-equal
18289 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
18290 // literal that cloned the offending `:deps :nome` verbatim and
18291 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
18292 // owned `reason` payload at the caller site inside
18293 // [`Dep::validate`]. Guards any future field-addition /
18294 // reordering / accessor-return tweak on the variant. Sibling of
18295 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
18296 // (below) and the sibling three-slot
18297 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
18298 // pin on the same envelope's three-slot `{ nome, <axis>: String,
18299 // reason: String }` family.
18300 let nome = "Caixa-Teia";
18301 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
18302 let via_ctor = DepError::nome_invalid(nome, reason.clone());
18303 let via_literal = DepError::NomeInvalid {
18304 nome: nome.to_string(),
18305 reason,
18306 };
18307 assert_eq!(
18308 via_ctor, via_literal,
18309 "nome_invalid(nome, reason) must byte-equal the open-coded \
18310 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
18311 );
18312 assert_eq!(
18313 via_ctor.to_string(),
18314 via_literal.to_string(),
18315 "Display byte-string must byte-equal the open-coded struct-literal"
18316 );
18317 }
18318
18319 #[test]
18320 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
18321 // Boundary-sweep pin on the ctor's two-slot projection: sweep
18322 // the two ctor input axes (`nome: &str`, `reason: String`)
18323 // through distinct-per-axis fixtures against a representative
18324 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
18325 // wrapper-side silent lowercase / trim / truncate at codegen
18326 // time — a silent field swap between `nome` and `reason`, an
18327 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
18328 // divergence on the `reason` axis — surfaces at caixa-core
18329 // build time rather than at a downstream diagnostic consumer
18330 // that reads `err.nome` / `err.reason` back and gets a different
18331 // value than the one it stored. Peer of the sibling
18332 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
18333 // (7f7c950) pin on the same envelope's peer two-slot family
18334 // (`{ nome, <axis>: String }`) — extended here onto the
18335 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
18336 // variant carries. Distinct-per-axis fixtures rule out any
18337 // two-axis swap (`nome` ↔ `reason`) that would still pass a
18338 // same-fixture-per-axis pin. The sweep list carries a mixed
18339 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
18340 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
18341 // over-63-byte) so a future silent per-input normalization
18342 // surfaces on the arm that diverges.
18343 for nome in [
18344 "Caixa-Teia",
18345 "caixa_teia",
18346 "caixa.teia",
18347 "-caixa-teia",
18348 "caixa-teia-",
18349 "caixa/teia",
18350 &"a".repeat(64),
18351 ] {
18352 let reason = crate::render::is_dns_1123_label(nome)
18353 .expect_err("fixture must be a DNS-1123-refused label");
18354 let via_ctor = DepError::nome_invalid(nome, reason.clone());
18355 let DepError::NomeInvalid {
18356 nome: stored_nome,
18357 reason: stored_reason,
18358 } = via_ctor
18359 else {
18360 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
18361 };
18362 assert_eq!(
18363 stored_nome, nome,
18364 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
18365 );
18366 assert_eq!(
18367 stored_reason, reason,
18368 "reason slot must forward the owned `String` verbatim for {nome:?}"
18369 );
18370 }
18371 }
18372
18373 #[test]
18374 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
18375 // End-to-end pin: the sole in-crate wire-up site
18376 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
18377 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
18378 // the ctor's output on the same DNS-1123-refused `:deps :nome`
18379 // fixture, with identical `Display` rendering. A future silent
18380 // de-lift of the wire-up back to the open-coded struct-literal
18381 // trips this test at caixa-core build time rather than at a
18382 // downstream diagnostic consumer far from the wire-up commit.
18383 // Sibling of the peer
18384 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
18385 // pin on the same wire-up — extended here from a `matches!`
18386 // shape check to a byte-identity + Display parity route through
18387 // the ctor.
18388 let d = Dep::simple("Caixa_Teia", "^0.1");
18389 let observed = d.validate().unwrap_err();
18390 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
18391 .expect_err("fixture must be DNS-1123-refused");
18392 let expected = DepError::nome_invalid("Caixa_Teia", reason);
18393 assert_eq!(
18394 observed, expected,
18395 "Dep::validate's DNS-1123 refusal arm must byte-equal \
18396 nome_invalid(nome, reason)"
18397 );
18398 assert_eq!(
18399 observed.to_string(),
18400 expected.to_string(),
18401 "Display byte-string parity"
18402 );
18403 }
18404}