caixa_core/dep.rs
1use serde::{Deserialize, Serialize};
2use thiserror::Error;
3
4/// A single dependency declaration in a `caixa.lisp` manifest.
5///
6/// **Store model = Git, like Zig.** There is no central registry; a caixa is
7/// just a Git repo with a `caixa.lisp` at its root. When `:fonte` is omitted,
8/// the resolver falls back to `github:<default-org>/<nome>` (org defaults to
9/// `pleme-io`, override via `~/.config/caixa/config.yaml`).
10///
11/// ```lisp
12/// ;; Shorthand — resolves to github:pleme-io/caixa-teia (or your default org):
13/// (:nome "caixa-teia" :versao "^0.1")
14///
15/// ;; Explicit git source:
16/// (:nome "caixa-teia"
17/// :versao "^0.1"
18/// :fonte (:tipo git :repo "github:pleme-io/caixa-teia" :tag "v0.1.0"))
19///
20/// ;; Arbitrary git URL (not limited to GitHub):
21/// (:nome "private-caixa"
22/// :versao "*"
23/// :fonte (:tipo git :repo "ssh://git@git.example/team/priv-caixa.git" :branch "main"))
24///
25/// ;; Local path (dev only; not publishable):
26/// (:nome "caixa-teia"
27/// :versao "0.1.0"
28/// :fonte (:tipo path :caminho "../caixa-teia"))
29/// ```
30#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
31#[serde(rename_all = "camelCase")]
32pub struct Dep {
33 /// Caixa name — must match the target caixa's `:nome`.
34 pub nome: String,
35
36 /// Semver constraint string (`"^0.1"`, `"~0.1.2"`, `"0.1.0"`, `"*"`).
37 pub versao: String,
38
39 /// Where to fetch the caixa from. Defaults to the feira registry.
40 #[serde(default, skip_serializing_if = "Option::is_none")]
41 pub fonte: Option<DepSource>,
42
43 /// If true, a missing `:fonte` is not a build failure.
44 #[serde(default, skip_serializing_if = "is_false")]
45 pub opcional: bool,
46
47 /// Feature flags to enable on the target caixa.
48 #[serde(default, skip_serializing_if = "Vec::is_empty")]
49 pub caracteristicas: Vec<String>,
50}
51
52/// Where a dep is fetched from. Tagged via `:tipo` in Lisp.
53///
54/// Only two shapes — Git and local Path. No central registry variant: a caixa
55/// is just a Git repo. Omitting `:fonte` means *"use the default resolver
56/// convention"*, which is `github:<default-org>/<nome>`; the resolver fills
57/// that in when computing the lacre.
58///
59/// The [`gen_platform::IsVariant`] derive emits per-arm arm-discriminator
60/// predicates — [`Self::is_git`], [`Self::is_path`] — so every downstream
61/// consumer that only needs the arm-discriminator projection (not the
62/// borrowed field value) reaches for one typed dispatch on the substrate
63/// primitive rather than a hand-rolled `matches!(s, DepSource::X { .. })`
64/// literal. Extends the closed-set-typed-enum discipline the sibling
65/// caixa-core enums ([`crate::CaixaKind`], [`crate::CaixaDialeto`],
66/// [`crate::supervisor::RestartStrategy`], [`crate::supervisor::RestartPolicy`],
67/// [`crate::upgrade::UpgradeInstruction`], [`crate::aplicacao::PlacementStrategy`],
68/// [`crate::aplicacao::RateLimitUnit`], [`crate::aplicacao::WitTarget`],
69/// [`crate::render::PathShapeViolation`], [`DepList`]) and the sibling
70/// out-of-crate enums (caixa-arch's `InvariantKind` + `ArchVerdict`,
71/// caixa-lint's `Severity` + `FixSafety`, caixa-provedor's
72/// `FerriteRuntime`, caixa-theme's `Semantic`, caixa-flux's `GitRefSpec`,
73/// caixa-ast's `NodeKind` + `TriviaKind`) already carry onto the
74/// two-arm `:fonte` dep-source axis — the 17th closed-set typed enum
75/// on the caixa surface, and the first on the outer-`Dep` `:fonte`-slot
76/// axis every git-fetching consumer runs after the outer `:fonte` slot
77/// resolves to a shape.
78#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, gen_platform::IsVariant)]
79#[serde(tag = "tipo", rename_all = "lowercase")]
80pub enum DepSource {
81 /// Clone from Git. One of `:tag`, `:rev`, or `:branch` may be set.
82 /// `repo` can be a `github:org/repo` shorthand, a full `https://…` URL,
83 /// or any git-ssh URL.
84 Git {
85 repo: String,
86 #[serde(default, skip_serializing_if = "Option::is_none")]
87 tag: Option<String>,
88 #[serde(default, skip_serializing_if = "Option::is_none")]
89 rev: Option<String>,
90 #[serde(default, skip_serializing_if = "Option::is_none")]
91 branch: Option<String>,
92 },
93 /// Local filesystem path — dev only; cannot be published.
94 Path { caminho: String },
95}
96
97impl DepSource {
98 /// Build a registry-shorthand git source (`github:<org>/<nome>`).
99 ///
100 /// This is the resolver-side fallback for `dep.fonte: None`, not an
101 /// author-surface value — it carries no pin (`:tag`/`:rev`/`:branch`
102 /// all `None`) and is therefore rejected by [`Self::validate`]. The
103 /// resolver fills the pin in at fetch time from the resolved commit;
104 /// authors never serialize this shape as a `Dep::fonte` value.
105 #[must_use]
106 pub fn default_github(org: &str, nome: &str) -> Self {
107 Self::Git {
108 repo: format!("github:{org}/{nome}"),
109 tag: None,
110 rev: None,
111 branch: None,
112 }
113 }
114
115 /// Substrate-canonical per-`:fonte` sole-set git-pin scalar accessor
116 /// every consumer that reads "which single git ref does this source
117 /// resolve to?" keys off — returns the author-declared `:tag` /
118 /// `:rev` / `:branch` byte-string verbatim as an `Option<&str>`,
119 /// borrowed from the typed slot's own `Option<String>` storage; `None`
120 /// on [`Self::Path`] (a path source carries no git-ref) and on a
121 /// [`Self::Git`] variant whose `tag`, `rev`, and `branch` are all
122 /// `None` (the [`Self::default_github`] shorthand shape the resolver
123 /// materializes when the author omits `:fonte` — rejected by
124 /// [`Self::validate`], but the accessor's return is defined on this
125 /// arm too so pre-validate consumers reach for the same typed dispatch
126 /// as post-validate ones).
127 ///
128 /// **Precedence: rev > tag > branch.** The canonical precedence every
129 /// per-`:fonte` git-ref consumer already applies: caixa-resolver's
130 /// per-fetch `git checkout <ref>` reads through the same
131 /// `rev.or(tag).or(branch)` cascade at caixa-resolver/src/resolve.rs,
132 /// and caixa-crd's `dep_into_ref` `CaixaSource.git_ref` fill reads
133 /// through the same cascade at caixa-crd/src/conversion.rs. The
134 /// [`Self::validate`] gate enforces "exactly one pin set" — under
135 /// that invariant every accepted [`Self::Git`] carries exactly one
136 /// non-`None` pin and the precedence is unobservable, but the
137 /// precedence remains defined for pre-validate consumers (the
138 /// resolver's `MissingPin` diagnostic path, the caixa-crd
139 /// round-trip's default `"main"` fallback the author never sees a
140 /// diagnostic on) and defense-in-depth for a hypothetical future
141 /// state where multiple pins survive the gate. The precedence is
142 /// **rev before tag** because `:rev` (a git commit OID) is the
143 /// reproducibility-strongest identifier — an OID resolves to exactly
144 /// one commit regardless of which refname points at it, whereas
145 /// `:tag` and `:branch` are refnames the remote can silently move
146 /// (a tag re-push, a branch head advance); the resolver's freeze
147 /// step at fetch time promotes the resolved commit to `:rev` for
148 /// exactly this reason. **Tag before branch** because `:tag` is
149 /// conventionally immutable (a release tag) whereas `:branch` is
150 /// conventionally mutable (a tracking ref) — a caixa carrying both
151 /// a release tag and a tracking branch reads as "prefer the release
152 /// pin, fall through to the tracking pin only if the release is
153 /// missing". The cascade order also matches the byte-order every
154 /// per-`:tag`/`:rev`/`:branch` diagnostic tuple this crate emits
155 /// (`(":tag", tag), (":rev", rev), (":branch", branch)` — see
156 /// [`Self::validate`]'s `pins` array).
157 ///
158 /// Prior to this lift the "sole set pin" projection sat twice in the
159 /// workspace — inline at caixa-resolver's `fetch_git` (`let gitref =
160 /// rev.or(tag).or(branch).ok_or_else(|| ResolveError::MissingPin
161 /// { … })?;`) and at caixa-crd's `dep_into_ref`
162 /// (`git_ref: rev.clone().or(tag.clone()).or(branch.clone())
163 /// .unwrap_or_else(|| "main".to_string())`) — two open-coded copies
164 /// of the same precedence cascade with no compile-time link back to
165 /// the typed slot. A future extension of the pin axis to a richer
166 /// author surface (a `:commit` pin peer of `:rev` once the substrate
167 /// grows a signed-commit-verification pin, a `:ref` pin the M4
168 /// substrate operator resolves per-cluster ahead of fetch, a
169 /// promotion of the plain `Option<String>` pins to a typed
170 /// `GitPin::{Rev(Oid), Tag(RefName), Branch(RefName)}` newtype
171 /// once the sibling [`crate::render::is_git_oid`] /
172 /// [`crate::render::is_git_ref_name`] gates land as typed
173 /// constructors) would have had to be threaded through both
174 /// open-coded copies in lockstep or the resolver's `git checkout`
175 /// target would silently disagree with the CRD's `git_ref` fill —
176 /// an author's `(:fonte (:tipo git :repo "…" :rev "deadbeef" :tag
177 /// "v1"))` would ship with the resolver checking out `deadbeef`
178 /// while the CRD round-trip re-emitted a Dep pointing at `v1`, one
179 /// lacre closure disagreeing with the emitted K8s CR the operator
180 /// reads. Lifting the resolution to a typed method on the substrate
181 /// primitive means both downstream consumers reach for exactly one
182 /// typed dispatch — the resolver's accept-set migrates as a unit on
183 /// any future pin-axis addition.
184 ///
185 /// Peer of the sibling outer-`Dep` [`Dep::fonte`] (d65d1bf)
186 /// `Option<&DepSource>` composite-reference accessor on the outer-
187 /// `Dep` `:fonte`-slot axis — extended one nesting level down onto
188 /// the per-[`Self::Git`]-variant sole-set-pin projection axis every
189 /// git-fetching consumer runs after the outer `:fonte` slot resolves
190 /// to a [`Self::Git`] shape. Same "one typed dispatch on the
191 /// substrate primitive, thin projections at each consumer" discipline
192 /// the outer accessor family already carries.
193 #[must_use]
194 pub fn sole_pin(&self) -> Option<&str> {
195 match self {
196 Self::Git {
197 tag, rev, branch, ..
198 } => rev.as_deref().or(tag.as_deref()).or(branch.as_deref()),
199 Self::Path { .. } => None,
200 }
201 }
202
203 /// Validate the `:fonte` value-shape: every author-surface
204 /// `:fonte (:tipo git …)` must carry a non-empty `:repo` and
205 /// exactly one of `:tag` / `:rev` / `:branch` set to a non-empty
206 /// value; every `:fonte (:tipo path …)` must carry a non-empty
207 /// `:caminho`.
208 ///
209 /// Called from [`Dep::validate`] with the dep's `:nome` so every
210 /// diagnostic carries the offending entry verbatim — same
211 /// self-locating shape the `:deps :versao` (2420c44),
212 /// `:membros :versao` (9888b13), `:children :versao` (b38ff3a),
213 /// `:placement :clusters` (6cbb900), and `:membros :caixa`
214 /// (3f9d7a0) gates already expose.
215 ///
216 /// Until this gate landed `:fonte` was the only `:deps`-related
217 /// typed surface still untyped past `Caixa::from_lisp`:
218 /// - Empty `:repo` (`(:tipo git :repo "" :tag "v1")`) silently
219 /// passed parse and surfaced as a git-clone failure at
220 /// lacre-resolve time, far from the source caixa.lisp.
221 /// - A bare `(:tipo git :repo "…")` with no `:tag`/`:rev`/`:branch`
222 /// passed parse and surfaced as the resolver's
223 /// [`ResolveError::MissingPin`](../../caixa-resolver/src/resolve.rs)
224 /// at fetch time, again far from the source caixa.lisp; lifting
225 /// to validate-time gives the author the same diagnostic at the
226 /// edit site.
227 /// - `(:tipo git :repo "…" :tag "v1" :branch "main")` — multiple
228 /// pins set — passed parse and the resolver silently picked
229 /// `:rev > :tag > :branch`, ignoring the other pins with no
230 /// diagnostic; the author had no way to know their `:branch`
231 /// was dropped. This is the canonical "pin drift" footgun.
232 /// - An empty pin value (`(:tipo git :repo "…" :tag "")`) silently
233 /// passed parse and surfaced as `git checkout ""` at fetch time.
234 /// - Empty `:caminho` (`(:tipo path :caminho "")`) silently passed
235 /// parse and surfaced as
236 /// [`ResolveError::MissingPath`](../../caixa-resolver/src/resolve.rs)
237 /// with `path: PathBuf("")` — not actionable.
238 ///
239 /// Each rejected shape maps to a typed
240 /// [`DepError::Fonte*`] variant that names the offending
241 /// dep's `:nome` and the specific axis, so the author can grep
242 /// their caixa.lisp for the `:nome "<nome>"` block and fix it in
243 /// one edit.
244 pub fn validate(&self, nome: &str) -> Result<(), DepError> {
245 match self {
246 Self::Git {
247 repo,
248 tag,
249 rev,
250 branch,
251 } => {
252 if repo.is_empty() {
253 return Err(DepError::fonte_repo_empty(nome));
254 }
255 // The `:repo` value flows verbatim into the caixa-resolver's
256 // `git clone <repo>` subprocess invocation. Until this gate
257 // landed `:repo` was the last untyped `:fonte`-related axis
258 // past the empty arm: a malformed-but-non-empty repo URL
259 // (`":repo "github:p/x ""` trailing space, paste-from-doc;
260 // `":repo "-upload-pack=evil""` leading `-` — the canonical
261 // CLI-argument-injection vector at the `git clone` boundary;
262 // `":repo "pleme-io/caixa-teia""` missing scheme — `git clone`
263 // reads as a relative filesystem path rather than the
264 // GitHub-shorthand expansion; `":repo "github:p/x\n""`
265 // embedded newline; `":repo "github:café/x""` raw non-ASCII)
266 // silently passed validate and the failure surfaced at
267 // lacre-resolve time with a porcelain-quoting-confused error
268 // far from the source caixa.lisp. The lifted predicate makes
269 // the git-porcelain-URL intersection-floor a substrate-level
270 // invariant at validate time, peer with the three pin axes
271 // (`:tag` + `:branch` via [`crate::render::is_git_ref_name`],
272 // e70d213; `:rev` via [`crate::render::is_git_oid`], be07fd5)
273 // — every `:fonte (:tipo git …)` past validate is now
274 // structurally accept-shaped on every axis the resolver
275 // consumes (the `:repo` URL the `git clone` invokes against,
276 // the `:tag`/`:branch` refname `git fetch`/`git checkout`
277 // accepts, the `:rev` commit OID the lacre's content-
278 // addressing equality probe resolves), closing the
279 // `:fonte` slot's value-shape trajectory end-to-end.
280 if let Err(reason) = crate::render::is_git_repo_url(repo) {
281 return Err(DepError::fonte_repo_shape(nome, repo, reason));
282 }
283 let pins: [(&'static str, Option<&String>); 3] = [
284 (":tag", tag.as_ref()),
285 (":rev", rev.as_ref()),
286 (":branch", branch.as_ref()),
287 ];
288 let set: Vec<&'static str> =
289 pins.iter().filter_map(|(n, v)| v.map(|_| *n)).collect();
290 match set.len() {
291 0 => {
292 return Err(DepError::fonte_pin_missing(nome));
293 }
294 1 => {
295 for (pin, value) in pins {
296 if value.is_some_and(String::is_empty) {
297 return Err(DepError::fonte_pin_empty(nome, pin));
298 }
299 }
300 }
301 _ => {
302 return Err(DepError::fonte_pin_ambiguous(nome, &set.join(", ")));
303 }
304 }
305 // Per-pin value-shape gate. The refname-shaped axes
306 // (`:tag` + `:branch`) route through
307 // [`crate::render::is_git_ref_name`]; the hex-OID-shaped
308 // `:rev` axis routes through
309 // [`crate::render::is_git_oid`]. The two predicates
310 // partition the `:fonte` pin axes structurally — refname
311 // vs. hex commit — so a cross-axis mis-slot (the
312 // canonical "I conflated `:rev` and `:branch`" footgun:
313 // `:rev "main"` defeating the reproducibility contract,
314 // `:tag "deadbeef…"` mis-slotting a SHA into the
315 // refname-shaped axis) lands at the offending axis's
316 // predicate, not at lacre-resolve `git fetch` /
317 // `git checkout` time. Their valid sets intersect at
318 // the empty set: every refname is rejected by
319 // `is_git_oid`, every OID is rejected by
320 // `is_git_ref_name`, structurally.
321 //
322 // Until this gate landed `:tag` / `:branch` were the
323 // refname-shaped axes still untyped past the empty-pin
324 // arm: a malformed-but-non-empty refname
325 // (`:tag "v0.1.0 "` trailing space — the canonical
326 // paste-from-doc footgun; `:tag "v0.1.0.lock"` colliding
327 // with git's atomic-rename guard suffix; `:tag "../escape"`
328 // path-traversal via consecutive dots; `:branch "main "`
329 // trailing space; `:branch "feature/foo bar"` embedded
330 // space; `:branch "@"` the literal HEAD alias;
331 // `:branch "refs/heads/main"` the fully-qualified ref
332 // copied from `git show-ref` output that resolves to
333 // a literal ref named `refs/heads/refs/heads/main` on
334 // disk) silently passed validate; the `:rev` axis was
335 // the last `:fonte`-related axis still untyped past the
336 // empty-pin arm: a malformed-but-non-empty hex-OID
337 // (`:rev "main"` conflating with `:branch` — the
338 // reproducibility-contract leak; `:rev "v0.1.0"`
339 // conflating with `:tag` — the same mis-slot on the
340 // refname/OID boundary; `:rev "c0ffee"` an abbreviated
341 // 6-char prefix that's ambiguous across repo history;
342 // `:rev "DEADBEEF…"` an uppercase OID that round-trips
343 // inconsistently against `git rev-parse HEAD`'s
344 // lowercase emission) silently passed validate and the
345 // failure surfaced at lacre-resolve `git fetch` /
346 // `git checkout` time with a quoting-confused error
347 // far from the source caixa.lisp, with no field naming
348 // which `:deps` entry carried the typo. Lifting both
349 // gates to caixa-build time matches the value-shape
350 // trajectory the peer typed axes already follow
351 // (c4213a4 typed WitContract endpoint/subject/slot;
352 // eb3456d :entrada :paths; c7d05ec :entrada :host;
353 // 4f0390b :contratos :endpoint; 6226bf4 :contratos :wit;
354 // 63e18a0 :contratos :subject; 2f4316e :contratos
355 // :slot; e70d213 :fonte :tag + :branch) — the typed
356 // slot's valid set matches its downstream consumer's
357 // accepted set (here, the git porcelain's refname /
358 // commit-OID grammars at `git fetch` / `git checkout`
359 // time), structurally. Same diagnostic shape every
360 // per-axis value-shape lift already exposes
361 // (`*Invalid { axis, reason }`); the `value:` field
362 // carries the offending refname / OID verbatim so the
363 // author can grep their caixa.lisp for the
364 // `:tag "<value>"` / `:branch "<value>"` /
365 // `:rev "<value>"` literal and fix it in one edit.
366 for (pin, value) in [(":tag", tag.as_ref()), (":branch", branch.as_ref())] {
367 if let Some(v) = value
368 && let Err(reason) = crate::render::is_git_ref_name(v)
369 {
370 return Err(DepError::fonte_pin_shape(nome, pin, v, reason));
371 }
372 }
373 if let Some(v) = rev.as_ref()
374 && let Err(reason) = crate::render::is_git_oid(v)
375 {
376 return Err(DepError::fonte_pin_shape(nome, ":rev", v, reason));
377 }
378 Ok(())
379 }
380 Self::Path { caminho } => Self::validate_caminho(nome, caminho),
381 }
382 }
383
384 /// Reproducibility + path-API gate on the `:fonte (:tipo path …)`
385 /// `:caminho` axis. Walks the leading-byte cascade closed by the
386 /// b94fd83 (`/`), a5c248e (`~`), and f4efe9c (`$`) arms; the
387 /// orthogonal embedded-control-byte arm (d624c8d) covering
388 /// `0x00..=0x1F` plus `0x7F` anywhere in the value; and the
389 /// embedded-`\` Windows-path-separator arm closing the
390 /// cross-host-OS-separator divergence vector on the same
391 /// THEORY.md §V.2 render-determinism axis.
392 ///
393 /// Extracted from [`Self::validate`]'s `Self::Path` arm because the
394 /// per-arm cascade now spans nine diagnostic shapes — every new
395 /// `:caminho` arm (a future `&` / `;` / `|` shell-metachar arm,
396 /// a future glob-metachar `*` / `?` arm) lands here rather than
397 /// re-inflating `Self::validate`. The
398 /// function stays a thin per-arm linear walk for one reason: each
399 /// arm's diagnostic carries a distinct typed [`DepError`] variant
400 /// rather than a parser-shaped `reason` string, so collapsing the
401 /// cascade onto a generic [`crate::render`] predicate would regress
402 /// the per-arm self-locating diagnostic that `feira lint` consumers
403 /// depend on. The wrapped predicate trajectory ([`crate::render::is_dns_1123_label`],
404 /// [`crate::render::is_git_repo_url`], etc.) lives on the
405 /// reason-string-shaped axes; the `:caminho` axis keeps its
406 /// per-arm variant shape.
407 #[allow(
408 clippy::too_many_lines,
409 reason = "the per-arm cascade is structurally flat by design — every \
410 `:caminho` arm carries its own typed [`DepError`] variant + \
411 per-arm Why comment, so collapsing the cascade onto a generic \
412 [`crate::render`] predicate would regress the per-arm self-locating \
413 diagnostic the `feira lint` consumer surface depends on"
414 )]
415 fn validate_caminho(nome: &str, caminho: &str) -> Result<(), DepError> {
416 if caminho.is_empty() {
417 return Err(DepError::fonte_caminho_empty(nome));
418 }
419 // Reproducibility gate on the `:fonte (:tipo path …)`
420 // `:caminho` axis. The lacre pipeline embeds the value
421 // verbatim in its per-dep content-address
422 // (`conteudo: format!("path:{caminho}")`,
423 // caixa-resolver/src/resolve.rs:189) and that string
424 // folds into the BLAKE3 closure the lacre keys every
425 // downstream consumer (the substrate's reproducibility
426 // contract, CAIXA-SDLC §III.2 — the lacre is the
427 // build's content-addressed identity, peer of the Nix
428 // store path) against. Until this gate landed an
429 // absolute `:caminho` (`/home/me/work/caixa-teia` — the
430 // canonical "I dragged the folder out of Finder into
431 // my editor" footgun; `/Users/alice/dev/caixa-teia` on
432 // the macOS path-layout peer; the
433 // `${WORKSPACE}/caixa-teia` shell-expanded literal
434 // pasted from a CI manifest) silently passed validate
435 // and the failure surfaced *as a successful build with
436 // a divergent lacre*: the BLAKE3 closure on Alice's
437 // workstation differed from the closure on Bob's
438 // workstation, two CI runners with different
439 // `${HOME}` layouts emitted two distinct
440 // content-addresses for the byte-identical caixa, and
441 // the substrate's "the lacre is the build's identity"
442 // contract silently broke far from the source
443 // caixa.lisp — the most insidious failure mode the
444 // typed slot can carry (no error surfaces; the
445 // divergence is invisible until two machines compare
446 // lacres). The same THEORY.md §V.2 render-determinism
447 // discipline `is_sandboxed_relative_path` already
448 // applies on the M2 typed path-slots
449 // (`:behavior :on-*`, `:upgrade-from :state-change
450 // :script`, `:bibliotecas`, `:exe`, `:servicos`), here
451 // narrowed to the absolute-vs-relative axis only:
452 // `:fonte :caminho`'s canonical author-surface form is
453 // the `..`-traversing sibling-workspace path
454 // (`"../caixa-teia"`, the in-tree dev-dep frame), so a
455 // full `is_sandboxed_relative_path` lift would
456 // structurally reject every legitimate path-fonte
457 // dep. The narrower
458 // `std::path::Path::is_absolute` cut admits the
459 // sibling-workspace form while still rejecting the
460 // host-layout-leaking absolute shape — the
461 // reproducibility contract bites at exactly the
462 // absolute boundary, and that's the axis the
463 // substrate-level invariant is meant to hold. Same
464 // diagnostic shape every per-axis value-shape lift on
465 // the surrounding [`DepError::Fonte*`] cluster carries
466 // (the offending `:nome` + offending `:caminho`
467 // quoted verbatim so the author can grep their
468 // caixa.lisp for the `:caminho "<value>"` literal and
469 // fix it in one edit). The empty arm strictly
470 // precedes this arm so the blank-string footgun
471 // surfaces the more self-locating
472 // `FonteCaminhoEmpty` diagnostic (the empty string
473 // is not absolute under `Path::new("").is_absolute()`
474 // so the precedence is a no-op at value level — the
475 // pin matters only at the diagnostic-shape level if
476 // a future codec round-trip ever produces an empty
477 // string that probes as absolute).
478 if std::path::Path::new(caminho).is_absolute() {
479 return Err(DepError::fonte_caminho_absolute(nome, caminho));
480 }
481 // Reproducibility gate's tilde-expansion arm. The b94fd83
482 // `FonteCaminhoAbsolute` closes the leading-`/`
483 // host-layout-leak; a `:caminho "~/work/caixa-teia"` (the
484 // canonical paste-from-shell-prompt / paste-from-`cd ~`-
485 // doc footgun) silently passed both the empty arm and
486 // the absolute arm because `Path::new("~").is_absolute()`
487 // returns `false` — `~` is a shell-expansion convention,
488 // not a POSIX path component, so `std::path::Path` treats
489 // it as a literal directory-name segment. The lacre
490 // pipeline then embedded the value verbatim
491 // (`conteudo: format!("path:~/work/caixa-teia")`) and the
492 // failure mode forked per consumer:
493 //
494 // - The caixa-resolver's `Path` arm folds `:caminho`
495 // through `Path::new(caminho).join(<file>)` without
496 // `~`-expansion, so the build looked for a literal
497 // `./~/work/caixa-teia` subdirectory and failed at
498 // resolve time with a `No such file or directory`
499 // error far from the source caixa.lisp (the lacre
500 // itself, though, was already byte-identical across
501 // machines — every machine emitted the same
502 // `path:~/work/caixa-teia` content-address).
503 // - A future caixa-resolver pass that *does* expand `~`
504 // (the canonical shell-convention idiom every
505 // resolver eventually reaches for once an author
506 // reports the literal-`~`-directory bug) would re-
507 // introduce the host-layout-leak the b94fd83 absolute
508 // gate closes: Alice's `~` expands to `/home/alice`,
509 // Bob's to `/home/bob`, two CI runners with different
510 // `$HOME` layouts resolve to two distinct paths for
511 // the byte-identical caixa, and the substrate's
512 // "the lacre is the build's identity" contract
513 // silently breaks far from the source caixa.lisp.
514 //
515 // Closing the gate at `DepSource::validate` (here at the
516 // canonical caixa-build-time boundary, peer with the
517 // absolute arm above) refuses both failure modes
518 // structurally: the typed accepted set excludes every
519 // `~`-prefixed authoring shape, so the resolver is
520 // free to grow `~`-expansion (or any other convention-
521 // expansion the substrate adopts) without re-opening
522 // the host-layout-leak at the typed boundary. Same
523 // diagnostic shape every per-axis value-shape gate on
524 // the surrounding [`DepError::Fonte*`] cluster carries
525 // (the offending `:nome` + offending `:caminho` quoted
526 // verbatim so the author can grep their caixa.lisp for
527 // the `:caminho "<value>"` literal and fix it in one
528 // edit).
529 //
530 // The cascade preserves narrower-diagnostic-first
531 // ordering: `FonteCaminhoEmpty` → `FonteCaminhoAbsolute`
532 // → `FonteCaminhoTildeExpansion`. The empty arm
533 // structurally precedes both (the bytes "" / "~" don't
534 // overlap), and the absolute arm structurally precedes
535 // the tilde arm (an absolute path can't start with `~`
536 // since absolute paths start with `/`; the bytes "/" /
537 // "~" don't overlap either). Both arms are
538 // value-disjoint, so the precedence is a no-op at value
539 // level — the pin matters only at the diagnostic-shape
540 // level if a future codec round-trip ever produces a
541 // value that probes as both absolute and tilde-prefixed.
542 if caminho.starts_with('~') {
543 return Err(DepError::fonte_caminho_tilde_expansion(nome, caminho));
544 }
545 // Reproducibility gate's shell-variable-expansion arm.
546 // The b94fd83 `FonteCaminhoAbsolute` closes the leading-`/`
547 // host-layout-leak; the a5c248e `FonteCaminhoTildeExpansion`
548 // closes the leading-`~` shell-home-expansion shape; the
549 // leading-`$` is the sibling shell-variable-expansion shape
550 // — same host-layout-leaking semantic, different syntactic
551 // surface. A `:caminho "$HOME/work/caixa-teia"` (the
552 // canonical paste-from-`echo $HOME`-doc footgun) and the
553 // `${VAR}`-braced variant (`"${WORKSPACE}/caixa-teia"` —
554 // the canonical paste-from-CI-manifest footgun every
555 // GitHub Actions / GitLab CI / Drone manifest carries)
556 // silently passed every prior arm because
557 // `Path::is_absolute` returns false on `$` (the `$` is a
558 // shell convention, not a POSIX path component, so
559 // `std::path::Path` treats it as a literal directory-name
560 // segment) and the tilde arm's `starts_with('~')` doesn't
561 // fire.
562 //
563 // Same per-consumer failure-fork the tilde arm closes:
564 //
565 // - The caixa-resolver's `Path` arm folds `:caminho`
566 // through `Path::new(caminho).join(<file>)` without
567 // `$`-expansion, so the build looks for a literal
568 // `./$HOME/work/caixa-teia` subdirectory and fails at
569 // resolve time with a `No such file or directory`
570 // error far from the source caixa.lisp.
571 // - A future caixa-resolver pass that *does* expand
572 // `$VAR` (the shell-convention idiom every resolver
573 // eventually reaches for once an author reports the
574 // literal-`$HOME`-directory bug, especially for CI's
575 // `${WORKSPACE}` idiom) would re-introduce the host-
576 // layout-leak the b94fd83 absolute gate closes:
577 // Alice's `$HOME` expands to `/home/alice`, Bob's to
578 // `/home/bob`, two CI runners with different
579 // `${WORKSPACE}` layouts resolve to two distinct
580 // paths for the byte-identical caixa, and the
581 // substrate's "the lacre is the build's identity"
582 // contract silently breaks far from the source
583 // caixa.lisp.
584 //
585 // Closing the gate at `DepSource::validate` (here at the
586 // canonical caixa-build-time boundary, peer with the
587 // absolute + tilde arms above) refuses both failure modes
588 // structurally. Same diagnostic shape every per-axis
589 // value-shape gate on the surrounding [`DepError::Fonte*`]
590 // cluster carries (the offending `:nome` + offending
591 // `:caminho` quoted verbatim).
592 //
593 // The cascade preserves narrower-diagnostic-first ordering:
594 // `FonteCaminhoEmpty` → `FonteCaminhoAbsolute` →
595 // `FonteCaminhoTildeExpansion` → `FonteCaminhoVarExpansion`.
596 // The empty arm structurally precedes all three subsequent
597 // arms; the absolute arm structurally precedes both the
598 // tilde and the var arms (absolute paths start with `/`,
599 // the bytes `/` / `~` / `$` don't overlap at the leading
600 // position); the tilde arm structurally precedes the var
601 // arm (`~` and `$` don't overlap at the leading position).
602 // Every pair is value-disjoint, so the precedence is a
603 // no-op at value level — the pin matters only at the
604 // diagnostic-shape level if a future codec round-trip ever
605 // produces a probe-as-both value.
606 //
607 // The gate covers every leading-`$` shape: the canonical
608 // `"$HOME/work/caixa-teia"` (POSIX shell), the braced
609 // `"${HOME}/work/caixa-teia"` (POSIX shell braces), the
610 // CI-manifest idiom `"${WORKSPACE}/caixa-teia"` (the
611 // GitHub Actions / GitLab CI / Drone paste footgun), the
612 // XDG idiom `"$XDG_CONFIG_HOME/caixa"`, and the bare `$`
613 // (degenerate "I meant `$HOME` and forgot the rest"). All
614 // shapes route through the same `caminho.starts_with('$')`
615 // byte check.
616 if caminho.starts_with('$') {
617 return Err(DepError::fonte_caminho_var_expansion(nome, caminho));
618 }
619 // Reproducibility gate's leading-space arm. The b94fd83 / a5c248e /
620 // f4efe9c arms closed the leading-byte host-layout-leak shapes
621 // (`/` / `~` / `$`); the embedded-control-byte arm below closes
622 // every byte in `0x00..=0x1F` plus `0x7F` (which already includes
623 // tab `0x09`, LF `0x0A`, CR `0x0D` — every ASCII whitespace
624 // *except* the ASCII space byte `0x20`). The bare ASCII space at
625 // the leading position is the orthogonal paste-from-aligned-doc
626 // shape that silently passed every prior arm: `Path::is_absolute`
627 // returns false on `" ../caixa-teia"` (the leading byte is `0x20`
628 // not `0x2F`), `0x20` is not `~` / `$` / `\` / a control byte, and
629 // the value's last byte is not `/`, so the canonical
630 // paste-from-aligned-`caixa.lisp`-doc footgun (every `:fonte`
631 // form in a multi-entry `:deps` block sits at the same column —
632 // an author selecting `"<sp><sp><sp>../caixa-teia"` and pasting
633 // it from the rendered alignment into a fresh entry preserves the
634 // leading whitespace verbatim) silently rendered as a path with
635 // a leading-space directory component the resolver folds through
636 // `Path::join` looking for a literal `./ ../caixa-teia`
637 // subdirectory that fails at resolve time with a non-self-
638 // locating `No such file or directory` error.
639 //
640 // The lacre pipeline's reproducibility contract bites
641 // strictly at this byte: `path:" ../caixa-teia"` and
642 // `path:"../caixa-teia"` yield distinct BLAKE3 closures
643 // (`conteudo: format!("path:{caminho}")`,
644 // caixa-resolver/src/resolve.rs:189) for the byte-divergent /
645 // semantic-identical caixa, and the substrate's "the lacre is
646 // the build's identity" contract (CAIXA-SDLC §III.2) silently
647 // breaks across two workstations whose authors differ only in
648 // paste-from-aligned-doc whitespace habits — the most insidious
649 // failure mode the typed slot can carry (no error surfaces; the
650 // divergence is invisible until two machines compare lacres).
651 //
652 // The arm fires AFTER the absolute / tilde / var leading-byte
653 // arms (each names the more self-locating shell-convention
654 // diagnostic on values that probe as that arm's leading-byte
655 // sentinel followed by a leading space — e.g.
656 // `:caminho "/ /foo"` surfaces `FonteCaminhoAbsolute` because
657 // the leading byte is `/`, not space) and BEFORE the
658 // embedded-control-byte arm (a leading-space value with an
659 // embedded control byte surfaces the broader leading-space
660 // diagnostic because the cascade walks leading-byte arms first
661 // — peer with how `FonteCaminhoAbsolute` precedes
662 // `FonteCaminhoControlChar` on `"/etc/passwd\n"`).
663 //
664 // The peer single-token-shaped axes already reject leading
665 // whitespace on the same paste-from-aligned-doc contract:
666 // [`crate::render::is_git_repo_url`] rejects leading whitespace
667 // on `:fonte :repo`, [`crate::render::is_git_ref_name`] rejects
668 // leading whitespace on `:fonte :tag`/`:branch`,
669 // [`crate::render::is_chart_description_shape`] rejects leading
670 // whitespace on `:descricao`,
671 // [`crate::render::is_spdx_expression_shape`] rejects leading
672 // whitespace on `:licenca`. Closing the same byte on
673 // `:fonte :caminho` makes the substrate-wide "no leading ASCII
674 // space anywhere in a typed string slot" invariant structurally
675 // consistent across every value-shape-gated typed surface (the
676 // `:caminho` axis was the last typed string surface still
677 // admitting a leading space byte).
678 if caminho.starts_with(' ') {
679 return Err(DepError::fonte_caminho_leading_whitespace(nome, caminho));
680 }
681 // Reproducibility gate's leading-`-` CLI-argument-injection arm.
682 // The b94fd83 + a5c248e + f4efe9c + LeadingWhitespace arms closed
683 // the four prior leading-byte shapes (`/` / `~` / `$` / space);
684 // this arm closes the orthogonal leading-`-` axis on the same
685 // subprocess-argument-boundary the peer `is_git_repo_url` arm
686 // (render.rs:2037, `-upload-pack=…` on `:fonte :repo`) and
687 // `is_git_ref_name` arm (render.rs:1381, 5a28454, `-stable` on
688 // `:fonte :tag` / `:branch`) already reject.
689 //
690 // The lacre pipeline embeds `:caminho` verbatim in its per-dep
691 // content-address (`conteudo: format!("path:{caminho}")`,
692 // caixa-resolver/src/resolve.rs:189) and the resolver folds the
693 // value through `Path::join` looking for a literal `./{caminho}`
694 // subdirectory. Every downstream subprocess that consumes the
695 // resolved path — a `git -C {caminho} <verb>` invocation, a
696 // future `feira tofu` `terraform -chdir={caminho}` shell-out, a
697 // future operator-side `nix build --path {caminho}` spawn, an
698 // `xargs` / `find {caminho}` / `stat {caminho}` /
699 // `rm -rf {caminho}` cleanup — reinterprets a leading-`-` value
700 // as a CLI flag rather than a positional path when the
701 // subprocess invocation does not carry a `--` argument-list
702 // terminator between the flag block and the path argument. The
703 // canonical footguns:
704 //
705 // - `:caminho "-rf"` — bare short-flag paste (`rm -rf` /
706 // `find -rf` reinterpretation; the byte the peer
707 // `FonteCaminhoShellSemicolon` arm's `; rm -rf build`
708 // example paste-idiom carries as its first token).
709 // - `:caminho "-C"` — `git -C` config-injection paste
710 // (`git -C -C` reinterprets the second `-C` as another
711 // `--change-directory` flag rather than the path
712 // argument; the canonical `git -C <path>` porcelain
713 // idiom every multi-repo workspace tool carries).
714 // - `:caminho "--upload-pack=cat /etc/passwd"` — the
715 // canonical long-flag CLI-arg-injection vector at every
716 // git porcelain entry point (`git clone`, `git fetch`,
717 // `git ls-remote`) that consumes a path or URL
718 // argument; peer with `is_git_repo_url`'s leading-`-`
719 // arm (render.rs:2037) on the sibling `:fonte :repo`
720 // axis, which the arm's diagnostic explicitly cites.
721 // - `:caminho "--config=…"` / `:caminho "-c"` — git-config
722 // override paste-idiom (paste-from-`git -c foo=bar`
723 // shell-history footgun that reinterprets the value as
724 // a `[foo] bar` config injection on every git porcelain
725 // entry point).
726 //
727 // POSIX `std::path::Path` treats a leading `-` as a literal
728 // filename byte, so the resolver folds `-rf` through `Path::join`
729 // and looks for a literal `./-rf` subdirectory — the failure
730 // surfaces at resolve time with a non-self-locating `No such
731 // file or directory` error far from the source caixa.lisp, and
732 // the value rides through the lacre content-address into every
733 // downstream shell-spawned subprocess. On any consumer that
734 // shells out without the `--` terminator (the common case at
735 // every porcelain entry-point) the reinterpretation is silent
736 // and the failure mode is arbitrary-argument-injection.
737 //
738 // The arm fires AFTER the absolute / tilde / var / leading-space
739 // leading-byte arms (each names the more self-locating shell-
740 // convention diagnostic on values that probe as that arm's
741 // leading-byte sentinel — the byte sets are pairwise disjoint at
742 // the leading position, so the precedence pin is a no-op at
743 // value level, but the ordering keeps every leading-byte arm's
744 // diagnostic-shape stable) and BEFORE the embedded-control-byte
745 // arm (a leading-`-` value with an embedded control byte
746 // surfaces the narrower leading-`-` diagnostic because the
747 // cascade walks leading-byte arms first — peer with how
748 // `FonteCaminhoAbsolute` precedes `FonteCaminhoControlChar` on
749 // `"/etc/passwd\n"`, and how `FonteCaminhoLeadingWhitespace`
750 // precedes `FonteCaminhoControlChar` on `" ../foo\n"`).
751 //
752 // The peer single-token-shaped axes already reject leading `-`
753 // on the same CLI-arg-injection contract:
754 // [`crate::render::is_git_repo_url`] rejects it on `:fonte :repo`
755 // (render.rs:2037), [`crate::render::is_git_ref_name`] rejects
756 // it on `:fonte :tag` / `:fonte :branch` (render.rs:1381,
757 // 5a28454), [`crate::render::is_dns_1123_label`] rejects it on
758 // every DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros
759 // :caixa`, `:children :caixa`, `:deps :nome`, cluster names),
760 // [`crate::render::is_cargo_feature_name`] rejects it on
761 // `:caracteristicas`, and the feira `init` / `add <nome>`
762 // positional gate (868c191) rejects it on the CLI positional
763 // itself. Closing the same byte on `:fonte :caminho` makes the
764 // substrate-wide "no leading `-` anywhere in a typed single-
765 // token string slot routed through a subprocess argument"
766 // invariant structurally consistent across every value-shape-
767 // gated typed surface (the `:caminho` axis was the last typed
768 // string surface still admitting a leading `-` byte).
769 if caminho.starts_with('-') {
770 return Err(DepError::fonte_caminho_leading_hyphen(nome, caminho));
771 }
772 // Reproducibility gate's embedded-control-byte arm. The
773 // b94fd83 + a5c248e + f4efe9c arms closed the three
774 // leading-byte host-layout-leak shapes (`/` / `~` / `$`);
775 // this arm closes the orthogonal embedded-control-byte
776 // axis — any ASCII control byte (`0x00..=0x1F` plus
777 // `0x7F` DEL) appearing anywhere in `:caminho`. Same
778 // shape every peer single-token-typed-slot value-shape
779 // predicate the surrounding [`crate::render`] cluster
780 // gates against (the lifted `is_git_repo_url` arm on
781 // `:fonte :repo`, the `is_git_ref_name` arm on
782 // `:tag`/`:branch`, the `is_chart_description_shape` /
783 // `is_chart_maintainer_name_shape` /
784 // `is_chart_keyword_shape` arms on the
785 // Helm-chart-shaped axes); now consistent on the
786 // `:caminho` axis too.
787 //
788 // Until this gate landed any embedded control byte
789 // silently passed validate, the lacre pipeline embedded
790 // the value verbatim in its per-dep content-address
791 // (`conteudo: format!("path:{caminho}")`,
792 // caixa-resolver/src/resolve.rs:189), and the failure
793 // forked per byte and per consumer:
794 //
795 // - NUL (`0x00`) the canonical "POSIX paths cannot
796 // contain a NUL byte" shape: every `std::fs` syscall
797 // routes the path through `CString::new`, which
798 // fails with `NulError` on the first NUL byte; the
799 // build would surface a `NulError` at resolve time
800 // far from the source caixa.lisp.
801 // - LF (`0x0A`) / CR (`0x0D`) the canonical paste-from-
802 // multiline-doc footgun: a `:caminho
803 // "../caixa-teia\nrm -rf /"` value (paste landed mid-
804 // `:caminho` block from a multi-line code-fence)
805 // silently round-trips through `Path::join` but the
806 // embedded newline class is a sibling of the CRLF-at-
807 // subprocess-argument injection vector
808 // `is_git_repo_url` already closes on `:repo`.
809 // - Tab (`0x09`) the canonical paste-from-aligned-table
810 // footgun: the tab is invisible in most editors, and
811 // the lacre embeds the value verbatim so two
812 // paste-from-distinct-tables yield divergent lacres
813 // across host editors that strip vs preserve tabs.
814 // - DEL (`0x7F`) + every other `0x00..=0x1F` byte: the
815 // paste-from-binary-blob shape every peer single-
816 // token-shaped slot rejects under the same
817 // `b < 0x20 || b == 0x7F` predicate.
818 //
819 // Mirrors the cascade discipline every prior `:caminho`
820 // arm establishes: `FonteCaminhoEmpty` →
821 // `FonteCaminhoAbsolute` → `FonteCaminhoTildeExpansion`
822 // → `FonteCaminhoVarExpansion` →
823 // `FonteCaminhoLeadingWhitespace` →
824 // `FonteCaminhoLeadingHyphen` → `FonteCaminhoControlChar`.
825 // The six leading-byte arms structurally precede the
826 // embedded-byte arm because the leading-byte shapes are
827 // the more self-locating diagnostic on values that probe
828 // as both (e.g. `:caminho "/etc/passwd\n"` surfaces the
829 // narrower `FonteCaminhoAbsolute` rather than the broader
830 // embedded-control-byte arm); the precedence pin matters
831 // at the diagnostic-shape level even though the empty /
832 // absolute / tilde / var arms are value-disjoint from a
833 // bare control byte (which would itself be a leading
834 // byte under the empty / absolute / tilde / var arms'
835 // leading-position semantics, but those arms guard the
836 // specific shell-convention characters `/` / `~` / `$`
837 // — a leading `0x01` byte falls through to this arm).
838 for &b in caminho.as_bytes() {
839 if b < 0x20 || b == 0x7F {
840 return Err(DepError::fonte_caminho_control_char(nome, caminho, b));
841 }
842 }
843 // Reproducibility gate's Windows-path-separator arm. The four
844 // leading-byte arms (`/` / `~` / `$`) and the embedded-
845 // control-byte arm close the host-layout-leaking + paste-from-
846 // multiline-doc shapes; the leading-`\` / embedded-`\` byte is
847 // the orthogonal cross-host-OS-separator shape — same render-
848 // determinism axis, different semantic mechanism. POSIX
849 // [`std::path::Path`] treats `\` (0x5C) as a literal byte
850 // inside a single path component (so `..\caixa-teia` is one
851 // directory named literally `..\caixa-teia`, sibling of `.`
852 // and `..`); Windows [`std::path::Path`] treats `\` as a
853 // primary path separator equal to `/` (so `..\caixa-teia` is
854 // the parent's sibling directory `caixa-teia`). The lacre
855 // pipeline embeds the value verbatim in its per-dep content-
856 // address (`conteudo: format!("path:{caminho}")`, caixa-
857 // resolver/src/resolve.rs:189), so byte-identical caixa.lisp
858 // values resolve to two distinct directories across runner
859 // OSes — the same THEORY.md §V.2 render-determinism contract
860 // the absolute / tilde / var arms protect, here against the
861 // cross-host-OS-separator divergence vector. Even on POSIX-
862 // only resolvers (the canonical pleme-io substrate posture),
863 // a `..\caixa-teia` (the Windows-Explorer "copy as path" /
864 // PowerShell `Get-Location` paste-idiom footgun) silently
865 // passes every prior arm because `Path::is_absolute` returns
866 // false on `..` and `\` is neither a leading-byte sentinel
867 // nor a control byte, then the resolver folds the value
868 // through `Path::new(caminho).join(<file>)` looking for a
869 // literal `./..\caixa-teia` subdirectory and fails at
870 // resolve time with a non-self-locating `No such file or
871 // directory` error far from the source caixa.lisp.
872 //
873 // The peer single-token-shaped axes on the same git-CLI /
874 // path-CLI consumer cluster already reject `\` under the same
875 // Windows-path-leak banner: [`crate::render::is_git_ref_name`]
876 // line 1441 (`"must not contain \\ … the canonical Windows-
877 // path-leak footgun; use / for hierarchical refs"`) gates
878 // `:fonte :tag` / `:fonte :branch` against the same byte,
879 // and [`crate::render::is_gateway_api_http_path`] line 506
880 // includes `\` in the eleven-byte RFC-3986-reserved rejection
881 // set on `:entrada :paths`. Closing the same byte on `:fonte
882 // :caminho` makes the substrate-wide "no Windows path
883 // separator anywhere in a typed string slot" invariant
884 // structurally consistent across every path-shaped typed
885 // surface (the `:caminho` axis was the last typed string
886 // surface still admitting `\`).
887 //
888 // The arm fires AFTER the control-char arm because the
889 // control-char diagnostic is the more self-locating axis on
890 // values that probe as both (`"..\caixa\0teia"` carries both
891 // a `\` and a NUL — NUL is the load-bearing POSIX-syscall-
892 // rejected byte, so `FonteCaminhoControlChar` wins). Same
893 // narrower-diagnostic-first cascade discipline every prior
894 // arm establishes. A pure-`\` value
895 // (`"..\caixa-teia"` with no control bytes) falls through
896 // every prior arm and lands here.
897 for &b in caminho.as_bytes() {
898 if b == b'\\' {
899 return Err(DepError::fonte_caminho_backslash(nome, caminho));
900 }
901 }
902 // Reproducibility gate's shell-redirection arm. The 3a4e1d7 backslash
903 // arm closes the cross-host-OS-separator vector; `<` (`0x3C`) and `>`
904 // (`0x3E`) are the orthogonal shell-redirection sentinels — same
905 // paste-from-shell-prompt footgun class, different syntactic surface.
906 // POSIX `std::path::Path` treats `<` / `>` as literal bytes inside a
907 // single path component (so `../caixa-teia>output` is one directory
908 // named literally `../caixa-teia>output`, sibling of `.` and `..`),
909 // but every interactive shell (bash / zsh / fish / nushell) lexes
910 // `<` / `>` as input / output redirection operators — a `:caminho
911 // "../caixa-teia>build.log"` (the canonical "I pasted a shell
912 // pipeline that wrote build output and forgot to trim the redirect"
913 // footgun) or `:caminho "../<input.lisp"` (the symmetric input-
914 // redirection paste idiom) silently passes every prior arm because
915 // `Path::is_absolute` returns false, `<` / `>` are neither leading-
916 // byte sentinels nor control bytes nor `\`, and the value's last byte
917 // isn't `/`. The resolver folds the value through
918 // `Path::new(caminho).join(<file>)` looking for a literal
919 // `./..\caixa-teia>build.log` subdirectory and fails at resolve time
920 // with a non-self-locating `No such file or directory` error far
921 // from the source caixa.lisp.
922 //
923 // The lacre pipeline embeds the value verbatim in its per-dep
924 // content-address (`conteudo: format!("path:{caminho}")`,
925 // caixa-resolver/src/resolve.rs:189), so a `<` / `>` byte lands in
926 // the BLAKE3 closure and rides downstream as part of the build's
927 // identity. The bytes carry a second class of hazard the prior
928 // separator-shaped arms don't: every typed-string slot whose value
929 // ever flows verbatim into a shell-spawned subprocess (the caixa-
930 // resolver's `git clone` invocation, a future `feira tofu` shell-
931 // out, a future operator-side `nix flake check` spawn) is the
932 // canonical CRLF-at-subprocess-argument / shell-metachar injection
933 // surface that every peer single-token-shaped typed slot already
934 // closes. The peer path-shaped axis `[crate::render::is_gateway_api_http_path]`
935 // (caixa-core/src/render.rs:506) rejects `<` / `>` as part of its
936 // eleven-byte RFC-3986-reserved set on `:entrada :paths`, and the
937 // peer git-ref-shaped axis `[crate::render::is_git_ref_name]` rejects
938 // `<` / `>` on `:fonte :tag` / `:fonte :branch` under the same
939 // shell-metachar-injection banner. The `:caminho` axis was the last
940 // typed string surface still admitting these two bytes; this arm
941 // closes the gap so the substrate-wide "no shell-redirection
942 // metacharacter anywhere in a typed string slot" invariant is now
943 // structurally consistent across every path-shaped typed surface.
944 //
945 // The arm fires AFTER the control-char arm + backslash arm because
946 // both prior arms carry more self-locating diagnostics on values
947 // that probe as both (`"..\foo<bar"` carries both `\` and `<` — the
948 // cross-OS-separator divergence is the load-bearing axis, so the
949 // backslash arm wins; `"../foo\n<bar"` carries both LF and `<` —
950 // the POSIX-syscall-rejected byte is the load-bearing axis, so the
951 // control-char arm wins). The arm fires BEFORE the trailing-`/` arm
952 // because the embedded redirection byte is the more semantic-
953 // locating axis on probe-as-both values (`"../foo</"` ends in `/`
954 // but the load-bearing diagnostic is the embedded `<` shell-
955 // redirection — the trailing `/` is the secondary observation, and
956 // an author who removes the `<` is likely to also tab-strip the
957 // trailing separator).
958 for &b in caminho.as_bytes() {
959 if b == b'<' || b == b'>' {
960 return Err(DepError::fonte_caminho_shell_redirection(nome, caminho, b));
961 }
962 }
963 // Reproducibility gate's shell-pipe arm. The e457141 shell-redirection
964 // arm closes the `<` / `>` input/output redirection sentinels; `|`
965 // (`0x7C`) is the orthogonal shell-pipe sentinel — same paste-from-
966 // shell-prompt footgun class, different syntactic surface. POSIX
967 // `std::path::Path` treats `|` as a literal path-component byte (so
968 // `../caixa-teia|tee` is one directory named literally
969 // `../caixa-teia|tee`, sibling of `.` and `..`), but every interactive
970 // shell (bash / zsh / fish / nushell) lexes `|` as the pipe operator
971 // — a `:caminho "../caixa-teia | grep foo"` (the canonical "I copied a
972 // `ls ../caixa-teia | grep` line out of a shell-history block and
973 // forgot to trim the pipeline tail" footgun) or `:caminho
974 // "../foo||bar"` (the symmetric "I copied a `cmd-a || cmd-b` short-
975 // circuit OR line" idiom) silently passes every prior arm because
976 // `Path::is_absolute` returns false on `..`, `|` is neither a leading-
977 // byte sentinel nor a control byte nor `\` nor `<` / `>`, and the
978 // value's last byte isn't `/`. The resolver folds the value through
979 // `Path::new(caminho).join(<file>)` looking for a literal
980 // `./../caixa-teia | grep foo` subdirectory and fails at resolve time
981 // with a non-self-locating `No such file or directory` error far
982 // from the source caixa.lisp.
983 //
984 // The lacre pipeline embeds the value verbatim in its per-dep
985 // content-address (`conteudo: format!("path:{caminho}")`,
986 // caixa-resolver/src/resolve.rs:189), so a `|` byte lands in the
987 // BLAKE3 closure and rides downstream as part of the build's identity
988 // into every shell-spawned subprocess (the caixa-resolver's `git
989 // clone` invocation, a future `feira tofu` shell-out, a future
990 // operator-side `nix flake check` spawn) as the canonical CRLF-at-
991 // subprocess-argument / shell-metachar injection surface every peer
992 // single-token-shaped typed slot already closes. The peer path-shaped
993 // axis [`crate::render::is_gateway_api_http_path`]
994 // (caixa-core/src/render.rs:506) rejects `|` as part of its eleven-
995 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
996 // axis was the last typed path-string surface still admitting this
997 // byte; this arm closes the gap so the substrate-wide "no shell-
998 // composition metacharacter anywhere in a typed string slot that
999 // flows verbatim into a shell-spawned subprocess" invariant extends
1000 // from shell-redirection (`<` / `>`) to shell-pipe (`|`) on the
1001 // `:caminho` axis.
1002 //
1003 // The arm fires AFTER the shell-redirection arm because the prior
1004 // arm's two-byte `byte: u8` payload is the more self-locating axis on
1005 // values that probe as both (`"../caixa-teia<input|tee"` carries both
1006 // `<` and `|` — the input-redirection-paste idiom is the load-bearing
1007 // root-cause edit, so `FonteCaminhoShellRedirection` wins; same
1008 // cascade discipline every prior `:caminho` arm establishes). The arm
1009 // fires BEFORE the trailing-`/` arm because the embedded pipe byte is
1010 // the more semantic-locating axis on probe-as-both values
1011 // (`"../foo|tee/"` ends in `/` but the load-bearing diagnostic is the
1012 // embedded `|` shell-pipe — the trailing `/` is the secondary
1013 // observation, and an author who removes the `|` is likely to also
1014 // tab-strip the trailing separator).
1015 for &b in caminho.as_bytes() {
1016 if b == b'|' {
1017 return Err(DepError::fonte_caminho_shell_pipe(nome, caminho));
1018 }
1019 }
1020 // Reproducibility gate's shell-command-separator arm. The 124106f
1021 // shell-pipe arm closes the `|` byte; `;` (`0x3B`) is the orthogonal
1022 // shell-command-separator sentinel — same paste-from-shell-prompt
1023 // footgun class, different syntactic surface. POSIX `std::path::Path`
1024 // treats `;` as a literal path-component byte (so
1025 // `../caixa-teia;rm -rf /` is one directory named literally
1026 // `../caixa-teia;rm -rf /`, sibling of `.` and `..`), but every
1027 // interactive shell (bash / zsh / fish / nushell) lexes `;` as the
1028 // sequential-command terminator that fires the next command
1029 // regardless of the prior command's exit status — a `:caminho
1030 // "../caixa-teia; rm -rf build"` (the canonical "I pasted a shell
1031 // one-liner that chained a cleanup tail after the directory name"
1032 // footgun) or `:caminho "../foo;;bar"` (the symmetric "I copied a
1033 // POSIX `case` arm's `;;` terminator into the middle of a path"
1034 // idiom) silently passes every prior arm because `Path::is_absolute`
1035 // returns false on `..`, `;` is neither a leading-byte sentinel nor a
1036 // control byte nor `\` nor `<` / `>` nor `|`, and the value's last
1037 // byte isn't `/`. The resolver folds the value through
1038 // `Path::new(caminho).join(<file>)` looking for a literal
1039 // `./../caixa-teia; rm -rf build` subdirectory and fails at resolve
1040 // time with a non-self-locating `No such file or directory` error far
1041 // from the source caixa.lisp.
1042 //
1043 // The lacre pipeline embeds the value verbatim in its per-dep
1044 // content-address (`conteudo: format!("path:{caminho}")`,
1045 // caixa-resolver/src/resolve.rs:189), so a `;` byte lands in the
1046 // BLAKE3 closure and rides downstream as part of the build's identity
1047 // into every shell-spawned subprocess (the caixa-resolver's `git
1048 // clone` invocation, a future `feira tofu` shell-out, a future
1049 // operator-side `nix flake check` spawn) as the canonical
1050 // shell-metachar injection surface every peer single-token-shaped
1051 // typed slot already closes. The peer path-shaped axis
1052 // [`crate::render::is_gateway_api_http_path`]
1053 // (caixa-core/src/render.rs:506) rejects `;` as part of its eleven-
1054 // byte RFC-3986-reserved set on `:entrada :paths`. The `:caminho`
1055 // axis was the last typed path-string surface still admitting this
1056 // byte; this arm closes the gap so the substrate-wide "no shell-
1057 // composition metacharacter anywhere in a typed string slot that
1058 // flows verbatim into a shell-spawned subprocess" invariant extends
1059 // from shell-pipe (`|`) to shell-command-separator (`;`) on the
1060 // `:caminho` axis.
1061 //
1062 // The arm fires AFTER the shell-pipe arm because the prior arm's
1063 // canonical-cmd-a-|-cmd-b shape is the more common shell-history
1064 // paste idiom on values that probe as both (`"../caixa-teia | tee;
1065 // rm"` carries both `|` and `;` — the pipeline-tail paste is the
1066 // load-bearing root-cause edit, so `FonteCaminhoShellPipe` wins; same
1067 // cascade discipline every prior `:caminho` arm establishes). The arm
1068 // fires BEFORE the trailing-`/` arm because the embedded
1069 // command-separator byte is the more semantic-locating axis on
1070 // probe-as-both values (`"../foo;rm/"` ends in `/` but the
1071 // load-bearing diagnostic is the embedded `;` shell-command-
1072 // separator — the trailing `/` is the secondary observation, and an
1073 // author who removes the `;` is likely to also tab-strip the trailing
1074 // separator).
1075 for &b in caminho.as_bytes() {
1076 if b == b';' {
1077 return Err(DepError::fonte_caminho_shell_semicolon(nome, caminho));
1078 }
1079 }
1080 // Reproducibility gate's shell-background / logical-AND arm. The
1081 // 05c358e shell-command-separator arm closes the `;` byte; `&`
1082 // (`0x26`) is the orthogonal shell-background / list-AND sentinel
1083 // — same paste-from-shell-prompt footgun class, different
1084 // syntactic surface. POSIX `std::path::Path` treats `&` as a
1085 // literal path-component byte (so `../caixa-teia & sleep 1` is
1086 // one directory named literally `../caixa-teia & sleep 1`,
1087 // sibling of `.` and `..`), but every interactive shell
1088 // (bash / zsh / fish / nushell) lexes `&` two ways:
1089 //
1090 // - Single `&` as the background-task terminator that detaches
1091 // the prior command into the background and returns control
1092 // to the prompt immediately (the canonical `cmd &` idiom
1093 // every long-running pipeline uses);
1094 // - Double `&&` as the logical-AND list operator that fires
1095 // the next command only if the prior command succeeded (the
1096 // canonical `make && make install` idiom every build script
1097 // carries).
1098 //
1099 // A `:caminho "../caixa-teia & sleep 1"` (the canonical "I
1100 // pasted a `cd path & sleep 1` background-launch into the
1101 // `:caminho` slot" footgun) or `:caminho "../caixa-teia && make"`
1102 // (the symmetric "I copied a `cd path && make` build chain"
1103 // idiom) silently passes every prior arm because
1104 // `Path::is_absolute` returns false on `..`, `&` is neither a
1105 // leading-byte sentinel nor a control byte nor `\` nor
1106 // `<` / `>` nor `|` nor `;`, and the value's last byte isn't `/`.
1107 // The resolver folds the value through
1108 // `Path::new(caminho).join(<file>)` looking for a literal
1109 // `./../caixa-teia & sleep 1` subdirectory and fails at resolve
1110 // time with a non-self-locating `No such file or directory`
1111 // error far from the source caixa.lisp.
1112 //
1113 // The lacre pipeline embeds the value verbatim in its per-dep
1114 // content-address (`conteudo: format!("path:{caminho}")`,
1115 // caixa-resolver/src/resolve.rs:189), so an `&` byte lands in
1116 // the BLAKE3 closure and rides downstream as part of the build's
1117 // identity into every shell-spawned subprocess (the
1118 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1119 // shell-out, a future operator-side `nix flake check` spawn) as
1120 // the canonical shell-metachar injection surface every peer
1121 // single-token-shaped typed slot already closes. The peer
1122 // path-shaped axis [`crate::render::is_gateway_api_http_path`]
1123 // (caixa-core/src/render.rs:506) rejects `&` as part of its
1124 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1125 // `:caminho` axis was the last typed path-string surface still
1126 // admitting this byte; this arm closes the gap so the
1127 // substrate-wide "no shell-composition metacharacter anywhere
1128 // in a typed string slot that flows verbatim into a
1129 // shell-spawned subprocess" invariant extends from
1130 // shell-command-separator (`;`) to shell-background /
1131 // logical-AND (`&`) on the `:caminho` axis.
1132 //
1133 // The arm fires AFTER the shell-command-separator arm because
1134 // the prior arm's `cmd-a; cmd-b` shape is the more common
1135 // shell-history paste idiom on values that probe as both
1136 // (`"../caixa-teia; rm & sleep"` carries both `;` and `&` — the
1137 // command-separator-tail paste is the load-bearing root-cause
1138 // edit, so `FonteCaminhoShellSemicolon` wins; same cascade
1139 // discipline every prior `:caminho` arm establishes). The arm
1140 // fires BEFORE the trailing-`/` arm because the embedded
1141 // background / list-AND byte is the more semantic-locating axis
1142 // on probe-as-both values (`"../foo&bar/"` ends in `/` but the
1143 // load-bearing diagnostic is the embedded `&` shell-background
1144 // / logical-AND metachar — the trailing `/` is the secondary
1145 // observation, and an author who removes the `&` is likely to
1146 // also tab-strip the trailing separator).
1147 for &b in caminho.as_bytes() {
1148 if b == b'&' {
1149 return Err(DepError::fonte_caminho_shell_background(nome, caminho));
1150 }
1151 }
1152 // Reproducibility gate's shell-command-substitution arm. The
1153 // e12e4f3 shell-background / logical-AND arm closes the `&`
1154 // byte; the backtick (`0x60`) is the orthogonal POSIX legacy
1155 // command-substitution sentinel — every POSIX shell (sh /
1156 // bash / zsh / dash / ksh / fish / nushell) lexes the byte as
1157 // the canonical legacy wrapper that runs the enclosed command
1158 // and substitutes its standard-output verbatim into the
1159 // surrounding word (a `whoami` wrapped in backticks expands
1160 // to the current user's name; a `cat /etc/passwd` wrapped in
1161 // backticks expands to the file's contents — the canonical
1162 // CWE-78 shell-command-injection vector every shell-side
1163 // hardening guide enumerates first). POSIX
1164 // `std::path::Path` treats backtick as a literal path-
1165 // component byte (so `../caixa-teia/<backtick>whoami<backtick>`
1166 // is one directory named literally that, sibling of `.` and
1167 // `..`).
1168 //
1169 // A `:caminho "../caixa-teia/<backtick>whoami<backtick>"` (the
1170 // canonical "I pasted a shell one-liner carrying a backticked
1171 // `whoami` command-substitution expansion into the `:caminho`
1172 // slot" footgun) or `:caminho "<backtick>pwd<backtick>/caixa-
1173 // teia"` (the symmetric "I copied a `<backtick>pwd<backtick>/
1174 // path` working-directory expansion") silently passes every
1175 // prior arm because `Path::is_absolute` returns false on
1176 // `..`, the backtick byte is neither a leading-byte sentinel
1177 // (the f4efe9c `FonteCaminhoVarExpansion` arm catches the
1178 // modern `$()` form at leading position only; backtick is
1179 // the orthogonal legacy form) nor a control byte nor `\` nor
1180 // `<` / `>` nor `|` nor `;` nor `&`, and the value's last
1181 // byte isn't `/`. The resolver folds the value through
1182 // `Path::new(caminho).join(<file>)` looking for a literal
1183 // subdirectory whose name embeds the backticked token and
1184 // fails at resolve time with a non-self-locating `No such
1185 // file or directory` error far from the source caixa.lisp.
1186 //
1187 // The lacre pipeline embeds the value verbatim in its per-
1188 // dep content-address (`conteudo: format!("path:{caminho}")`,
1189 // caixa-resolver/src/resolve.rs:189), so a backtick byte
1190 // lands in the BLAKE3 closure and rides downstream as part
1191 // of the build's identity into every shell-spawned
1192 // subprocess (the caixa-resolver's `git clone` invocation, a
1193 // future `feira tofu` shell-out, a future operator-side
1194 // `nix flake check` spawn) as the canonical shell-metachar
1195 // injection surface every peer single-token-shaped typed
1196 // slot already closes. The peer path-shaped axis
1197 // [`crate::render::is_gateway_api_http_path`]
1198 // (caixa-core/src/render.rs:506) rejects backtick as part of
1199 // its eleven-byte RFC-3986-reserved set on `:entrada
1200 // :paths`. The `:caminho` axis was the last typed path-
1201 // string surface still admitting this byte; this arm closes
1202 // the gap so the substrate-wide "no shell-composition
1203 // metacharacter anywhere in a typed string slot that flows
1204 // verbatim into a shell-spawned subprocess" invariant
1205 // extends from shell-background / logical-AND (`&`) to
1206 // shell-command-substitution (backtick) on the `:caminho`
1207 // axis.
1208 //
1209 // The arm fires AFTER the shell-background arm because the
1210 // prior arm's `cmd & sleep` shape is the more common shell-
1211 // history paste idiom on values that probe as both (a
1212 // `"../caixa-teia & <backtick>whoami<backtick>"` carries
1213 // both `&` and a backtick — the background-launch tail is
1214 // the load-bearing root-cause edit, so
1215 // `FonteCaminhoShellBackground` wins; same cascade
1216 // discipline every prior `:caminho` arm establishes). The
1217 // arm fires BEFORE the trailing-`/` arm because the
1218 // embedded command-substitution byte is the more semantic-
1219 // locating axis on probe-as-both values (a
1220 // `"../<backtick>whoami<backtick>/"` ends in `/` but the
1221 // load-bearing diagnostic is the embedded backtick shell-
1222 // command-substitution metachar — the trailing `/` is the
1223 // secondary observation, and an author who removes the
1224 // backtick is likely to also tab-strip the trailing
1225 // separator).
1226 for &b in caminho.as_bytes() {
1227 if b == b'`' {
1228 return Err(DepError::fonte_caminho_shell_command_substitution(
1229 nome, caminho,
1230 ));
1231 }
1232 }
1233 // Reproducibility gate's shell-glob arm. The c4d62b3 shell-command-
1234 // substitution arm closes the backtick byte; `*` (`0x2A`) and `?`
1235 // (`0x3F`) are the orthogonal POSIX glob-expansion sentinels — same
1236 // paste-from-shell-prompt footgun class, different syntactic surface.
1237 // Every POSIX shell (sh / bash / zsh / dash / ksh / fish / nushell)
1238 // lexes `*` and `?` as pathname-expansion wildcards: `*` matches any
1239 // sequence of characters in a path component (including the empty
1240 // sequence), `?` matches exactly one character. POSIX
1241 // `std::path::Path` treats both bytes as literal path-component bytes
1242 // (so `../caixa-teia/*.lisp` is one directory named literally
1243 // `../caixa-teia/*.lisp`, sibling of `.` and `..`).
1244 //
1245 // A `:caminho "../caixa-teia/*"` (the canonical "I pasted a
1246 // `ls ../caixa-teia/*` shell-listing one-liner into the `:caminho`
1247 // slot" footgun) or `:caminho "../foo?"` (the symmetric "I copied a
1248 // `rm foo?` single-char-wildcard removal idiom") silently passes
1249 // every prior arm because `Path::is_absolute` returns false on `..`,
1250 // `*` / `?` are neither leading-byte sentinels nor control bytes nor
1251 // `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick, and the
1252 // value's last byte isn't `/`. The resolver folds the value through
1253 // `Path::new(caminho).join(<file>)` looking for a literal
1254 // `./../caixa-teia/*` subdirectory and fails at resolve time with a
1255 // non-self-locating `No such file or directory` error far from the
1256 // source caixa.lisp.
1257 //
1258 // The lacre pipeline embeds the value verbatim in its per-dep
1259 // content-address (`conteudo: format!("path:{caminho}")`,
1260 // caixa-resolver/src/resolve.rs:189), so a `*` or `?` byte lands in
1261 // the BLAKE3 closure and rides downstream as part of the build's
1262 // identity into every shell-spawned subprocess (the caixa-resolver's
1263 // `git clone` invocation, a future `feira tofu` shell-out, a future
1264 // operator-side `nix flake check` spawn) as the canonical
1265 // shell-metachar / pathname-expansion surface every peer
1266 // single-token-shaped typed slot already closes. The peer path-shaped
1267 // axis [`crate::render::is_gateway_api_http_path`]
1268 // (caixa-core/src/render.rs:506) rejects `*` and `?` as part of its
1269 // eleven-byte RFC-3986-reserved set on `:entrada :paths`. The
1270 // `:caminho` axis was the last typed path-string surface still
1271 // admitting these two bytes; this arm closes the gap so the
1272 // substrate-wide "no shell-composition / glob-expansion
1273 // metacharacter anywhere in a typed string slot that flows verbatim
1274 // into a shell-spawned subprocess" invariant extends from
1275 // shell-command-substitution (backtick) to glob-expansion
1276 // (`*` / `?`) on the `:caminho` axis.
1277 //
1278 // The arm fires AFTER the backtick arm because the prior arm's
1279 // CWE-78 shell-command-injection vector is the load-bearing
1280 // diagnostic on values that probe as both (a `"../`whoami`/*"`
1281 // carries both backtick and `*` — the command-substitution paste
1282 // is the load-bearing root-cause edit, so
1283 // `FonteCaminhoShellCommandSubstitution` wins; same cascade
1284 // discipline every prior `:caminho` arm establishes). The arm
1285 // fires BEFORE the trailing-`/` arm because the embedded glob
1286 // byte is the more semantic-locating axis on probe-as-both values
1287 // (`"../foo*/"` ends in `/` but the load-bearing diagnostic is the
1288 // embedded `*` glob metachar — the trailing `/` is the secondary
1289 // observation, and an author who removes the `*` is likely to
1290 // also tab-strip the trailing separator).
1291 for &b in caminho.as_bytes() {
1292 if b == b'*' || b == b'?' {
1293 return Err(DepError::fonte_caminho_shell_glob(nome, caminho, b));
1294 }
1295 }
1296 // Reproducibility gate's shell-subshell-grouping arm. The cf9034b
1297 // shell-glob arm closes the `*` / `?` pathname-expansion sentinels;
1298 // `(` (`0x28`) and `)` (`0x29`) are the orthogonal POSIX subshell-
1299 // grouping sentinels — same paste-from-shell-prompt footgun class,
1300 // different syntactic surface. Every POSIX shell (sh / bash / zsh /
1301 // dash / ksh / fish / nushell) lexes the parenthesis pair as the
1302 // subshell-grouping operator: `(<cmd>)` runs `<cmd>` in a child
1303 // shell with a fresh environment scope (the canonical sandboxing
1304 // idiom every shell-history `(cd <path> && <cmd>)` one-liner uses
1305 // to scope a `cd` to one subshell without disturbing the parent's
1306 // working directory), and `$(<cmd>)` is the modern Bourne
1307 // command-substitution shape the upstream f4efe9c
1308 // `FonteCaminhoVarExpansion` arm closes the leading `$` byte of —
1309 // the closing `)` byte completes that substitution shape and must
1310 // be refused on the same axis (peer with the
1311 // [`crate::render::is_git_repo_url`] 3b99147 arm that closes the
1312 // same byte-pair on the sibling `:fonte :repo` axis under the
1313 // same shell-subshell-grouping + RFC-3986-sub-delims banner).
1314 // POSIX `std::path::Path` treats both bytes as literal path-
1315 // component bytes (so `../caixa-teia/(date)` is one directory
1316 // named literally `../caixa-teia/(date)`, sibling of `.` and
1317 // `..`).
1318 //
1319 // A `:caminho "../caixa-teia/$(date)/build"` (the canonical "I
1320 // pasted a `cd ../caixa-teia/$(date)/build` shell-history one-
1321 // liner whose modern command-substitution expansion lands the
1322 // current date as a subdirectory name" footgun) or `:caminho
1323 // "../(cd foo && pwd)/caixa-teia"` (the symmetric "I copied a
1324 // `(cd foo && pwd)` subshell-grouping working-directory probe
1325 // idiom") silently passes every prior arm because
1326 // `Path::is_absolute` returns false on `..`, `(` / `)` are
1327 // neither leading-byte sentinels nor control bytes nor `\` nor
1328 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` / `?`,
1329 // and the value's last byte isn't `/`. The resolver folds the
1330 // value through `Path::new(caminho).join(<file>)` looking for a
1331 // literal `./../caixa-teia/$(date)/build` subdirectory and fails
1332 // at resolve time with a non-self-locating `No such file or
1333 // directory` error far from the source caixa.lisp.
1334 //
1335 // The lacre pipeline embeds the value verbatim in its per-dep
1336 // content-address (`conteudo: format!("path:{caminho}")`,
1337 // caixa-resolver/src/resolve.rs:189), so a `(` or `)` byte lands
1338 // in the BLAKE3 closure and rides downstream as part of the
1339 // build's identity into every shell-spawned subprocess (the
1340 // caixa-resolver's `git clone` invocation, a future `feira tofu`
1341 // shell-out, a future operator-side `nix flake check` spawn) as
1342 // the canonical shell-metachar / subshell-grouping surface every
1343 // peer single-token-shaped typed slot already closes. The peer
1344 // git-source axis [`crate::render::is_git_repo_url`] (3b99147)
1345 // rejects the same byte pair on `:fonte :repo` under the same
1346 // shell-subshell-grouping / RFC-3986-sub-delims banner. The
1347 // `:caminho` axis was the last typed path-string surface still
1348 // admitting these two bytes;
1349 // this arm closes the gap so the substrate-wide "no shell-
1350 // composition metacharacter anywhere in a typed string slot that
1351 // flows verbatim into a shell-spawned subprocess" invariant
1352 // extends from shell-glob (`*` / `?`) to shell-subshell-grouping
1353 // (`(` / `)`) on the `:caminho` axis. Together with the f4efe9c
1354 // leading-`$` arm, the typed `:caminho` accepted set now
1355 // structurally excludes the entire modern Bourne
1356 // command-substitution surface — leading `$` closes the
1357 // leading byte of every `$(<cmd>)` shape, this arm closes the
1358 // trailing `)` boundary.
1359 //
1360 // The arm fires AFTER the shell-glob arm because the prior arm's
1361 // `*` / `?` pathname-expansion shape is the more common shell-
1362 // history paste idiom on values that probe as both
1363 // (`"../caixa-teia/*(date)"` carries both `*` and `(` — the
1364 // glob-paste-tail is the load-bearing root-cause edit, so
1365 // `FonteCaminhoShellGlob` wins; same cascade discipline every
1366 // prior `:caminho` arm establishes). The arm fires BEFORE the
1367 // trailing-`/` arm because the embedded subshell-grouping byte
1368 // is the more semantic-locating axis on probe-as-both values
1369 // (`"../foo(date)/"` ends in `/` but the load-bearing diagnostic
1370 // is the embedded `(` shell-subshell-grouping metachar — the
1371 // trailing `/` is the secondary observation, and an author who
1372 // removes the `(` is likely to also tab-strip the trailing
1373 // separator).
1374 for &b in caminho.as_bytes() {
1375 if b == b'(' || b == b')' {
1376 return Err(DepError::fonte_caminho_shell_subshell_grouping(
1377 nome, caminho, b,
1378 ));
1379 }
1380 }
1381 // Reproducibility gate's shell-brace-expansion arm. The 0633c91
1382 // shell-subshell-grouping arm closes `(` / `)`; `{` (`0x7b`) and
1383 // `}` (`0x7d`) are the orthogonal shell-brace-expansion /
1384 // URI-Template-placeholder byte pair — same paste-from-shell-
1385 // prompt + paste-from-templated-doc footgun class, different
1386 // syntactic surface. Every POSIX-derived shell that implements
1387 // brace expansion (bash / zsh / ksh / fish; the canonical
1388 // `mkdir -p ../{caixa-teia,caixa-helm,caixa-flux}` /
1389 // `cp file{,.bak}` idiom every shell-history block carries)
1390 // expands `{a,b,c}` to the cross-product of its comma-separated
1391 // members and `{1..10}` to the integer range; RFC 6570 reserves
1392 // the matched pair for URI Template placeholders (the canonical
1393 // `https://{host}/{org}/{repo}` substitution shape every
1394 // OpenAPI / Swagger / Postman / GitHub Octokit client /
1395 // Helm chart-URL fragment / Mustache `{{org}}` doubled-brace
1396 // form carries), and Tera / Jinja2 / Handlebars / Go html/template
1397 // every IaC tool (Helm, Kustomize, Terraform's `${var}` cousin
1398 // shape) emit. POSIX `std::path::Path` treats both bytes as
1399 // literal path-component bytes (so `../{caixa-teia,caixa-helm}`
1400 // is one directory named literally `../{caixa-teia,caixa-helm}`,
1401 // sibling of `.` and `..`).
1402 //
1403 // A `:caminho "../{caixa-teia,caixa-helm}/build"` (the canonical
1404 // "I pasted a `cd ../{caixa-teia,caixa-helm}` shell brace-
1405 // expansion one-liner that fans across two siblings" footgun)
1406 // or `:caminho "../{{org}}/caixa-teia"` (the symmetric "I copied
1407 // a `{{org}}` Mustache / Helm template placeholder out of a
1408 // README quick-start and forgot to substitute") silently passes
1409 // every prior arm because `Path::is_absolute` returns false on
1410 // `..`, `{` / `}` are neither leading-byte sentinels nor control
1411 // bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor
1412 // backtick nor `*` / `?` nor `(` / `)`, and the value's last
1413 // byte isn't `/`. The resolver folds the value through
1414 // `Path::new(caminho).join(<file>)` looking for a literal
1415 // `./../{caixa-teia,caixa-helm}/build` subdirectory and fails
1416 // at resolve time with a non-self-locating `No such file or
1417 // directory` error far from the source caixa.lisp.
1418 //
1419 // The lacre pipeline embeds the value verbatim in its per-dep
1420 // content-address (`conteudo: format!("path:{caminho}")`,
1421 // caixa-resolver/src/resolve.rs:189), so a `{` or `}` byte
1422 // lands in the BLAKE3 closure and rides downstream as part of
1423 // the build's identity into every shell-spawned subprocess
1424 // (the caixa-resolver's `git clone` invocation, a future
1425 // `feira tofu` shell-out, a future operator-side `nix flake
1426 // check` spawn) as the canonical shell-metachar / brace-
1427 // expansion surface every peer single-token-shaped typed
1428 // slot already closes. The peer git-source axis
1429 // [`crate::render::is_git_repo_url`] (42d8f9d — the URI Template
1430 // placeholder arm) rejects the same byte pair on `:fonte :repo`
1431 // under the same RFC-3986-'delims' / RFC-6570-URI-Template /
1432 // shell-brace-expansion banner. The `:caminho` axis was the last
1433 // typed path-string surface still admitting these two bytes;
1434 // this arm closes the gap so the substrate-wide "no shell-
1435 // composition metacharacter anywhere in a typed string slot
1436 // that flows verbatim into a shell-spawned subprocess"
1437 // invariant extends from shell-subshell-grouping (`(` / `)`)
1438 // to shell-brace-expansion (`{` / `}`) on the `:caminho` axis,
1439 // and the typed `:caminho` accepted set now also structurally
1440 // excludes the URI Template / templating-engine placeholder
1441 // surface that would silently round-trip through any
1442 // downstream IaC templating-engine layer.
1443 //
1444 // The arm fires AFTER the shell-subshell-grouping arm because
1445 // the prior arm's `(` / `)` shape is the more semantic-locating
1446 // axis on values that probe as both (`"../{cd foo}(date)"`
1447 // carries both `{` and `(` — the parenthesis-pair is the
1448 // load-bearing modern-Bourne-command-substitution surface the
1449 // prior arm closes; same cascade discipline every prior
1450 // `:caminho` arm establishes). The arm fires BEFORE the
1451 // trailing-`/` arm because the embedded brace-expansion byte
1452 // is the more semantic-locating axis on probe-as-both values
1453 // (`"../{caixa-teia,caixa-helm}/"` ends in `/` but the
1454 // load-bearing diagnostic is the embedded `{` brace-expansion
1455 // metachar — the trailing `/` is the secondary observation,
1456 // and an author who removes the `{` is likely to also tab-
1457 // strip the trailing separator).
1458 for &b in caminho.as_bytes() {
1459 if b == b'{' || b == b'}' {
1460 return Err(DepError::fonte_caminho_shell_brace_expansion(
1461 nome, caminho, b,
1462 ));
1463 }
1464 }
1465 // Reproducibility gate's shell-bracket-expansion arm. The 598b770
1466 // shell-brace-expansion arm closes `{` / `}`; `[` (`0x5b`) and
1467 // `]` (`0x5d`) are the orthogonal POSIX glob-character-class /
1468 // shell-`test`-builtin byte pair — same paste-from-shell-prompt
1469 // footgun class, different syntactic surface. Every POSIX shell
1470 // (sh / bash / zsh / dash / ksh / fish / nushell) lexes the
1471 // bracket pair as the glob character-class operator: `[abc]`
1472 // matches one of `a`, `b`, `c`; `[a-z]` matches any lowercase
1473 // ASCII letter; `[^x]` negates (the canonical
1474 // `ls *.[ch]` C-source-file glob and the `cd ../[a-z]*`
1475 // lowercase-sibling glob every shell-history block carries —
1476 // the orthogonal axis to the cf9034b `*` / `?` shell-glob arm
1477 // closing the unbounded pathname-expansion sentinels). The
1478 // bracket pair additionally carries the POSIX `test` /
1479 // `[` builtin command (`[ -d ../caixa-teia ] && cd ...` —
1480 // the canonical idiom every shell-script conditional uses) and
1481 // bash's `[[ ... ]]` extended-test grammar. Beyond shell, the
1482 // bracket pair is the TOML inline-array delimiter
1483 // (`features = ["a", "b"]` — the canonical paste-from-Cargo-
1484 // manifest cross-idiom-leak vector), the YAML flow-sequence
1485 // delimiter (`paths: [/a, /b]` — the canonical paste-from-
1486 // values.yaml cross-idiom leak), the JSON array delimiter,
1487 // and the POSIX-ERE / PCRE bracket-expression / character-
1488 // class anchor (the canonical paste-from-regex-doc shape).
1489 // POSIX `std::path::Path` treats both bytes as literal path-
1490 // component bytes (so `../[caixa-teia]` is one directory
1491 // named literally `../[caixa-teia]`, sibling of `.` and
1492 // `..`).
1493 //
1494 // A `:caminho "../caixa-[a-z]/build"` (the canonical "I
1495 // pasted a `cd ../caixa-[a-z]/build` glob-character-class
1496 // one-liner that matches every lowercase-sibling-suffix
1497 // sibling directory" footgun), `:caminho "../[caixa-teia]/
1498 // build"` (the symmetric "I pasted a TOML inline-array /
1499 // YAML flow-sequence shape out of an aligned manifest"
1500 // idiom), or `:caminho "../caixa-[ch]"` (the canonical
1501 // `*.[ch]` C-source character-class paste-from-shell-history
1502 // shape) silently passes every prior arm because
1503 // `Path::is_absolute` returns false on `..`, `[` / `]` are
1504 // neither leading-byte sentinels nor control bytes nor `\`
1505 // nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1506 // `*` / `?` nor `(` / `)` nor `{` / `}`, and the value's
1507 // last byte isn't `/`. The resolver folds the value through
1508 // `Path::new(caminho).join(<file>)` looking for a literal
1509 // `./../caixa-[a-z]/build` subdirectory and fails at resolve
1510 // time with a non-self-locating `No such file or directory`
1511 // error far from the source caixa.lisp.
1512 //
1513 // The lacre pipeline embeds the value verbatim in its per-dep
1514 // content-address (`conteudo: format!("path:{caminho}")`,
1515 // caixa-resolver/src/resolve.rs:189), so a `[` or `]` byte
1516 // lands in the BLAKE3 closure and rides downstream as part of
1517 // the build's identity into every shell-spawned subprocess
1518 // (the caixa-resolver's `git clone` invocation, a future
1519 // `feira tofu` shell-out, a future operator-side `nix flake
1520 // check` spawn) as the canonical shell-metachar / glob-
1521 // character-class / TOML-array surface every peer single-
1522 // token-shaped typed slot already closes. The `:caminho` axis
1523 // was the last typed path-string surface still admitting
1524 // these two bytes; this arm closes the gap so the substrate-
1525 // wide "no shell-composition metacharacter anywhere in a
1526 // typed string slot that flows verbatim into a shell-spawned
1527 // subprocess" invariant extends from shell-brace-expansion
1528 // (`{` / `}`) to shell-bracket-expansion (`[` / `]`) on the
1529 // `:caminho` axis. Together with the cf9034b `*` / `?` arm,
1530 // the typed `:caminho` accepted set now structurally excludes
1531 // the entire POSIX pathname-expansion / glob surface —
1532 // unbounded glob (`*` / `?`) AND bounded character-class
1533 // (`[abc]` / `[a-z]`).
1534 //
1535 // The arm fires AFTER the shell-brace-expansion arm because
1536 // the prior arm's `{` / `}` shape is the more semantic-
1537 // locating axis on values that probe as both
1538 // (`"../{a,b}[ch]"` carries both `{` and `[` — the brace-
1539 // expansion fan is the load-bearing root-cause edit, so
1540 // `FonteCaminhoShellBraceExpansion` wins; same cascade
1541 // discipline every prior `:caminho` arm establishes). The arm
1542 // fires BEFORE the trailing-`/` arm because the embedded
1543 // bracket-expansion byte is the more semantic-locating axis
1544 // on probe-as-both values (`"../[a-z]/"` ends in `/` but the
1545 // load-bearing diagnostic is the embedded `[` glob-character-
1546 // class metachar — the trailing `/` is the secondary
1547 // observation, and an author who removes the `[` is likely
1548 // to also tab-strip the trailing separator).
1549 for &b in caminho.as_bytes() {
1550 if b == b'[' || b == b']' {
1551 return Err(DepError::fonte_caminho_shell_bracket_expansion(
1552 nome, caminho, b,
1553 ));
1554 }
1555 }
1556 // Reproducibility gate's shell-quote-grouping arm. The 986963b
1557 // shell-bracket-expansion arm closes `[` / `]`; `'` (`0x27`) and
1558 // `"` (`0x22`) are the orthogonal POSIX shell-string-literal
1559 // delimiter pair — same paste-from-shell-prompt footgun class,
1560 // different syntactic surface. Every POSIX shell (sh / bash /
1561 // zsh / dash / ksh / fish / nushell) lexes the pair as the
1562 // string-literal quoting operator: `'…'` is the strong
1563 // (no-expansion) single-quoted string and `"…"` is the weak
1564 // (variable-/command-substitution-preserving) double-quoted
1565 // string — the canonical `cd '../caixa-teia'` shell-history
1566 // idiom every path-with-embedded-whitespace paste block carries,
1567 // and the symmetric `git clone "$REPO"` weak-quoted CI-manifest
1568 // shape. Beyond shell, the two bytes carry the JSON string-literal
1569 // delimiter (`"key": "value"` — the canonical paste-from-JSON-
1570 // config cross-idiom-leak vector), the YAML double-quoted +
1571 // single-quoted flow-scalar delimiters (`path: "../caixa-teia"`
1572 // — the canonical paste-from-values.yaml / paste-from-K8s-YAML-
1573 // manifest cross-idiom leak), the TOML basic + literal string
1574 // delimiters (`path = "../caixa-teia"` — the canonical paste-
1575 // from-Cargo-manifest cross-idiom-leak vector), the tatara-lisp
1576 // string-literal delimiter itself (`(:caminho "../caixa-teia")`
1577 // — the canonical "I copied the entire `:caminho "..."` slot
1578 // rather than just the string body" author-surface footgun),
1579 // and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which
1580 // excludes both bytes from the `unreserved / pct-encoded /
1581 // sub-delims / ":" / "@"` `pchar` production. POSIX
1582 // `std::path::Path` treats both bytes as literal path-component
1583 // bytes (so `../"caixa-teia"` is one directory named literally
1584 // `../"caixa-teia"`, sibling of `.` and `..`).
1585 //
1586 // A `:caminho "'../caixa-teia'"` (the canonical "I pasted a
1587 // `cd '../caixa-teia'` shell-history one-liner whose strong-
1588 // quoting preserved the sibling-workspace path verbatim across
1589 // the whitespace paste boundary" footgun), `:caminho
1590 // "\"../caixa-teia\""` (the symmetric weak-quoted paste-from-
1591 // JSON / paste-from-YAML flow-scalar / paste-from-TOML basic-
1592 // string / paste-from-tatara-lisp string-literal cross-idiom-
1593 // leak shape), or `:caminho "../\"caixa-teia\""` (the embedded-
1594 // quote "I pasted a JSON key-value pair fragment into the
1595 // middle of the path" idiom) silently passes every prior arm
1596 // because `Path::is_absolute` returns false on `..` / `'` /
1597 // `"`, `'` / `"` are neither leading-byte sentinels nor
1598 // control bytes nor `\` nor `<` / `>` nor `|` nor `;` nor `&`
1599 // nor backtick nor `*` / `?` nor `(` / `)` nor `{` / `}` nor
1600 // `[` / `]`, and the value's last byte isn't `/`. The resolver
1601 // folds the value through `Path::new(caminho).join(<file>)`
1602 // looking for a literal `./'../caixa-teia'` subdirectory and
1603 // fails at resolve time with a non-self-locating `No such file
1604 // or directory` error far from the source caixa.lisp.
1605 //
1606 // The lacre pipeline embeds the value verbatim in its per-dep
1607 // content-address (`conteudo: format!("path:{caminho}")`,
1608 // caixa-resolver/src/resolve.rs:189), so a `'` or `"` byte
1609 // lands in the BLAKE3 closure and rides downstream as part of
1610 // the build's identity into every shell-spawned subprocess
1611 // (the caixa-resolver's `git clone` invocation, a future
1612 // `feira tofu` shell-out, a future operator-side `nix flake
1613 // check` spawn) as the canonical shell-metachar / string-
1614 // literal-delimiter surface every peer single-token-shaped
1615 // typed slot already closes. The peer `:fonte :repo` axis
1616 // closes both bytes under the same shell-quote-grouping /
1617 // RFC-3986-sub-delims banner (e7a109f `'` shell-single-quote
1618 // + 4267d8b `"` shell-double-quote on `is_git_repo_url`). The
1619 // `:caminho` axis was the last typed path-string surface
1620 // still admitting these two bytes; this arm closes the gap
1621 // so the substrate-wide "no shell-composition metacharacter
1622 // anywhere in a typed string slot that flows verbatim into a
1623 // shell-spawned subprocess" invariant extends from shell-
1624 // bracket-expansion (`[` / `]`) to shell-quote-grouping (`'`
1625 // / `"`) on the `:caminho` axis. Together with the peer
1626 // JSON / YAML / TOML string-literal delimiters closing at
1627 // this arm and the 598b770 `{` / `}` brace-expansion arm
1628 // closing the templating-engine-placeholder boundary, the
1629 // typed `:caminho` accepted set now structurally excludes
1630 // the entire cross-config-DSL string-literal / templating
1631 // paste-from-aligned-manifest cross-idiom-leak surface that
1632 // would silently round-trip through any downstream JSON /
1633 // YAML / TOML / HCL / tatara-lisp parsing layer.
1634 //
1635 // The arm fires AFTER the shell-bracket-expansion arm because
1636 // the prior arm's `[` / `]` shape is the more semantic-
1637 // locating axis on values that probe as both (`"../[a-z]'x'"`
1638 // carries both `[` and `'` — the glob-character-class
1639 // expansion is the load-bearing root-cause edit, so
1640 // `FonteCaminhoShellBracketExpansion` wins; same cascade
1641 // discipline every prior `:caminho` arm establishes). The arm
1642 // fires BEFORE the trailing-`/` arm because the embedded
1643 // quote-grouping byte is the more semantic-locating axis on
1644 // probe-as-both values (`"../'caixa-teia'/"` ends in `/` but
1645 // the load-bearing diagnostic is the embedded `'` shell-
1646 // string-literal metachar — the trailing `/` is the secondary
1647 // observation, and an author who removes the `'` is likely to
1648 // also tab-strip the trailing separator).
1649 for &b in caminho.as_bytes() {
1650 if b == b'\'' || b == b'"' {
1651 return Err(DepError::fonte_caminho_shell_quote_grouping(
1652 nome, caminho, b,
1653 ));
1654 }
1655 }
1656 // Reproducibility gate's shell-comment / URL-fragment / YAML-comment arm.
1657 // The d14cbc5 shell-quote-grouping arm closes `'` / `"`; `#` (`0x23`) is
1658 // the orthogonal "byte at which four distinct downstream parsers all
1659 // truncate the value at the first occurrence" surface, and no prior arm
1660 // has covered it on the `:caminho` axis. Every POSIX shell (sh / bash /
1661 // zsh / dash / ksh / fish / nushell) lexes an unquoted `#` at the head
1662 // of a word (or after unquoted whitespace) as the comment-lead: from
1663 // that byte to the end of the physical line is a comment discarded
1664 // before command parsing (`cd ../caixa-teia # legacy sibling` — the
1665 // canonical paste-from-shell-history-with-trailing-annotation shape
1666 // every operator-notebook and CI-manifest carries; POSIX.1-2017 §2.3
1667 // Token Recognition step 6). YAML 1.2 §6.6 makes `#` the comment lead
1668 // at any position preceded by whitespace or at line-start (`path:
1669 // ../caixa-teia # pin` — the canonical paste-from-values.yaml /
1670 // paste-from-K8s-manifest cross-idiom-leak shape). tatara-lisp itself
1671 // treats `;` as the comment-lead but a growing number of consumer
1672 // config-DSL layers (HCL, Terraform, Nix flake attributes, .env
1673 // dotenv-style files, gitconfig / .gitignore, ini / TOML) use `#` as
1674 // the comment-lead too — the pair extends the cross-config-DSL
1675 // paste-idiom surface the d14cbc5 quote-grouping arm and the 598b770
1676 // brace-expansion arm already cover on adjacent axes. RFC 3986 §3.5
1677 // reserves `#` as the URL fragment-identifier delimiter (the canonical
1678 // paste-from-browser-address-bar `github.com/foo/bar#readme` /
1679 // `github.com/foo/bar#L42` permalink shape, and the symmetric
1680 // Nix-flake-ref cross-idiom leak `github:foo/bar#packageName` where
1681 // `#` selects a flake output — the same axis the peer
1682 // [`crate::render::is_git_repo_url`] closes on the `:fonte :repo`
1683 // surface at a68f818 with the same downstream-drops-the-tail
1684 // rationale).
1685 //
1686 // POSIX `std::path::Path` treats `#` as a literal path-component byte,
1687 // so a `:caminho "../caixa-teia # legacy sibling"` (the canonical
1688 // paste-from-shell-history-with-trailing-annotation footgun),
1689 // `:caminho "../caixa-teia # pin"` (the symmetric YAML flow-scalar
1690 // paste-with-trailing-comment shape), or `:caminho "../caixa-teia
1691 // #readme"` (the URL fragment paste-from-browser-address-bar shape)
1692 // silently passes every prior arm because `Path::is_absolute` returns
1693 // false on `..`, `#` is neither a leading-byte sentinel nor a control
1694 // byte nor `\` nor `<` / `>` nor `|` nor `;` nor `&` nor backtick nor
1695 // `*` / `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` / `"`,
1696 // and the value's last byte isn't `/`. The resolver folds the value
1697 // through `Path::new(caminho).join(<file>)` looking for a literal
1698 // subdirectory named `../caixa-teia # legacy sibling` and fails at
1699 // resolve time with a non-self-locating `No such file or directory`
1700 // error far from the source caixa.lisp — while every downstream
1701 // shell / YAML / URL parser silently truncates the value at the `#`
1702 // byte to `../caixa-teia`, so a `feira tofu` shell-out to a
1703 // `cd '{caminho}'` command line and a `nix flake check` invocation on
1704 // an emitted YAML `path:` scalar disagree with the resolver on which
1705 // directory the value names. Two workstations whose downstream
1706 // shell / YAML / URL parsing layers differ in unquoted-`#`
1707 // recognition emit divergent build artifacts for the byte-identical
1708 // caixa.lisp value.
1709 //
1710 // The lacre pipeline embeds the value verbatim in its per-dep
1711 // content-address (`conteudo: format!("path:{caminho}")`,
1712 // caixa-resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1713 // closure and rides downstream as part of the build's identity into
1714 // every shell-spawned subprocess (the caixa-resolver's `git clone`
1715 // invocation, a future `feira tofu` shell-out, a future operator-side
1716 // `nix flake check` spawn) as the canonical shell-metachar /
1717 // comment-lead / URL-fragment-delimiter surface every peer
1718 // single-token-shaped typed slot already closes. The peer `:fonte
1719 // :repo` axis closes the byte under the URL-fragment-identifier
1720 // banner (a68f818 `#` on `is_git_repo_url`); the `:caminho` axis was
1721 // the last typed path-string surface still admitting the byte. This
1722 // arm closes the gap so the substrate-wide "no shell-composition
1723 // metacharacter / comment-lead / URL-fragment-delimiter anywhere in a
1724 // typed string slot that flows verbatim into a shell-spawned
1725 // subprocess or downstream YAML / URL parser" invariant extends from
1726 // shell-quote-grouping (`'` / `"`) to shell-comment / URL-fragment
1727 // (`#`) on the `:caminho` axis. Together with the peer JSON / YAML /
1728 // TOML string-literal delimiters the d14cbc5 quote-grouping arm
1729 // closes and the 598b770 `{` / `}` brace-expansion arm closes on the
1730 // templating-engine-placeholder boundary, the typed `:caminho`
1731 // accepted set now structurally excludes the entire
1732 // paste-with-trailing-annotation / paste-from-URL-permalink /
1733 // paste-from-YAML-comment cross-idiom-leak surface that would
1734 // silently round-trip through any downstream shell / YAML / URL /
1735 // dotenv / gitconfig / HCL parsing layer to a different value than
1736 // the resolver's `Path::join` sees.
1737 //
1738 // The arm fires AFTER the shell-quote-grouping arm because the prior
1739 // arm's `'` / `"` shape is the more semantic-locating axis on values
1740 // that probe as both (`"../'x'#pin"` carries both `'` and `#` — the
1741 // shell-string-literal-delimiter is the load-bearing root-cause edit,
1742 // so `FonteCaminhoShellQuoteGrouping` wins; same cascade discipline
1743 // every prior `:caminho` arm establishes). The arm fires BEFORE the
1744 // trailing-`/` arm because the embedded comment-lead / fragment-
1745 // delimiter byte is the more semantic-locating axis on probe-as-both
1746 // values (`"../caixa-teia#pin/"` ends in `/` but the load-bearing
1747 // diagnostic is the embedded `#` — the trailing `/` is the secondary
1748 // observation, and an author who removes the `#pin` fragment is
1749 // likely to also tab-strip the trailing separator).
1750 for &b in caminho.as_bytes() {
1751 if b == b'#' {
1752 return Err(DepError::fonte_caminho_shell_comment(nome, caminho, b));
1753 }
1754 }
1755 // Reproducibility gate's URL-percent-encoding-escape arm. The 6622063
1756 // shell-comment arm closes the `#` URL-fragment-identifier byte; `%`
1757 // (`0x25`) is the orthogonal RFC 3986 §2.1 URL percent-encoding-escape
1758 // byte — the mandatory encoding mechanism for every byte outside the
1759 // `unreserved` alphanumeric / `-` / `.` / `_` / `~` set, and `%`
1760 // itself must be percent-encoded as `%25` to appear literally inside
1761 // a URL value. The byte carries three distinct render-determinism
1762 // hazards on the `:caminho` axis, no prior arm has covered it, and
1763 // the peer `:fonte :repo` axis (a323db8 `%` on `is_git_repo_url`)
1764 // already closes the same byte under the same URL-percent-encoding
1765 // banner — the `:caminho` axis was the last typed path-string surface
1766 // still admitting the byte.
1767 //
1768 // First, the paste-from-browser-address-bar percent-encoded-space
1769 // footgun: an author copies `../caixa%20teia` out of a URL-encoded
1770 // README hyperlink / a browser address bar / a percent-encoded
1771 // permalink expecting `%20` to decode to a literal space at the
1772 // filesystem layer. POSIX `std::path::Path` treats the byte as a
1773 // literal path-component byte, so `Path::join` looks for a literal
1774 // `./../caixa%20teia` subdirectory and fails at resolve time with a
1775 // non-self-locating `No such file or directory` error far from the
1776 // source caixa.lisp — while the author's mental model was
1777 // `../caixa teia`, the decoded shape. Two authors whose only
1778 // difference is percent-encoding presence resolve to two distinct
1779 // BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`)
1780 // for what they intended as the byte-identical sibling-workspace
1781 // dep. The lacre pipeline embeds the value verbatim in its per-dep
1782 // content-address (`conteudo: format!("path:{caminho}")`,
1783 // caixa-resolver/src/resolve.rs:189), so the divergence rides
1784 // downstream into the BLAKE3 closure and locks the substrate's
1785 // "the lacre is the build's identity" contract (CAIXA-SDLC §III.2)
1786 // to the wrong encoding — the same THEORY.md §V.2 render-
1787 // determinism vector every prior `:caminho` arm protects.
1788 //
1789 // Second, the printf-format-specifier lead footgun: `%` is the C /
1790 // POSIX printf format-directive lead-in (`%s`, `%d`, `%02x`, the
1791 // canonical `printf "path=%s\n" ../caixa-teia` invocation every
1792 // shell-diagnostic one-liner carries) and the printf builtin is
1793 // wired into every POSIX shell (bash / zsh / dash / ksh / busybox
1794 // ash) as the format-string lead. A `:caminho "../caixa-%s-teia"`
1795 // value flowing into any future `feira` verb that shells out with a
1796 // printf-formatted path template silently gets reinterpreted as a
1797 // format-directive rather than a literal byte — the canonical
1798 // CWE-134 format-string-injection vector.
1799 //
1800 // Third, the bash-job-control-specifier lead footgun: bash / zsh /
1801 // ksh reserve `%N` at word-start as the job-control specifier —
1802 // `%1` names "job 1", `%%` names "the current job", `%foo` names
1803 // "the most recent job whose command started with `foo`". A future
1804 // `feira` verb that invokes `kill %1` on a caminho-scoped
1805 // subprocess would silently redirect the signal to a wrong target.
1806 //
1807 // Beyond the three shell-side hazards, `%` is a first-class parser
1808 // byte in three cross-config-DSL layers the substrate's paste-idiom
1809 // surface routinely crosses: YAML 1.2 §6.8.1 lexes `%` at
1810 // line-start as the directive lead (`%YAML 1.2` / `%TAG` — a
1811 // `:caminho "%YAML/1.2/../caixa-teia"` paste from a top-of-doc
1812 // YAML directive block silently trips the YAML directive parser on
1813 // any downstream emitted YAML manifest); Prometheus / Grafana
1814 // template syntax uses `%(var)s` as the substitution lead; and Nix
1815 // interpolation uses `${var}` (not `%`) but Envsubst /
1816 // Kubernetes / OpenShift template layers use `%VAR%` as the
1817 // Windows-shell env-var-reference lead — the paste-from-`.bat` /
1818 // paste-from-PowerShell-`%env:PATH%` cross-idiom leak.
1819 //
1820 // The three malformed-`%HH` classes documented on the peer
1821 // `is_git_repo_url` `%` arm (a323db8) apply here too:
1822 //
1823 // - The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
1824 // where `%` isn't followed by two hex digits) — every WHATWG-
1825 // conformant URL parser rejects the value at parse time per
1826 // RFC 3986 §2.1, but the byte rides into the lacre before
1827 // the resolver subprocess crosses the URL-parser boundary.
1828 // - The over-encoded path-separator shape (`"../caixa%2Fteia"`
1829 // intending the `%2F` as the URL encoding of `/`) locks a
1830 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
1831 // the byte-identical `path:../caixa/teia` form.
1832 // - The double-encoded shape (`"../caixa%2520teia"` — the `%25`
1833 // already itself an encoded `%`, so the intent was likely a
1834 // literal `%20` that survived one round-trip through a
1835 // URL-encoder that shouldn't have run) locks a triply-
1836 // divergent closure across the encoded / once-decoded /
1837 // twice-decoded chain.
1838 //
1839 // POSIX `std::path::Path` treats the byte as a literal path-
1840 // component byte, so a `:caminho "../caixa%20teia"` (the canonical
1841 // paste-from-browser-address-bar percent-encoded-space footgun),
1842 // `:caminho "%YAML/../caixa-teia"` (the symmetric paste-from-YAML-
1843 // directive-block cross-idiom leak), or `:caminho
1844 // "../caixa-%s-teia"` (the printf-format-specifier paste-from-
1845 // shell-diagnostic-one-liner shape) silently passes every prior arm
1846 // because `Path::is_absolute` returns false on `..`, `%` is neither
1847 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
1848 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
1849 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`, and the
1850 // value's last byte isn't `/`. The resolver folds the value through
1851 // `Path::new(caminho).join(<file>)` looking for a literal
1852 // subdirectory named `../caixa%20teia` and fails at resolve time
1853 // with a non-self-locating `No such file or directory` error far
1854 // from the source caixa.lisp — while every downstream URL parser /
1855 // shell printf builtin / YAML directive parser silently
1856 // reinterprets the byte to a different value than the resolver's
1857 // `Path::join` sees. Two workstations whose downstream URL / shell
1858 // / YAML layers differ in `%HH` recognition emit divergent build
1859 // artifacts for the byte-identical caixa.lisp value.
1860 //
1861 // The lacre pipeline embeds the value verbatim in its per-dep
1862 // content-address (`conteudo: format!("path:{caminho}")`, caixa-
1863 // resolver/src/resolve.rs:189), so the byte lands in the BLAKE3
1864 // closure and rides into every shell-spawned subprocess (the
1865 // resolver's `git clone`, a future `feira tofu` shell-out, a
1866 // future operator-side `nix flake check` spawn) as the canonical
1867 // URL-percent-encoding-escape / printf-format-specifier / bash-
1868 // job-control-specifier surface every peer single-token-shaped
1869 // typed slot already closes. This arm closes the gap so the
1870 // substrate-wide "no URL-percent-encoding-escape / printf-format-
1871 // specifier / job-control-specifier / YAML-directive-lead byte
1872 // anywhere in a typed string slot that flows verbatim into a
1873 // shell-spawned subprocess or downstream URL / printf / YAML
1874 // parser" invariant extends from shell-comment / URL-fragment
1875 // (`#` — 6622063) to URL-percent-encoding-escape (`%`) on the
1876 // `:caminho` axis.
1877 //
1878 // The arm fires AFTER the shell-comment arm because the prior
1879 // arm's `#` shape is the more semantic-locating axis on values
1880 // that probe as both (`"../caixa%20teia#pin"` carries both `%`
1881 // and `#` — the URL-fragment-identifier is the load-bearing
1882 // downstream-truncation edit, so `FonteCaminhoShellComment` wins;
1883 // same cascade discipline every prior `:caminho` arm establishes).
1884 // The arm fires BEFORE the trailing-`/` arm because the embedded
1885 // percent-encoding-escape byte is the more semantic-locating axis
1886 // on probe-as-both values (`"../caixa%20teia/"` ends in `/` but
1887 // the load-bearing diagnostic is the embedded `%` percent-
1888 // encoding-escape — the trailing `/` is the secondary observation,
1889 // and an author who decodes the `%20` to a literal space is
1890 // likely to also tab-strip the trailing separator).
1891 for &b in caminho.as_bytes() {
1892 if b == b'%' {
1893 return Err(DepError::fonte_caminho_url_percent_encoding(
1894 nome, caminho, b,
1895 ));
1896 }
1897 }
1898 // Reproducibility gate's embedded-`$` shell-variable-expansion /
1899 // command-substitution / arithmetic-expansion arm. The f4efe9c
1900 // leading-`$` arm at line 540 routes `caminho.starts_with('$')`
1901 // through `FonteCaminhoVarExpansion` under the leading-byte-
1902 // sentinel host-layout-leak banner (peer with the b94fd83
1903 // absolute / a5c248e tilde leading-byte arms), but the arm
1904 // fires only at position 0 — a `:caminho "../foo$HOME/bar"`
1905 // (embedded `$HOME` in a nested path segment — the canonical
1906 // paste-from-`ls ../foo$HOME/bar`-shell-one-liner footgun where
1907 // an author copies a partially-substituted shell one-liner and
1908 // the leading segment is a literal `../foo` while the mid
1909 // segment carries the un-substituted `$HOME` template), a
1910 // `:caminho "../foo${WORKSPACE}/bar"` (the symmetric braced-CI-
1911 // manifest paste-from-`.gitlab-ci.yml` / paste-from-GitHub-
1912 // Actions-workflow shape), a `:caminho "../foo$(whoami)/bar"`
1913 // (the paste-from-shell-prompt command-substitution idiom), or
1914 // a `:caminho "../foo$((1+2))/bar"` (the arithmetic-expansion
1915 // idiom) silently passes every prior arm because
1916 // `Path::is_absolute` returns false on `..`, `$` is neither a
1917 // leading-byte sentinel (the f4efe9c arm fires only at position
1918 // 0) nor a control byte nor `\` nor `<` / `>` nor `|` nor `;`
1919 // nor `&` nor backtick nor `*` / `?` nor `(` / `)` nor `{` /
1920 // `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%`, and the
1921 // value's last byte isn't `/`. Note that `$(...)` command-
1922 // substitution and `$((...))` arithmetic-expansion each carry
1923 // an embedded `(` byte that the 0633c91 shell-subshell-grouping
1924 // arm catches structurally at the earlier `(` position — but
1925 // an author who reaches for the sh-brace-substitution
1926 // `${VAR}` or the bare `$VAR` shape carries only the `$` byte,
1927 // which no prior arm covers. This arm closes the last
1928 // positional gap on the `$` byte on the `:caminho` axis so
1929 // every position — leading (`FonteCaminhoVarExpansion`) and
1930 // embedded (`FonteCaminhoShellVariableExpansion`) — is
1931 // structurally rejected.
1932 //
1933 // Every POSIX shell (sh / bash / zsh / dash / ksh / busybox
1934 // ash / fish / nushell) lexes `$` as the variable-expansion /
1935 // command-substitution / arithmetic-expansion operator per
1936 // POSIX.1-2017 §2.6 (Word Expansions): `$<name>` (Parameter
1937 // Expansion) expands a named variable, `${<name>}` (Parameter
1938 // Expansion braced form) does the same with an explicit token
1939 // boundary, `$(<cmd>)` (Command Substitution modern form,
1940 // `` `<cmd>` `` legacy form which the c370458 backtick arm
1941 // already closes) runs a subshell and substitutes its stdout,
1942 // and `$((<expr>))` (Arithmetic Expansion) evaluates an
1943 // arithmetic expression. Every form is a host-layout /
1944 // environment-state / shell-subprocess-side-effect leak when
1945 // the byte lands in a value the resolver passes to a shell-
1946 // spawned subprocess. Beyond the POSIX shell layer, `$` is
1947 // the Nix `${var}` string-interpolation lead (the paste-from-
1948 // `flake.nix` / paste-from-`.nix`-attribute cross-idiom leak
1949 // where an author copies `"${pkgs.hello}/bin/hello"` out of a
1950 // nix expression), the Make `$(var)` / `$@` / `$<` automatic-
1951 // variable lead (the paste-from-`Makefile` shape), the
1952 // JavaScript / TypeScript template-literal `${expr}` interp
1953 // lead (the paste-from-JS-template-string idiom in a
1954 // multi-lang-monorepo where a `path` attribute gets copied out
1955 // of a `package.json` script or a Vite config), the envsubst /
1956 // Kubernetes / OpenShift template `${VAR}` interp lead (the
1957 // paste-from-Helm-values / paste-from-K8s-manifest cross-idiom
1958 // leak), the PHP variable lead (`$_GET`, `$_ENV` — the paste-
1959 // from-`.php`-config footgun), the Perl scalar-variable lead
1960 // (`$foo`), the SASS / SCSS variable lead (`$primary-color`),
1961 // and the SQL bind-parameter lead in PostgreSQL / SQLite
1962 // (`$1`, `$2` — the paste-from-`.sql`-migration idiom). The
1963 // cross-idiom paste-footgun surface is broader than any single
1964 // shell layer — `$` is a first-class parser byte in nearly
1965 // every config / templating / build-system DSL the substrate's
1966 // paste-idiom surface routinely crosses. The peer `:fonte
1967 // :repo` axis closes the byte under the shell-variable-
1968 // expansion / URL-sub-delim banner (b9d187c `$` on
1969 // `is_git_repo_url`), the peer `:fonte :tag` / `:fonte :branch`
1970 // axes close `$` as part of `is_git_ref_name`'s printable-
1971 // ASCII-restricted grammar (`git check-ref-format` rejects the
1972 // byte outright), and the peer `:entrada :paths` axis closes
1973 // `$` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-
1974 // reserved set. The `:caminho` axis was the last typed path-
1975 // string surface still admitting `$` at positions other than 0.
1976 //
1977 // POSIX `std::path::Path` treats `$` as a literal path-
1978 // component byte, so `:caminho "../foo$HOME/bar"` silently
1979 // routes through `Path::new(caminho).join(<file>)` looking for
1980 // a literal `./{caminho}` subdirectory that fails at resolve
1981 // time with a non-self-locating `No such file or directory`
1982 // error far from the source caixa.lisp. But every downstream
1983 // shell / envsubst / Nix / Make / K8s-template parser silently
1984 // reinterprets the byte to a different value than the
1985 // resolver's `Path::join` sees — so a `feira tofu` shell-out
1986 // to a `cd '{caminho}'` command line, a `nix flake check`
1987 // invocation on an emitted YAML `path:` scalar folded through
1988 // envsubst, or a `helm template` invocation with a
1989 // `values.yaml` `path: {caminho}` embedded in a `{{`-quoted
1990 // template all disagree with the resolver on which directory
1991 // the value names. Two workstations whose downstream shell /
1992 // envsubst / Nix / Make / K8s-template parsing layers differ
1993 // in `$VAR` recognition (or, worse, expand the byte against
1994 // divergent environments — Alice's `$HOME=/home/alice`, Bob's
1995 // `$HOME=/home/bob`) emit divergent build artifacts for the
1996 // byte-identical caixa.lisp value. Even in the case where the
1997 // resolver strictly does NOT expand `$VAR` (the current
1998 // implementation) the divergence still bites at the lacre-
1999 // identity axis: the lacre pipeline embeds the value verbatim
2000 // in its per-dep content-address (`conteudo:
2001 // format!("path:{caminho}")`, caixa-resolver/src/resolve.rs:189),
2002 // so `path:../foo$HOME/bar` locks a BLAKE3 closure distinct
2003 // from the byte-identical-semantic `path:../foo/home/alice/bar`
2004 // one author would have produced by substituting the literal
2005 // value at author time, defeating the THEORY.md §V.2 render-
2006 // determinism contract on the same axis every prior `:caminho`
2007 // arm protects.
2008 //
2009 // Beyond the render-determinism / host-layout-leak vectors,
2010 // `$` at any position in a value flowing verbatim into a
2011 // shell-spawned subprocess is the canonical CWE-78 shell-
2012 // command-injection surface every peer single-token-shaped
2013 // typed slot already closes. A `:caminho "../foo$(whoami)/bar"`
2014 // that rides into a future `feira tofu` shell-out as `cd
2015 // '../foo$(whoami)/bar'` gets substituted by the shell at
2016 // subprocess-argument-expansion time even inside single quotes
2017 // in fewer positions than one might expect (the substitution
2018 // fires only outside single-quoting per POSIX §2.2.2, but
2019 // eval-style wrappers and `sh -c` layers that route the value
2020 // through re-parsing round-trip the substitution — the same
2021 // vector the c370458 backtick arm closes at the sibling
2022 // command-substitution-legacy-form surface). Every future
2023 // `feira` verb that shells out with a `caminho`-formatted
2024 // subprocess argument silently inherits this substitution
2025 // vector unless the typed slot's accepted set structurally
2026 // excludes the byte.
2027 //
2028 // Frontier inspiration: OTP's `gen_server` return-value grammar
2029 // rejects mid-tuple shell-metachar bytes by construction —
2030 // `{noreply, State}` never carries a raw `$` because the
2031 // Erlang term type system has no notion of "string that gets
2032 // shelled out"; caixa's typed slots inherit the same
2033 // structural discipline (types-are-theorems, the compounding
2034 // mandate's leverage-point-1) by refusing values that would
2035 // silently reinterpret at any downstream layer. Peer with
2036 // Unison's content-addressed code (no ambient environment —
2037 // every reference is a hash, no `$VAR` substitution possible)
2038 // and Pony's capabilities (a path capability that carries a
2039 // `$` would be ill-typed at the reference layer).
2040 //
2041 // The arm fires AFTER the URL-percent-encoding-escape arm (the
2042 // e3558fa `%` arm) because a value carrying both `%` and `$`
2043 // (`"../foo%20$HOME/bar"` — the canonical "I pasted a percent-
2044 // encoded space next to a `$HOME` template") surfaces the
2045 // narrower URL-encoding diagnostic first — the paste-from-
2046 // browser-address-bar shape is the load-bearing self-locating
2047 // edit on every probe-as-both value; same cascade discipline
2048 // every prior `:caminho` arm establishes (a323db8 % before
2049 // this arm, this arm before trailing-`/`). The arm fires
2050 // BEFORE the trailing-`/` arm because the embedded shell-
2051 // variable-expansion byte is the more semantic-locating axis
2052 // on probe-as-both values (`"../foo$HOME/bar/"` ends in `/`
2053 // but the load-bearing diagnostic is the embedded `$` — the
2054 // trailing `/` is the secondary observation, and an author
2055 // who substitutes the `$HOME` template with a literal value is
2056 // likely to also tab-strip the trailing separator).
2057 for &b in caminho.as_bytes() {
2058 if b == b'$' {
2059 return Err(DepError::fonte_caminho_shell_variable_expansion(
2060 nome, caminho, b,
2061 ));
2062 }
2063 }
2064 // Reproducibility gate's shell-history-expansion / RFC-3986-sub-delims
2065 // arm. The immediate-predecessor `$` embedded arm closes the shell-
2066 // variable-expansion / command-substitution byte; `!` (`0x21`) is the
2067 // orthogonal POSIX shell-history-expansion sentinel every interactive
2068 // shell with history enabled (bash / ksh / zsh's `bashcompat` /
2069 // csh / tcsh) lexes as the history-expansion prefix: `!command`
2070 // re-runs the most recent history entry beginning with `command`,
2071 // `!!` re-runs the prior command verbatim, `!$` substitutes the
2072 // last word of the prior command, `!:N` substitutes the Nth word,
2073 // `^old^new` rewrites the prior command's `old` to `new` (the
2074 // canonical set of `set -o histexpand` operators bash's default
2075 // interactive session enables). Beyond the shell-history layer,
2076 // RFC 3986 §2.2 lists `!` in the `sub-delims` set (the URL grammar
2077 // admits the byte inside a path segment, but every WHATWG-conformant
2078 // special-scheme URL parser percent-encodes it inside a query
2079 // component via the 'special-query percent-encode set' the peer
2080 // `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte
2081 // is also the C / C++ / Rust / JavaScript / Python bang-operator
2082 // (logical-negation prefix — the paste-from-source-code idiom where
2083 // an author copies `!path.exists()` out of a Rust snippet and the
2084 // trailing punctuation crosses the string-literal boundary); the
2085 // canonical English-typography emphasis / exclamation mark (the
2086 // paste-from-prose enthusiasm-form idiom where an author writes
2087 // `:caminho "../caixa-teia!"` expecting the substrate to coerce it
2088 // to a kebab-case slug); and the Nix flake-ref import-attribute
2089 // `import ./foo.nix { … }` sibling operator surface.
2090 //
2091 // POSIX `std::path::Path` treats `!` as a literal path-component
2092 // byte, so a `:caminho "../caixa-teia!sudo"` (the canonical paste-
2093 // from-shell-history footgun where the author copies a `cd
2094 // ../caixa-teia && !sudo make install` one-liner from a quick-
2095 // start README and the trailing `!sudo` rides in verbatim as a
2096 // history-expansion reference), a `:caminho "../foo!!/bar"` (the
2097 // `!!` repeat-prior-command paste idiom), a `:caminho
2098 // "../caixa-teia!"` (the English-typography enthusiasm-form
2099 // paste-from-prose footgun), or a `:caminho "../foo!$"` (the
2100 // last-word-substitution shape) silently pass every prior arm
2101 // because `Path::is_absolute` returns false on `..`, `!` is neither
2102 // a leading-byte sentinel nor a control byte nor `\` nor `<` / `>`
2103 // nor `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` / `)`
2104 // nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#` nor `%` nor `$`,
2105 // and the value's last byte isn't `/`. The resolver folds the value
2106 // through `Path::new(caminho).join(<file>)` looking for a literal
2107 // `./../caixa-teia!sudo` subdirectory and fails at resolve time
2108 // with a non-self-locating `No such file or directory` error far
2109 // from the source caixa.lisp — while every downstream interactive
2110 // shell with `set -o histexpand` reinterprets the byte as the
2111 // history-expansion prefix, and the failure mode forks per
2112 // consumer: a `feira tofu` shell-out to a `cd '{caminho}'` command
2113 // line executed under `bash -i` (the operator-notebook interactive
2114 // shell) substitutes the `!sudo` reference to the most recent
2115 // history entry starting with `sudo`, silently invoking whatever
2116 // privileged command that entry named.
2117 //
2118 // The lacre pipeline embeds the value verbatim in its per-dep
2119 // content-address (`conteudo: format!("path:{caminho}")`,
2120 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2121 // BLAKE3 closure and rides into every shell-spawned subprocess
2122 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2123 // a future operator-side `nix flake check` spawn) as the
2124 // canonical shell-history-expansion / RFC-3986-sub-delims surface
2125 // every peer single-token-shaped typed slot already closes. The
2126 // peer `:fonte :repo` axis closes the byte under the same shell-
2127 // history-expansion / RFC-3986-sub-delims banner (7d53c68 `!` on
2128 // `is_git_repo_url`); the `:caminho` axis was the last typed
2129 // path-string surface still admitting the byte. This arm closes
2130 // the gap so the substrate-wide "no shell-composition
2131 // metacharacter / history-expansion sentinel anywhere in a typed
2132 // string slot that flows verbatim into a shell-spawned subprocess"
2133 // invariant extends from shell-variable-expansion (`$`) to shell-
2134 // history-expansion (`!`) on the `:caminho` axis. Together with
2135 // the peer c370458 backtick command-substitution-legacy-form arm
2136 // and the b9d187c-`$`-embedded-variable-expansion arm on the
2137 // sibling `:repo` axis, the typed `:caminho` accepted set now
2138 // structurally excludes every byte the POSIX shell §2.6 Word
2139 // Expansions section, §2.3 Token Recognition step 6, and every
2140 // history-expansion / brace-expansion / pathname-expansion /
2141 // parameter-expansion / command-substitution / arithmetic-
2142 // expansion operator lexes as a first-class parser byte.
2143 //
2144 // Frontier inspiration: Unison's content-addressed code (no
2145 // ambient environment — every reference is a hash, no `!<num>`
2146 // history-index substitution possible; the caixa substrate's
2147 // lacre discipline arrives at the same guarantee by refusing
2148 // bytes at manifest-parse time that would reinterpret against
2149 // ambient shell history state); Pony's capabilities (a path
2150 // capability that carries a `!` would be ill-typed at the
2151 // reference layer).
2152 //
2153 // The arm fires AFTER the shell-variable-expansion arm because a
2154 // value carrying both `$` and `!` (`"../foo$HOME/bar!sudo"` — the
2155 // canonical "I pasted a `$HOME`-templated path adjacent to a
2156 // trailing `!sudo` history-expansion") surfaces the narrower
2157 // shell-variable-expansion diagnostic first — the paste-from-CI-
2158 // manifest-with-`$VAR`-template shape is the load-bearing self-
2159 // locating edit on every probe-as-both value; same cascade
2160 // discipline every prior `:caminho` arm establishes. The arm
2161 // fires BEFORE the trailing-`/` arm because the embedded shell-
2162 // history-expansion byte is the more semantic-locating axis on
2163 // probe-as-both values (`"../foo!sudo/"` ends in `/` but the
2164 // load-bearing diagnostic is the embedded `!` — the trailing `/`
2165 // is the secondary observation, and an author who removes the
2166 // `!sudo` history reference is likely to also tab-strip the
2167 // trailing separator).
2168 for &b in caminho.as_bytes() {
2169 if b == b'!' {
2170 return Err(DepError::fonte_caminho_shell_history_expansion(
2171 nome, caminho, b,
2172 ));
2173 }
2174 }
2175 // Reproducibility gate's shell-history-substitution / RFC-3986-unwise
2176 // / regex-anchor arm. The immediate-predecessor `!` arm closes the
2177 // POSIX `!command` / `!!` / `!$` history-expansion prefix; `^`
2178 // (`0x5E`) is the paired-operator half of the same bash-reference
2179 // §9.3 histexpand feature — the `^old^new^` "quick substitution"
2180 // form (POSIX bash rewrites the prior command's `old` string to
2181 // `new` and re-executes it, the canonical typo-correction one-
2182 // liner idiom `git clone <bad-url>` → `^bad^good` that pastes the
2183 // trailing substitution fragment verbatim into a `:caminho` value
2184 // when the author trims only the leading `git clone` prefix). The
2185 // peer `:fonte :repo` axis closes the byte under the same
2186 // shell-history-substitution / RFC-3986-unwise banner (49e142f `^`
2187 // on `is_git_repo_url`); the `:caminho` axis was the last typed
2188 // path-string surface still admitting the byte after 6a04767
2189 // landed the `!` arm.
2190 //
2191 // Beyond bash history-substitution, `^` carries five distinct
2192 // downstream-reinterpretation surfaces the typed slot's accepted
2193 // set must structurally exclude:
2194 //
2195 // 1. **RFC 3986 §2 'unwise' set** — the four-byte cross-transport
2196 // layer set (`{`, `}`, `|`, `\`) plus `^` every URL parser is
2197 // required to percent-encode-or-refuse at the wire boundary.
2198 // The WHATWG URL spec's 'fragment percent-encode set' maps
2199 // `^` → `%5E` at the query / fragment component transition;
2200 // libcurl silently percent-encodes the byte on the wire, so a
2201 // `:caminho "../foo^bar"` value the resolver's `Path::join`
2202 // sees as a literal `./../foo^bar` subdirectory diverges from
2203 // the byte-transformed `%5E` shape any downstream `feira tofu`
2204 // curl-invocation or artifact-registry-fetch would emit — the
2205 // canonical wire-boundary divergence vector the peer
2206 // `{`, `}`, `|`, `\` `:caminho` arms already close (
2207 // `FonteCaminhoShellBraceExpansion` at 598b770,
2208 // `FonteCaminhoShellPipe` at the pipe arm,
2209 // `FonteCaminhoBackslash` at the backslash arm).
2210 // 2. **Regex character-class negation prefix `[^abc]`** — the
2211 // canonical paste-from-doc-regex-pipeline footgun where an
2212 // author copies a `grep '[^abc]'` idiom from a docs quick-
2213 // listing and the character-class negation byte rides in
2214 // verbatim.
2215 // 3. **Bitwise XOR operator** in C / C++ / Rust / Python /
2216 // JavaScript / Nix / Go — the paste-from-source-code idiom
2217 // where an author copies an `x ^ y`-shaped expression out of
2218 // a source snippet and the operator crosses the string-
2219 // literal boundary.
2220 // 4. **Windows `cmd.exe` escape metacharacter** — the byte
2221 // escapes the next character in a `cmd.exe` batch context (a
2222 // peer of the backslash arm's Windows-separator-leak vector).
2223 // A `:caminho "..^&whoami"` cross-platform paste-from-batch-
2224 // file footgun reinterprets at every `cmd.exe`-spawned
2225 // subprocess (the resolver's future Windows-runner shell-out,
2226 // the operator's WinRM path, a future PowerShell-embedded
2227 // invocation).
2228 // 5. **LaTeX / Markdown / BibTeX superscript operator** — the
2229 // paste-from-typeset-doc footgun where a mathematical
2230 // superscript notation (`x^2` / `M^T`) leaks from prose.
2231 //
2232 // POSIX `std::path::Path` treats `^` as a literal path-component
2233 // byte, so `:caminho "../foo^bar/baz"` (embedded quick-
2234 // substitution), `:caminho "../foo^"` (trailing history-
2235 // substitution-open shape), `:caminho "../[^a-z]/foo"` (regex-
2236 // negation-prefix paste from a grep pipeline; note the `[` / `]`
2237 // arm at 986963b fires first on this shape), or `:caminho
2238 // "../x^y"` (XOR-expression paste-from-source) all silently pass
2239 // every prior arm (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` /
2240 // backtick / `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'`
2241 // / `"` / `#` / `%` / `$` / `!`) and route through
2242 // `Path::new(caminho).join(<file>)` looking for a literal
2243 // `./{caminho}` subdirectory that fails at resolve time with a
2244 // non-self-locating `No such file or directory` error far from
2245 // the source caixa.lisp — while every downstream shell / curl /
2246 // regex / `cmd.exe` layer reinterprets the byte to its own
2247 // semantic.
2248 //
2249 // The lacre pipeline embeds the value verbatim in its per-dep
2250 // content-address (`conteudo: format!("path:{caminho}")`,
2251 // caixa-resolver/src/resolve.rs:189), so the byte lands in the
2252 // BLAKE3 closure and rides into every shell-spawned subprocess
2253 // (the resolver's `git clone`, a future `feira tofu` shell-out,
2254 // a future operator-side `nix flake check` spawn) as the
2255 // canonical shell-history-substitution / RFC-3986-unwise /
2256 // regex-negation surface every peer single-token-shaped typed
2257 // slot already closes. This arm together with the immediate-
2258 // predecessor `!` arm (6a04767) closes the full `set -o
2259 // histexpand` operator surface on the `:caminho` axis — the
2260 // `!command` / `!!` / `!$` prefix form via `!`, the `^old^new^`
2261 // quick-substitution form via `^` — so the substrate-wide "no
2262 // shell-history operator anywhere in a typed string slot that
2263 // flows verbatim into a shell-spawned subprocess" invariant
2264 // extends from the `!` prefix half to the `^` quick-substitution
2265 // half. Every peer bash-history operator now fails at manifest-
2266 // parse time with a self-locating diagnostic naming the offending
2267 // caixa.lisp rather than at resolve-time as a `Path::join`-
2268 // derived `No such file or directory` (harmless but non-self-
2269 // locating) or worse riding into a downstream `bash -i` context
2270 // that reinterprets the byte-pair against ambient history state.
2271 //
2272 // Frontier inspiration: bash reference §9.3 HISTORY EXPANSION
2273 // "Quick substitution. Repeat the previous command, replacing
2274 // string1 with string2." + RFC 3986 §2 'unwise' set
2275 // ("characters that gateways and other transport agents are
2276 // known to sometimes modify") + Pony's capabilities (a path
2277 // capability that carries a `^` would be ill-typed at the
2278 // reference layer, matching the same structural discipline the
2279 // sibling `!` history-expansion arm inherits from Unison's
2280 // content-addressed no-ambient-history discipline).
2281 //
2282 // The arm fires AFTER the shell-history-expansion `!` arm because
2283 // a value carrying both `!` and `^` (`"../foo!sudo^bad^good"` —
2284 // the canonical "I pasted a `!sudo` history-reference next to a
2285 // `^bad^good` quick-substitution") surfaces the narrower prefix-
2286 // form `!` diagnostic first — the `!` form is the load-bearing
2287 // self-locating edit on every probe-as-both value (an author who
2288 // removes the `!sudo` reference is likely to also strip the
2289 // paired `^` substitution fragment); same cascade discipline
2290 // every prior `:caminho` arm establishes. The arm fires BEFORE
2291 // the trailing-`/` arm because the embedded shell-history-
2292 // substitution byte is the more semantic-locating axis on
2293 // probe-as-both values (`"../foo^bar/"` ends in `/` but the
2294 // load-bearing diagnostic is the embedded `^` — the trailing `/`
2295 // is the secondary observation, and an author who removes the
2296 // `^bar` substitution fragment is likely to also tab-strip the
2297 // trailing separator).
2298 for &b in caminho.as_bytes() {
2299 if b == b'^' {
2300 return Err(DepError::fonte_caminho_shell_history_substitution(
2301 nome, caminho, b,
2302 ));
2303 }
2304 }
2305 // Reproducibility gate's trailing-`/` arm. The b94fd83 absolute arm
2306 // closes the leading-`/` host-layout-leak; the embedded-control-byte
2307 // arm closes any byte-in-the-`0x00..=0x1F` / `0x7F` range; the
2308 // backslash arm closes the cross-host-OS-separator vector. The
2309 // trailing-`/` is the orthogonal shell-tab-completion-on-a-directory
2310 // footgun — `Path::join("../caixa-teia")` and
2311 // `Path::join("../caixa-teia/")` resolve to the same directory
2312 // (POSIX path-component-walk treats trailing `/` as a no-op for
2313 // directory targets, which `:caminho` always names — the sibling-
2314 // workspace dep root is structurally a directory). The lacre
2315 // pipeline embeds the value verbatim in its per-dep content-address
2316 // (`conteudo: format!("path:{caminho}")`,
2317 // caixa-resolver/src/resolve.rs:189), so byte-identical caixa
2318 // semantic-meaning yields two distinct BLAKE3 closures depending on
2319 // whether the author shell-tab-completed the path (every interactive
2320 // shell appends `/` on tab-completing a directory, idiomatic in
2321 // bash / zsh / fish / nushell), pasted from `pwd` (which on most
2322 // shells emits without trailing `/`, but `realpath -e -m` on a
2323 // directory with trailing `/` preserves it), or copied a Cargo
2324 // `path = "../caixa-teia/"` entry from cross-substrate documentation
2325 // (Cargo accepts both shapes and folds them the same way). Two
2326 // workstations whose authors differ only in tab-completion habits
2327 // emit byte-divergent lacres for the byte-identical-semantic caixa,
2328 // and the substrate's "the lacre is the build's identity" contract
2329 // (CAIXA-SDLC §III.2) silently breaks far from the source caixa.lisp.
2330 //
2331 // Same THEORY.md §V.2 render-determinism axis every prior `:caminho`
2332 // arm protects, here against the trailing-separator divergence
2333 // vector: every typed slot's accepted set excludes byte-divergent
2334 // values that round-trip to the same downstream semantic. The peer
2335 // path-shaped axes already reject trailing separators on the same
2336 // contract: [`crate::render::is_gateway_api_http_path`] gates
2337 // `:entrada :paths` against any non-canonical normalization, and
2338 // [`crate::render::is_sandboxed_relative_path`] gates the M2 typed
2339 // path-slots (`:behavior :on-*`, `:upgrade-from :state-change
2340 // :script`, `:bibliotecas`, `:exe`, `:servicos`) against shapes
2341 // whose canonical form would re-introduce determinism divergence.
2342 //
2343 // The arm fires last in the cascade because every prior arm carries
2344 // a more self-locating diagnostic on values that probe as both
2345 // (e.g. `:caminho "../foo/\0/"` ends in `/` but the load-bearing
2346 // diagnostic is the NUL byte's POSIX-syscall-rejection — the
2347 // control-char arm wins; `:caminho "/etc/passwd/"` ends in `/` but
2348 // the load-bearing diagnostic is the absolute host-layout-leak —
2349 // the absolute arm wins; `:caminho "..\caixa-teia/"` ends in `/`
2350 // but the load-bearing diagnostic is the Windows-separator cross-
2351 // OS divergence — the backslash arm wins). The arm covers every
2352 // shape where the last byte is `/` regardless of length, including
2353 // the degenerate single-`/` (which the absolute arm catches first)
2354 // and the consecutive-`//` (where every prior arm passes on the
2355 // bytes other than the trailing `/`).
2356 if caminho.as_bytes().last() == Some(&b'/') {
2357 return Err(DepError::fonte_caminho_trailing_slash(nome, caminho));
2358 }
2359 Ok(())
2360 }
2361}
2362
2363impl Dep {
2364 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:nome` scalar
2365 /// accessor every consumer of the dep-graph identity axis keys off —
2366 /// returns the author-declared `:nome` byte-string verbatim as a
2367 /// `&str`, borrowed from the typed slot's own [`String`] storage.
2368 ///
2369 /// The `:deps :nome` / `:deps-dev :nome` slot carries the DNS-1123
2370 /// label that names the target caixa (validated by [`Self::validate`]
2371 /// through the shared [`crate::render::is_dns_1123_label`] predicate,
2372 /// same accept-set the peer caixa-identifier axes carry — top-level
2373 /// [`crate::Caixa::nome`], per-`:membros` [`crate::Membro::nome`],
2374 /// per-`:children` [`crate::supervisor::ChildSpec::nome`]). Every
2375 /// downstream consumer that fans on the dep's name-identity keys off
2376 /// this scalar: the [`crate::Caixa::validate_deps`] per-list
2377 /// [`crate::render::insert_first_seen`] dedup key + the paired
2378 /// [`DepError::DuplicateNome`] carrier the walk raises on collision,
2379 /// the cross-list [`validate_no_self_dep`] parent-name equality gate
2380 /// on both `:deps` and `:deps-dev` traversals, the `caixa-resolver`
2381 /// pipeline's `HashSet<String>` seen-set the closure walker gates
2382 /// requeueing off (`caixa-resolver/src/resolve.rs:55`), the resolver's
2383 /// per-transitive-target requeue path (`resolve.rs:63,66`), the
2384 /// [`crate::DepSource::default_github`]-shaped resolver-side shorthand
2385 /// fill-in that folds `:nome` into the fetched-git-URL (`resolve.rs:147`),
2386 /// every `caixa-resolver` `ResolveError::MissingPath` /
2387 /// `ResolveError::MissingPin` carrier that names the offending dep
2388 /// (`resolve.rs:177,206`), each resolved
2389 /// `caixa-lacre::LacreEntry` `nome:` field the closure hash keys off
2390 /// (`resolve.rs:108,113`), and the peer `feira lock` stub-resolver's
2391 /// `LacreEntry` emitter (`caixa-feira/src/cmd/lock.rs:59,61,64`).
2392 ///
2393 /// Prior to this lift the `.nome` byte-string was read inline at every
2394 /// production site — the [`crate::Caixa::validate_deps`] paired
2395 /// `dep.nome.as_str()` / `dep.nome.clone()` accesses on both `:deps`
2396 /// and `:deps-dev` traversals, the [`validate_no_self_dep`] pair of
2397 /// parent-equality checks, and every caixa-resolver / caixa-feira
2398 /// site enumerated above — open-coded field-accesses that expressed
2399 /// no compile-time link back to the typed slot. A future extension of
2400 /// the `:deps :nome` axis to a richer author surface (a per-scope
2401 /// alias table the resolver folds through the `~/.config/caixa/config.yaml`
2402 /// entry the [`crate::dep::Dep`] docstring already acknowledges, a
2403 /// namespace-qualified rewrite the future M4 lacre-federation layer
2404 /// applies per-cluster, a promotion of the plain [`String`] byte-string
2405 /// to a richer scoped-identifier newtype once cross-registry federation
2406 /// lands) would have had to be threaded through every open-coded copy
2407 /// in lockstep or two consumers would silently disagree on which caixa
2408 /// a given dep resolves to — the [`crate::Caixa::validate_deps`] dedup
2409 /// set treating the name as `"caixa-teia"` while the caixa-resolver
2410 /// closure walker treated it as `"tenant-a/caixa-teia"` would silently
2411 /// split the [`DepError::DuplicateNome`] refusal from the resolver's
2412 /// requeue-suppression seen-set, one build-time diagnostic
2413 /// disagreeing with the run-time closure the substrate's lacre
2414 /// pipeline actually materializes. Lifting the resolution rule to a
2415 /// typed method on the substrate primitive means every downstream
2416 /// consumer of the caixa's per-`:deps` identity surface reaches for
2417 /// exactly one typed dispatch — the resolver's accept-set migrates as
2418 /// a unit on any future axis addition.
2419 ///
2420 /// First accessor on the outer `Dep` type — opens the outer-`Dep`
2421 /// `&str`-return required-scalar projection pattern the sibling
2422 /// per-`Dep` `:versao` future lift folds on. Peer of the sibling
2423 /// per-`:membros` [`crate::Membro::nome`] (4a32abf) /
2424 /// per-`:children` [`crate::supervisor::ChildSpec::nome`] (dfb4a81)
2425 /// / top-level [`crate::Caixa::nome`] (e6b7d97) caixa-identity scalar
2426 /// accessors — same "one typed dispatch on the substrate primitive,
2427 /// thin projections at each consumer" discipline extended onto the
2428 /// third named-caixa-referencing axis (`:deps` / `:deps-dev`), the
2429 /// remaining unlifted caixa-name-referencing accessor family in the
2430 /// substrate. Named `nome()` to match the tatara-lisp author-surface
2431 /// term the field's docstring already reaches for ("Caixa name — must
2432 /// match the target caixa's `:nome`") and the peer caixa-identity
2433 /// accessor family the substrate already carries.
2434 #[must_use]
2435 pub const fn nome(&self) -> &str {
2436 self.nome.as_str()
2437 }
2438
2439 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:versao`
2440 /// Cargo-shaped semver-requirement scalar accessor every consumer of
2441 /// the dep-graph version-pin axis keys off — returns the author-
2442 /// declared `:versao` requirement byte-string verbatim as a `&str`,
2443 /// borrowed from the typed slot's own [`String`] storage.
2444 ///
2445 /// The `:deps :versao` / `:deps-dev :versao` slot carries the
2446 /// Cargo-shaped semver requirement string (`"^0.1"`, `"~0.1.2"`,
2447 /// `"0.1.0"`, `"*"`) the shared [`crate::version::parse_requirement`]
2448 /// entry-point consumes — same accept-set the peer requirement-
2449 /// carrying axes carry (per-`:membros`
2450 /// [`crate::Membro::versao_requirement`], per-`:children`
2451 /// [`crate::supervisor::ChildSpec::versao_requirement`]), validated
2452 /// through the shared
2453 /// [`crate::render::require_valid_versao_requirement`] cascade in
2454 /// [`Self::validate`]. Every downstream consumer that fans on the
2455 /// dep's version-pin keys off this scalar: the [`Self::validate`]
2456 /// `require_valid_versao_requirement` gate + the paired
2457 /// [`DepError::VersaoInvalid`] carrier the cascade raises on
2458 /// requirement-shape rejection, the `feira lock` stub-resolver's
2459 /// `format!("{}@{}", dep.nome(), dep.versao_requirement())`
2460 /// `conteudo` hash-input interpolation and the paired
2461 /// `LacreEntry.versao:` `String`-carry fill (`caixa-feira/src/cmd/lock.rs`),
2462 /// and the peer `feira lock` end-to-end fixture in `caixa-feira/tests/feira_e2e.rs`.
2463 ///
2464 /// Prior to this lift the `.versao` byte-string was read inline at
2465 /// every production site — the [`Self::validate`] paired
2466 /// `&self.versao` requirement-gate reference and `self.versao.clone()`
2467 /// error-body carrier, the `caixa-feira/src/cmd/lock.rs` paired
2468 /// `format!("{}@{}", dep.nome(), dep.versao)` `conteudo` interpolation
2469 /// and `versao: dep.versao.clone()` `LacreEntry` fill, and the
2470 /// `caixa-feira/tests/feira_e2e.rs` end-to-end fixture's pair of the
2471 /// same shapes — open-coded field-accesses that expressed no
2472 /// compile-time link back to the typed slot. A future extension of
2473 /// the `:deps :versao` axis to a richer author surface (a per-scope
2474 /// version-lock overlay the resolver folds through the
2475 /// `~/.config/caixa/config.yaml` entry the [`crate::dep::Dep`]
2476 /// docstring already acknowledges, a per-cluster canary-version
2477 /// overlay per MESH-COMPOSITION §III.2, a promotion of the plain
2478 /// [`String`] requirement to a richer parsed-`VersionReq` newtype
2479 /// once cross-registry federation lands) would have had to be
2480 /// threaded through every open-coded copy in lockstep or two
2481 /// consumers would silently disagree on which release constraint a
2482 /// given dep resolves to — the [`Self::validate`] requirement-gate
2483 /// call reading `"^0.1"` while the `feira lock` stub-resolver's
2484 /// `conteudo` hash-input read `"tenant-a-pin/^0.1"` would silently
2485 /// split the [`DepError::VersaoInvalid`] refusal from the lacre's
2486 /// content-addressed hash the substrate's fetch pipeline actually
2487 /// materializes, one build-time diagnostic disagreeing with the
2488 /// run-time closure. Lifting the resolution rule to a typed method
2489 /// on the substrate primitive means every downstream consumer of
2490 /// the caixa's per-`:deps` version-pin surface reaches for exactly
2491 /// one typed dispatch — the resolver's accept-set migrates as a
2492 /// unit on any future axis addition.
2493 ///
2494 /// Second accessor on the outer `Dep` type — folds on the outer-
2495 /// `Dep` `&str`-return required-scalar projection pattern the
2496 /// sibling per-`Dep` [`Self::nome`] (eba2cde) accessor opened. Peer
2497 /// of the per-`:membros` [`crate::Membro::versao_requirement`]
2498 /// (a40b0e3) / per-`:children`
2499 /// [`crate::supervisor::ChildSpec::versao_requirement`] (7844f4e
2500 /// family) member/child version-pin accessors — the three
2501 /// requirement-carrying axes (`Dep::versao_requirement` on the
2502 /// per-caixa dep-graph edge, `Membro::versao_requirement` on the M3
2503 /// Aplicacao side, `ChildSpec::versao_requirement` on the M2
2504 /// Supervisor side) now share one accessor discipline for the
2505 /// shared substrate concept "another caixa referenced by a
2506 /// Cargo-shaped semver requirement". The pair
2507 /// `(nome(), versao_requirement())` jointly projects the
2508 /// `(nome, versao)` field pair every dep-graph consumer that fans
2509 /// on per-dep identity + version pin keys off. Named
2510 /// `versao_requirement()` rather than `versao()` because the field's
2511 /// storage-side `.versao` label is already the author-surface term
2512 /// (`:versao`); the accessor's name carries the semantic role — the
2513 /// semver *requirement* string the shared
2514 /// [`crate::version::parse_requirement`] entry-point consumes — so a
2515 /// raw field access and a typed dispatch read differently at every
2516 /// consumer site. Matches the peer
2517 /// [`crate::Membro::versao_requirement`] /
2518 /// [`crate::supervisor::ChildSpec::versao_requirement`] naming
2519 /// discipline verbatim.
2520 #[must_use]
2521 pub const fn versao_requirement(&self) -> &str {
2522 self.versao.as_str()
2523 }
2524
2525 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:fonte`
2526 /// Zig-store-model per-dep source-tuple optional-composite-reference
2527 /// accessor every consumer of the dep-graph fetch-source axis keys
2528 /// off — returns the author-declared `:fonte` typed [`DepSource`]
2529 /// verbatim as an `Option<&DepSource>` borrowed from the typed slot's
2530 /// own `Option<DepSource>` storage, with `None` naming the "author
2531 /// omitted `:fonte`" shorthand every resolver-side default-fill
2532 /// (`caixa-feira/src/cmd/lock.rs`'s stub, `caixa-resolver/src/resolve.rs`'s
2533 /// canonical fetcher, per the [`DepSource::default_github`] fallback
2534 /// the [`Dep::fonte`] field docstring already documents) treats as
2535 /// the "resolve through the configured default host / org
2536 /// (`github:<default-org>/<nome>`)" partition.
2537 ///
2538 /// The `:deps :fonte` / `:deps-dev :fonte` slot carries the two-
2539 /// arm typed [`DepSource`] the `Zig-style git-only store model` the
2540 /// enclosing [`Dep`] docstring names — `DepSource::Git { repo, tag,
2541 /// rev, branch }` for the git-clone arm every published caixa
2542 /// resolves through, `DepSource::Path { caminho }` for the dev-only
2543 /// local-filesystem arm every unpublishable in-tree checkout
2544 /// resolves through. Every downstream consumer that fans on the
2545 /// dep's fetch-source keys off this accessor: [`Self::validate`]'s
2546 /// per-`:fonte` [`DepSource::validate`] delegation (which raises
2547 /// the empty-`:repo` / missing-pin / multiple-pin / empty-`:caminho`
2548 /// diagnostics through the [`DepError::Fonte*`] carrier family
2549 /// naming the offending `Dep::nome`), the caixa-crd conversion
2550 /// crate's `dep_into_ref` two-arm projection into the `CaixaSource`
2551 /// `{repo, git_ref}` pair the K8s-CR side consumes
2552 /// (`caixa-crd/src/conversion.rs`), and — through the paired
2553 /// resolver-side default-fill's `Option::unwrap_or_else` — every
2554 /// `caixa-feira` / `caixa-resolver` fetch site that requires a
2555 /// concrete `DepSource` at run time.
2556 ///
2557 /// Prior to this lift the `.fonte` typed slot was read inline at
2558 /// every production site — the [`Self::validate`]
2559 /// `if let Some(ref fonte) = self.fonte` bracket the per-`:fonte`
2560 /// gate delegates through, the caixa-crd `dep_into_ref`
2561 /// `d.fonte.as_ref().and_then(...)` two-arm `CaixaSource` projector,
2562 /// the resolver-side `caixa-feira/src/cmd/lock.rs` / `caixa-resolver/src/resolve.rs`
2563 /// `dep.fonte.clone().unwrap_or_else(...)` default-fill pair — open-
2564 /// coded field-accesses that expressed no compile-time link back to
2565 /// the typed slot. A future extension of the `:deps :fonte` axis
2566 /// to a richer author surface (a per-scope source-override table
2567 /// the resolver folds through the `~/.config/caixa/config.yaml`
2568 /// entry the [`Dep`] docstring already acknowledges, a per-org
2569 /// mirror-fallback list the future M4 lacre-federation resolver
2570 /// consults ahead of the `default_github` fallback, a promotion of
2571 /// the plain `Option<DepSource>` to a richer
2572 /// `{primary, mirrors, integrity}` triple once cross-registry
2573 /// federation lands, a per-dep `sri:sha256-…` integrity slot the
2574 /// M4 lacre gate binds against ahead of the git-fetch) would have
2575 /// had to be threaded through every open-coded copy in lockstep or
2576 /// two consumers would silently disagree on which fetch source a
2577 /// given dep resolves to — the [`Self::validate`] per-`:fonte`
2578 /// gate reading the author-declared source while the caixa-crd
2579 /// projector read a per-scope-override-resolved source would
2580 /// silently split the build-time refusal from the CR the
2581 /// substrate's admission pipeline actually materializes, one
2582 /// build-time diagnostic disagreeing with the run-time closure.
2583 /// Lifting the resolution rule to a typed method on the substrate
2584 /// primitive means every downstream consumer of the caixa's per-
2585 /// `:deps` fetch-source surface reaches for exactly one typed
2586 /// dispatch — the resolver's accept-set migrates as a unit on any
2587 /// future axis addition.
2588 ///
2589 /// First outer-`Dep` `Option<&Composite>`-return composite-reference
2590 /// accessor — opens the outer-`Dep` `Option<&Composite>` composite-
2591 /// reference projection pattern the sibling per-`Dep` `:opcional`
2592 /// (`Option<Copy>` — the plain-bool axis) / `:caracteristicas`
2593 /// (`&[String]` — the feature-flag list) future outer scalar / slice
2594 /// lifts fold on. Peer of the outer-top-level [`crate::Caixa`]
2595 /// `Option<&Composite>` composite-reference sub-family the
2596 /// [`crate::Caixa::limits`] (b2bd9d7) / [`crate::Caixa::behavior`]
2597 /// (35d8b52) / [`crate::Caixa::politicas`] (5d23d29) /
2598 /// [`crate::Caixa::placement`] (4fb8074) / [`crate::Caixa::entrada`]
2599 /// (e4128e4) accessors already close on the outer [`crate::Caixa`]
2600 /// altitude, and of the outer M3 mesh-slot [`crate::AplicacaoSpec`]
2601 /// altitude the sibling [`crate::AplicacaoSpec::entrada`] (d32111c)
2602 /// accessor already carries — extends that "one typed dispatch on
2603 /// the substrate primitive, thin projections at each consumer"
2604 /// discipline onto the third outer typed-slot altitude that carries
2605 /// an `Option<Composite>` axis (`Dep`, the outer per-dep-list-entry
2606 /// slot). Returns `Option<&DepSource>` (not the owning composite by
2607 /// copy or clone) because every downstream consumer of the fonte
2608 /// composite treats it as a read-only per-arm dispatch source — the
2609 /// reference-view is the narrowest borrow that supports every
2610 /// present + roadmapped consumer (per-arm match projection at the
2611 /// caixa-crd `CaixaSource` two-arm emitter, presence-probe early
2612 /// return on the "author-omitted `:fonte` ⇒ resolver-side
2613 /// `default_github` fill applies" partition every resolver
2614 /// consults, `.cloned()`-on-demand for the two resolver-side
2615 /// default-fill call sites that require an owned `DepSource` for
2616 /// `Option::unwrap_or_else`) without cloning the composite through
2617 /// every consumer's fast path. The `Option` half of the return-type
2618 /// preserves the load-bearing "author-omitted `:fonte` ⇒ resolver-
2619 /// side default applies" partition (not a default composite the
2620 /// downstream must reject on emptiness) — the accessor projects the
2621 /// raw `Option<DepSource>` slot's presence bit through the
2622 /// reference-return unchanged. Named `fonte()` to match the storage
2623 /// field's name verbatim and the tatara-lisp author-surface term
2624 /// (`:fonte`) the field's own docstring already carries.
2625 ///
2626 /// Declared `pub const fn` — the body projects through
2627 /// `Option::<DepSource>::as_ref`, const-stable since Rust 1.83 and
2628 /// well within the workspace MSRV, so every downstream `const`-
2629 /// context consumer of the per-`Dep` `:fonte` composite-reference
2630 /// accessor reaches through the same typed dispatch on the
2631 /// substrate primitive at const-eval time as at runtime. The
2632 /// paired [`dep_outer_accessor_family_is_const_fn`][pin] pin
2633 /// (a `const fn <name>_via_const_fn(d: &Dep) -> …` wrapper family
2634 /// that forwards through each lifted accessor) locks the posture
2635 /// load-bearing at caixa-core build time — any future accidental
2636 /// downgrade to non-`const` fails the wrapper with E0015
2637 /// (`cannot call non-const method`), strictly stronger than a
2638 /// runtime `assert!` and side-stepping the destructor-in-const
2639 /// restriction the `Dep` fixture's `String` / `Option<DepSource>`
2640 /// / `Vec<String>` carriers rule out. Peer of the sibling per-
2641 /// `WitContract` pre-projection accessor family's `const`-eval-
2642 /// surface pass (279823b) and of the outer-`Caixa` slice-return
2643 /// accessor family's parallel pass (231a968) — same "one canonical
2644 /// dispatch per axis, `const`-eval posture pinned at the substrate
2645 /// primitive, thin projections at each consumer" discipline
2646 /// extended onto the outer per-dep-list-entry [`Dep`] altitude.
2647 ///
2648 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2649 #[must_use]
2650 pub const fn fonte(&self) -> Option<&DepSource> {
2651 self.fonte.as_ref()
2652 }
2653
2654 /// Substrate-canonical per-`:deps` / `:deps-dev` entry
2655 /// `:caracteristicas` Cargo-shaped feature-toggle-set slice accessor
2656 /// every consumer of the dep-graph feature-flag axis keys off —
2657 /// returns the author-declared `:caracteristicas` feature-name list
2658 /// verbatim as a `&[String]` slice-view over the same backing buffer
2659 /// the raw `self.caracteristicas.as_slice()` field access borrows
2660 /// from. Empty-list-carrying (`:caracteristicas` is a default-empty
2661 /// axis every `Dep` supplies with `Vec::new()` when the author omits
2662 /// the slot; the [`crate::Caixa::from_lisp`] derive folds an omitted
2663 /// `:caracteristicas` through `#[serde(default)]` to `Vec::new()`,
2664 /// so a `Dep` past parse definitionally carries a `Vec<String>` slot
2665 /// — possibly empty — and the returned `&[String]` degenerates to
2666 /// an empty slice on that arm without any silent `None` collapse).
2667 ///
2668 /// The `:deps :caracteristicas` / `:deps-dev :caracteristicas` slot
2669 /// carries the set-shaped feature-toggle list the substrate walks
2670 /// through the [`Self::validate_caracteristicas`] per-entry shape +
2671 /// duplicate cascade — same Cargo `[dependencies.<dep>.features]`
2672 /// accept-set (per-entry Cargo-feature-name grammar via the shared
2673 /// [`crate::render::is_cargo_feature_name`] predicate, cross-entry
2674 /// uniqueness via the shared [`crate::render::insert_first_seen`]
2675 /// walk, empty-first / value-shape-second / duplicate-third
2676 /// precedence via the peer per-axis two-arm cascade discipline every
2677 /// substrate-blessed Vec-keyed-by-name slot already follows).
2678 /// Every downstream consumer that fans on the dep's feature-toggle
2679 /// keys off this accessor: [`Self::validate_caracteristicas`]'s
2680 /// per-entry linear walk that gates each feature-name byte-string
2681 /// through the empty / value-shape / duplicate arms (raising the
2682 /// [`DepError::CaracteristicaEmpty`] / [`DepError::CaracteristicaInvalid`]
2683 /// / [`DepError::CaracteristicaDuplicate`] carrier family naming the
2684 /// offending `Dep::nome`), and every future
2685 /// per-`Caixa`-manifest / caixa-resolver / caixa-crd feature-toggle-
2686 /// facing consumer the CAIXA-SDLC §I roadmap acknowledges (the
2687 /// future caixa-resolver per-dep feature-projection walk that folds
2688 /// the toggle set into the resolved [`crate::Caixa`]'s activated
2689 /// [`crate::render::CARGO_FEATURE_NAME_MAX_LEN`]-bounded feature
2690 /// closure ahead of the lacre hash, the future caixa-crd per-`spec.deps`
2691 /// features slice the K8s-CR admission gate consumes, the future
2692 /// per-cluster feature-overlay the M4 lacre-federation resolver
2693 /// composes ahead of the substrate-wide feature-name accept-set).
2694 ///
2695 /// Prior to this lift the `.caracteristicas` byte-string list was
2696 /// read inline at the [`Self::validate_caracteristicas`] `for c in
2697 /// &self.caracteristicas` walk — the only in-crate consumer of the
2698 /// raw field beyond the per-`Dep` constructor pair
2699 /// ([`Self::simple`] / [`Self::git`]) and the paired serde
2700 /// round-trip / per-test fixture-mutation paths — an open-coded
2701 /// field-access that expressed no compile-time link back to the
2702 /// typed slot. A future extension of the `:caracteristicas` axis to
2703 /// a richer author surface (a per-scope feature-overlay the resolver
2704 /// folds through the `~/.config/caixa/config.yaml` entry the
2705 /// [`Dep`] docstring already acknowledges, a per-cluster feature-
2706 /// activation overlay the future M4 lacre-federation layer applies
2707 /// per-CR, a promotion of the plain `Vec<String>` byte-string list
2708 /// to a richer parsed-feature-set newtype once the Cargo-shaped
2709 /// namespaced-dep `dep/feat` syntax the value-shape gate's
2710 /// docstring anticipates lands) would have had to be threaded
2711 /// through every open-coded copy in lockstep or two consumers
2712 /// would silently disagree on which feature closure a given dep
2713 /// activates — the [`Self::validate_caracteristicas`] gate walking
2714 /// the author-declared list while a downstream caixa-resolver
2715 /// consumer walked a per-scope-override-resolved list would
2716 /// silently split the build-time refusal from the lacre closure
2717 /// the substrate's fetch pipeline actually materializes, one
2718 /// build-time diagnostic disagreeing with the run-time closure.
2719 /// Lifting the resolution rule to a typed method on the substrate
2720 /// primitive means every downstream consumer of the caixa's per-
2721 /// `:deps` feature-toggle surface reaches for exactly one typed
2722 /// dispatch — the resolver's accept-set migrates as a unit on any
2723 /// future axis addition.
2724 ///
2725 /// First outer-`Dep` `&[T]`-return slice accessor — opens the
2726 /// outer-`Dep` `&[String]` slice projection pattern the sibling
2727 /// per-`Dep` `:opcional` (`bool` — the plain-`Copy`-scalar axis)
2728 /// future outer scalar lift folds on and closes the outer-`Dep`
2729 /// slot-family the sibling [`Self::nome`] (eba2cde) /
2730 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2731 /// accessors already open, leaving the `:opcional` `Copy`-scalar arm
2732 /// as the sole remaining unlifted outer-`Dep` slot. Peer of the
2733 /// outer top-level [`crate::Caixa`] `&[String]`-return foreign-code-
2734 /// slot sub-family ([`crate::Caixa::bibliotecas`] 8a36c23,
2735 /// [`crate::Caixa::exe`] 65d9527, [`crate::Caixa::servicos`]
2736 /// 611f78b) and the outer top-level [`crate::Caixa`] universal-axis
2737 /// text-tag family ([`crate::Caixa::autores`] b5d813f,
2738 /// [`crate::Caixa::etiquetas`] 78c7d3c) that already carry the
2739 /// `&[String]` slice-projection discipline on the outer-`Caixa`
2740 /// altitude — extends the "one typed dispatch on the substrate
2741 /// primitive, thin projections at each consumer" discipline onto the
2742 /// outer per-dep-list-entry [`Dep`] altitude's set-shaped byte-
2743 /// string list slot. Returns `&[String]` (not `&Vec<String>`)
2744 /// because every downstream consumer of the feature-toggle list
2745 /// treats it as a read-only sequence — the slice-view is the
2746 /// narrowest borrow that supports every present + roadmapped
2747 /// consumer (`.iter()`, `.len()`, `.is_empty()`) without leaking
2748 /// the backing `Vec`'s grow/push/reserve surface no consumer of
2749 /// the typed view reaches for (the storage-side `Vec` remains
2750 /// reachable through the `pub caracteristicas` field for the
2751 /// mutation-carrying serde round-trip and per-test fixture-mutation
2752 /// paths). Named `caracteristicas()` to match the storage field's
2753 /// name verbatim and the tatara-lisp author-surface term
2754 /// (`:caracteristicas`) the field's own docstring already carries.
2755 ///
2756 /// Declared `pub const fn` — the body projects through
2757 /// `Vec::<String>::as_slice`, const-stable since Rust 1.83 and
2758 /// well within the workspace MSRV, so every downstream `const`-
2759 /// context consumer of the per-`Dep` `:caracteristicas` slice-
2760 /// accessor reaches through the same typed dispatch on the
2761 /// substrate primitive at const-eval time as at runtime. Pinned
2762 /// load-bearing by the paired
2763 /// [`dep_outer_accessor_family_is_const_fn`][pin] wrapper family
2764 /// alongside its sibling [`Self::fonte`] — see [`Self::fonte`] for
2765 /// the full pin-shape rationale.
2766 ///
2767 /// [pin]: tests::dep_outer_accessor_family_is_const_fn
2768 #[must_use]
2769 pub const fn caracteristicas(&self) -> &[String] {
2770 self.caracteristicas.as_slice()
2771 }
2772
2773 /// Substrate-canonical per-`:deps` / `:deps-dev` entry `:opcional`
2774 /// missing-source-tolerance flag scalar accessor every consumer of
2775 /// the dep-graph opt-in-fetch axis keys off — returns the author-
2776 /// declared `:opcional` `bool` verbatim, `Copy`-projected from the
2777 /// typed slot's own `bool` storage (no borrow of `&self` past the
2778 /// call; the `Copy`-return arm matches the peer
2779 /// [`crate::Caixa::max_restarts`] (eba5211) `Option<u32>` `Copy`-
2780 /// projected sibling discipline the outer flat-spread family
2781 /// already carries). Default-`false` (`#[serde(default,
2782 /// skip_serializing_if = "is_false")]` on the storage slot, so a
2783 /// `Dep` past parse definitionally carries a `bool` — `false` when
2784 /// the author omits `:opcional` — and the returned value degenerates
2785 /// to `false` on that arm without any silent `None` collapse).
2786 ///
2787 /// The `:deps :opcional` / `:deps-dev :opcional` slot carries the
2788 /// per-entry "if this dep's `:fonte` cannot be resolved, treat the
2789 /// missing-source arm as a soft-fail rather than a build refusal"
2790 /// bit — the same Cargo-shaped `[dependencies.<dep>.optional = true]`
2791 /// accept-set (an opcional dep whose `:fonte` fails to resolve is
2792 /// dropped from the resolved dep-graph rather than tripping the
2793 /// build-refusal edge that a mandatory `:opcional false` entry
2794 /// would). Every downstream consumer that fans on the dep's
2795 /// missing-source-tolerance keys off this accessor: the future
2796 /// caixa-resolver's per-`:fonte` resolve-fail arm (drop-vs-error
2797 /// dispatch on the opcional bit ahead of the lacre closure
2798 /// materialization), the future caixa-crd per-`spec.deps`
2799 /// `optional` boolean the K8s-CR admission gate consumes on the
2800 /// per-dep partition, and the future feira / caixa-resolver /
2801 /// caixa-crd feature-projection walk that folds the opcional bit
2802 /// into the resolved feature-closure the future M4 lacre-federation
2803 /// layer emits.
2804 ///
2805 /// Prior to this lift the `.opcional` `bool` slot was read inline
2806 /// at the sole in-crate consumer site — the tests-module
2807 /// `registry_dep_is_minimal` fixture's `assert!(!d.opcional)` gate
2808 /// pinning the [`Self::simple`] constructor's default-`false` fill
2809 /// (the only in-crate read of the raw field beyond the per-`Dep`
2810 /// constructor pair [`Self::simple`] / [`Self::git`] and the paired
2811 /// serde round-trip / per-test fixture-mutation paths) — an open-
2812 /// coded field-access that expressed no compile-time link back to
2813 /// the typed slot. A future extension of the `:opcional` axis to a
2814 /// richer author surface (a per-scope opcional-override the resolver
2815 /// folds through the `~/.config/caixa/config.yaml` entry the [`Dep`]
2816 /// docstring already acknowledges, a per-cluster opcional-override
2817 /// the future M4 lacre-federation layer applies per-CR, a promotion
2818 /// of the plain `bool` to a richer `OpcionalPolicy { drop, warn,
2819 /// error }` tri-state once the CAIXA-SDLC §II opcional-policy
2820 /// roadmap lands) would have had to be threaded through every open-
2821 /// coded copy in lockstep or two consumers would silently disagree
2822 /// on which missing-source arm a given dep resolves to — the
2823 /// [`Self::simple`] constructor's default-`false` fill reading
2824 /// verbatim while a downstream caixa-resolver consumer read a per-
2825 /// scope-override-resolved bit would silently split the build-time
2826 /// arm from the lacre closure the substrate's fetch pipeline
2827 /// actually materializes, one build-time diagnostic disagreeing
2828 /// with the run-time closure. Lifting the resolution rule to a
2829 /// typed method on the substrate primitive means every downstream
2830 /// consumer of the caixa's per-`:deps` opcional-tolerance surface
2831 /// reaches for exactly one typed dispatch — the resolver's accept-
2832 /// set migrates as a unit on any future axis addition.
2833 ///
2834 /// Fifth and final outer-`Dep` accessor — closes the outer-`Dep`
2835 /// slot-family the sibling per-`Dep` [`Self::nome`] (eba2cde) /
2836 /// [`Self::versao_requirement`] (05529b1) / [`Self::fonte`] (d65d1bf)
2837 /// / [`Self::caracteristicas`] (9197944) accessors opened, so every
2838 /// outer-`Dep` slot (`:nome`, `:versao`, `:fonte`, `:opcional`,
2839 /// `:caracteristicas`) now routes through exactly one typed
2840 /// dispatch on the substrate primitive. First outer-`Dep`
2841 /// `bool`-return / plain-`Copy`-scalar accessor — opens the
2842 /// outer-`Dep` `Copy`-scalar projection pattern that folds on the
2843 /// peer outer-top-level [`crate::Caixa`] `Option<Copy>`
2844 /// flat-spread sub-family ([`crate::Caixa::max_restarts`] eba5211,
2845 /// [`crate::Caixa::estrategia`] ed04d3c) the outer-`Caixa` altitude
2846 /// already carries — extends the "one typed dispatch on the
2847 /// substrate primitive, thin projections at each consumer"
2848 /// discipline onto the outer per-dep-list-entry [`Dep`] altitude's
2849 /// bool-shaped missing-source-tolerance slot. Returns `bool` by
2850 /// `Copy` (not by `&bool` reference) because `bool` is `Copy` and
2851 /// every downstream consumer treats it as a plain discriminant
2852 /// value — the by-value return is the narrowest return-shape that
2853 /// supports every present + roadmapped consumer (`.then(…)` early
2854 /// return on the resolver-side drop-vs-error partition, direct
2855 /// bool composition with a per-scope-override projector, plain
2856 /// `if dep.opcional() { … }` early return at every future admission
2857 /// gate) without leaking the storage field's `bool`-in-`&self`
2858 /// lifetime the by-value return elides. Marked `pub const fn` so
2859 /// the accessor is `const`-callable — same discipline the peer
2860 /// [`crate::Caixa::max_restarts`] `Option<u32>` `Copy`-return
2861 /// accessor carries. Named `opcional()` to match the storage
2862 /// field's name verbatim and the tatara-lisp author-surface term
2863 /// (`:opcional`) the field's own docstring already carries.
2864 #[must_use]
2865 pub const fn opcional(&self) -> bool {
2866 self.opcional
2867 }
2868
2869 /// Build a minimal registry-sourced dep.
2870 #[must_use]
2871 pub fn simple(nome: impl Into<String>, versao: impl Into<String>) -> Self {
2872 Self {
2873 nome: nome.into(),
2874 versao: versao.into(),
2875 fonte: None,
2876 opcional: false,
2877 caracteristicas: Vec::new(),
2878 }
2879 }
2880
2881 /// Build a Git-sourced dep (tag-based).
2882 #[must_use]
2883 pub fn git(
2884 nome: impl Into<String>,
2885 versao: impl Into<String>,
2886 repo: impl Into<String>,
2887 tag: impl Into<String>,
2888 ) -> Self {
2889 Self {
2890 nome: nome.into(),
2891 versao: versao.into(),
2892 fonte: Some(DepSource::Git {
2893 repo: repo.into(),
2894 tag: Some(tag.into()),
2895 rev: None,
2896 branch: None,
2897 }),
2898 opcional: false,
2899 caracteristicas: Vec::new(),
2900 }
2901 }
2902
2903 /// Reject dependency entries whose `:nome` or `:versao` are empty,
2904 /// whose `:nome` is non-empty but not a valid DNS-1123 label,
2905 /// or whose `:versao` is non-empty but not a valid Cargo-shaped
2906 /// semver requirement.
2907 ///
2908 /// The author surface for `:deps :versao` (and `:deps-dev :versao`)
2909 /// is the same Cargo-shaped requirement string `:membros :versao`
2910 /// (validated at [`crate::AplicacaoSpec::validate`] since 9888b13)
2911 /// and `:children :versao` (validated at
2912 /// [`crate::SupervisorSpec::validate`] since b38ff3a) carry — and
2913 /// the lacre pipeline resolves all three axes through the same
2914 /// [`crate::parse_requirement`] entry-point. Until 2420c44 landed
2915 /// `:deps :versao` was the last `:versao` axis untyped past
2916 /// `Caixa::from_lisp`: a malformed-but-non-empty requirement
2917 /// (`"^bad-version"`, `"^^0.1"`, the canonical git-tag-shape-
2918 /// leaking-into-:versao `"v0.1"` typo, the accidental
2919 /// `"not-a-req"`) silently passed parse and the `semver::Error`
2920 /// surfaced at lacre-resolve time, far from the source
2921 /// caixa.lisp, with no field naming which `:deps` entry carried
2922 /// the typo. The diagnostic [`DepError::VersaoInvalid`] carries
2923 /// the offending entry's `:nome` + the offending `:versao`
2924 /// verbatim + the parser's own wording in `reason`, so the
2925 /// author's grep target is unambiguous.
2926 ///
2927 /// The author surface for `:deps :nome` is the same DNS-1123 label
2928 /// the peer caixa-identifier axes carry — top-level Caixa `:nome`
2929 /// (validated at [`crate::Caixa::validate_nome`] since 6c992f8),
2930 /// `:membros :caixa` (validated at
2931 /// [`crate::AplicacaoSpec::validate_membros`] since 3f9d7a0),
2932 /// `:children :caixa` (validated at
2933 /// [`crate::SupervisorSpec::validate`] since 31bfa43). A `:deps
2934 /// :nome` value flows verbatim through the lacre pipeline as the
2935 /// target caixa's `:nome` (which the gate at the *target* side now
2936 /// rejects if non-DNS-1123) and lands as the rendered caixa's
2937 /// `lareira-<nome>` Helm chart name segment, the per-dep
2938 /// `LABEL_PROGRAM` label value, and the `caixa-resolver`'s
2939 /// `~/.cache/caixa/<org>/<nome>` checkout-directory leaf. Until
2940 /// this gate landed `:deps :nome` was the fourth and last
2941 /// DNS-1123-shaped caixa-identifier axis still untyped past
2942 /// `Caixa::from_lisp`: a syntactically wrong dep name (`"Caixa-
2943 /// Teia"` uppercase — the canonical "I copied the README header"
2944 /// typo; `"caixa_teia"` underscore — the Go module / Python
2945 /// identifier leak; `"caixa-teia."` trailing dot — the FQDN
2946 /// confusion; `"-caixa-teia"` leading hyphen; a 64-byte slug)
2947 /// silently passed parse and surfaced at lacre-resolve time when
2948 /// the resolved target caixa's `:nome` failed *its* DNS-1123 gate
2949 /// — far from the source `:deps` entry, with a diagnostic naming
2950 /// the *target's* `:nome` rather than the dep entry that referenced
2951 /// it. Mirroring the 3f9d7a0 / 31bfa43 / 6c992f8 trajectory through
2952 /// the lifted [`crate::render::is_dns_1123_label`] predicate (the
2953 /// "before its third occurrence" PRIME DIRECTIVE boundary, THEORY.md
2954 /// §I.3.5): every `Dep::nome` past validate is DNS-1123-label-shaped,
2955 /// so every downstream consumer (caixa-resolver's lacre fetch,
2956 /// caixa-helm's `lareira-<nome>` chart name, the future M4 per-dep
2957 /// fan-out emitter) reaches for the name knowing the value is
2958 /// apiserver-valid without re-validating.
2959 ///
2960 /// Empty checks fire first (narrower diagnostic), parse last —
2961 /// same ordering discipline as
2962 /// [`crate::AplicacaoSpec::validate_membros`] and
2963 /// [`crate::SupervisorSpec::validate`]. `parse_requirement("")`
2964 /// returns `Ok(VersionReq::STAR)`, so the empty-`:versao` arm is
2965 /// structurally necessary even with the parse arm in place. The
2966 /// `:nome` shape gate runs after the `:nome` empty gate and before
2967 /// the `:versao` checks so a one-entry caixa.lisp with both wrong
2968 /// sees the name-side diagnostic first (the name is the
2969 /// self-locating axis — without it, the parse diagnostic can't
2970 /// quote `:nome "<bad>"`).
2971 pub fn validate(&self) -> Result<(), DepError> {
2972 if self.nome.is_empty() {
2973 return Err(DepError::NomeEmpty);
2974 }
2975 if let Err(reason) = crate::render::is_dns_1123_label(&self.nome) {
2976 return Err(DepError::nome_invalid(&self.nome, reason));
2977 }
2978 // Delegate the empty-first + `parse_requirement` cascade to the
2979 // shared [`crate::render::require_valid_versao_requirement`]
2980 // helper — same two-arm shape the peer
2981 // [`crate::AplicacaoSpec::validate_membros`] on `:membros
2982 // :versao` and [`crate::SupervisorSpec::validate`] on `:children
2983 // :versao` route through, so drift between the three axes'
2984 // accepted requirement sets is structurally impossible and the
2985 // parse-side no-op the empty-first arm closes (semver's empty
2986 // parse yields an implicit `*`) lives in exactly one predicate.
2987 crate::render::require_valid_versao_requirement(
2988 self.versao_requirement(),
2989 || DepError::versao_empty(&self.nome),
2990 |reason| DepError::versao_invalid(&self.nome, self.versao_requirement(), reason),
2991 )?;
2992 if let Some(fonte) = self.fonte() {
2993 fonte.validate(&self.nome)?;
2994 }
2995 self.validate_caracteristicas()?;
2996 Ok(())
2997 }
2998
2999 /// Reject per-entry `:caracteristicas` (feature-flag) values that
3000 /// are operationally meaningless. The `:caracteristicas` slot is
3001 /// a set of feature toggles to enable on the target caixa — same
3002 /// shape as Cargo's `[dependencies.<dep>.features]` list — and
3003 /// two structural footguns close here:
3004 ///
3005 /// - empty-string entry (`(:caracteristicas (""))`): the future
3006 /// caixa-resolver lacre pipeline would consume the empty
3007 /// identifier as a no-op feature enable, silently dropping the
3008 /// author's intent far from the source `caixa.lisp`;
3009 /// - duplicate entry within one dep (`(:caracteristicas ("http"
3010 /// "http"))`): the feature-toggle slot is set-shaped (enabling
3011 /// a feature twice has no additional semantic — there is no
3012 /// `feature × 2`), so two entries naming the same feature are
3013 /// a silent miscount, the same set-not-multiset distinction
3014 /// every peer Vec-keyed-by-name axis already closes
3015 /// ([`crate::SupervisorError::DuplicateChildCaixa`] on
3016 /// `:children :caixa`, [`crate::AplicacaoError::MembroDuplicate`]
3017 /// on `:membros :caixa`, [`crate::AplicacaoError::ContratoDuplicate`]
3018 /// on `:contratos`, [`crate::AplicacaoError::PlacementClusterDuplicate`]
3019 /// on `:placement :clusters`, [`crate::AplicacaoError::EntradaPathDuplicate`]
3020 /// on `:entrada :paths`, [`crate::UpgradeError::DuplicateFrom`]
3021 /// on `:upgrade-from :from`, [`crate::UpgradeError::DuplicateLoadModule`]
3022 /// / [`crate::UpgradeError::DuplicateStateChange`] /
3023 /// [`crate::UpgradeError::DuplicateCleanup`] on the within-
3024 /// entry `:upgrade-from` axes, and [`DepError::DuplicateNome`]
3025 /// on the cross-entry `:deps`/`:deps-dev` `:nome` axis the
3026 /// immediate-predecessor 359fba5 closed).
3027 ///
3028 /// Same linear-walk + `HashSet` + first-collision diagnostic shape
3029 /// every peer set-not-multiset gate uses; the empty arm fires
3030 /// before the duplicate arm so an entry with both an empty feature
3031 /// *and* a duplicate of some later feature surfaces the empty-
3032 /// shape diagnostic first (the empty-feature axis is the
3033 /// more-actionable defect since the missing-name renders the
3034 /// duplicate-key arm ambiguous: two `""` entries would both report
3035 /// `caracteristica: ""` with no way to distinguish the offending
3036 /// site). Empty-first cascade discipline mirrors every peer per-
3037 /// entry shape + duplicate gate
3038 /// (`SupervisorSpec::validate`'s `EmptyChildName` before
3039 /// `DuplicateChildCaixa`; `validate_membros`'s `MembroCaixaEmpty`
3040 /// before `MembroDuplicate`).
3041 ///
3042 /// The per-entry value-shape gate (Cargo-feature-name grammar via
3043 /// the lifted [`crate::render::is_cargo_feature_name`] predicate)
3044 /// fires between the empty arm and the duplicate arm — the
3045 /// canonical per-entry-shape-before-cross-entry-uniqueness
3046 /// precedence every peer two-arm + value-shape gate establishes
3047 /// ([`crate::SupervisorSpec::validate`]'s `EmptyChildName` →
3048 /// `ChildCaixaInvalid` → `DuplicateChildCaixa`,
3049 /// [`crate::AplicacaoSpec::validate_membros`]'s `MembroCaixaEmpty`
3050 /// → `MembroCaixaInvalid` → `MembroDuplicate`, [`Dep::validate`]'s
3051 /// `NomeEmpty` → `NomeInvalid` → cross-list `DuplicateNome`).
3052 /// Until the value-shape arm landed `:caracteristicas` accepted
3053 /// every non-empty distinct string — a structurally invalid
3054 /// feature name (`"http feature"` whitespace, `"+http"` the
3055 /// canonical paste-from-`+optional-feature` doc activation-form
3056 /// footgun, `"-flag"` leading hyphen, `".feat"` leading dot,
3057 /// `"http/json"` Cargo's `dep/feat` namespaced-dep syntax that
3058 /// only applies inside list-grammar contexts, `"http,json"`
3059 /// list-separator-belongs-to-the-list-grammar miscomprehension,
3060 /// `"café"` un-percent-encoded non-ASCII silently round-tripping
3061 /// inconsistently across NFC/NFD normalization, the 65-byte
3062 /// paste-from-binary slug) silently passed validate and the
3063 /// failure surfaced at `cargo metadata` time as the
3064 /// `restricted_names::validate_feature_name` parser's rejection,
3065 /// far from the source `caixa.lisp`, with no field naming which
3066 /// `:deps` entry's `:caracteristicas` carried the typo. The
3067 /// lifted predicate makes the Cargo-feature-name-grammar
3068 /// intersection-floor a substrate-level invariant at validate
3069 /// time — same trajectory as the eight peer
3070 /// [`crate::render`] value-shape predicates each typed surface
3071 /// downstream of a structured grammar already follows
3072 /// ([`is_dns_1123_label`](crate::render::is_dns_1123_label),
3073 /// [`is_gateway_api_http_path`](crate::render::is_gateway_api_http_path),
3074 /// [`is_wit_world_ref`](crate::render::is_wit_world_ref),
3075 /// [`is_nats_subject`](crate::render::is_nats_subject),
3076 /// [`is_wasi_keyvalue_slot`](crate::render::is_wasi_keyvalue_slot),
3077 /// [`is_git_ref_name`](crate::render::is_git_ref_name),
3078 /// [`is_git_oid`](crate::render::is_git_oid),
3079 /// [`is_git_repo_url`](crate::render::is_git_repo_url)).
3080 fn validate_caracteristicas(&self) -> Result<(), DepError> {
3081 let mut seen = std::collections::HashSet::new();
3082 for c in self.caracteristicas() {
3083 if c.is_empty() {
3084 return Err(DepError::caracteristica_empty(&self.nome));
3085 }
3086 if let Err(reason) = crate::render::is_cargo_feature_name(c) {
3087 return Err(DepError::caracteristica_invalid(&self.nome, c, reason));
3088 }
3089 crate::render::insert_first_seen(&mut seen, c.as_str(), || {
3090 DepError::caracteristica_duplicate(&self.nome, c)
3091 })?;
3092 }
3093 Ok(())
3094 }
3095}
3096
3097/// Cross-slot coherence gate on the dep-graph axis: no `:deps` or
3098/// `:deps-dev` entry may name the caixa's own `:nome`.
3099///
3100/// A caixa that lists itself as a dep is a degenerate self-edge in the
3101/// lacre closure's dep-graph — the closure is a DAG rooted at the
3102/// caixa's `:nome`, and the caixa-resolver's lacre pipeline traverses
3103/// every `:deps` / `:deps-dev` entry's target by name. A self-dep
3104/// hands the resolver a node that is its own parent: a one-node cycle
3105/// it either rejects mid-traversal far from the source `caixa.lisp`
3106/// (the resolver detecting infinite recursion on the closure walk) or,
3107/// worse, recurses on until it exhausts its stack. Because every
3108/// `:nome` is a globally-unique substrate identity (DNS-1123 label +
3109/// lacre closure root), a dep entry whose `:nome` equals the caixa's
3110/// own `:nome` *is* the caixa itself, not a coincidentally-named peer.
3111///
3112/// Lives outside [`Caixa::validate_deps`] because the dep-list view
3113/// carries the entries but not the parent `:nome`; mirrors the
3114/// cross-slot self-edge gates [`crate::supervisor::validate_no_self_supervision`]
3115/// (ad4abf1) on the `:children :caixa` axis and
3116/// [`crate::aplicacao::validate_no_self_membership`] on the
3117/// `:membros :caixa` axis — the same "an edge from a graph node to
3118/// itself is structurally not a tree/graph edge" discipline, here on
3119/// the third typed-name-graph axis (the dep closure; the supervision
3120/// tree and the Aplicacao membership set were the prior two).
3121///
3122/// Walks `:deps` first then `:deps-dev` so the diagnostic for a caixa
3123/// that self-references on both axes surfaces the `:deps` arm first —
3124/// the load-bearing axis the lacre closure resolves at every build,
3125/// peer with the canonical [`Caixa::validate_deps`] walk order
3126/// (`:deps` → `:deps-dev`).
3127///
3128/// Carries the offending list tag (`":deps"` or `":deps-dev"`)
3129/// verbatim into the diagnostic so the author can grep their
3130/// `caixa.lisp` for the offending block in one edit — same
3131/// `list: &'static str` shape [`DepError::DuplicateNome`] (359fba5)
3132/// uses on the cross-list duplicate-name axis.
3133///
3134/// `Code paths` (`:bibliotecas` / `:exe` / `:servicos`) are the
3135/// substrate-blessed shape for referencing the caixa's *own* code, so
3136/// the diagnostic names them as the corrective surface — every
3137/// legitimate "I want to use code from this caixa" authoring intent
3138/// routes through one of those three slots, not a self-dep.
3139pub fn validate_no_self_dep(
3140 deps: &[Dep],
3141 deps_dev: &[Dep],
3142 parent_nome: &str,
3143) -> Result<(), DepError> {
3144 for dep in deps {
3145 if dep.nome() == parent_nome {
3146 return Err(DepError::dep_is_self(
3147 parent_nome,
3148 crate::render::DEP_AUTHOR_KEY_DEPS,
3149 ));
3150 }
3151 }
3152 for dep in deps_dev {
3153 if dep.nome() == parent_nome {
3154 return Err(DepError::dep_is_self(
3155 parent_nome,
3156 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3157 ));
3158 }
3159 }
3160 Ok(())
3161}
3162
3163/// Closed-set typed enum for the two dep-list author-surface axes every
3164/// top-level [`crate::Caixa`] carries — the runtime-closure `:deps` slot
3165/// (`Prod`) and the dev-only-closure `:deps-dev` slot (`Dev`). Every
3166/// substrate consumer that dispatches on "which of the two dep-lists"
3167/// (the `feira add` mutation head, the future per-cluster dev-closure-
3168/// audit overlay the M4 CR materializer resolves per-CR, the future
3169/// `caixa app graph` per-list dep summary, every future
3170/// `Caixa::push_dep` / `Caixa::deps_by_list` typed-method dispatch a
3171/// caller reaches for) reads through this enum rather than through a
3172/// bare `&'static str` — the closed-set is expressed at the type layer,
3173/// so a future third dep-list axis (a `:deps-build` build-only closure
3174/// once the substrate grows cross-artifact heterogeneous dep-graphs,
3175/// per CAIXA-SDLC §I) is one variant plus one arm per method and the
3176/// compiler enforces exhaustiveness on every consumer's `match` arms.
3177///
3178/// The wire byte-string [`Self::as_str`] returns is the same author-
3179/// surface tag the sibling [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3180/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry — the
3181/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] `list:
3182/// &'static str` payload family the substrate already emits routes
3183/// through the same source of truth (an author reading a
3184/// [`DepError::DuplicateNome`] refusal can grep their `caixa.lisp`
3185/// for the offending `:deps` / `:deps-dev` block in one edit whether
3186/// the diagnostic came from a `Caixa::validate_deps` walk or a
3187/// `Caixa::push_dep` mutation).
3188///
3189/// Same "closed-set typed-enum discriminator with canonical
3190/// projections per axis" discipline the sibling closed-set typed enums
3191/// on the caixa typed surface carry
3192/// ([`crate::aplicacao::PlacementStrategy`] cc8f749,
3193/// [`crate::aplicacao::RateLimitUnit`] 6bce03d,
3194/// [`crate::supervisor::RestartStrategy`],
3195/// [`crate::supervisor::RestartPolicy`],
3196/// [`crate::upgrade::UpgradeInstruction`], [`crate::CaixaKind`])
3197/// — extended onto the outer-`Caixa` two-list dep-graph axis, the
3198/// substrate's last unlifted closed-set-shaped `&'static str`-carrying
3199/// axis on the top-level manifest surface.
3200#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, gen_platform::IsVariant)]
3201pub enum DepList {
3202 /// Runtime-closure `:deps` axis — the load-bearing dep-list the
3203 /// lacre closure resolves at every build. Wire-format
3204 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`].
3205 Prod,
3206 /// Dev-only-closure `:deps-dev` axis — Cargo's `[dev-dependencies]`
3207 /// table's dev-time-only visibility contract per CAIXA-SDLC §I.
3208 /// Wire-format [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`].
3209 Dev,
3210}
3211
3212impl DepList {
3213 /// Exhaustive iteration surface for every consumer that reads the
3214 /// full closed-set (the future M4 admission webhook's per-list
3215 /// summary rejection body, any future round-trip pin harness). A
3216 /// future variant addition extends this slice as a single edit and
3217 /// every consumer picks up the new entry by construction — the
3218 /// compiler-checked exhaustiveness on the sibling method `match`
3219 /// arms is the build-time guarantee that no arm forgets to grow.
3220 pub const ALL: &'static [Self] = &[Self::Prod, Self::Dev];
3221
3222 /// Canonical author-surface tag every substrate consumer that
3223 /// names the offending dep-list in a diagnostic reaches for —
3224 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] for [`Self::Prod`] and
3225 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] for [`Self::Dev`],
3226 /// the same `&'static str` payload the sibling
3227 /// [`DepError::DuplicateNome`] and [`DepError::DepIsSelf`] variants
3228 /// already carry. Routing every dep-list diagnostic through the
3229 /// closed-set enum's `as_str` closes the last `&'static str`-shape
3230 /// literal-carry axis on the two-list dep-graph surface — a
3231 /// future kebab-case rebrand (`":deps"` → `":packages"`) or a
3232 /// wire-format promotion (a distinct diagnostic form for the
3233 /// `Dev` arm) reaches every consumer through one edit on the
3234 /// canonical constant, not a coordinated rewrite across the
3235 /// substrate's dep-graph consumers.
3236 #[must_use]
3237 pub const fn as_str(self) -> &'static str {
3238 match self {
3239 Self::Prod => crate::render::DEP_AUTHOR_KEY_DEPS,
3240 Self::Dev => crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
3241 }
3242 }
3243
3244 /// Substrate-canonical reverse projection on the two-list dep-graph
3245 /// axis — parses the author-surface wire tag back to the typed
3246 /// variant, or `None` when `s` is outside the closed-set arm-string
3247 /// set [`Self::as_str`] emits. Dispatches on the same lifted
3248 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3249 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants the
3250 /// [`Self::as_str`] emitter walks, so the parse and emit halves of
3251 /// the round-trip migrate through one caixa-core edit on any future
3252 /// list-axis addition.
3253 ///
3254 /// Prior to this lift the substrate carried only the forward
3255 /// `Self → &str` projection on the two-list dep-graph axis (the
3256 /// [`Self::as_str`] emitter, the [`std::fmt::Display`] impl routed
3257 /// through it, the two [`DepError::DuplicateNome`] /
3258 /// [`DepError::DepIsSelf`] variants that carry the wire tag verbatim
3259 /// as a `&'static str` `list:` field). Every future consumer that
3260 /// wanted to promote the wire tag back to the typed enum (a future
3261 /// `feira dep --list <deps|deps-dev>` CLI arg-parse that binds the
3262 /// wire form into the typed enum before dispatching to
3263 /// [`crate::Caixa::deps_of`] / [`crate::Caixa::push_dep`], the M4
3264 /// `mesh.pleme.io/v1alpha1/Caixa` CR materializer's admission-time
3265 /// wire re-parse of the per-list diagnostic body, a future
3266 /// [`DepError`] widening that promotes the two `list: &'static str`
3267 /// fields to a typed `list: DepList` carry so downstream consumers
3268 /// dispatch on the enum rather than string-comparing the wire
3269 /// scalar) would have had to re-inline a two-arm `match s { ":deps"
3270 /// => …, ":deps-dev" => …, _ => … }` cascade that expressed no
3271 /// compile-time link back to the typed [`DepList`] enum. A future
3272 /// variant addition (a `:build-dep` or `:test-dep` third list once
3273 /// the substrate grows Cargo-style split-graphs, a `:tool-dep` for
3274 /// build-time-only tooling per the peer Cargo `[build-dependencies]`
3275 /// / `[target.<cfg>.dev-dependencies]` future admission surface)
3276 /// would silently split the wire byte-string the emitter walks from
3277 /// the parser's arm-set — the round-trip would carry the new list
3278 /// through the forward projection but land on the fallback silently
3279 /// at every non-updated reverse parser, far from the arm-addition
3280 /// commit that caused the drift. Lifting the resolver to a typed
3281 /// method on the substrate primitive closes the drift footgun by
3282 /// construction: the parser's accept-set is the same set the
3283 /// [`Self::as_str`] emitter walks (routed through the same lifted
3284 /// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3285 /// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts), so both halves
3286 /// of the round-trip migrate through one caixa-core edit on any
3287 /// future list-axis addition.
3288 ///
3289 /// Same closed-set-reverse-projection discipline the sibling
3290 /// [`crate::CaixaKind::from_wire`] (2aa6d23) /
3291 /// [`crate::supervisor::RestartStrategy::from_wire`] (4eec29c) /
3292 /// [`crate::supervisor::RestartPolicy::from_wire`] (dd32ccf) /
3293 /// [`crate::aplicacao::PlacementStrategy::from_wire`] (18c7342) /
3294 /// [`crate::aplicacao::RateLimitUnit::from_suffix`] typed enums
3295 /// carry on the peer wire-side `str → Self` axes — extended onto
3296 /// the two-list dep-graph closed-set axis, the sixth substrate-side
3297 /// closed-set typed enum on the caixa surface to converge on the
3298 /// two-way `str ↔ Self` round-trip. Method-named `from_wire` (not
3299 /// `from_str`) to match the peer shapes verbatim and side-step the
3300 /// derived [`std::str::FromStr`] impls the sibling
3301 /// [`gen_platform::FromStrKind`]-carrying axes install on their
3302 /// kebab-case dispatcher-catalog identity. Returns `Option<Self>`
3303 /// (rather than `Result<Self, _>`) to match the peer shapes: the
3304 /// caller picks the diagnostic form appropriate for its use site —
3305 /// a future `feira dep --list …` arg-parse that surfaces
3306 /// `unknown list: <arg>` at the CLI builds one on top by iterating
3307 /// [`Self::ALL`], while the future M4 admission-webhook's rejection
3308 /// path folds `None` onto its per-CR structured refusal body.
3309 #[must_use]
3310 pub fn from_wire(s: &str) -> Option<Self> {
3311 match s {
3312 crate::render::DEP_AUTHOR_KEY_DEPS => Some(Self::Prod),
3313 crate::render::DEP_AUTHOR_KEY_DEPS_DEV => Some(Self::Dev),
3314 _ => None,
3315 }
3316 }
3317}
3318
3319/// Route [`std::fmt::Display`] through [`DepList::as_str`], so every
3320/// consumer that formats the axis as user-facing text (a future
3321/// `feira app graph` per-list summary, a future M4 admission-webhook
3322/// rejection body naming the offending list, this crate's own
3323/// [`DepError`] `#[error(...)]` templates when they widen to carry a
3324/// typed [`DepList`]) lands on the same author-surface tag the
3325/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3326/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] constants carry. Same
3327/// as-str-through-Display convergence discipline the sibling
3328/// [`crate::aplicacao::PlacementStrategy`],
3329/// [`crate::aplicacao::RateLimitUnit`],
3330/// [`crate::supervisor::RestartStrategy`],
3331/// [`crate::supervisor::RestartPolicy`], and [`crate::CaixaKind`]
3332/// closed-set typed enums carry.
3333impl std::fmt::Display for DepList {
3334 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
3335 f.write_str(self.as_str())
3336 }
3337}
3338
3339/// Substrate-canonical [`AsRef<str>`] projection on the two-list
3340/// dep-graph closed-set typed enum — routes through the same
3341/// [`DepList::as_str`] `pub const fn` scalar accessor the paired
3342/// [`std::fmt::Display`] impl already delegates through, so any future
3343/// consumer that binds a [`DepList`] through the standard-library
3344/// `impl AsRef<str>` bound (a [`std::process::Command::arg`] shell-out
3345/// that composes the canonical author-surface tag into a
3346/// `feira dep --list <deps|deps-dev>` diagnostic overlay, a
3347/// `tracing::field::Value::Str`-arm structured-log recorder on the
3348/// [`DepError::DuplicateNome`] / [`DepError::DepIsSelf`] refusal paths,
3349/// a [`std::collections::HashMap`] lookup keyed on the canonical tag
3350/// through `map.get::<str>(list.as_ref())` on a future M4 admission-
3351/// webhook's per-list rejection-body composition table) reaches the
3352/// paired [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3353/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string through one
3354/// substrate-primitive dispatch rather than an open-coded `.as_str()`
3355/// re-inlining at every wire-up.
3356///
3357/// Same "route the trait impl through the substrate-primitive
3358/// accessor" discipline the sibling [`crate::CaixaDialeto`]
3359/// [`AsRef<str>`] impl (1723611), the [`crate::aplicacao::RateLimitUnit`]
3360/// [`AsRef<str>`] impl (d8136db), the [`crate::CaixaKind`]
3361/// [`AsRef<str>`] impl (cd2091f), the M3
3362/// [`crate::aplicacao::PlacementStrategy`] [`AsRef<str>`] impl
3363/// (d86edd2), the M2 [`crate::supervisor::RestartPolicy`]
3364/// [`AsRef<str>`] impl (419ea81), the M2
3365/// [`crate::supervisor::RestartStrategy`] [`AsRef<str>`] impl
3366/// (63eb1a4), and the [`crate::CaixaVersion`] [`AsRef<str>`] impl
3367/// (16d5c7e) carry — closes the substrate primitive's
3368/// [`AsRef<str>`] projection axis on the seventh (and last unlifted)
3369/// closed-set typed enum on the caixa surface: the two-list dep-graph
3370/// axis previously carried [`fmt::Display`]-through-`as_str` but not
3371/// yet the paired [`AsRef<str>`] impl, so a downstream consumer that
3372/// bound the enum through the standard-library `AsRef<str>` trait had
3373/// to reach the canonical byte-string through an open-coded
3374/// `.as_str()` call rather than the trait-idiomatic `.as_ref()` the
3375/// peer closed-set typed enums already admit.
3376///
3377/// Pinned load-bearing by
3378/// [`tests::dep_list_as_ref_str_routes_through_as_str_accessor`]
3379/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3380/// closed set) and
3381/// [`tests::dep_list_as_ref_str_routes_through_display_via_shared_accessor`]
3382/// (three-path convergence: `AsRef<str>` + `Display` + `as_str` all
3383/// resolve to the same byte-string per arm) — any future silent detour
3384/// that routes the impl through a divergent projection (a per-arm
3385/// inline `match self { DepList::Prod => ":deps", … }` re-inlining
3386/// that opens a compile-time link to the un-lifted arm-literal, a
3387/// swap onto a second projection axis) trips at caixa-core test time
3388/// under `assert_eq!` rather than at a downstream
3389/// `impl AsRef<str>`-bound consumer's silent split.
3390impl AsRef<str> for DepList {
3391 fn as_ref(&self) -> &str {
3392 self.as_str()
3393 }
3394}
3395
3396/// Trait-idiomatic *reverse* projection on the two-list dep-graph
3397/// [`DepList`] closed-set typed enum — routes through the paired
3398/// substrate-primitive [`DepList::from_wire`] `Option<Self>` accessor
3399/// so `<DepList>::try_from(":deps")` reaches the same two-arm
3400/// accept-set the sibling [`DepList::from_wire`] resolver dispatches
3401/// through, rather than an open-coded per-arm
3402/// `match s { ":deps" => Ok(Self::Prod), … }` cascade whose arm-set
3403/// has no compile-time link back to the substrate primitive.
3404///
3405/// Corrects a completeness gap in the substrate-wide trait-idiomatic
3406/// reverse-projection campaign (opened by [`crate::CaixaKind`] via
3407/// 3c83606, closed onto 14 sibling closed-set fieldless typed enums
3408/// across the caixa surface — 5b828ed, 6fdd0d9, 5472902, bf78400,
3409/// e67e48a, e21a857, 0a4cc45, a7bf74c, df86c94, bd7da69, 42ab951 —
3410/// which silently omitted [`DepList`] despite this enum being listed
3411/// as a sibling closed-set fieldless typed enum in every peer's
3412/// docstring). Every sibling closed-set fieldless typed enum on the
3413/// caixa surface now carries both trait-idiomatic axes
3414/// (`TryFrom<&str> for Self` + `From<Self> for &'static str`) paired
3415/// against the substrate-primitive canonical projection accessors
3416/// (`as_str`/`variant_slug` + `from_wire`) — the two-list dep-graph
3417/// closed-set is the fifteenth and true-final peer.
3418///
3419/// `type Error = ()` matches the sibling [`DepList::from_wire`]'s
3420/// `Option<Self>` return-shape's deliberate deferral of error typing:
3421/// the caller picks the diagnostic form appropriate for its use site
3422/// (a future `feira dep --list <deps|deps-dev>` arg-parse composes
3423/// `unknown list: <arg> — accepted: {…}` enumerating [`DepList::ALL`];
3424/// the M4 admission-webhook rejection body wraps `Err(())` with the
3425/// accepted-set enumeration).
3426///
3427/// Pinned load-bearing by
3428/// [`tests::dep_list_try_from_str_routes_through_from_wire_accessor`]
3429/// (byte-parity pin against [`DepList::from_wire`] across the two-arm
3430/// accept-set) and
3431/// [`tests::dep_list_try_from_str_rejects_unknown_byte_strings`]
3432/// (rejection witness against silent accept-set widening).
3433impl TryFrom<&str> for DepList {
3434 type Error = ();
3435
3436 fn try_from(s: &str) -> Result<Self, Self::Error> {
3437 Self::from_wire(s).ok_or(())
3438 }
3439}
3440
3441/// Trait-idiomatic *forward* projection on the two-list dep-graph
3442/// [`DepList`] closed-set typed enum onto the `&'static str` axis —
3443/// routes byte-for-byte through the paired substrate-primitive
3444/// [`DepList::as_str`] `pub const fn` accessor so
3445/// `<&'static str>::from(list)` / `list.into::<&'static str>()`
3446/// reaches the same two-arm lifted
3447/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3448/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the sibling
3449/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3450/// surfaces already return.
3451///
3452/// Closes the substrate-wide trait-idiomatic forward-projection
3453/// campaign for real — the campaign opened on [`crate::supervisor::RestartStrategy`]
3454/// via 523157d and traced through the 13 sibling closed-set typed
3455/// enums (9fb37d0, edb827b, c189a6f, afa3562, 56998ec, 7fdfbf4,
3456/// 070a6de, f2ca7bc, d4559cb, 5cc3b8b, 2a56127, 07f36bb, 85d0443)
3457/// silently omitted [`DepList`] on both trait-idiomatic axes despite
3458/// every peer's docstring naming it as a sibling. Paired with the
3459/// [`TryFrom<&str> for DepList`] impl immediately above, this closes
3460/// the two-way `DepList ↔ &'static str` round-trip on the trait-
3461/// idiomatic axis pair, mirroring the pre-existing method-named
3462/// [`DepList::as_str`] + [`DepList::from_wire`] pair on the
3463/// substrate-primitive axis pair.
3464///
3465/// The paired [`DepList::as_str`] returns `&'static str` by
3466/// construction — each arm resolves to a
3467/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3468/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str` with
3469/// static lifetime — so the trait's return-type promise is upheld
3470/// structurally.
3471///
3472/// Pinned load-bearing by
3473/// [`tests::dep_list_from_into_static_str_routes_through_as_str_accessor`]
3474/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3475/// emit-set, plus a `const`-context materialization witness for the
3476/// `&'static str` lifetime promise) and
3477/// [`tests::dep_list_from_into_static_str_and_as_str_partition_the_emit_set`]
3478/// (partition pin + two-way round-trip through the paired
3479/// [`TryFrom<&str>`] axis).
3480impl From<DepList> for &'static str {
3481 fn from(list: DepList) -> &'static str {
3482 list.as_str()
3483 }
3484}
3485
3486/// Trait-idiomatic *forward* projection on the two-list dep-graph
3487/// [`DepList`] closed-set typed enum from a *borrowed* input onto the
3488/// `&'static str` axis — the borrowed-input companion to the paired
3489/// owned-input [`From<DepList> for &'static str`] impl immediately
3490/// above. Routes byte-for-byte through the same substrate-primitive
3491/// [`DepList::as_str`] `pub const fn` accessor so every consumer that
3492/// binds a `&DepList` through the standard-library `.into()` /
3493/// [`From<&Self> for &'static str`] axis (a
3494/// `DepList::ALL.iter().map(<&'static str>::from).collect::<Vec<_>>()`
3495/// per-arm accept-set materializer that iterates the substrate-
3496/// canonical [`DepList::ALL`] slice — whose iterator yields `&DepList`,
3497/// not `DepList`, so the owned-input [`From<DepList>`] axis alone
3498/// forces every call site through an explicit `.copied()` /
3499/// dereference / [`Copy`]-bound restatement rather than the direct
3500/// trait-idiomatic projection; a future generic
3501/// `<T: Copy + for<'a> Into<&'static str>>`-bound diagnostic column
3502/// that walks the `iter().map(Into::into)` shape verbatim; the future
3503/// M4 admission-webhook rejection body that composes the accepted-set
3504/// enumeration from an iterated `DepList::ALL.iter().map(|l| l.into())`
3505/// pipe rather than a per-arm `match l { … }` cascade) reaches the same
3506/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3507/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3508/// owned-input [`From<DepList> for &'static str`], the sibling
3509/// [`std::fmt::Display`], [`AsRef<str>`], and [`DepList::as_str`]
3510/// surfaces already return.
3511///
3512/// Opens the substrate-wide trait-idiomatic *borrowed-input*
3513/// forward-projection family on the last-touched closed-set fieldless
3514/// typed enum — first-mover on the borrowed-input axis, mirroring the
3515/// role [`crate::supervisor::RestartStrategy`] played on the owned-
3516/// input axis (523157d). Rust's `From` trait does not auto-derive the
3517/// `From<&Self>` sibling from a `From<Self>` impl (the blanket
3518/// `impl<T, U> From<&T> for U where T: Copy, U: From<T>` does not exist
3519/// in `core`), so every closed-set typed enum that carries the
3520/// owned-input axis but not the borrowed-input axis forces every
3521/// borrowed-input call site through a `.copied()` /
3522/// `<&'static str>::from(*list)` / `list.as_str()` detour whose type
3523/// bounds have no compile-time link to the substrate primitive. The
3524/// remaining fourteen substrate-wide closed-set fieldless typed enum
3525/// peers (`CaixaKind`, `CaixaDialeto`, `RestartStrategy`,
3526/// `RestartPolicy`, `WitShape`, `RateLimitUnit`, `PlacementStrategy`,
3527/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3528/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets
3529/// of this campaign.
3530///
3531/// Pinned load-bearing by
3532/// [`tests::dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor`]
3533/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3534/// emit-set via a borrowed input, plus a `const`-context materialization
3535/// witness) and
3536/// [`tests::dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm`]
3537/// (cross-axis partition pin against the paired owned-input
3538/// [`From<DepList> for &'static str`] impl).
3539impl From<&DepList> for &'static str {
3540 fn from(list: &DepList) -> &'static str {
3541 list.as_str()
3542 }
3543}
3544
3545/// Trait-idiomatic *forward* projection on the two-list dep-graph
3546/// [`DepList`] closed-set typed enum from an *owned* input onto the
3547/// owned-[`String`] axis — routes byte-for-byte through the
3548/// substrate-primitive [`DepList::as_str`] `pub const fn` accessor so
3549/// every consumer that binds a [`DepList`] through the standard-library
3550/// `.into()` / [`From<Self> for String`] (equivalently [`Into<String>`])
3551/// axis reaches the same two-arm lifted
3552/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3553/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string the paired
3554/// owned-input [`From<DepList> for &'static str`], the borrowed-input
3555/// [`From<&DepList> for &'static str`], the sibling [`std::fmt::Display`],
3556/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return.
3557///
3558/// Extends the trait-idiomatic *owned-[`String`]* forward-projection
3559/// family (opened on [`crate::supervisor::RestartStrategy`] — 7baa18a —
3560/// the first-mover on the M2 OTP-shape sibling-restart-strategy axis,
3561/// extended onto [`crate::supervisor::RestartPolicy`] — 7851725 — the
3562/// second-of-two-in-M2 per-child restart-decision axis, then onto
3563/// [`crate::CaixaKind`] — 231a18c — the structurally most fundamental
3564/// closed-set fieldless typed enum on the caixa surface, then onto
3565/// [`crate::CaixaDialeto`] — 88942cd — the dialect-classification axis)
3566/// onto the fifth peer: the two-list dep-graph axis [`DepList`] carries.
3567/// Rust's standard library does not carry a blanket
3568/// `impl<T: AsRef<str>> From<T> for String` (nor an
3569/// `impl<T: fmt::Display> From<T> for String`), so every closed-set
3570/// typed enum that carries the paired [`AsRef<str>`] / [`std::fmt::Display`] /
3571/// [`From<Self> for &'static str`] / [`From<&Self> for &'static str`]
3572/// quadruple but not the owned-[`String`] axis forces every owned-string
3573/// call site through a `.to_string()` / `.as_str().to_owned()` /
3574/// `String::from(list.as_str())` detour whose type bounds have no
3575/// compile-time link to the substrate primitive.
3576///
3577/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3578/// [`crate::supervisor::RestartPolicy`] / [`crate::CaixaDialeto`]
3579/// owned-[`String`] axis pairs (whose forward emit and reverse parse
3580/// share one vocabulary by construction — `PascalCase` on the three
3581/// prior peers, the `":deps"` / `":deps-dev"` leading-colon lispy
3582/// author-surface tags on this one), [`DepList`]'s [`DepList::as_str`]
3583/// emit and [`DepList::from_wire`] parse resolve through the same
3584/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3585/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3586/// (there is no wire/diagnostic axis split on this enum — both halves
3587/// of the round-trip route through the same two `pub const &str` values),
3588/// so the owned-[`String`] forward projection this impl exposes composes
3589/// directly with the paired trait-idiomatic reverse
3590/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3591/// borrow — no intermediate wire-vocab hop like the peer
3592/// [`crate::CaixaKind`] axis pair requires.
3593///
3594/// The remaining ten closed-set typed enums on the caixa substrate
3595/// surface (`PlacementStrategy`, `WitShape`, `RateLimitUnit`,
3596/// `PathShapeViolation`, `InvariantKind`, `ArchVerdict`, `Severity`,
3597/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the future targets of
3598/// this campaign — each carries the same paired [`AsRef<str>`] /
3599/// [`std::fmt::Display`] / [`From<Self> for &'static str`] /
3600/// [`From<&Self> for &'static str`] quadruple that this owned-[`String`]
3601/// axis extends onto.
3602///
3603/// Pinned load-bearing by
3604/// [`tests::dep_list_from_into_owned_string_routes_through_as_str_accessor`]
3605/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3606/// [`DepList::ALL`] emit-set plus a blanket `.into::<String>()` shape
3607/// witness) and
3608/// [`tests::dep_list_from_into_owned_string_and_static_str_agree_on_every_arm`]
3609/// (cross-axis partition against the sibling owned-`&'static str` axis
3610/// and the [`ToString::to_string`] surface, a
3611/// `.iter().copied().map(String::from)` pipe witness over
3612/// [`DepList::ALL`], plus a direct `Self → String → Self` round-trip
3613/// via [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3614/// borrow — composes directly without the wire-vocab intermediate hop
3615/// the peer [`crate::CaixaKind`] axis pair requires).
3616impl From<DepList> for String {
3617 fn from(list: DepList) -> String {
3618 list.as_str().to_owned()
3619 }
3620}
3621
3622/// Trait-idiomatic *borrowed-input, owned-`String` output* forward
3623/// projection on the two-list dep-graph [`DepList`] closed-set typed
3624/// enum — the fourth (and closing) corner of the
3625/// `{Self, &Self} × {&'static str, String}` 2×2 trait-idiomatic
3626/// projection family on this enum, mirror of the peer M2 OTP-shape
3627/// [`From<&RestartStrategy> for String`] (579385f) and
3628/// [`From<&RestartPolicy> for String`] (8465740) that opened and
3629/// closed the corner on the sibling supervisor-level restart-strategy
3630/// and per-child restart-decision enums. Routes byte-for-byte through
3631/// the substrate-primitive [`DepList::as_str`] `pub const fn` accessor
3632/// (via [`str::to_owned`]) so every consumer that holds a borrowed
3633/// [`&DepList`] and needs an owned [`String`] — a future
3634/// `serde_json::Value::String(String::from(&list))` structured-payload
3635/// composer over a borrowed field, a future `Iterator::map` over
3636/// `&[DepList]` that projects to owned keys through
3637/// `.iter().map(String::from)` (whose iterator yields `&DepList`, not
3638/// `DepList`, so the owned-input [`From<DepList> for String`] axis
3639/// alone forces every call site through an explicit `.copied()` /
3640/// spurious [`Copy`] deref restatement rather than the direct trait-
3641/// idiomatic projection), a future `HashMap::<String, DepList>::from_iter`
3642/// that keys off a borrowed-iteration axis where dereferencing the list
3643/// would force an unnecessary `Copy` at every step, the future
3644/// wasm-operator's per-manifest `list_axes.iter().map(String::from).collect()`
3645/// per-list author-surface-tag diagnostic emit whose iteration axis is
3646/// borrowed by construction — reaches the same two-arm lifted
3647/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3648/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] const the paired
3649/// [`std::fmt::Display`], [`AsRef<str>`], [`DepList::as_str`], and the
3650/// three other trait-idiomatic forward-projection impls
3651/// ([`From<DepList> for &'static str`],
3652/// [`From<&DepList> for &'static str`],
3653/// [`From<DepList> for String`]) already return.
3654///
3655/// Third peer on the substrate-wide trait-idiomatic *borrowed-input,
3656/// owned-`String` output* forward-projection family opened on
3657/// [`crate::supervisor::RestartStrategy`] (579385f) and closed on
3658/// [`crate::supervisor::RestartPolicy`] (8465740) — extends the
3659/// `{Self, &Self} × {&'static str, String}` 2×2 projection corner off
3660/// the M2 OTP-shape axis pair onto the first non-M2 closed-set
3661/// fieldless typed enum peer (the two-list dep-graph axis). Rust's
3662/// standard library does not carry a blanket
3663/// `impl<T: AsRef<str>> From<&T> for String` (nor an
3664/// `impl<T: fmt::Display> From<&T> for String`), so every closed-set
3665/// typed enum that carries the paired `AsRef<str>` / `Display` /
3666/// `From<Self> for &'static str` / `From<&Self> for &'static str` /
3667/// `From<Self> for String` quintuple but not the borrowed-input owned-
3668/// [`String`] axis forces every borrowed-input owned-string call site
3669/// through a `list.as_str().to_owned()` / `String::from(*list)` (with a
3670/// spurious `Copy`) / `list.to_string()` (through `Display`) detour
3671/// whose type bounds have no compile-time link to the substrate
3672/// primitive.
3673///
3674/// Same as the peer [`crate::supervisor::RestartStrategy`] /
3675/// [`crate::supervisor::RestartPolicy`] borrowed-input owned-[`String`]
3676/// axis pairs (whose forward emit and reverse parse share one
3677/// vocabulary by construction — `PascalCase` on the M2 OTP-shape
3678/// peers), [`DepList`]'s [`DepList::as_str`] emit and
3679/// [`DepList::from_wire`] parse resolve through the same lifted
3680/// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3681/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by construction
3682/// (the `":deps"` / `":deps-dev"` leading-colon lispy author-surface
3683/// tags — there is no wire/diagnostic axis split on this enum), so the
3684/// borrowed-input owned-[`String`] projection this impl exposes
3685/// composes directly with the paired trait-idiomatic reverse
3686/// [`TryFrom<&str>`] axis on the owned-[`String`]'s [`String::as_str`]
3687/// borrow — no intermediate wire-vocab hop like the peer
3688/// [`crate::CaixaKind`] axis pair requires.
3689///
3690/// The remaining ten closed-set typed enums on the caixa substrate
3691/// surface (`CaixaKind`, `CaixaDialeto`, `PlacementStrategy`,
3692/// `WitShape`, `RateLimitUnit`, `PathShapeViolation`, `InvariantKind`,
3693/// `ArchVerdict`, `Severity`, `FixSafety`, `Semantic`, `FerriteRuntime`)
3694/// are the future targets of this 2×2-completion campaign — each
3695/// carries the same paired quintuple that this borrowed-input owned-
3696/// [`String`] axis extends onto.
3697///
3698/// Pinned load-bearing by
3699/// [`tests::dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
3700/// (byte-parity pin against [`DepList::as_str`] across the two-arm
3701/// emit-set through the borrowed-input surface) and
3702/// [`tests::dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
3703/// (cross-axis partition pin against the paired owned-input owned-
3704/// [`String`] [`From<DepList> for String`] impl, the paired borrowed-
3705/// input owned-[`&'static str`] [`From<&DepList> for &'static str`]
3706/// impl, and the sibling [`ToString::to_string`] surface routed through
3707/// [`std::fmt::Display`], plus a direct round-trip witness through
3708/// [`TryFrom<&str>`] on the owned-[`String`]'s [`String::as_str`]
3709/// borrow that closes the two-way `&Self → String → Self` round-trip
3710/// on the trait-idiomatic borrowed-input owned-[`String`] forward +
3711/// reverse axis pair).
3712impl From<&DepList> for String {
3713 fn from(list: &DepList) -> String {
3714 list.as_str().to_owned()
3715 }
3716}
3717
3718/// Trait-idiomatic *forward* projection on the two-list dep-graph
3719/// [`DepList`] closed-set typed enum from an *owned* input onto the
3720/// borrowed-heap-string [`std::borrow::Cow<'static, str>`] axis —
3721/// routes byte-for-byte through the substrate-primitive
3722/// [`DepList::as_str`] `pub const fn` accessor (via
3723/// [`std::borrow::Cow::Borrowed`]) so every consumer that binds a
3724/// [`DepList`] through the standard-library `.into()` /
3725/// [`From<Self> for std::borrow::Cow<'static, str>`] (equivalently
3726/// [`Into<std::borrow::Cow<'static, str>>`]) axis reaches the same
3727/// two-arm lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3728/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] canonical `pub const
3729/// &str` values the paired [`From<DepList> for &'static str`],
3730/// [`From<&DepList> for &'static str`], [`From<DepList> for String`],
3731/// and [`From<&DepList> for String`] 2×2 trait-idiomatic forward-
3732/// projection corners, the sibling [`std::fmt::Display`],
3733/// [`AsRef<str>`], and [`DepList::as_str`] surfaces already return,
3734/// rather than an open-coded per-call-site
3735/// `std::borrow::Cow::Borrowed(list.as_str())` /
3736/// `std::borrow::Cow::Owned(list.to_string())` composition whose
3737/// type bounds have no compile-time link back to the substrate
3738/// primitive.
3739///
3740/// Deliberately returns [`std::borrow::Cow::Borrowed`] rather than
3741/// [`std::borrow::Cow::Owned`] — the substrate-primitive
3742/// [`DepList::as_str`] accessor's return carries the `&'static str`
3743/// lifetime by construction (each `match` arm resolves to one of
3744/// the two lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3745/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3746/// values with static lifetime), so the zero-alloc borrowed arm is
3747/// the type-correct projection with no runtime allocation. The
3748/// paired [`std::borrow::Cow::Owned`] arm stays reachable at the
3749/// call site through the existing [`From<DepList> for String`] axis
3750/// composed with [`std::borrow::Cow::from`] on the resulting owned
3751/// [`String`] — a caller who chose to mutate the projection lands
3752/// on the owned arm by their own composition, not by the substrate-
3753/// primitive projection silently allocating on their behalf.
3754///
3755/// Rust's standard library carries no blanket `impl<T: AsRef<str>>
3756/// From<T> for Cow<'static, str>` (nor an `impl<T: fmt::Display>
3757/// From<T> for Cow<'static, str>`), so the paired sibling
3758/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3759/// [`AsRef<str>`], and [`std::fmt::Display`] surfaces do not
3760/// implicitly extend to a [`std::borrow::Cow<'static, str>`]-bound
3761/// call site — every such site is forced through a
3762/// `Cow::Borrowed(list.as_str())` / `Cow::Owned(list.to_string())`
3763/// open-code whose type bounds have no compile-time link back to
3764/// the substrate primitive until this lift.
3765///
3766/// First-mover on the outside-M3 substrate-wide tier of the
3767/// substrate-wide trait-idiomatic [`std::borrow::Cow<'static, str>`]
3768/// forward-projection campaign, opening the tier on the first
3769/// caixa-core-internal closed-set fieldless typed enum peer outside
3770/// the M2 OTP-shape and M3 mesh-shape tiers. The
3771/// [`crate::CaixaKind`] top-level first-mover
3772/// (99c1735 owned-input, d45c409 borrowed-input) opened the axis on
3773/// the structurally most fundamental closed-set fieldless typed
3774/// enum; the paired M2 OTP-shape
3775/// [`crate::supervisor::RestartStrategy`] (7dd28b3, 9b3e4b3) and
3776/// [`crate::supervisor::RestartPolicy`] (0612398, ee577fd) closed
3777/// the M2 OTP-shape tier; the paired M3-mesh-shape
3778/// [`crate::aplicacao::WitShape`] `:contratos :wit` census-label
3779/// (8634dec, 25690ef), [`crate::aplicacao::PlacementStrategy`]
3780/// `:placement :estrategia` distribution-strategy (eee504d,
3781/// afdf0f4), and [`crate::aplicacao::RateLimitUnit`] `:politicas
3782/// :rate-limit` canonical-suffix (1d59925, `From<&RateLimitUnit>`
3783/// Cow closer) closed the M3-mesh-shape tier. The remaining
3784/// outside-M3 caixa-core peers ([`crate::CaixaDialeto`],
3785/// [`crate::render::PathShapeViolation`]) and the outside-
3786/// `caixa-core` peers (`InvariantKind`, `ArchVerdict`, `Severity`,
3787/// `FixSafety`, `Semantic`, `FerriteRuntime`) are the remaining
3788/// future targets of this campaign; the paired borrowed-input
3789/// [`From<&DepList> for std::borrow::Cow<'static, str>`]
3790/// `{Self, &Self}`-closer on this outside-M3-tier-opening peer is
3791/// the next commit's target.
3792///
3793/// Same three-path convergence discipline as the paired sibling
3794/// [`From<DepList> for &'static str`] / [`From<DepList> for String`]
3795/// / [`std::fmt::Display`] / [`AsRef<str>`] surfaces (this
3796/// [`std::borrow::Cow<'static, str>`] axis, the paired sibling
3797/// surfaces, and [`DepList::as_str`] all route through the same two
3798/// lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
3799/// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const &str`
3800/// values by construction), so a future variant addition, rename,
3801/// or per-arm wire-tag drift reaches every forward-projection path
3802/// through exactly one caixa-core edit at the [`DepList::as_str`]
3803/// `match` head.
3804///
3805/// Pinned load-bearing by
3806/// [`tests::dep_list_from_into_static_cow_str_routes_through_as_str_accessor`]
3807/// (byte-parity + zero-alloc [`std::borrow::Cow::Borrowed`]-arm pin
3808/// against [`DepList::as_str`] across the two-arm [`DepList::ALL`])
3809/// and
3810/// [`tests::dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm`]
3811/// (cross-axis partition pin against the paired
3812/// [`From<DepList> for &'static str`], [`From<DepList> for String`],
3813/// and [`ToString`]-through-[`std::fmt::Display`] axes, plus a
3814/// `.iter().copied().map(Cow::from)` pipe witness over
3815/// [`DepList::ALL`] that materializes the two-arm accept-set through
3816/// the [`std::borrow::Cow<'static, str>`] axis alone and pins the
3817/// zero-alloc discipline on every element).
3818impl From<DepList> for std::borrow::Cow<'static, str> {
3819 fn from(list: DepList) -> std::borrow::Cow<'static, str> {
3820 std::borrow::Cow::Borrowed(list.as_str())
3821 }
3822}
3823
3824/// Errors raised by [`Dep::validate`].
3825///
3826/// Mirrors the per-axis error families the other `:versao`-carrying
3827/// typed surfaces expose
3828/// ([`crate::AplicacaoError::MembroVersaoEmpty`] /
3829/// [`crate::AplicacaoError::MembroVersaoInvalid`],
3830/// [`crate::SupervisorError::EmptyChildVersion`] /
3831/// [`crate::SupervisorError::ChildVersaoInvalid`]) so a future top-
3832/// level `CaixaError` (M4) sums these without reshaping the diagnostic.
3833#[derive(Debug, Error, PartialEq, Eq)]
3834pub enum DepError {
3835 #[error(
3836 ":deps entry has empty :nome (every dep must name a target caixa; \
3837 omit the entry instead of carrying an empty name)"
3838 )]
3839 NomeEmpty,
3840 #[error(
3841 ":deps entry :nome {nome:?} is not a valid DNS-1123 label: {reason} \
3842 (the value flows verbatim as the target caixa's `:nome`, the rendered \
3843 `lareira-<nome>` Helm chart name segment, the `LABEL_PROGRAM` label \
3844 value, and the resolver's checkout-directory leaf — each apiserver-side \
3845 schema rejects non-DNS-1123 names at admission time; use a lowercase \
3846 RFC 1123 label like `\"caixa-teia\"` or `\"pleme-mesh\"`, 1..=63 bytes, \
3847 pattern `^[a-z0-9]([-a-z0-9]*[a-z0-9])?$`)"
3848 )]
3849 NomeInvalid { nome: String, reason: String },
3850 #[error(
3851 ":deps entry {nome:?} has empty :versao (every dep must pin a semver \
3852 constraint that resolves through the lacre pipeline)"
3853 )]
3854 VersaoEmpty { nome: String },
3855 #[error(
3856 ":deps entry {nome:?} :versao {versao:?} is not a valid semver \
3857 requirement: {reason} (use Cargo-shaped forms like `\"^0.1\"`, \
3858 `\"~0.1.2\"`, `\"0.1.0\"`, or `\"*\"` — the same shape `:membros :versao` \
3859 and `:children :versao` carry; the lacre pipeline resolves all three \
3860 through the same parser)"
3861 )]
3862 VersaoInvalid {
3863 nome: String,
3864 versao: String,
3865 reason: String,
3866 },
3867 #[error(
3868 ":deps entry {nome:?} :fonte (:tipo git …) has empty :repo \
3869 (every git source must name a repo — use a `github:org/repo` \
3870 shorthand, an `https://…` URL, or an ssh-git URL; omit the \
3871 entire :fonte block to fall back to the default-host resolver \
3872 convention)"
3873 )]
3874 FonteRepoEmpty { nome: String },
3875 #[error(
3876 ":deps entry {nome:?} :fonte (:tipo git …) :repo {repo:?} has \
3877 invalid value-shape: {reason} (the value flows verbatim into the \
3878 caixa-resolver's `git clone <repo>` subprocess invocation; every \
3879 documented form carries a `:` separator and no whitespace / \
3880 control / non-ASCII bytes — use a `github:org/repo` shorthand, \
3881 an `https://host/path` / `ssh://[user@]host/path` / \
3882 `git://host/path` / `file:///path` URL, or the `git@host:path` \
3883 scp-style SSH form)"
3884 )]
3885 FonteRepoShape {
3886 nome: String,
3887 repo: String,
3888 reason: String,
3889 },
3890 #[error(
3891 ":deps entry {nome:?} :fonte (:tipo git …) has no pin set \
3892 (set exactly one of :tag, :rev, or :branch so the resolver \
3893 can pick a reproducible commit; omit the entire :fonte block \
3894 to fall back to the default-host resolver convention, which \
3895 resolves the latest tag matching :versao)"
3896 )]
3897 FontePinMissing { nome: String },
3898 #[error(
3899 ":deps entry {nome:?} :fonte (:tipo git …) has multiple pins \
3900 set ({pins}); exactly one of :tag, :rev, or :branch must be \
3901 set so the resolver's checkout target is unambiguous (the \
3902 resolver's silent precedence is :rev > :tag > :branch — if \
3903 you intended one specifically, drop the others)"
3904 )]
3905 FontePinAmbiguous { nome: String, pins: String },
3906 #[error(
3907 ":deps entry {nome:?} :fonte (:tipo git …) has empty {pin} \
3908 (a set pin must name a non-empty git ref; drop the {pin} key \
3909 entirely to fall through to another pin axis)"
3910 )]
3911 FontePinEmpty { nome: String, pin: String },
3912 #[error(
3913 ":deps entry {nome:?} :fonte (:tipo git …) {pin} {value:?} has invalid \
3914 value-shape: {reason} (the git porcelain enforces the same shape at \
3915 `git fetch` / `git checkout` time on every pin; use a leaf refname \
3916 like `\"v0.1.0\"` for `:tag` or `\"main\"` / `\"feature/foo\"` for \
3917 `:branch`, or a full 40/64 lowercase-hex commit OID for `:rev` — \
3918 drop any `refs/heads/` or `refs/tags/` prefix the caixa-resolver \
3919 prepends at clone time, and avoid abbreviated SHAs which are \
3920 ambiguous across repository history)"
3921 )]
3922 FontePinShape {
3923 nome: String,
3924 pin: String,
3925 value: String,
3926 reason: String,
3927 },
3928 #[error(
3929 ":deps entry {nome:?} :fonte (:tipo path …) has empty :caminho \
3930 (every path source must name a non-empty filesystem path; \
3931 omit the entire :fonte block to fall back to the default-host \
3932 resolver convention)"
3933 )]
3934 FonteCaminhoEmpty { nome: String },
3935 #[error(
3936 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} is \
3937 absolute (the lacre pipeline embeds the value verbatim in its \
3938 per-dep content-address `path:{caminho}` at \
3939 caixa-resolver/src/resolve.rs:189, so an absolute path makes the \
3940 BLAKE3 closure differ across machines — defeating the \
3941 reproducibility contract that's load-bearing for CSE; express \
3942 the path relative to the caixa.lisp location, e.g. \
3943 \"../caixa-teia\" for a sibling workspace dep)"
3944 )]
3945 FonteCaminhoAbsolute { nome: String, caminho: String },
3946 #[error(
3947 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3948 with `~` (the leading-tilde is a shell-expansion convention, not a \
3949 POSIX path component — `Path::is_absolute` returns false on it, so \
3950 the b94fd83 absolute-path gate doesn't catch it, but the lacre \
3951 pipeline embeds the value verbatim in its per-dep content-address \
3952 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3953 caixa-resolver folds it through `Path::join` without `~`-expansion, \
3954 so the build looks for a literal `./{caminho}` subdirectory and \
3955 fails at resolve time far from the source caixa.lisp; even worse, a \
3956 future caixa-resolver pass that *does* expand `~` would silently \
3957 re-open the host-layout-leak the b94fd83 absolute gate closes — \
3958 Alice's `~` resolves to `/home/alice`, Bob's to `/home/bob`, two CI \
3959 runners with different `$HOME` layouts resolve to two distinct paths \
3960 for the byte-identical caixa, defeating the THEORY.md §V.2 render-\
3961 determinism contract; express the path relative to the caixa.lisp \
3962 location, e.g. \"../caixa-teia\" for a sibling workspace dep, or \
3963 spell out the full relative path explicitly if a workstation-rooted \
3964 dep is genuinely intended)"
3965 )]
3966 FonteCaminhoTildeExpansion { nome: String, caminho: String },
3967 #[error(
3968 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3969 with `$` (the leading-`$` is a shell-variable-expansion convention, \
3970 not a POSIX path component — `Path::is_absolute` returns false on it \
3971 and the a5c248e tilde gate doesn't catch it, but the lacre pipeline \
3972 embeds the value verbatim in its per-dep content-address \
3973 `path:{caminho}` at caixa-resolver/src/resolve.rs:189 and the \
3974 caixa-resolver folds it through `Path::join` without `$`-expansion, \
3975 so the build looks for a literal `./{caminho}` subdirectory and \
3976 fails at resolve time far from the source caixa.lisp; even worse, a \
3977 future caixa-resolver pass that *does* expand `$VAR` (the canonical \
3978 shell-convention idiom that CI's `${{WORKSPACE}}` paste-idiom \
3979 invites) would silently re-open the host-layout-leak the b94fd83 \
3980 absolute gate closes — Alice's `$HOME` resolves to `/home/alice`, \
3981 Bob's to `/home/bob`, two CI runners with different `${{WORKSPACE}}` \
3982 layouts resolve to two distinct paths for the byte-identical caixa, \
3983 defeating the THEORY.md §V.2 render-determinism contract; express \
3984 the path relative to the caixa.lisp location, e.g. \"../caixa-teia\" \
3985 for a sibling workspace dep, or spell out the full relative path \
3986 explicitly if a workstation-rooted dep is genuinely intended)"
3987 )]
3988 FonteCaminhoVarExpansion { nome: String, caminho: String },
3989 #[error(
3990 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
3991 with a space (the leading ASCII space `0x20` is the orthogonal \
3992 paste-from-aligned-doc footgun that silently passes \
3993 `Path::is_absolute` and every prior leading-byte arm — \
3994 `\" ../caixa-teia\"` resolves via `Path::join` to a literal \
3995 `./ ../caixa-teia` subdirectory the resolver fails to find at \
3996 resolve time with a non-self-locating `No such file or directory` \
3997 error far from the source caixa.lisp; the lacre pipeline embeds \
3998 the value verbatim in its per-dep content-address `path:{caminho}` \
3999 at caixa-resolver/src/resolve.rs:189, so byte-divergent / \
4000 semantic-identical caixa values (` ../caixa-teia` vs \
4001 `../caixa-teia`) yield two distinct BLAKE3 closures across two \
4002 workstations whose authors differ only in paste-from-aligned- \
4003 caixa.lisp-doc whitespace habits — the most insidious failure \
4004 mode the typed slot can carry (no error surfaces; the divergence \
4005 is invisible until two machines compare lacres), defeating the \
4006 THEORY.md §V.2 render-determinism contract. The canonical \
4007 paste-from-aligned-`:deps`-block footgun (every `:fonte` form in \
4008 a multi-entry `:deps` block sits at the same column — an author \
4009 selecting `\"<sp><sp><sp>../caixa-teia\"` and pasting it from \
4010 the rendered alignment into a fresh entry preserves the leading \
4011 whitespace verbatim); peer `:fonte :repo` axis already rejects \
4012 leading whitespace via `is_git_repo_url`, `:fonte :tag` / \
4013 `:fonte :branch` via `is_git_ref_name`, `:descricao` via \
4014 `is_chart_description_shape`, `:licenca` via \
4015 `is_spdx_expression_shape`. Drop the leading space; express the \
4016 path as a bare relative single-token like \"../caixa-teia\")"
4017 )]
4018 FonteCaminhoLeadingWhitespace { nome: String, caminho: String },
4019 #[error(
4020 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} starts \
4021 with `-` (the canonical CLI-argument-injection footgun on the \
4022 `:caminho` axis — the lacre pipeline embeds the value verbatim in \
4023 its per-dep content-address `path:{caminho}` at \
4024 caixa-resolver/src/resolve.rs:189 and the caixa-resolver folds it \
4025 through `Path::join` looking for a literal `./{caminho}` \
4026 subdirectory. Every downstream subprocess that consumes the resolved \
4027 path — `git -C {caminho} <verb>`, `terraform -chdir={caminho}`, \
4028 `nix build --path {caminho}`, `find {caminho}`, `stat {caminho}`, \
4029 `cp -r {caminho} …`, `rm -rf {caminho}` — reinterprets a leading-`-` \
4030 value as a CLI flag rather than a positional path when the invocation \
4031 does not carry a `--` argument-list terminator between the flag block \
4032 and the path (the common case at every porcelain entry point). The \
4033 canonical footguns: `:caminho \"-rf\"` (bare short-flag paste), \
4034 `:caminho \"-C\"` (`git -C -C` config-injection paste), \
4035 `:caminho \"--upload-pack=cat /etc/passwd\"` (the canonical long-flag \
4036 CLI-arg-injection vector at every git porcelain entry point that \
4037 consumes a path or URL argument, peer with is_git_repo_url's \
4038 leading-`-` arm on the sibling `:fonte :repo` axis), \
4039 `:caminho \"--config=…\"` (`git -c foo=bar` config-override paste). \
4040 POSIX `std::path::Path` treats a leading `-` as a literal filename \
4041 byte so the resolver folds `\"-rf\"` through `Path::join` and looks \
4042 for a literal `./-rf` subdirectory that fails at resolve time with a \
4043 non-self-locating `No such file or directory` error far from the \
4044 source caixa.lisp — but on any downstream shell-out without `--` the \
4045 reinterpretation is silent and the failure mode is arbitrary-\
4046 argument-injection. Peer arms: `is_git_repo_url` (render.rs:2037) \
4047 rejects leading `-` on `:fonte :repo` for `git clone <repo>` CLI-\
4048 arg-injection; `is_git_ref_name` (render.rs:1381, 5a28454) rejects \
4049 leading `-` on `:fonte :tag` / `:branch` for `git checkout <ref>` \
4050 CLI-arg-injection; `is_dns_1123_label` rejects leading `-` on every \
4051 DNS-1123-shaped axis (top-level Caixa `:nome`, `:membros :caixa`, \
4052 `:children :caixa`, `:deps :nome`, cluster names); \
4053 `is_cargo_feature_name` rejects leading `-` on `:caracteristicas`; \
4054 the feira `init` / `add <nome>` positional gate (868c191) rejects \
4055 leading `-` on the CLI positional itself. Express the path as a bare \
4056 relative single-token like \"../caixa-teia\" — the sibling-workspace \
4057 directory name carries no leading-hyphen semantic, and `./` / `../` \
4058 prefixes structurally partition the leading-byte set to safe values.)"
4059 )]
4060 FonteCaminhoLeadingHyphen { nome: String, caminho: String },
4061 #[error(
4062 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains \
4063 ASCII control byte 0x{byte:02x} (POSIX paths reject NUL `0x00` outright — \
4064 every `std::fs` syscall routes the path through `CString::new` which \
4065 fails with `NulError` at resolve time; the lacre pipeline embeds the \
4066 value verbatim in its per-dep content-address `path:{caminho}` at \
4067 caixa-resolver/src/resolve.rs:189 so a control byte anywhere in the \
4068 value lands in the BLAKE3 closure and breaks the THEORY.md §V.2 render-\
4069 determinism contract — the canonical paste-from-multiline-doc \
4070 (`\\n`/`\\r`), paste-from-aligned-table (`\\t`), or paste-from-binary-\
4071 blob (`0x00`-DEL) footgun every peer single-token-shaped axis \
4072 (`:fonte :repo`, `:fonte :tag`/`:branch`, the Helm chart-string axes) \
4073 already gates against. Express the path as a relative single-line ASCII \
4074 string, e.g. \"../caixa-teia\" for a sibling workspace dep)"
4075 )]
4076 FonteCaminhoControlChar {
4077 nome: String,
4078 caminho: String,
4079 byte: u8,
4080 },
4081 #[error(
4082 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains `\\` \
4083 (POSIX `std::path::Path` treats `\\` as a literal byte inside a single path \
4084 component, so `..\\caixa-teia` is one directory named literally `..\\caixa-teia` — \
4085 not the parent's sibling — and the caixa-resolver folds the value through \
4086 `Path::join` looking for a literal `./{caminho}` subdirectory that fails at \
4087 resolve time with a non-self-locating `No such file or directory` error far \
4088 from the source caixa.lisp; Windows `std::path::Path` treats `\\` as a \
4089 primary path separator equal to `/`, so byte-identical caixa.lisp values \
4090 resolve to two distinct directories across runner OSes — the lacre pipeline \
4091 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4092 caixa-resolver/src/resolve.rs:189, defeating the THEORY.md §V.2 render-\
4093 determinism contract via the cross-host-OS-separator divergence vector. The \
4094 canonical Windows-Explorer `Copy as path` / PowerShell `Get-Location` \
4095 paste-idiom footgun; peer `:fonte :tag` / `:fonte :branch` axis already \
4096 rejects `\\` via `is_git_ref_name` for the same Windows-path-leak reason, \
4097 and `:entrada :paths` rejects `\\` via `is_gateway_api_http_path`'s eleven-\
4098 byte RFC-3986-reserved set. Express the path with `/` as the separator, e.g. \
4099 \"../caixa-teia\" for a sibling workspace dep)"
4100 )]
4101 FonteCaminhoBackslash { nome: String, caminho: String },
4102 #[error(
4103 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4104 redirection metacharacter 0x{byte:02x} `{ch}` (every interactive shell — bash / \
4105 zsh / fish / nushell — lexes `<` and `>` as input / output redirection \
4106 operators, so `:caminho \"../caixa-teia>build.log\"` is the canonical \
4107 paste-from-shell-pipeline footgun where an author copies a `command > log` \
4108 tail without trimming the redirect; POSIX `std::path::Path` treats both bytes \
4109 as literal path-component bytes, so the resolver folds the value through \
4110 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4111 subdirectory and fails at resolve time with a non-self-locating `No such \
4112 file or directory` error far from the source caixa.lisp. The lacre pipeline \
4113 embeds the value verbatim in its per-dep content-address `path:{caminho}` at \
4114 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure \
4115 and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4116 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4117 canonical CRLF-at-subprocess-argument / shell-metachar injection surface every \
4118 peer single-token-shaped typed slot already closes. The peer `:fonte :tag` / \
4119 `:fonte :branch` axis already rejects `<` / `>` via `is_git_ref_name`, and \
4120 `:entrada :paths` rejects them via `is_gateway_api_http_path`'s eleven-byte \
4121 RFC-3986-reserved set. Express the path as a bare relative single-token like \
4122 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4123 redirection semantic.",
4124 ch = *byte as char
4125 )]
4126 FonteCaminhoShellRedirection {
4127 nome: String,
4128 caminho: String,
4129 byte: u8,
4130 },
4131 #[error(
4132 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-pipe \
4133 metacharacter `|` (every interactive shell — bash / zsh / fish / nushell — lexes \
4134 `|` as the pipe operator that wires one command's stdout to the next command's \
4135 stdin, so `:caminho \"../caixa-teia | grep foo\"` is the canonical paste-from-\
4136 shell-history footgun where an author copies a `ls ../caixa-teia | grep` line \
4137 without trimming the pipeline tail, and `:caminho \"../foo||bar\"` is the \
4138 symmetric `cmd-a || cmd-b` short-circuit-OR paste shape; POSIX `std::path::Path` \
4139 treats `|` as a literal path-component byte, so the resolver folds the value \
4140 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4141 subdirectory and fails at resolve time with a non-self-locating `No such file or \
4142 directory` error far from the source caixa.lisp. The lacre pipeline embeds the \
4143 value verbatim in its per-dep content-address `path:{caminho}` at caixa-resolver/\
4144 src/resolve.rs:189, so the byte lands in the BLAKE3 closure and rides into every \
4145 shell-spawned subprocess (the resolver's `git clone`, a future `feira tofu` \
4146 shell-out, a future operator-side `nix` spawn) as the canonical CRLF-at-\
4147 subprocess-argument / shell-metachar injection surface every peer single-token-\
4148 shaped typed slot already closes. The peer `:entrada :paths` axis rejects `|` \
4149 via `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4150 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4151 workspace directory name carries no shell-pipe semantic."
4152 )]
4153 FonteCaminhoShellPipe { nome: String, caminho: String },
4154 #[error(
4155 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4156 command-separator metacharacter `;` (every interactive shell — bash / zsh / fish \
4157 / nushell — lexes `;` as the sequential-command terminator that fires the next \
4158 command regardless of the prior command's exit status, so `:caminho \
4159 \"../caixa-teia; rm -rf build\"` is the canonical paste-from-shell-one-liner \
4160 footgun where an author copies a `cd path; do-thing` chain without trimming \
4161 the cleanup tail, and `:caminho \"../foo;;bar\"` is the symmetric POSIX `case` \
4162 arm `;;` terminator paste shape; POSIX `std::path::Path` treats `;` as a \
4163 literal path-component byte, so the resolver folds the value through \
4164 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4165 subdirectory and fails at resolve time with a non-self-locating `No such file \
4166 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4167 the value verbatim in its per-dep content-address `path:{caminho}` at \
4168 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4169 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4170 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the \
4171 canonical shell-metachar injection surface every peer single-token-shaped \
4172 typed slot already closes. The peer `:entrada :paths` axis rejects `;` via \
4173 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the \
4174 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4175 workspace directory name carries no shell-command-separator semantic."
4176 )]
4177 FonteCaminhoShellSemicolon { nome: String, caminho: String },
4178 #[error(
4179 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4180 background / list-AND metacharacter `&` (every interactive shell — bash / zsh \
4181 / fish / nushell — lexes `&` two ways: single `&` as the background-task \
4182 terminator detaching the prior command and returning control immediately to \
4183 the prompt, double `&&` as the logical-AND list operator firing the next \
4184 command only if the prior succeeded; POSIX `std::path::Path` treats it as a \
4185 literal byte. The canonical paste-from-shell-prompt footgun is a `cd path & \
4186 sleep 1` background-launch one-liner or a `cd path && make install` build-\
4187 chain idiom selected whole into the `:caminho` slot — the prior `;` arm at \
4188 05c358e closed the sequential-command-separator vector, this arm closes the \
4189 orthogonal background-task / logical-AND vector on the same paste-from-shell-\
4190 prompt class. The lacre pipeline embeds the value verbatim in its per-dep \
4191 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4192 byte lands in the BLAKE3 closure and rides into every shell-spawned \
4193 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4194 future operator-side `nix` spawn) as the canonical shell-metachar injection \
4195 surface every peer single-token-shaped typed slot already closes. The peer \
4196 `:entrada :paths` axis rejects `&` via `is_gateway_api_http_path`'s eleven-\
4197 byte RFC-3986-reserved set. Express the path as a bare relative single-token \
4198 like \"../caixa-teia\" — the sibling-workspace directory name carries no \
4199 shell-background / logical-AND semantic."
4200 )]
4201 FonteCaminhoShellBackground { nome: String, caminho: String },
4202 #[error(
4203 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4204 command-substitution metacharacter `` ` `` (every POSIX shell — sh / bash / zsh / \
4205 dash / ksh / fish / nushell — lexes the byte as the legacy command-substitution \
4206 wrapper that runs the enclosed command and substitutes its standard-output \
4207 verbatim into the surrounding word, so a backticked `whoami` expands to the \
4208 current user's name and a backticked `cat /etc/passwd` expands to the file's \
4209 contents — the canonical CWE-78 shell-command-injection vector; POSIX \
4210 `std::path::Path` treats the byte as a literal path-component byte. The canonical \
4211 paste-from-shell-prompt footgun is a `cd ../path/<backtick>whoami<backtick>` legacy substitution \
4212 one-liner or a `cd <backtick>pwd<backtick>/path` working-directory expansion idiom selected whole \
4213 into the `:caminho` slot — the prior `&` arm at e12e4f3 closed the shell-\
4214 background / logical-AND vector, this arm closes the orthogonal command-\
4215 substitution vector on the same paste-from-shell-prompt class (the modern `$()` \
4216 form is gated at leading position by the f4efe9c `FonteCaminhoVarExpansion` arm; \
4217 the legacy backtick form is the orthogonal axis). The lacre pipeline embeds the \
4218 value verbatim in its per-dep content-address `path:{caminho}` at \
4219 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4220 rides into every shell-spawned subprocess (the resolver's `git clone`, a future \
4221 `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4222 shell-metachar injection surface every peer single-token-shaped typed slot \
4223 already closes. The peer `:entrada :paths` axis rejects the byte via \
4224 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. Express the path \
4225 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4226 directory name carries no shell-command-substitution semantic."
4227 )]
4228 FonteCaminhoShellCommandSubstitution { nome: String, caminho: String },
4229 #[error(
4230 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4231 glob / pathname-expansion metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — \
4232 sh / bash / zsh / dash / ksh / fish / nushell — lexes `*` and `?` as pathname-\
4233 expansion wildcards: `*` matches any sequence of characters in a path component \
4234 and `?` matches exactly one character, so a `:caminho \"../caixa-teia/*\"` is the \
4235 canonical paste-from-shell-listing footgun where an author copies a \
4236 `ls ../caixa-teia/*` listing without trimming the wildcard, and `:caminho \
4237 \"../foo?\"` is the symmetric single-char-wildcard paste shape; POSIX \
4238 `std::path::Path` treats both bytes as literal path-component bytes, so the \
4239 resolver folds the value through `Path::new(caminho).join(<file>)` looking for \
4240 a literal `./{caminho}` subdirectory and fails at resolve time with a non-self-\
4241 locating `No such file or directory` error far from the source caixa.lisp. The \
4242 lacre pipeline embeds the value verbatim in its per-dep content-address \
4243 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the \
4244 BLAKE3 closure and rides into every shell-spawned subprocess (the resolver's \
4245 `git clone`, a future `feira tofu` shell-out, a future operator-side `nix` \
4246 spawn) as the canonical shell-metachar / glob-expansion surface every peer \
4247 single-token-shaped typed slot already closes. The peer `:entrada :paths` axis \
4248 rejects `*` and `?` via `is_gateway_api_http_path`'s eleven-byte RFC-3986-\
4249 reserved set. Express the path as a bare relative single-token like \
4250 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-glob \
4251 / pathname-expansion semantic.",
4252 ch = *byte as char
4253 )]
4254 FonteCaminhoShellGlob {
4255 nome: String,
4256 caminho: String,
4257 byte: u8,
4258 },
4259 #[error(
4260 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4261 subshell-grouping metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / \
4262 zsh / dash / ksh / fish / nushell — lexes `(` and `)` as the subshell-grouping \
4263 operator: `(<cmd>)` runs `<cmd>` in a child shell with a fresh environment scope \
4264 (the canonical `(cd <path> && <cmd>)` shell-history one-liner scopes a `cd` to one \
4265 subshell without disturbing the parent's working directory), and `$(<cmd>)` is the \
4266 modern Bourne command-substitution shape the leading-`$` `FonteCaminhoVarExpansion` \
4267 arm closes the leading byte of — together the two arms now structurally exclude the \
4268 entire `$(<cmd>)` substitution surface from the typed `:caminho` accepted set. \
4269 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4270 `:caminho \"../caixa-teia/$(date)/build\"` (the canonical paste-from-shell-history \
4271 modern-command-substitution footgun) or `:caminho \"../(cd foo && pwd)/caixa-teia\"` \
4272 (the symmetric subshell-grouping working-directory-probe paste idiom) silently passes \
4273 every prior arm and the resolver folds the value through `Path::new(caminho).join(\
4274 <file>)` looking for a literal subdirectory and fails at resolve time with a non-\
4275 self-locating `No such file or directory` error far from the source caixa.lisp. The \
4276 lacre pipeline embeds the value verbatim in its per-dep content-address `path:\
4277 {caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 \
4278 closure and rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4279 future `feira tofu` shell-out, a future operator-side `nix` spawn) as the canonical \
4280 shell-metachar / subshell-grouping surface every peer single-token-shaped typed slot \
4281 already closes. The peer `:fonte :repo` axis (3b99147) closes the same byte under the \
4282 same shell-subshell-grouping / RFC-3986-sub-delims banner on `is_git_repo_url`, \
4283 together with the leading-`$` `FonteCaminhoVarExpansion` arm closing the leading byte \
4284 of every `$(<cmd>)` shape. Express the path as a bare relative single-token \
4285 like \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4286 subshell-grouping semantic.",
4287 ch = *byte as char
4288 )]
4289 FonteCaminhoShellSubshellGrouping {
4290 nome: String,
4291 caminho: String,
4292 byte: u8,
4293 },
4294 #[error(
4295 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4296 brace-expansion / URI-Template placeholder metacharacter 0x{byte:02x} `{ch}` \
4297 (every POSIX-derived brace-expanding shell — bash / zsh / ksh / fish — lexes `{{` / \
4298 `}}` as the brace-expansion operator: `{{a,b,c}}` expands to the cross-product of \
4299 comma-separated members and `{{1..10}}` expands to the integer range — the \
4300 canonical `mkdir -p ../{{caixa-teia,caixa-helm,caixa-flux}}` / `cp file{{,.bak}}` \
4301 idiom every shell-history block carries; RFC 6570 reserves the matched pair for \
4302 URI Template placeholders (the canonical `https://{{host}}/{{org}}/{{repo}}` \
4303 substitution shape every OpenAPI / Swagger / Postman / GitHub Octokit client \
4304 library / Helm chart-URL fragment carries) and the Mustache / Handlebars / \
4305 Tera / Jinja2 / Go html/template doubled-brace substitution form every IaC \
4306 templating engine (Helm, Kustomize, Terraform's `${{var}}` cousin) emits. POSIX \
4307 `std::path::Path` treats the byte as a literal path-component byte, so a \
4308 `:caminho \"../{{caixa-teia,caixa-helm}}/build\"` (the canonical paste-from-\
4309 shell-history brace-expansion fan-across-siblings footgun) or `:caminho \"../{{{{org}}}}/\
4310 caixa-teia\"` (the symmetric paste-from-templated-doc URI-Template placeholder \
4311 idiom every README quick-start / OpenAPI spec / Helm chart `home:` field carries) \
4312 silently passes every prior arm and the resolver folds the value through \
4313 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4314 resolve time with a non-self-locating `No such file or directory` error far from \
4315 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its \
4316 per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4317 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4318 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a \
4319 future operator-side `nix` spawn) as the canonical shell-metachar / brace-\
4320 expansion / URI-Template-placeholder surface every peer single-token-shaped \
4321 typed slot already closes. The peer `:fonte :repo` axis (42d8f9d) closes the \
4322 same byte pair on `is_git_repo_url` under the same RFC-3986-'delims' / \
4323 RFC-6570-URI-Template / shell-brace-expansion banner. Express the path as a \
4324 bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4325 directory name carries no shell-brace-expansion / URI-Template-placeholder \
4326 semantic; if two siblings actually need pinning, author two separate `:deps` \
4327 entries rather than one brace-expanded `:caminho` value.",
4328 ch = *byte as char
4329 )]
4330 FonteCaminhoShellBraceExpansion {
4331 nome: String,
4332 caminho: String,
4333 byte: u8,
4334 },
4335 #[error(
4336 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4337 bracket-expansion / POSIX glob-character-class / shell-`test`-builtin metacharacter \
4338 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / nushell \
4339 — lexes the bracket pair as the glob character-class operator: `[abc]` matches one of \
4340 `a` / `b` / `c`, `[a-z]` matches any lowercase ASCII letter, `[^x]` negates — the \
4341 canonical `ls *.[ch]` C-source-file glob and `cd ../caixa-[a-z]*` lowercase-sibling \
4342 glob every shell-history block carries; the bracket pair additionally carries the \
4343 POSIX `test` / `[` builtin command (`[ -d ../caixa-teia ] && cd ...` every shell-\
4344 script conditional uses) and bash's `[[ ... ]]` extended-test grammar; beyond shell \
4345 the pair is the TOML inline-array delimiter (`features = [\"a\", \"b\"]` — the \
4346 canonical paste-from-Cargo-manifest cross-idiom-leak vector), the YAML flow-sequence \
4347 delimiter (`paths: [/a, /b]` — the canonical paste-from-values.yaml cross-idiom \
4348 leak), the JSON array delimiter, and the POSIX-ERE / PCRE bracket-expression anchor. \
4349 POSIX `std::path::Path` treats the byte as a literal path-component byte, so a \
4350 `:caminho \"../caixa-[a-z]/build\"` (the canonical paste-from-shell-history glob-\
4351 character-class fan-across-siblings footgun) or `:caminho \"../[caixa-teia]/build\"` \
4352 (the symmetric paste-from-TOML-array / paste-from-YAML-flow-sequence cross-idiom \
4353 leak) silently passes every prior arm and the resolver folds the value through \
4354 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4355 resolve time with a non-self-locating `No such file or directory` error far from \
4356 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4357 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4358 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4359 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4360 `nix` spawn) as the canonical shell-metachar / glob-character-class / TOML-array \
4361 surface every peer single-token-shaped typed slot already closes. Express the path \
4362 as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4363 directory name carries no shell-bracket-expansion / glob-character-class / array-\
4364 literal semantic; if a family of sibling caixas actually needs pinning, author \
4365 separate `:deps` entries rather than one character-class-expanded `:caminho` value.",
4366 ch = *byte as char
4367 )]
4368 FonteCaminhoShellBracketExpansion {
4369 nome: String,
4370 caminho: String,
4371 byte: u8,
4372 },
4373 #[error(
4374 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4375 quote-grouping / cross-config-DSL string-literal-delimiter metacharacter \
4376 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4377 nushell — lexes `'` as the strong string-literal delimiter (`'…'` — no expansion) \
4378 and `\"` as the weak string-literal delimiter (`\"…\"` — variable- / command-\
4379 substitution-preserving); the canonical `cd '../caixa-teia'` shell-history idiom \
4380 every path-with-embedded-whitespace paste block carries and the symmetric \
4381 `git clone \"$REPO\"` weak-quoted CI-manifest shape both leak the pair verbatim. \
4382 Beyond shell the pair is the JSON string-literal delimiter (`\"key\": \"value\"` — \
4383 the canonical paste-from-JSON-config cross-idiom-leak vector), the YAML double- \
4384 and single-quoted flow-scalar delimiter (`path: \"../caixa-teia\"` — the canonical \
4385 paste-from-values.yaml / paste-from-K8s-YAML-manifest cross-idiom leak), the TOML \
4386 basic and literal string delimiter (`path = \"../caixa-teia\"` — the canonical \
4387 paste-from-Cargo-manifest cross-idiom leak), the tatara-lisp string-literal \
4388 delimiter itself (`(:caminho \"../caixa-teia\")` — the canonical \"I copied the \
4389 entire `:caminho \"...\"` slot rather than just the string body\" author-surface \
4390 footgun), and RFC 3986 §2.2's `gen-delims` / `sub-delims` grammar which excludes \
4391 both bytes from the `pchar = unreserved / pct-encoded / sub-delims / \":\" / \"@\"` \
4392 production. POSIX `std::path::Path` treats the byte as a literal path-component \
4393 byte, so a `:caminho \"'../caixa-teia'\"` (the canonical paste-from-shell-history \
4394 strong-quoted sibling-workspace path footgun) or `:caminho \"\\\"../caixa-teia\\\"\"` \
4395 (the symmetric weak-quoted paste-from-JSON / paste-from-YAML flow-scalar / paste-\
4396 from-TOML basic-string / paste-from-tatara-lisp string-literal cross-idiom-leak \
4397 shape) silently passes every prior arm and the resolver folds the value through \
4398 `Path::new(caminho).join(<file>)` looking for a literal subdirectory and fails at \
4399 resolve time with a non-self-locating `No such file or directory` error far from \
4400 the source caixa.lisp. The lacre pipeline embeds the value verbatim in its per-dep \
4401 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte \
4402 lands in the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4403 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-side \
4404 `nix` spawn) as the canonical shell-metachar / string-literal-delimiter surface \
4405 every peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4406 axis closes both bytes under the same shell-quote-grouping / RFC-3986-sub-delims \
4407 banner (e7a109f `'` shell-single-quote + 4267d8b `\"` shell-double-quote on \
4408 `is_git_repo_url`). Express the path as a bare relative single-token like \
4409 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-quote-\
4410 grouping / string-literal-delimiter semantic; strip the outer quote pair from the \
4411 paste (the tatara-lisp `:caminho \"...\"` slot already carries the string-literal \
4412 quoting on the outer syntactic layer, so an inner quote pair would nest and \
4413 desugar to a broken layer).",
4414 ch = *byte as char
4415 )]
4416 FonteCaminhoShellQuoteGrouping {
4417 nome: String,
4418 caminho: String,
4419 byte: u8,
4420 },
4421 #[error(
4422 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4423 comment / URL-fragment-identifier / YAML-comment cross-config-DSL metacharacter \
4424 0x{byte:02x} `{ch}` (every POSIX shell — sh / bash / zsh / dash / ksh / fish / \
4425 nushell — lexes an unquoted `#` at the head of a word or after unquoted \
4426 whitespace as the comment-lead per POSIX.1-2017 §2.3 Token Recognition step 6, \
4427 discarding the byte and everything after it to the end of the physical line \
4428 before command parsing (`cd ../caixa-teia # legacy sibling` — the canonical \
4429 paste-from-shell-history-with-trailing-annotation shape every operator-notebook \
4430 and CI-manifest carries); YAML 1.2 §6.6 makes `#` the comment-lead at any \
4431 position preceded by whitespace or at line-start (`path: ../caixa-teia # pin` \
4432 — the canonical paste-from-values.yaml / paste-from-K8s-manifest cross-idiom-\
4433 leak); RFC 3986 §3.5 reserves `#` as the URL fragment-identifier delimiter (the \
4434 canonical paste-from-browser-address-bar `github.com/foo/bar#readme` / \
4435 `github.com/foo/bar#L42` permalink shape, and the symmetric Nix-flake-ref \
4436 cross-idiom leak `github:foo/bar#packageName` where `#` selects a flake \
4437 output); the same cross-config-DSL surface extends to HCL / Terraform / Nix \
4438 flake attributes / dotenv `.env` / gitconfig / .gitignore / ini / TOML where \
4439 `#` is likewise the comment-lead. POSIX `std::path::Path` treats the byte as a \
4440 literal path-component byte, so a `:caminho \"../caixa-teia # legacy sibling\"` \
4441 (the canonical paste-from-shell-history-with-trailing-annotation footgun), \
4442 `:caminho \"../caixa-teia # pin\"` (the symmetric YAML flow-scalar paste-with-\
4443 trailing-comment shape), or `:caminho \"../caixa-teia#readme\"` (the URL \
4444 fragment paste-from-browser-address-bar shape) silently passes every prior arm \
4445 and the resolver folds the value through `Path::new(caminho).join(<file>)` \
4446 looking for a literal subdirectory named `../caixa-teia # legacy sibling` and \
4447 fails at resolve time with a non-self-locating `No such file or directory` \
4448 error far from the source caixa.lisp — while every downstream shell / YAML / \
4449 URL parser silently truncates the value at the `#` byte to `../caixa-teia`, so \
4450 a `feira tofu` shell-out and a `nix flake check` on an emitted YAML `path:` \
4451 scalar disagree with the resolver on which directory the value names. The \
4452 lacre pipeline embeds the value verbatim in its per-dep content-address \
4453 `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the byte lands in \
4454 the BLAKE3 closure and rides into every shell-spawned subprocess (the \
4455 resolver's `git clone`, a future `feira tofu` shell-out, a future operator-\
4456 side `nix` spawn) as the canonical shell-metachar / comment-lead / URL-\
4457 fragment-delimiter surface every peer single-token-shaped typed slot already \
4458 closes. The peer `:fonte :repo` axis closes the byte under the same URL-\
4459 fragment-identifier banner (a68f818 `#` on `is_git_repo_url`). Express the \
4460 path as a bare relative single-token like \"../caixa-teia\" — the sibling-\
4461 workspace directory name carries no shell-comment / URL-fragment / YAML-\
4462 comment semantic; move any trailing annotation to a tatara-lisp `;`-comment \
4463 on the surrounding form (`;; legacy sibling` above the `(:caminho ...)` slot) \
4464 and drop any `#fragment` tail entirely (fragment identifiers select \
4465 renderings, not directories, and `:caminho` names a directory).",
4466 ch = *byte as char
4467 )]
4468 FonteCaminhoShellComment {
4469 nome: String,
4470 caminho: String,
4471 byte: u8,
4472 },
4473 #[error(
4474 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains URL-\
4475 percent-encoding-escape / printf-format-specifier / bash-job-control-specifier \
4476 / YAML-directive-lead metacharacter 0x{byte:02x} `{ch}` (RFC 3986 §2.1 reserves \
4477 `%` as the URL percent-encoding-escape — `%HH` is the mandatory encoding \
4478 mechanism for every byte outside the `unreserved` alphanumeric / `-` / `.` / \
4479 `_` / `~` set, and `%` itself must be percent-encoded as `%25` to appear \
4480 literally inside a URL value. The canonical paste-from-browser-address-bar \
4481 percent-encoded-space footgun (an author copies `../caixa%20teia` out of a URL-\
4482 encoded README hyperlink / browser address bar / percent-encoded permalink \
4483 expecting `%20` to decode to a literal space at the filesystem layer) locks two \
4484 distinct BLAKE3 closures (`path:../caixa%20teia` vs `path:../caixa teia`) for \
4485 what the author intended as the byte-identical sibling-workspace dep. POSIX \
4486 `std::path::Path` treats the byte as a literal path-component byte, so \
4487 `Path::join` looks for a literal `./{caminho}` subdirectory and fails at \
4488 resolve time with a non-self-locating `No such file or directory` error far \
4489 from the source caixa.lisp — while every downstream URL parser / shell printf \
4490 builtin / YAML directive parser silently reinterprets the byte to a different \
4491 value than the resolver's `Path::join` sees. Beyond the URL-encoding hazard, \
4492 `%` is the C / POSIX printf format-directive lead-in (`%s`, `%d`, `%02x` — \
4493 wired into every POSIX shell's `printf` builtin, the canonical CWE-134 format-\
4494 string-injection vector); the bash / zsh / ksh job-control-specifier lead-in \
4495 (`%1` names \"job 1\", `%%` names \"the current job\", `%foo` names \"the most \
4496 recent job whose command started with `foo`\" — a future `kill %1` invocation \
4497 silently redirects the signal to a wrong target); the YAML 1.2 §6.8.1 \
4498 directive lead-in (`%YAML 1.2` / `%TAG` — the paste-from-top-of-doc YAML \
4499 directive block cross-idiom leak); and the Windows-shell env-var-reference \
4500 lead-in (`%PATH%` — the paste-from-`.bat` / paste-from-PowerShell-`%env:PATH%` \
4501 cross-idiom leak). The lacre pipeline embeds the value verbatim in its per-dep \
4502 content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, so the \
4503 byte lands in the BLAKE3 closure and rides into every shell-spawned subprocess \
4504 (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4505 operator-side `nix` spawn) as the canonical URL-percent-encoding-escape / \
4506 printf-format-specifier / job-control-specifier surface every peer single-\
4507 token-shaped typed slot already closes. The peer `:fonte :repo` axis closes \
4508 the byte under the same URL-percent-encoding-escape banner (a323db8 `%` on \
4509 `is_git_repo_url`). Express the path as a bare relative single-token like \
4510 \"../caixa-teia\" — the sibling-workspace directory name carries no URL-\
4511 percent-encoding-escape / format-specifier / job-control semantic; substitute \
4512 any `%20` percent-encoded-space with a literal space then reject the whole \
4513 value at the leading-whitespace / embedded-`?` arm on the same axis (a caixa \
4514 directory name never carries an embedded space in practice); drop any \
4515 `%2F`-encoded path separator in favor of a literal `/`; and drop any leading \
4516 `%YAML` / `%PATH%` cross-idiom-leak prefix entirely.",
4517 ch = *byte as char
4518 )]
4519 FonteCaminhoUrlPercentEncoding {
4520 nome: String,
4521 caminho: String,
4522 byte: u8,
4523 },
4524 #[error(
4525 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4526 variable-expansion / command-substitution / arithmetic-expansion / cross-config-\
4527 DSL-interpolation metacharacter 0x{byte:02x} `{ch}` (every POSIX shell — sh / \
4528 bash / zsh / dash / ksh / busybox ash / fish / nushell — lexes `$` per \
4529 POSIX.1-2017 §2.6 as the variable-expansion `$<name>` / braced-form `${{<name>}}` \
4530 / command-substitution `$(<cmd>)` / arithmetic-expansion `$((<expr>))` operator; \
4531 Nix uses `${{var}}` as the string-interpolation lead, Make uses `$(var)` / `$@` \
4532 / `$<` for variables and automatic-variables, JavaScript / TypeScript template \
4533 literals use `${{expr}}` for interpolation, envsubst / Kubernetes / OpenShift \
4534 templates use `${{VAR}}` for env-var-reference, PHP uses `$_GET` / `$_ENV` for \
4535 superglobals, Perl uses `$foo` for scalars, SASS / SCSS uses `$primary-color` \
4536 for variables, and PostgreSQL / SQLite use `$1` / `$2` for bind parameters — \
4537 the byte is a first-class parser byte in nearly every config / templating / \
4538 build-system DSL the substrate's paste-idiom surface routinely crosses. POSIX \
4539 `std::path::Path` treats the byte as a literal path-component byte, so the \
4540 canonical paste-from-shell-one-liner `:caminho \"../foo$HOME/bar\"` / paste-\
4541 from-CI-manifest `:caminho \"../foo${{WORKSPACE}}/bar\"` / paste-from-shell-\
4542 prompt `:caminho \"../foo$(whoami)/bar\"` footguns silently pass every prior \
4543 cascade arm (`$` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / \
4544 `?` / `(` / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%`) and route \
4545 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4546 subdirectory that fails at resolve time with a non-self-locating `No such file \
4547 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4548 the value verbatim in its per-dep content-address `path:{caminho}` at \
4549 caixa-resolver/src/resolve.rs:189, so byte-identical caixa.lisp values differing \
4550 only in whether the author substituted `$HOME` / `${{WORKSPACE}}` at author \
4551 time lock to two distinct BLAKE3 closures across two workstations whose \
4552 downstream envsubst / Nix / Make / K8s-template layers differ in `$VAR` \
4553 recognition — defeating the THEORY.md §V.2 render-determinism contract on the \
4554 same axis every prior `:caminho` arm protects. Beyond the determinism vector, \
4555 `$` at any position in a value flowing verbatim into a shell-spawned subprocess \
4556 is the canonical CWE-78 shell-command-injection surface every peer single-\
4557 token-shaped typed slot already closes: peer `:fonte :repo` axis rejects `$` \
4558 under the shell-variable-expansion / URL-sub-delim banner via `is_git_repo_url` \
4559 (b9d187c), peer `:fonte :tag` / `:fonte :branch` axes reject `$` as part of \
4560 `is_git_ref_name`'s printable-ASCII-restricted grammar (`git check-ref-format` \
4561 rejects the byte outright), and peer `:entrada :paths` axis rejects `$` via \
4562 `is_gateway_api_http_path`'s eleven-byte RFC-3986-reserved set. The leading-`$` \
4563 position on the same axis routes through `FonteCaminhoVarExpansion` at the \
4564 f4efe9c leading-byte arm; this arm closes the last positional gap on the byte \
4565 so every position — leading and embedded — is structurally rejected. Substitute \
4566 the `$VAR` / `${{VAR}}` / `$(cmd)` template with the literal value at author \
4567 time, or express the path as a bare relative single-token like \
4568 \"../caixa-teia\" — the sibling-workspace directory name carries no shell-\
4569 variable-expansion / command-substitution / arithmetic-expansion semantic.",
4570 ch = *byte as char
4571 )]
4572 FonteCaminhoShellVariableExpansion {
4573 nome: String,
4574 caminho: String,
4575 byte: u8,
4576 },
4577 #[error(
4578 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4579 history-expansion / RFC-3986-sub-delims / bang-operator metacharacter 0x{byte:02x} \
4580 `{ch}` (every interactive POSIX shell with history enabled — bash / ksh / zsh's \
4581 `bashcompat` / csh / tcsh — lexes `!` as the history-expansion prefix per bash \
4582 reference §9.3: `!command` re-runs the most recent history entry beginning with \
4583 `command`, `!!` re-runs the prior command verbatim, `!$` substitutes the last \
4584 word of the prior command, `!:N` substitutes the Nth word of the prior command, \
4585 and the substitution fires at every history-expansion-enabled shell context — \
4586 `set -o histexpand` is bash's default for interactive sessions and the layer \
4587 every `feira tofu` / `git clone` / `nix flake check` subprocess-argument \
4588 invocation crosses when spawned under `bash -i`. Beyond shell history, RFC 3986 \
4589 §2.2 lists `!` in the `sub-delims` set (the URL grammar admits the byte inside \
4590 a path segment, but every WHATWG-conformant special-scheme URL parser percent-\
4591 encodes it inside a query component via the 'special-query percent-encode set' \
4592 the peer `is_git_repo_url` `*` / `(` / `)` / `'` arms close on); the byte is \
4593 also the C / C++ / Rust / JavaScript / Python bang-operator (logical-negation \
4594 prefix — the paste-from-source-code idiom where an author copies \
4595 `!path.exists()` out of a Rust snippet and the trailing punctuation crosses \
4596 the string-literal boundary); the canonical English-typography emphasis / \
4597 exclamation mark (the paste-from-prose enthusiasm-form idiom where an author \
4598 writes `:caminho \"../caixa-teia!\"` expecting the substrate to coerce it to a \
4599 kebab-case slug); and the Nix flake-ref attribute-selection operator surface. \
4600 POSIX `std::path::Path` treats `!` as a literal path-component byte, so the \
4601 canonical paste-from-shell-history footgun `:caminho \"../caixa-teia!sudo\"` \
4602 (an author copies a `cd ../caixa-teia && !sudo make install` one-liner from a \
4603 quick-start README and the trailing `!sudo` rides in verbatim as a history-\
4604 expansion reference), the symmetric `:caminho \"../foo!!/bar\"` (the `!!` \
4605 repeat-prior-command paste idiom), the English-typography `:caminho \
4606 \"../caixa-teia!\"` (paste-from-prose enthusiasm-form), and the last-word-\
4607 substitution `:caminho \"../foo!$\"` shape silently pass every prior cascade \
4608 arm (`!` isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` \
4609 / `)` / `{{` / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$`) and route \
4610 through `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` \
4611 subdirectory that fails at resolve time with a non-self-locating `No such file \
4612 or directory` error far from the source caixa.lisp. The lacre pipeline embeds \
4613 the value verbatim in its per-dep content-address `path:{caminho}` at \
4614 caixa-resolver/src/resolve.rs:189, so the byte lands in the BLAKE3 closure and \
4615 rides into every shell-spawned subprocess (the resolver's `git clone`, a \
4616 future `feira tofu` shell-out, a future operator-side `nix flake check` spawn) \
4617 as the canonical shell-history-expansion / RFC-3986-sub-delims surface every \
4618 peer single-token-shaped typed slot already closes. The peer `:fonte :repo` \
4619 axis closes the byte under the same shell-history-expansion / RFC-3986-sub-\
4620 delims banner (7d53c68 `!` on `is_git_repo_url`). Express the path as a bare \
4621 relative single-token like \"../caixa-teia\" — the sibling-workspace directory \
4622 name carries no shell-history-expansion / bang-operator semantic; drop any \
4623 `!sudo` / `!!` / `!$` history-expansion trailing paste-from-shell-history \
4624 idiom; and drop any trailing English-typography exclamation mark that pasted \
4625 from prose.",
4626 ch = *byte as char
4627 )]
4628 FonteCaminhoShellHistoryExpansion {
4629 nome: String,
4630 caminho: String,
4631 byte: u8,
4632 },
4633 #[error(
4634 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} contains shell-\
4635 history-substitution / RFC-3986-'unwise' / regex-negation metacharacter 0x{byte:02x} \
4636 `{ch}` (POSIX bash's `set -o histexpand` mode — the default for every interactive \
4637 session and every `bash -i` subprocess-argument context `feira tofu` / `git clone` / \
4638 `nix flake check` cross — lexes `^old^new^` per bash reference §9.3 as the 'quick \
4639 substitution' history operator that rewrites the prior command's `old` string to \
4640 `new` and re-executes it verbatim, the canonical typo-correction one-liner idiom \
4641 (`git clone <bad-url>` → `^bad^good` typo-fix-and-rerun the paste-from-shell-\
4642 history author trims only the leading `git clone` prefix from). RFC 3986 §2 lists \
4643 `^` in the 'unwise' set every URL parser is required to percent-encode-or-refuse at \
4644 the wire boundary, and the WHATWG URL spec's 'fragment percent-encode set' maps \
4645 `^` → `%5E` at the query / fragment component transition, so `Path::join` on the \
4646 literal value diverges from every downstream `feira tofu` curl-invocation / \
4647 artifact-registry-fetch that percent-encodes the byte before the wire. `^` is also \
4648 the regex character-class negation prefix (`[^abc]`), the bitwise XOR operator in \
4649 C / C++ / Rust / Python / JavaScript / Nix / Go, the Windows `cmd.exe` escape \
4650 metacharacter, and the LaTeX / Markdown / BibTeX superscript operator. POSIX \
4651 `std::path::Path` treats `^` as a literal path-component byte, so \
4652 `:caminho \"../foo^bar/baz\"` (embedded quick-substitution), `:caminho \
4653 \"../foo^\"` (trailing history-substitution-open shape), or `:caminho \"../x^y\"` \
4654 (XOR-expression paste-from-source) silently pass every prior cascade arm (`^` \
4655 isn't `\\` / `<` / `>` / `|` / `;` / `&` / backtick / `*` / `?` / `(` / `)` / `{{` \
4656 / `}}` / `[` / `]` / `'` / `\"` / `#` / `%` / `$` / `!`) and route through \
4657 `Path::new(caminho).join(<file>)` looking for a literal `./{caminho}` subdirectory \
4658 that fails at resolve time with a non-self-locating `No such file or directory` \
4659 error far from the source caixa.lisp. The lacre pipeline embeds the value verbatim \
4660 in its per-dep content-address `path:{caminho}` at caixa-resolver/src/resolve.rs:189, \
4661 so the byte lands in the BLAKE3 closure and rides into every shell-spawned \
4662 subprocess (the resolver's `git clone`, a future `feira tofu` shell-out, a future \
4663 operator-side `nix flake check` spawn) as the canonical shell-history-substitution \
4664 / RFC-3986-unwise surface every peer single-token-shaped typed slot already closes. \
4665 The peer `:fonte :repo` axis closes the byte under the same shell-history-\
4666 substitution / RFC-3986-unwise banner (49e142f `^` on `is_git_repo_url`). Together \
4667 with the immediate-predecessor `!` arm (6a04767) this arm closes the full `set -o \
4668 histexpand` operator surface on the `:caminho` axis — the `!command` / `!!` / `!$` \
4669 prefix form via `!`, the `^old^new^` quick-substitution form via `^`. Express the \
4670 path as a bare relative single-token like \"../caixa-teia\" — the sibling-workspace \
4671 directory name carries no shell-history-substitution / regex-negation / XOR-operator \
4672 semantic; drop any `^old^new` history-substitution paste-from-shell-history idiom; \
4673 drop any trailing `^` history-substitution-open fragment.",
4674 ch = *byte as char
4675 )]
4676 FonteCaminhoShellHistorySubstitution {
4677 nome: String,
4678 caminho: String,
4679 byte: u8,
4680 },
4681 #[error(
4682 ":deps entry {nome:?} :fonte (:tipo path …) :caminho {caminho:?} has a trailing \
4683 `/` (the resolver's `Path::join` resolves `\"../caixa-teia\"` and \
4684 `\"../caixa-teia/\"` to the same directory, but the lacre pipeline embeds the \
4685 value verbatim in its per-dep content-address `path:{caminho}` at \
4686 caixa-resolver/src/resolve.rs:189, so two authors whose only difference is \
4687 shell tab-completion emit byte-divergent BLAKE3 closures for the same caixa — \
4688 defeating the THEORY.md §V.2 render-determinism contract via the trailing-\
4689 separator vector (the canonical paste-from-shell-tab-completion + paste-from-\
4690 `pwd`-with-`/`-suffix footgun, and the canonical Cargo-style `path = \
4691 \"../caixa-teia/\"` paste-from-Cargo-manifest cross-idiom leak). Drop the \
4692 trailing `/`; every `:caminho` value names a sibling-workspace directory \
4693 already, so the trailing separator carries no information. Use \
4694 `\"../caixa-teia\"` rather than `\"../caixa-teia/\"`)"
4695 )]
4696 FonteCaminhoTrailingSlash { nome: String, caminho: String },
4697 #[error(
4698 "{list} carries duplicate entry :nome {nome:?} — every dep list keys its \
4699 entries by caixa name (Cargo's [dependencies] / [dev-dependencies] tables \
4700 apply the same set-not-multiset discipline; one package per table), and \
4701 two entries naming the same caixa carry two version constraints / source \
4702 pins / feature sets for one identity. The caixa-resolver's lacre pipeline \
4703 consumes the list as a `HashMap`-keyed-by-`:nome` lookup: the second entry \
4704 silently overwrites the first at the resolver-side `concrete_versao` step, \
4705 and the dropped entry's pin / features never reach the closure — far from \
4706 the source caixa.lisp, with no field naming which `:deps` entry was the \
4707 silent loser. If two version constraints are genuinely needed (the rare \
4708 multi-version closure case the lacre pipeline doesn't yet support), the \
4709 author surface is two distinct caixa names (e.g. a `caixa-teia-v01` / \
4710 `caixa-teia-v02` aliased pair); within one list, one entry per caixa name."
4711 )]
4712 DuplicateNome { nome: String, list: &'static str },
4713 #[error(
4714 ":deps entry {nome:?} has empty :caracteristicas entry — every feature flag must \
4715 name a non-empty identifier on the target caixa (Cargo's [dependencies.<dep>.features] \
4716 applies the same per-entry non-empty discipline). An empty feature flag reaches the \
4717 caixa-resolver's lacre pipeline as a no-op feature enable, silently dropping the \
4718 author's intent far from the source caixa.lisp; drop the empty entry, or replace it \
4719 with the canonical kebab-case feature name the target caixa declares."
4720 )]
4721 CaracteristicaEmpty { nome: String },
4722 #[error(
4723 ":deps entry {nome:?} :caracteristicas entry {caracteristica:?} is not a valid Cargo \
4724 feature name: {reason} (the value flows verbatim into Cargo's \
4725 [dependencies.<dep>.features] list and Cargo's `restricted_names::validate_feature_name` \
4726 parser enforces the same shape at `cargo metadata` time; use a single-token \
4727 identifier like `\"http\"`, `\"derive\"`, or `\"runtime-tokio\"` — kebab-case ASCII \
4728 alphanumeric with `-`, `_`, `+`, or `.` as continuation characters, starting with \
4729 an ASCII alphanumeric or `_`)"
4730 )]
4731 CaracteristicaInvalid {
4732 nome: String,
4733 caracteristica: String,
4734 reason: String,
4735 },
4736 #[error(
4737 ":deps entry {nome:?} :caracteristicas carries duplicate feature {caracteristica:?} — \
4738 every feature-flag list keys its entries by name (Cargo's \
4739 [dependencies.<dep>.features] applies the same set-not-multiset discipline; one entry \
4740 per feature per dep), and two entries naming the same feature are a redundant \
4741 set-membership declaration for one identity (the feature-toggle slot is set-shaped; \
4742 enabling a feature twice has no additional semantic). The caixa-resolver's lacre \
4743 pipeline consumes the list as a set-shaped feature toggle — the resolver enables the \
4744 feature once regardless of declaration count, so the duplicate's pin / position never \
4745 reaches the closure with no field naming the silent loser. One entry per feature per \
4746 dep; if two distinct features are intended, name each verbatim."
4747 )]
4748 CaracteristicaDuplicate {
4749 nome: String,
4750 caracteristica: String,
4751 },
4752 #[error(
4753 "{list} entry :nome {nome:?} names the caixa itself — a caixa cannot depend \
4754 on itself (the lacre closure's dep-graph traversal is rooted at the caixa's \
4755 :nome, and a self-dep would be a one-node cycle the caixa-resolver either \
4756 rejects mid-traversal far from the source caixa.lisp or recurses on until \
4757 it exhausts its stack). Every :nome is globally-unique substrate identity, \
4758 so a :deps / :deps-dev entry whose :nome equals the parent caixa's :nome \
4759 *is* the parent itself, not a coincidentally-named peer. Drop the \
4760 self-referential dep entry — to reference code from this caixa, use \
4761 :bibliotecas / :exe / :servicos (the substrate-blessed shape for \
4762 referencing the caixa's own code surface) instead."
4763 )]
4764 DepIsSelf { nome: String, list: &'static str },
4765}
4766
4767// Fold the eleven `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4768// caminho: caminho.to_string() }` two-slot struct-variant wire-up sites at
4769// [`DepSource::validate_caminho`] onto one substrate primitive per typed
4770// variant — the paired `{ nome: String, caminho: String }` two-slot family
4771// on [`DepError`], sibling of the peer
4772// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4773// on `{ caixa: String }`) on the `SupervisorError` envelope, the peer
4774// [`crate::aplicacao::contrato_empty_pair_ctors!`] (8580068, 4 variants on
4775// `{ de, para }`), [`crate::aplicacao::aplicacao_field_reason_ctors!`]
4776// (981060b, 7 variants on `{ <field>: String, reason: String }`),
4777// [`crate::aplicacao::contrato_target_ctors!`] (14b81d5, 2 variants on
4778// `{ de, para, wit, expected }`), and
4779// [`crate::aplicacao::contrato_pair_value_reason_ctors!`] (14e13f1, 3
4780// variants on `{ de, para, <field>: String, reason: String }`) on the
4781// `AplicacaoError` envelopes, the peer
4782// [`crate::layout::layout_violation_ctors!`] (131ca0d, 16 variants on
4783// `{ caixa, issue }`), [`crate::layout::layout_slot_kind_ctors!`]
4784// (0419438, 4 variants on `{ caixa, kind, slots }`),
4785// [`crate::LayoutError::missing_entry`] (1b09f9d, one variant on
4786// `{ kind, path }`), and [`crate::layout::layout_nome_only_ctors!`]
4787// (3fe3dd7, 6 variants on `<Variant>(String)`) on the `LayoutError`
4788// envelopes, the peer three [`crate::limits::limits_codec_value_*_ctors!`]
4789// codec-family macros (81c856c, 12 wire-ups) on the `LimitsError`
4790// envelope, and the peer [`crate::upgrade::upgrade_from_script_ctors!`]
4791// (8e67041, 3 variants on `{ from: String, script: PathBuf }`) on the
4792// `UpgradeError` envelope. First fold family on this `DepError` envelope.
4793//
4794// Each of the eleven wire-up sites on this shape (the leading-byte cascade
4795// closing the seven `FonteCaminho{Absolute, TildeExpansion, VarExpansion,
4796// LeadingWhitespace, LeadingHyphen}` arms; the orthogonal single-metachar
4797// cascade closing `FonteCaminhoBackslash` on `\`; the shell-lexer-metachar
4798// cascade closing `FonteCaminhoShell{Pipe, Semicolon, Background,
4799// CommandSubstitution}` on the four single-byte shell operators; and the
4800// trailing-`/` reproducibility arm closing `FonteCaminhoTrailingSlash`)
4801// opened the identical `DepError::FonteCaminho<Variant> { nome:
4802// nome.to_string(), caminho: caminho.to_string() }` four-line
4803// struct-literal against the same `(nome: &str, caminho: &str)` local pair
4804// — the exact "same block re-inlined at every consumer" shape the PRIME
4805// DIRECTIVE names as a bug, on the same altitude the peer `LayoutError` /
4806// `AplicacaoError` / `SupervisorError` / `LimitsError` / `UpgradeError`
4807// families each closed on their sibling envelopes. The eleven variants
4808// share one `{ nome: String, caminho: String }` shape, so the fold routes
4809// each wire-up site through one dispatch per typed variant.
4810//
4811// The macro below generates one `#[must_use]` inherent constructor per
4812// variant of shape `fn <ctor>(nome: &str, caminho: &str) -> Self`, so every
4813// wire-up site collapses onto one dispatch:
4814// `DepError::<ctor>(nome, caminho)`, byte-equal to the pre-lift
4815// struct-literal on the same `(&str, &str)` fixture. The uniform two-field
4816// construction (`nome.to_string()` / `caminho.to_string()`) is spelled
4817// once — inside the macro — rather than at every wire-up site.
4818//
4819// The twelve `FonteCaminho<Variant> { nome, caminho, byte }` three-field
4820// shapes at the per-byte-classification arms — the
4821// `FonteCaminho{ControlChar,ShellRedirection,ShellGlob,
4822// ShellSubshellGrouping,ShellBraceExpansion,ShellBracketExpansion,
4823// ShellQuoteGrouping,ShellComment,UrlPercentEncoding,
4824// ShellVariableExpansion,ShellHistoryExpansion,ShellHistorySubstitution}`
4825// cluster — carry an additional `byte: u8` naming the offending byte and
4826// so would break the uniform-two-field routing this macro promises. They
4827// instead fold onto the sibling three-field envelope through
4828// [`fonte_caminho_byte_ctors!`] (this-commit-lift, 12 variants on the
4829// `{ nome, caminho, byte }` shape), whose sole additional axis over this
4830// two-slot family is the `byte: u8` classification the arms carry. The
4831// remaining `FonteCaminhoEmpty` one-field `{ nome }` shape at the empty-
4832// first arm folds instead onto the peer [`dep_nome_only_ctors!`]
4833// (792aa92, 5 variants on `{ nome: String }`) sibling family of this
4834// envelope.
4835//
4836// Every future consumer that wants to construct one of these eleven
4837// variants outside the current in-crate [`DepSource::validate_caminho`]
4838// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4839// at lacre-resolve time re-checking the same value-shape axes the resolver
4840// consumes, a future `feira validate --deps` per-caixa admission verb
4841// re-checking the `:fonte :caminho` axis, a per-lacre overlay resolver
4842// rejecting a `:caminho` value against a cluster-local snapshot) now
4843// reaches each variant through one call rather than re-inlining the
4844// four-line struct-literal in lockstep with the eleven in-crate wire-up
4845// sites.
4846macro_rules! fonte_caminho_ctors {
4847 ($($ctor:ident => $variant:ident),* $(,)?) => {
4848 impl DepError {
4849 $(
4850 #[doc = concat!(
4851 "Construct a [`DepError::",
4852 stringify!($variant),
4853 "`] naming the offending `:deps :nome` + `:fonte ",
4854 "(:tipo path …) :caminho` pair. Folds the uniform ",
4855 "`Self::",
4856 stringify!($variant),
4857 " { nome: nome.to_string(), caminho: caminho.to_string() }` ",
4858 "two-slot struct-literal onto one substrate primitive so ",
4859 "every [`DepSource::validate_caminho`] wire-up on this ",
4860 "variant reads through one dispatch rather than the ",
4861 "pre-lift four-line open-coded block."
4862 )]
4863 #[must_use]
4864 pub fn $ctor(nome: &str, caminho: &str) -> Self {
4865 Self::$variant {
4866 nome: nome.to_string(),
4867 caminho: caminho.to_string(),
4868 }
4869 }
4870 )*
4871 }
4872 };
4873}
4874
4875fonte_caminho_ctors! {
4876 fonte_caminho_absolute => FonteCaminhoAbsolute,
4877 fonte_caminho_tilde_expansion => FonteCaminhoTildeExpansion,
4878 fonte_caminho_var_expansion => FonteCaminhoVarExpansion,
4879 fonte_caminho_leading_whitespace => FonteCaminhoLeadingWhitespace,
4880 fonte_caminho_leading_hyphen => FonteCaminhoLeadingHyphen,
4881 fonte_caminho_backslash => FonteCaminhoBackslash,
4882 fonte_caminho_shell_pipe => FonteCaminhoShellPipe,
4883 fonte_caminho_shell_semicolon => FonteCaminhoShellSemicolon,
4884 fonte_caminho_shell_background => FonteCaminhoShellBackground,
4885 fonte_caminho_shell_command_substitution => FonteCaminhoShellCommandSubstitution,
4886 fonte_caminho_trailing_slash => FonteCaminhoTrailingSlash,
4887}
4888
4889// Fold the twelve `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4890// caminho: caminho.to_string(), byte: b }` three-slot struct-variant wire-up
4891// sites at [`DepSource::validate_caminho`] onto one substrate primitive per
4892// typed variant — the paired `{ nome: String, caminho: String, byte: u8 }`
4893// three-slot family on [`DepError`], strict sibling of the peer
4894// [`fonte_caminho_ctors!`] (f85f145, 11 variants on the two-slot
4895// `{ nome: String, caminho: String }` envelope) of this envelope. Extends
4896// that fold onto the `byte`-classifying arms whose additional `byte: u8`
4897// axis broke its uniform-two-field routing — the exact "future compounding
4898// work" the pre-lift `fonte_caminho_ctors!` prose named as deferred, closed
4899// here. Third fold family on this `DepError` envelope, sibling of the peer
4900// two-slot [`fonte_caminho_ctors!`] and one-slot [`dep_nome_only_ctors!`]
4901// (792aa92, 5 variants on the `{ nome: String }` envelope) families on the
4902// same enum.
4903//
4904// Each of the twelve wire-up sites on this shape (the control-byte arm
4905// closing `FonteCaminhoControlChar` on the sub-`0x20` / `0x7F` cluster; the
4906// shell-lexer-metachar cascade closing `FonteCaminhoShellRedirection` on
4907// `< >`, `FonteCaminhoShellGlob` on `* ?`, `FonteCaminhoShellSubshellGrouping`
4908// on `( )`, `FonteCaminhoShellBraceExpansion` on `{ }`,
4909// `FonteCaminhoShellBracketExpansion` on `[ ]`, and
4910// `FonteCaminhoShellQuoteGrouping` on `' "`; the single-metachar arms
4911// closing `FonteCaminhoShellComment` on `#`, `FonteCaminhoUrlPercentEncoding`
4912// on `%`, `FonteCaminhoShellVariableExpansion` on `$`,
4913// `FonteCaminhoShellHistoryExpansion` on `!`, and
4914// `FonteCaminhoShellHistorySubstitution` on `^`) opened the identical
4915// `DepError::FonteCaminho<Variant> { nome: nome.to_string(),
4916// caminho: caminho.to_string(), byte: b }` five-line struct-literal against
4917// the same `(nome: &str, caminho: &str, b: u8)` local triple — the exact
4918// "same block re-inlined at every consumer" shape the PRIME DIRECTIVE names
4919// as a bug, on the same altitude the peer two-slot `fonte_caminho_ctors!`
4920// closed on the sibling two-field envelope of this same enum. The twelve
4921// variants share one `{ nome: String, caminho: String, byte: u8 }` shape, so
4922// the fold routes each wire-up site through one dispatch per typed variant.
4923//
4924// The macro below generates one `#[must_use]` inherent constructor per
4925// variant of shape `fn <ctor>(nome: &str, caminho: &str, byte: u8) -> Self`,
4926// so every wire-up site collapses onto one dispatch:
4927// `DepError::<ctor>(nome, caminho, b)`, byte-equal to the pre-lift
4928// struct-literal on the same `(&str, &str, u8)` fixture. The uniform
4929// three-field construction (`nome.to_string()` / `caminho.to_string()` /
4930// `byte`) is spelled once — inside the macro — rather than at every wire-up
4931// site.
4932//
4933// Every future consumer that wants to construct one of these twelve
4934// variants outside the current in-crate [`DepSource::validate_caminho`]
4935// wire-up sites (a deferred `caixa-resolver` per-`:caminho` re-validator
4936// at lacre-resolve time re-checking the same value-shape axes the resolver
4937// consumes, a future `feira validate --deps` per-caixa admission verb
4938// re-checking the `:fonte :caminho` axis against the shell-metachar
4939// classification bytes this cluster catches, a per-lacre overlay resolver
4940// rejecting a `:caminho` value against a cluster-local snapshot) now
4941// reaches each variant through one call rather than re-inlining the
4942// five-line struct-literal in lockstep with the twelve in-crate wire-up
4943// sites.
4944macro_rules! fonte_caminho_byte_ctors {
4945 ($($ctor:ident => $variant:ident),* $(,)?) => {
4946 impl DepError {
4947 $(
4948 #[doc = concat!(
4949 "Construct a [`DepError::",
4950 stringify!($variant),
4951 "`] naming the offending `:deps :nome` + `:fonte ",
4952 "(:tipo path …) :caminho` pair + the offending `byte: u8` ",
4953 "classification. Folds the uniform `Self::",
4954 stringify!($variant),
4955 " { nome: nome.to_string(), caminho: caminho.to_string(), ",
4956 "byte }` three-slot struct-literal onto one substrate ",
4957 "primitive so every [`DepSource::validate_caminho`] wire-up ",
4958 "on this variant reads through one dispatch rather than ",
4959 "the pre-lift five-line open-coded block."
4960 )]
4961 #[must_use]
4962 pub fn $ctor(nome: &str, caminho: &str, byte: u8) -> Self {
4963 Self::$variant {
4964 nome: nome.to_string(),
4965 caminho: caminho.to_string(),
4966 byte,
4967 }
4968 }
4969 )*
4970 }
4971 };
4972}
4973
4974fonte_caminho_byte_ctors! {
4975 fonte_caminho_control_char => FonteCaminhoControlChar,
4976 fonte_caminho_shell_redirection => FonteCaminhoShellRedirection,
4977 fonte_caminho_shell_glob => FonteCaminhoShellGlob,
4978 fonte_caminho_shell_subshell_grouping => FonteCaminhoShellSubshellGrouping,
4979 fonte_caminho_shell_brace_expansion => FonteCaminhoShellBraceExpansion,
4980 fonte_caminho_shell_bracket_expansion => FonteCaminhoShellBracketExpansion,
4981 fonte_caminho_shell_quote_grouping => FonteCaminhoShellQuoteGrouping,
4982 fonte_caminho_shell_comment => FonteCaminhoShellComment,
4983 fonte_caminho_url_percent_encoding => FonteCaminhoUrlPercentEncoding,
4984 fonte_caminho_shell_variable_expansion => FonteCaminhoShellVariableExpansion,
4985 fonte_caminho_shell_history_expansion => FonteCaminhoShellHistoryExpansion,
4986 fonte_caminho_shell_history_substitution => FonteCaminhoShellHistorySubstitution,
4987}
4988
4989// Fold the five `DepError::<Variant> { nome: <owner>.clone_or_to_string() }`
4990// single-slot struct-variant wire-up sites scattered across
4991// [`Dep::validate`] / [`Dep::validate_caracteristicas`] /
4992// [`DepSource::validate`] / [`DepSource::validate_caminho`] onto one
4993// substrate primitive per typed variant — the paired `{ nome: String }`
4994// single-slot family on [`DepError`], sibling of the peer
4995// [`fonte_caminho_ctors!`] (f85f145, 11 variants on
4996// `{ nome: String, caminho: String }`) on the sibling two-slot envelope of
4997// the same enum, and of the peer
4998// [`crate::supervisor::supervisor_caixa_only_ctors!`] (db09650, 3 variants
4999// on `{ caixa: String }`) on the `SupervisorError` envelope's single-slot
5000// axis. Second fold family on this `DepError` envelope, and the first on
5001// the single-`{ nome }` shape.
5002//
5003// The five wire-up sites this fold closes each opened the identical
5004// `DepError::<Variant> { nome: <owner>.to_string_or_clone() }` three-line
5005// struct-literal against the same `nome: &str` (or `self.nome: &String`)
5006// local — the exact "same block re-inlined at every consumer" shape the
5007// PRIME DIRECTIVE names as a bug. The five variants share one
5008// `{ nome: String }` shape, so the fold routes each wire-up site through
5009// one dispatch per typed variant.
5010//
5011// The macro below generates one `#[must_use]` inherent constructor per
5012// variant of shape `fn <ctor>(nome: &str) -> Self`, so every wire-up site
5013// collapses onto one dispatch: `DepError::<ctor>(nome)`, byte-equal to the
5014// pre-lift struct-literal on the same `&str` fixture. The uniform
5015// one-field construction (`nome.to_string()`) is spelled once — inside
5016// the macro — rather than at every wire-up site. Callers that hold a
5017// `String` (`self.nome`) pass `&self.nome`, which auto-derefs to `&str`
5018// and lets the macro-owned `.to_string()` produce the fresh owning copy
5019// the enum variant needs; the semantics collapse onto the same
5020// `.clone()`-equivalent one this fold replaces at every site.
5021//
5022// The sibling `NomeEmpty` unit-variant (`enum DepError { NomeEmpty, … }`)
5023// on the same envelope stays on its pre-lift open-coded wire-up shape —
5024// it carries no `nome` field (the offending `:nome` value *is* the empty
5025// string this variant catches) so the uniform `fn(nome: &str) -> Self`
5026// signature this macro promises does not apply. Every future consumer
5027// that wants to construct one of these five variants outside the current
5028// in-crate wire-up sites (a deferred `caixa-resolver` per-`:versao` /
5029// `:caracteristicas` / `:fonte :repo` / `:fonte :pin` / `:fonte :caminho`
5030// re-validator at lacre-resolve time, a future `feira validate --deps`
5031// per-caixa admission verb, a per-lacre overlay resolver rejecting one of
5032// these empty-value shapes against a cluster-local snapshot) now reaches
5033// each variant through one call rather than re-inlining the three-line
5034// struct-literal in lockstep with the five in-crate wire-up sites.
5035macro_rules! dep_nome_only_ctors {
5036 ($($ctor:ident => $variant:ident),* $(,)?) => {
5037 impl DepError {
5038 $(
5039 #[doc = concat!(
5040 "Construct a [`DepError::",
5041 stringify!($variant),
5042 "`] naming the offending `:deps :nome`. Folds the ",
5043 "uniform `Self::",
5044 stringify!($variant),
5045 " { nome: nome.to_string() }` one-field ",
5046 "struct-literal onto one substrate primitive so every ",
5047 "in-crate wire-up on this variant reads through one ",
5048 "dispatch rather than the pre-lift three-line ",
5049 "open-coded block."
5050 )]
5051 #[must_use]
5052 pub fn $ctor(nome: &str) -> Self {
5053 Self::$variant { nome: nome.to_string() }
5054 }
5055 )*
5056 }
5057 };
5058}
5059
5060dep_nome_only_ctors! {
5061 versao_empty => VersaoEmpty,
5062 fonte_repo_empty => FonteRepoEmpty,
5063 fonte_pin_missing => FontePinMissing,
5064 fonte_caminho_empty => FonteCaminhoEmpty,
5065 caracteristica_empty => CaracteristicaEmpty,
5066}
5067
5068// Fold the four `DepError::{DuplicateNome, DepIsSelf}` struct-variant
5069// wire-up sites at [`crate::manifest::Caixa::push_dep`] +
5070// [`crate::manifest::Caixa::validate_deps`] +
5071// [`validate_no_self_dep`] onto one substrate-primitive family per
5072// typed variant — the `DepError`-side siblings of the peer
5073// [`crate::supervisor::supervisor_caixa_only_ctors!`] macro (db09650)
5074// on the `SupervisorError { caixa: String }` one-slot envelope and of
5075// the peer [`dep_nome_only_ctors!`] macro (792aa92) on the
5076// `DepError { nome: String }` one-slot envelope. The two variants
5077// carry the same `{ nome: String, list: &'static str }` two-slot
5078// shape: the `nome` field names the offending dep the diagnostic
5079// points the author back at, and the `list` field carries the
5080// `":deps"` / `":deps-dev"` author-surface tag verbatim (via
5081// [`crate::dep::DepList::as_str`] on the [`push_dep`] /
5082// [`validate_deps`] arms, and via the paired
5083// [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
5084// [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `&'static str`
5085// canonicals on the [`validate_no_self_dep`] arm) so the author can
5086// grep their caixa.lisp for the offending list block in one edit.
5087//
5088// Each of the four wire-up sites opened the same struct-literal
5089// `DepError::<Variant> { nome: <name>.to_string(), list: <tag> }`
5090// two-line block — the exact "same block re-inlined at every
5091// consumer" shape the PRIME DIRECTIVE names as a bug, on the same
5092// altitude the peer `DepError` / `SupervisorError` /
5093// `AplicacaoError` / `LayoutError` / `LimitsError` ctor families
5094// already closed on their sibling envelopes. The two `#[must_use]`
5095// inherent constructors below fold each wire-up onto one dispatch:
5096// `DepError::duplicate_nome(<nome>, <list>)` and
5097// `DepError::dep_is_self(<nome>, <list>)`, byte-equal to the
5098// pre-lift struct-literal on the same scalar fixtures. The `list:
5099// &'static str` parameter (not `impl Into<String>`) preserves the
5100// exact wire tag every consumer already passes verbatim — no
5101// downstream diagnostic reshaping at the lift, matching the peer
5102// `DepList::as_str` / `DEP_AUTHOR_KEY_DEPS*` `&'static str`
5103// contract each wire-up site already keys off.
5104macro_rules! dep_nome_list_ctors {
5105 ($($ctor:ident => $variant:ident),* $(,)?) => {
5106 impl DepError {
5107 $(
5108 #[doc = concat!(
5109 "Construct a [`DepError::",
5110 stringify!($variant),
5111 "`] naming the offending `:deps :nome` and the ",
5112 "author-surface list tag (`:deps` vs. `:deps-dev`) ",
5113 "the diagnostic points the author back at. Folds ",
5114 "the uniform `Self::",
5115 stringify!($variant),
5116 " { nome: nome.to_string(), list }` two-field ",
5117 "struct-literal onto one substrate primitive so ",
5118 "every in-crate wire-up on this variant reads ",
5119 "through one dispatch rather than the pre-lift ",
5120 "open-coded struct-literal block."
5121 )]
5122 #[must_use]
5123 pub fn $ctor(nome: &str, list: &'static str) -> Self {
5124 Self::$variant { nome: nome.to_string(), list }
5125 }
5126 )*
5127 }
5128 };
5129}
5130
5131dep_nome_list_ctors! {
5132 duplicate_nome => DuplicateNome,
5133 dep_is_self => DepIsSelf,
5134}
5135
5136// Fold the three `DepError::{VersaoInvalid, FonteRepoShape,
5137// CaracteristicaInvalid} { nome: <nome>.to_string(), <axis>:
5138// <value>.to_string(), reason }` struct-variant wire-up sites at
5139// [`Dep::validate`]'s `:versao` requirement-shape gate + [`DepSource::validate`]'s
5140// `:fonte (:tipo git …) :repo` value-shape gate + [`Dep::validate_caracteristicas`]'s
5141// per-entry `:caracteristicas` feature-name-shape gate onto one substrate-
5142// primitive family per typed variant — the `DepError`-side siblings of the
5143// peer [`dep_nome_only_ctors!`] (792aa92) on the one-slot `{ nome }`
5144// envelope, [`dep_nome_list_ctors!`] (6f5e0cd) on the two-slot `{ nome,
5145// list: &'static str }` envelope, [`fonte_caminho_ctors!`] (f85f145) on
5146// the two-slot `{ nome, caminho }` envelope, and
5147// [`fonte_caminho_byte_ctors!`] (0e35793) on the three-slot `{ nome,
5148// caminho, byte }` envelope. The three variants share the same
5149// `{ nome: String, <axis>: String, reason: String }` three-slot shape —
5150// the `nome` field names the offending dep the diagnostic points the
5151// author back at, the middle `<axis>: String` field carries the offending
5152// axis value verbatim (`:versao` requirement scalar on `VersaoInvalid`,
5153// `:repo` URL scalar on `FonteRepoShape`, `:caracteristicas` per-entry
5154// feature-name scalar on `CaracteristicaInvalid`), and the `reason: String`
5155// field carries the parser-shaped rejection sentence the paired
5156// [`crate::render::require_valid_versao_requirement`] /
5157// [`crate::render::is_git_repo_url`] /
5158// [`crate::render::is_cargo_feature_name`] predicate returned. The middle
5159// axis-field name differs across variants (`versao` / `repo` /
5160// `caracteristica`) so the ctor family below takes the axis field name as
5161// a macro parameter (`$axis:ident`) alongside the ctor + variant names,
5162// generating one `pub fn $ctor(nome: &str, $axis: &str, reason: String)
5163// -> Self` inherent constructor per typed variant that spells the uniform
5164// three-field construction (`nome.to_string()` / `<axis>.to_string()` /
5165// `reason` forwarded owned) exactly once. Peer of the sibling
5166// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) macro
5167// family on the `AplicacaoError` envelope's mirror-symmetric
5168// `{ <field>: String, reason: String }` two-slot shape — same
5169// `<axis>: <value>.to_string()` + `reason` owned-forward payload shape,
5170// one `nome`-axis added at the per-dep-owned altitude the `DepError`
5171// envelope keys off (every `DepError` variant carries the offending
5172// `:deps :nome` verbatim so the author can grep their caixa.lisp for the
5173// offending block in one edit).
5174//
5175// The three wire-up sites this fold closes are:
5176// - [`DepSource::validate`]'s `:repo` value-shape arm
5177// (`Err(DepError::FonteRepoShape { nome: nome.to_string(), repo:
5178// repo.clone(), reason })` after [`crate::render::is_git_repo_url`]
5179// rejects the offending URL);
5180// - [`Dep::validate`]'s `:versao` requirement-shape arm
5181// (`|reason| DepError::VersaoInvalid { nome: self.nome.clone(), versao:
5182// self.versao_requirement().to_string(), reason }` inside the
5183// [`crate::render::require_valid_versao_requirement`] callback pair);
5184// - [`Dep::validate_caracteristicas`]'s per-entry feature-name-shape arm
5185// (`Err(DepError::CaracteristicaInvalid { nome: self.nome.clone(),
5186// caracteristica: c.clone(), reason })` after
5187// [`crate::render::is_cargo_feature_name`] rejects the offending
5188// feature-name).
5189//
5190// Each opened the identical five-line struct-literal against the same
5191// `(nome, <axis>, reason)` local triple — the exact "same block re-inlined
5192// at every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5193// same altitude the peer four already-lifted `DepError` ctor families
5194// closed on their sibling shape-envelopes. The three variant / axis-field
5195// discriminators are the only things that vary between them; the rest of
5196// the struct-literal is a byte-for-byte re-inline.
5197//
5198// Every future consumer wanting to raise one of these three diagnostics
5199// (a deferred `caixa-resolver` per-`:deps` re-validator at lacre-resolve
5200// time re-checking each declared dep against the same requirement +
5201// git-URL + feature-name value-shape cascade, a future `feira validate
5202// --deps` per-caixa admission verb re-running the shape gates on demand,
5203// a per-lacre overlay resolver rejecting an author-supplied dep against a
5204// cluster-local snapshot) now reaches one dispatch rather than re-inlining
5205// the five-line struct-literal in lockstep with the three in-crate
5206// wire-up sites.
5207macro_rules! dep_nome_axis_reason_ctors {
5208 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5209 impl DepError {
5210 $(
5211 #[doc = concat!(
5212 "Construct a [`DepError::",
5213 stringify!($variant),
5214 "`] naming the offending `:deps :nome`, the offending ",
5215 "`:", stringify!($axis), "` axis value, and the ",
5216 "parser-shaped rejection `reason`. Folds the uniform ",
5217 "`Self::",
5218 stringify!($variant),
5219 " { nome: nome.to_string(), ",
5220 stringify!($axis),
5221 ": ",
5222 stringify!($axis),
5223 ".to_string(), reason }` three-field struct-literal ",
5224 "onto one substrate primitive so every in-crate ",
5225 "wire-up on this variant reads through one dispatch ",
5226 "rather than the pre-lift five-line open-coded block. ",
5227 "The `nome: &str` and `",
5228 stringify!($axis),
5229 ": &str` parameters accept `&str` literals and ",
5230 "`&String` (via Deref coercion) so every existing ",
5231 "wire-up threads through the ctor without a ",
5232 "pre-conversion; the `reason: String` parameter takes ",
5233 "an owned `String` (not `impl Into<String>`) matching ",
5234 "the paired `crate::render::*` predicate's ",
5235 "`Result<(), String>` return shape every wire-up ",
5236 "already holds owned at the call site."
5237 )]
5238 #[must_use]
5239 pub fn $ctor(nome: &str, $axis: &str, reason: String) -> Self {
5240 Self::$variant {
5241 nome: nome.to_string(),
5242 $axis: $axis.to_string(),
5243 reason,
5244 }
5245 }
5246 )*
5247 }
5248 };
5249}
5250
5251dep_nome_axis_reason_ctors! {
5252 versao_invalid => VersaoInvalid { versao },
5253 fonte_repo_shape => FonteRepoShape { repo },
5254 caracteristica_invalid => CaracteristicaInvalid { caracteristica },
5255}
5256
5257// Fold the three `DepError::{FontePinEmpty, FontePinAmbiguous,
5258// CaracteristicaDuplicate} { nome: <nome>.to_string(), <axis>:
5259// <value>.to_string() }` struct-variant wire-up sites at
5260// [`DepSource::validate`]'s per-`:fonte` git-pin single-pin-empty +
5261// multi-pin-ambiguous cascade and [`Dep::validate_caracteristicas`]'s
5262// per-entry set-not-multiset dedup closure onto one substrate-primitive
5263// family per typed variant — the missing two-slot rung on the
5264// `DepError`-side four-family ladder ([`dep_nome_only_ctors!`] (792aa92)
5265// one-slot `{ nome }` → this two-slot `{ nome, <axis>: String }` →
5266// [`dep_nome_list_ctors!`] (6f5e0cd) two-slot `{ nome, list: &'static
5267// str }` → [`dep_nome_axis_reason_ctors!`] (5621f8a) three-slot
5268// `{ nome, <axis>: String, reason: String }` → [`fonte_pin_shape`]
5269// (86e2a17) four-slot `{ nome, pin, value, reason }`), and mirror-
5270// symmetric sibling of the peer
5271// [`crate::aplicacao::aplicacao_field_reason_ctors!`] (981060b) two-slot
5272// `{ <field>: String, reason: String }` fold on the `AplicacaoError`
5273// envelope — same `<axis>: <value>.to_string()` owned-forward payload
5274// shape, `reason` axis removed and `nome`-axis added at the per-dep-
5275// owned altitude the `DepError` envelope keys off (every `DepError`
5276// variant carries the offending `:deps :nome` verbatim so the author
5277// can grep their caixa.lisp for the offending block in one edit). The
5278// three variants share the same `{ nome: String, <axis>: String }`
5279// two-slot shape: the `nome` field names the offending dep the
5280// diagnostic points the author back at, and the middle `<axis>:
5281// String` field carries the offending per-envelope axis value verbatim
5282// (`:fonte` per-pin author-surface tag on `FontePinEmpty`, the
5283// comma-joined multi-pin ambiguity report on `FontePinAmbiguous`, the
5284// duplicate `:caracteristicas` entry on `CaracteristicaDuplicate`).
5285// The middle axis-field name differs across variants (`pin` / `pins` /
5286// `caracteristica`) so the ctor family below takes the axis field name
5287// as a macro parameter (`$axis:ident`) alongside the ctor + variant
5288// names, generating one `pub fn $ctor(nome: &str, $axis: &str) ->
5289// Self` inherent constructor per typed variant that spells the
5290// uniform two-field construction (`nome.to_string()` /
5291// `<axis>.to_string()`) exactly once.
5292//
5293// The three wire-up sites this fold closes are:
5294// - [`DepSource::validate`]'s per-`:fonte` set-of-one empty-pin arm
5295// (`return Err(DepError::FontePinEmpty { nome: nome.to_string(), pin:
5296// pin.to_string() });` inside the `set.len() == 1` branch after the
5297// `is_some_and(String::is_empty)` iterator);
5298// - [`DepSource::validate`]'s per-`:fonte` set-of-two-or-more
5299// ambiguity arm (`return Err(DepError::FontePinAmbiguous { nome:
5300// nome.to_string(), pins: set.join(", ") });` inside the `_` branch);
5301// - [`Dep::validate_caracteristicas`]'s per-entry
5302// set-not-multiset-dedup closure (`|| DepError::CaracteristicaDuplicate
5303// { nome: self.nome.clone(), caracteristica: c.clone() }` passed to
5304// [`crate::render::insert_first_seen`]).
5305//
5306// Each opened the identical four-line struct-literal against the same
5307// `(nome, <axis>)` local pair — the exact "same block re-inlined at
5308// every consumer" shape the PRIME DIRECTIVE names as a bug, on the
5309// same altitude the peer four already-lifted `DepError` ctor families
5310// closed on their sibling shape-envelopes. The three variant / axis-
5311// field discriminators are the only things that vary between them;
5312// the rest of the struct-literal is a byte-for-byte re-inline.
5313//
5314// Every future consumer wanting to raise one of these three
5315// diagnostics (a deferred `caixa-resolver` per-`:deps` re-validator
5316// at lacre-resolve time re-checking each declared dep against the
5317// same `:fonte` set-of-one / set-of-many + `:caracteristicas`
5318// set-not-multiset cascade, a future `feira validate --deps` per-
5319// caixa admission verb re-running the shape gates on demand, a
5320// per-lacre overlay resolver rejecting an author-supplied dep against
5321// a cluster-local snapshot the M4 CR materializer projects) now
5322// reaches one dispatch rather than re-inlining the four-line struct-
5323// literal in lockstep with the three in-crate wire-up sites.
5324macro_rules! dep_nome_axis_ctors {
5325 ($($ctor:ident => $variant:ident { $axis:ident }),* $(,)?) => {
5326 impl DepError {
5327 $(
5328 #[doc = concat!(
5329 "Construct a [`DepError::",
5330 stringify!($variant),
5331 "`] naming the offending `:deps :nome` and the ",
5332 "offending `:", stringify!($axis), "` axis value. ",
5333 "Folds the uniform `Self::",
5334 stringify!($variant),
5335 " { nome: nome.to_string(), ",
5336 stringify!($axis),
5337 ": ",
5338 stringify!($axis),
5339 ".to_string() }` two-field struct-literal onto one ",
5340 "substrate primitive so every in-crate wire-up on ",
5341 "this variant reads through one dispatch rather than ",
5342 "the pre-lift four-line open-coded block. Both `nome: ",
5343 "&str` and `",
5344 stringify!($axis),
5345 ": &str` parameters accept `&str` literals and ",
5346 "`&String` (via Deref coercion) so every existing ",
5347 "wire-up threads through the ctor without a pre-",
5348 "conversion."
5349 )]
5350 #[must_use]
5351 pub fn $ctor(nome: &str, $axis: &str) -> Self {
5352 Self::$variant {
5353 nome: nome.to_string(),
5354 $axis: $axis.to_string(),
5355 }
5356 }
5357 )*
5358 }
5359 };
5360}
5361
5362dep_nome_axis_ctors! {
5363 fonte_pin_empty => FontePinEmpty { pin },
5364 fonte_pin_ambiguous => FontePinAmbiguous { pins },
5365 caracteristica_duplicate => CaracteristicaDuplicate { caracteristica },
5366}
5367
5368// Fold the two `DepError::FontePinShape { nome: nome.to_string(),
5369// pin: <pin>.to_string(), value: v.clone(), reason }` four-slot
5370// struct-variant wire-up sites at [`DepSource::validate`]'s
5371// per-`:fonte` git-pin value-shape gate onto one substrate primitive on
5372// the `DepError` envelope — the last open-coded ctor site remaining on
5373// the `:fonte (:tipo git …)` value-shape trajectory this envelope
5374// carries, and the single-variant sibling of the peer four already-
5375// lifted [`DepError`] ctor families ([`fonte_caminho_ctors!`] f85f145
5376// on the two-slot `{ nome, caminho }` envelope,
5377// [`fonte_caminho_byte_ctors!`] 0e35793 on the three-slot
5378// `{ nome, caminho, byte }` envelope, [`dep_nome_only_ctors!`] 792aa92
5379// on the one-slot `{ nome }` envelope, and [`dep_nome_list_ctors!`]
5380// 6f5e0cd on the two-slot `{ nome, list }` envelope). Peer of the
5381// sibling [`crate::aplicacao::contrato_pair_value_reason_ctors!`]
5382// (14e13f1) four-slot fold on the `AplicacaoError` envelope — same
5383// `{ …, value: String, reason: String }` payload shape, one axis
5384// removed at the `nome`-only-owner altitude the `DepError` envelope
5385// keys off (no `edge_pair()` de/para pair).
5386//
5387// The two wire-up sites this fold closes are the paired refname-pin
5388// arm (`|| DepError::FontePinShape { nome: nome.to_string(),
5389// pin: pin.to_string(), value: v.clone(), reason }` inside the
5390// `[(":tag", tag), (":branch", branch)]` iterator against
5391// [`crate::render::is_git_ref_name`]) and the hex-OID-pin arm
5392// (`|| DepError::FontePinShape { nome: nome.to_string(),
5393// pin: ":rev".to_string(), value: v.clone(), reason }` against
5394// [`crate::render::is_git_oid`]) — each opened the identical
5395// `DepError::FontePinShape { … }` six-line struct-literal against the
5396// same `(nome: &str, pin: &str, v: &String, reason: String)` local
5397// tuple, the exact "same block re-inlined at every consumer" shape
5398// the PRIME DIRECTIVE names as a bug. The `pin` axis discriminator is
5399// the only thing that varies between them (`":tag"`/`":branch"` on
5400// the refname arm, `":rev"` on the hex-OID arm); the rest of the
5401// struct-literal is a byte-for-byte re-inline. Refname/hex-OID both
5402// route through the same ctor because their `pin` field carries the
5403// author-surface tag verbatim (matching the `FontePinEmpty` /
5404// `FontePinAmbiguous` sibling variants' `pin: String` axis
5405// convention), so the offending author can grep their caixa.lisp for
5406// the offending `:tag "<value>"` / `:branch "<value>"` /
5407// `:rev "<value>"` literal in one edit.
5408//
5409// The single ctor below folds each wire-up onto one dispatch:
5410// `DepError::fonte_pin_shape(nome, pin, v, reason)`, byte-equal to
5411// the pre-lift struct-literal on the same `(&str, &str, &str,
5412// String)` fixture. The uniform four-field construction
5413// (`nome.to_string()` / `pin.to_string()` / `value.to_string()` /
5414// `reason` forwarded owned) is spelled once here rather than at every
5415// wire-up site. The `reason: String` field takes an owned `String`
5416// (not `impl Into<String>`) matching the two call sites' pre-existing
5417// `let Err(reason) = crate::render::is_git_ref_name(v)` /
5418// `let Err(reason) = crate::render::is_git_oid(v)` shape — both
5419// predicates return `Result<(), String>`, so the caller always holds
5420// an owned `String` at the wire-up site and threading it through the
5421// ctor without a `.into()` shim keeps the routing shape byte-equal to
5422// the pre-lift block. The `value: &str` parameter accepts both `&str`
5423// literals (unused today) and `&String` (from the caller-held
5424// `v: &String` on each arm, via Deref coercion), so every existing
5425// wire-up threads through the ctor without a pre-conversion.
5426//
5427// Every future consumer that wants to construct this variant outside
5428// the two in-crate [`DepSource::validate`] wire-up sites (a deferred
5429// `caixa-resolver` per-`:fonte` re-validator at lacre-resolve time
5430// re-checking the same value-shape axes the resolver consumes, a
5431// future `feira validate --deps` per-caixa admission verb re-checking
5432// the `:fonte :tag`/`:branch`/`:rev` axes, a per-lacre overlay
5433// resolver rejecting a git-pin value against a cluster-local
5434// snapshot) now reaches this variant through one call rather than
5435// re-inlining the six-line struct-literal in lockstep with the two
5436// in-crate wire-up sites.
5437impl DepError {
5438 /// Construct a [`DepError::FontePinShape`] naming the offending
5439 /// `:deps :nome`, the offending `:fonte (:tipo git …) :<pin>`
5440 /// axis tag, the offending value, and the parser-shaped `reason`.
5441 /// Folds the uniform
5442 /// `Self::FontePinShape { nome: nome.to_string(),
5443 /// pin: pin.to_string(), value: value.to_string(), reason }`
5444 /// four-field struct-literal onto one substrate primitive so
5445 /// every [`DepSource::validate`] wire-up on this variant reads
5446 /// through one dispatch rather than the pre-lift six-line
5447 /// open-coded block. The `nome` string threads verbatim from
5448 /// [`Dep::nome`] at the call site; the `pin` string carries the
5449 /// author-surface `:tag` / `:branch` / `:rev` tag verbatim; the
5450 /// `value` string carries the offending refname / hex-OID
5451 /// verbatim; and `reason` forwards the owned `String` returned
5452 /// by [`crate::render::is_git_ref_name`] /
5453 /// [`crate::render::is_git_oid`] without a `.into()` shim.
5454 #[must_use]
5455 pub fn fonte_pin_shape(nome: &str, pin: &str, value: &str, reason: String) -> Self {
5456 Self::FontePinShape {
5457 nome: nome.to_string(),
5458 pin: pin.to_string(),
5459 value: value.to_string(),
5460 reason,
5461 }
5462 }
5463
5464 /// Construct a [`DepError::NomeInvalid`] naming the offending
5465 /// `:deps :nome` byte-string and the parser-shaped rejection
5466 /// `reason` returned by [`crate::render::is_dns_1123_label`].
5467 ///
5468 /// Folds the uniform
5469 /// `Self::NomeInvalid { nome: nome.to_string(), reason }` two-field
5470 /// struct-literal onto one substrate primitive so every wire-up on
5471 /// this variant reads through one dispatch rather than the pre-lift
5472 /// four-line open-coded `DepError::NomeInvalid { nome:
5473 /// self.nome.clone(), reason }` block inside [`Dep::validate`]. The
5474 /// missing two-slot `{ nome, reason }` rung on the `DepError`-side
5475 /// ctor-family ladder (`{ nome }` one-slot →
5476 /// [`dep_nome_only_ctors!`] (792aa92); `{ nome, <axis>: String }`
5477 /// two-slot → [`dep_nome_axis_ctors!`] (7f7c950); `{ nome, list:
5478 /// &'static str }` two-slot → [`dep_nome_list_ctors!`] (6f5e0cd);
5479 /// `{ nome, <axis>: String, reason: String }` three-slot →
5480 /// [`dep_nome_axis_reason_ctors!`] (5621f8a); `{ nome, pin, value,
5481 /// reason }` four-slot → [`DepError::fonte_pin_shape`] (86e2a17))
5482 /// — the sole variant on the envelope carrying the
5483 /// `{ nome: String, reason: String }` two-slot shape without a
5484 /// middle axis, matching the peer
5485 /// [`crate::manifest::ManifestError::NomeInvalid`] +
5486 /// [`crate::aplicacao::AplicacaoError::MembroCaixaInvalid`] +
5487 /// [`crate::supervisor::SupervisorError::ChildCaixaInvalid`]
5488 /// four-axis DNS-1123 caixa-identifier diagnostic family the
5489 /// existing `nome_invalid_diagnostic_carries_offending_name` test
5490 /// pins on this envelope.
5491 ///
5492 /// The `nome: &str` parameter accepts `&str` literals and `&String`
5493 /// (via Deref coercion) so the sole in-crate wire-up threads through
5494 /// the ctor without a pre-conversion; the `reason: String`
5495 /// parameter takes an owned `String` (not `impl Into<String>`)
5496 /// matching the [`crate::render::is_dns_1123_label`] predicate's
5497 /// `Result<(), String>` return shape the sole wire-up site already
5498 /// holds owned at the call site, keeping the routing byte-equal to
5499 /// the pre-lift block. Same owned-`String`-forward `reason` payload
5500 /// discipline as the sibling three-slot family
5501 /// [`dep_nome_axis_reason_ctors!`] on `{ nome, <axis>, reason }`
5502 /// and the four-slot [`DepError::fonte_pin_shape`] on
5503 /// `{ nome, pin, value, reason }`.
5504 ///
5505 /// Every future consumer that raises the same diagnostic outside
5506 /// [`Dep::validate`] — a deferred `caixa-resolver` per-`:deps`
5507 /// re-validator at lacre-resolve time re-checking each declared
5508 /// dep's `:nome` against the same DNS-1123 predicate the apiserver-
5509 /// side schema uses (the `:nome` value flows verbatim as the target
5510 /// caixa's `:nome`, the rendered `lareira-<nome>` Helm chart name
5511 /// segment, the `LABEL_PROGRAM` label value, and the resolver's
5512 /// checkout-directory leaf), a future `feira validate --deps`
5513 /// per-caixa admission verb re-running the shape gate on demand, a
5514 /// per-lacre overlay resolver rejecting an author-supplied dep's
5515 /// `:nome` against a cluster-local snapshot the M4 CR materializer
5516 /// projects, a future authoring-surface widening the field into a
5517 /// `(String, Vec<Suggestion>)` pair carrying a
5518 /// "did-you-mean-<nearest-valid-label>" hint — now reaches this
5519 /// variant through one call rather than re-inlining the four-line
5520 /// struct-literal in lockstep with the one in-crate wire-up site.
5521 #[must_use]
5522 pub fn nome_invalid(nome: &str, reason: String) -> Self {
5523 Self::NomeInvalid {
5524 nome: nome.to_string(),
5525 reason,
5526 }
5527 }
5528}
5529
5530#[allow(clippy::trivially_copy_pass_by_ref)]
5531fn is_false(b: &bool) -> bool {
5532 !*b
5533}
5534
5535#[cfg(test)]
5536mod tests {
5537 use super::*;
5538
5539 #[test]
5540 fn registry_dep_is_minimal() {
5541 let d = Dep::simple("caixa-teia", "^0.1");
5542 assert_eq!(d.nome, "caixa-teia");
5543 assert_eq!(d.versao, "^0.1");
5544 assert!(d.fonte.is_none());
5545 assert!(!d.opcional());
5546 assert!(d.caracteristicas().is_empty());
5547 }
5548
5549 #[test]
5550 fn dep_string_scalar_accessor_pair_is_const_fn() {
5551 // Fail-before-pass-after pin on [`Dep::nome`] +
5552 // [`Dep::versao_requirement`]'s `const`-eval-surface posture.
5553 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5554 // entry's [`String`] storage through the `pub const fn`
5555 // [`String::as_str`] (const-stable since Rust 1.87, well
5556 // within the workspace MSRV) — any future accidental
5557 // downgrade to non-`const` fails the corresponding
5558 // `<name>_via_const_fn` wrapper at caixa-core build time with
5559 // E0015 (`cannot call non-const method`), strictly stronger
5560 // than a runtime `assert!`. Sibling of the peer
5561 // per-M2/M3/universal-axis `String → &str` scalar-accessor
5562 // family pins on the sibling `const`-eval-surface passes
5563 // ([`crate::Caixa::nome`] / [`crate::Caixa::versao`] at the
5564 // top-level manifest, [`crate::CaixaVersion::as_str`] at the
5565 // typed-newtype wrapper, [`crate::aplicacao::Membro::nome`] /
5566 // [`crate::aplicacao::Membro::versao_requirement`] at the M3
5567 // membership axis, [`crate::aplicacao::Entrada::hostname`] /
5568 // [`crate::aplicacao::Entrada::destination`] at the M3
5569 // ingress axis, [`crate::supervisor::ChildSpec::nome`] /
5570 // [`crate::supervisor::ChildSpec::versao_requirement`] at the
5571 // M2 supervisor-tree axis,
5572 // [`crate::upgrade::UpgradeFromEntry::prior_versao`] at the
5573 // M2 upgrade axis, and the per-`:contratos`
5574 // [`crate::aplicacao::WitContract::source`] /
5575 // [`crate::aplicacao::WitContract::destination`] /
5576 // [`crate::aplicacao::WitContract::world_ref`] trio the
5577 // sibling pin at 279823b already anchors).
5578 const fn nome_via_const_fn(d: &Dep) -> &str {
5579 d.nome()
5580 }
5581 const fn versao_via_const_fn(d: &Dep) -> &str {
5582 d.versao_requirement()
5583 }
5584 for (nome, versao) in [
5585 ("caixa-teia", "^0.1"),
5586 ("caixa-mesh", "~0.2.3"),
5587 ("caixa-helm", "*"),
5588 ] {
5589 let d = Dep::simple(nome, versao);
5590 assert_eq!(nome_via_const_fn(&d), d.nome());
5591 assert_eq!(versao_via_const_fn(&d), d.versao_requirement());
5592 assert_eq!(d.nome(), nome);
5593 assert_eq!(d.versao_requirement(), versao);
5594 }
5595 }
5596
5597 #[test]
5598 fn dep_outer_accessor_family_is_const_fn() {
5599 // Fail-before-pass-after pin on [`Dep::fonte`] +
5600 // [`Dep::caracteristicas`]'s `const`-eval-surface posture.
5601 // Each accessor projects the per-`:deps` / per-`:deps-dev`
5602 // entry's composite / list storage through a `pub const fn`
5603 // stdlib method (`Option::<DepSource>::as_ref` /
5604 // `Vec::<String>::as_slice`, both const-stable since Rust
5605 // 1.83, well within the workspace MSRV). Any future
5606 // accidental downgrade to non-`const` fails the corresponding
5607 // `<name>_via_const_fn` wrapper at caixa-core build time with
5608 // E0015 (`cannot call non-const method`), strictly stronger
5609 // than a runtime `assert!` and side-stepping the destructor-
5610 // in-const restriction the `Dep` fixture's `String` /
5611 // `Option<DepSource>` / `Vec<String>` carriers rule out on the
5612 // direct-`const _: () = assert!(...)` residence.
5613 //
5614 // Peer of the sibling per-`Dep` scalar-accessor pair pin
5615 // [`dep_string_scalar_accessor_pair_is_const_fn`] on the same
5616 // outer per-dep-list-entry [`Dep`] altitude — this pin extends
5617 // the `const`-eval-surface discipline onto the composite-
5618 // reference and slice-return arms of the outer-`Dep` accessor
5619 // family, closing the four-slot outer surface (`:nome` +
5620 // `:versao` + `:fonte` + `:caracteristicas`) on the `const`-fn
5621 // posture. The `:opcional` `bool` arm already carries the
5622 // posture through [`Dep::opcional`]'s prior `pub const fn`
5623 // declaration, so this pin lands the last two unlifted
5624 // outer-`Dep` accessors and closes the family.
5625 const fn fonte_via_const_fn(d: &Dep) -> Option<&DepSource> {
5626 d.fonte()
5627 }
5628 const fn caracteristicas_via_const_fn(d: &Dep) -> &[String] {
5629 d.caracteristicas()
5630 }
5631 // `Dep::simple` — no `:fonte`, empty `:caracteristicas`.
5632 let empty = Dep::simple("caixa-teia", "^0.1");
5633 assert!(fonte_via_const_fn(&empty).is_none());
5634 assert_eq!(fonte_via_const_fn(&empty), empty.fonte());
5635 assert!(caracteristicas_via_const_fn(&empty).is_empty());
5636 assert_eq!(
5637 caracteristicas_via_const_fn(&empty),
5638 empty.caracteristicas()
5639 );
5640 // `Dep::git` — `:fonte` is `Some(Git{…})`, `:caracteristicas`
5641 // still empty.
5642 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
5643 assert!(fonte_via_const_fn(&git).is_some());
5644 assert_eq!(fonte_via_const_fn(&git), git.fonte());
5645 assert_eq!(caracteristicas_via_const_fn(&git), git.caracteristicas());
5646 // Populated `:caracteristicas` — exercise the non-empty
5647 // slice-view arm to pin the accessor's borrow shape against
5648 // both a `Vec::new()` empty backing buffer and a populated one.
5649 let mut with_features = Dep::simple("caixa-teia", "^0.1");
5650 with_features.caracteristicas = vec!["feat-a".into(), "feat-b".into()];
5651 assert_eq!(caracteristicas_via_const_fn(&with_features).len(), 2);
5652 assert_eq!(
5653 caracteristicas_via_const_fn(&with_features),
5654 with_features.caracteristicas()
5655 );
5656 }
5657
5658 #[test]
5659 fn git_dep_carries_tag() {
5660 let d = Dep::git("t", "*", "github:o/r", "v1");
5661 match d.fonte {
5662 Some(DepSource::Git {
5663 ref repo, ref tag, ..
5664 }) => {
5665 assert_eq!(repo, "github:o/r");
5666 assert_eq!(tag.as_deref(), Some("v1"));
5667 }
5668 _ => panic!("expected Git source"),
5669 }
5670 }
5671
5672 #[test]
5673 fn validate_accepts_simple_dep() {
5674 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
5675 }
5676
5677 #[test]
5678 fn validate_rejects_empty_nome() {
5679 // The fail-before-pass-after pin for `:nome ""`: the empty-name
5680 // arm fires first so the per-entry parse-side diagnostic doesn't
5681 // emit a useless `nome: ""` reference.
5682 let mut d = Dep::simple("placeholder", "^0.1");
5683 d.nome = String::new();
5684 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5685 }
5686
5687 #[test]
5688 fn validate_rejects_empty_versao() {
5689 // `parse_requirement("")` returns `Ok(VersionReq::STAR)` (the
5690 // semver crate accepts the empty string as a wildcard match),
5691 // so the empty-`:versao` arm is structurally necessary even
5692 // with the parse arm in place — mirrors `MembroVersaoEmpty` /
5693 // `EmptyChildVersion` ordering on the other two `:versao` axes.
5694 let mut d = Dep::simple("caixa-teia", "ignored");
5695 d.versao = String::new();
5696 let err = d.validate().unwrap_err();
5697 assert!(
5698 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
5699 "got {err:?}"
5700 );
5701 }
5702
5703 // ── value-shape: DNS-1123 label on :deps :nome ────────────────────────
5704
5705 #[test]
5706 fn validate_rejects_nome_with_uppercase() {
5707 // The fail-before-pass-after pin: a non-empty but uppercase
5708 // `:nome` silently passed `validate()` on every pre-gate
5709 // codebase because the prior shape only refused the empty
5710 // string. The DNS-1123 violation surfaced far downstream at
5711 // lacre-resolve time when the *target* caixa's `:nome` failed
5712 // its own gate — far from the `:deps` entry, with a diagnostic
5713 // naming the target rather than the dep entry that referenced
5714 // it. Same fail-before-pass-after fixture pinned for
5715 // `:membros :caixa` (3f9d7a0), `:children :caixa` (31bfa43),
5716 // and Caixa `:nome` (6c992f8).
5717 let d = Dep::simple("Caixa-Teia", "^0.1");
5718 let err = d.validate().unwrap_err();
5719 assert!(
5720 matches!(
5721 err,
5722 DepError::NomeInvalid { ref nome, ref reason }
5723 if nome == "Caixa-Teia" && reason.contains("uppercase")
5724 ),
5725 "got {err:?}"
5726 );
5727 }
5728
5729 #[test]
5730 fn validate_rejects_nome_with_underscore() {
5731 // RFC 1123 allows `[a-z0-9-]` only; underscore is the canonical
5732 // "I'm thinking of Go module names / Python identifiers" leak.
5733 // Same fixture pinned for the peer caixa-identifier axes.
5734 let d = Dep::simple("caixa_teia", "^0.1");
5735 let err = d.validate().unwrap_err();
5736 assert!(
5737 matches!(
5738 err,
5739 DepError::NomeInvalid { ref nome, ref reason }
5740 if nome == "caixa_teia" && reason.contains('_')
5741 ),
5742 "got {err:?}"
5743 );
5744 }
5745
5746 #[test]
5747 fn validate_rejects_nome_with_dot() {
5748 // A `:deps :nome` is a single DNS-1123 *label*, not a
5749 // subdomain — dots are rejected. The `"caixa.teia"` shape is
5750 // the canonical "I confused the dep name with the FQDN /
5751 // namespace" footgun, distinct from the legitimate
5752 // `:fonte :repo "github:org/caixa-teia"` axis.
5753 let d = Dep::simple("caixa.teia", "^0.1");
5754 let err = d.validate().unwrap_err();
5755 assert!(
5756 matches!(
5757 err,
5758 DepError::NomeInvalid { ref nome, ref reason }
5759 if nome == "caixa.teia" && reason.contains('.')
5760 ),
5761 "got {err:?}"
5762 );
5763 }
5764
5765 #[test]
5766 fn validate_rejects_nome_with_leading_hyphen() {
5767 // RFC 1123 requires alphanumeric at both label boundaries.
5768 // Pinned in parity with the peer DNS-1123 fixtures.
5769 let d = Dep::simple("-caixa-teia", "^0.1");
5770 let err = d.validate().unwrap_err();
5771 assert!(
5772 matches!(
5773 err,
5774 DepError::NomeInvalid { ref nome, ref reason }
5775 if nome == "-caixa-teia" && reason.contains("alphanumeric")
5776 ),
5777 "got {err:?}"
5778 );
5779 }
5780
5781 #[test]
5782 fn validate_rejects_nome_with_trailing_hyphen() {
5783 let d = Dep::simple("caixa-teia-", "^0.1");
5784 let err = d.validate().unwrap_err();
5785 assert!(
5786 matches!(
5787 err,
5788 DepError::NomeInvalid { ref nome, ref reason }
5789 if nome == "caixa-teia-" && reason.contains("alphanumeric")
5790 ),
5791 "got {err:?}"
5792 );
5793 }
5794
5795 #[test]
5796 fn validate_rejects_nome_with_slash() {
5797 // The canonical "I copied the GitHub repo path into `:nome`
5798 // instead of `:fonte :repo`" typo. A `/` in the name leaks the
5799 // lacre-side `:repositorio` shape (`pleme-io/caixa-teia`) into
5800 // the local-name slot. Same fixture pinned for `:membros
5801 // :caixa` (3f9d7a0).
5802 let d = Dep::simple("pleme-io/caixa-teia", "^0.1");
5803 let err = d.validate().unwrap_err();
5804 assert!(
5805 matches!(
5806 err,
5807 DepError::NomeInvalid { ref nome, ref reason }
5808 if nome == "pleme-io/caixa-teia" && reason.contains('/')
5809 ),
5810 "got {err:?}"
5811 );
5812 }
5813
5814 #[test]
5815 fn validate_rejects_nome_too_long() {
5816 // 64-byte label — one over the RFC 1035 / RFC 1123 label cap.
5817 // Built from a valid character set so the length-bound
5818 // diagnostic surfaces before any per-character check (the
5819 // order pin parallel to the per-character predicates inside
5820 // [`crate::render::is_dns_1123_label`]).
5821 let long = "a".repeat(64);
5822 let d = Dep::simple(&long, "^0.1");
5823 let err = d.validate().unwrap_err();
5824 assert!(
5825 matches!(
5826 err,
5827 DepError::NomeInvalid { ref nome, ref reason }
5828 if nome.len() == 64 && reason.contains("max length of 63")
5829 ),
5830 "got {err:?}"
5831 );
5832 }
5833
5834 #[test]
5835 fn validate_accepts_canonical_nome_labels() {
5836 // Positive-control sweep — every form the K8s apiserver
5837 // accepts as a DNS-1123 label must round-trip through
5838 // validate. Covers a hyphen-bearing label, a numeric-suffix
5839 // label, a leading-digit label, a single-character label, and
5840 // a 63-byte (exactly the cap) label — the same fixture set
5841 // the peer `:membros :caixa` / `:children :caixa` positive
5842 // controls pin.
5843 for nome in [
5844 "caixa-teia",
5845 "caixa-resolver2",
5846 "2nd-tier-cache",
5847 "x",
5848 "abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz0",
5849 ] {
5850 Dep::simple(nome, "^0.1")
5851 .validate()
5852 .unwrap_or_else(|e| panic!("canonical label {nome:?} must validate, got {e:?}"));
5853 }
5854 }
5855
5856 #[test]
5857 fn nome_empty_takes_precedence_over_nome_invalid() {
5858 // Ordering pin: `NomeEmpty` is the more self-locating
5859 // diagnostic on `""` and must lead — `is_dns_1123_label` is
5860 // only reached after the empty-check fires at the call site.
5861 // Mirrors `membro_caixa_empty_takes_precedence_over_invalid`
5862 // (3f9d7a0) on the peer caixa-identifier axis.
5863 let mut d = Dep::simple("placeholder", "^0.1");
5864 d.nome = String::new();
5865 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
5866 }
5867
5868 #[test]
5869 fn nome_invalid_fires_before_versao_empty() {
5870 // Ordering pin: a malformed `:nome` fires before any `:versao`
5871 // axis check on the *same* entry — the per-entry shape gates
5872 // run top-to-bottom (nome empty → nome shape → versao empty →
5873 // versao parse → fonte shape), so a one-entry caixa.lisp with
5874 // both wrong sees the name-side diagnostic first (the name is
5875 // the self-locating axis — without a valid name, the parse
5876 // diagnostic can't quote `:nome "<bad>"`). Same ordering
5877 // discipline as `membro_caixa_invalid_fires_before_versao_check`
5878 // (3f9d7a0).
5879 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5880 d.versao = String::new();
5881 let err = d.validate().unwrap_err();
5882 assert!(
5883 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5884 "got {err:?}"
5885 );
5886 }
5887
5888 #[test]
5889 fn nome_invalid_fires_before_versao_invalid() {
5890 // Ordering pin: a malformed `:nome` fires before the `:versao`
5891 // parse-side check on the *same* entry. Pin separately from
5892 // the empty-versao ordering so a future re-ordering surfaces
5893 // here, parallel to the b0c8389 / c4213a4 trajectory.
5894 let d = Dep::simple("Caixa-Teia", "^^0.1");
5895 let err = d.validate().unwrap_err();
5896 assert!(
5897 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5898 "got {err:?}"
5899 );
5900 }
5901
5902 #[test]
5903 fn nome_invalid_fires_before_fonte_invalid() {
5904 // Ordering pin: a malformed `:nome` fires before the `:fonte`
5905 // shape check on the *same* entry. The `:fonte` diagnostic
5906 // names the offending dep's `:nome` verbatim (via
5907 // `DepSource::validate(&self.nome)`), so a non-self-locating
5908 // name would taint the downstream diagnostic too — the gate
5909 // ordering keeps both diagnostics individually self-locating.
5910 let mut d = Dep::simple("Caixa-Teia", "^0.1");
5911 d.fonte = Some(DepSource::Git {
5912 repo: String::new(),
5913 tag: None,
5914 rev: None,
5915 branch: None,
5916 });
5917 let err = d.validate().unwrap_err();
5918 assert!(
5919 matches!(err, DepError::NomeInvalid { ref nome, .. } if nome == "Caixa-Teia"),
5920 "got {err:?}"
5921 );
5922 }
5923
5924 #[test]
5925 fn nome_invalid_diagnostic_carries_offending_name() {
5926 // The diagnostic-shape pin: the error names the offending
5927 // `:nome` value verbatim so the author can grep their
5928 // caixa.lisp without re-running the build, and carries a
5929 // non-empty `reason` from `is_dns_1123_label` so the
5930 // predicate's own wording flows through to the diagnostic.
5931 // Same shape as `MembroCaixaInvalid` (3f9d7a0),
5932 // `ChildCaixaInvalid` (31bfa43), `ManifestError::NomeInvalid`
5933 // (6c992f8) — the four DNS-1123 caixa-identifier axes now
5934 // share a structurally-equivalent diagnostic family.
5935 let d = Dep::simple("Caixa_Teia", "^0.1");
5936 let err = d.validate().unwrap_err();
5937 let DepError::NomeInvalid { nome, reason } = err else {
5938 panic!("expected NomeInvalid, got other variant");
5939 };
5940 assert_eq!(nome, "Caixa_Teia");
5941 assert!(
5942 !reason.is_empty(),
5943 "NomeInvalid `reason` must carry the predicate's wording verbatim"
5944 );
5945 }
5946
5947 #[test]
5948 fn validate_rejects_invalid_versao_requirement() {
5949 // The fail-before-pass-after pin: a non-empty but malformed
5950 // requirement (`"^bad-version"`) silently passed every pre-gate
5951 // codebase because `:deps :versao` wasn't validated. The parse
5952 // failure surfaced far downstream at lacre-resolve time with a
5953 // `semver::Error` that didn't name which `:deps` entry carried
5954 // the typo. The new gate moves the check to caixa-build time
5955 // at the source caixa.lisp.
5956 let d = Dep::simple("caixa-teia", "^bad-version");
5957 let err = d.validate().unwrap_err();
5958 assert!(
5959 matches!(
5960 err,
5961 DepError::VersaoInvalid { ref nome, ref versao, .. }
5962 if nome == "caixa-teia" && versao == "^bad-version"
5963 ),
5964 "got {err:?}"
5965 );
5966 }
5967
5968 #[test]
5969 fn validate_rejects_versao_with_double_caret_typo() {
5970 // `"^^0.1"` is the canonical doubled-caret typo — looks like a
5971 // Cargo-shaped requirement on first glance but fails the parser
5972 // because semver doesn't accept stacked operators. Pin this
5973 // adjacent-shape footgun explicitly so a future relaxation that
5974 // accepts "looks-canonical-but-isn't" forms surfaces here, in
5975 // parity with the `:membros` / `:children` fixtures.
5976 let d = Dep::simple("caixa-teia", "^^0.1");
5977 let err = d.validate().unwrap_err();
5978 assert!(
5979 matches!(
5980 err,
5981 DepError::VersaoInvalid { ref nome, ref versao, .. }
5982 if nome == "caixa-teia" && versao == "^^0.1"
5983 ),
5984 "got {err:?}"
5985 );
5986 }
5987
5988 #[test]
5989 fn validate_rejects_versao_with_v_prefixed_tag() {
5990 // `"v0.1"` is the canonical "git-tag-shape leaking into the
5991 // semver requirement slot" typo — an author copies the
5992 // publish-side git-tag string verbatim into `:versao`, but
5993 // Cargo's semver parser rejects the leading `v`. Same fixture
5994 // pinned for `:membros :versao` (9888b13) and `:children
5995 // :versao` (b38ff3a). (Bare `x`-glob shorthands like `^0.1.x`
5996 // are *accepted* by the semver crate as an `*` wildcard on the
5997 // patch axis — they're a Cargo-side valid shape, not a typo.)
5998 let d = Dep::simple("caixa-teia", "v0.1");
5999 let err = d.validate().unwrap_err();
6000 assert!(
6001 matches!(
6002 err,
6003 DepError::VersaoInvalid { ref nome, ref versao, .. }
6004 if nome == "caixa-teia" && versao == "v0.1"
6005 ),
6006 "got {err:?}"
6007 );
6008 }
6009
6010 #[test]
6011 fn validate_accepts_canonical_versao_forms() {
6012 // The five Cargo-shaped requirement forms `:membros :versao`
6013 // and `:children :versao` already accept via
6014 // `crate::parse_requirement` must pass the deps gate without
6015 // re-validating at the resolver layer. Pin every leg so a
6016 // future tightening of the canonical set surfaces here as a
6017 // test failure.
6018 for form in [
6019 "^0.1", // caret — minor-range pin (the most common shape)
6020 "~0.1.2", // tilde — patch-range pin
6021 "0.1.0", // exact — single-version pin
6022 "*", // wildcard — explicitly any-version
6023 ">=0.1, <2", // multi-range — comma-separated comparators
6024 ] {
6025 Dep::simple("caixa-teia", form)
6026 .validate()
6027 .unwrap_or_else(|e| panic!("canonical form {form:?} must validate, got {e:?}"));
6028 }
6029 }
6030
6031 #[test]
6032 fn versao_empty_takes_precedence_over_invalid() {
6033 // Order pin: the existing `VersaoEmpty` diagnostic (which
6034 // doesn't try to parse) fires before the new `VersaoInvalid`
6035 // parse-side diagnostic, so an empty `:versao` keeps its
6036 // narrower error message — `parse_requirement("")` would
6037 // otherwise return `Ok(STAR)` and silently pass, but the empty
6038 // arm catches it first.
6039 let mut d = Dep::simple("caixa-teia", "ignored");
6040 d.versao = String::new();
6041 let err = d.validate().unwrap_err();
6042 assert!(
6043 matches!(err, DepError::VersaoEmpty { ref nome } if nome == "caixa-teia"),
6044 "got {err:?}"
6045 );
6046 }
6047
6048 #[test]
6049 fn nome_empty_takes_precedence_over_versao_invalid() {
6050 // Order pin: even when `:versao` is malformed and would raise
6051 // its own diagnostic, `:nome ""` fires first because the
6052 // per-entry parse diagnostic needs a non-empty name to be
6053 // self-locating. Mirrors the
6054 // `membros_validation_runs_before_contratos_membership_check`
6055 // ordering on the typed-graph layer.
6056 let mut d = Dep::simple("placeholder", "^bad");
6057 d.nome = String::new();
6058 let err = d.validate().unwrap_err();
6059 assert_eq!(err, DepError::NomeEmpty);
6060 }
6061
6062 #[test]
6063 fn versao_invalid_diagnostic_carries_offending_versao() {
6064 // The diagnostic-shape pin: the error names the offending
6065 // `:versao` value verbatim so the author can grep their
6066 // caixa.lisp without re-running the build, and carries a
6067 // non-empty `reason` from `semver::VersionReq::parse` so the
6068 // parser's own wording flows through to the diagnostic.
6069 let d = Dep::simple("caixa-teia", "not-a-req");
6070 let err = d.validate().unwrap_err();
6071 let DepError::VersaoInvalid {
6072 nome,
6073 versao,
6074 reason,
6075 } = err
6076 else {
6077 panic!("expected VersaoInvalid, got other variant");
6078 };
6079 assert_eq!(nome, "caixa-teia");
6080 assert_eq!(versao, "not-a-req");
6081 assert!(
6082 !reason.is_empty(),
6083 "VersaoInvalid `reason` must carry the parser's wording verbatim"
6084 );
6085 }
6086
6087 // -- :fonte value-shape gate ------------------------------------------
6088
6089 fn dep_with_fonte(fonte: DepSource) -> Dep {
6090 let mut d = Dep::simple("caixa-teia", "^0.1");
6091 d.fonte = Some(fonte);
6092 d
6093 }
6094
6095 #[test]
6096 fn validate_accepts_git_fonte_with_tag() {
6097 // The positive-control pin on the canonical git source — exactly
6098 // one of :tag/:rev/:branch set, non-empty :repo. Mirrors the
6099 // shape every existing caixa-resolver integration test uses.
6100 let d = dep_with_fonte(DepSource::Git {
6101 repo: "github:pleme-io/caixa-teia".into(),
6102 tag: Some("v0.1.0".into()),
6103 rev: None,
6104 branch: None,
6105 });
6106 d.validate().unwrap();
6107 }
6108
6109 #[test]
6110 fn validate_accepts_git_fonte_with_rev() {
6111 // Each of the three pin axes is independently a valid single-pin
6112 // shape; pin the :rev arm so a future relaxation that only
6113 // accepts :tag surfaces here. The value is a full 40-hex SHA-1
6114 // OID — the canonical `git rev-parse HEAD` emission shape the
6115 // `crate::render::is_git_oid` value-shape gate now requires;
6116 // abbreviated OIDs are ambiguous across repo history and
6117 // rejected at this gate (pinned separately by
6118 // `validate_rejects_git_fonte_with_rev_abbreviated_prefix`).
6119 let d = dep_with_fonte(DepSource::Git {
6120 repo: "github:pleme-io/caixa-teia".into(),
6121 tag: None,
6122 rev: Some("c0ffee0123abcdef0123456789abcdef01234567".into()),
6123 branch: None,
6124 });
6125 d.validate().unwrap();
6126 }
6127
6128 #[test]
6129 fn validate_accepts_git_fonte_with_branch() {
6130 // The :branch arm is the third valid single-pin shape — pinned
6131 // separately so the gate-accepts-all-three-pin-axes contract is
6132 // a build-error to relax.
6133 let d = dep_with_fonte(DepSource::Git {
6134 repo: "github:pleme-io/caixa-teia".into(),
6135 tag: None,
6136 rev: None,
6137 branch: Some("main".into()),
6138 });
6139 d.validate().unwrap();
6140 }
6141
6142 #[test]
6143 fn validate_accepts_path_fonte() {
6144 // The positive-control pin on the path source — non-empty
6145 // :caminho, no pin axes (paths have no commit identity). Pinned
6146 // so a future "paths must also pin a rev" tightening surfaces
6147 // here as a structural decision, not a silent break.
6148 let d = dep_with_fonte(DepSource::Path {
6149 caminho: "../caixa-teia".into(),
6150 });
6151 d.validate().unwrap();
6152 }
6153
6154 #[test]
6155 fn validate_rejects_git_fonte_with_empty_repo() {
6156 // The fail-before-pass-after pin for `(:tipo git :repo "" :tag
6157 // "v1")`: the empty-repo shape silently passed every pre-gate
6158 // codebase because `:fonte` wasn't validated. The git-clone
6159 // failure surfaced far downstream at lacre-resolve time with no
6160 // field naming which `:deps` entry carried the typo. The new
6161 // gate moves the check to caixa-build time at the source
6162 // caixa.lisp.
6163 let d = dep_with_fonte(DepSource::Git {
6164 repo: String::new(),
6165 tag: Some("v0.1.0".into()),
6166 rev: None,
6167 branch: None,
6168 });
6169 let err = d.validate().unwrap_err();
6170 assert!(
6171 matches!(err, DepError::FonteRepoEmpty { ref nome } if nome == "caixa-teia"),
6172 "got {err:?}"
6173 );
6174 }
6175
6176 // -- :repo value-shape gate -------------------------------------------
6177 //
6178 // The `:fonte (:tipo git :repo …)` value flows verbatim into the
6179 // caixa-resolver's `git clone <repo>` subprocess. The pre-gate
6180 // codebase admitted any non-empty string; the new
6181 // [`crate::render::is_git_repo_url`] predicate gates the git-porcelain
6182 // URL intersection-floor at validate time, peer with the three pin
6183 // axes (`:tag` + `:branch` via `is_git_ref_name`, `:rev` via
6184 // `is_git_oid`). Every test in this section is a fail-before /
6185 // pass-after pin on a specific authoring footgun.
6186
6187 #[test]
6188 fn validate_rejects_git_fonte_with_repo_carrying_trailing_space() {
6189 // The canonical paste-from-doc footgun on `:repo` — an author
6190 // copies `"github:pleme-io/caixa-teia "` (trailing space) out of
6191 // a doc paragraph. Until this gate landed the empty-repo arm
6192 // passed (the string isn't empty), the resolver issued
6193 // `git clone 'github:pleme-io/caixa-teia '`, and the failure
6194 // surfaced at clone time with a quoting-confused error far from
6195 // the source caixa.lisp. Same paste-from-doc footgun the
6196 // `:tag "v0.1.0 "` gate (e70d213) closes on the peer refname
6197 // axis — now closed on the `:repo` URL axis too.
6198 let d = dep_with_fonte(DepSource::Git {
6199 repo: "github:pleme-io/caixa-teia ".into(),
6200 tag: Some("v0.1.0".into()),
6201 rev: None,
6202 branch: None,
6203 });
6204 let err = d.validate().unwrap_err();
6205 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6206 panic!("expected FonteRepoShape, got other variant");
6207 };
6208 assert_eq!(nome, "caixa-teia");
6209 assert_eq!(repo, "github:pleme-io/caixa-teia ");
6210 assert!(
6211 reason.contains("whitespace"),
6212 "reason must surface the whitespace arm, got {reason:?}"
6213 );
6214 }
6215
6216 #[test]
6217 fn validate_rejects_git_fonte_with_repo_starting_with_dash() {
6218 // The canonical CLI-argument-injection footgun at the `git clone`
6219 // subprocess boundary — `:repo "-upload-pack=evil"` makes git's
6220 // argv parser read the value as a CLI flag, escaping the
6221 // subprocess argument boundary. The `--` separator workaround
6222 // does not fix the typed slot's accepted set; the gate rejects
6223 // the shape upstream at validate time so the resolver never
6224 // invokes a `git clone -…` subprocess.
6225 let d = dep_with_fonte(DepSource::Git {
6226 repo: "-upload-pack=evil".into(),
6227 tag: Some("v0.1.0".into()),
6228 rev: None,
6229 branch: None,
6230 });
6231 let err = d.validate().unwrap_err();
6232 let DepError::FonteRepoShape { repo, reason, .. } = err else {
6233 panic!("expected FonteRepoShape, got other variant");
6234 };
6235 assert_eq!(repo, "-upload-pack=evil");
6236 assert!(
6237 reason.contains("must not start with `-`"),
6238 "reason must surface the leading-`-` arm, got {reason:?}"
6239 );
6240 }
6241
6242 #[test]
6243 fn validate_rejects_git_fonte_with_repo_carrying_embedded_newline() {
6244 // The canonical paste-from-multiline-doc footgun — a `:repo`
6245 // string with an embedded `\n` silently breaks git's URL parser
6246 // and is a class of CRLF-injection at the subprocess-argument
6247 // boundary. Caught by the control-char arm (0x0A < 0x20).
6248 let d = dep_with_fonte(DepSource::Git {
6249 repo: "github:pleme-io/caixa-teia\nrm -rf /".into(),
6250 tag: Some("v0.1.0".into()),
6251 rev: None,
6252 branch: None,
6253 });
6254 let err = d.validate().unwrap_err();
6255 let DepError::FonteRepoShape { reason, .. } = err else {
6256 panic!("expected FonteRepoShape, got other variant");
6257 };
6258 assert!(
6259 reason.contains("control character"),
6260 "reason must surface the control-char arm, got {reason:?}"
6261 );
6262 }
6263
6264 #[test]
6265 fn validate_rejects_git_fonte_with_repo_carrying_tab() {
6266 // Tab is the sibling whitespace footgun (the canonical
6267 // copy-from-aligned-table paste); pinned separately from the
6268 // space arm so a future relaxation that only catches one
6269 // surfaces here.
6270 let d = dep_with_fonte(DepSource::Git {
6271 repo: "github:pleme-io/caixa-teia\t".into(),
6272 tag: Some("v0.1.0".into()),
6273 rev: None,
6274 branch: None,
6275 });
6276 let err = d.validate().unwrap_err();
6277 assert!(
6278 matches!(
6279 err,
6280 DepError::FonteRepoShape { ref reason, .. }
6281 if reason.contains("whitespace")
6282 ),
6283 "got {err:?}"
6284 );
6285 }
6286
6287 #[test]
6288 fn validate_rejects_git_fonte_with_repo_carrying_non_ascii() {
6289 // IDN hosts must be pre-encoded as Punycode (`xn--…`) — raw
6290 // non-ASCII silently breaks at git's URL parser and round-trips
6291 // inconsistently across NFC/NFD normalization on APFS /
6292 // case-folding filesystems. Same intersection-floor
6293 // [`is_git_ref_name`] enforces on the refname axes.
6294 let d = dep_with_fonte(DepSource::Git {
6295 repo: "https://github.com/pleme-io/café".into(),
6296 tag: Some("v0.1.0".into()),
6297 rev: None,
6298 branch: None,
6299 });
6300 let err = d.validate().unwrap_err();
6301 assert!(
6302 matches!(
6303 err,
6304 DepError::FonteRepoShape { ref reason, .. }
6305 if reason.contains("non-ASCII")
6306 ),
6307 "got {err:?}"
6308 );
6309 }
6310
6311 #[test]
6312 fn validate_rejects_git_fonte_with_repo_carrying_fragment_anchor() {
6313 // The fail-before-pass-after pin for the canonical paste-from-
6314 // browser-address-bar footgun on `:repo`: an author copies a
6315 // GitHub permalink to a README anchor / line-permalink and
6316 // forgets to trim the `#fragment` tail. Until this arm landed
6317 // `:repo "https://github.com/pleme-io/caixa-teia#readme"`
6318 // silently passed every prior arm (no whitespace, no control
6319 // chars, no non-ASCII, contains a `:`, doesn't start with `-`
6320 // or `:`), libcurl's URL parser stripped the `#readme` tail
6321 // before opening the HTTPS transport, and the lacre embedded
6322 // the value verbatim in its per-dep BLAKE3 closure — two
6323 // authors whose values differ only in their fragment anchor
6324 // (`#readme` vs `#L42`) resolve to the byte-identical upstream
6325 // `git clone` but lock to two distinct lacres, defeating the
6326 // THEORY.md §V.2 render-determinism contract. Same value-shape
6327 // axis-floor every peer typed surface enforces; peer `:fonte
6328 // :tag` / `:fonte :branch` already reject the byte-class through
6329 // `is_git_ref_name`'s alphabet (refs are leaf identifiers, no
6330 // URL grammar admitted) and `:entrada :paths` rejects `#` as
6331 // part of `is_gateway_api_http_path`'s RFC-3986-reserved set.
6332 let d = dep_with_fonte(DepSource::Git {
6333 repo: "https://github.com/pleme-io/caixa-teia#readme".into(),
6334 tag: Some("v0.1.0".into()),
6335 rev: None,
6336 branch: None,
6337 });
6338 let err = d.validate().unwrap_err();
6339 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6340 panic!("expected FonteRepoShape, got other variant");
6341 };
6342 assert_eq!(nome, "caixa-teia");
6343 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia#readme");
6344 assert!(
6345 reason.contains("must not contain `#`"),
6346 "reason must surface the fragment-`#` arm, got {reason:?}"
6347 );
6348 assert!(
6349 reason.contains("fragment"),
6350 "reason must name the URL fragment grammar, got {reason:?}"
6351 );
6352 }
6353
6354 #[test]
6355 fn validate_rejects_git_fonte_with_repo_carrying_flake_ref_fragment() {
6356 // The symmetric paste-from-Nix-flake-ref footgun — an author
6357 // confuses the Nix flake-reference idiom (`github:foo/
6358 // bar#packageName`, where `#packageName` selects a flake
6359 // output) with the bare git `:repo` shape. The pleme-io
6360 // substrate authors compose flakes downstream of caixa
6361 // (caixa-flake renders a flake.nix), so the cross-idiom leak
6362 // is the canonical near-miss: the author writes the
6363 // flake-ref shape into a git `:repo` slot. Pinned separately
6364 // from the HTTPS-anchor arm so a future relaxation that
6365 // narrows to one URL scheme surfaces here.
6366 let d = dep_with_fonte(DepSource::Git {
6367 repo: "github:pleme-io/caixa-teia#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 { reason, .. } = err else {
6374 panic!("expected FonteRepoShape, got other variant");
6375 };
6376 assert!(
6377 reason.contains("must not contain `#`"),
6378 "reason must surface the fragment-`#` arm, got {reason:?}"
6379 );
6380 assert!(
6381 reason.contains("Nix flake"),
6382 "reason must name the Nix-flake-ref cross-idiom footgun, got {reason:?}"
6383 );
6384 }
6385
6386 #[test]
6387 fn validate_rejects_git_fonte_with_repo_carrying_query_string() {
6388 // The fail-before-pass-after pin for the canonical paste-from-
6389 // browser-address-bar footgun on `:repo` (peer with the
6390 // a68f818 fragment-`#` arm on the same axis). An author
6391 // copies a GitHub tab deep-link out of the address bar and
6392 // forgets to trim the `?tab=…` query tail. Until this arm
6393 // landed `:repo "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"`
6394 // silently passed every prior arm (no whitespace, no control
6395 // chars, no non-ASCII, no `#` fragment, contains a `:`,
6396 // doesn't start with `-` or `:`); GitHub silently ignored
6397 // the `?query` tail and served the same repo regardless;
6398 // the lacre embedded the value verbatim in its per-dep
6399 // BLAKE3 closure — two authors whose values differ only in
6400 // their query tail (`?tab=readme-ov-file` vs `?ref=main` vs
6401 // `?utm_source=twitter`) resolve to the byte-identical
6402 // upstream `git clone` but lock to two distinct lacres,
6403 // defeating the THEORY.md §V.2 render-determinism contract
6404 // on the same axis the `#` fragment arm closes. Same value-
6405 // shape axis-floor every peer typed surface enforces; peer
6406 // `:fonte :tag` / `:fonte :branch` already reject the byte-
6407 // class through `is_git_ref_name`'s alphabet (refspec glob
6408 // wildcards, caixa-core/src/render.rs:1426) and `:entrada
6409 // :paths` rejects `?` as the query separator in
6410 // `is_gateway_api_http_path` (caixa-core/src/render.rs:473).
6411 let d = dep_with_fonte(DepSource::Git {
6412 repo: "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file".into(),
6413 tag: Some("v0.1.0".into()),
6414 rev: None,
6415 branch: None,
6416 });
6417 let err = d.validate().unwrap_err();
6418 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6419 panic!("expected FonteRepoShape, got other variant");
6420 };
6421 assert_eq!(nome, "caixa-teia");
6422 assert_eq!(
6423 repo,
6424 "https://github.com/pleme-io/caixa-teia?tab=readme-ov-file"
6425 );
6426 assert!(
6427 reason.contains("must not contain `?`"),
6428 "reason must surface the query-`?` arm, got {reason:?}"
6429 );
6430 assert!(
6431 reason.contains("query"),
6432 "reason must name the URL query grammar, got {reason:?}"
6433 );
6434 }
6435
6436 #[test]
6437 fn validate_rejects_git_fonte_with_repo_carrying_utm_tracker() {
6438 // The symmetric paste-from-social-share footgun — an author
6439 // copies a repo URL out of a Slack unfurl / Twitter share /
6440 // newsletter link / Discord embed and forgets to trim the
6441 // `?utm_source=…` / `?utm_medium=…` / `?utm_campaign=…`
6442 // campaign-tracker tail. Every major social-share / unfurl /
6443 // newsletter platform appends these UTM parameters; the
6444 // canonical near-miss on the `:repo` axis. Pinned separately
6445 // from the GitHub-tab-deep-link arm so a future relaxation
6446 // that narrows to one query-parameter class surfaces here.
6447 let d = dep_with_fonte(DepSource::Git {
6448 repo: "https://github.com/pleme-io/caixa-teia?utm_source=twitter&utm_campaign=launch"
6449 .into(),
6450 tag: Some("v0.1.0".into()),
6451 rev: None,
6452 branch: None,
6453 });
6454 let err = d.validate().unwrap_err();
6455 let DepError::FonteRepoShape { reason, .. } = err else {
6456 panic!("expected FonteRepoShape, got other variant");
6457 };
6458 assert!(
6459 reason.contains("must not contain `?`"),
6460 "reason must surface the query-`?` arm, got {reason:?}"
6461 );
6462 assert!(
6463 reason.contains("campaign-tracker"),
6464 "reason must name the campaign-tracker paste footgun, got {reason:?}"
6465 );
6466 }
6467
6468 #[test]
6469 fn fonte_repo_fragment_fires_before_query_when_fragment_first() {
6470 // Cascade pin: the fragment-`#` arm and the query-`?` arm are
6471 // both per-byte arms inside the same `for &b in s.as_bytes()`
6472 // loop, so the byte that appears first in the value's byte
6473 // order wins. A `:repo "https://github.com/p/x#readme?ref=main"`
6474 // (fragment before query — unusual URL-grammar but value-
6475 // disjoint at byte level) carries both `#` and `?`; the `#`
6476 // byte appears first, so the fragment-`#` arm fires, surfacing
6477 // the more self-locating diagnostic on the byte the author
6478 // pasted earliest in the URL. Mirrors the peer cascade
6479 // discipline `fonte_repo_control_char_fires_before_fragment`
6480 // pins on the prior `:repo` byte-class arm.
6481 let d = dep_with_fonte(DepSource::Git {
6482 repo: "https://github.com/pleme-io/caixa-teia#readme?ref=main".into(),
6483 tag: Some("v0.1.0".into()),
6484 rev: None,
6485 branch: None,
6486 });
6487 let err = d.validate().unwrap_err();
6488 let DepError::FonteRepoShape { reason, .. } = err else {
6489 panic!("expected FonteRepoShape, got other variant");
6490 };
6491 assert!(
6492 reason.contains("must not contain `#`"),
6493 "reason must surface the fragment-`#` arm (fires before query-`?` when \
6494 `#` byte appears first in value), got {reason:?}"
6495 );
6496 }
6497
6498 #[test]
6499 fn fonte_repo_control_char_fires_before_fragment() {
6500 // Cascade pin: the control-char arm structurally precedes the
6501 // fragment-`#` arm. A value like `"github:p/x\n#readme"` probes
6502 // positive on both arms (contains LF and `#`), but the narrower
6503 // POSIX-syscall-rejected / CRLF-injection-class diagnostic
6504 // (`control character`) wins so the author sees the more
6505 // self-locating arm first. Mirrors the peer cascade discipline
6506 // every prior `:repo` byte-class arm establishes.
6507 let d = dep_with_fonte(DepSource::Git {
6508 repo: "github:pleme-io/caixa-teia\n#readme".into(),
6509 tag: Some("v0.1.0".into()),
6510 rev: None,
6511 branch: None,
6512 });
6513 let err = d.validate().unwrap_err();
6514 let DepError::FonteRepoShape { reason, .. } = err else {
6515 panic!("expected FonteRepoShape, got other variant");
6516 };
6517 assert!(
6518 reason.contains("control character"),
6519 "reason must surface the control-char arm, got {reason:?}"
6520 );
6521 }
6522
6523 #[test]
6524 fn validate_rejects_git_fonte_with_repo_carrying_embedded_backslash() {
6525 // The fail-before-pass-after pin for the canonical Windows-
6526 // file-path-confusion footgun on `:repo` (peer with the 3a4e1d7
6527 // backslash arm on the sibling `:caminho` path-fonte axis).
6528 // An author pastes a Windows Explorer address-bar / PowerShell
6529 // `Get-Location` output into a `file://` URL slot, producing
6530 // `file:///C:\Users\me\caixa-teia`. Until this arm landed the
6531 // value silently passed every prior arm (no whitespace, no
6532 // control chars, no non-ASCII, no `#`, no `?`, doesn't start
6533 // with `-` or `:`); libcurl's URL parser silently translates
6534 // `\` → `/` on some platforms and refuses it on others, so
6535 // the byte rides verbatim into the lacre's per-dep content-
6536 // address but is silently rewritten / rejected at the wire —
6537 // two authors whose `:repo` values differ only in backslash-
6538 // vs-forward-slash (`file:///C:\path` vs `file:///C:/path`)
6539 // resolve to the byte-identical local clone but lock to two
6540 // distinct BLAKE3 closures, defeating the THEORY.md §V.2
6541 // render-determinism contract on the same axis the `#`
6542 // fragment and `?` query arms close. Same value-shape axis-
6543 // floor every peer typed surface enforces; the `:caminho`
6544 // 3a4e1d7 arm closes the same byte on the path-fonte axis.
6545 let d = dep_with_fonte(DepSource::Git {
6546 repo: "file:///C:\\Users\\me\\caixa-teia".into(),
6547 tag: Some("v0.1.0".into()),
6548 rev: None,
6549 branch: None,
6550 });
6551 let err = d.validate().unwrap_err();
6552 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6553 panic!("expected FonteRepoShape, got other variant");
6554 };
6555 assert_eq!(nome, "caixa-teia");
6556 assert_eq!(repo, "file:///C:\\Users\\me\\caixa-teia");
6557 assert!(
6558 reason.contains("must not contain `\\`"),
6559 "reason must surface the backslash-`\\` arm, got {reason:?}"
6560 );
6561 assert!(
6562 reason.contains("Windows"),
6563 "reason must name the Windows-path-confusion footgun, got {reason:?}"
6564 );
6565 }
6566
6567 #[test]
6568 fn validate_rejects_git_fonte_with_repo_carrying_mangled_https_backslashes() {
6569 // The symmetric Win32-shell-mangled-slashes footgun — an author
6570 // copies `https://github.com/foo/bar` into a Win32 shell that
6571 // rewrites every `/` to `\` (the canonical `cmd.exe` path-
6572 // separator-coercion bug), pastes the result into a `:repo`
6573 // slot, and produces `https:\\github.com\foo\bar`. Pinned
6574 // separately from the `file://` Explorer-paste arm so a future
6575 // relaxation that narrows to one URL scheme surfaces here.
6576 let d = dep_with_fonte(DepSource::Git {
6577 repo: "https:\\\\github.com\\pleme-io\\caixa-teia".into(),
6578 tag: Some("v0.1.0".into()),
6579 rev: None,
6580 branch: None,
6581 });
6582 let err = d.validate().unwrap_err();
6583 let DepError::FonteRepoShape { reason, .. } = err else {
6584 panic!("expected FonteRepoShape, got other variant");
6585 };
6586 assert!(
6587 reason.contains("must not contain `\\`"),
6588 "reason must surface the backslash-`\\` arm, got {reason:?}"
6589 );
6590 assert!(
6591 reason.contains("path separator") || reason.contains("path-segment separator"),
6592 "reason must name the URL path-segment separator grammar, got {reason:?}"
6593 );
6594 }
6595
6596 #[test]
6597 fn fonte_repo_fragment_fires_before_backslash_when_fragment_first() {
6598 // Cascade pin: the fragment-`#` arm and the backslash-`\` arm
6599 // are both per-byte arms inside the same `for &b in s.as_bytes()`
6600 // loop, so the byte that appears first in the value's byte order
6601 // wins. A `:repo "https://github.com/p/x#readme\\foo"` carries
6602 // both `#` and `\`; the `#` byte appears first, so the fragment-
6603 // `#` arm fires, surfacing the more self-locating diagnostic on
6604 // the byte the author pasted earliest in the URL. Mirrors the
6605 // peer cascade discipline `fonte_repo_fragment_fires_before_query_when_fragment_first`
6606 // pins on the prior `:repo` byte-class arm.
6607 let d = dep_with_fonte(DepSource::Git {
6608 repo: "https://github.com/pleme-io/caixa-teia#readme\\foo".into(),
6609 tag: Some("v0.1.0".into()),
6610 rev: None,
6611 branch: None,
6612 });
6613 let err = d.validate().unwrap_err();
6614 let DepError::FonteRepoShape { reason, .. } = err else {
6615 panic!("expected FonteRepoShape, got other variant");
6616 };
6617 assert!(
6618 reason.contains("must not contain `#`"),
6619 "reason must surface the fragment-`#` arm (fires before backslash-`\\` when \
6620 `#` byte appears first in value), got {reason:?}"
6621 );
6622 }
6623
6624 #[test]
6625 fn validate_rejects_git_fonte_with_repo_carrying_uri_template_placeholder() {
6626 // The fail-before-pass-after pin for the canonical URI Template
6627 // (RFC 6570) placeholder footgun on `:repo`. An author copies a
6628 // README quick-start snippet / OpenAPI `servers:` URL / Helm
6629 // chart `home:` template that carries unresolved
6630 // `{org}` / `{repo}` placeholders and pastes the raw template
6631 // into the `:repo` slot, expecting the substrate to resolve the
6632 // placeholder downstream. Until this arm landed the value
6633 // silently passed every prior arm (no whitespace, no control
6634 // chars, no non-ASCII, no `#`, no `?`, no `\`, doesn't start
6635 // with `-` or `:`); libcurl percent-encodes `{` / `}` to `%7B`
6636 // / `%7D` on the wire, so the byte rides verbatim into the
6637 // lacre's per-dep content-address but round-trips inconsistently
6638 // between the lacre's per-dep content-address and the
6639 // resolver's `git clone <repo>` invocation, defeating the
6640 // THEORY.md §V.2 render-determinism contract on the same axis
6641 // the `#` fragment, `?` query, and `\` backslash arms close;
6642 // every git porcelain entry-point additionally fetches a
6643 // nonexistent literal-`{placeholder}`-named path far from the
6644 // source caixa.lisp.
6645 let d = dep_with_fonte(DepSource::Git {
6646 repo: "https://github.com/{org}/caixa-teia".into(),
6647 tag: Some("v0.1.0".into()),
6648 rev: None,
6649 branch: None,
6650 });
6651 let err = d.validate().unwrap_err();
6652 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6653 panic!("expected FonteRepoShape, got other variant");
6654 };
6655 assert_eq!(nome, "caixa-teia");
6656 assert_eq!(repo, "https://github.com/{org}/caixa-teia");
6657 assert!(
6658 reason.contains("must not contain `{`"),
6659 "reason must surface the open-brace `{{` arm, got {reason:?}"
6660 );
6661 assert!(
6662 reason.contains("URI Template") || reason.contains("RFC 6570"),
6663 "reason must name the RFC 6570 URI Template grammar, got {reason:?}"
6664 );
6665 }
6666
6667 #[test]
6668 fn validate_rejects_git_fonte_with_repo_carrying_handlebars_doubled_brace() {
6669 // The symmetric Mustache / Handlebars doubled-brace
6670 // substitution-form footgun every CI / IaC templating engine
6671 // (Argo Workflows, Jinja2, Liquid, Vue / Angular interpolation,
6672 // GitHub Actions `${{ … }}` even though Actions uses `${{`) /
6673 // chart README quick-start snippet emits. Pinned separately
6674 // from the single-`{` `{org}` arm so a future relaxation that
6675 // narrows to one substitution-form surfaces here.
6676 let d = dep_with_fonte(DepSource::Git {
6677 repo: "https://github.com/{{org}}/caixa-teia".into(),
6678 tag: Some("v0.1.0".into()),
6679 rev: None,
6680 branch: None,
6681 });
6682 let err = d.validate().unwrap_err();
6683 let DepError::FonteRepoShape { reason, .. } = err else {
6684 panic!("expected FonteRepoShape, got other variant");
6685 };
6686 assert!(
6687 reason.contains("must not contain `{`"),
6688 "reason must surface the open-brace `{{` arm, got {reason:?}"
6689 );
6690 }
6691
6692 #[test]
6693 fn validate_rejects_git_fonte_with_repo_carrying_closing_brace_only() {
6694 // Asymmetric `}`-only shape — covers the closing-brace-by-
6695 // itself footgun (an author truncated `{org}/{repo}` mid-edit
6696 // and left a trailing `}` from the prior template fragment,
6697 // or pasted a value that included a closing brace from a
6698 // surrounding shell context). Pinned to ensure the predicate
6699 // refuses each brace independently rather than only when both
6700 // appear — a future regression that ANDs the two byte tests
6701 // surfaces here.
6702 let d = dep_with_fonte(DepSource::Git {
6703 repo: "https://github.com/pleme-io/caixa-teia}".into(),
6704 tag: Some("v0.1.0".into()),
6705 rev: None,
6706 branch: None,
6707 });
6708 let err = d.validate().unwrap_err();
6709 let DepError::FonteRepoShape { reason, .. } = err else {
6710 panic!("expected FonteRepoShape, got other variant");
6711 };
6712 assert!(
6713 reason.contains("must not contain `}`"),
6714 "reason must surface the close-brace `}}` arm, got {reason:?}"
6715 );
6716 }
6717
6718 #[test]
6719 fn fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first() {
6720 // Cascade pin: the fragment-`#` arm and the template-`{` /
6721 // `}` arm are both per-byte arms inside the same
6722 // `for &b in s.as_bytes()` loop, so the byte that appears
6723 // first in the value's byte order wins. A `:repo
6724 // "https://github.com/p/x#readme{org}"` carries both `#` and
6725 // `{`; the `#` byte appears first, so the fragment-`#` arm
6726 // fires, surfacing the more self-locating diagnostic on the
6727 // byte the author pasted earliest in the URL. Mirrors the
6728 // peer cascade discipline `fonte_repo_fragment_fires_before_backslash_when_fragment_first`
6729 // pins on the prior `:repo` byte-class arm.
6730 let d = dep_with_fonte(DepSource::Git {
6731 repo: "https://github.com/pleme-io/caixa-teia#readme{org}".into(),
6732 tag: Some("v0.1.0".into()),
6733 rev: None,
6734 branch: None,
6735 });
6736 let err = d.validate().unwrap_err();
6737 let DepError::FonteRepoShape { reason, .. } = err else {
6738 panic!("expected FonteRepoShape, got other variant");
6739 };
6740 assert!(
6741 reason.contains("must not contain `#`"),
6742 "reason must surface the fragment-`#` arm (fires before template-`{{` when \
6743 `#` byte appears first in value), got {reason:?}"
6744 );
6745 }
6746
6747 #[test]
6748 fn validate_rejects_git_fonte_with_repo_carrying_output_redirection() {
6749 // The fail-before-pass-after pin for the canonical
6750 // shell-output-redirection footgun on `:repo`: an author
6751 // pastes a shell-pipeline tail (`git clone <repo> > build.log`
6752 // / `… >output.txt`) into the `:repo` slot without trimming
6753 // the redirect. Until this arm landed the value silently
6754 // passed every prior arm (no whitespace, no control chars,
6755 // no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, doesn't
6756 // start with `-` or `:`); RFC 3986 §2 lists `<` / `>` in the
6757 // 'delims' / 'unwise' set and the WHATWG URL spec's fragment
6758 // percent-encode set maps `>` → `%3E` on the wire, so the
6759 // byte rides verbatim into the lacre's per-dep BLAKE3 closure
6760 // but is silently rewritten or rejected at libcurl's URL-
6761 // parser layer — two authors whose values differ only in
6762 // their redirect tail (`>build.log` vs nothing) resolve to
6763 // the byte-identical upstream `git clone` but lock to two
6764 // distinct lacres, defeating the THEORY.md §V.2 render-
6765 // determinism contract. Peer with the `:caminho` axis's
6766 // `FonteCaminhoShellRedirection` arm (e457141) on the sibling
6767 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
6768 // byte RFC-3986-reserved set on `:entrada :paths`.
6769 let d = dep_with_fonte(DepSource::Git {
6770 repo: "https://github.com/pleme-io/caixa-teia>build.log".into(),
6771 tag: Some("v0.1.0".into()),
6772 rev: None,
6773 branch: None,
6774 });
6775 let err = d.validate().unwrap_err();
6776 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6777 panic!("expected FonteRepoShape, got other variant");
6778 };
6779 assert_eq!(nome, "caixa-teia");
6780 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia>build.log");
6781 assert!(
6782 reason.contains("must not contain `>`"),
6783 "reason must surface the output-redirection `>` arm, got {reason:?}"
6784 );
6785 assert!(
6786 reason.contains("redirection") || reason.contains("'delims'"),
6787 "reason must name the shell-redirection / RFC-3986-unwise rationale, got {reason:?}"
6788 );
6789 }
6790
6791 #[test]
6792 fn validate_rejects_git_fonte_with_repo_carrying_input_redirection() {
6793 // The symmetric shell-input-redirection footgun — an author
6794 // pastes a shell-pipeline head (`git clone <input.url` /
6795 // `cat <README.md`) into the `:repo` slot. Pinned separately
6796 // from the `>`-output arm so a future relaxation that only
6797 // catches one of the two redirect bytes surfaces here. Peer
6798 // with the `:caminho` axis's `FonteCaminhoShellRedirection`
6799 // arm which closes both `<` and `>` under the same banner.
6800 let d = dep_with_fonte(DepSource::Git {
6801 repo: "https://github.com/pleme-io/caixa-teia<input.url".into(),
6802 tag: Some("v0.1.0".into()),
6803 rev: None,
6804 branch: None,
6805 });
6806 let err = d.validate().unwrap_err();
6807 let DepError::FonteRepoShape { reason, .. } = err else {
6808 panic!("expected FonteRepoShape, got other variant");
6809 };
6810 assert!(
6811 reason.contains("must not contain `<`"),
6812 "reason must surface the input-redirection `<` arm, got {reason:?}"
6813 );
6814 assert!(
6815 reason.contains("RFC 3986") || reason.contains("'unwise'"),
6816 "reason must name the RFC 3986 'unwise' grammar, got {reason:?}"
6817 );
6818 }
6819
6820 #[test]
6821 fn validate_rejects_git_fonte_with_repo_carrying_backtick_command_substitution() {
6822 // The fail-before-pass-after pin for the canonical
6823 // paste-from-shell-prompt-with-backticked-substitution footgun
6824 // on `:repo` (peer with the c4d62b3 backtick arm on the sibling
6825 // `:caminho` path-fonte axis). An author pastes a URL whose
6826 // segment carries a backticked command-substitution wrapper
6827 // (`` `whoami` ``, `` `git config user.name` ``, `` `pwd` ``)
6828 // from a doc / README quick-start snippet that expected the
6829 // substrate to substitute the value downstream. Until this arm
6830 // landed the value silently passed every prior arm (no
6831 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6832 // no `\`, no `{`/`}`, no `<`/`>`, doesn't start with `-` or
6833 // `:`); RFC 3986 §2 lists the backtick byte in the 'delims' /
6834 // 'unwise' set and the WHATWG URL spec's fragment percent-
6835 // encode set maps `` ` `` → `%60` on the wire, so the byte
6836 // rides verbatim into the lacre's per-dep BLAKE3 closure but
6837 // is silently rewritten or rejected at libcurl's URL-parser
6838 // layer — two authors whose values differ only in their
6839 // backtick wrapper (`` `whoami` `` vs nothing) resolve to the
6840 // byte-identical upstream `git clone` but lock to two distinct
6841 // lacres, defeating the THEORY.md §V.2 render-determinism
6842 // contract. Peer with the `:caminho` axis's
6843 // `FonteCaminhoShellCommandSubstitution` arm (c4d62b3) on the
6844 // sibling path-fonte axis, and `is_gateway_api_http_path`'s
6845 // eleven-byte RFC-3986-reserved set on `:entrada :paths`.
6846 let d = dep_with_fonte(DepSource::Git {
6847 repo: "https://github.com/pleme-io/`whoami`/caixa-teia".into(),
6848 tag: Some("v0.1.0".into()),
6849 rev: None,
6850 branch: None,
6851 });
6852 let err = d.validate().unwrap_err();
6853 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6854 panic!("expected FonteRepoShape, got other variant");
6855 };
6856 assert_eq!(nome, "caixa-teia");
6857 assert_eq!(repo, "https://github.com/pleme-io/`whoami`/caixa-teia");
6858 assert!(
6859 reason.contains("must not contain `` ` ``"),
6860 "reason must surface the backtick command-substitution arm, got {reason:?}"
6861 );
6862 assert!(
6863 reason.contains("command-substitution") || reason.contains("'unwise'"),
6864 "reason must name the shell-command-substitution / RFC-3986-unwise rationale, \
6865 got {reason:?}"
6866 );
6867 }
6868
6869 #[test]
6870 fn fonte_repo_fragment_fires_before_backtick_when_fragment_first() {
6871 // Cascade pin: the fragment-`#` arm and the backtick command-
6872 // substitution arm are both per-byte arms inside the same
6873 // `for &b in s.as_bytes()` loop, so the byte that appears first
6874 // in the value's byte order wins. A `:repo
6875 // "https://github.com/p/x#readme/`whoami`"` carries both `#`
6876 // and backtick; the `#` byte appears first, so the fragment-
6877 // `#` arm fires, surfacing the more self-locating diagnostic
6878 // on the byte the author pasted earliest in the URL. Mirrors
6879 // the peer cascade discipline
6880 // `fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first`
6881 // pins on the prior `:repo` byte-class arm.
6882 let d = dep_with_fonte(DepSource::Git {
6883 repo: "https://github.com/pleme-io/caixa-teia#readme/`whoami`".into(),
6884 tag: Some("v0.1.0".into()),
6885 rev: None,
6886 branch: None,
6887 });
6888 let err = d.validate().unwrap_err();
6889 let DepError::FonteRepoShape { reason, .. } = err else {
6890 panic!("expected FonteRepoShape, got other variant");
6891 };
6892 assert!(
6893 reason.contains("must not contain `#`"),
6894 "reason must surface the fragment-`#` arm (fires before backtick when `#` byte \
6895 appears first in value), got {reason:?}"
6896 );
6897 }
6898
6899 #[test]
6900 fn fonte_repo_shell_redirection_fires_before_backtick_when_redirection_first() {
6901 // Cascade pin: the shell-redirection `<` / `>` arm and the
6902 // backtick command-substitution arm are both per-byte arms
6903 // inside the same `for &b in s.as_bytes()` loop, so the byte
6904 // that appears first in the value's byte order wins. A `:repo
6905 // "https://github.com/p/x>build.log/`whoami`"` carries both
6906 // `>` and backtick; the `>` byte appears first, so the
6907 // shell-redirection arm fires, surfacing the more self-
6908 // locating diagnostic on the byte the author pasted earliest
6909 // in the URL. Pins the natural-order cascade so a future
6910 // reorder of the per-byte arms surfaces here.
6911 let d = dep_with_fonte(DepSource::Git {
6912 repo: "https://github.com/pleme-io/caixa-teia>build.log/`whoami`".into(),
6913 tag: Some("v0.1.0".into()),
6914 rev: None,
6915 branch: None,
6916 });
6917 let err = d.validate().unwrap_err();
6918 let DepError::FonteRepoShape { reason, .. } = err else {
6919 panic!("expected FonteRepoShape, got other variant");
6920 };
6921 assert!(
6922 reason.contains("must not contain `>`"),
6923 "reason must surface the shell-redirection `>` arm (fires before backtick when \
6924 `>` byte appears first in value), got {reason:?}"
6925 );
6926 }
6927
6928 #[test]
6929 fn fonte_repo_fragment_fires_before_shell_redirection_when_fragment_first() {
6930 // Cascade pin: the fragment-`#` arm and the shell-redirection
6931 // `<` / `>` arm are both per-byte arms inside the same
6932 // `for &b in s.as_bytes()` loop, so the byte that appears
6933 // first in the value's byte order wins. A `:repo
6934 // "https://github.com/p/x#readme>build.log"` carries both
6935 // `#` and `>`; the `#` byte appears first, so the fragment-
6936 // `#` arm fires, surfacing the more self-locating diagnostic
6937 // on the byte the author pasted earliest in the URL. Mirrors
6938 // the peer cascade discipline
6939 // `fonte_repo_fragment_fires_before_template_placeholder_when_fragment_first`
6940 // pins on the prior `:repo` byte-class arm.
6941 let d = dep_with_fonte(DepSource::Git {
6942 repo: "https://github.com/pleme-io/caixa-teia#readme>build.log".into(),
6943 tag: Some("v0.1.0".into()),
6944 rev: None,
6945 branch: None,
6946 });
6947 let err = d.validate().unwrap_err();
6948 let DepError::FonteRepoShape { reason, .. } = err else {
6949 panic!("expected FonteRepoShape, got other variant");
6950 };
6951 assert!(
6952 reason.contains("must not contain `#`"),
6953 "reason must surface the fragment-`#` arm (fires before shell-redirection `>` when \
6954 `#` byte appears first in value), got {reason:?}"
6955 );
6956 }
6957
6958 #[test]
6959 fn validate_rejects_git_fonte_with_repo_carrying_shell_pipe() {
6960 // The fail-before-pass-after pin for the canonical
6961 // paste-from-shell-prompt-with-piped-pipeline footgun on
6962 // `:repo` (peer with the 124106f pipe arm on the sibling
6963 // `:caminho` path-fonte axis). An author pastes a shell
6964 // pipeline (`git clone <url> | tee build.log`,
6965 // `git ls-remote <url> | head`) into the `:repo` slot,
6966 // forgetting to trim the `| <consumer>` tail. Until this arm
6967 // landed the value silently passed every prior arm (no
6968 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
6969 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, doesn't start
6970 // with `-` or `:`); RFC 3986 §2 lists the pipe byte in the
6971 // 'unwise' set and the WHATWG URL spec's fragment percent-
6972 // encode set maps `|` → `%7C` on the wire, so the byte rides
6973 // verbatim into the lacre's per-dep BLAKE3 closure but is
6974 // silently rewritten or rejected at libcurl's URL-parser
6975 // layer — two authors whose values differ only in their pipe
6976 // tail (`|tee build.log` vs nothing) resolve to the byte-
6977 // identical upstream `git clone` but lock to two distinct
6978 // lacres, defeating the THEORY.md §V.2 render-determinism
6979 // contract. Peer with the `:caminho` axis's
6980 // `FonteCaminhoShellPipe` arm (124106f) on the sibling path-
6981 // fonte axis, and `is_gateway_api_http_path`'s eleven-byte
6982 // RFC-3986-reserved set on `:entrada :paths`.
6983 let d = dep_with_fonte(DepSource::Git {
6984 repo: "https://github.com/pleme-io/caixa-teia|tee build.log".into(),
6985 tag: Some("v0.1.0".into()),
6986 rev: None,
6987 branch: None,
6988 });
6989 let err = d.validate().unwrap_err();
6990 let DepError::FonteRepoShape { nome, repo, reason } = err else {
6991 panic!("expected FonteRepoShape, got other variant");
6992 };
6993 assert_eq!(nome, "caixa-teia");
6994 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia|tee build.log");
6995 assert!(
6996 reason.contains("must not contain `|`"),
6997 "reason must surface the shell-pipe arm, got {reason:?}"
6998 );
6999 assert!(
7000 reason.contains("pipe") || reason.contains("'unwise'"),
7001 "reason must name the shell-pipe / RFC-3986-unwise rationale, got {reason:?}"
7002 );
7003 }
7004
7005 #[test]
7006 fn fonte_repo_fragment_fires_before_pipe_when_fragment_first() {
7007 // Cascade pin: the fragment-`#` arm and the pipe arm are both
7008 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7009 // so the byte that appears first in the value's byte order
7010 // wins. A `:repo "https://github.com/p/x#readme|tee"` carries
7011 // both `#` and `|`; the `#` byte appears first, so the
7012 // fragment-`#` arm fires, surfacing the more self-locating
7013 // diagnostic on the byte the author pasted earliest in the
7014 // URL. Mirrors the peer cascade discipline
7015 // `fonte_repo_fragment_fires_before_backtick_when_fragment_first`
7016 // pins on the prior `:repo` byte-class arm.
7017 let d = dep_with_fonte(DepSource::Git {
7018 repo: "https://github.com/pleme-io/caixa-teia#readme|tee".into(),
7019 tag: Some("v0.1.0".into()),
7020 rev: None,
7021 branch: None,
7022 });
7023 let err = d.validate().unwrap_err();
7024 let DepError::FonteRepoShape { reason, .. } = err else {
7025 panic!("expected FonteRepoShape, got other variant");
7026 };
7027 assert!(
7028 reason.contains("must not contain `#`"),
7029 "reason must surface the fragment-`#` arm (fires before pipe when `#` byte \
7030 appears first in value), got {reason:?}"
7031 );
7032 }
7033
7034 #[test]
7035 fn fonte_repo_backtick_fires_before_pipe_when_backtick_first() {
7036 // Cascade pin: the backtick arm and the pipe arm are both per-
7037 // byte arms inside the same `for &b in s.as_bytes()` loop, so
7038 // the byte that appears first in the value's byte order wins.
7039 // A `:repo "https://github.com/p/x/`whoami`|tee"` carries both
7040 // `` ` `` and `|`; the backtick byte appears first, so the
7041 // backtick arm fires, surfacing the more self-locating
7042 // diagnostic on the byte the author pasted earliest in the
7043 // URL. Pins the natural-order cascade so a future reorder of
7044 // the per-byte arms surfaces here.
7045 let d = dep_with_fonte(DepSource::Git {
7046 repo: "https://github.com/pleme-io/caixa-teia/`whoami`|tee".into(),
7047 tag: Some("v0.1.0".into()),
7048 rev: None,
7049 branch: None,
7050 });
7051 let err = d.validate().unwrap_err();
7052 let DepError::FonteRepoShape { reason, .. } = err else {
7053 panic!("expected FonteRepoShape, got other variant");
7054 };
7055 assert!(
7056 reason.contains("must not contain `` ` ``"),
7057 "reason must surface the backtick arm (fires before pipe when `` ` `` byte \
7058 appears first in value), got {reason:?}"
7059 );
7060 }
7061
7062 #[test]
7063 fn validate_rejects_git_fonte_with_repo_carrying_shell_command_separator() {
7064 // The fail-before-pass-after pin for the canonical
7065 // paste-from-shell-prompt-with-sequential-command-tail footgun
7066 // on `:repo` (peer with the 05c358e `;` arm on the sibling
7067 // `:caminho` path-fonte axis). An author pastes a shell
7068 // one-liner that chained a cleanup tail after the URL
7069 // (`git clone <url>; rm -rf build`, `git ls-remote <url>;
7070 // echo done`) into the `:repo` slot, forgetting to trim the
7071 // `; <cmd>` tail. Until this arm landed the value silently
7072 // passed every prior `is_git_repo_url` arm (no whitespace, no
7073 // control chars, no non-ASCII, no `#`, no `?`, no `\`, no
7074 // `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, doesn't start with
7075 // `-` or `:`); RFC 3986 §2 lists `;` in the 'sub-delims' /
7076 // reserved set and the WHATWG URL spec's fragment percent-
7077 // encode set maps `;` → `%3B` on the wire, so the byte rides
7078 // verbatim into the lacre's per-dep BLAKE3 closure but is
7079 // silently rewritten at libcurl's URL-parser layer — two
7080 // authors whose values differ only in their sequential-command
7081 // tail (`; rm -rf build` vs nothing) resolve to the byte-
7082 // identical upstream `git clone` but lock to two distinct
7083 // lacres, defeating the THEORY.md §V.2 render-determinism
7084 // contract. Peer with the `:caminho` axis's
7085 // `FonteCaminhoShellSemicolon` arm (05c358e) on the sibling
7086 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7087 // byte RFC-3986-reserved set on `:entrada :paths`.
7088 let d = dep_with_fonte(DepSource::Git {
7089 repo: "https://github.com/pleme-io/caixa-teia; rm -rf build".into(),
7090 tag: Some("v0.1.0".into()),
7091 rev: None,
7092 branch: None,
7093 });
7094 let err = d.validate().unwrap_err();
7095 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7096 panic!("expected FonteRepoShape, got other variant");
7097 };
7098 assert_eq!(nome, "caixa-teia");
7099 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia; rm -rf build");
7100 assert!(
7101 reason.contains("must not contain `;`"),
7102 "reason must surface the shell-command-separator arm, got {reason:?}"
7103 );
7104 assert!(
7105 reason.contains("sequential-command") || reason.contains("'sub-delims'"),
7106 "reason must name the shell-command-separator / RFC-3986-sub-delims \
7107 rationale, got {reason:?}"
7108 );
7109 }
7110
7111 #[test]
7112 fn fonte_repo_fragment_fires_before_semicolon_when_fragment_first() {
7113 // Cascade pin: the fragment-`#` arm and the semicolon arm are
7114 // both per-byte arms inside the same `for &b in s.as_bytes()`
7115 // loop, so the byte that appears first in the value's byte
7116 // order wins. A `:repo "https://github.com/p/x#readme; rm"`
7117 // carries both `#` and `;`; the `#` byte appears first, so the
7118 // fragment-`#` arm fires, surfacing the more self-locating
7119 // diagnostic on the byte the author pasted earliest in the URL.
7120 // Mirrors the peer cascade discipline
7121 // `fonte_repo_fragment_fires_before_pipe_when_fragment_first`
7122 // pins on the prior `:repo` byte-class arm.
7123 let d = dep_with_fonte(DepSource::Git {
7124 repo: "https://github.com/pleme-io/caixa-teia#readme; rm".into(),
7125 tag: Some("v0.1.0".into()),
7126 rev: None,
7127 branch: None,
7128 });
7129 let err = d.validate().unwrap_err();
7130 let DepError::FonteRepoShape { reason, .. } = err else {
7131 panic!("expected FonteRepoShape, got other variant");
7132 };
7133 assert!(
7134 reason.contains("must not contain `#`"),
7135 "reason must surface the fragment-`#` arm (fires before semicolon when `#` \
7136 byte appears first in value), got {reason:?}"
7137 );
7138 }
7139
7140 #[test]
7141 fn fonte_repo_pipe_fires_before_semicolon_when_pipe_first() {
7142 // Cascade pin: the pipe arm and the semicolon arm are both
7143 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7144 // so the byte that appears first in the value's byte order
7145 // wins. A `:repo "https://github.com/p/x|tee; rm"` carries
7146 // both `|` and `;`; the `|` byte appears first, so the
7147 // pipe arm fires, surfacing the more self-locating diagnostic
7148 // on the byte the author pasted earliest in the URL. Pins the
7149 // natural-order cascade so a future reorder of the per-byte
7150 // arms surfaces here.
7151 let d = dep_with_fonte(DepSource::Git {
7152 repo: "https://github.com/pleme-io/caixa-teia|tee; rm".into(),
7153 tag: Some("v0.1.0".into()),
7154 rev: None,
7155 branch: None,
7156 });
7157 let err = d.validate().unwrap_err();
7158 let DepError::FonteRepoShape { reason, .. } = err else {
7159 panic!("expected FonteRepoShape, got other variant");
7160 };
7161 assert!(
7162 reason.contains("must not contain `|`"),
7163 "reason must surface the pipe arm (fires before semicolon when `|` byte \
7164 appears first in value), got {reason:?}"
7165 );
7166 }
7167
7168 #[test]
7169 fn validate_rejects_git_fonte_with_repo_carrying_shell_background() {
7170 // The fail-before-pass-after pin for the canonical
7171 // paste-from-shell-prompt-with-background-launch-tail footgun
7172 // on `:repo` (peer with the e12e4f3 `&` arm on the sibling
7173 // `:caminho` path-fonte axis). An author pastes a shell one-
7174 // liner that detached the clone into the background
7175 // (`git clone <url> & sleep 1`, `git clone <url> && cd …`)
7176 // into the `:repo` slot, forgetting to trim the `& <cmd>` /
7177 // `&& <cmd>` tail. Until this arm landed the value silently
7178 // passed every prior `is_git_repo_url` arm (no whitespace,
7179 // no control chars, no non-ASCII, no `#`, no `?`, no `\`,
7180 // no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
7181 // doesn't start with `-` or `:`); RFC 3986 §2 lists `&` in
7182 // the 'sub-delims' / reserved set and the WHATWG URL spec's
7183 // fragment percent-encode set maps `&` → `%26` on the wire,
7184 // so the byte rides verbatim into the lacre's per-dep
7185 // BLAKE3 closure but is silently rewritten at libcurl's
7186 // URL-parser layer — two authors whose values differ only
7187 // in their background-launch tail (`& sleep 1` vs nothing)
7188 // resolve to the byte-identical upstream `git clone` but
7189 // lock to two distinct lacres, defeating the THEORY.md
7190 // §V.2 render-determinism contract. Peer with the
7191 // `:caminho` axis's `FonteCaminhoShellBackground` arm
7192 // (e12e4f3) on the sibling path-fonte axis, and
7193 // `is_gateway_api_http_path`'s eleven-byte RFC-3986-
7194 // reserved set on `:entrada :paths`.
7195 let d = dep_with_fonte(DepSource::Git {
7196 repo: "https://github.com/pleme-io/caixa-teia&sleep".into(),
7197 tag: Some("v0.1.0".into()),
7198 rev: None,
7199 branch: None,
7200 });
7201 let err = d.validate().unwrap_err();
7202 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7203 panic!("expected FonteRepoShape, got other variant");
7204 };
7205 assert_eq!(nome, "caixa-teia");
7206 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia&sleep");
7207 assert!(
7208 reason.contains("must not contain `&`"),
7209 "reason must surface the shell-background / logical-AND arm, got {reason:?}"
7210 );
7211 assert!(
7212 reason.contains("background-task") || reason.contains("'sub-delims'"),
7213 "reason must name the shell-background / RFC-3986-sub-delims rationale, \
7214 got {reason:?}"
7215 );
7216 }
7217
7218 #[test]
7219 fn validate_rejects_git_fonte_with_repo_carrying_logical_and() {
7220 // The fail-before-pass-after pin for the symmetric `&&`
7221 // logical-AND build-chain paste footgun: an author pastes
7222 // a `git clone <url> && cd <repo>` build-chain one-liner
7223 // and forgets to trim the `&& <cmd>` tail. The `&&` shape
7224 // is the same `&` byte twice in a row; the per-byte arm
7225 // fires on the first `&` it sees. Pinned separately from
7226 // the single-`&` background-launch shape so a future
7227 // diagnostic-surface change that special-cased the
7228 // doubled-byte form surfaces here.
7229 let d = dep_with_fonte(DepSource::Git {
7230 repo: "github:pleme-io/caixa-teia&&echo".into(),
7231 tag: Some("v0.1.0".into()),
7232 rev: None,
7233 branch: None,
7234 });
7235 let err = d.validate().unwrap_err();
7236 let DepError::FonteRepoShape { reason, .. } = err else {
7237 panic!("expected FonteRepoShape, got other variant");
7238 };
7239 assert!(
7240 reason.contains("must not contain `&`"),
7241 "reason must surface the shell-background / logical-AND arm on the doubled-`&&` \
7242 shape too, got {reason:?}"
7243 );
7244 }
7245
7246 #[test]
7247 fn fonte_repo_fragment_fires_before_background_when_fragment_first() {
7248 // Cascade pin: the fragment-`#` arm and the background-`&`
7249 // arm are both per-byte arms inside the same `for &b in
7250 // s.as_bytes()` loop, so the byte that appears first in the
7251 // value's byte order wins. A `:repo
7252 // "https://github.com/p/x#readme & sleep"` carries both `#`
7253 // and `&`; the `#` byte appears first, so the fragment-`#`
7254 // arm fires, surfacing the more self-locating diagnostic on
7255 // the byte the author pasted earliest in the URL. Mirrors
7256 // the peer cascade discipline
7257 // `fonte_repo_fragment_fires_before_semicolon_when_fragment_first`
7258 // on the prior `:repo` byte-class arm.
7259 let d = dep_with_fonte(DepSource::Git {
7260 repo: "https://github.com/pleme-io/caixa-teia#readme&sleep".into(),
7261 tag: Some("v0.1.0".into()),
7262 rev: None,
7263 branch: None,
7264 });
7265 let err = d.validate().unwrap_err();
7266 let DepError::FonteRepoShape { reason, .. } = err else {
7267 panic!("expected FonteRepoShape, got other variant");
7268 };
7269 assert!(
7270 reason.contains("must not contain `#`"),
7271 "reason must surface the fragment-`#` arm (fires before background-`&` when `#` \
7272 byte appears first in value), got {reason:?}"
7273 );
7274 }
7275
7276 #[test]
7277 fn fonte_repo_semicolon_fires_before_background_when_semicolon_first() {
7278 // Cascade pin: the semicolon arm and the background-`&` arm
7279 // are both per-byte arms inside the same `for &b in
7280 // s.as_bytes()` loop, so the byte that appears first in the
7281 // value's byte order wins. A `:repo
7282 // "https://github.com/p/x; rm & sleep"` carries both `;` and
7283 // `&`; the `;` byte appears first, so the semicolon arm
7284 // fires, surfacing the more self-locating diagnostic on the
7285 // byte the author pasted earliest in the URL. Pins the
7286 // natural-order cascade so a future reorder of the per-byte
7287 // arms surfaces here.
7288 let d = dep_with_fonte(DepSource::Git {
7289 repo: "https://github.com/pleme-io/caixa-teia;rm&sleep".into(),
7290 tag: Some("v0.1.0".into()),
7291 rev: None,
7292 branch: None,
7293 });
7294 let err = d.validate().unwrap_err();
7295 let DepError::FonteRepoShape { reason, .. } = err else {
7296 panic!("expected FonteRepoShape, got other variant");
7297 };
7298 assert!(
7299 reason.contains("must not contain `;`"),
7300 "reason must surface the semicolon arm (fires before background-`&` when `;` \
7301 byte appears first in value), got {reason:?}"
7302 );
7303 }
7304
7305 #[test]
7306 fn validate_rejects_git_fonte_with_repo_carrying_shell_variable_expansion() {
7307 // The fail-before-pass-after pin for the canonical
7308 // paste-from-shell-prompt-with-unsubstituted-variable footgun
7309 // on `:repo` (peer with the f4efe9c `$` arm on the sibling
7310 // `:caminho` path-fonte axis). An author pastes a shell one-
7311 // liner that referenced an environment variable
7312 // (`git clone https://github.com/$ORG/x`, `git clone
7313 // github:$USER/repo`) into the `:repo` slot, forgetting to
7314 // substitute the literal value at author time. Until this arm
7315 // landed the value silently passed every prior
7316 // `is_git_repo_url` arm (no whitespace, no control chars, no
7317 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
7318 // no `` ` ``, no `|`, no `;`, no `&`, doesn't start with `-`
7319 // or `:`); RFC 3986 §2 lists `$` in the 'sub-delims' /
7320 // reserved set and the WHATWG URL spec's fragment percent-
7321 // encode set maps `$` → `%24` on the wire, so the byte rides
7322 // verbatim into the lacre's per-dep BLAKE3 closure but is
7323 // silently rewritten at libcurl's URL-parser layer — two
7324 // authors whose values differ only in their `$VAR` /
7325 // `${VAR}` / `$(cmd)` expansion tail resolve to the byte-
7326 // identical upstream `git clone` but lock to two distinct
7327 // lacres, defeating the THEORY.md §V.2 render-determinism
7328 // contract. Beyond determinism, the value is a structural
7329 // host-layout leak: two authors with the same `:repo` slot
7330 // but different `$ORG` / `$HOME` / `$WORKSPACE` resolve
7331 // different upstreams. Peer with the `:caminho` axis's
7332 // `FonteCaminhoVarExpansion` arm (f4efe9c) on the sibling
7333 // path-fonte axis, and `is_gateway_api_http_path`'s eleven-
7334 // byte RFC-3986-reserved set on `:entrada :paths`.
7335 let d = dep_with_fonte(DepSource::Git {
7336 repo: "https://github.com/$ORG/caixa-teia".into(),
7337 tag: Some("v0.1.0".into()),
7338 rev: None,
7339 branch: None,
7340 });
7341 let err = d.validate().unwrap_err();
7342 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7343 panic!("expected FonteRepoShape, got other variant");
7344 };
7345 assert_eq!(nome, "caixa-teia");
7346 assert_eq!(repo, "https://github.com/$ORG/caixa-teia");
7347 assert!(
7348 reason.contains("must not contain `$`"),
7349 "reason must surface the shell-variable-expansion arm, got {reason:?}"
7350 );
7351 assert!(
7352 reason.contains("variable-expansion") || reason.contains("'sub-delims'"),
7353 "reason must name the shell-variable-expansion / RFC-3986-sub-delims \
7354 rationale, got {reason:?}"
7355 );
7356 }
7357
7358 #[test]
7359 fn validate_rejects_git_fonte_with_repo_carrying_braced_variable_expansion() {
7360 // The fail-before-pass-after pin for the symmetric POSIX-
7361 // shell braced `${VAR}` expansion paste footgun: an author
7362 // pastes a CI-manifest line `git clone
7363 // https://github.com/${WORKSPACE}/x` (the canonical GitHub
7364 // Actions / GitLab CI / Drone shape) and forgets to
7365 // substitute the literal value. The `${...}` shape is the
7366 // same `$` byte at the leading position of the expansion;
7367 // the per-byte arm fires on the `$`. Pinned separately from
7368 // the bare-`$VAR` shape so a future diagnostic-surface
7369 // change that special-cased the braced form surfaces here.
7370 let d = dep_with_fonte(DepSource::Git {
7371 repo: "https://github.com/${WORKSPACE}/caixa-teia".into(),
7372 tag: Some("v0.1.0".into()),
7373 rev: None,
7374 branch: None,
7375 });
7376 let err = d.validate().unwrap_err();
7377 let DepError::FonteRepoShape { reason, .. } = err else {
7378 panic!("expected FonteRepoShape, got other variant");
7379 };
7380 assert!(
7381 reason.contains("must not contain `$`"),
7382 "reason must surface the shell-variable-expansion arm on the braced `${{...}}` \
7383 shape too, got {reason:?}"
7384 );
7385 }
7386
7387 #[test]
7388 fn fonte_repo_fragment_fires_before_var_expansion_when_fragment_first() {
7389 // Cascade pin: the fragment-`#` arm and the var-expansion-`$`
7390 // arm are both per-byte arms inside the same `for &b in
7391 // s.as_bytes()` loop, so the byte that appears first in the
7392 // value's byte order wins. A `:repo
7393 // "https://github.com/p/x#readme$HOME"` carries both `#` and
7394 // `$`; the `#` byte appears first, so the fragment-`#` arm
7395 // fires, surfacing the more self-locating diagnostic on the
7396 // byte the author pasted earliest in the URL. Mirrors the
7397 // peer cascade discipline
7398 // `fonte_repo_fragment_fires_before_background_when_fragment_first`
7399 // on the prior `:repo` byte-class arm.
7400 let d = dep_with_fonte(DepSource::Git {
7401 repo: "https://github.com/pleme-io/caixa-teia#readme$HOME".into(),
7402 tag: Some("v0.1.0".into()),
7403 rev: None,
7404 branch: None,
7405 });
7406 let err = d.validate().unwrap_err();
7407 let DepError::FonteRepoShape { reason, .. } = err else {
7408 panic!("expected FonteRepoShape, got other variant");
7409 };
7410 assert!(
7411 reason.contains("must not contain `#`"),
7412 "reason must surface the fragment-`#` arm (fires before var-expansion-`$` when \
7413 `#` byte appears first in value), got {reason:?}"
7414 );
7415 }
7416
7417 #[test]
7418 fn fonte_repo_background_fires_before_var_expansion_when_background_first() {
7419 // Cascade pin: the background-`&` arm and the
7420 // var-expansion-`$` arm are both per-byte arms inside the
7421 // same `for &b in s.as_bytes()` loop, so the byte that
7422 // appears first in the value's byte order wins. A `:repo
7423 // "https://github.com/p/x&sleep$HOME"` carries both `&` and
7424 // `$`; the `&` byte appears first, so the background arm
7425 // fires, surfacing the more self-locating diagnostic on the
7426 // byte the author pasted earliest in the URL. Pins the
7427 // natural-order cascade so a future reorder of the per-byte
7428 // arms surfaces here — `$` is the most recent byte-class arm,
7429 // so the cascade-pin sweep extends to cover every immediately
7430 // prior byte arm (`#`, `&`) firing first when ordered ahead
7431 // of `$` in the value.
7432 let d = dep_with_fonte(DepSource::Git {
7433 repo: "https://github.com/pleme-io/caixa-teia&sleep$HOME".into(),
7434 tag: Some("v0.1.0".into()),
7435 rev: None,
7436 branch: None,
7437 });
7438 let err = d.validate().unwrap_err();
7439 let DepError::FonteRepoShape { reason, .. } = err else {
7440 panic!("expected FonteRepoShape, got other variant");
7441 };
7442 assert!(
7443 reason.contains("must not contain `&`"),
7444 "reason must surface the background-`&` arm (fires before var-expansion-`$` when \
7445 `&` byte appears first in value), got {reason:?}"
7446 );
7447 }
7448
7449 #[test]
7450 fn validate_rejects_git_fonte_with_repo_carrying_shell_glob_wildcard() {
7451 // The fail-before-pass-after pin for the canonical
7452 // paste-from-shell-prompt glob footgun on `:repo` (peer with
7453 // the cf9034b `*` / `?` arm on the sibling `:caminho`
7454 // path-fonte axis). An author pastes a shell one-liner that
7455 // referenced a glob expansion (`ls
7456 // github.com/pleme-io/caixa-*`, `git clone
7457 // github:pleme-io/caixa-*`) into the `:repo` slot, forgetting
7458 // to substitute the literal repo name. Until this arm landed
7459 // the `*` byte silently passed every prior `is_git_repo_url`
7460 // arm (no whitespace, no control chars, no non-ASCII, no `#`,
7461 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`,
7462 // no `;`, no `&`, no `$`, doesn't start with `-` or `:`); RFC
7463 // 3986 §2 lists `*` in the 'sub-delims' / reserved set and
7464 // the WHATWG URL spec's special-query percent-encode set maps
7465 // `*` → `%2A` on the wire, so the byte rides verbatim into
7466 // the lacre's per-dep BLAKE3 closure but is silently
7467 // rewritten at libcurl's URL-parser layer — two authors
7468 // whose values differ only in their asterisk presence
7469 // resolve to the byte-identical upstream `git clone` but
7470 // lock to two distinct lacres, defeating the THEORY.md §V.2
7471 // render-determinism contract. Peer with the `:caminho`
7472 // axis's `FonteCaminhoShellGlob` arm (cf9034b) on the
7473 // sibling path-fonte axis, and the `is_git_ref_name`
7474 // refspec-wildcard cascade on the `:fonte :tag` / `:branch`
7475 // axes.
7476 let d = dep_with_fonte(DepSource::Git {
7477 repo: "https://github.com/pleme-io/caixa-*".into(),
7478 tag: Some("v0.1.0".into()),
7479 rev: None,
7480 branch: None,
7481 });
7482 let err = d.validate().unwrap_err();
7483 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7484 panic!("expected FonteRepoShape, got other variant");
7485 };
7486 assert_eq!(nome, "caixa-teia");
7487 assert_eq!(repo, "https://github.com/pleme-io/caixa-*");
7488 assert!(
7489 reason.contains("must not contain `*`"),
7490 "reason must surface the shell-glob arm, got {reason:?}"
7491 );
7492 assert!(
7493 reason.contains("pathname-expansion") || reason.contains("'sub-delims'"),
7494 "reason must name the shell-glob / pathname-expansion / \
7495 RFC-3986-sub-delims rationale, got {reason:?}"
7496 );
7497 }
7498
7499 #[test]
7500 fn validate_rejects_git_fonte_with_repo_carrying_recursive_shell_glob() {
7501 // The fail-before-pass-after pin for the symmetric bash
7502 // `globstar` recursive-glob paste footgun: an author pastes
7503 // a `ls github.com/pleme-io/**/x` (the canonical
7504 // `globstar`-shopt-enabled recursive-listing tail) into the
7505 // `:repo` slot. The `**` shape is two `*` bytes adjacent;
7506 // the per-byte arm fires on the first `*`. Pinned
7507 // separately from the single-`*` shape so a future
7508 // diagnostic-surface change that special-cased the
7509 // double-`*` form surfaces here.
7510 let d = dep_with_fonte(DepSource::Git {
7511 repo: "https://github.com/pleme-io/**/caixa-teia".into(),
7512 tag: Some("v0.1.0".into()),
7513 rev: None,
7514 branch: None,
7515 });
7516 let err = d.validate().unwrap_err();
7517 let DepError::FonteRepoShape { reason, .. } = err else {
7518 panic!("expected FonteRepoShape, got other variant");
7519 };
7520 assert!(
7521 reason.contains("must not contain `*`"),
7522 "reason must surface the shell-glob arm on the `**` recursive-glob shape too, \
7523 got {reason:?}"
7524 );
7525 }
7526
7527 #[test]
7528 fn fonte_repo_fragment_fires_before_glob_when_fragment_first() {
7529 // Cascade pin: the fragment-`#` arm and the glob-`*` arm are
7530 // both per-byte arms inside the same `for &b in s.as_bytes()`
7531 // loop, so the byte that appears first in the value's byte
7532 // order wins. A `:repo
7533 // "https://github.com/p/x#readme*tail"` carries both `#` and
7534 // `*`; the `#` byte appears first, so the fragment-`#` arm
7535 // fires, surfacing the more self-locating diagnostic on the
7536 // byte the author pasted earliest in the URL. Mirrors the
7537 // peer cascade discipline
7538 // `fonte_repo_fragment_fires_before_var_expansion_when_fragment_first`
7539 // on the prior `:repo` byte-class arm.
7540 let d = dep_with_fonte(DepSource::Git {
7541 repo: "https://github.com/pleme-io/caixa-teia#readme*tail".into(),
7542 tag: Some("v0.1.0".into()),
7543 rev: None,
7544 branch: None,
7545 });
7546 let err = d.validate().unwrap_err();
7547 let DepError::FonteRepoShape { reason, .. } = err else {
7548 panic!("expected FonteRepoShape, got other variant");
7549 };
7550 assert!(
7551 reason.contains("must not contain `#`"),
7552 "reason must surface the fragment-`#` arm (fires before glob-`*` when `#` byte \
7553 appears first in value), got {reason:?}"
7554 );
7555 }
7556
7557 #[test]
7558 fn fonte_repo_var_expansion_fires_before_glob_when_var_expansion_first() {
7559 // Cascade pin: the var-expansion-`$` arm and the glob-`*`
7560 // arm are both per-byte arms inside the same `for &b in
7561 // s.as_bytes()` loop, so the byte that appears first in the
7562 // value's byte order wins. A `:repo
7563 // "https://github.com/p/$ORG-*"` carries both `$` and `*`;
7564 // the `$` byte appears first, so the var-expansion arm
7565 // fires, surfacing the more self-locating diagnostic on the
7566 // byte the author pasted earliest in the URL. Pins the
7567 // natural-order cascade so a future reorder of the per-byte
7568 // arms surfaces here — `*` is the most recent byte-class
7569 // arm, so the cascade-pin sweep extends to cover the
7570 // immediately prior `$` byte arm firing first when ordered
7571 // ahead of `*` in the value.
7572 let d = dep_with_fonte(DepSource::Git {
7573 repo: "https://github.com/pleme-io/$ORG-caixa-*".into(),
7574 tag: Some("v0.1.0".into()),
7575 rev: None,
7576 branch: None,
7577 });
7578 let err = d.validate().unwrap_err();
7579 let DepError::FonteRepoShape { reason, .. } = err else {
7580 panic!("expected FonteRepoShape, got other variant");
7581 };
7582 assert!(
7583 reason.contains("must not contain `$`"),
7584 "reason must surface the var-expansion-`$` arm (fires before glob-`*` when `$` \
7585 byte appears first in value), got {reason:?}"
7586 );
7587 }
7588
7589 #[test]
7590 fn validate_rejects_git_fonte_with_repo_carrying_subshell_open_paren() {
7591 // The fail-before-pass-after pin for the canonical paste-from-
7592 // shell-prompt subshell-grouping footgun on `:repo`. An author
7593 // pastes a doc / README snippet carrying a regex-alternation
7594 // grouping shape (`https://github.com/(foo|bar)/repo`) or a
7595 // dynamic-config-substitution wrapper (`$(<cmd>)`) into the
7596 // `:repo` slot, forgetting to substitute one literal org name.
7597 // Until this arm landed the `(` byte silently passed every
7598 // prior `is_git_repo_url` arm (no whitespace, no control
7599 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7600 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no
7601 // `*`, doesn't start with `-` or `:`); RFC 3986 §2 lists `(`
7602 // / `)` in the 'sub-delims' / reserved set, and the WHATWG
7603 // URL spec's special-query percent-encode set maps `(` →
7604 // `%28` and `)` → `%29` on the wire, so the byte rides
7605 // verbatim into the lacre's per-dep BLAKE3 closure but is
7606 // silently rewritten at libcurl's URL-parser layer —
7607 // defeating the THEORY.md §V.2 render-determinism contract on
7608 // the same axis the prior twelve byte-class arms close.
7609 let d = dep_with_fonte(DepSource::Git {
7610 repo: "https://github.com/(foo|bar)/caixa-teia".into(),
7611 tag: Some("v0.1.0".into()),
7612 rev: None,
7613 branch: None,
7614 });
7615 let err = d.validate().unwrap_err();
7616 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7617 panic!("expected FonteRepoShape, got other variant");
7618 };
7619 assert_eq!(nome, "caixa-teia");
7620 assert_eq!(repo, "https://github.com/(foo|bar)/caixa-teia");
7621 assert!(
7622 reason.contains("must not contain `(`"),
7623 "reason must surface the subshell-open-paren arm, got {reason:?}"
7624 );
7625 assert!(
7626 reason.contains("subshell-grouping") || reason.contains("'sub-delims'"),
7627 "reason must name the shell-subshell-grouping / RFC-3986-sub-delims rationale, \
7628 got {reason:?}"
7629 );
7630 }
7631
7632 #[test]
7633 fn validate_rejects_git_fonte_with_repo_carrying_subshell_close_paren() {
7634 // The symmetric arm pin on the closing `)` byte: an author
7635 // pastes a `$(date)` command-substitution wrapper or a
7636 // regex-alternation `(foo|bar)` tail into the `:repo` slot.
7637 // Pinned separately from the opening `(` shape so a future
7638 // diagnostic-surface change that only checked one boundary
7639 // surfaces here. The `(` byte appears earlier in the
7640 // canonical regex / subshell wrapper so the per-byte loop
7641 // fires on `(` first; this test exercises a `:repo` value
7642 // carrying only the closing `)` byte (no opening paren) so
7643 // the `)` arm fires directly — pinning the byte-class arm
7644 // independent of order.
7645 let d = dep_with_fonte(DepSource::Git {
7646 repo: "github:pleme-io/caixa-teia)tail".into(),
7647 tag: Some("v0.1.0".into()),
7648 rev: None,
7649 branch: None,
7650 });
7651 let err = d.validate().unwrap_err();
7652 let DepError::FonteRepoShape { reason, .. } = err else {
7653 panic!("expected FonteRepoShape, got other variant");
7654 };
7655 assert!(
7656 reason.contains("must not contain `)`"),
7657 "reason must surface the subshell-close-paren arm on the bare `)` shape, \
7658 got {reason:?}"
7659 );
7660 }
7661
7662 #[test]
7663 fn fonte_repo_fragment_fires_before_subshell_when_fragment_first() {
7664 // Cascade pin: the fragment-`#` arm and the subshell-`(` arm
7665 // are both per-byte arms inside the same `for &b in
7666 // s.as_bytes()` loop, so the byte that appears first in the
7667 // value's byte order wins. A `:repo
7668 // "https://github.com/p/x#readme(tail)"` carries both `#` and
7669 // `(`; the `#` byte appears first, so the fragment-`#` arm
7670 // fires, surfacing the more self-locating diagnostic on the
7671 // byte the author pasted earliest in the URL. Mirrors the
7672 // peer cascade discipline
7673 // `fonte_repo_fragment_fires_before_glob_when_fragment_first`
7674 // on the prior `:repo` byte-class arm.
7675 let d = dep_with_fonte(DepSource::Git {
7676 repo: "https://github.com/pleme-io/caixa-teia#readme(tail)".into(),
7677 tag: Some("v0.1.0".into()),
7678 rev: None,
7679 branch: None,
7680 });
7681 let err = d.validate().unwrap_err();
7682 let DepError::FonteRepoShape { reason, .. } = err else {
7683 panic!("expected FonteRepoShape, got other variant");
7684 };
7685 assert!(
7686 reason.contains("must not contain `#`"),
7687 "reason must surface the fragment-`#` arm (fires before subshell-`(` when `#` \
7688 byte appears first in value), got {reason:?}"
7689 );
7690 }
7691
7692 #[test]
7693 fn fonte_repo_glob_fires_before_subshell_when_glob_first() {
7694 // Cascade pin: the glob-`*` arm (the immediate-predecessor
7695 // byte-class arm, 3902a9a) and the subshell-`(` arm are both
7696 // per-byte arms inside the same `for &b in s.as_bytes()`
7697 // loop, so the byte that appears first in the value's byte
7698 // order wins. A `:repo
7699 // "https://github.com/p/x-*-(date)"` carries both `*` and
7700 // `(`; the `*` byte appears first, so the glob arm fires,
7701 // surfacing the more self-locating diagnostic on the byte
7702 // the author pasted earliest in the URL. Pins the natural-
7703 // order cascade so a future reorder of the per-byte arms
7704 // surfaces here — `(` is the most recent byte-class arm,
7705 // so the cascade-pin sweep extends to cover the immediately
7706 // prior `*` byte arm firing first when ordered ahead of `(`
7707 // in the value.
7708 let d = dep_with_fonte(DepSource::Git {
7709 repo: "https://github.com/pleme-io/caixa-teia-*-(date)".into(),
7710 tag: Some("v0.1.0".into()),
7711 rev: None,
7712 branch: None,
7713 });
7714 let err = d.validate().unwrap_err();
7715 let DepError::FonteRepoShape { reason, .. } = err else {
7716 panic!("expected FonteRepoShape, got other variant");
7717 };
7718 assert!(
7719 reason.contains("must not contain `*`"),
7720 "reason must surface the glob-`*` arm (fires before subshell-`(` when `*` byte \
7721 appears first in value), got {reason:?}"
7722 );
7723 }
7724
7725 #[test]
7726 fn validate_rejects_git_fonte_with_repo_carrying_shell_double_quote() {
7727 // The fail-before-pass-after pin for the canonical paste-from-
7728 // doc-shell-quoting footgun on `:repo`. An author copies a
7729 // README quick-start snippet (`$ git clone "https://github.com/
7730 // foo/bar"`) and keeps the surrounding double-quote bytes when
7731 // pasting into the `:repo` slot — the doc wraps the URL in
7732 // double quotes so the shell doesn't re-lex metachars inside,
7733 // but the typed slot is itself a byte-level string parser, not
7734 // a shell context, so the quote bytes ride into the value
7735 // verbatim. Until this arm landed the `"` byte silently passed
7736 // every prior `is_git_repo_url` arm (no whitespace, no control
7737 // chars, no non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no
7738 // `<`/`>`, no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`,
7739 // no `(`/`)`, doesn't start with `-` or `:`); RFC 3986 §2 lists
7740 // `"` in the strict four-byte 'delims' subset (with `<`, `>`,
7741 // `` ` ``) every URL parser is required to refuse or percent-
7742 // encode, and the WHATWG URL spec's 'C0 control percent-encode
7743 // set' maps `"` → `%22` on the wire, so the byte rides verbatim
7744 // into the lacre's per-dep BLAKE3 closure but is silently
7745 // rewritten at libcurl's URL-parser layer, defeating the
7746 // THEORY.md §V.2 render-determinism contract.
7747 let d = dep_with_fonte(DepSource::Git {
7748 repo: "\"https://github.com/pleme-io/caixa-teia\"".into(),
7749 tag: Some("v0.1.0".into()),
7750 rev: None,
7751 branch: None,
7752 });
7753 let err = d.validate().unwrap_err();
7754 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7755 panic!("expected FonteRepoShape, got other variant");
7756 };
7757 assert_eq!(nome, "caixa-teia");
7758 assert_eq!(repo, "\"https://github.com/pleme-io/caixa-teia\"");
7759 assert!(
7760 reason.contains("must not contain `\"`"),
7761 "reason must surface the shell-double-quote arm, got {reason:?}"
7762 );
7763 assert!(
7764 reason.contains("double-quote") || reason.contains("'delims'"),
7765 "reason must name the shell-double-quote / RFC-3986-delims rationale, \
7766 got {reason:?}"
7767 );
7768 }
7769
7770 #[test]
7771 fn validate_rejects_git_fonte_with_repo_carrying_stray_trailing_double_quote() {
7772 // The symmetric stray-quote tail pin: an author pastes only a
7773 // closing `"` from a shell-history line like `git clone
7774 // "https://github.com/foo/bar" && cd …` (the trim went too
7775 // far in one direction but not the other) into the `:repo`
7776 // slot. Pinned separately from the wrapped-quote shape so a
7777 // future diagnostic-surface change that only checked one
7778 // boundary (only leading, only trailing, only paired) surfaces
7779 // here — the per-byte arm fires anywhere `"` appears.
7780 let d = dep_with_fonte(DepSource::Git {
7781 repo: "github:pleme-io/caixa-teia\"".into(),
7782 tag: Some("v0.1.0".into()),
7783 rev: None,
7784 branch: None,
7785 });
7786 let err = d.validate().unwrap_err();
7787 let DepError::FonteRepoShape { reason, .. } = err else {
7788 panic!("expected FonteRepoShape, got other variant");
7789 };
7790 assert!(
7791 reason.contains("must not contain `\"`"),
7792 "reason must surface the shell-double-quote arm on the trailing-`\"` shape, \
7793 got {reason:?}"
7794 );
7795 }
7796
7797 #[test]
7798 fn fonte_repo_fragment_fires_before_double_quote_when_fragment_first() {
7799 // Cascade pin: the fragment-`#` arm and the double-quote arm
7800 // are both per-byte arms inside the same `for &b in
7801 // s.as_bytes()` loop, so the byte that appears first in the
7802 // value's byte order wins. A `:repo
7803 // "https://github.com/p/x#readme\"tail"` carries both `#` and
7804 // `"`; the `#` byte appears first, so the fragment-`#` arm
7805 // fires, surfacing the more self-locating diagnostic on the
7806 // byte the author pasted earliest in the URL.
7807 let d = dep_with_fonte(DepSource::Git {
7808 repo: "https://github.com/pleme-io/caixa-teia#readme\"tail".into(),
7809 tag: Some("v0.1.0".into()),
7810 rev: None,
7811 branch: None,
7812 });
7813 let err = d.validate().unwrap_err();
7814 let DepError::FonteRepoShape { reason, .. } = err else {
7815 panic!("expected FonteRepoShape, got other variant");
7816 };
7817 assert!(
7818 reason.contains("must not contain `#`"),
7819 "reason must surface the fragment-`#` arm (fires before double-quote when `#` \
7820 byte appears first in value), got {reason:?}"
7821 );
7822 }
7823
7824 #[test]
7825 fn fonte_repo_subshell_fires_before_double_quote_when_subshell_first() {
7826 // Cascade pin: the subshell-`(` arm (the immediate-predecessor
7827 // byte-class arm, 3b99147) and the double-quote arm are both
7828 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7829 // so the byte that appears first in the value's byte order
7830 // wins. A `:repo "github:p/x(date)\"tail"` carries both `(`
7831 // and `"`; the `(` byte appears first, so the subshell arm
7832 // fires, surfacing the more self-locating diagnostic on the
7833 // byte the author pasted earliest in the URL. Pins the natural-
7834 // order cascade so a future reorder of the per-byte arms
7835 // surfaces here — `"` is the most recent byte-class arm, so
7836 // the cascade-pin sweep extends to cover the immediately prior
7837 // `(` byte arm firing first when ordered ahead of `"` in the
7838 // value.
7839 let d = dep_with_fonte(DepSource::Git {
7840 repo: "github:pleme-io/caixa-teia(date)\"tail".into(),
7841 tag: Some("v0.1.0".into()),
7842 rev: None,
7843 branch: None,
7844 });
7845 let err = d.validate().unwrap_err();
7846 let DepError::FonteRepoShape { reason, .. } = err else {
7847 panic!("expected FonteRepoShape, got other variant");
7848 };
7849 assert!(
7850 reason.contains("must not contain `(`"),
7851 "reason must surface the subshell-`(` arm (fires before double-quote when `(` \
7852 byte appears first in value), got {reason:?}"
7853 );
7854 }
7855
7856 #[test]
7857 fn validate_rejects_git_fonte_with_repo_carrying_shell_single_quote() {
7858 // The fail-before-pass-after pin for the canonical paste-from-
7859 // doc-strong-quoting footgun on `:repo`. An author copies a
7860 // security-conscious README quick-start snippet (`$ git clone
7861 // 'https://github.com/foo/bar'`) and keeps the surrounding
7862 // single-quote bytes when pasting into the `:repo` slot — the
7863 // doc strong-quotes the URL so the shell suppresses every form
7864 // of expansion on the bytes inside (no `$`, no backtick, no
7865 // glob, no word-splitting), but the typed slot is itself a
7866 // byte-level string parser, not a shell context, so the quote
7867 // bytes ride into the value verbatim. Until this arm landed the
7868 // `'` byte silently passed every prior `is_git_repo_url` arm
7869 // (no whitespace, no control chars, no non-ASCII, no `#`, no
7870 // `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no
7871 // `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`, doesn't start
7872 // with `-` or `:`); RFC 3986 §2.2 lists `'` in the 'sub-delims'
7873 // set, peer with the `\"` 'delims' double-quote arm and the
7874 // partner ASCII shell-string-delimiter byte every byte-level
7875 // string parser sharing a value-shape with a shell argument
7876 // must refuse on a URL-shaped slot.
7877 let d = dep_with_fonte(DepSource::Git {
7878 repo: "'https://github.com/pleme-io/caixa-teia'".into(),
7879 tag: Some("v0.1.0".into()),
7880 rev: None,
7881 branch: None,
7882 });
7883 let err = d.validate().unwrap_err();
7884 let DepError::FonteRepoShape { nome, repo, reason } = err else {
7885 panic!("expected FonteRepoShape, got other variant");
7886 };
7887 assert_eq!(nome, "caixa-teia");
7888 assert_eq!(repo, "'https://github.com/pleme-io/caixa-teia'");
7889 assert!(
7890 reason.contains("must not contain `'`"),
7891 "reason must surface the shell-single-quote arm, got {reason:?}"
7892 );
7893 assert!(
7894 reason.contains("single-quote") || reason.contains("strong-quote"),
7895 "reason must name the shell-single-quote / strong-quote rationale, \
7896 got {reason:?}"
7897 );
7898 }
7899
7900 #[test]
7901 fn validate_rejects_git_fonte_with_repo_carrying_english_apostrophe() {
7902 // The symmetric English-typography pin: an author writes
7903 // `:repo "github:p/repo's-fork"` (the possessive-form paste-
7904 // from-prose idiom every README / commit-message / chat-thread
7905 // reference to a repo carries) expecting the substrate to
7906 // coerce it to a kebab-case slug — but the byte rides into the
7907 // lacre verbatim. Pinned separately from the wrapped-quote
7908 // shape so a future diagnostic-surface change that only checked
7909 // the boundary positions (only leading, only trailing, only
7910 // paired) surfaces here — the per-byte arm fires anywhere `'`
7911 // appears in the value.
7912 let d = dep_with_fonte(DepSource::Git {
7913 repo: "github:pleme-io/repo's-fork".into(),
7914 tag: Some("v0.1.0".into()),
7915 rev: None,
7916 branch: None,
7917 });
7918 let err = d.validate().unwrap_err();
7919 let DepError::FonteRepoShape { reason, .. } = err else {
7920 panic!("expected FonteRepoShape, got other variant");
7921 };
7922 assert!(
7923 reason.contains("must not contain `'`"),
7924 "reason must surface the shell-single-quote arm on the mid-string \
7925 apostrophe shape, got {reason:?}"
7926 );
7927 }
7928
7929 #[test]
7930 fn fonte_repo_fragment_fires_before_single_quote_when_fragment_first() {
7931 // Cascade pin: the fragment-`#` arm and the single-quote arm
7932 // are both per-byte arms inside the same `for &b in
7933 // s.as_bytes()` loop, so the byte that appears first in the
7934 // value's byte order wins. A `:repo
7935 // "https://github.com/p/x#readme'tail"` carries both `#` and
7936 // `'`; the `#` byte appears first, so the fragment-`#` arm
7937 // fires, surfacing the more self-locating diagnostic on the
7938 // byte the author pasted earliest in the URL.
7939 let d = dep_with_fonte(DepSource::Git {
7940 repo: "https://github.com/pleme-io/caixa-teia#readme'tail".into(),
7941 tag: Some("v0.1.0".into()),
7942 rev: None,
7943 branch: None,
7944 });
7945 let err = d.validate().unwrap_err();
7946 let DepError::FonteRepoShape { reason, .. } = err else {
7947 panic!("expected FonteRepoShape, got other variant");
7948 };
7949 assert!(
7950 reason.contains("must not contain `#`"),
7951 "reason must surface the fragment-`#` arm (fires before single-quote when `#` \
7952 byte appears first in value), got {reason:?}"
7953 );
7954 }
7955
7956 #[test]
7957 fn fonte_repo_double_quote_fires_before_single_quote_when_double_quote_first() {
7958 // Cascade pin: the double-quote-`"` arm (the immediate-predecessor
7959 // byte-class arm, 4267d8b) and the single-quote arm are both
7960 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
7961 // so the byte that appears first in the value's byte order
7962 // wins. A `:repo "github:p/x\"mid'tail"` carries both `"` and
7963 // `'`; the `"` byte appears first, so the double-quote arm
7964 // fires, surfacing the more self-locating diagnostic on the
7965 // byte the author pasted earliest in the URL. Pins the natural-
7966 // order cascade so a future reorder of the per-byte arms
7967 // surfaces here — `'` is the most recent byte-class arm, so
7968 // the cascade-pin sweep extends to cover the immediately prior
7969 // `"` byte arm firing first when ordered ahead of `'` in the
7970 // value.
7971 let d = dep_with_fonte(DepSource::Git {
7972 repo: "github:pleme-io/caixa-teia\"mid'tail".into(),
7973 tag: Some("v0.1.0".into()),
7974 rev: None,
7975 branch: None,
7976 });
7977 let err = d.validate().unwrap_err();
7978 let DepError::FonteRepoShape { reason, .. } = err else {
7979 panic!("expected FonteRepoShape, got other variant");
7980 };
7981 assert!(
7982 reason.contains("must not contain `\"`"),
7983 "reason must surface the double-quote arm (fires before single-quote when `\"` \
7984 byte appears first in value), got {reason:?}"
7985 );
7986 }
7987
7988 #[test]
7989 fn validate_rejects_git_fonte_with_repo_carrying_shell_history_expansion() {
7990 // The fail-before-pass-after pin for the canonical paste-from-
7991 // shell-history footgun on `:repo`. An author copies a `git
7992 // clone <url>!sudo make install` one-liner from a README's
7993 // quick-start snippet, intending the trailing `!sudo` as a
7994 // shell-history-expansion reference but the typed slot is itself
7995 // a byte-level string parser, not a shell context, so the byte
7996 // rides into the value verbatim. Until this arm landed the `!`
7997 // byte silently passed every prior `is_git_repo_url` arm (no
7998 // whitespace, no control chars, no non-ASCII, no `#`, no `?`,
7999 // no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no `|`, no `;`,
8000 // no `&`, no `$`, no `*`, no `(`/`)`, no `"`, no `'`, doesn't
8001 // start with `-` or `:`); bash with the default `histexpand`
8002 // mode rewrites `!command` to the most recent history entry
8003 // beginning with `command`, the canonical RCE-class injection
8004 // vector when the byte rides into a shell argument.
8005 let d = dep_with_fonte(DepSource::Git {
8006 repo: "https://github.com/pleme-io/caixa-teia!sudo".into(),
8007 tag: Some("v0.1.0".into()),
8008 rev: None,
8009 branch: None,
8010 });
8011 let err = d.validate().unwrap_err();
8012 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8013 panic!("expected FonteRepoShape, got other variant");
8014 };
8015 assert_eq!(nome, "caixa-teia");
8016 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia!sudo");
8017 assert!(
8018 reason.contains("must not contain `!`"),
8019 "reason must surface the shell-history-expansion arm, got {reason:?}"
8020 );
8021 assert!(
8022 reason.contains("history-expansion") || reason.contains("bang"),
8023 "reason must name the shell-history-expansion / bang rationale, got {reason:?}"
8024 );
8025 }
8026
8027 #[test]
8028 fn validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference() {
8029 // The symmetric `!!` repeat-prior-command pin: an author paste-
8030 // trims a `git clone <url>` retry idiom from shell history that
8031 // expands to the previous command via `!!`. Pinned separately
8032 // from the wrapped `!command` shape so a future diagnostic-
8033 // surface change that only checked the leading or paired-bang
8034 // position surfaces here — the per-byte arm fires anywhere `!`
8035 // appears in the value.
8036 let d = dep_with_fonte(DepSource::Git {
8037 repo: "github:pleme-io/caixa-teia!!".into(),
8038 tag: Some("v0.1.0".into()),
8039 rev: None,
8040 branch: None,
8041 });
8042 let err = d.validate().unwrap_err();
8043 let DepError::FonteRepoShape { reason, .. } = err else {
8044 panic!("expected FonteRepoShape, got other variant");
8045 };
8046 assert!(
8047 reason.contains("must not contain `!`"),
8048 "reason must surface the shell-history-expansion arm on the trailing-`!!` shape, \
8049 got {reason:?}"
8050 );
8051 }
8052
8053 #[test]
8054 fn fonte_repo_fragment_fires_before_bang_when_fragment_first() {
8055 // Cascade pin: the fragment-`#` arm and the bang arm are both
8056 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8057 // so the byte that appears first in the value's byte order
8058 // wins. A `:repo "https://github.com/p/x#readme!tail"` carries
8059 // both `#` and `!`; the `#` byte appears first, so the
8060 // fragment-`#` arm fires, surfacing the more self-locating
8061 // diagnostic on the byte the author pasted earliest in the URL.
8062 let d = dep_with_fonte(DepSource::Git {
8063 repo: "https://github.com/pleme-io/caixa-teia#readme!tail".into(),
8064 tag: Some("v0.1.0".into()),
8065 rev: None,
8066 branch: None,
8067 });
8068 let err = d.validate().unwrap_err();
8069 let DepError::FonteRepoShape { reason, .. } = err else {
8070 panic!("expected FonteRepoShape, got other variant");
8071 };
8072 assert!(
8073 reason.contains("must not contain `#`"),
8074 "reason must surface the fragment-`#` arm (fires before bang when `#` byte \
8075 appears first in value), got {reason:?}"
8076 );
8077 }
8078
8079 #[test]
8080 fn fonte_repo_single_quote_fires_before_bang_when_single_quote_first() {
8081 // Cascade pin: the single-quote-`'` arm (the immediate-predecessor
8082 // byte-class arm, e7a109f) and the bang arm are both per-byte
8083 // arms inside the same `for &b in s.as_bytes()` loop, so the
8084 // byte that appears first in the value's byte order wins. A
8085 // `:repo "github:p/x'mid!tail"` carries both `'` and `!`; the
8086 // `'` byte appears first, so the single-quote arm fires,
8087 // surfacing the more self-locating diagnostic on the byte the
8088 // author pasted earliest in the URL. Pins the natural-order
8089 // cascade so a future reorder of the per-byte arms surfaces
8090 // here — `!` is the most recent byte-class arm, so the
8091 // cascade-pin sweep extends to cover the immediately prior `'`
8092 // byte arm firing first when ordered ahead of `!` in the value.
8093 let d = dep_with_fonte(DepSource::Git {
8094 repo: "github:pleme-io/caixa-teia'mid!tail".into(),
8095 tag: Some("v0.1.0".into()),
8096 rev: None,
8097 branch: None,
8098 });
8099 let err = d.validate().unwrap_err();
8100 let DepError::FonteRepoShape { reason, .. } = err else {
8101 panic!("expected FonteRepoShape, got other variant");
8102 };
8103 assert!(
8104 reason.contains("must not contain `'`"),
8105 "reason must surface the single-quote arm (fires before bang when `'` byte \
8106 appears first in value), got {reason:?}"
8107 );
8108 }
8109
8110 #[test]
8111 fn validate_rejects_git_fonte_with_repo_carrying_list_separator_comma() {
8112 // The fail-before-pass-after pin for the canonical
8113 // list-separator-belongs-to-list-grammar footgun on `:repo`.
8114 // An author copies a `git clone <a>, <b>, <c>` paste-from-CSV
8115 // one-liner from a multi-repo bootstrap doc, intending the
8116 // comma to separate multiple repo entries but the typed
8117 // `:repo` slot names *one* repo (the list-separator belongs
8118 // to the `:deps` list grammar, not to the value). Until this
8119 // arm landed the `,` byte silently passed every prior
8120 // `is_git_repo_url` arm (no whitespace, no control chars, no
8121 // non-ASCII, no `#`, no `?`, no `\`, no `{`/`}`, no `<`/`>`,
8122 // no `` ` ``, no `|`, no `;`, no `&`, no `$`, no `*`, no
8123 // `(`/`)`, no `"`, no `'`, no `!`, doesn't start with `-` or
8124 // `:`); the byte rode into the lacre's per-dep content-
8125 // address and the resolver's `git clone <repo>` subprocess
8126 // invocation, where no host's repo registry resolved the
8127 // comma-bearing slug.
8128 let d = dep_with_fonte(DepSource::Git {
8129 repo: "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira".into(),
8130 tag: Some("v0.1.0".into()),
8131 rev: None,
8132 branch: None,
8133 });
8134 let err = d.validate().unwrap_err();
8135 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8136 panic!("expected FonteRepoShape, got other variant");
8137 };
8138 assert_eq!(nome, "caixa-teia");
8139 assert_eq!(
8140 repo,
8141 "github:pleme-io/caixa-teia,github:pleme-io/caixa-feira"
8142 );
8143 assert!(
8144 reason.contains("must not contain `,`"),
8145 "reason must surface the list-separator-comma arm, got {reason:?}"
8146 );
8147 assert!(
8148 reason.contains("list-separator") || reason.contains("sub-delims"),
8149 "reason must name the list-separator / RFC-3986-sub-delims rationale, \
8150 got {reason:?}"
8151 );
8152 }
8153
8154 #[test]
8155 fn validate_rejects_git_fonte_with_repo_carrying_trailing_comma() {
8156 // The symmetric trailing-`,` paste-from-prose pin: an author
8157 // writes `:repo "github:pleme-io/caixa-feira,"` (the trailing
8158 // comma every README-prose list-of-projects sentence carries,
8159 // mistakenly retained when the slug is pasted mid-sentence)
8160 // expecting the substrate to coerce it to a kebab-case slug.
8161 // Pinned separately from the wrapped mid-token shape so a
8162 // future diagnostic-surface change that only checked the
8163 // leading or paired-comma position surfaces here — the
8164 // per-byte arm fires anywhere `,` appears in the value.
8165 let d = dep_with_fonte(DepSource::Git {
8166 repo: "github:pleme-io/caixa-feira,".into(),
8167 tag: Some("v0.1.0".into()),
8168 rev: None,
8169 branch: None,
8170 });
8171 let err = d.validate().unwrap_err();
8172 let DepError::FonteRepoShape { reason, .. } = err else {
8173 panic!("expected FonteRepoShape, got other variant");
8174 };
8175 assert!(
8176 reason.contains("must not contain `,`"),
8177 "reason must surface the list-separator-comma arm on the trailing-`,` shape, \
8178 got {reason:?}"
8179 );
8180 }
8181
8182 #[test]
8183 fn fonte_repo_fragment_fires_before_comma_when_fragment_first() {
8184 // Cascade pin: the fragment-`#` arm and the comma arm are
8185 // both per-byte arms inside the same `for &b in s.as_bytes()`
8186 // loop, so the byte that appears first in the value's byte
8187 // order wins. A `:repo "https://github.com/p/x#readme,tail"`
8188 // carries both `#` and `,`; the `#` byte appears first, so
8189 // the fragment-`#` arm fires, surfacing the more self-
8190 // locating diagnostic on the byte the author pasted earliest
8191 // in the URL.
8192 let d = dep_with_fonte(DepSource::Git {
8193 repo: "https://github.com/pleme-io/caixa-teia#readme,tail".into(),
8194 tag: Some("v0.1.0".into()),
8195 rev: None,
8196 branch: None,
8197 });
8198 let err = d.validate().unwrap_err();
8199 let DepError::FonteRepoShape { reason, .. } = err else {
8200 panic!("expected FonteRepoShape, got other variant");
8201 };
8202 assert!(
8203 reason.contains("must not contain `#`"),
8204 "reason must surface the fragment-`#` arm (fires before comma when `#` byte \
8205 appears first in value), got {reason:?}"
8206 );
8207 }
8208
8209 #[test]
8210 fn fonte_repo_bang_fires_before_comma_when_bang_first() {
8211 // Cascade pin: the bang-`!` arm (the immediate-predecessor
8212 // byte-class arm, 7d53c68) and the comma arm are both
8213 // per-byte arms inside the same `for &b in s.as_bytes()`
8214 // loop, so the byte that appears first in the value's byte
8215 // order wins. A `:repo "github:p/x!mid,tail"` carries both
8216 // `!` and `,`; the `!` byte appears first, so the bang arm
8217 // fires, surfacing the more self-locating diagnostic on the
8218 // byte the author pasted earliest in the URL. Pins the
8219 // natural-order cascade so a future reorder of the per-byte
8220 // arms surfaces here — `,` is the most recent byte-class
8221 // arm, so the cascade-pin sweep extends to cover the
8222 // immediately prior `!` byte arm firing first when ordered
8223 // ahead of `,` in the value.
8224 let d = dep_with_fonte(DepSource::Git {
8225 repo: "github:pleme-io/caixa-teia!mid,tail".into(),
8226 tag: Some("v0.1.0".into()),
8227 rev: None,
8228 branch: None,
8229 });
8230 let err = d.validate().unwrap_err();
8231 let DepError::FonteRepoShape { reason, .. } = err else {
8232 panic!("expected FonteRepoShape, got other variant");
8233 };
8234 assert!(
8235 reason.contains("must not contain `!`"),
8236 "reason must surface the bang arm (fires before comma when `!` byte \
8237 appears first in value), got {reason:?}"
8238 );
8239 }
8240
8241 #[test]
8242 fn validate_rejects_git_fonte_with_repo_carrying_shell_env_var_assignment() {
8243 // The fail-before-pass-after pin for the canonical
8244 // shell-env-var-assignment-belongs-to-shell-grammar footgun
8245 // on `:repo`. An author copies
8246 // `GIT_TERMINAL_PROMPT=0 git clone <url>` (or
8247 // `GIT_SSL_NO_VERIFY=1 git clone <url>`, `HTTPS_PROXY=…
8248 // git clone <url>`, etc. — the canonical
8249 // git-troubleshooting README idiom for a one-shot env-var
8250 // scoped to the `git clone` invocation) from a shell-prompt
8251 // one-liner, intending the `KEY=VALUE` prefix as a shell-
8252 // grammar env-var assignment but the typed `:repo` slot is
8253 // a value parser, not a shell context, so the bytes ride
8254 // into the value verbatim. Until this arm landed the `=`
8255 // byte silently passed every prior `is_git_repo_url` arm
8256 // (no whitespace, no control chars, no non-ASCII, no `#`,
8257 // no `?`, no `\`, no `{`/`}`, no `<`/`>`, no `` ` ``, no
8258 // `|`, no `;`, no `&`, no `$`, no `*`, no `(`/`)`, no `"`,
8259 // no `'`, no `!`, no `,`, doesn't start with `-` or `:`);
8260 // the byte rode into the lacre's per-dep content-address
8261 // and the resolver's `git clone <repo>` subprocess
8262 // invocation, where the upstream host's git porcelain
8263 // fetched a literal `GIT_TERMINAL_PROMPT=0 https://…`-shaped
8264 // path that no host's repo registry resolves.
8265 let d = dep_with_fonte(DepSource::Git {
8266 repo: "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia".into(),
8267 tag: Some("v0.1.0".into()),
8268 rev: None,
8269 branch: None,
8270 });
8271 let err = d.validate().unwrap_err();
8272 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8273 panic!("expected FonteRepoShape, got other variant");
8274 };
8275 assert_eq!(nome, "caixa-teia");
8276 assert_eq!(
8277 repo,
8278 "GIT_TERMINAL_PROMPT=0 https://github.com/pleme-io/caixa-teia"
8279 );
8280 // The `=` byte at position 19 of `GIT_TERMINAL_PROMPT=0 …`
8281 // appears before the ` ` byte at position 21, so the `=`
8282 // arm fires (not the whitespace arm) — both arms guard
8283 // the slot, but the per-byte for-loop scans left-to-right
8284 // and the first matching byte wins.
8285 assert!(
8286 reason.contains("must not contain `=`"),
8287 "reason must surface the equals-`=` arm on the env-var-assignment \
8288 paste shape, got {reason:?}"
8289 );
8290 assert!(
8291 reason.contains("env-var-assignment") || reason.contains("KEY=VALUE"),
8292 "reason must name the shell-env-var-assignment rationale, got {reason:?}"
8293 );
8294 }
8295
8296 #[test]
8297 fn validate_rejects_git_fonte_with_repo_carrying_gitconfig_url_key_prefix() {
8298 // The symmetric paste-from-gitconfig pin: an author copies
8299 // `url=https://github.com/p/x` from `git config --get-all
8300 // remote.origin.url` output, a `.gitconfig` `[remote
8301 // "origin"] url = https://…` ini-stanza paste, or a
8302 // `git config remote.origin.url <value>` doc snippet,
8303 // intending the `url=` prefix as the ini-key but the typed
8304 // `:repo` slot is a URL value parser, not a gitconfig
8305 // grammar. With no leading whitespace and no earlier-arm
8306 // bytes in the value, the `=` arm itself fires (rather
8307 // than cascading to the whitespace arm as in the env-var
8308 // paste shape). Pinned separately so a future diagnostic-
8309 // surface change that only checked the whitespace-leading
8310 // shape surfaces here — the per-byte arm fires anywhere
8311 // `=` appears in the value.
8312 let d = dep_with_fonte(DepSource::Git {
8313 repo: "url=https://github.com/pleme-io/caixa-feira".into(),
8314 tag: Some("v0.1.0".into()),
8315 rev: None,
8316 branch: None,
8317 });
8318 let err = d.validate().unwrap_err();
8319 let DepError::FonteRepoShape { reason, .. } = err else {
8320 panic!("expected FonteRepoShape, got other variant");
8321 };
8322 assert!(
8323 reason.contains("must not contain `=`"),
8324 "reason must surface the equals-`=` arm on the `url=…` gitconfig \
8325 paste shape, got {reason:?}"
8326 );
8327 assert!(
8328 reason.contains("key-value-separator") || reason.contains("sub-delims"),
8329 "reason must name the key-value-separator / RFC-3986-sub-delims \
8330 rationale, got {reason:?}"
8331 );
8332 }
8333
8334 #[test]
8335 fn fonte_repo_fragment_fires_before_equals_when_fragment_first() {
8336 // Cascade pin: the fragment-`#` arm and the `=` arm are
8337 // both per-byte arms inside the same `for &b in s.as_bytes()`
8338 // loop, so the byte that appears first in the value's byte
8339 // order wins. A `:repo "https://github.com/p/x#readme=tail"`
8340 // carries both `#` and `=`; the `#` byte appears first, so
8341 // the fragment-`#` arm fires, surfacing the more self-
8342 // locating diagnostic on the byte the author pasted earliest
8343 // in the URL.
8344 let d = dep_with_fonte(DepSource::Git {
8345 repo: "https://github.com/pleme-io/caixa-teia#readme=tail".into(),
8346 tag: Some("v0.1.0".into()),
8347 rev: None,
8348 branch: None,
8349 });
8350 let err = d.validate().unwrap_err();
8351 let DepError::FonteRepoShape { reason, .. } = err else {
8352 panic!("expected FonteRepoShape, got other variant");
8353 };
8354 assert!(
8355 reason.contains("must not contain `#`"),
8356 "reason must surface the fragment-`#` arm (fires before equals when \
8357 `#` byte appears first in value), got {reason:?}"
8358 );
8359 }
8360
8361 #[test]
8362 fn fonte_repo_comma_fires_before_equals_when_comma_first() {
8363 // Cascade pin: the comma-`,` arm (the immediate-predecessor
8364 // byte-class arm, 775b80e) and the `=` arm are both per-byte
8365 // arms inside the same `for &b in s.as_bytes()` loop, so
8366 // the byte that appears first in the value's byte order
8367 // wins. A `:repo "github:p/x,mid=tail"` carries both `,`
8368 // and `=`; the `,` byte appears first, so the comma arm
8369 // fires, surfacing the more self-locating diagnostic on
8370 // the byte the author pasted earliest in the URL. Pins the
8371 // natural-order cascade so a future reorder of the per-byte
8372 // arms surfaces here — `=` is the most recent byte-class
8373 // arm, so the cascade-pin sweep extends to cover the
8374 // immediately prior `,` byte arm firing first when ordered
8375 // ahead of `=` in the value.
8376 let d = dep_with_fonte(DepSource::Git {
8377 repo: "github:pleme-io/caixa-teia,mid=tail".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 not contain `,`"),
8388 "reason must surface the comma arm (fires before equals when `,` byte \
8389 appears first in value), got {reason:?}"
8390 );
8391 }
8392
8393 #[test]
8394 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_space() {
8395 // The fail-before-pass-after pin for the canonical paste-from-
8396 // browser-address-bar percent-encoded-space footgun on `:repo`.
8397 // An author copies `https://github.com/p/x%20test` from a
8398 // browser address bar (or a percent-encoded README hyperlink,
8399 // or a `curl --data-urlencode` shell-pipeline output)
8400 // intending `%20` as the URL encoding of a literal space; the
8401 // typed `:repo` slot already rejects the literal space byte
8402 // (the whitespace arm at the top of `is_git_repo_url`), so an
8403 // author trying to express "I really meant a space" reaches
8404 // for percent-encoding. Until this arm landed the `%` byte
8405 // silently passed every prior `is_git_repo_url` arm and rode
8406 // verbatim into the lacre's per-dep content-address — but
8407 // libcurl re-percent-encodes `%` to `%25` on the wire (since
8408 // `%` is reserved as the escape-sequence lead-in), so the
8409 // wire request becomes `https://github.com/p/x%2520test`, a
8410 // path the lacre's content-address never names. The classic
8411 // render-determinism violation on the encoding-mechanism axis
8412 // itself.
8413 let d = dep_with_fonte(DepSource::Git {
8414 repo: "https://github.com/pleme-io/caixa-teia%20test".into(),
8415 tag: Some("v0.1.0".into()),
8416 rev: None,
8417 branch: None,
8418 });
8419 let err = d.validate().unwrap_err();
8420 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8421 panic!("expected FonteRepoShape, got other variant");
8422 };
8423 assert_eq!(nome, "caixa-teia");
8424 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia%20test");
8425 assert!(
8426 reason.contains("must not contain `%`"),
8427 "reason must surface the percent-`%` arm on the percent-encoded-space \
8428 paste shape, got {reason:?}"
8429 );
8430 assert!(
8431 reason.contains("percent-encoding") || reason.contains("%25"),
8432 "reason must name the percent-encoding / `%25` re-encoding rationale, \
8433 got {reason:?}"
8434 );
8435 }
8436
8437 #[test]
8438 fn validate_rejects_git_fonte_with_repo_carrying_percent_encoded_slash() {
8439 // The symmetric over-encoded-path-separator pin: an author
8440 // writes `:repo "https://github.com/p%2Fx"` intending the
8441 // `%2F` as the URL encoding of `/` (the canonical
8442 // paste-from-OpenAPI-spec / paste-from-percent-encoded-template
8443 // footgun every API client library and OAuth redirect-URI
8444 // documentation surfaces — the `/` is the URL-path-separator
8445 // and some templates percent-encode it to escape interpretation
8446 // as a path separator). The GitHub Smart-HTTP transport
8447 // resolves the URL's path-segment grammar before the
8448 // percent-decoding pass, so the value identifies a different
8449 // resource on the wire than the literal-`/` form the lacre's
8450 // content-address must agree with — two authors whose `:repo`
8451 // values differ only in their `/` vs `%2F` presence lock to
8452 // two distinct BLAKE3 closures for the byte-identical upstream
8453 // `git clone`. Pinned separately so a future diagnostic
8454 // surface that only catches the `%20` shape surfaces here too.
8455 let d = dep_with_fonte(DepSource::Git {
8456 repo: "https://github.com/pleme-io%2Fcaixa-teia".into(),
8457 tag: Some("v0.1.0".into()),
8458 rev: None,
8459 branch: None,
8460 });
8461 let err = d.validate().unwrap_err();
8462 let DepError::FonteRepoShape { reason, .. } = err else {
8463 panic!("expected FonteRepoShape, got other variant");
8464 };
8465 assert!(
8466 reason.contains("must not contain `%`"),
8467 "reason must surface the percent-`%` arm on the over-encoded-path \
8468 shape, got {reason:?}"
8469 );
8470 assert!(
8471 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8472 "reason must name the render-determinism / BLAKE3-closure rationale, \
8473 got {reason:?}"
8474 );
8475 }
8476
8477 #[test]
8478 fn fonte_repo_fragment_fires_before_percent_when_fragment_first() {
8479 // Cascade pin: the fragment-`#` arm and the `%` arm are both
8480 // per-byte arms inside the same `for &b in s.as_bytes()` loop,
8481 // so the byte that appears first in the value's byte order
8482 // wins. A `:repo "https://github.com/p/x#sec%20tail"` carries
8483 // both `#` and `%`; the `#` byte appears first, so the
8484 // fragment-`#` arm fires, surfacing the more self-locating
8485 // diagnostic on the byte the author pasted earliest in the URL.
8486 let d = dep_with_fonte(DepSource::Git {
8487 repo: "https://github.com/pleme-io/caixa-teia#sec%20tail".into(),
8488 tag: Some("v0.1.0".into()),
8489 rev: None,
8490 branch: None,
8491 });
8492 let err = d.validate().unwrap_err();
8493 let DepError::FonteRepoShape { reason, .. } = err else {
8494 panic!("expected FonteRepoShape, got other variant");
8495 };
8496 assert!(
8497 reason.contains("must not contain `#`"),
8498 "reason must surface the fragment-`#` arm (fires before percent when \
8499 `#` byte appears first in value), got {reason:?}"
8500 );
8501 }
8502
8503 #[test]
8504 fn fonte_repo_equals_fires_before_percent_when_equals_first() {
8505 // Cascade pin: the equals-`=` arm (the immediate-predecessor
8506 // byte-class arm, acf99af) and the `%` arm are both per-byte
8507 // arms inside the same `for &b in s.as_bytes()` loop, so the
8508 // byte that appears first in the value's byte order wins.
8509 // A `:repo "github:p/x=mid%20tail"` carries both `=` and `%`;
8510 // the `=` byte appears first, so the equals arm fires,
8511 // surfacing the more self-locating diagnostic on the byte the
8512 // author pasted earliest in the URL. Pins the natural-order
8513 // cascade so a future reorder of the per-byte arms surfaces
8514 // here — `%` is the most recent byte-class arm, so the
8515 // cascade-pin sweep extends to cover the immediately prior
8516 // `=` byte arm firing first when ordered ahead of `%` in the
8517 // value.
8518 let d = dep_with_fonte(DepSource::Git {
8519 repo: "github:pleme-io/caixa-teia=mid%20tail".into(),
8520 tag: Some("v0.1.0".into()),
8521 rev: None,
8522 branch: None,
8523 });
8524 let err = d.validate().unwrap_err();
8525 let DepError::FonteRepoShape { reason, .. } = err else {
8526 panic!("expected FonteRepoShape, got other variant");
8527 };
8528 assert!(
8529 reason.contains("must not contain `=`"),
8530 "reason must surface the equals arm (fires before percent when `=` byte \
8531 appears first in value), got {reason:?}"
8532 );
8533 }
8534
8535 #[test]
8536 fn validate_rejects_git_fonte_with_repo_carrying_caret_history_substitution() {
8537 // The fail-before-pass-after pin for the canonical paste-from-
8538 // shell-history footgun on `:repo`. An author copies a
8539 // `git clone <url>` line from their terminal followed by a
8540 // bash / ksh / zsh `^typo^fix^` quick-edit-and-rerun shell-
8541 // history shorthand (the `^old^new^` form re-runs the prior
8542 // history entry with the first `old` substituted by `new`,
8543 // bash's default behavior on interactive sessions with
8544 // `set -o histexpand`), forgetting to trim the trailing
8545 // `^...^...` shell-history fragment from the URL value. The
8546 // `^` byte sits in the RFC 3986 §2 'unwise' set (peer with
8547 // `{`, `}`, `|`, `\\` — the strictest of the §2 reserved
8548 // classes), the WHATWG URL spec's 'fragment percent-encode
8549 // set' maps `^` → `%5E` on the wire, so the byte rides
8550 // verbatim into the lacre's per-dep content-address but
8551 // libcurl re-encodes it to `%5E` at `git clone` time — the
8552 // classic render-determinism violation on the same axis the
8553 // peer `%`, `=`, `,`, `!`, `'`, `"`, `(`, `)`, `*`, `$`,
8554 // `&`, `;`, `|`, backtick, `<`, `>`, `{`, `}`, `\\`, `?`,
8555 // `#` arms close.
8556 let d = dep_with_fonte(DepSource::Git {
8557 repo: "https://github.com/pleme-io/caixa-teia^typo^fix".into(),
8558 tag: Some("v0.1.0".into()),
8559 rev: None,
8560 branch: None,
8561 });
8562 let err = d.validate().unwrap_err();
8563 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8564 panic!("expected FonteRepoShape, got other variant");
8565 };
8566 assert_eq!(nome, "caixa-teia");
8567 assert_eq!(repo, "https://github.com/pleme-io/caixa-teia^typo^fix");
8568 assert!(
8569 reason.contains("must not contain `^`"),
8570 "reason must surface the caret-`^` arm on the paste-from-shell-history \
8571 shape, got {reason:?}"
8572 );
8573 assert!(
8574 reason.contains("history-substitution") || reason.contains("%5E"),
8575 "reason must name the shell-history-substitution / `%5E` wire-encoding \
8576 rationale, got {reason:?}"
8577 );
8578 }
8579
8580 #[test]
8581 fn validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor() {
8582 // The symmetric paste-from-doc-grep-pipeline footgun: an
8583 // author writes `:repo "github:p/^archived"` after copying a
8584 // `grep '^archived'` regex-anchor / negation idiom from a
8585 // doc / README quick-listing snippet, expecting the substrate
8586 // to coerce it to a literal repo name. The byte rides
8587 // verbatim into the lacre's per-dep content-address and
8588 // diverges from the byte-identical literal `archived` form
8589 // every other author authored — the canonical render-
8590 // determinism violation pin on the second footgun shape the
8591 // caret-`^` arm closes.
8592 let d = dep_with_fonte(DepSource::Git {
8593 repo: "github:pleme-io/^archived".into(),
8594 tag: Some("v0.1.0".into()),
8595 rev: None,
8596 branch: None,
8597 });
8598 let err = d.validate().unwrap_err();
8599 let DepError::FonteRepoShape { reason, .. } = err else {
8600 panic!("expected FonteRepoShape, got other variant");
8601 };
8602 assert!(
8603 reason.contains("must not contain `^`"),
8604 "reason must surface the caret-`^` arm on the regex-anchor shape, \
8605 got {reason:?}"
8606 );
8607 assert!(
8608 reason.contains("render-determinism") || reason.contains("BLAKE3"),
8609 "reason must name the render-determinism / BLAKE3-closure rationale, \
8610 got {reason:?}"
8611 );
8612 }
8613
8614 #[test]
8615 fn fonte_repo_percent_fires_before_caret_when_percent_first() {
8616 // Cascade pin: the `%` arm (the immediate-predecessor byte-
8617 // class arm, a323db8) and the `^` arm are both per-byte arms
8618 // inside the same `for &b in s.as_bytes()` loop, so the byte
8619 // that appears first in the value's byte order wins. A
8620 // `:repo "https://github.com/p/x%20mid^tail"` carries both
8621 // `%` and `^`; the `%` byte appears first, so the percent
8622 // arm fires, surfacing the more self-locating diagnostic on
8623 // the byte the author pasted earliest in the URL. Pins the
8624 // natural-order cascade so a future reorder of the per-byte
8625 // arms surfaces here — `^` is the most recent byte-class arm,
8626 // so the cascade-pin sweep extends to cover the immediately
8627 // prior `%` byte arm firing first when ordered ahead of `^`
8628 // in the value.
8629 let d = dep_with_fonte(DepSource::Git {
8630 repo: "https://github.com/pleme-io/caixa-teia%20mid^tail".into(),
8631 tag: Some("v0.1.0".into()),
8632 rev: None,
8633 branch: None,
8634 });
8635 let err = d.validate().unwrap_err();
8636 let DepError::FonteRepoShape { reason, .. } = err else {
8637 panic!("expected FonteRepoShape, got other variant");
8638 };
8639 assert!(
8640 reason.contains("must not contain `%`"),
8641 "reason must surface the percent arm (fires before caret when `%` byte \
8642 appears first in value), got {reason:?}"
8643 );
8644 }
8645
8646 #[test]
8647 fn validate_rejects_git_fonte_with_repo_missing_colon_separator() {
8648 // The "I dropped the scheme" footgun — `:repo "pleme-io/caixa-teia"`
8649 // (no `github:` prefix, no scheme). Every documented form
8650 // carries a `:` (`github:`, `https://`, `ssh://`, `git://`,
8651 // `file://`, or `git@host:path`); a bare `org/repo` is
8652 // ambiguous (`git clone` reads as a relative filesystem path
8653 // rather than the GitHub-shorthand expansion the author
8654 // probably intended) and the gate rejects the shape upstream.
8655 let d = dep_with_fonte(DepSource::Git {
8656 repo: "pleme-io/caixa-teia".into(),
8657 tag: Some("v0.1.0".into()),
8658 rev: None,
8659 branch: None,
8660 });
8661 let err = d.validate().unwrap_err();
8662 let DepError::FonteRepoShape { reason, .. } = err else {
8663 panic!("expected FonteRepoShape, got other variant");
8664 };
8665 assert!(
8666 reason.contains("must contain a `:`"),
8667 "reason must surface the missing-`:` arm, got {reason:?}"
8668 );
8669 assert!(
8670 reason.contains("github:"),
8671 "reason must name the canonical `github:` shorthand prefix, got {reason:?}"
8672 );
8673 }
8674
8675 #[test]
8676 fn validate_rejects_git_fonte_with_repo_leading_colon() {
8677 // The "empty scheme" footgun — `:repo ":foo"` has a zero-length
8678 // scheme that no git porcelain entry-point accepts. Pinned
8679 // separately from the missing-`:` arm because a value with a
8680 // leading `:` does technically contain a `:` separator; the
8681 // shape gate rejects on a dedicated arm so the diagnostic
8682 // names the specific footgun.
8683 let d = dep_with_fonte(DepSource::Git {
8684 repo: ":pleme-io/caixa-teia".into(),
8685 tag: Some("v0.1.0".into()),
8686 rev: None,
8687 branch: None,
8688 });
8689 let err = d.validate().unwrap_err();
8690 let DepError::FonteRepoShape { reason, .. } = err else {
8691 panic!("expected FonteRepoShape, got other variant");
8692 };
8693 assert!(
8694 reason.contains("must not start with `:`"),
8695 "reason must surface the leading-`:` arm, got {reason:?}"
8696 );
8697 }
8698
8699 #[test]
8700 fn validate_rejects_git_fonte_with_repo_too_long() {
8701 // The cap arm — a `:repo` value longer than
8702 // [`crate::render::GIT_REPO_URL_MAX_LEN`] (2048) bytes is
8703 // structurally untenable on every realistic landing site (the
8704 // resolver's `git clone` invocation, the future M4 CR
8705 // materializer's per-dep `repo:` axis); a value of that length
8706 // is almost certainly a paste-from-binary slug.
8707 let too_long = format!(
8708 "github:pleme-io/{}",
8709 "x".repeat(crate::render::GIT_REPO_URL_MAX_LEN)
8710 );
8711 let d = dep_with_fonte(DepSource::Git {
8712 repo: too_long.clone(),
8713 tag: Some("v0.1.0".into()),
8714 rev: None,
8715 branch: None,
8716 });
8717 let err = d.validate().unwrap_err();
8718 let DepError::FonteRepoShape { reason, .. } = err else {
8719 panic!("expected FonteRepoShape, got other variant");
8720 };
8721 assert!(
8722 reason.contains("2048"),
8723 "reason must name the cap, got {reason:?}"
8724 );
8725 }
8726
8727 #[test]
8728 fn validate_accepts_canonical_git_fonte_repo_shapes() {
8729 // The positive-control sweep: every documented author shape on
8730 // the `:fonte :repo` axis ([`crate::DepSource::Git`] doc comment)
8731 // must pass the value-shape gate. Pinned so a future tightening
8732 // (e.g. forbidding `http://` in favor of `https://`-only) surfaces
8733 // here as a structural decision. Each form is exercised with the
8734 // same canonical `:tag` pin so only the `:repo` axis varies.
8735 for repo in [
8736 // The pleme-io registry-shorthand convention — `github:org/repo`.
8737 "github:pleme-io/caixa-teia",
8738 // Other host-aliased shorthands (the resolver's pluggable
8739 // host-prefix table).
8740 "gitlab:pleme-io/caixa-teia",
8741 "codeberg:pleme-io/caixa-teia",
8742 "sourcehut:~pleme-io/caixa-teia",
8743 // Full HTTPS URL with and without `.git` suffix.
8744 "https://github.com/pleme-io/caixa-teia",
8745 "https://github.com/pleme-io/caixa-teia.git",
8746 // HTTP (rare; dev / mirror).
8747 "http://example.com/pleme-io/caixa-teia.git",
8748 // SSH URL.
8749 "ssh://git@github.com/pleme-io/caixa-teia.git",
8750 "ssh://git@git.example.com:2222/pleme-io/caixa-teia.git",
8751 // Scp-style SSH — the canonical `git@host:path` short form.
8752 "git@github.com:pleme-io/caixa-teia.git",
8753 "git@git.example.com:team/private.git",
8754 // Anonymous git protocol.
8755 "git://git.example.com/pleme-io/caixa-teia.git",
8756 // Local file URL (dev path).
8757 "file:///tmp/caixa-teia",
8758 ] {
8759 let d = dep_with_fonte(DepSource::Git {
8760 repo: repo.into(),
8761 tag: Some("v0.1.0".into()),
8762 rev: None,
8763 branch: None,
8764 });
8765 d.validate()
8766 .unwrap_or_else(|e| panic!("canonical repo {repo:?} must validate, got {e:?}"));
8767 }
8768 }
8769
8770 #[test]
8771 fn fonte_repo_empty_takes_precedence_over_shape() {
8772 // Order pin: the existing `FonteRepoEmpty` diagnostic (narrower
8773 // diagnostic; doesn't try to parse the URL shape) fires before
8774 // the new `FonteRepoShape` per-axis gate, so an empty `:repo`
8775 // keeps its narrower error message. Mirrors
8776 // `fonte_repo_empty_fires_before_pin_missing` (already pinned)
8777 // on the ordering layer.
8778 let d = dep_with_fonte(DepSource::Git {
8779 repo: String::new(),
8780 tag: Some("v0.1.0".into()),
8781 rev: None,
8782 branch: None,
8783 });
8784 let err = d.validate().unwrap_err();
8785 assert!(
8786 matches!(err, DepError::FonteRepoEmpty { .. }),
8787 "got {err:?}"
8788 );
8789 }
8790
8791 #[test]
8792 fn fonte_repo_shape_fires_before_pin_missing() {
8793 // Order pin: a malformed `:repo` value on a dep with no pin set
8794 // surfaces the `:repo` shape diagnostic (the more self-locating
8795 // axis — the `:repo` is the load-bearing identity of the source;
8796 // a missing pin is downstream from "do we even know the repo")
8797 // rather than collapsing onto the pin-missing diagnostic. The
8798 // shape gate runs inline before the pin enumeration in
8799 // `DepSource::validate`.
8800 let d = dep_with_fonte(DepSource::Git {
8801 repo: "pleme-io/caixa-teia".into(), // missing `:` separator
8802 tag: None,
8803 rev: None,
8804 branch: None,
8805 });
8806 let err = d.validate().unwrap_err();
8807 assert!(
8808 matches!(err, DepError::FonteRepoShape { .. }),
8809 "got {err:?}"
8810 );
8811 }
8812
8813 #[test]
8814 fn fonte_repo_shape_diagnostic_carries_offending_repo_verbatim() {
8815 // The diagnostic-shape pin: the error names the offending
8816 // `:repo` value verbatim plus a non-empty parser-shaped `reason`
8817 // so the author can grep their caixa.lisp without re-running
8818 // the build. Mirrors the diagnostic-shape sweep on every prior
8819 // value-shape gate (3f9d7a0, 6cbb900, c7d05ec, e70d213, be07fd5).
8820 let d = dep_with_fonte(DepSource::Git {
8821 repo: "pleme-io/caixa-teia".into(),
8822 tag: Some("v0.1.0".into()),
8823 rev: None,
8824 branch: None,
8825 });
8826 let err = d.validate().unwrap_err();
8827 let DepError::FonteRepoShape { nome, repo, reason } = err else {
8828 panic!("expected FonteRepoShape, got other variant");
8829 };
8830 assert_eq!(nome, "caixa-teia");
8831 assert_eq!(repo, "pleme-io/caixa-teia");
8832 assert!(
8833 !reason.is_empty(),
8834 "FonteRepoShape `reason` must carry the predicate's wording verbatim"
8835 );
8836 }
8837
8838 #[test]
8839 fn validate_rejects_git_fonte_with_no_pin() {
8840 // The fail-before-pass-after pin for the canonical
8841 // `(:tipo git :repo "github:pleme-io/x")` shape with no
8842 // :tag/:rev/:branch — until this gate landed the resolver's
8843 // ResolveError::MissingPin surfaced at fetch time, far from the
8844 // source caixa.lisp. The new gate moves the check to validate
8845 // time and names the offending dep.
8846 let d = dep_with_fonte(DepSource::Git {
8847 repo: "github:pleme-io/caixa-teia".into(),
8848 tag: None,
8849 rev: None,
8850 branch: None,
8851 });
8852 let err = d.validate().unwrap_err();
8853 assert!(
8854 matches!(err, DepError::FontePinMissing { ref nome } if nome == "caixa-teia"),
8855 "got {err:?}"
8856 );
8857 }
8858
8859 #[test]
8860 fn validate_rejects_git_fonte_with_ambiguous_tag_and_branch() {
8861 // The canonical "pin drift" footgun: an author writes
8862 // `:tag "v1"` and later adds `:branch "main"` without removing
8863 // the :tag, and the resolver silently picks :tag (precedence
8864 // :rev > :tag > :branch). The :branch was dropped with no
8865 // diagnostic. The gate now rejects multi-pin shapes so the
8866 // author makes the precedence explicit at the source.
8867 let d = dep_with_fonte(DepSource::Git {
8868 repo: "github:pleme-io/caixa-teia".into(),
8869 tag: Some("v0.1.0".into()),
8870 rev: None,
8871 branch: Some("main".into()),
8872 });
8873 let err = d.validate().unwrap_err();
8874 let DepError::FontePinAmbiguous { nome, pins } = err else {
8875 panic!("expected FontePinAmbiguous");
8876 };
8877 assert_eq!(nome, "caixa-teia");
8878 assert!(pins.contains(":tag"));
8879 assert!(pins.contains(":branch"));
8880 assert!(!pins.contains(":rev"));
8881 }
8882
8883 #[test]
8884 fn validate_rejects_git_fonte_with_ambiguous_tag_and_rev() {
8885 // Sibling arm of the pin-drift footgun: :tag + :rev set
8886 // simultaneously. Pinned separately so a future relaxation
8887 // that only catches the (:tag, :branch) pair surfaces here.
8888 let d = dep_with_fonte(DepSource::Git {
8889 repo: "github:pleme-io/caixa-teia".into(),
8890 tag: Some("v0.1.0".into()),
8891 rev: Some("c0ffee".into()),
8892 branch: None,
8893 });
8894 let err = d.validate().unwrap_err();
8895 let DepError::FontePinAmbiguous { nome, pins } = err else {
8896 panic!("expected FontePinAmbiguous");
8897 };
8898 assert_eq!(nome, "caixa-teia");
8899 assert!(pins.contains(":tag"));
8900 assert!(pins.contains(":rev"));
8901 }
8902
8903 #[test]
8904 fn validate_rejects_git_fonte_with_all_three_pins() {
8905 // The maximal ambiguity case — every pin axis set. Pinned so a
8906 // future relaxation that only catches pairs surfaces here. The
8907 // diagnostic must enumerate every offending axis so the author
8908 // sees the full set, not just the first match.
8909 let d = dep_with_fonte(DepSource::Git {
8910 repo: "github:pleme-io/caixa-teia".into(),
8911 tag: Some("v0.1.0".into()),
8912 rev: Some("c0ffee".into()),
8913 branch: Some("main".into()),
8914 });
8915 let err = d.validate().unwrap_err();
8916 let DepError::FontePinAmbiguous { nome, pins } = err else {
8917 panic!("expected FontePinAmbiguous");
8918 };
8919 assert_eq!(nome, "caixa-teia");
8920 assert!(pins.contains(":tag"));
8921 assert!(pins.contains(":rev"));
8922 assert!(pins.contains(":branch"));
8923 }
8924
8925 #[test]
8926 fn validate_rejects_git_fonte_with_empty_tag_pin() {
8927 // The empty-pin arm: exactly one pin axis is `Some(_)`, but its
8928 // inner string is empty. Distinct from FontePinMissing (where
8929 // every axis is None) — pinned separately so a future
8930 // tightening collapsing them surfaces here as a structural
8931 // decision.
8932 let d = dep_with_fonte(DepSource::Git {
8933 repo: "github:pleme-io/caixa-teia".into(),
8934 tag: Some(String::new()),
8935 rev: None,
8936 branch: None,
8937 });
8938 let err = d.validate().unwrap_err();
8939 let DepError::FontePinEmpty { nome, pin } = err else {
8940 panic!("expected FontePinEmpty");
8941 };
8942 assert_eq!(nome, "caixa-teia");
8943 assert_eq!(pin, ":tag");
8944 }
8945
8946 #[test]
8947 fn validate_rejects_git_fonte_with_empty_rev_pin() {
8948 // Sibling arm — the empty-pin diagnostic names which axis
8949 // carries the empty value, so the author's grep target is
8950 // unambiguous.
8951 let d = dep_with_fonte(DepSource::Git {
8952 repo: "github:pleme-io/caixa-teia".into(),
8953 tag: None,
8954 rev: Some(String::new()),
8955 branch: None,
8956 });
8957 let err = d.validate().unwrap_err();
8958 let DepError::FontePinEmpty { nome, pin } = err else {
8959 panic!("expected FontePinEmpty");
8960 };
8961 assert_eq!(nome, "caixa-teia");
8962 assert_eq!(pin, ":rev");
8963 }
8964
8965 #[test]
8966 fn validate_rejects_path_fonte_with_empty_caminho() {
8967 // The fail-before-pass-after pin for `(:tipo path :caminho "")`:
8968 // until this gate landed the resolver's
8969 // ResolveError::MissingPath surfaced with `path: PathBuf("")` at
8970 // fetch time — not actionable. The new gate moves the check to
8971 // validate time and names the offending dep.
8972 let d = dep_with_fonte(DepSource::Path {
8973 caminho: String::new(),
8974 });
8975 let err = d.validate().unwrap_err();
8976 assert!(
8977 matches!(err, DepError::FonteCaminhoEmpty { ref nome } if nome == "caixa-teia"),
8978 "got {err:?}"
8979 );
8980 }
8981
8982 #[test]
8983 fn validate_rejects_path_fonte_with_absolute_caminho() {
8984 // The fail-before-pass-after pin for the absolute-`:caminho`
8985 // shape: `(:tipo path :caminho "/home/me/work/caixa-teia")`.
8986 // Until this gate landed an absolute `:caminho` silently
8987 // passed validate; the lacre pipeline embedded the
8988 // host-specific filesystem path verbatim in its
8989 // content-address (`conteudo: format!("path:{caminho}")`,
8990 // caixa-resolver/src/resolve.rs:189), so the BLAKE3 closure
8991 // differed per machine — the build succeeded but two CI
8992 // runners with different `${HOME}` layouts emitted two
8993 // distinct lacres for the byte-identical caixa, silently
8994 // breaking the THEORY.md §V.2 render-determinism contract
8995 // far from the source caixa.lisp. The new gate moves the
8996 // check to validate time and names the offending dep +
8997 // caminho verbatim.
8998 let d = dep_with_fonte(DepSource::Path {
8999 caminho: "/home/me/work/caixa-teia".into(),
9000 });
9001 let err = d.validate().unwrap_err();
9002 let DepError::FonteCaminhoAbsolute { nome, caminho } = err else {
9003 panic!("expected FonteCaminhoAbsolute, got other variant");
9004 };
9005 assert_eq!(nome, "caixa-teia");
9006 assert_eq!(caminho, "/home/me/work/caixa-teia");
9007 }
9008
9009 #[test]
9010 fn validate_accepts_path_fonte_with_parent_escape_caminho() {
9011 // The canonical sibling-workspace dep form
9012 // (`:caminho "../caixa-teia"`) remains accepted. The
9013 // absolute-path gate above is specifically narrower than the
9014 // shared [`crate::render::is_sandboxed_relative_path`]
9015 // predicate (which additionally forbids `..` traversal): a
9016 // local-path dep's canonical author surface is the in-tree
9017 // sibling-workspace path, so a full sandboxed-relative-path
9018 // lift would structurally reject every legitimate path-fonte
9019 // dep. Pinned so a future tightening to the full predicate
9020 // surfaces here as a structural decision, not a silent break.
9021 let d = dep_with_fonte(DepSource::Path {
9022 caminho: "../caixa-teia".into(),
9023 });
9024 d.validate().unwrap();
9025 }
9026
9027 #[test]
9028 fn validate_accepts_path_fonte_with_deeply_nested_relative_caminho() {
9029 // A multi-segment relative `:caminho`
9030 // (`"vendor/forks/caixa-teia"`) remains accepted — the
9031 // absolute-path gate brackets the host-layout-leaking shape
9032 // at the leading-`/` boundary only; every relative shape past
9033 // the empty arm continues to pass. Pinned alongside the
9034 // `..`-traversal positive control so a future tightening
9035 // surfaces the full set of legitimate relative forms here
9036 // rather than at a downstream consumer.
9037 let d = dep_with_fonte(DepSource::Path {
9038 caminho: "vendor/forks/caixa-teia".into(),
9039 });
9040 d.validate().unwrap();
9041 }
9042
9043 #[test]
9044 fn validate_rejects_path_fonte_with_tilde_prefix_caminho() {
9045 // The fail-before-pass-after pin for the tilde-expansion
9046 // `:caminho` shape: `(:tipo path :caminho "~/work/caixa-teia")`.
9047 // Until this gate landed the b94fd83 absolute arm let `~/foo`
9048 // through (`Path::is_absolute` returns false on a leading `~`
9049 // — the tilde is a shell-expansion convention, not a POSIX
9050 // path component), so the lacre embedded the value verbatim
9051 // and the resolver folded it through `Path::join` without
9052 // expansion, looking for a literal `./~/work/caixa-teia`
9053 // subdirectory and failing at resolve time with a
9054 // `No such file or directory` error far from the source
9055 // caixa.lisp. The new gate moves the check to validate time
9056 // and names the offending dep + caminho verbatim.
9057 let d = dep_with_fonte(DepSource::Path {
9058 caminho: "~/work/caixa-teia".into(),
9059 });
9060 let err = d.validate().unwrap_err();
9061 let DepError::FonteCaminhoTildeExpansion { nome, caminho } = err else {
9062 panic!("expected FonteCaminhoTildeExpansion, got {err:?}");
9063 };
9064 assert_eq!(nome, "caixa-teia");
9065 assert_eq!(caminho, "~/work/caixa-teia");
9066 }
9067
9068 #[test]
9069 fn validate_rejects_path_fonte_with_bare_tilde_caminho() {
9070 // The bare `~` form (canonical "I meant `$HOME` and forgot
9071 // the rest"): both the leading-tilde arm catches it and the
9072 // canonical-user-tilde shell idiom (`~alice/dev/caixa-teia`)
9073 // sweeps through the same arm. Pinned both to ensure the
9074 // gate doesn't narrow to `~/` only.
9075 for s in ["~", "~alice/dev/caixa-teia", "~/", "~root/work"] {
9076 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9077 let err = d.validate().unwrap_err();
9078 assert!(
9079 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9080 "{s:?} → {err:?}",
9081 );
9082 }
9083 }
9084
9085 #[test]
9086 fn validate_accepts_path_fonte_with_mid_path_tilde_caminho() {
9087 // The leading-`~` is the canonical shell-expansion footgun —
9088 // a tilde mid-path (`"../foo~bar/caixa-teia"` — the canonical
9089 // backup-file-suffix idiom) is a legitimate POSIX path byte
9090 // with no shell-expansion semantic at the leading position.
9091 // Pinned so the gate doesn't widen to a full no-tilde-anywhere
9092 // sweep that would break every legitimate-shape backup-file
9093 // path.
9094 let d = dep_with_fonte(DepSource::Path {
9095 caminho: "../foo~bar/caixa-teia".into(),
9096 });
9097 d.validate().unwrap();
9098 }
9099
9100 #[test]
9101 fn fonte_caminho_empty_fires_before_tilde_expansion() {
9102 // Cascade pin: the empty arm structurally precedes the
9103 // tilde arm (the bytes `""` and `"~"` don't overlap), but the
9104 // pin establishes the precedence at the diagnostic-shape
9105 // level should a future codec round-trip ever produce a
9106 // probe-as-both value. Mirrors the peer
9107 // `fonte_repo_empty_fires_before_pin_missing` cascade
9108 // discipline.
9109 let d = dep_with_fonte(DepSource::Path {
9110 caminho: String::new(),
9111 });
9112 let err = d.validate().unwrap_err();
9113 assert!(
9114 matches!(err, DepError::FonteCaminhoEmpty { .. }),
9115 "got {err:?}",
9116 );
9117 }
9118
9119 #[test]
9120 fn fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho() {
9121 // Diagnostic-shape pin (peer with
9122 // `validate_rejects_path_fonte_with_absolute_caminho`'s
9123 // payload assertion): the error's Display surfaces both the
9124 // offending `:nome` and the offending `:caminho` verbatim
9125 // so a `feira lint` run can render the diagnostic without
9126 // re-parsing.
9127 let d = dep_with_fonte(DepSource::Path {
9128 caminho: "~alice/dev/caixa-teia".into(),
9129 });
9130 let rendered = d.validate().unwrap_err().to_string();
9131 assert!(
9132 rendered.contains("caixa-teia"),
9133 "diagnostic must name the offending dep: {rendered}",
9134 );
9135 assert!(
9136 rendered.contains("~alice/dev/caixa-teia"),
9137 "diagnostic must quote the offending caminho: {rendered}",
9138 );
9139 assert!(
9140 rendered.contains('~'),
9141 "diagnostic must reference the tilde footgun: {rendered}",
9142 );
9143 }
9144
9145 #[test]
9146 fn validate_rejects_path_fonte_with_dollar_prefix_caminho() {
9147 // The fail-before-pass-after pin for the shell-variable-
9148 // expansion `:caminho` shape: `(:tipo path :caminho
9149 // "$HOME/work/caixa-teia")`. Until this gate landed the
9150 // b94fd83 absolute arm + the a5c248e tilde arm both let
9151 // `$HOME/foo` through (`Path::is_absolute` returns false on
9152 // a leading `$` — the `$` is a shell convention, not a POSIX
9153 // path component; `starts_with('~')` returns false too), so
9154 // the lacre embedded the value verbatim and the resolver
9155 // folded it through `Path::join` without `$`-expansion,
9156 // looking for a literal `./$HOME/work/caixa-teia`
9157 // subdirectory and failing at resolve time with a
9158 // `No such file or directory` error far from the source
9159 // caixa.lisp. The new gate moves the check to validate time
9160 // and names the offending dep + caminho verbatim.
9161 let d = dep_with_fonte(DepSource::Path {
9162 caminho: "$HOME/work/caixa-teia".into(),
9163 });
9164 let err = d.validate().unwrap_err();
9165 let DepError::FonteCaminhoVarExpansion { nome, caminho } = err else {
9166 panic!("expected FonteCaminhoVarExpansion, got {err:?}");
9167 };
9168 assert_eq!(nome, "caixa-teia");
9169 assert_eq!(caminho, "$HOME/work/caixa-teia");
9170 }
9171
9172 #[test]
9173 fn validate_rejects_path_fonte_with_dollar_brace_prefix_caminho() {
9174 // Sweep over every leading-`$` shape: the `${VAR}`-braced
9175 // form (canonical "paste-from-CI-manifest" footgun every
9176 // GitHub Actions / GitLab CI / Drone manifest carries on
9177 // `${WORKSPACE}`), the XDG idiom (`$XDG_CONFIG_HOME/caixa`,
9178 // canonical "I'm referencing a per-user config dir"),
9179 // and the bare `$` (canonical "I meant `$HOME` and forgot
9180 // the rest"). All shapes route through the same gate's
9181 // byte check. Pinned so the gate doesn't narrow to a
9182 // single shape (e.g. `$HOME/` only).
9183 for s in [
9184 "${HOME}/work/caixa-teia",
9185 "${WORKSPACE}/caixa-teia",
9186 "$XDG_CONFIG_HOME/caixa",
9187 "$",
9188 ] {
9189 let d = dep_with_fonte(DepSource::Path { caminho: s.into() });
9190 let err = d.validate().unwrap_err();
9191 assert!(
9192 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9193 "{s:?} → {err:?}",
9194 );
9195 }
9196 }
9197
9198 #[test]
9199 fn validate_rejects_path_fonte_with_mid_path_dollar_caminho() {
9200 // The `$` byte is the canonical shell-variable-expansion /
9201 // command-substitution / arithmetic-expansion sentinel and
9202 // is rejected at *every* position on the `:caminho` axis: the
9203 // leading arm surfaces `FonteCaminhoVarExpansion`, the
9204 // embedded arm surfaces `FonteCaminhoShellVariableExpansion`
9205 // (6620f39). Pinned so a future arm doesn't narrow the gate
9206 // back to the leading position and re-open the paste-from-
9207 // shell-one-liner `"../foo$HOME/bar"` / paste-from-CI-
9208 // manifest `"../foo${WORKSPACE}/bar"` / paste-from-shell-
9209 // prompt `"../foo$(whoami)/bar"` cross-idiom-leak surface on
9210 // the lacre content-address (`path:{caminho}`,
9211 // caixa-resolver/src/resolve.rs:189).
9212 let d = dep_with_fonte(DepSource::Path {
9213 caminho: "../foo$bar/caixa-teia".into(),
9214 });
9215 let err = d.validate().unwrap_err();
9216 assert!(
9217 matches!(
9218 err,
9219 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
9220 ),
9221 "got {err:?}",
9222 );
9223 }
9224
9225 #[test]
9226 fn fonte_caminho_tilde_fires_before_var_expansion() {
9227 // Cascade pin: the tilde arm structurally precedes the var
9228 // arm (the bytes `~` and `$` don't overlap at the leading
9229 // position), but the pin establishes the precedence at the
9230 // diagnostic-shape level should a future codec round-trip
9231 // ever produce a probe-as-both value. Mirrors the peer
9232 // `fonte_caminho_empty_fires_before_tilde_expansion` cascade
9233 // discipline on the immediate-predecessor arm.
9234 let d = dep_with_fonte(DepSource::Path {
9235 caminho: "~/work/caixa-teia".into(),
9236 });
9237 let err = d.validate().unwrap_err();
9238 assert!(
9239 matches!(err, DepError::FonteCaminhoTildeExpansion { .. }),
9240 "got {err:?}",
9241 );
9242 }
9243
9244 #[test]
9245 fn fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho() {
9246 // Diagnostic-shape pin (peer with
9247 // `fonte_caminho_tilde_diagnostic_carries_offending_dep_and_caminho`'s
9248 // payload assertion on the immediate-predecessor arm): the
9249 // error's Display surfaces both the offending `:nome` and
9250 // the offending `:caminho` verbatim plus the `$` footgun
9251 // character itself so a `feira lint` run can render the
9252 // diagnostic without re-parsing.
9253 let d = dep_with_fonte(DepSource::Path {
9254 caminho: "${WORKSPACE}/caixa-teia".into(),
9255 });
9256 let rendered = d.validate().unwrap_err().to_string();
9257 assert!(
9258 rendered.contains("caixa-teia"),
9259 "diagnostic must name the offending dep: {rendered}",
9260 );
9261 assert!(
9262 rendered.contains("${WORKSPACE}/caixa-teia"),
9263 "diagnostic must quote the offending caminho: {rendered}",
9264 );
9265 assert!(
9266 rendered.contains('$'),
9267 "diagnostic must reference the dollar footgun: {rendered}",
9268 );
9269 }
9270
9271 #[test]
9272 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_nul() {
9273 // The fail-before-pass-after pin for the load-bearing NUL byte:
9274 // POSIX paths cannot contain `0x00` (every `std::fs` syscall
9275 // routes the path through `CString::new` which fails with
9276 // `NulError`); until this gate landed a `:caminho
9277 // "../caixa\0teia"` silently passed validate, the lacre
9278 // pipeline embedded the value verbatim, and the failure
9279 // surfaced at the resolver's `Path::join` → `CString::new`
9280 // boundary with a non-self-locating `NulError` far from the
9281 // source caixa.lisp. The new gate moves the check to validate
9282 // time and names the offending dep + caminho + offending byte
9283 // verbatim.
9284 let d = dep_with_fonte(DepSource::Path {
9285 caminho: "../caixa\0teia".into(),
9286 });
9287 let err = d.validate().unwrap_err();
9288 let DepError::FonteCaminhoControlChar {
9289 nome,
9290 caminho,
9291 byte,
9292 } = err
9293 else {
9294 panic!("expected FonteCaminhoControlChar, got {err:?}");
9295 };
9296 assert_eq!(nome, "caixa-teia");
9297 assert_eq!(caminho, "../caixa\0teia");
9298 assert_eq!(byte, 0x00);
9299 }
9300
9301 #[test]
9302 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_newline() {
9303 // The canonical paste-from-multiline-doc footgun on `:caminho`
9304 // — author copies `"../caixa-teia\n"` (trailing newline) out
9305 // of a multi-line code-fence or, worse, a `:caminho
9306 // "../caixa-teia\nrm -rf /"` value (CRLF-at-subprocess-argument
9307 // injection sibling on the path axis the `is_git_repo_url`
9308 // control-char arm already closes on `:repo`). Pinned
9309 // separately from the NUL arm so a future relaxation that
9310 // catches one but not the other surfaces here.
9311 let d = dep_with_fonte(DepSource::Path {
9312 caminho: "../caixa-teia\n".into(),
9313 });
9314 let err = d.validate().unwrap_err();
9315 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9316 panic!("expected FonteCaminhoControlChar, got {err:?}");
9317 };
9318 assert_eq!(byte, 0x0A);
9319 }
9320
9321 #[test]
9322 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_carriage_return() {
9323 // The CRLF sibling of the LF arm — Windows-line-ending
9324 // paste-from-multiline-doc on a `\r\n`-terminated buffer
9325 // leaves a stray `\r` mid-string after the LF strip. Pinned
9326 // separately from the LF arm so a future relaxation that
9327 // only catches LF surfaces here.
9328 let d = dep_with_fonte(DepSource::Path {
9329 caminho: "../caixa-teia\r".into(),
9330 });
9331 let err = d.validate().unwrap_err();
9332 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9333 panic!("expected FonteCaminhoControlChar, got {err:?}");
9334 };
9335 assert_eq!(byte, 0x0D);
9336 }
9337
9338 #[test]
9339 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_tab() {
9340 // The canonical paste-from-aligned-table footgun — a `\t`
9341 // mid-`:caminho` is invisible in most editors but rides
9342 // through the lacre's content-address verbatim, so two
9343 // paste-from-distinct-tables (one editor strips tabs, one
9344 // preserves them) yield divergent lacres for the byte-
9345 // identical-looking caixa. Pinned separately from the
9346 // whitespace-shaped LF/CR arms so a future relaxation that
9347 // narrows to line-terminator-only surfaces here.
9348 let d = dep_with_fonte(DepSource::Path {
9349 caminho: "../caixa\tteia".into(),
9350 });
9351 let err = d.validate().unwrap_err();
9352 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9353 panic!("expected FonteCaminhoControlChar, got {err:?}");
9354 };
9355 assert_eq!(byte, 0x09);
9356 }
9357
9358 #[test]
9359 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_del() {
9360 // The DEL byte (`0x7F`) closes the upper-end paste-from-
9361 // binary-blob footgun — the gate's contract is `b < 0x20 ||
9362 // b == 0x7F`, matching the `is_git_repo_url` /
9363 // `is_git_ref_name` predicates' control-char arms. Pinned
9364 // separately from the lower-range arms so a future narrowing
9365 // to `< 0x20` only surfaces here.
9366 let d = dep_with_fonte(DepSource::Path {
9367 caminho: "../caixa\x7fteia".into(),
9368 });
9369 let err = d.validate().unwrap_err();
9370 let DepError::FonteCaminhoControlChar { byte, .. } = err else {
9371 panic!("expected FonteCaminhoControlChar, got {err:?}");
9372 };
9373 assert_eq!(byte, 0x7F);
9374 }
9375
9376 #[test]
9377 fn validate_accepts_path_fonte_with_caminho_carrying_high_bit_utf8() {
9378 // The control-byte arm targets `0x00..=0x1F` + `0x7F` only —
9379 // high-bit / non-ASCII UTF-8 bytes are not gated. POSIX paths
9380 // are opaque byte sequences and UTF-8 multi-byte sequences
9381 // are a legitimate filename shape (the `café-teia/foo` idiom).
9382 // Pinned so the gate doesn't widen to a full ASCII-only sweep
9383 // that would break every legitimate-shape UTF-8 path.
9384 let d = dep_with_fonte(DepSource::Path {
9385 caminho: "../café-teia/foo".into(),
9386 });
9387 d.validate().unwrap();
9388 }
9389
9390 #[test]
9391 fn fonte_caminho_var_fires_before_control_char() {
9392 // Cascade pin: the var-expansion arm structurally precedes the
9393 // control-char arm. A value like `"$\n"` probes positive on
9394 // both arms (`starts_with('$')` and contains LF), but the
9395 // narrower leading-byte diagnostic (`FonteCaminhoVarExpansion`)
9396 // wins so the author sees the more self-locating shell-
9397 // expansion arm first. Mirrors the
9398 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9399 // discipline on the immediate-predecessor arm.
9400 let d = dep_with_fonte(DepSource::Path {
9401 caminho: "$HOME\n".into(),
9402 });
9403 let err = d.validate().unwrap_err();
9404 assert!(
9405 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9406 "got {err:?}",
9407 );
9408 }
9409
9410 #[test]
9411 fn validate_rejects_path_fonte_with_leading_space_caminho() {
9412 // The fail-before-pass-after pin for the leading ASCII space
9413 // `:caminho` shape: `(:tipo path :caminho " ../caixa-teia")`.
9414 // Until this gate landed the b94fd83 absolute arm + the a5c248e
9415 // tilde arm + the f4efe9c var arm + the d624c8d control-byte arm
9416 // all let `" ../caixa-teia"` through: `Path::is_absolute` returns
9417 // false on a leading space (the leading byte is `0x20`, not `0x2F`),
9418 // `starts_with('~')` / `starts_with('$')` return false, and `0x20`
9419 // is not in the `0x00..=0x1F` plus `0x7F` control-byte set (the
9420 // four ASCII whitespace bytes `0x09` tab, `0x0A` LF, `0x0D` CR
9421 // are caught, but the most common whitespace `0x20` space is
9422 // not). The lacre embedded the value verbatim and the resolver
9423 // folded it through `Path::join` looking for a literal `./ ../
9424 // caixa-teia` subdirectory and failing at resolve time with a
9425 // non-self-locating `No such file or directory` error far from
9426 // the source caixa.lisp. The new gate moves the check to
9427 // validate time and names the offending dep + caminho verbatim.
9428 let d = dep_with_fonte(DepSource::Path {
9429 caminho: " ../caixa-teia".into(),
9430 });
9431 let err = d.validate().unwrap_err();
9432 let DepError::FonteCaminhoLeadingWhitespace { nome, caminho } = err else {
9433 panic!("expected FonteCaminhoLeadingWhitespace, got {err:?}");
9434 };
9435 assert_eq!(nome, "caixa-teia");
9436 assert_eq!(caminho, " ../caixa-teia");
9437 }
9438
9439 #[test]
9440 fn validate_rejects_path_fonte_with_multiple_leading_spaces_caminho() {
9441 // The aligned-doc paste footgun sweep: more than one leading
9442 // space (`" ../caixa-teia"` — the canonical "I selected the
9443 // aligned column from a four-`:fonte`-entry `:deps` block"
9444 // paste) routes through the same gate's `starts_with(' ')`
9445 // byte check. Pinned so the gate doesn't narrow to a
9446 // single-space prefix.
9447 let d = dep_with_fonte(DepSource::Path {
9448 caminho: " ../caixa-teia".into(),
9449 });
9450 let err = d.validate().unwrap_err();
9451 assert!(
9452 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9453 "got {err:?}",
9454 );
9455 }
9456
9457 #[test]
9458 fn validate_accepts_path_fonte_with_mid_path_space_caminho() {
9459 // The leading-space is the canonical paste-from-aligned-doc
9460 // footgun — a space mid-path (`"../my dir/caixa-teia"` — the
9461 // canonical "I have a directory with a space in its name"
9462 // idiom; ASCII `0x20` is a valid POSIX filename byte) is a
9463 // legitimate path with no whitespace-leak semantic at the
9464 // non-leading position. Pinned so the gate doesn't widen to a
9465 // full no-space-anywhere sweep that would break every
9466 // legitimate-shape space-in-filename path.
9467 let d = dep_with_fonte(DepSource::Path {
9468 caminho: "../my dir/caixa-teia".into(),
9469 });
9470 d.validate().unwrap();
9471 }
9472
9473 #[test]
9474 fn fonte_caminho_var_fires_before_leading_whitespace() {
9475 // Cascade pin: the var-expansion arm structurally precedes the
9476 // leading-whitespace arm. A value like `"$ "` would probe positive
9477 // on var (`starts_with('$')`) but the leading-byte arms walk
9478 // left-to-right so the var arm fires on the leading `$` before
9479 // the leading-whitespace arm probes. Mirrors the
9480 // `fonte_caminho_tilde_fires_before_var_expansion` cascade
9481 // discipline on the immediate-predecessor arms.
9482 let d = dep_with_fonte(DepSource::Path {
9483 caminho: "$VAR".into(),
9484 });
9485 let err = d.validate().unwrap_err();
9486 assert!(
9487 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9488 "got {err:?}",
9489 );
9490 }
9491
9492 #[test]
9493 fn fonte_caminho_leading_whitespace_fires_before_control_char() {
9494 // Cascade pin: the leading-whitespace arm structurally precedes
9495 // the control-char arm. A value like `" ../foo\n"` probes
9496 // positive on both (starts with space AND contains LF), but
9497 // the narrower leading-byte diagnostic
9498 // (`FonteCaminhoLeadingWhitespace`) wins so the author sees the
9499 // more self-locating paste-from-aligned-doc arm first. Mirrors
9500 // the `fonte_caminho_var_fires_before_control_char` cascade
9501 // discipline on the immediate-predecessor arm.
9502 let d = dep_with_fonte(DepSource::Path {
9503 caminho: " ../foo\n".into(),
9504 });
9505 let err = d.validate().unwrap_err();
9506 assert!(
9507 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9508 "got {err:?}",
9509 );
9510 }
9511
9512 #[test]
9513 fn fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho() {
9514 // Diagnostic-shape pin (peer with
9515 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9516 // payload assertion on the immediate-predecessor arm): the
9517 // error's Display surfaces both the offending `:nome` and the
9518 // offending `:caminho` verbatim, so a `feira lint` run can
9519 // render the diagnostic without re-parsing and the author can
9520 // grep their caixa.lisp for `:caminho "<value>"` and fix it in
9521 // one edit.
9522 let d = dep_with_fonte(DepSource::Path {
9523 caminho: " ../caixa-teia".into(),
9524 });
9525 let rendered = d.validate().unwrap_err().to_string();
9526 assert!(
9527 rendered.contains("caixa-teia"),
9528 "diagnostic must name the offending dep: {rendered}",
9529 );
9530 assert!(
9531 rendered.contains(" ../caixa-teia"),
9532 "diagnostic must quote the offending caminho: {rendered}",
9533 );
9534 assert!(
9535 rendered.contains("space"),
9536 "diagnostic must name the space footgun: {rendered}",
9537 );
9538 }
9539
9540 #[test]
9541 fn fonte_caminho_absolute_fires_before_control_char() {
9542 // Cascade pin on the sibling leading-byte arm: a leading `/`
9543 // value with embedded control byte (`"/etc/passwd\n"`) routes
9544 // through `FonteCaminhoAbsolute` not `FonteCaminhoControlChar`
9545 // — the host-layout-leak diagnostic is the load-bearing axis,
9546 // the control byte is the secondary observation. Same precedence
9547 // logic on every prior leading-byte arm.
9548 let d = dep_with_fonte(DepSource::Path {
9549 caminho: "/etc/passwd\n".into(),
9550 });
9551 let err = d.validate().unwrap_err();
9552 assert!(
9553 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9554 "got {err:?}",
9555 );
9556 }
9557
9558 #[test]
9559 fn validate_rejects_path_fonte_with_leading_hyphen_caminho() {
9560 // The fail-before-pass-after pin for the leading-`-` CLI-arg-
9561 // injection `:caminho` shape sweep. Until this gate landed
9562 // every prior leading-byte arm passed a leading-`-` value
9563 // through: `Path::is_absolute` returns false on `-` (the
9564 // leading byte is `0x2D`, not `0x2F`), `starts_with('~')` /
9565 // `starts_with('$')` / `starts_with(' ')` all return false,
9566 // and `0x2D` sits outside the control-byte set. The lacre
9567 // embedded the value verbatim and the resolver folded it
9568 // through `Path::join` looking for a literal `./-rf` /
9569 // `./-C` / `./--upload-pack=…` subdirectory; the failure at
9570 // `Path::join` time is non-self-locating but harmless, while
9571 // the failure at every downstream `git -C {caminho}` /
9572 // `terraform -chdir={caminho}` / `find {caminho}` shell-out
9573 // is arbitrary-CLI-arg-injection because none of those
9574 // porcelains carry a `--` argument-list terminator between
9575 // the flag block and the path argument. The new arm moves the
9576 // rejection to `Caixa::from_lisp` boundary time and names
9577 // the offending dep + caminho verbatim.
9578 //
9579 // Sweep spans the canonical CLI-arg-injection shapes matching
9580 // the peer sweep on the sibling `is_git_ref_name` /
9581 // `is_git_repo_url` axes: short-flag `-rf` (the `rm -rf` /
9582 // `find -rf` reinterpretation vector), `-C` (the `git -C`
9583 // change-directory-config-injection paste), long-flag
9584 // `--upload-pack=cat /etc/passwd` (the canonical
9585 // arbitrary-command-execution vector on every git porcelain
9586 // entry point), git-config-injection `--config=core.merge=ours`,
9587 // and the degenerate single-byte `-` value.
9588 for caminho in [
9589 "-rf",
9590 "-C",
9591 "--upload-pack=cat /etc/passwd",
9592 "--config=core.merge=ours",
9593 "-",
9594 ] {
9595 let d = dep_with_fonte(DepSource::Path {
9596 caminho: caminho.into(),
9597 });
9598 let err = d.validate().unwrap_err();
9599 let DepError::FonteCaminhoLeadingHyphen { nome, caminho: got } = err else {
9600 panic!("expected FonteCaminhoLeadingHyphen for {caminho:?}, got {err:?}");
9601 };
9602 assert_eq!(nome, "caixa-teia");
9603 assert_eq!(got, caminho);
9604 }
9605 }
9606
9607 #[test]
9608 fn validate_accepts_path_fonte_with_mid_path_hyphen_caminho() {
9609 // The leading-`-` is the canonical CLI-arg-injection footgun
9610 // — a `-` anywhere else in the path (`"../caixa-teia"` — the
9611 // canonical kebab-separator-between-alphanumeric-segments
9612 // shape every DNS-1123-shaped caixa name carries; `"../-hidden"`
9613 // — a mid-path segment starting with `-`, still a legitimate
9614 // POSIX filename byte at that non-leading position because the
9615 // subprocess reads the whole `{caminho}` value as one positional
9616 // argument, so only the very first byte of the composite path
9617 // string is at the CLI-arg-injection boundary) is a legitimate
9618 // path with no CLI-flag-reinterpretation semantic at the non-
9619 // leading position of the top-level value. Pinned so the gate
9620 // doesn't widen to a full no-`-`-anywhere sweep that would
9621 // break every legitimate-shape kebab-in-filename path (i.e.
9622 // essentially every sibling-workspace caixa dep).
9623 for caminho in [
9624 "../caixa-teia",
9625 "../caixa-teia/-hidden",
9626 "./my-lib",
9627 "../foo-bar/baz",
9628 ] {
9629 let d = dep_with_fonte(DepSource::Path {
9630 caminho: caminho.into(),
9631 });
9632 d.validate()
9633 .unwrap_or_else(|e| panic!("mid-path `-` caminho {caminho:?} must pass: {e:?}"));
9634 }
9635 }
9636
9637 #[test]
9638 fn fonte_caminho_leading_whitespace_fires_before_leading_hyphen() {
9639 // Cascade pin: the leading-whitespace arm structurally precedes
9640 // the leading-hyphen arm. A value like `" -rf"` probes positive
9641 // on both (leading space AND, one byte in, a `-` — though the
9642 // leading-hyphen arm probes only the very first byte so it
9643 // wouldn't fire on this value; the pin instead documents the
9644 // arm order on the more common "leading space then a hyphen"
9645 // paste-from-aligned-doc paste-flag-shell-one-liner idiom).
9646 // The narrower leading-space diagnostic (the paste-from-aligned-
9647 // doc footgun) wins so the author sees the more self-locating
9648 // whitespace arm first. Mirrors the
9649 // `fonte_caminho_var_fires_before_leading_whitespace` cascade
9650 // discipline on the immediate-predecessor arm.
9651 let d = dep_with_fonte(DepSource::Path {
9652 caminho: " -rf".into(),
9653 });
9654 let err = d.validate().unwrap_err();
9655 assert!(
9656 matches!(err, DepError::FonteCaminhoLeadingWhitespace { .. }),
9657 "got {err:?}",
9658 );
9659 }
9660
9661 #[test]
9662 fn fonte_caminho_leading_hyphen_fires_before_control_char() {
9663 // Cascade pin: the leading-hyphen arm structurally precedes
9664 // the control-char arm. A value like `"-rf\n"` probes positive
9665 // on both (starts with `-` AND contains LF), but the narrower
9666 // leading-byte diagnostic (`FonteCaminhoLeadingHyphen`) wins so
9667 // the author sees the more self-locating CLI-arg-injection arm
9668 // first. Mirrors the
9669 // `fonte_caminho_leading_whitespace_fires_before_control_char`
9670 // cascade discipline on the immediate-predecessor arm.
9671 let d = dep_with_fonte(DepSource::Path {
9672 caminho: "-rf\n".into(),
9673 });
9674 let err = d.validate().unwrap_err();
9675 assert!(
9676 matches!(err, DepError::FonteCaminhoLeadingHyphen { .. }),
9677 "got {err:?}",
9678 );
9679 }
9680
9681 #[test]
9682 fn fonte_caminho_leading_hyphen_diagnostic_carries_offending_dep_and_caminho() {
9683 // Diagnostic-shape pin (peer with
9684 // `fonte_caminho_leading_whitespace_diagnostic_carries_offending_dep_and_caminho`'s
9685 // payload assertion on the immediate-predecessor arm): the
9686 // error's Display surfaces both the offending `:nome` and the
9687 // offending `:caminho` verbatim plus the CLI-argument-injection
9688 // vocabulary, so a `feira lint` run can render the diagnostic
9689 // without re-parsing and the author can grep their caixa.lisp
9690 // for `:caminho "<value>"` and fix it in one edit.
9691 let d = dep_with_fonte(DepSource::Path {
9692 caminho: "--upload-pack=cat /etc/passwd".into(),
9693 });
9694 let rendered = d.validate().unwrap_err().to_string();
9695 assert!(
9696 rendered.contains("caixa-teia"),
9697 "diagnostic must name the offending dep: {rendered}",
9698 );
9699 assert!(
9700 rendered.contains("--upload-pack=cat /etc/passwd"),
9701 "diagnostic must quote the offending caminho: {rendered}",
9702 );
9703 assert!(
9704 rendered.contains("CLI-argument-injection"),
9705 "diagnostic must name the CLI-argument-injection vector: {rendered}",
9706 );
9707 assert!(
9708 rendered.contains("`-`"),
9709 "diagnostic must name the offending byte: {rendered}",
9710 );
9711 }
9712
9713 #[test]
9714 fn fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte() {
9715 // Diagnostic-shape pin (peer with
9716 // `fonte_caminho_var_diagnostic_carries_offending_dep_and_caminho`'s
9717 // payload assertion on the immediate-predecessor arm): the
9718 // error's Display surfaces the offending `:nome`, the
9719 // offending `:caminho` verbatim, and the offending byte in
9720 // hex form (`0x09` for tab) so a `feira lint` run can render
9721 // the diagnostic without re-parsing.
9722 let d = dep_with_fonte(DepSource::Path {
9723 caminho: "../caixa\tteia".into(),
9724 });
9725 let rendered = d.validate().unwrap_err().to_string();
9726 assert!(
9727 rendered.contains("caixa-teia"),
9728 "diagnostic must name the offending dep: {rendered}",
9729 );
9730 assert!(
9731 rendered.contains("../caixa\tteia"),
9732 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9733 );
9734 assert!(
9735 rendered.contains("0x09"),
9736 "diagnostic must name the offending byte in hex: {rendered:?}",
9737 );
9738 }
9739
9740 #[test]
9741 fn validate_rejects_path_fonte_with_caminho_carrying_backslash() {
9742 // The fail-before-pass-after pin for the canonical Windows-
9743 // path-separator paste footgun: an author who pastes a path
9744 // from Windows-Explorer's `Copy as path`, PowerShell's
9745 // `Get-Location`, or any CMD/Cygwin/MSYS shell prompt
9746 // produces `..\caixa-teia`-shape values that silently passed
9747 // every prior arm (`Path::is_absolute("..\\caixa-teia")` is
9748 // false; `\` is neither a leading-byte sentinel nor a
9749 // control byte). On POSIX resolvers the value rides through
9750 // `Path::join` as a literal directory name and fails at
9751 // resolve time with `No such file or directory`; on Windows
9752 // resolvers the value resolves to the parent's sibling — two
9753 // distinct directories for the byte-identical caixa.lisp.
9754 // The new arm moves the rejection to validate time and names
9755 // the offending dep + caminho verbatim.
9756 let d = dep_with_fonte(DepSource::Path {
9757 caminho: "..\\caixa-teia".into(),
9758 });
9759 let err = d.validate().unwrap_err();
9760 let DepError::FonteCaminhoBackslash { nome, caminho } = err else {
9761 panic!("expected FonteCaminhoBackslash, got {err:?}");
9762 };
9763 assert_eq!(nome, "caixa-teia");
9764 assert_eq!(caminho, "..\\caixa-teia");
9765 }
9766
9767 #[test]
9768 fn validate_rejects_path_fonte_with_caminho_carrying_windows_drive_letter() {
9769 // The Windows drive-letter paste shape (`C:\work\caixa-teia`
9770 // out of Explorer / `cd`-and-`pwd`-on-Windows). On POSIX
9771 // hosts `Path::is_absolute("C:\\work\\caixa-teia")` returns
9772 // false (POSIX absolute paths start with `/`, drive letters
9773 // are not a POSIX concept), so the b94fd83 absolute arm
9774 // doesn't fire; the value contains `\` bytes that this arm
9775 // now catches with the more self-locating Windows-path-
9776 // separator diagnostic. Pinned separately from the bare
9777 // `..\caixa-teia` shape so a future arm that targets only
9778 // leading-`..\` doesn't regress the drive-letter coverage.
9779 let d = dep_with_fonte(DepSource::Path {
9780 caminho: "C:\\work\\caixa-teia".into(),
9781 });
9782 let err = d.validate().unwrap_err();
9783 assert!(
9784 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9785 "got {err:?}",
9786 );
9787 }
9788
9789 #[test]
9790 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backslash() {
9791 // The trailing-`\` shape (`..\caixa-teia\` — the canonical
9792 // PowerShell tab-completion-on-a-directory append). Pinned
9793 // separately from the embedded-`\` shape so the gate's
9794 // contract is "any `\` anywhere", not "any `\` not at end".
9795 let d = dep_with_fonte(DepSource::Path {
9796 caminho: "..\\caixa-teia\\".into(),
9797 });
9798 let err = d.validate().unwrap_err();
9799 assert!(
9800 matches!(err, DepError::FonteCaminhoBackslash { .. }),
9801 "got {err:?}",
9802 );
9803 }
9804
9805 #[test]
9806 fn validate_accepts_path_fonte_with_caminho_carrying_legitimate_forward_slash() {
9807 // The positive-control pin: the gate targets `\` only,
9808 // never `/`. The canonical relative POSIX path
9809 // (`../caixa-teia/foo/bar`) must continue to validate cleanly
9810 // so legitimate nested-directory deps aren't broken. Pinned
9811 // so the gate doesn't accidentally widen to a "no path
9812 // separators at all" sweep.
9813 let d = dep_with_fonte(DepSource::Path {
9814 caminho: "../caixa-teia/foo/bar".into(),
9815 });
9816 d.validate().unwrap();
9817 }
9818
9819 #[test]
9820 fn fonte_caminho_control_char_fires_before_backslash() {
9821 // Cascade pin: the control-char arm structurally precedes the
9822 // backslash arm. A value like `"..\caixa\0teia"` probes
9823 // positive on both (`\` byte + NUL byte), but the control-
9824 // char diagnostic wins so the author sees the more self-
9825 // locating POSIX-syscall-rejected-byte diagnostic first
9826 // (NUL outright breaks `CString::new` at every `std::fs`
9827 // syscall boundary; the `\` divergence is the cross-OS-
9828 // separator axis). Mirrors the
9829 // `fonte_caminho_var_fires_before_control_char` cascade
9830 // discipline on the immediate-predecessor arm.
9831 let d = dep_with_fonte(DepSource::Path {
9832 caminho: "..\\caixa\0teia".into(),
9833 });
9834 let err = d.validate().unwrap_err();
9835 assert!(
9836 matches!(err, DepError::FonteCaminhoControlChar { .. }),
9837 "got {err:?}",
9838 );
9839 }
9840
9841 #[test]
9842 fn fonte_caminho_absolute_fires_before_backslash() {
9843 // Cascade pin on the load-bearing leading-byte arm: a leading
9844 // `/` value with embedded `\` (`/etc/passwd\foo`) routes
9845 // through `FonteCaminhoAbsolute` not `FonteCaminhoBackslash`
9846 // — the host-layout-leak diagnostic is the load-bearing
9847 // axis, the `\` byte is the secondary observation. Same
9848 // precedence logic as every prior leading-byte arm.
9849 let d = dep_with_fonte(DepSource::Path {
9850 caminho: "/etc/passwd\\foo".into(),
9851 });
9852 let err = d.validate().unwrap_err();
9853 assert!(
9854 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
9855 "got {err:?}",
9856 );
9857 }
9858
9859 #[test]
9860 fn fonte_caminho_var_fires_before_backslash() {
9861 // Cascade pin on the var-expansion arm: a leading-`$` value
9862 // with embedded `\` (`$WORKSPACE\caixa-teia` — the canonical
9863 // PowerShell-env-var paste-from-CI-manifest footgun) routes
9864 // through `FonteCaminhoVarExpansion` not `FonteCaminhoBackslash`.
9865 // The shell-expansion diagnostic is the more self-locating
9866 // axis since both the leading `$` and the embedded `\`
9867 // are Windows-shell artifacts but the `$` is the root-cause
9868 // surface (an author who removes the `$` is likely to leave
9869 // the `\` too).
9870 let d = dep_with_fonte(DepSource::Path {
9871 caminho: "$WORKSPACE\\caixa-teia".into(),
9872 });
9873 let err = d.validate().unwrap_err();
9874 assert!(
9875 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
9876 "got {err:?}",
9877 );
9878 }
9879
9880 #[test]
9881 fn fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho() {
9882 // Diagnostic-shape pin (peer with the prior
9883 // `fonte_caminho_*_diagnostic_carries_*` payload assertions
9884 // on every preceding arm): the error's Display surfaces the
9885 // offending `:nome` and the offending `:caminho` verbatim
9886 // so a `feira lint` run can render the diagnostic without
9887 // re-parsing.
9888 let d = dep_with_fonte(DepSource::Path {
9889 caminho: "..\\caixa-teia".into(),
9890 });
9891 let rendered = d.validate().unwrap_err().to_string();
9892 assert!(
9893 rendered.contains("caixa-teia"),
9894 "diagnostic must name the offending dep: {rendered}",
9895 );
9896 assert!(
9897 rendered.contains("..\\caixa-teia"),
9898 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
9899 );
9900 assert!(
9901 rendered.contains('\\'),
9902 "diagnostic must reference the backslash footgun: {rendered:?}",
9903 );
9904 }
9905
9906 #[test]
9907 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_slash() {
9908 // The fail-before-pass-after pin for the canonical trailing-`/`
9909 // paste footgun: an author who shell-tab-completes a sibling
9910 // directory (every interactive shell — bash/zsh/fish/nushell —
9911 // appends `/` on tab-completing a directory) produces
9912 // `"../caixa-teia/"`-shape values that silently passed every
9913 // prior arm (the leading byte is `.`, no control bytes, no
9914 // backslash). `Path::join` resolves both shapes to the same
9915 // directory at the resolver, but the lacre embeds the value
9916 // verbatim and the BLAKE3 closures diverge across two
9917 // workstations whose authors differ only in tab-completion
9918 // habits.
9919 let d = dep_with_fonte(DepSource::Path {
9920 caminho: "../caixa-teia/".into(),
9921 });
9922 let err = d.validate().unwrap_err();
9923 let DepError::FonteCaminhoTrailingSlash { nome, caminho } = err else {
9924 panic!("expected FonteCaminhoTrailingSlash, got {err:?}");
9925 };
9926 assert_eq!(nome, "caixa-teia");
9927 assert_eq!(caminho, "../caixa-teia/");
9928 }
9929
9930 #[test]
9931 fn validate_rejects_path_fonte_with_caminho_carrying_bare_dot_slash() {
9932 // The `"./"` shape (the canonical "I meant the caixa.lisp's own
9933 // directory and tab-completed it" footgun). Pinned separately
9934 // from the canonical `"../caixa-teia/"` shape so the gate's
9935 // contract is "any trailing `/`", not "trailing `/` after a leaf
9936 // name".
9937 let d = dep_with_fonte(DepSource::Path {
9938 caminho: "./".into(),
9939 });
9940 let err = d.validate().unwrap_err();
9941 assert!(
9942 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9943 "got {err:?}",
9944 );
9945 }
9946
9947 #[test]
9948 fn validate_rejects_path_fonte_with_caminho_carrying_consecutive_trailing_slashes() {
9949 // The `"foo//"` shape (the canonical "I pasted from a CI manifest
9950 // that double-templated `${VAR}/` over an already-`/`-suffixed
9951 // path" footgun). The gate fires on the last byte being `/`
9952 // regardless of how many `/` precede it; the arm contract is
9953 // "the value ends with `/`", structurally.
9954 let d = dep_with_fonte(DepSource::Path {
9955 caminho: "../caixa-teia//".into(),
9956 });
9957 let err = d.validate().unwrap_err();
9958 assert!(
9959 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9960 "got {err:?}",
9961 );
9962 }
9963
9964 #[test]
9965 fn validate_rejects_path_fonte_with_caminho_carrying_dotdot_trailing_slash() {
9966 // The `"../"` shape (the canonical "I want the parent" tab-
9967 // completion footgun on a bare `..` path). Pinned separately so
9968 // the gate doesn't accidentally narrow to "trailing `/` only on
9969 // multi-segment paths".
9970 let d = dep_with_fonte(DepSource::Path {
9971 caminho: "../".into(),
9972 });
9973 let err = d.validate().unwrap_err();
9974 assert!(
9975 matches!(err, DepError::FonteCaminhoTrailingSlash { .. }),
9976 "got {err:?}",
9977 );
9978 }
9979
9980 #[test]
9981 fn validate_accepts_path_fonte_with_caminho_carrying_internal_slashes() {
9982 // The positive-control pin: the gate targets the trailing byte
9983 // only, never internal `/` separators. The canonical nested
9984 // relative POSIX path (`"../caixa-teia/foo/bar"`) must continue
9985 // to validate cleanly so legitimate deeply-nested deps aren't
9986 // broken. Pinned so the gate doesn't accidentally widen to a
9987 // "no `/` separators anywhere" sweep that would defeat the
9988 // entire path-fonte author surface.
9989 let d = dep_with_fonte(DepSource::Path {
9990 caminho: "../caixa-teia/foo/bar".into(),
9991 });
9992 d.validate().unwrap();
9993 }
9994
9995 #[test]
9996 fn validate_accepts_path_fonte_with_caminho_carrying_bare_dot() {
9997 // The positive-control pin on the degenerate single-`.` shape
9998 // (the canonical "the caixa.lisp's own directory" idiom). The
9999 // gate fires on the trailing byte being `/`, not on the path
10000 // being short, so `"."` (one byte, not `/`) must continue to
10001 // validate cleanly.
10002 let d = dep_with_fonte(DepSource::Path {
10003 caminho: ".".into(),
10004 });
10005 d.validate().unwrap();
10006 }
10007
10008 #[test]
10009 fn fonte_caminho_control_char_fires_before_trailing_slash() {
10010 // Cascade pin: the control-char arm structurally precedes the
10011 // trailing-slash arm. A value like `"../foo\n/"` ends in `/`
10012 // but the embedded LF (`0x0A`) is the load-bearing diagnostic
10013 // (control bytes are the paste-from-multiline-doc footgun the
10014 // d624c8d arm already closes). Mirrors the
10015 // `fonte_caminho_control_char_fires_before_backslash` cascade
10016 // discipline on the immediate-predecessor arm.
10017 let d = dep_with_fonte(DepSource::Path {
10018 caminho: "../foo\n/".into(),
10019 });
10020 let err = d.validate().unwrap_err();
10021 assert!(
10022 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10023 "got {err:?}",
10024 );
10025 }
10026
10027 #[test]
10028 fn fonte_caminho_backslash_fires_before_trailing_slash() {
10029 // Cascade pin on the backslash arm: a value like `"..\foo/"`
10030 // ends in `/` but the embedded `\` is the load-bearing
10031 // diagnostic (the cross-host-OS-separator divergence vector
10032 // the 3a4e1d7 arm closes). Same precedence logic as the prior
10033 // narrower-diagnostic-first cascade.
10034 let d = dep_with_fonte(DepSource::Path {
10035 caminho: "..\\caixa-teia/".into(),
10036 });
10037 let err = d.validate().unwrap_err();
10038 assert!(
10039 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10040 "got {err:?}",
10041 );
10042 }
10043
10044 #[test]
10045 fn fonte_caminho_absolute_fires_before_trailing_slash() {
10046 // Cascade pin on the load-bearing leading-byte arm: a leading
10047 // `/` value with a trailing `/` (`"/etc/passwd/"`) routes
10048 // through `FonteCaminhoAbsolute` not `FonteCaminhoTrailingSlash`
10049 // — the host-layout-leak diagnostic is the load-bearing axis,
10050 // the trailing `/` is the secondary observation. Same
10051 // precedence logic as every prior leading-byte arm.
10052 let d = dep_with_fonte(DepSource::Path {
10053 caminho: "/etc/passwd/".into(),
10054 });
10055 let err = d.validate().unwrap_err();
10056 assert!(
10057 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10058 "got {err:?}",
10059 );
10060 }
10061
10062 #[test]
10063 fn fonte_caminho_trailing_slash_diagnostic_carries_offending_dep_and_caminho() {
10064 // Diagnostic-shape pin (peer with the prior
10065 // `fonte_caminho_*_diagnostic_carries_*` payload assertions on
10066 // every preceding arm): the error's Display surfaces the
10067 // offending `:nome` and the offending `:caminho` verbatim so a
10068 // `feira lint` run can render the diagnostic without re-parsing.
10069 let d = dep_with_fonte(DepSource::Path {
10070 caminho: "../caixa-teia/".into(),
10071 });
10072 let rendered = d.validate().unwrap_err().to_string();
10073 assert!(
10074 rendered.contains("caixa-teia"),
10075 "diagnostic must name the offending dep: {rendered}",
10076 );
10077 assert!(
10078 rendered.contains("../caixa-teia/"),
10079 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10080 );
10081 assert!(
10082 rendered.contains("trailing"),
10083 "diagnostic must reference the trailing-slash footgun: {rendered:?}",
10084 );
10085 }
10086
10087 // -- :caminho shell-redirection metacharacter arm -----------------------
10088
10089 #[test]
10090 fn validate_rejects_path_fonte_with_caminho_carrying_gt_redirection() {
10091 // The fail-before-pass-after pin for the canonical output-redirection
10092 // paste footgun: an author copies a shell pipeline tail
10093 // (`"../caixa-teia>build.log"` — the canonical "I selected the whole
10094 // line including the `> build.log` redirect" idiom) and silently
10095 // passed every prior arm (`Path::is_absolute` false on `..`, no
10096 // control bytes, no backslash, doesn't end in `/`). The lacre
10097 // embedded the value verbatim, the resolver folded it through
10098 // `Path::join` looking for a literal `./../caixa-teia>build.log`
10099 // subdirectory, and the failure surfaced at resolve time with a
10100 // non-self-locating `No such file or directory` error. The new arm
10101 // moves the rejection to validate time and names the offending dep
10102 // + caminho + byte verbatim.
10103 let d = dep_with_fonte(DepSource::Path {
10104 caminho: "../caixa-teia>build.log".into(),
10105 });
10106 let err = d.validate().unwrap_err();
10107 let DepError::FonteCaminhoShellRedirection {
10108 nome,
10109 caminho,
10110 byte,
10111 } = err
10112 else {
10113 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10114 };
10115 assert_eq!(nome, "caixa-teia");
10116 assert_eq!(caminho, "../caixa-teia>build.log");
10117 assert_eq!(byte, b'>');
10118 }
10119
10120 #[test]
10121 fn validate_rejects_path_fonte_with_caminho_carrying_lt_redirection() {
10122 // The symmetric input-redirection paste shape
10123 // (`"../caixa-teia<input.lisp"` — the canonical "I copied a
10124 // `command < input.lisp` line from a tatara-lisp REPL log"
10125 // idiom). Pinned separately from the `>` shape so the gate's
10126 // contract is "any `<` or `>` anywhere", not single-byte coverage.
10127 let d = dep_with_fonte(DepSource::Path {
10128 caminho: "../caixa-teia<input.lisp".into(),
10129 });
10130 let err = d.validate().unwrap_err();
10131 let DepError::FonteCaminhoShellRedirection { byte, .. } = err else {
10132 panic!("expected FonteCaminhoShellRedirection, got {err:?}");
10133 };
10134 assert_eq!(byte, b'<');
10135 }
10136
10137 #[test]
10138 fn validate_rejects_path_fonte_with_caminho_carrying_leading_gt_redirection() {
10139 // Leading-position `>` shape (`">../caixa-teia"` — the degenerate
10140 // "I forgot the source side of the redirect" idiom). Pinned
10141 // separately from the embedded-byte shapes so the gate covers
10142 // every position, not only mid-path.
10143 let d = dep_with_fonte(DepSource::Path {
10144 caminho: ">../caixa-teia".into(),
10145 });
10146 let err = d.validate().unwrap_err();
10147 assert!(
10148 matches!(
10149 err,
10150 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10151 ),
10152 "got {err:?}",
10153 );
10154 }
10155
10156 #[test]
10157 fn validate_rejects_path_fonte_with_caminho_carrying_double_gt_append() {
10158 // The bash append-redirection shape (`"../caixa-teia>>build.log"` —
10159 // the canonical "I copied a `>>` append redirect" idiom). The arm
10160 // fires on the first `>` encountered; pinned so a future arm that
10161 // tries to distinguish `>` from `>>` doesn't break the broader
10162 // contract.
10163 let d = dep_with_fonte(DepSource::Path {
10164 caminho: "../caixa-teia>>build.log".into(),
10165 });
10166 let err = d.validate().unwrap_err();
10167 assert!(
10168 matches!(
10169 err,
10170 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10171 ),
10172 "got {err:?}",
10173 );
10174 }
10175
10176 #[test]
10177 fn validate_accepts_path_fonte_with_caminho_carrying_no_redirection() {
10178 // The positive-control pin: the gate targets only `<` / `>`,
10179 // never adjacent printable ASCII or POSIX-valid bytes. The
10180 // canonical relative POSIX path (`"../caixa-teia"`) and a
10181 // nested deeply-pathed variant (`"../caixa-teia/foo/bar"`) must
10182 // continue to validate cleanly so the gate doesn't widen to a
10183 // "no printable punctuation anywhere" sweep that would defeat
10184 // the entire path-fonte author surface.
10185 let d = dep_with_fonte(DepSource::Path {
10186 caminho: "../caixa-teia/foo/bar".into(),
10187 });
10188 d.validate().unwrap();
10189 }
10190
10191 #[test]
10192 fn fonte_caminho_backslash_fires_before_shell_redirection() {
10193 // Cascade pin on the immediate-predecessor arm: a value carrying
10194 // both `\` and `<` / `>` (`"..\caixa-teia>build.log"` — the
10195 // canonical "I pasted a Windows-shell command with output
10196 // redirect" footgun) routes through `FonteCaminhoBackslash` not
10197 // `FonteCaminhoShellRedirection`. The cross-host-OS-separator
10198 // divergence is the load-bearing axis (an author who removes
10199 // the `\` is the root-cause edit; the `>` falls away in the
10200 // same edit since it's downstream of the Windows-shell
10201 // convention).
10202 let d = dep_with_fonte(DepSource::Path {
10203 caminho: "..\\caixa-teia>build.log".into(),
10204 });
10205 let err = d.validate().unwrap_err();
10206 assert!(
10207 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10208 "got {err:?}",
10209 );
10210 }
10211
10212 #[test]
10213 fn fonte_caminho_control_char_fires_before_shell_redirection() {
10214 // Cascade pin on the embedded-control-byte arm: a value carrying
10215 // both a control byte and `<` / `>` (`"../foo\n>bar"` — the
10216 // canonical paste-from-multiline-doc footgun where a newline
10217 // landed mid-caminho) routes through `FonteCaminhoControlChar`
10218 // not `FonteCaminhoShellRedirection`. The POSIX-syscall-
10219 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
10220 // load-bearing axis on every value that probes positive for
10221 // both — mirrors the cascade discipline on every prior arm.
10222 let d = dep_with_fonte(DepSource::Path {
10223 caminho: "../foo\n>bar".into(),
10224 });
10225 let err = d.validate().unwrap_err();
10226 assert!(
10227 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10228 "got {err:?}",
10229 );
10230 }
10231
10232 #[test]
10233 fn fonte_caminho_absolute_fires_before_shell_redirection() {
10234 // Cascade pin on the load-bearing leading-byte arm: a leading
10235 // `/` value with embedded `<` / `>` (`"/etc/passwd>out"`)
10236 // routes through `FonteCaminhoAbsolute` not
10237 // `FonteCaminhoShellRedirection` — the host-layout-leak
10238 // diagnostic is the load-bearing axis, the `>` byte is the
10239 // secondary observation. Same precedence logic as every prior
10240 // leading-byte arm.
10241 let d = dep_with_fonte(DepSource::Path {
10242 caminho: "/etc/passwd>out".into(),
10243 });
10244 let err = d.validate().unwrap_err();
10245 assert!(
10246 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10247 "got {err:?}",
10248 );
10249 }
10250
10251 #[test]
10252 fn fonte_caminho_shell_redirection_fires_before_trailing_slash() {
10253 // Cascade pin on the immediate-successor arm: a value carrying
10254 // both `<` / `>` and a trailing `/` (`"../foo></"` — the
10255 // canonical "I tab-completed a path that already had a
10256 // redirect" footgun) routes through `FonteCaminhoShellRedirection`
10257 // not `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10258 // the more semantic-locating axis (an author who removes the
10259 // `<` / `>` typically also drops the trailing separator since
10260 // both are paste-from-shell artifacts).
10261 let d = dep_with_fonte(DepSource::Path {
10262 caminho: "../foo></".into(),
10263 });
10264 let err = d.validate().unwrap_err();
10265 assert!(
10266 matches!(
10267 err,
10268 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10269 ),
10270 "got {err:?}",
10271 );
10272 }
10273
10274 #[test]
10275 fn fonte_caminho_shell_redirection_diagnostic_carries_offending_dep_caminho_byte() {
10276 // Diagnostic-shape pin (peer with
10277 // `fonte_caminho_control_diagnostic_carries_offending_dep_caminho_byte`'s
10278 // payload assertion on the closest peer arm that also carries a
10279 // `byte` field): the error's Display surfaces the offending
10280 // `:nome`, the offending `:caminho` verbatim, and the offending
10281 // byte in hex (`0x3c` for `<`, `0x3e` for `>`) so a `feira lint`
10282 // run can render the diagnostic without re-parsing.
10283 let d = dep_with_fonte(DepSource::Path {
10284 caminho: "../caixa-teia>build.log".into(),
10285 });
10286 let rendered = d.validate().unwrap_err().to_string();
10287 assert!(
10288 rendered.contains("caixa-teia"),
10289 "diagnostic must name the offending dep: {rendered}",
10290 );
10291 assert!(
10292 rendered.contains("../caixa-teia>build.log"),
10293 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10294 );
10295 assert!(
10296 rendered.contains("0x3e"),
10297 "diagnostic must name the offending byte in hex: {rendered:?}",
10298 );
10299 assert!(
10300 rendered.contains("redirection"),
10301 "diagnostic must name the shell-redirection footgun: {rendered:?}",
10302 );
10303 }
10304
10305 // -- :caminho shell-pipe metacharacter arm ----------------------------
10306
10307 #[test]
10308 fn validate_rejects_path_fonte_with_caminho_carrying_pipe() {
10309 // The fail-before-pass-after pin for the canonical shell-pipe
10310 // paste footgun: an author copies a shell-history line
10311 // (`"../caixa-teia | grep foo"` — the canonical "I selected
10312 // the whole `ls dir | grep` line out of zsh history") and
10313 // silently passed every prior arm (`Path::is_absolute` false
10314 // on `..`, no control bytes, no backslash, no `<` / `>`,
10315 // doesn't end in `/`). The lacre embedded the value verbatim,
10316 // the resolver folded it through `Path::join` looking for a
10317 // literal `./../caixa-teia | grep foo` subdirectory, and the
10318 // failure surfaced at resolve time with a non-self-locating
10319 // `No such file or directory` error. The new arm moves the
10320 // rejection to validate time and names the offending dep +
10321 // caminho verbatim.
10322 let d = dep_with_fonte(DepSource::Path {
10323 caminho: "../caixa-teia | grep foo".into(),
10324 });
10325 let err = d.validate().unwrap_err();
10326 let DepError::FonteCaminhoShellPipe { nome, caminho } = err else {
10327 panic!("expected FonteCaminhoShellPipe, got {err:?}");
10328 };
10329 assert_eq!(nome, "caixa-teia");
10330 assert_eq!(caminho, "../caixa-teia | grep foo");
10331 }
10332
10333 #[test]
10334 fn validate_rejects_path_fonte_with_caminho_carrying_leading_pipe() {
10335 // Leading-position `|` shape (`"|../caixa-teia"` — the
10336 // degenerate "I forgot the source side of the pipe" idiom).
10337 // Pinned separately from the embedded-byte shape so the gate
10338 // covers every position, not only mid-path.
10339 let d = dep_with_fonte(DepSource::Path {
10340 caminho: "|../caixa-teia".into(),
10341 });
10342 let err = d.validate().unwrap_err();
10343 assert!(
10344 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10345 "got {err:?}",
10346 );
10347 }
10348
10349 #[test]
10350 fn validate_rejects_path_fonte_with_caminho_carrying_double_pipe_or() {
10351 // The bash short-circuit-OR shape (`"../caixa-teia||fallback"`
10352 // — the canonical "I copied a `cmd-a || cmd-b` fallback line"
10353 // idiom). The arm fires on the first `|` encountered; pinned
10354 // so a future arm that tries to distinguish `|` from `||`
10355 // doesn't break the broader contract.
10356 let d = dep_with_fonte(DepSource::Path {
10357 caminho: "../caixa-teia||fallback".into(),
10358 });
10359 let err = d.validate().unwrap_err();
10360 assert!(
10361 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10362 "got {err:?}",
10363 );
10364 }
10365
10366 #[test]
10367 fn validate_accepts_path_fonte_with_caminho_carrying_no_pipe() {
10368 // The positive-control pin: the gate targets only `|`, never
10369 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10370 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10371 // pathed variant with adjacent printable punctuation
10372 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10373 // cleanly so the gate doesn't widen to a "no printable
10374 // punctuation anywhere" sweep that would defeat the entire
10375 // path-fonte author surface.
10376 let d = dep_with_fonte(DepSource::Path {
10377 caminho: "../caixa-teia/sub-dir.v2".into(),
10378 });
10379 d.validate().unwrap();
10380 }
10381
10382 #[test]
10383 fn fonte_caminho_shell_redirection_fires_before_shell_pipe() {
10384 // Cascade pin on the immediate-predecessor arm: a value carrying
10385 // both `<` / `>` and `|` (`"../caixa-teia<input|tee"` — the
10386 // canonical "I pasted a `cmd < input | tee` pipeline tail"
10387 // footgun) routes through `FonteCaminhoShellRedirection` not
10388 // `FonteCaminhoShellPipe`. The input/output redirection
10389 // metachar carries the more self-locating `byte: u8` payload
10390 // (it names which of `<` or `>` triggered), so the prior arm
10391 // wins on every probe-as-both value — same cascade discipline
10392 // every prior `:caminho` arm establishes.
10393 let d = dep_with_fonte(DepSource::Path {
10394 caminho: "../caixa-teia<input|tee".into(),
10395 });
10396 let err = d.validate().unwrap_err();
10397 assert!(
10398 matches!(
10399 err,
10400 DepError::FonteCaminhoShellRedirection { byte: b'<', .. }
10401 ),
10402 "got {err:?}",
10403 );
10404 }
10405
10406 #[test]
10407 fn fonte_caminho_backslash_fires_before_shell_pipe() {
10408 // Cascade pin on the upstream backslash arm: a value carrying
10409 // both `\` and `|` (`"..\caixa-teia|tee"` — the canonical
10410 // "I pasted a Windows-shell command with pipe to tee"
10411 // footgun) routes through `FonteCaminhoBackslash` not
10412 // `FonteCaminhoShellPipe`. The cross-host-OS-separator
10413 // divergence is the load-bearing axis on every probe-as-both
10414 // value (an author who removes the `\` is the root-cause edit;
10415 // the `|` falls away in the same edit since it's downstream of
10416 // the Windows-shell convention).
10417 let d = dep_with_fonte(DepSource::Path {
10418 caminho: "..\\caixa-teia|tee".into(),
10419 });
10420 let err = d.validate().unwrap_err();
10421 assert!(
10422 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10423 "got {err:?}",
10424 );
10425 }
10426
10427 #[test]
10428 fn fonte_caminho_control_char_fires_before_shell_pipe() {
10429 // Cascade pin on the embedded-control-byte arm: a value
10430 // carrying both a control byte and `|` (`"../foo\n|bar"` —
10431 // the canonical paste-from-multiline-doc footgun where a
10432 // newline landed mid-caminho) routes through
10433 // `FonteCaminhoControlChar` not `FonteCaminhoShellPipe`. The
10434 // POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10435 // diagnostic is the load-bearing axis on every value that
10436 // probes positive for both — mirrors the cascade discipline
10437 // on every prior arm.
10438 let d = dep_with_fonte(DepSource::Path {
10439 caminho: "../foo\n|bar".into(),
10440 });
10441 let err = d.validate().unwrap_err();
10442 assert!(
10443 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10444 "got {err:?}",
10445 );
10446 }
10447
10448 #[test]
10449 fn fonte_caminho_absolute_fires_before_shell_pipe() {
10450 // Cascade pin on the load-bearing leading-byte arm: a leading
10451 // `/` value with embedded `|` (`"/etc/passwd|tee"`) routes
10452 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellPipe`
10453 // — the host-layout-leak diagnostic is the load-bearing axis,
10454 // the `|` byte is the secondary observation. Same precedence
10455 // logic as every prior leading-byte arm.
10456 let d = dep_with_fonte(DepSource::Path {
10457 caminho: "/etc/passwd|tee".into(),
10458 });
10459 let err = d.validate().unwrap_err();
10460 assert!(
10461 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10462 "got {err:?}",
10463 );
10464 }
10465
10466 #[test]
10467 fn fonte_caminho_shell_pipe_fires_before_trailing_slash() {
10468 // Cascade pin on the immediate-successor arm: a value carrying
10469 // both `|` and a trailing `/` (`"../foo|tee/"` — the canonical
10470 // "I tab-completed a path that already had a pipeline tail"
10471 // footgun) routes through `FonteCaminhoShellPipe` not
10472 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10473 // the more semantic-locating axis (an author who removes the
10474 // `|` typically also drops the trailing separator since both
10475 // are paste-from-shell artifacts).
10476 let d = dep_with_fonte(DepSource::Path {
10477 caminho: "../foo|tee/".into(),
10478 });
10479 let err = d.validate().unwrap_err();
10480 assert!(
10481 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10482 "got {err:?}",
10483 );
10484 }
10485
10486 #[test]
10487 fn fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho() {
10488 // Diagnostic-shape pin (peer with
10489 // `fonte_caminho_backslash_diagnostic_carries_offending_dep_and_caminho`
10490 // on the closest single-byte peer arm): the error's Display
10491 // surfaces the offending `:nome` and the offending `:caminho`
10492 // verbatim, and names the shell-pipe footgun explicitly so a
10493 // `feira lint` run can render the diagnostic without
10494 // re-parsing.
10495 let d = dep_with_fonte(DepSource::Path {
10496 caminho: "../caixa-teia | grep foo".into(),
10497 });
10498 let rendered = d.validate().unwrap_err().to_string();
10499 assert!(
10500 rendered.contains("caixa-teia"),
10501 "diagnostic must name the offending dep: {rendered}",
10502 );
10503 assert!(
10504 rendered.contains("../caixa-teia | grep foo"),
10505 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10506 );
10507 assert!(
10508 rendered.contains('|'),
10509 "diagnostic must reference the pipe footgun: {rendered:?}",
10510 );
10511 assert!(
10512 rendered.contains("pipe"),
10513 "diagnostic must name the shell-pipe footgun: {rendered:?}",
10514 );
10515 }
10516
10517 // -- :caminho shell-command-separator metacharacter arm ---------------
10518
10519 #[test]
10520 fn validate_rejects_path_fonte_with_caminho_carrying_semicolon() {
10521 // The fail-before-pass-after pin for the canonical shell-command-
10522 // separator paste footgun: an author copies a shell one-liner
10523 // (`"../caixa-teia; rm -rf build"` — the canonical "I selected the
10524 // whole `cd path; do-thing` chain out of a shell-history block")
10525 // and silently passed every prior arm (`Path::is_absolute` false
10526 // on `..`, no control bytes, no backslash, no `<` / `>`, no `|`,
10527 // doesn't end in `/`). The lacre embedded the value verbatim, the
10528 // resolver folded it through `Path::join` looking for a literal
10529 // `./../caixa-teia; rm -rf build` subdirectory, and the failure
10530 // surfaced at resolve time with a non-self-locating `No such file
10531 // or directory` error. The new arm moves the rejection to validate
10532 // time and names the offending dep + caminho verbatim.
10533 let d = dep_with_fonte(DepSource::Path {
10534 caminho: "../caixa-teia; rm -rf build".into(),
10535 });
10536 let err = d.validate().unwrap_err();
10537 let DepError::FonteCaminhoShellSemicolon { nome, caminho } = err else {
10538 panic!("expected FonteCaminhoShellSemicolon, got {err:?}");
10539 };
10540 assert_eq!(nome, "caixa-teia");
10541 assert_eq!(caminho, "../caixa-teia; rm -rf build");
10542 }
10543
10544 #[test]
10545 fn validate_rejects_path_fonte_with_caminho_carrying_leading_semicolon() {
10546 // Leading-position `;` shape (`";../caixa-teia"` — the degenerate
10547 // "I forgot the prior command side of the separator" idiom).
10548 // Pinned separately from the embedded-byte shape so the gate
10549 // covers every position, not only mid-path.
10550 let d = dep_with_fonte(DepSource::Path {
10551 caminho: ";../caixa-teia".into(),
10552 });
10553 let err = d.validate().unwrap_err();
10554 assert!(
10555 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10556 "got {err:?}",
10557 );
10558 }
10559
10560 #[test]
10561 fn validate_rejects_path_fonte_with_caminho_carrying_double_semicolon() {
10562 // The POSIX `case` arm `;;` terminator shape
10563 // (`"../caixa-teia;;next"` — the canonical "I copied a `case`
10564 // arm tail" idiom). The arm fires on the first `;` encountered;
10565 // pinned so a future arm that tries to distinguish `;` from `;;`
10566 // doesn't break the broader contract.
10567 let d = dep_with_fonte(DepSource::Path {
10568 caminho: "../caixa-teia;;next".into(),
10569 });
10570 let err = d.validate().unwrap_err();
10571 assert!(
10572 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10573 "got {err:?}",
10574 );
10575 }
10576
10577 #[test]
10578 fn validate_accepts_path_fonte_with_caminho_carrying_no_semicolon() {
10579 // The positive-control pin: the gate targets only `;`, never
10580 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10581 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10582 // pathed variant with adjacent printable punctuation
10583 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10584 // cleanly so the gate doesn't widen to a "no printable
10585 // punctuation anywhere" sweep that would defeat the entire
10586 // path-fonte author surface.
10587 let d = dep_with_fonte(DepSource::Path {
10588 caminho: "../caixa-teia/sub-dir.v2".into(),
10589 });
10590 d.validate().unwrap();
10591 }
10592
10593 #[test]
10594 fn fonte_caminho_shell_pipe_fires_before_shell_semicolon() {
10595 // Cascade pin on the immediate-predecessor arm: a value carrying
10596 // both `|` and `;` (`"../caixa-teia | tee; rm"` — the canonical
10597 // "I pasted a `cmd | tee; cleanup` chain" footgun) routes through
10598 // `FonteCaminhoShellPipe` not `FonteCaminhoShellSemicolon`. The
10599 // pipeline-tail paste is the load-bearing root-cause edit on
10600 // every probe-as-both value (an author who removes the `|`
10601 // typically also drops the trailing `; cleanup` since both are
10602 // the same paste-from-shell-history artifact) — same cascade
10603 // discipline every prior `:caminho` arm establishes.
10604 let d = dep_with_fonte(DepSource::Path {
10605 caminho: "../caixa-teia | tee; rm".into(),
10606 });
10607 let err = d.validate().unwrap_err();
10608 assert!(
10609 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10610 "got {err:?}",
10611 );
10612 }
10613
10614 #[test]
10615 fn fonte_caminho_shell_redirection_fires_before_shell_semicolon() {
10616 // Cascade pin on the upstream shell-redirection arm: a value
10617 // carrying both `<` / `>` and `;` (`"../caixa-teia>log; rm"` —
10618 // the canonical "I pasted a `cmd > log; cleanup` chain"
10619 // footgun) routes through `FonteCaminhoShellRedirection` not
10620 // `FonteCaminhoShellSemicolon`. The input/output redirection
10621 // metachar carries the more self-locating `byte: u8` payload
10622 // (it names which of `<` or `>` triggered), so the prior arm
10623 // wins on every probe-as-both value.
10624 let d = dep_with_fonte(DepSource::Path {
10625 caminho: "../caixa-teia>log; rm".into(),
10626 });
10627 let err = d.validate().unwrap_err();
10628 assert!(
10629 matches!(
10630 err,
10631 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10632 ),
10633 "got {err:?}",
10634 );
10635 }
10636
10637 #[test]
10638 fn fonte_caminho_backslash_fires_before_shell_semicolon() {
10639 // Cascade pin on the upstream backslash arm: a value carrying
10640 // both `\` and `;` (`"..\caixa-teia;rm"` — the canonical "I
10641 // pasted a Windows-shell `cd ..\path; cleanup` chain") routes
10642 // through `FonteCaminhoBackslash` not `FonteCaminhoShellSemicolon`.
10643 // The cross-host-OS-separator divergence is the load-bearing axis
10644 // on every probe-as-both value (an author who removes the `\` is
10645 // the root-cause edit; the `;` falls away in the same edit since
10646 // it's downstream of the Windows-shell convention).
10647 let d = dep_with_fonte(DepSource::Path {
10648 caminho: "..\\caixa-teia;rm".into(),
10649 });
10650 let err = d.validate().unwrap_err();
10651 assert!(
10652 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10653 "got {err:?}",
10654 );
10655 }
10656
10657 #[test]
10658 fn fonte_caminho_control_char_fires_before_shell_semicolon() {
10659 // Cascade pin on the embedded-control-byte arm: a value carrying
10660 // both a control byte and `;` (`"../foo\n;bar"` — the canonical
10661 // paste-from-multiline-doc footgun where a newline landed mid-
10662 // caminho) routes through `FonteCaminhoControlChar` not
10663 // `FonteCaminhoShellSemicolon`. The POSIX-syscall-rejected-byte
10664 // / NUL-`CString::new`-fail diagnostic is the load-bearing axis
10665 // on every value that probes positive for both — mirrors the
10666 // cascade discipline on every prior arm.
10667 let d = dep_with_fonte(DepSource::Path {
10668 caminho: "../foo\n;bar".into(),
10669 });
10670 let err = d.validate().unwrap_err();
10671 assert!(
10672 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10673 "got {err:?}",
10674 );
10675 }
10676
10677 #[test]
10678 fn fonte_caminho_absolute_fires_before_shell_semicolon() {
10679 // Cascade pin on the load-bearing leading-byte arm: a leading
10680 // `/` value with embedded `;` (`"/etc/passwd;rm"`) routes
10681 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellSemicolon`
10682 // — the host-layout-leak diagnostic is the load-bearing axis,
10683 // the `;` byte is the secondary observation. Same precedence
10684 // logic as every prior leading-byte arm.
10685 let d = dep_with_fonte(DepSource::Path {
10686 caminho: "/etc/passwd;rm".into(),
10687 });
10688 let err = d.validate().unwrap_err();
10689 assert!(
10690 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10691 "got {err:?}",
10692 );
10693 }
10694
10695 #[test]
10696 fn fonte_caminho_shell_semicolon_fires_before_trailing_slash() {
10697 // Cascade pin on the immediate-successor arm: a value carrying
10698 // both `;` and a trailing `/` (`"../foo;rm/"` — the canonical
10699 // "I tab-completed a path that already had a `; cleanup` tail"
10700 // footgun) routes through `FonteCaminhoShellSemicolon` not
10701 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
10702 // the more semantic-locating axis (an author who removes the
10703 // `;` typically also drops the trailing separator since both
10704 // are paste-from-shell artifacts).
10705 let d = dep_with_fonte(DepSource::Path {
10706 caminho: "../foo;rm/".into(),
10707 });
10708 let err = d.validate().unwrap_err();
10709 assert!(
10710 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10711 "got {err:?}",
10712 );
10713 }
10714
10715 #[test]
10716 fn fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho() {
10717 // Diagnostic-shape pin (peer with
10718 // `fonte_caminho_shell_pipe_diagnostic_carries_offending_dep_and_caminho`
10719 // on the closest single-byte peer arm): the error's Display
10720 // surfaces the offending `:nome` and the offending `:caminho`
10721 // verbatim, and names the shell-command-separator footgun
10722 // explicitly so a `feira lint` run can render the diagnostic
10723 // without re-parsing.
10724 let d = dep_with_fonte(DepSource::Path {
10725 caminho: "../caixa-teia; rm -rf build".into(),
10726 });
10727 let rendered = d.validate().unwrap_err().to_string();
10728 assert!(
10729 rendered.contains("caixa-teia"),
10730 "diagnostic must name the offending dep: {rendered}",
10731 );
10732 assert!(
10733 rendered.contains("../caixa-teia; rm -rf build"),
10734 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10735 );
10736 assert!(
10737 rendered.contains(';'),
10738 "diagnostic must reference the semicolon footgun: {rendered:?}",
10739 );
10740 assert!(
10741 rendered.contains("command-separator"),
10742 "diagnostic must name the shell-command-separator footgun: {rendered:?}",
10743 );
10744 }
10745
10746 #[test]
10747 fn validate_rejects_path_fonte_with_caminho_carrying_ampersand() {
10748 // The fail-before-pass-after pin for the canonical shell-
10749 // background-task paste footgun: an author copies a shell one-
10750 // liner (`"../caixa-teia & sleep 1"` — the canonical "I selected
10751 // the whole `cd path & sleep 1` background-launch out of a
10752 // shell-history block") and silently passed every prior arm
10753 // (`Path::is_absolute` false on `..`, no control bytes, no
10754 // backslash, no `<` / `>`, no `|`, no `;`, doesn't end in `/`).
10755 // The lacre embedded the value verbatim, the resolver folded it
10756 // through `Path::join` looking for a literal `./../caixa-teia &
10757 // sleep 1` subdirectory, and the failure surfaced at resolve
10758 // time with a non-self-locating `No such file or directory`
10759 // error. The new arm moves the rejection to validate time and
10760 // names the offending dep + caminho verbatim.
10761 let d = dep_with_fonte(DepSource::Path {
10762 caminho: "../caixa-teia & sleep 1".into(),
10763 });
10764 let err = d.validate().unwrap_err();
10765 let DepError::FonteCaminhoShellBackground { nome, caminho } = err else {
10766 panic!("expected FonteCaminhoShellBackground, got {err:?}");
10767 };
10768 assert_eq!(nome, "caixa-teia");
10769 assert_eq!(caminho, "../caixa-teia & sleep 1");
10770 }
10771
10772 #[test]
10773 fn validate_rejects_path_fonte_with_caminho_carrying_leading_ampersand() {
10774 // Leading-position `&` shape (`"&../caixa-teia"` — the
10775 // degenerate "I forgot the prior command side of the
10776 // background terminator" idiom). Pinned separately from the
10777 // embedded-byte shape so the gate covers every position, not
10778 // only mid-path.
10779 let d = dep_with_fonte(DepSource::Path {
10780 caminho: "&../caixa-teia".into(),
10781 });
10782 let err = d.validate().unwrap_err();
10783 assert!(
10784 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10785 "got {err:?}",
10786 );
10787 }
10788
10789 #[test]
10790 fn validate_rejects_path_fonte_with_caminho_carrying_double_ampersand() {
10791 // The logical-AND `&&` shape (`"../caixa-teia && make"` — the
10792 // canonical "I copied a `cd path && make` build chain" idiom
10793 // every Makefile / shell-script wraps). The arm fires on the
10794 // first `&` encountered; pinned so a future arm that tries to
10795 // distinguish `&` from `&&` doesn't break the broader contract.
10796 let d = dep_with_fonte(DepSource::Path {
10797 caminho: "../caixa-teia && make".into(),
10798 });
10799 let err = d.validate().unwrap_err();
10800 assert!(
10801 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10802 "got {err:?}",
10803 );
10804 }
10805
10806 #[test]
10807 fn validate_accepts_path_fonte_with_caminho_carrying_no_ampersand() {
10808 // The positive-control pin: the gate targets only `&`, never
10809 // adjacent printable ASCII or POSIX-valid bytes. The canonical
10810 // relative POSIX path (`"../caixa-teia"`) and a nested deeply-
10811 // pathed variant with adjacent printable punctuation
10812 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
10813 // cleanly so the gate doesn't widen to a "no printable
10814 // punctuation anywhere" sweep that would defeat the entire
10815 // path-fonte author surface.
10816 let d = dep_with_fonte(DepSource::Path {
10817 caminho: "../caixa-teia/sub-dir.v2".into(),
10818 });
10819 d.validate().unwrap();
10820 }
10821
10822 #[test]
10823 fn fonte_caminho_shell_semicolon_fires_before_shell_background() {
10824 // Cascade pin on the immediate-predecessor arm: a value carrying
10825 // both `;` and `&` (`"../caixa-teia; rm & sleep"` — the
10826 // canonical "I pasted a `cmd; cleanup & sleep` chain" footgun)
10827 // routes through `FonteCaminhoShellSemicolon` not
10828 // `FonteCaminhoShellBackground`. The sequential-command-
10829 // separator paste is the more common shell-history paste idiom
10830 // on every probe-as-both value (an author who removes the `;`
10831 // typically also drops the trailing `& sleep` since both are
10832 // paste-from-shell-history artifacts) — same cascade discipline
10833 // every prior `:caminho` arm establishes.
10834 let d = dep_with_fonte(DepSource::Path {
10835 caminho: "../caixa-teia; rm & sleep".into(),
10836 });
10837 let err = d.validate().unwrap_err();
10838 assert!(
10839 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
10840 "got {err:?}",
10841 );
10842 }
10843
10844 #[test]
10845 fn fonte_caminho_shell_pipe_fires_before_shell_background() {
10846 // Cascade pin on the upstream shell-pipe arm: a value carrying
10847 // both `|` and `&` (`"../caixa-teia | tee & sleep"` — the
10848 // canonical "I pasted a `cmd | tee & sleep` background-pipeline
10849 // chain" footgun) routes through `FonteCaminhoShellPipe` not
10850 // `FonteCaminhoShellBackground`. The pipeline-tail paste is the
10851 // load-bearing root-cause edit on every probe-as-both value.
10852 let d = dep_with_fonte(DepSource::Path {
10853 caminho: "../caixa-teia | tee & sleep".into(),
10854 });
10855 let err = d.validate().unwrap_err();
10856 assert!(
10857 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
10858 "got {err:?}",
10859 );
10860 }
10861
10862 #[test]
10863 fn fonte_caminho_shell_redirection_fires_before_shell_background() {
10864 // Cascade pin on the upstream shell-redirection arm: a value
10865 // carrying both `>` and `&` (`"../caixa-teia>log & sleep"` —
10866 // the canonical "I pasted a `cmd > log & sleep` background-
10867 // redirect chain" footgun) routes through
10868 // `FonteCaminhoShellRedirection` not
10869 // `FonteCaminhoShellBackground`. The input/output redirection
10870 // metachar carries the more self-locating `byte: u8` payload
10871 // (it names which of `<` or `>` triggered), so the prior arm
10872 // wins on every probe-as-both value.
10873 let d = dep_with_fonte(DepSource::Path {
10874 caminho: "../caixa-teia>log & sleep".into(),
10875 });
10876 let err = d.validate().unwrap_err();
10877 assert!(
10878 matches!(
10879 err,
10880 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
10881 ),
10882 "got {err:?}",
10883 );
10884 }
10885
10886 #[test]
10887 fn fonte_caminho_backslash_fires_before_shell_background() {
10888 // Cascade pin on the upstream backslash arm: a value carrying
10889 // both `\` and `&` (`"..\caixa-teia & sleep"` — the canonical
10890 // "I pasted a Windows-shell `cd ..\path & sleep` background-
10891 // launch chain") routes through `FonteCaminhoBackslash` not
10892 // `FonteCaminhoShellBackground`. The cross-host-OS-separator
10893 // divergence is the load-bearing axis on every probe-as-both
10894 // value (an author who removes the `\` is the root-cause edit;
10895 // the `&` falls away in the same edit since it's downstream of
10896 // the Windows-shell convention).
10897 let d = dep_with_fonte(DepSource::Path {
10898 caminho: "..\\caixa-teia & sleep".into(),
10899 });
10900 let err = d.validate().unwrap_err();
10901 assert!(
10902 matches!(err, DepError::FonteCaminhoBackslash { .. }),
10903 "got {err:?}",
10904 );
10905 }
10906
10907 #[test]
10908 fn fonte_caminho_control_char_fires_before_shell_background() {
10909 // Cascade pin on the embedded-control-byte arm: a value
10910 // carrying both a control byte and `&` (`"../foo\n&sleep"` —
10911 // the canonical paste-from-multiline-doc footgun where a
10912 // newline landed mid-caminho) routes through
10913 // `FonteCaminhoControlChar` not `FonteCaminhoShellBackground`.
10914 // The POSIX-syscall-rejected-byte / NUL-`CString::new`-fail
10915 // diagnostic is the load-bearing axis on every value that
10916 // probes positive for both — mirrors the cascade discipline on
10917 // every prior arm.
10918 let d = dep_with_fonte(DepSource::Path {
10919 caminho: "../foo\n&sleep".into(),
10920 });
10921 let err = d.validate().unwrap_err();
10922 assert!(
10923 matches!(err, DepError::FonteCaminhoControlChar { .. }),
10924 "got {err:?}",
10925 );
10926 }
10927
10928 #[test]
10929 fn fonte_caminho_absolute_fires_before_shell_background() {
10930 // Cascade pin on the load-bearing leading-byte arm: a leading
10931 // `/` value with embedded `&` (`"/etc/passwd & sleep"`) routes
10932 // through `FonteCaminhoAbsolute` not
10933 // `FonteCaminhoShellBackground` — the host-layout-leak
10934 // diagnostic is the load-bearing axis, the `&` byte is the
10935 // secondary observation. Same precedence logic as every prior
10936 // leading-byte arm.
10937 let d = dep_with_fonte(DepSource::Path {
10938 caminho: "/etc/passwd & sleep".into(),
10939 });
10940 let err = d.validate().unwrap_err();
10941 assert!(
10942 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
10943 "got {err:?}",
10944 );
10945 }
10946
10947 #[test]
10948 fn fonte_caminho_shell_background_fires_before_trailing_slash() {
10949 // Cascade pin on the immediate-successor arm: a value carrying
10950 // both `&` and a trailing `/` (`"../foo&sleep/"` — the
10951 // canonical "I tab-completed a path that already had a `&
10952 // sleep` background-launch tail" footgun) routes through
10953 // `FonteCaminhoShellBackground` not `FonteCaminhoTrailingSlash`.
10954 // The embedded shell-metachar is the more semantic-locating
10955 // axis (an author who removes the `&` typically also drops
10956 // the trailing separator since both are paste-from-shell
10957 // artifacts).
10958 let d = dep_with_fonte(DepSource::Path {
10959 caminho: "../foo&sleep/".into(),
10960 });
10961 let err = d.validate().unwrap_err();
10962 assert!(
10963 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
10964 "got {err:?}",
10965 );
10966 }
10967
10968 #[test]
10969 fn fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho() {
10970 // Diagnostic-shape pin (peer with
10971 // `fonte_caminho_shell_semicolon_diagnostic_carries_offending_dep_and_caminho`
10972 // on the closest single-byte peer arm): the error's Display
10973 // surfaces the offending `:nome` and the offending `:caminho`
10974 // verbatim, and names the shell-background / logical-AND
10975 // footgun explicitly so a `feira lint` run can render the
10976 // diagnostic without re-parsing.
10977 let d = dep_with_fonte(DepSource::Path {
10978 caminho: "../caixa-teia & sleep 1".into(),
10979 });
10980 let rendered = d.validate().unwrap_err().to_string();
10981 assert!(
10982 rendered.contains("caixa-teia"),
10983 "diagnostic must name the offending dep: {rendered}",
10984 );
10985 assert!(
10986 rendered.contains("../caixa-teia & sleep 1"),
10987 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
10988 );
10989 assert!(
10990 rendered.contains('&'),
10991 "diagnostic must reference the ampersand footgun: {rendered:?}",
10992 );
10993 assert!(
10994 rendered.contains("background") || rendered.contains("list-AND"),
10995 "diagnostic must name the shell-background / logical-AND footgun: {rendered:?}",
10996 );
10997 }
10998
10999 #[test]
11000 fn validate_rejects_path_fonte_with_caminho_carrying_backtick() {
11001 // The fail-before-pass-after pin for the canonical shell-
11002 // command-substitution paste footgun: an author copies a
11003 // POSIX legacy backticked one-liner (`"../caixa-teia/`whoami`"`
11004 // — the canonical "I pasted a path that included a `pwd`
11005 // / `whoami` / `date` legacy command-substitution expansion
11006 // out of a shell-history block") and silently passed every
11007 // prior arm (`Path::is_absolute` false on `..`, no control
11008 // bytes, no `\`, no `<` / `>`, no `|`, no `;`, no `&`, doesn't
11009 // end in `/`). The lacre embedded the value verbatim, the
11010 // resolver folded it through `Path::join` looking for a
11011 // literal `./../caixa-teia/`whoami`` subdirectory, and the
11012 // failure surfaced at resolve time with a non-self-locating
11013 // `No such file or directory` error. The new arm moves the
11014 // rejection to validate time and names the offending dep +
11015 // caminho verbatim.
11016 let d = dep_with_fonte(DepSource::Path {
11017 caminho: "../caixa-teia/`whoami`".into(),
11018 });
11019 let err = d.validate().unwrap_err();
11020 let DepError::FonteCaminhoShellCommandSubstitution { nome, caminho } = err else {
11021 panic!("expected FonteCaminhoShellCommandSubstitution, got {err:?}");
11022 };
11023 assert_eq!(nome, "caixa-teia");
11024 assert_eq!(caminho, "../caixa-teia/`whoami`");
11025 }
11026
11027 #[test]
11028 fn validate_rejects_path_fonte_with_caminho_carrying_leading_backtick() {
11029 // Leading-position backtick shape (``"`pwd`/caixa-teia"`` —
11030 // the canonical `<backtick>pwd<backtick>/path` working-
11031 // directory expansion shape every shell-side path-composition
11032 // idiom carries). Pinned separately from the embedded-byte
11033 // shape so the gate covers every position, not only mid-path.
11034 let d = dep_with_fonte(DepSource::Path {
11035 caminho: "`pwd`/caixa-teia".into(),
11036 });
11037 let err = d.validate().unwrap_err();
11038 assert!(
11039 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11040 "got {err:?}",
11041 );
11042 }
11043
11044 #[test]
11045 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_backtick() {
11046 // Trailing-position backtick shape (`"../caixa-teia`"` — the
11047 // degenerate "I selected an unbalanced backtick out of a
11048 // shell-history block" idiom that probes for the cascade's
11049 // last-byte handling). The trailing-`/` arm fires only on
11050 // last-byte `/`; an unbalanced trailing backtick must route
11051 // through this arm regardless of position.
11052 let d = dep_with_fonte(DepSource::Path {
11053 caminho: "../caixa-teia`".into(),
11054 });
11055 let err = d.validate().unwrap_err();
11056 assert!(
11057 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11058 "got {err:?}",
11059 );
11060 }
11061
11062 #[test]
11063 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_backtick_pair() {
11064 // The canonical balanced-pair shape (``"../<backtick>cat
11065 // /etc/passwd<backtick>"`` — the canonical CWE-78 shell-
11066 // command-injection paste idiom every shell-side hardening
11067 // guide enumerates first). The arm fires on the first
11068 // backtick encountered; pinned so a future arm that tries to
11069 // distinguish the opening from the closing byte doesn't break
11070 // the broader contract.
11071 let d = dep_with_fonte(DepSource::Path {
11072 caminho: "../`cat /etc/passwd`".into(),
11073 });
11074 let err = d.validate().unwrap_err();
11075 assert!(
11076 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11077 "got {err:?}",
11078 );
11079 }
11080
11081 #[test]
11082 fn validate_accepts_path_fonte_with_caminho_carrying_no_backtick() {
11083 // The positive-control pin: the gate targets only the
11084 // backtick byte, never adjacent printable ASCII or POSIX-
11085 // valid bytes. The canonical relative POSIX path
11086 // (`"../caixa-teia"`) and a nested deeply-pathed variant with
11087 // adjacent printable punctuation
11088 // (`"../caixa-teia/sub-dir.v2"`) must continue to validate
11089 // cleanly so the gate doesn't widen to a "no printable
11090 // punctuation anywhere" sweep that would defeat the entire
11091 // path-fonte author surface.
11092 let d = dep_with_fonte(DepSource::Path {
11093 caminho: "../caixa-teia/sub-dir.v2".into(),
11094 });
11095 d.validate().unwrap();
11096 }
11097
11098 #[test]
11099 fn fonte_caminho_shell_background_fires_before_shell_command_substitution() {
11100 // Cascade pin on the immediate-predecessor arm: a value
11101 // carrying both `&` and a backtick (``"../caixa-teia &
11102 // <backtick>sleep 1<backtick>"`` — the canonical "I pasted a
11103 // `cmd & <backtick>sleep N<backtick>` background-launch +
11104 // command-substitution chain" footgun) routes through
11105 // `FonteCaminhoShellBackground` not
11106 // `FonteCaminhoShellCommandSubstitution`. The background-
11107 // launch tail is the more common shell-history paste idiom
11108 // on every probe-as-both value — same cascade discipline
11109 // every prior `:caminho` arm establishes.
11110 let d = dep_with_fonte(DepSource::Path {
11111 caminho: "../caixa-teia & `sleep 1`".into(),
11112 });
11113 let err = d.validate().unwrap_err();
11114 assert!(
11115 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11116 "got {err:?}",
11117 );
11118 }
11119
11120 #[test]
11121 fn fonte_caminho_shell_semicolon_fires_before_shell_command_substitution() {
11122 // Cascade pin on the upstream shell-semicolon arm: a value
11123 // carrying both `;` and a backtick (``"../caixa-teia;
11124 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11125 // `cmd; <backtick>follow-up<backtick>` sequential-chain
11126 // footgun) routes through `FonteCaminhoShellSemicolon` not
11127 // `FonteCaminhoShellCommandSubstitution`. The sequential-
11128 // command-separator paste is the load-bearing root-cause
11129 // edit on every probe-as-both value.
11130 let d = dep_with_fonte(DepSource::Path {
11131 caminho: "../caixa-teia; `whoami`".into(),
11132 });
11133 let err = d.validate().unwrap_err();
11134 assert!(
11135 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11136 "got {err:?}",
11137 );
11138 }
11139
11140 #[test]
11141 fn fonte_caminho_shell_pipe_fires_before_shell_command_substitution() {
11142 // Cascade pin on the upstream shell-pipe arm: a value
11143 // carrying both `|` and a backtick (``"../caixa-teia |
11144 // <backtick>tee log<backtick>"`` — the canonical pipeline-to-
11145 // command-substitution paste idiom) routes through
11146 // `FonteCaminhoShellPipe` not
11147 // `FonteCaminhoShellCommandSubstitution`. The pipeline-tail
11148 // paste is the load-bearing root-cause edit on every
11149 // probe-as-both value.
11150 let d = dep_with_fonte(DepSource::Path {
11151 caminho: "../caixa-teia | `tee log`".into(),
11152 });
11153 let err = d.validate().unwrap_err();
11154 assert!(
11155 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11156 "got {err:?}",
11157 );
11158 }
11159
11160 #[test]
11161 fn fonte_caminho_shell_redirection_fires_before_shell_command_substitution() {
11162 // Cascade pin on the upstream shell-redirection arm: a value
11163 // carrying both `>` and a backtick (``"../caixa-teia>log
11164 // <backtick>date<backtick>"`` — the canonical "I pasted a
11165 // `cmd > log <backtick>date<backtick>` redirect-plus-
11166 // substitution chain" footgun) routes through
11167 // `FonteCaminhoShellRedirection` not
11168 // `FonteCaminhoShellCommandSubstitution`. The input/output
11169 // redirection metachar carries the more self-locating `byte`
11170 // payload (it names which of `<` or `>` triggered), so the
11171 // prior arm wins on every probe-as-both value.
11172 let d = dep_with_fonte(DepSource::Path {
11173 caminho: "../caixa-teia>log `date`".into(),
11174 });
11175 let err = d.validate().unwrap_err();
11176 assert!(
11177 matches!(
11178 err,
11179 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11180 ),
11181 "got {err:?}",
11182 );
11183 }
11184
11185 #[test]
11186 fn fonte_caminho_backslash_fires_before_shell_command_substitution() {
11187 // Cascade pin on the upstream backslash arm: a value
11188 // carrying both `\` and a backtick (``"..\caixa-teia
11189 // <backtick>whoami<backtick>"`` — the canonical "I pasted a
11190 // Windows-shell `cd ..\path <backtick>whoami<backtick>`
11191 // chain") routes through `FonteCaminhoBackslash` not
11192 // `FonteCaminhoShellCommandSubstitution`. The cross-host-OS-
11193 // separator divergence is the load-bearing axis on every
11194 // probe-as-both value (an author who removes the `\` is the
11195 // root-cause edit; the backtick falls away in the same edit
11196 // since it's downstream of the Windows-shell convention).
11197 let d = dep_with_fonte(DepSource::Path {
11198 caminho: "..\\caixa-teia `whoami`".into(),
11199 });
11200 let err = d.validate().unwrap_err();
11201 assert!(
11202 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11203 "got {err:?}",
11204 );
11205 }
11206
11207 #[test]
11208 fn fonte_caminho_control_char_fires_before_shell_command_substitution() {
11209 // Cascade pin on the embedded-control-byte arm: a value
11210 // carrying both a control byte and a backtick (`"../foo\n
11211 // `whoami`"` — the canonical paste-from-multiline-doc
11212 // footgun where a newline landed mid-caminho between two
11213 // paste fragments) routes through `FonteCaminhoControlChar`
11214 // not `FonteCaminhoShellCommandSubstitution`. The POSIX-
11215 // syscall-rejected-byte / NUL-`CString::new`-fail diagnostic
11216 // is the load-bearing axis on every value that probes
11217 // positive for both — mirrors the cascade discipline on
11218 // every prior arm.
11219 let d = dep_with_fonte(DepSource::Path {
11220 caminho: "../foo\n`whoami`".into(),
11221 });
11222 let err = d.validate().unwrap_err();
11223 assert!(
11224 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11225 "got {err:?}",
11226 );
11227 }
11228
11229 #[test]
11230 fn fonte_caminho_absolute_fires_before_shell_command_substitution() {
11231 // Cascade pin on the load-bearing leading-byte arm: a
11232 // leading `/` value with embedded backtick (``"/etc/passwd
11233 // <backtick>whoami<backtick>"``) routes through
11234 // `FonteCaminhoAbsolute` not
11235 // `FonteCaminhoShellCommandSubstitution` — the host-layout-
11236 // leak diagnostic is the load-bearing axis, the backtick
11237 // byte is the secondary observation. Same precedence logic
11238 // as every prior leading-byte arm.
11239 let d = dep_with_fonte(DepSource::Path {
11240 caminho: "/etc/passwd `whoami`".into(),
11241 });
11242 let err = d.validate().unwrap_err();
11243 assert!(
11244 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11245 "got {err:?}",
11246 );
11247 }
11248
11249 #[test]
11250 fn fonte_caminho_shell_command_substitution_fires_before_trailing_slash() {
11251 // Cascade pin on the immediate-successor arm: a value
11252 // carrying both a backtick and a trailing `/`
11253 // (``"../`whoami`/"`` — the canonical "I tab-completed a
11254 // path that already had a backticked `whoami` substitution
11255 // tail" footgun) routes through
11256 // `FonteCaminhoShellCommandSubstitution` not
11257 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
11258 // is the more semantic-locating axis (an author who removes
11259 // the backtick typically also drops the trailing separator
11260 // since both are paste-from-shell artifacts).
11261 let d = dep_with_fonte(DepSource::Path {
11262 caminho: "../`whoami`/".into(),
11263 });
11264 let err = d.validate().unwrap_err();
11265 assert!(
11266 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11267 "got {err:?}",
11268 );
11269 }
11270
11271 #[test]
11272 fn fonte_caminho_shell_command_substitution_diagnostic_carries_offending_dep_and_caminho() {
11273 // Diagnostic-shape pin (peer with
11274 // `fonte_caminho_shell_background_diagnostic_carries_offending_dep_and_caminho`
11275 // on the closest single-byte peer arm): the error's Display
11276 // surfaces the offending `:nome` and the offending `:caminho`
11277 // verbatim, and names the shell-command-substitution footgun
11278 // explicitly so a `feira lint` run can render the diagnostic
11279 // without re-parsing.
11280 let d = dep_with_fonte(DepSource::Path {
11281 caminho: "../caixa-teia/`whoami`".into(),
11282 });
11283 let rendered = d.validate().unwrap_err().to_string();
11284 assert!(
11285 rendered.contains("caixa-teia"),
11286 "diagnostic must name the offending dep: {rendered}",
11287 );
11288 assert!(
11289 rendered.contains("../caixa-teia/`whoami`"),
11290 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11291 );
11292 assert!(
11293 rendered.contains('`'),
11294 "diagnostic must reference the backtick footgun: {rendered:?}",
11295 );
11296 assert!(
11297 rendered.contains("command-substitution"),
11298 "diagnostic must name the shell-command-substitution footgun: {rendered:?}",
11299 );
11300 }
11301
11302 #[test]
11303 fn validate_rejects_path_fonte_with_caminho_carrying_star_glob() {
11304 // The fail-before-pass-after pin for the canonical pathname-
11305 // expansion paste footgun: an author copies an `ls
11306 // ../caixa-teia/*` shell-listing tail into the `:caminho`
11307 // slot and silently passes every prior arm
11308 // (`Path::is_absolute` false on `..`, no control bytes, no
11309 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick,
11310 // doesn't end in `/`). The lacre embedded the value
11311 // verbatim, the resolver folded it through `Path::join`
11312 // looking for a literal `./../caixa-teia/*` subdirectory,
11313 // and the failure surfaced at resolve time with a non-self-
11314 // locating `No such file or directory` error. The new arm
11315 // moves the rejection to validate time and names the
11316 // offending dep + caminho + byte verbatim.
11317 let d = dep_with_fonte(DepSource::Path {
11318 caminho: "../caixa-teia/*".into(),
11319 });
11320 let err = d.validate().unwrap_err();
11321 let DepError::FonteCaminhoShellGlob {
11322 nome,
11323 caminho,
11324 byte,
11325 } = err
11326 else {
11327 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11328 };
11329 assert_eq!(nome, "caixa-teia");
11330 assert_eq!(caminho, "../caixa-teia/*");
11331 assert_eq!(byte, b'*');
11332 }
11333
11334 #[test]
11335 fn validate_rejects_path_fonte_with_caminho_carrying_question_glob() {
11336 // The symmetric single-char-wildcard paste shape
11337 // (`"../foo?"` — the canonical "I copied a `rm foo?` line
11338 // out of shell history" idiom). Pinned separately from the
11339 // `*` shape so the gate's contract is "any `*` or `?`
11340 // anywhere", not single-byte coverage.
11341 let d = dep_with_fonte(DepSource::Path {
11342 caminho: "../foo?".into(),
11343 });
11344 let err = d.validate().unwrap_err();
11345 let DepError::FonteCaminhoShellGlob { byte, .. } = err else {
11346 panic!("expected FonteCaminhoShellGlob, got {err:?}");
11347 };
11348 assert_eq!(byte, b'?');
11349 }
11350
11351 #[test]
11352 fn validate_rejects_path_fonte_with_caminho_carrying_leading_star_glob() {
11353 // Leading-position `*` shape (`"*/caixa-teia"` — the
11354 // degenerate "I selected only the wildcard prefix out of a
11355 // shell-glob expression" idiom). Pinned separately from the
11356 // embedded-byte shapes so the gate covers every position,
11357 // not only mid-path.
11358 let d = dep_with_fonte(DepSource::Path {
11359 caminho: "*/caixa-teia".into(),
11360 });
11361 let err = d.validate().unwrap_err();
11362 assert!(
11363 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11364 "got {err:?}",
11365 );
11366 }
11367
11368 #[test]
11369 fn validate_rejects_path_fonte_with_caminho_carrying_double_star_recursive_glob() {
11370 // The bash/zsh `globstar` recursive-glob shape
11371 // (`"../caixa-teia/**/foo"` — the canonical "I copied a
11372 // `find ../caixa-teia/**/foo` recursive expansion" idiom).
11373 // The arm fires on the first `*` encountered; pinned so a
11374 // future arm that tries to distinguish single `*` from
11375 // double `**` doesn't break the broader contract.
11376 let d = dep_with_fonte(DepSource::Path {
11377 caminho: "../caixa-teia/**/foo".into(),
11378 });
11379 let err = d.validate().unwrap_err();
11380 assert!(
11381 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11382 "got {err:?}",
11383 );
11384 }
11385
11386 #[test]
11387 fn validate_rejects_path_fonte_with_caminho_carrying_dotted_extension_glob() {
11388 // The canonical extension-glob shape (`"../caixa-teia/*.lisp"`
11389 // — the "I selected `*.lisp` to mean every Lisp source file
11390 // in the dep root" footgun the prior arms structurally
11391 // cannot catch since `.` is a POSIX-valid path-component
11392 // byte). Pinned so the gate's contract covers the most
11393 // idiomatic glob-paste shape every author meets first.
11394 let d = dep_with_fonte(DepSource::Path {
11395 caminho: "../caixa-teia/*.lisp".into(),
11396 });
11397 let err = d.validate().unwrap_err();
11398 assert!(
11399 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11400 "got {err:?}",
11401 );
11402 }
11403
11404 #[test]
11405 fn validate_accepts_path_fonte_with_caminho_carrying_no_glob() {
11406 // The positive-control pin: the gate targets only `*` /
11407 // `?`, never adjacent printable ASCII or POSIX-valid bytes.
11408 // The canonical relative POSIX path (`"../caixa-teia"`) and
11409 // a nested deeply-pathed variant with adjacent printable
11410 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
11411 // to validate cleanly so the gate doesn't widen to a "no
11412 // printable punctuation anywhere" sweep that would defeat
11413 // the entire path-fonte author surface.
11414 let d = dep_with_fonte(DepSource::Path {
11415 caminho: "../caixa-teia/sub-dir.v2".into(),
11416 });
11417 d.validate().unwrap();
11418 }
11419
11420 #[test]
11421 fn fonte_caminho_shell_command_substitution_fires_before_shell_glob() {
11422 // Cascade pin on the immediate-predecessor arm: a value
11423 // carrying both a backtick and `*` (``"../`whoami`/*"`` —
11424 // the canonical "I pasted a `cd <backtick>whoami<backtick>/*`
11425 // command-substitution + glob chain") routes through
11426 // `FonteCaminhoShellCommandSubstitution` not
11427 // `FonteCaminhoShellGlob`. The CWE-78 shell-command-
11428 // injection vector is the load-bearing root-cause edit on
11429 // every probe-as-both value — same cascade discipline every
11430 // prior `:caminho` arm establishes.
11431 let d = dep_with_fonte(DepSource::Path {
11432 caminho: "../`whoami`/*".into(),
11433 });
11434 let err = d.validate().unwrap_err();
11435 assert!(
11436 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11437 "got {err:?}",
11438 );
11439 }
11440
11441 #[test]
11442 fn fonte_caminho_shell_background_fires_before_shell_glob() {
11443 // Cascade pin on the upstream shell-background arm: a value
11444 // carrying both `&` and `*` (`"../caixa-teia & ls /*"` — the
11445 // canonical "I pasted a `cmd & ls /*` background + glob
11446 // chain" footgun) routes through `FonteCaminhoShellBackground`
11447 // not `FonteCaminhoShellGlob`. The background-launch tail is
11448 // the load-bearing root-cause edit on every probe-as-both
11449 // value.
11450 let d = dep_with_fonte(DepSource::Path {
11451 caminho: "../caixa-teia & ls /*".into(),
11452 });
11453 let err = d.validate().unwrap_err();
11454 assert!(
11455 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11456 "got {err:?}",
11457 );
11458 }
11459
11460 #[test]
11461 fn fonte_caminho_shell_semicolon_fires_before_shell_glob() {
11462 // Cascade pin on the upstream shell-semicolon arm: a value
11463 // carrying both `;` and `*` (`"../caixa-teia; rm *"` — the
11464 // canonical sequential-cleanup + glob paste idiom) routes
11465 // through `FonteCaminhoShellSemicolon` not
11466 // `FonteCaminhoShellGlob`. The sequential-command-separator
11467 // paste is the load-bearing root-cause edit on every
11468 // probe-as-both value.
11469 let d = dep_with_fonte(DepSource::Path {
11470 caminho: "../caixa-teia; rm *".into(),
11471 });
11472 let err = d.validate().unwrap_err();
11473 assert!(
11474 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11475 "got {err:?}",
11476 );
11477 }
11478
11479 #[test]
11480 fn fonte_caminho_shell_pipe_fires_before_shell_glob() {
11481 // Cascade pin on the upstream shell-pipe arm: a value
11482 // carrying both `|` and `*` (`"../caixa-teia | ls *"` — the
11483 // canonical pipeline-to-glob paste idiom) routes through
11484 // `FonteCaminhoShellPipe` not `FonteCaminhoShellGlob`. The
11485 // pipeline-tail paste is the load-bearing root-cause edit
11486 // on every probe-as-both value.
11487 let d = dep_with_fonte(DepSource::Path {
11488 caminho: "../caixa-teia | ls *".into(),
11489 });
11490 let err = d.validate().unwrap_err();
11491 assert!(
11492 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11493 "got {err:?}",
11494 );
11495 }
11496
11497 #[test]
11498 fn fonte_caminho_shell_redirection_fires_before_shell_glob() {
11499 // Cascade pin on the upstream shell-redirection arm: a value
11500 // carrying both `>` and `*` (`"../caixa-teia>log *"` — the
11501 // canonical "I pasted a `cmd > log *` redirect-plus-glob
11502 // chain" footgun) routes through
11503 // `FonteCaminhoShellRedirection` not `FonteCaminhoShellGlob`.
11504 // The input/output redirection metachar carries the more
11505 // self-locating `byte` payload (it names which of `<` or `>`
11506 // triggered), so the prior arm wins on every probe-as-both
11507 // value.
11508 let d = dep_with_fonte(DepSource::Path {
11509 caminho: "../caixa-teia>log *".into(),
11510 });
11511 let err = d.validate().unwrap_err();
11512 assert!(
11513 matches!(
11514 err,
11515 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11516 ),
11517 "got {err:?}",
11518 );
11519 }
11520
11521 #[test]
11522 fn fonte_caminho_backslash_fires_before_shell_glob() {
11523 // Cascade pin on the upstream backslash arm: a value
11524 // carrying both `\` and `*` (`"..\caixa-teia\*"` — the
11525 // canonical "I pasted a Windows-shell `cd ..\path\*` glob
11526 // expression" footgun) routes through
11527 // `FonteCaminhoBackslash` not `FonteCaminhoShellGlob`. The
11528 // cross-host-OS-separator divergence is the load-bearing
11529 // axis on every probe-as-both value (an author who removes
11530 // the `\` is the root-cause edit; the `*` falls away in the
11531 // same edit since it's downstream of the Windows-shell
11532 // convention).
11533 let d = dep_with_fonte(DepSource::Path {
11534 caminho: "..\\caixa-teia\\*".into(),
11535 });
11536 let err = d.validate().unwrap_err();
11537 assert!(
11538 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11539 "got {err:?}",
11540 );
11541 }
11542
11543 #[test]
11544 fn fonte_caminho_control_char_fires_before_shell_glob() {
11545 // Cascade pin on the embedded-control-byte arm: a value
11546 // carrying both a control byte and `*` (`"../foo\n*"` — the
11547 // canonical paste-from-multiline-doc footgun where a
11548 // newline landed mid-caminho between two paste fragments)
11549 // routes through `FonteCaminhoControlChar` not
11550 // `FonteCaminhoShellGlob`. The POSIX-syscall-rejected-byte /
11551 // NUL-`CString::new`-fail diagnostic is the load-bearing
11552 // axis on every value that probes positive for both —
11553 // mirrors the cascade discipline on every prior arm.
11554 let d = dep_with_fonte(DepSource::Path {
11555 caminho: "../foo\n*".into(),
11556 });
11557 let err = d.validate().unwrap_err();
11558 assert!(
11559 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11560 "got {err:?}",
11561 );
11562 }
11563
11564 #[test]
11565 fn fonte_caminho_absolute_fires_before_shell_glob() {
11566 // Cascade pin on the load-bearing leading-byte arm: a
11567 // leading `/` value with embedded `*` (`"/etc/*"`) routes
11568 // through `FonteCaminhoAbsolute` not `FonteCaminhoShellGlob`
11569 // — the host-layout-leak diagnostic is the load-bearing
11570 // axis, the glob byte is the secondary observation. Same
11571 // precedence logic as every prior leading-byte arm.
11572 let d = dep_with_fonte(DepSource::Path {
11573 caminho: "/etc/*".into(),
11574 });
11575 let err = d.validate().unwrap_err();
11576 assert!(
11577 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11578 "got {err:?}",
11579 );
11580 }
11581
11582 #[test]
11583 fn fonte_caminho_shell_glob_fires_before_trailing_slash() {
11584 // Cascade pin on the immediate-successor arm: a value
11585 // carrying both `*` and a trailing `/` (`"../foo*/"` — the
11586 // canonical "I tab-completed a path that already had a
11587 // glob-expansion tail" footgun) routes through
11588 // `FonteCaminhoShellGlob` not `FonteCaminhoTrailingSlash`.
11589 // The embedded shell-metachar is the more semantic-locating
11590 // axis (an author who removes the `*` typically also drops
11591 // the trailing separator since both are paste-from-shell
11592 // artifacts).
11593 let d = dep_with_fonte(DepSource::Path {
11594 caminho: "../foo*/".into(),
11595 });
11596 let err = d.validate().unwrap_err();
11597 assert!(
11598 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11599 "got {err:?}",
11600 );
11601 }
11602
11603 #[test]
11604 fn fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte() {
11605 // Diagnostic-shape pin (peer with
11606 // `fonte_caminho_shell_redirection_diagnostic_*` on the
11607 // closest two-byte peer arm): the error's Display surfaces
11608 // the offending `:nome`, the offending `:caminho` verbatim,
11609 // the offending byte's hex / character form, and names the
11610 // shell-glob / pathname-expansion footgun explicitly so a
11611 // `feira lint` run can render the diagnostic without
11612 // re-parsing.
11613 let d = dep_with_fonte(DepSource::Path {
11614 caminho: "../caixa-teia/*.lisp".into(),
11615 });
11616 let rendered = d.validate().unwrap_err().to_string();
11617 assert!(
11618 rendered.contains("caixa-teia"),
11619 "diagnostic must name the offending dep: {rendered}",
11620 );
11621 assert!(
11622 rendered.contains("../caixa-teia/*.lisp"),
11623 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
11624 );
11625 assert!(
11626 rendered.contains("0x2a"),
11627 "diagnostic must surface the offending byte hex: {rendered:?}",
11628 );
11629 assert!(
11630 rendered.contains("glob"),
11631 "diagnostic must name the shell-glob footgun: {rendered:?}",
11632 );
11633 assert!(
11634 rendered.contains("pathname-expansion"),
11635 "diagnostic must reference the POSIX pathname-expansion vocabulary: {rendered:?}",
11636 );
11637 }
11638
11639 #[test]
11640 fn validate_rejects_path_fonte_with_caminho_carrying_modern_command_substitution() {
11641 // The fail-before-pass-after pin for the canonical modern-Bourne
11642 // command-substitution paste footgun: an author copies a
11643 // `cd ../caixa-teia/$(date)/build` shell-history one-liner whose
11644 // `$(<cmd>)` expansion would land the current date as a
11645 // subdirectory name and silently passed every prior arm
11646 // (`Path::is_absolute` false on `..`, no control bytes, no `\`,
11647 // no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no `*` /
11648 // `?`, doesn't end in `/`; the leading-`$` f4efe9c
11649 // `FonteCaminhoVarExpansion` arm doesn't fire because the `$`
11650 // sits mid-path). The lacre embedded the value verbatim, the
11651 // resolver folded it through `Path::join` looking for a literal
11652 // `./../caixa-teia/$(date)/build` subdirectory, and the failure
11653 // surfaced at resolve time with a non-self-locating `No such
11654 // file or directory` error. The new arm moves the rejection to
11655 // validate time and names the offending dep + caminho + byte
11656 // verbatim. The arm fires on the first `(` encountered (the
11657 // opening byte of `$(date)`).
11658 let d = dep_with_fonte(DepSource::Path {
11659 caminho: "../caixa-teia/$(date)/build".into(),
11660 });
11661 let err = d.validate().unwrap_err();
11662 let DepError::FonteCaminhoShellSubshellGrouping {
11663 nome,
11664 caminho,
11665 byte,
11666 } = err
11667 else {
11668 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11669 };
11670 assert_eq!(nome, "caixa-teia");
11671 assert_eq!(caminho, "../caixa-teia/$(date)/build");
11672 assert_eq!(byte, b'(');
11673 }
11674
11675 #[test]
11676 fn validate_rejects_path_fonte_with_caminho_carrying_close_paren() {
11677 // The symmetric close-paren paste shape (`"../caixa-teia)"` —
11678 // the degenerate "I selected an unbalanced closing paren out of
11679 // a shell-history block" idiom that probes for the cascade's
11680 // last-byte handling on a value carrying only the closing byte).
11681 // Pinned separately from the open-paren shape so the gate's
11682 // contract is "any `(` or `)` anywhere", not single-byte
11683 // coverage. Mirrors the peer `validate_rejects_path_fonte_with_\
11684 // caminho_carrying_question_glob` shape on the immediate-
11685 // predecessor `FonteCaminhoShellGlob` arm.
11686 let d = dep_with_fonte(DepSource::Path {
11687 caminho: "../caixa-teia)".into(),
11688 });
11689 let err = d.validate().unwrap_err();
11690 let DepError::FonteCaminhoShellSubshellGrouping { byte, .. } = err else {
11691 panic!("expected FonteCaminhoShellSubshellGrouping, got {err:?}");
11692 };
11693 assert_eq!(byte, b')');
11694 }
11695
11696 #[test]
11697 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_paren() {
11698 // Leading-position `(` shape (`"(cd foo)/caixa-teia"` — the
11699 // canonical "I selected a `(cd foo)` subshell-grouping prefix
11700 // out of a `(cd foo) && cmd` shell-history one-liner" idiom).
11701 // Pinned separately from the embedded-byte shape so the gate
11702 // covers every position, not only mid-path.
11703 let d = dep_with_fonte(DepSource::Path {
11704 caminho: "(cd foo)/caixa-teia".into(),
11705 });
11706 let err = d.validate().unwrap_err();
11707 assert!(
11708 matches!(
11709 err,
11710 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11711 ),
11712 "got {err:?}",
11713 );
11714 }
11715
11716 #[test]
11717 fn validate_rejects_path_fonte_with_caminho_carrying_balanced_subshell_grouping_pair() {
11718 // The canonical balanced-pair shape (`"../(pwd)/caixa-teia"`
11719 // — the canonical "I copied a `(pwd)` working-directory-probe
11720 // subshell-grouping idiom every shell-history block carries"
11721 // footgun). The value carries no other cascade-preceding
11722 // shell metachar (`&` / `;` / `|` / `<` / `>` / backtick /
11723 // `*` / `?`) so the arm fires on the first `(` encountered;
11724 // pinned so a future arm that tries to distinguish the
11725 // opening from the closing byte doesn't break the broader
11726 // contract. Mirrors the peer
11727 // `validate_rejects_path_fonte_with_caminho_carrying_balanced_\
11728 // backtick_pair` shape on the upstream `FonteCaminhoShell\
11729 // CommandSubstitution` arm.
11730 let d = dep_with_fonte(DepSource::Path {
11731 caminho: "../(pwd)/caixa-teia".into(),
11732 });
11733 let err = d.validate().unwrap_err();
11734 assert!(
11735 matches!(
11736 err,
11737 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11738 ),
11739 "got {err:?}",
11740 );
11741 }
11742
11743 #[test]
11744 fn validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping() {
11745 // The positive-control pin: the gate targets only `(` / `)`,
11746 // never adjacent printable ASCII or POSIX-valid bytes. The
11747 // canonical relative POSIX path (`"../caixa-teia"`) and a
11748 // nested deeply-pathed variant with adjacent printable
11749 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
11750 // validate cleanly so the gate doesn't widen to a "no printable
11751 // punctuation anywhere" sweep that would defeat the entire
11752 // path-fonte author surface.
11753 let d = dep_with_fonte(DepSource::Path {
11754 caminho: "../caixa-teia/sub-dir.v2".into(),
11755 });
11756 d.validate().unwrap();
11757 }
11758
11759 #[test]
11760 fn fonte_caminho_shell_glob_fires_before_shell_subshell_grouping() {
11761 // Cascade pin on the immediate-predecessor arm: a value
11762 // carrying both `*` and `(` (`"../caixa-teia/*(date)"` — the
11763 // canonical "I pasted a glob expansion followed by a
11764 // subshell-grouping tail" footgun) routes through
11765 // `FonteCaminhoShellGlob` not
11766 // `FonteCaminhoShellSubshellGrouping`. The pathname-expansion
11767 // shape is the more common shell-history paste idiom on every
11768 // probe-as-both value — same cascade discipline every prior
11769 // `:caminho` arm establishes.
11770 let d = dep_with_fonte(DepSource::Path {
11771 caminho: "../caixa-teia/*(date)".into(),
11772 });
11773 let err = d.validate().unwrap_err();
11774 assert!(
11775 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
11776 "got {err:?}",
11777 );
11778 }
11779
11780 #[test]
11781 fn fonte_caminho_shell_command_substitution_fires_before_shell_subshell_grouping() {
11782 // Cascade pin on the upstream shell-command-substitution arm: a
11783 // value carrying both a backtick and `(` (``"../`whoami`/$(date)"``
11784 // — the canonical "I pasted a legacy-backtick + modern-paren
11785 // command-substitution chain" footgun) routes through
11786 // `FonteCaminhoShellCommandSubstitution` not
11787 // `FonteCaminhoShellSubshellGrouping`. The CWE-78 shell-
11788 // command-injection vector is the load-bearing root-cause edit
11789 // on every probe-as-both value.
11790 let d = dep_with_fonte(DepSource::Path {
11791 caminho: "../`whoami`/$(date)".into(),
11792 });
11793 let err = d.validate().unwrap_err();
11794 assert!(
11795 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
11796 "got {err:?}",
11797 );
11798 }
11799
11800 #[test]
11801 fn fonte_caminho_shell_background_fires_before_shell_subshell_grouping() {
11802 // Cascade pin on the upstream shell-background arm: a value
11803 // carrying both `&` and `(` (`"../caixa-teia & (cd foo)"` —
11804 // the canonical "I pasted a `cmd & (cd foo)` background-launch
11805 // + subshell-grouping chain" footgun) routes through
11806 // `FonteCaminhoShellBackground` not
11807 // `FonteCaminhoShellSubshellGrouping`. The background-launch
11808 // tail is the load-bearing root-cause edit on every probe-as-
11809 // both value.
11810 let d = dep_with_fonte(DepSource::Path {
11811 caminho: "../caixa-teia & (cd foo)".into(),
11812 });
11813 let err = d.validate().unwrap_err();
11814 assert!(
11815 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
11816 "got {err:?}",
11817 );
11818 }
11819
11820 #[test]
11821 fn fonte_caminho_shell_semicolon_fires_before_shell_subshell_grouping() {
11822 // Cascade pin on the upstream shell-semicolon arm: a value
11823 // carrying both `;` and `(` (`"../caixa-teia; (cd foo)"` —
11824 // the canonical sequential-cleanup + subshell-grouping paste
11825 // idiom) routes through `FonteCaminhoShellSemicolon` not
11826 // `FonteCaminhoShellSubshellGrouping`. The sequential-command-
11827 // separator paste is the load-bearing root-cause edit on
11828 // every probe-as-both value.
11829 let d = dep_with_fonte(DepSource::Path {
11830 caminho: "../caixa-teia; (cd foo)".into(),
11831 });
11832 let err = d.validate().unwrap_err();
11833 assert!(
11834 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
11835 "got {err:?}",
11836 );
11837 }
11838
11839 #[test]
11840 fn fonte_caminho_shell_pipe_fires_before_shell_subshell_grouping() {
11841 // Cascade pin on the upstream shell-pipe arm: a value carrying
11842 // both `|` and `(` (`"../caixa-teia | (tee log)"` — the
11843 // canonical pipeline-to-subshell-grouping paste idiom) routes
11844 // through `FonteCaminhoShellPipe` not
11845 // `FonteCaminhoShellSubshellGrouping`. The pipeline-tail paste
11846 // is the load-bearing root-cause edit on every probe-as-both
11847 // value.
11848 let d = dep_with_fonte(DepSource::Path {
11849 caminho: "../caixa-teia | (tee log)".into(),
11850 });
11851 let err = d.validate().unwrap_err();
11852 assert!(
11853 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
11854 "got {err:?}",
11855 );
11856 }
11857
11858 #[test]
11859 fn fonte_caminho_shell_redirection_fires_before_shell_subshell_grouping() {
11860 // Cascade pin on the upstream shell-redirection arm: a value
11861 // carrying both `>` and `(` (`"../caixa-teia>log (cd foo)"` —
11862 // the canonical "I pasted a `cmd > log (cd foo)` redirect-
11863 // plus-subshell-grouping chain" footgun) routes through
11864 // `FonteCaminhoShellRedirection` not
11865 // `FonteCaminhoShellSubshellGrouping`. The input/output
11866 // redirection metachar carries the more self-locating `byte`
11867 // payload (it names which of `<` or `>` triggered), so the
11868 // prior arm wins on every probe-as-both value.
11869 let d = dep_with_fonte(DepSource::Path {
11870 caminho: "../caixa-teia>log (cd foo)".into(),
11871 });
11872 let err = d.validate().unwrap_err();
11873 assert!(
11874 matches!(
11875 err,
11876 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
11877 ),
11878 "got {err:?}",
11879 );
11880 }
11881
11882 #[test]
11883 fn fonte_caminho_backslash_fires_before_shell_subshell_grouping() {
11884 // Cascade pin on the upstream backslash arm: a value carrying
11885 // both `\` and `(` (`"..\caixa-teia\(cd foo)"` — the canonical
11886 // "I pasted a Windows-shell `cd ..\path\(cmd)` chain") routes
11887 // through `FonteCaminhoBackslash` not
11888 // `FonteCaminhoShellSubshellGrouping`. The cross-host-OS-
11889 // separator divergence is the load-bearing axis on every
11890 // probe-as-both value (an author who removes the `\` is the
11891 // root-cause edit; the `(` falls away in the same edit since
11892 // it's downstream of the Windows-shell convention).
11893 let d = dep_with_fonte(DepSource::Path {
11894 caminho: "..\\caixa-teia\\(cd foo)".into(),
11895 });
11896 let err = d.validate().unwrap_err();
11897 assert!(
11898 matches!(err, DepError::FonteCaminhoBackslash { .. }),
11899 "got {err:?}",
11900 );
11901 }
11902
11903 #[test]
11904 fn fonte_caminho_control_char_fires_before_shell_subshell_grouping() {
11905 // Cascade pin on the embedded-control-byte arm: a value
11906 // carrying both a control byte and `(` (`"../foo\n(cd bar)"` —
11907 // the canonical paste-from-multiline-doc footgun where a
11908 // newline landed mid-caminho between two paste fragments)
11909 // routes through `FonteCaminhoControlChar` not
11910 // `FonteCaminhoShellSubshellGrouping`. The POSIX-syscall-
11911 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
11912 // load-bearing axis on every value that probes positive for
11913 // both — mirrors the cascade discipline on every prior arm.
11914 let d = dep_with_fonte(DepSource::Path {
11915 caminho: "../foo\n(cd bar)".into(),
11916 });
11917 let err = d.validate().unwrap_err();
11918 assert!(
11919 matches!(err, DepError::FonteCaminhoControlChar { .. }),
11920 "got {err:?}",
11921 );
11922 }
11923
11924 #[test]
11925 fn fonte_caminho_absolute_fires_before_shell_subshell_grouping() {
11926 // Cascade pin on the load-bearing leading-byte arm: a leading
11927 // `/` value with embedded `(` (`"/etc/(cd foo)"`) routes
11928 // through `FonteCaminhoAbsolute` not
11929 // `FonteCaminhoShellSubshellGrouping` — the host-layout-leak
11930 // diagnostic is the load-bearing axis, the subshell-grouping
11931 // byte is the secondary observation. Same precedence logic as
11932 // every prior leading-byte arm.
11933 let d = dep_with_fonte(DepSource::Path {
11934 caminho: "/etc/(cd foo)".into(),
11935 });
11936 let err = d.validate().unwrap_err();
11937 assert!(
11938 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
11939 "got {err:?}",
11940 );
11941 }
11942
11943 #[test]
11944 fn fonte_caminho_var_expansion_fires_before_shell_subshell_grouping() {
11945 // Cascade pin on the upstream leading-`$` var-expansion arm: a
11946 // value carrying both a leading `$` and a `(` (`"$(date)/\
11947 // caixa-teia"` — the canonical "I pasted a `$(date)` modern-
11948 // command-substitution at the head of a sibling-workspace
11949 // path" footgun) routes through `FonteCaminhoVarExpansion` not
11950 // `FonteCaminhoShellSubshellGrouping`. The leading-byte
11951 // shell-variable-expansion is the more self-locating diagnostic
11952 // on values that probe as both — same load-bearing-leading-
11953 // byte cascade discipline every prior `:caminho` arm
11954 // establishes. Closing both halves of `$(<cmd>)` structurally
11955 // (leading `$` here, trailing `)` on the new arm) excludes the
11956 // entire modern Bourne command-substitution surface from the
11957 // typed `:caminho` accepted set; the cascade preserves the
11958 // narrower leading-byte diagnostic on values that probe both
11959 // halves at the canonical leading position.
11960 let d = dep_with_fonte(DepSource::Path {
11961 caminho: "$(date)/caixa-teia".into(),
11962 });
11963 let err = d.validate().unwrap_err();
11964 assert!(
11965 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
11966 "got {err:?}",
11967 );
11968 }
11969
11970 #[test]
11971 fn fonte_caminho_shell_subshell_grouping_fires_before_trailing_slash() {
11972 // Cascade pin on the immediate-successor arm: a value carrying
11973 // both `(` and a trailing `/` (`"../(cd foo)/"` — the canonical
11974 // "I tab-completed a path that already had a subshell-grouping
11975 // expansion tail" footgun) routes through
11976 // `FonteCaminhoShellSubshellGrouping` not
11977 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar is
11978 // the more semantic-locating axis (an author who removes the
11979 // `(` typically also drops the trailing separator since both
11980 // are paste-from-shell artifacts).
11981 let d = dep_with_fonte(DepSource::Path {
11982 caminho: "../(cd foo)/".into(),
11983 });
11984 let err = d.validate().unwrap_err();
11985 assert!(
11986 matches!(
11987 err,
11988 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
11989 ),
11990 "got {err:?}",
11991 );
11992 }
11993
11994 #[test]
11995 fn fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
11996 // Diagnostic-shape pin (peer with
11997 // `fonte_caminho_shell_glob_diagnostic_carries_offending_dep_caminho_and_byte`
11998 // on the closest two-byte peer arm): the error's Display
11999 // surfaces the offending `:nome`, the offending `:caminho`
12000 // verbatim, the offending byte's hex / character form, and
12001 // names the shell-subshell-grouping footgun explicitly so a
12002 // `feira lint` run can render the diagnostic without re-
12003 // parsing.
12004 let d = dep_with_fonte(DepSource::Path {
12005 caminho: "../caixa-teia/$(date)/build".into(),
12006 });
12007 let rendered = d.validate().unwrap_err().to_string();
12008 assert!(
12009 rendered.contains("caixa-teia"),
12010 "diagnostic must name the offending dep: {rendered}",
12011 );
12012 assert!(
12013 rendered.contains("../caixa-teia/$(date)/build"),
12014 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12015 );
12016 assert!(
12017 rendered.contains("0x28"),
12018 "diagnostic must surface the offending byte hex: {rendered:?}",
12019 );
12020 assert!(
12021 rendered.contains("subshell-grouping"),
12022 "diagnostic must name the shell-subshell-grouping footgun: {rendered:?}",
12023 );
12024 assert!(
12025 rendered.contains("command-substitution"),
12026 "diagnostic must reference the `$(<cmd>)` command-substitution vocabulary: \
12027 {rendered:?}",
12028 );
12029 }
12030
12031 // ── shell-brace-expansion / URI-Template-placeholder arm ───────────
12032 //
12033 // Peer with the prior `FonteCaminhoShellSubshellGrouping` (`(` /
12034 // `)`) byte-pair arm: the same per-byte cascade with the same
12035 // self-locating `byte: u8` diagnostic on the orthogonal `{` /
12036 // `}` brace-expansion / URI-Template placeholder axis. The peer
12037 // [`crate::render::is_git_repo_url`] (42d8f9d) closes the same
12038 // byte pair on the sibling `:fonte :repo` axis under the same
12039 // banner.
12040
12041 #[test]
12042 fn validate_rejects_path_fonte_with_caminho_carrying_brace_expansion_fan_across_siblings() {
12043 // The fail-before-pass-after pin for the canonical paste-from-
12044 // shell-history brace-expansion footgun: an author copies a
12045 // `cd ../{caixa-teia,caixa-helm}/build` shell-history one-
12046 // liner whose `{a,b}` brace expansion fans across two siblings
12047 // and silently passed every prior arm (`Path::is_absolute`
12048 // false on `..`, no control bytes, no `\`, no `<` / `>`, no
12049 // `|`, no `;`, no `&`, no backtick, no `*` / `?`, no `(` /
12050 // `)`, doesn't end in `/`; the leading-`$` f4efe9c
12051 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12052 // value starts with `..` not `$`). The lacre embedded the
12053 // value verbatim, the resolver folded it through `Path::join`
12054 // looking for a literal `./../{caixa-teia,caixa-helm}/build`
12055 // subdirectory, and the failure surfaced at resolve time with
12056 // a non-self-locating `No such file or directory` error. The
12057 // new arm moves the rejection to validate time and names the
12058 // offending dep + caminho + byte verbatim. The arm fires on
12059 // the first `{` encountered.
12060 let d = dep_with_fonte(DepSource::Path {
12061 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12062 });
12063 let err = d.validate().unwrap_err();
12064 let DepError::FonteCaminhoShellBraceExpansion {
12065 nome,
12066 caminho,
12067 byte,
12068 } = err
12069 else {
12070 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12071 };
12072 assert_eq!(nome, "caixa-teia");
12073 assert_eq!(caminho, "../{caixa-teia,caixa-helm}/build");
12074 assert_eq!(byte, b'{');
12075 }
12076
12077 #[test]
12078 fn validate_rejects_path_fonte_with_caminho_carrying_close_brace() {
12079 // The symmetric close-brace paste shape (`"../caixa-teia}"` —
12080 // the degenerate "I selected an unbalanced closing brace out
12081 // of a shell-history block" idiom that probes for the
12082 // cascade's last-byte handling on a value carrying only the
12083 // closing byte). Pinned separately from the open-brace shape
12084 // so the gate's contract is "any `{` or `}` anywhere", not
12085 // single-byte coverage. Mirrors the peer
12086 // `validate_rejects_path_fonte_with_caminho_carrying_close_paren`
12087 // shape on the immediate-predecessor `FonteCaminhoShellSubshellGrouping`
12088 // arm.
12089 let d = dep_with_fonte(DepSource::Path {
12090 caminho: "../caixa-teia}".into(),
12091 });
12092 let err = d.validate().unwrap_err();
12093 let DepError::FonteCaminhoShellBraceExpansion { byte, .. } = err else {
12094 panic!("expected FonteCaminhoShellBraceExpansion, got {err:?}");
12095 };
12096 assert_eq!(byte, b'}');
12097 }
12098
12099 #[test]
12100 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_brace() {
12101 // Leading-position `{` shape (`"{caixa-teia,caixa-helm}/build"`
12102 // — the canonical "I selected a `{a,b}` brace-expansion prefix
12103 // out of a shell-history one-liner" idiom). Pinned separately
12104 // from the embedded-byte shape so the gate covers every
12105 // position, not only mid-path.
12106 let d = dep_with_fonte(DepSource::Path {
12107 caminho: "{caixa-teia,caixa-helm}/build".into(),
12108 });
12109 let err = d.validate().unwrap_err();
12110 assert!(
12111 matches!(
12112 err,
12113 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12114 ),
12115 "got {err:?}",
12116 );
12117 }
12118
12119 #[test]
12120 fn validate_rejects_path_fonte_with_caminho_carrying_uri_template_placeholder() {
12121 // The canonical URI-Template / Mustache / Helm doubled-brace
12122 // placeholder shape (`"../{{org}}/caixa-teia"` — the canonical
12123 // "I copied a `https://github.com/{{org}}/caixa-teia` README
12124 // quick-start / OpenAPI spec / Helm chart `home:` template
12125 // and forgot to substitute the placeholder" footgun). The arm
12126 // fires on the first `{` encountered; pinned so the gate's
12127 // coverage extends from the bare-brace shell-history shape to
12128 // the doubled-brace URI-Template / templating-engine shape.
12129 // Mirrors the peer 42d8f9d `is_git_repo_url` arm on the
12130 // sibling `:fonte :repo` axis.
12131 let d = dep_with_fonte(DepSource::Path {
12132 caminho: "../{{org}}/caixa-teia".into(),
12133 });
12134 let err = d.validate().unwrap_err();
12135 assert!(
12136 matches!(
12137 err,
12138 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12139 ),
12140 "got {err:?}",
12141 );
12142 }
12143
12144 #[test]
12145 fn validate_rejects_path_fonte_with_caminho_carrying_brace_range_expansion() {
12146 // The canonical bash brace-range-expansion shape (`"../caixa-
12147 // v{1..10}"` — the `{1..10}` sequence expansion every bash /
12148 // zsh `for i in {1..10}; do …; done` idiom uses, the symmetric
12149 // sequence-range form to the `{a,b,c}` comma-separated form).
12150 // The arm fires on the first `{` encountered; pinned so the
12151 // gate's coverage extends from the comma-separated form to
12152 // the integer-range form.
12153 let d = dep_with_fonte(DepSource::Path {
12154 caminho: "../caixa-v{1..10}".into(),
12155 });
12156 let err = d.validate().unwrap_err();
12157 assert!(
12158 matches!(
12159 err,
12160 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12161 ),
12162 "got {err:?}",
12163 );
12164 }
12165
12166 #[test]
12167 fn validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion() {
12168 // The positive-control pin: the gate targets only `{` / `}`,
12169 // never adjacent printable ASCII or POSIX-valid bytes. The
12170 // canonical relative POSIX path (`"../caixa-teia"`) and a
12171 // nested deeply-pathed variant with adjacent printable
12172 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue to
12173 // validate cleanly so the gate doesn't widen to a "no
12174 // printable punctuation anywhere" sweep that would defeat
12175 // the entire path-fonte author surface. Peer with
12176 // `validate_accepts_path_fonte_with_caminho_carrying_no_subshell_grouping`
12177 // on the immediate-predecessor arm.
12178 let d = dep_with_fonte(DepSource::Path {
12179 caminho: "../caixa-teia/sub-dir.v2".into(),
12180 });
12181 d.validate().unwrap();
12182 }
12183
12184 #[test]
12185 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_brace_expansion() {
12186 // Cascade pin on the immediate-predecessor arm: a value
12187 // carrying both `(` and `{` (`"../(cd foo)/{a,b}"` — the
12188 // canonical "I pasted a subshell-grouping followed by a
12189 // brace-expansion tail" footgun) routes through
12190 // `FonteCaminhoShellSubshellGrouping` not
12191 // `FonteCaminhoShellBraceExpansion`. The subshell-grouping
12192 // shape is the more semantic-locating axis on every probe-
12193 // as-both value because it closes both halves of the modern
12194 // Bourne `$(<cmd>)` command-substitution surface — same
12195 // cascade discipline every prior `:caminho` arm establishes.
12196 let d = dep_with_fonte(DepSource::Path {
12197 caminho: "../(cd foo)/{a,b}".into(),
12198 });
12199 let err = d.validate().unwrap_err();
12200 assert!(
12201 matches!(
12202 err,
12203 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12204 ),
12205 "got {err:?}",
12206 );
12207 }
12208
12209 #[test]
12210 fn fonte_caminho_shell_glob_fires_before_shell_brace_expansion() {
12211 // Cascade pin on the upstream shell-glob arm: a value carrying
12212 // both `*` and `{` (`"../caixa-teia/*{a,b}"` — the canonical
12213 // "I pasted a glob expansion followed by a brace-expansion
12214 // tail" footgun) routes through `FonteCaminhoShellGlob` not
12215 // `FonteCaminhoShellBraceExpansion`. The pathname-expansion
12216 // shape is the load-bearing root-cause edit on every
12217 // probe-as-both value.
12218 let d = dep_with_fonte(DepSource::Path {
12219 caminho: "../caixa-teia/*{a,b}".into(),
12220 });
12221 let err = d.validate().unwrap_err();
12222 assert!(
12223 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12224 "got {err:?}",
12225 );
12226 }
12227
12228 #[test]
12229 fn fonte_caminho_shell_command_substitution_fires_before_shell_brace_expansion() {
12230 // Cascade pin on the upstream shell-command-substitution arm:
12231 // a value carrying both a backtick and `{` (``"../`whoami`/{a,b}"``
12232 // — the canonical "I pasted a legacy-backtick command-
12233 // substitution followed by a brace-expansion fan-out" footgun)
12234 // routes through `FonteCaminhoShellCommandSubstitution` not
12235 // `FonteCaminhoShellBraceExpansion`. The CWE-78 shell-
12236 // command-injection vector is the load-bearing root-cause
12237 // edit on every probe-as-both value.
12238 let d = dep_with_fonte(DepSource::Path {
12239 caminho: "../`whoami`/{a,b}".into(),
12240 });
12241 let err = d.validate().unwrap_err();
12242 assert!(
12243 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12244 "got {err:?}",
12245 );
12246 }
12247
12248 #[test]
12249 fn fonte_caminho_shell_background_fires_before_shell_brace_expansion() {
12250 // Cascade pin on the upstream shell-background arm: a value
12251 // carrying both `&` and `{` (`"../caixa-teia & {a,b}"` — the
12252 // canonical "I pasted a `cmd & {fork-fan}` background-launch
12253 // + brace-expansion chain" footgun) routes through
12254 // `FonteCaminhoShellBackground` not
12255 // `FonteCaminhoShellBraceExpansion`. The background-launch
12256 // tail is the load-bearing root-cause edit on every
12257 // probe-as-both value.
12258 let d = dep_with_fonte(DepSource::Path {
12259 caminho: "../caixa-teia & {a,b}".into(),
12260 });
12261 let err = d.validate().unwrap_err();
12262 assert!(
12263 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12264 "got {err:?}",
12265 );
12266 }
12267
12268 #[test]
12269 fn fonte_caminho_shell_semicolon_fires_before_shell_brace_expansion() {
12270 // Cascade pin on the upstream shell-semicolon arm: a value
12271 // carrying both `;` and `{` (`"../caixa-teia; {a,b}"` — the
12272 // canonical sequential-cleanup + brace-expansion paste
12273 // idiom) routes through `FonteCaminhoShellSemicolon` not
12274 // `FonteCaminhoShellBraceExpansion`. The sequential-command-
12275 // separator paste is the load-bearing root-cause edit on
12276 // every probe-as-both value.
12277 let d = dep_with_fonte(DepSource::Path {
12278 caminho: "../caixa-teia; {a,b}".into(),
12279 });
12280 let err = d.validate().unwrap_err();
12281 assert!(
12282 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12283 "got {err:?}",
12284 );
12285 }
12286
12287 #[test]
12288 fn fonte_caminho_shell_pipe_fires_before_shell_brace_expansion() {
12289 // Cascade pin on the upstream shell-pipe arm: a value
12290 // carrying both `|` and `{` (`"../caixa-teia | {tee,cat}"`
12291 // — the canonical pipeline-to-brace-expansion paste idiom)
12292 // routes through `FonteCaminhoShellPipe` not
12293 // `FonteCaminhoShellBraceExpansion`. The pipeline-tail paste
12294 // is the load-bearing root-cause edit on every probe-as-
12295 // both value.
12296 let d = dep_with_fonte(DepSource::Path {
12297 caminho: "../caixa-teia | {tee,cat}".into(),
12298 });
12299 let err = d.validate().unwrap_err();
12300 assert!(
12301 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12302 "got {err:?}",
12303 );
12304 }
12305
12306 #[test]
12307 fn fonte_caminho_shell_redirection_fires_before_shell_brace_expansion() {
12308 // Cascade pin on the upstream shell-redirection arm: a value
12309 // carrying both `>` and `{` (`"../caixa-teia>log {a,b}"` —
12310 // the canonical "I pasted a `cmd > log {a,b}` redirect-
12311 // plus-brace-expansion chain" footgun) routes through
12312 // `FonteCaminhoShellRedirection` not
12313 // `FonteCaminhoShellBraceExpansion`. The input/output
12314 // redirection metachar carries the more self-locating
12315 // `byte` payload, so the prior arm wins on every probe-
12316 // as-both value.
12317 let d = dep_with_fonte(DepSource::Path {
12318 caminho: "../caixa-teia>log {a,b}".into(),
12319 });
12320 let err = d.validate().unwrap_err();
12321 assert!(
12322 matches!(
12323 err,
12324 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12325 ),
12326 "got {err:?}",
12327 );
12328 }
12329
12330 #[test]
12331 fn fonte_caminho_backslash_fires_before_shell_brace_expansion() {
12332 // Cascade pin on the upstream backslash arm: a value
12333 // carrying both `\` and `{` (`"..\caixa-teia\{a,b}"` — the
12334 // canonical "I pasted a Windows-shell `cd ..\path\{a,b}`
12335 // chain") routes through `FonteCaminhoBackslash` not
12336 // `FonteCaminhoShellBraceExpansion`. The cross-host-OS-
12337 // separator divergence is the load-bearing axis on every
12338 // probe-as-both value.
12339 let d = dep_with_fonte(DepSource::Path {
12340 caminho: "..\\caixa-teia\\{a,b}".into(),
12341 });
12342 let err = d.validate().unwrap_err();
12343 assert!(
12344 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12345 "got {err:?}",
12346 );
12347 }
12348
12349 #[test]
12350 fn fonte_caminho_control_char_fires_before_shell_brace_expansion() {
12351 // Cascade pin on the embedded-control-byte arm: a value
12352 // carrying both a control byte and `{` (`"../foo\n{a,b}"` —
12353 // the canonical paste-from-multiline-doc footgun where a
12354 // newline landed mid-caminho between two paste fragments)
12355 // routes through `FonteCaminhoControlChar` not
12356 // `FonteCaminhoShellBraceExpansion`. The POSIX-syscall-
12357 // rejected-byte / NUL-`CString::new`-fail diagnostic is the
12358 // load-bearing axis on every value that probes positive for
12359 // both — mirrors the cascade discipline on every prior arm.
12360 let d = dep_with_fonte(DepSource::Path {
12361 caminho: "../foo\n{a,b}".into(),
12362 });
12363 let err = d.validate().unwrap_err();
12364 assert!(
12365 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12366 "got {err:?}",
12367 );
12368 }
12369
12370 #[test]
12371 fn fonte_caminho_absolute_fires_before_shell_brace_expansion() {
12372 // Cascade pin on the load-bearing leading-byte arm: a
12373 // leading `/` value with embedded `{` (`"/etc/{a,b}"`)
12374 // routes through `FonteCaminhoAbsolute` not
12375 // `FonteCaminhoShellBraceExpansion` — the host-layout-leak
12376 // diagnostic is the load-bearing axis, the brace-expansion
12377 // byte is the secondary observation. Same precedence logic
12378 // as every prior leading-byte arm.
12379 let d = dep_with_fonte(DepSource::Path {
12380 caminho: "/etc/{a,b}".into(),
12381 });
12382 let err = d.validate().unwrap_err();
12383 assert!(
12384 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12385 "got {err:?}",
12386 );
12387 }
12388
12389 #[test]
12390 fn fonte_caminho_var_expansion_fires_before_shell_brace_expansion() {
12391 // Cascade pin on the upstream leading-`$` var-expansion
12392 // arm: a value carrying both a leading `$` and a `{`
12393 // (`"${ORG}/caixa-teia"` — the canonical "I pasted a
12394 // `${ORG}` shell-variable + curly-brace expansion at the
12395 // head of a sibling-workspace path" footgun) routes through
12396 // `FonteCaminhoVarExpansion` not
12397 // `FonteCaminhoShellBraceExpansion`. The leading-byte
12398 // shell-variable-expansion is the more self-locating
12399 // diagnostic on values that probe as both — same
12400 // load-bearing-leading-byte cascade discipline every prior
12401 // `:caminho` arm establishes.
12402 let d = dep_with_fonte(DepSource::Path {
12403 caminho: "${ORG}/caixa-teia".into(),
12404 });
12405 let err = d.validate().unwrap_err();
12406 assert!(
12407 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12408 "got {err:?}",
12409 );
12410 }
12411
12412 #[test]
12413 fn fonte_caminho_shell_brace_expansion_fires_before_trailing_slash() {
12414 // Cascade pin on the immediate-successor arm: a value
12415 // carrying both `{` and a trailing `/`
12416 // (`"../{caixa-teia,caixa-helm}/"` — the canonical "I
12417 // tab-completed a path that already had a brace-expansion
12418 // expansion tail" footgun) routes through
12419 // `FonteCaminhoShellBraceExpansion` not
12420 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12421 // is the more semantic-locating axis (an author who removes
12422 // the `{` typically also drops the trailing separator since
12423 // both are paste-from-shell artifacts).
12424 let d = dep_with_fonte(DepSource::Path {
12425 caminho: "../{caixa-teia,caixa-helm}/".into(),
12426 });
12427 let err = d.validate().unwrap_err();
12428 assert!(
12429 matches!(
12430 err,
12431 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12432 ),
12433 "got {err:?}",
12434 );
12435 }
12436
12437 #[test]
12438 fn fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12439 // Diagnostic-shape pin (peer with
12440 // `fonte_caminho_shell_subshell_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
12441 // on the closest two-byte peer arm): the error's Display
12442 // surfaces the offending `:nome`, the offending `:caminho`
12443 // verbatim, the offending byte's hex / character form, and
12444 // names the shell-brace-expansion / URI-Template footgun
12445 // explicitly so a `feira lint` run can render the diagnostic
12446 // without re-parsing.
12447 let d = dep_with_fonte(DepSource::Path {
12448 caminho: "../{caixa-teia,caixa-helm}/build".into(),
12449 });
12450 let rendered = d.validate().unwrap_err().to_string();
12451 assert!(
12452 rendered.contains("caixa-teia"),
12453 "diagnostic must name the offending dep: {rendered}",
12454 );
12455 assert!(
12456 rendered.contains("../{caixa-teia,caixa-helm}/build"),
12457 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12458 );
12459 assert!(
12460 rendered.contains("0x7b"),
12461 "diagnostic must surface the offending byte hex: {rendered:?}",
12462 );
12463 assert!(
12464 rendered.contains("brace-expansion"),
12465 "diagnostic must name the shell-brace-expansion footgun: {rendered:?}",
12466 );
12467 assert!(
12468 rendered.contains("URI Template"),
12469 "diagnostic must reference the RFC-6570 URI-Template-placeholder vocabulary: \
12470 {rendered:?}",
12471 );
12472 }
12473
12474 #[test]
12475 fn validate_rejects_path_fonte_with_caminho_carrying_bracket_glob_character_class() {
12476 // The canonical paste-from-shell-history bracket-glob /
12477 // character-class footgun: an author copies a
12478 // `cd ../caixa-[a-z]/build` shell-history one-liner whose
12479 // `[a-z]` POSIX glob character-class matches every lowercase-
12480 // ASCII-suffix sibling caixa directory and silently passed
12481 // every prior arm (`Path::is_absolute` false on `..`, no
12482 // control bytes, no `\`, no `<` / `>`, no `|`, no `;`, no
12483 // `&`, no backtick, no `*` / `?`, no `(` / `)`, no `{` /
12484 // `}`, doesn't end in `/`; the leading-`$` f4efe9c
12485 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12486 // value starts with `..` not `$`). The lacre embedded the
12487 // value verbatim, the resolver folded it through
12488 // `Path::join` looking for a literal `./../caixa-[a-z]/
12489 // build` subdirectory, and the failure surfaced at resolve
12490 // time with a non-self-locating `No such file or directory`
12491 // error. The new arm moves the rejection to validate time
12492 // and names the offending dep + caminho + byte verbatim.
12493 // The arm fires on the first `[` encountered.
12494 let d = dep_with_fonte(DepSource::Path {
12495 caminho: "../caixa-[a-z]/build".into(),
12496 });
12497 let err = d.validate().unwrap_err();
12498 let DepError::FonteCaminhoShellBracketExpansion {
12499 nome,
12500 caminho,
12501 byte,
12502 } = err
12503 else {
12504 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12505 };
12506 assert_eq!(nome, "caixa-teia");
12507 assert_eq!(caminho, "../caixa-[a-z]/build");
12508 assert_eq!(byte, b'[');
12509 }
12510
12511 #[test]
12512 fn validate_rejects_path_fonte_with_caminho_carrying_close_bracket() {
12513 // The symmetric close-bracket paste shape (`"../caixa-teia]"`
12514 // — the degenerate "I selected an unbalanced closing bracket
12515 // out of a glob character-class block" idiom that probes for
12516 // the cascade's last-byte handling on a value carrying only
12517 // the closing byte). Pinned separately from the open-bracket
12518 // shape so the gate's contract is "any `[` or `]` anywhere",
12519 // not single-byte coverage. Mirrors the peer
12520 // `validate_rejects_path_fonte_with_caminho_carrying_close_brace`
12521 // shape on the immediate-predecessor
12522 // `FonteCaminhoShellBraceExpansion` arm.
12523 let d = dep_with_fonte(DepSource::Path {
12524 caminho: "../caixa-teia]".into(),
12525 });
12526 let err = d.validate().unwrap_err();
12527 let DepError::FonteCaminhoShellBracketExpansion { byte, .. } = err else {
12528 panic!("expected FonteCaminhoShellBracketExpansion, got {err:?}");
12529 };
12530 assert_eq!(byte, b']');
12531 }
12532
12533 #[test]
12534 fn validate_rejects_path_fonte_with_caminho_carrying_leading_open_bracket() {
12535 // Leading-position `[` shape (`"[caixa-teia]/build"` — the
12536 // canonical "I selected a `[caixa-teia]` TOML-table-header /
12537 // glob-character-class prefix out of an aligned config /
12538 // shell-history one-liner" idiom). Pinned separately from
12539 // the embedded-byte shape so the gate covers every position,
12540 // not only mid-path.
12541 let d = dep_with_fonte(DepSource::Path {
12542 caminho: "[caixa-teia]/build".into(),
12543 });
12544 let err = d.validate().unwrap_err();
12545 assert!(
12546 matches!(
12547 err,
12548 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12549 ),
12550 "got {err:?}",
12551 );
12552 }
12553
12554 #[test]
12555 fn validate_rejects_path_fonte_with_caminho_carrying_toml_inline_array() {
12556 // The canonical TOML inline-array / YAML flow-sequence
12557 // paste shape (`"../[\"a\", \"b\"]/caixa-teia"` — the
12558 // canonical "I copied a `features = [\"a\", \"b\"]` TOML
12559 // inline-array out of a sibling-Cargo manifest" cross-idiom
12560 // leak; the symmetric YAML flow-sequence form `paths: [/a,
12561 // /b]` paste-from-values.yaml shape carries the same
12562 // bracket pair). The arm fires on the first `[` encountered;
12563 // pinned so the gate's coverage extends from the bare-
12564 // bracket glob-character-class shape to the TOML / YAML /
12565 // JSON array-literal shape.
12566 let d = dep_with_fonte(DepSource::Path {
12567 caminho: "../[\"a\", \"b\"]/caixa-teia".into(),
12568 });
12569 let err = d.validate().unwrap_err();
12570 assert!(
12571 matches!(
12572 err,
12573 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12574 ),
12575 "got {err:?}",
12576 );
12577 }
12578
12579 #[test]
12580 fn validate_rejects_path_fonte_with_caminho_carrying_shell_test_builtin() {
12581 // The canonical POSIX `test` / `[` builtin command paste
12582 // shape (`"../[ -d caixa-teia ]"` — the `[ <expr> ]` shell-
12583 // script conditional every paste-from-shell-script idiom
12584 // carries; bash's `[[ <expr> ]]` extended-test grammar
12585 // would surface the same byte pair). The arm fires on the
12586 // first `[` encountered; pinned so the gate's coverage
12587 // extends from the embedded-glob-character-class shape to
12588 // the leading-`test`-builtin / extended-test form.
12589 let d = dep_with_fonte(DepSource::Path {
12590 caminho: "../[ -d caixa-teia ]".into(),
12591 });
12592 let err = d.validate().unwrap_err();
12593 assert!(
12594 matches!(
12595 err,
12596 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12597 ),
12598 "got {err:?}",
12599 );
12600 }
12601
12602 #[test]
12603 fn validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion() {
12604 // The positive-control pin: the gate targets only `[` /
12605 // `]`, never adjacent printable ASCII or POSIX-valid bytes.
12606 // The canonical relative POSIX path (`"../caixa-teia"`) and
12607 // a nested deeply-pathed variant with adjacent printable
12608 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
12609 // to validate cleanly so the gate doesn't widen to a "no
12610 // printable punctuation anywhere" sweep that would defeat
12611 // the entire path-fonte author surface. Peer with
12612 // `validate_accepts_path_fonte_with_caminho_carrying_no_brace_expansion`
12613 // on the immediate-predecessor arm.
12614 let d = dep_with_fonte(DepSource::Path {
12615 caminho: "../caixa-teia/sub-dir.v2".into(),
12616 });
12617 d.validate().unwrap();
12618 }
12619
12620 #[test]
12621 fn fonte_caminho_shell_brace_expansion_fires_before_shell_bracket_expansion() {
12622 // Cascade pin on the immediate-predecessor arm: a value
12623 // carrying both `{` and `[` (`"../{a,b}[ch]"` — the
12624 // canonical "I pasted a brace-expansion fan followed by a
12625 // glob-character-class tail" footgun) routes through
12626 // `FonteCaminhoShellBraceExpansion` not
12627 // `FonteCaminhoShellBracketExpansion`. The brace-expansion
12628 // fan is the load-bearing root-cause edit on every
12629 // probe-as-both value because the bracket-class tail
12630 // typically rides on a prior brace-expansion expansion;
12631 // same cascade discipline every prior `:caminho` arm
12632 // establishes.
12633 let d = dep_with_fonte(DepSource::Path {
12634 caminho: "../{a,b}[ch]".into(),
12635 });
12636 let err = d.validate().unwrap_err();
12637 assert!(
12638 matches!(
12639 err,
12640 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
12641 ),
12642 "got {err:?}",
12643 );
12644 }
12645
12646 #[test]
12647 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_bracket_expansion() {
12648 // Cascade pin on the upstream shell-subshell-grouping arm:
12649 // a value carrying both `(` and `[` (`"../(cd foo)/[ch]"` —
12650 // the canonical "I pasted a subshell-grouping followed by
12651 // a glob-character-class tail" footgun) routes through
12652 // `FonteCaminhoShellSubshellGrouping` not
12653 // `FonteCaminhoShellBracketExpansion`. The modern Bourne
12654 // `$(<cmd>)` command-substitution boundary is the load-
12655 // bearing axis on every probe-as-both value.
12656 let d = dep_with_fonte(DepSource::Path {
12657 caminho: "../(cd foo)/[ch]".into(),
12658 });
12659 let err = d.validate().unwrap_err();
12660 assert!(
12661 matches!(
12662 err,
12663 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
12664 ),
12665 "got {err:?}",
12666 );
12667 }
12668
12669 #[test]
12670 fn fonte_caminho_shell_glob_fires_before_shell_bracket_expansion() {
12671 // Cascade pin on the upstream shell-glob arm: a value
12672 // carrying both `*` and `[` (`"../caixa-teia/*[ch]"` — the
12673 // canonical "I pasted a `*.[ch]` C-source-file glob whose
12674 // unbounded `*` precedes the bracket character-class"
12675 // footgun) routes through `FonteCaminhoShellGlob` not
12676 // `FonteCaminhoShellBracketExpansion`. The unbounded
12677 // pathname-expansion sentinel is the load-bearing root-
12678 // cause edit on every probe-as-both value — the unbounded
12679 // `*` carries the more aggressive expansion vector than
12680 // the bounded `[ch]` class, so the prior arm wins.
12681 let d = dep_with_fonte(DepSource::Path {
12682 caminho: "../caixa-teia/*[ch]".into(),
12683 });
12684 let err = d.validate().unwrap_err();
12685 assert!(
12686 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
12687 "got {err:?}",
12688 );
12689 }
12690
12691 #[test]
12692 fn fonte_caminho_shell_command_substitution_fires_before_shell_bracket_expansion() {
12693 // Cascade pin on the upstream shell-command-substitution
12694 // arm: a value carrying both a backtick and `[`
12695 // (``"../`whoami`/[ch]"`` — the canonical "I pasted a
12696 // legacy-backtick command-substitution followed by a
12697 // glob-character-class tail" footgun) routes through
12698 // `FonteCaminhoShellCommandSubstitution` not
12699 // `FonteCaminhoShellBracketExpansion`. The CWE-78 shell-
12700 // command-injection vector is the load-bearing root-cause
12701 // edit on every probe-as-both value.
12702 let d = dep_with_fonte(DepSource::Path {
12703 caminho: "../`whoami`/[ch]".into(),
12704 });
12705 let err = d.validate().unwrap_err();
12706 assert!(
12707 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
12708 "got {err:?}",
12709 );
12710 }
12711
12712 #[test]
12713 fn fonte_caminho_shell_background_fires_before_shell_bracket_expansion() {
12714 // Cascade pin on the upstream shell-background arm: a
12715 // value carrying both `&` and `[` (`"../caixa-teia & [ch]"`
12716 // — the canonical "I pasted a `cmd & [glob]` background-
12717 // launch + bracket-class chain" footgun) routes through
12718 // `FonteCaminhoShellBackground` not
12719 // `FonteCaminhoShellBracketExpansion`. The background-
12720 // launch tail is the load-bearing root-cause edit on
12721 // every probe-as-both value.
12722 let d = dep_with_fonte(DepSource::Path {
12723 caminho: "../caixa-teia & [ch]".into(),
12724 });
12725 let err = d.validate().unwrap_err();
12726 assert!(
12727 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
12728 "got {err:?}",
12729 );
12730 }
12731
12732 #[test]
12733 fn fonte_caminho_shell_semicolon_fires_before_shell_bracket_expansion() {
12734 // Cascade pin on the upstream shell-semicolon arm: a value
12735 // carrying both `;` and `[` (`"../caixa-teia; [ch]"` — the
12736 // canonical sequential-cleanup + bracket-class paste
12737 // idiom) routes through `FonteCaminhoShellSemicolon` not
12738 // `FonteCaminhoShellBracketExpansion`. The sequential-
12739 // command-separator paste is the load-bearing root-cause
12740 // edit on every probe-as-both value.
12741 let d = dep_with_fonte(DepSource::Path {
12742 caminho: "../caixa-teia; [ch]".into(),
12743 });
12744 let err = d.validate().unwrap_err();
12745 assert!(
12746 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
12747 "got {err:?}",
12748 );
12749 }
12750
12751 #[test]
12752 fn fonte_caminho_shell_pipe_fires_before_shell_bracket_expansion() {
12753 // Cascade pin on the upstream shell-pipe arm: a value
12754 // carrying both `|` and `[` (`"../caixa-teia | [tee]"` —
12755 // the canonical pipeline-to-bracket-class paste idiom)
12756 // routes through `FonteCaminhoShellPipe` not
12757 // `FonteCaminhoShellBracketExpansion`. The pipeline-tail
12758 // paste is the load-bearing root-cause edit on every
12759 // probe-as-both value.
12760 let d = dep_with_fonte(DepSource::Path {
12761 caminho: "../caixa-teia | [tee]".into(),
12762 });
12763 let err = d.validate().unwrap_err();
12764 assert!(
12765 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
12766 "got {err:?}",
12767 );
12768 }
12769
12770 #[test]
12771 fn fonte_caminho_shell_redirection_fires_before_shell_bracket_expansion() {
12772 // Cascade pin on the upstream shell-redirection arm: a
12773 // value carrying both `>` and `[` (`"../caixa-teia>log
12774 // [ch]"` — the canonical "I pasted a `cmd > log [glob]`
12775 // redirect-plus-bracket chain" footgun) routes through
12776 // `FonteCaminhoShellRedirection` not
12777 // `FonteCaminhoShellBracketExpansion`. The input/output
12778 // redirection metachar carries the more self-locating
12779 // `byte` payload, so the prior arm wins on every
12780 // probe-as-both value.
12781 let d = dep_with_fonte(DepSource::Path {
12782 caminho: "../caixa-teia>log [ch]".into(),
12783 });
12784 let err = d.validate().unwrap_err();
12785 assert!(
12786 matches!(
12787 err,
12788 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
12789 ),
12790 "got {err:?}",
12791 );
12792 }
12793
12794 #[test]
12795 fn fonte_caminho_backslash_fires_before_shell_bracket_expansion() {
12796 // Cascade pin on the upstream backslash arm: a value
12797 // carrying both `\` and `[` (`"..\caixa-teia\[ch]"` — the
12798 // canonical "I pasted a Windows-shell `cd ..\path\[glob]`
12799 // chain") routes through `FonteCaminhoBackslash` not
12800 // `FonteCaminhoShellBracketExpansion`. The cross-host-OS-
12801 // separator divergence is the load-bearing axis on every
12802 // probe-as-both value.
12803 let d = dep_with_fonte(DepSource::Path {
12804 caminho: "..\\caixa-teia\\[ch]".into(),
12805 });
12806 let err = d.validate().unwrap_err();
12807 assert!(
12808 matches!(err, DepError::FonteCaminhoBackslash { .. }),
12809 "got {err:?}",
12810 );
12811 }
12812
12813 #[test]
12814 fn fonte_caminho_control_char_fires_before_shell_bracket_expansion() {
12815 // Cascade pin on the embedded-control-byte arm: a value
12816 // carrying both a control byte and `[` (`"../foo\n[ch]"` —
12817 // the canonical paste-from-multiline-doc footgun where a
12818 // newline landed mid-caminho between two paste fragments)
12819 // routes through `FonteCaminhoControlChar` not
12820 // `FonteCaminhoShellBracketExpansion`. The POSIX-syscall-
12821 // rejected-byte / NUL-`CString::new`-fail diagnostic is
12822 // the load-bearing axis on every value that probes
12823 // positive for both — mirrors the cascade discipline on
12824 // every prior arm.
12825 let d = dep_with_fonte(DepSource::Path {
12826 caminho: "../foo\n[ch]".into(),
12827 });
12828 let err = d.validate().unwrap_err();
12829 assert!(
12830 matches!(err, DepError::FonteCaminhoControlChar { .. }),
12831 "got {err:?}",
12832 );
12833 }
12834
12835 #[test]
12836 fn fonte_caminho_absolute_fires_before_shell_bracket_expansion() {
12837 // Cascade pin on the load-bearing leading-byte arm: a
12838 // leading `/` value with embedded `[` (`"/etc/[ch]"`)
12839 // routes through `FonteCaminhoAbsolute` not
12840 // `FonteCaminhoShellBracketExpansion` — the host-layout-
12841 // leak diagnostic is the load-bearing axis, the bracket-
12842 // expansion byte is the secondary observation. Same
12843 // precedence logic as every prior leading-byte arm.
12844 let d = dep_with_fonte(DepSource::Path {
12845 caminho: "/etc/[ch]".into(),
12846 });
12847 let err = d.validate().unwrap_err();
12848 assert!(
12849 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
12850 "got {err:?}",
12851 );
12852 }
12853
12854 #[test]
12855 fn fonte_caminho_var_expansion_fires_before_shell_bracket_expansion() {
12856 // Cascade pin on the upstream leading-`$` var-expansion
12857 // arm: a value carrying both a leading `$` and a `[`
12858 // (`"$DIR/[ch]"` — the canonical "I pasted a `$DIR` shell-
12859 // variable + bracket-class at the head of a sibling-
12860 // workspace path" footgun) routes through
12861 // `FonteCaminhoVarExpansion` not
12862 // `FonteCaminhoShellBracketExpansion`. The leading-byte
12863 // shell-variable-expansion is the more self-locating
12864 // diagnostic on values that probe as both — same
12865 // load-bearing-leading-byte cascade discipline every
12866 // prior `:caminho` arm establishes.
12867 let d = dep_with_fonte(DepSource::Path {
12868 caminho: "$DIR/[ch]".into(),
12869 });
12870 let err = d.validate().unwrap_err();
12871 assert!(
12872 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
12873 "got {err:?}",
12874 );
12875 }
12876
12877 #[test]
12878 fn fonte_caminho_shell_bracket_expansion_fires_before_trailing_slash() {
12879 // Cascade pin on the immediate-successor arm: a value
12880 // carrying both `[` and a trailing `/` (`"../[a-z]/"` —
12881 // the canonical "I tab-completed a path that already had
12882 // a bracket-glob-character-class expansion tail" footgun)
12883 // routes through `FonteCaminhoShellBracketExpansion` not
12884 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
12885 // is the more semantic-locating axis (an author who
12886 // removes the `[` typically also drops the trailing
12887 // separator since both are paste-from-shell artifacts).
12888 let d = dep_with_fonte(DepSource::Path {
12889 caminho: "../[a-z]/".into(),
12890 });
12891 let err = d.validate().unwrap_err();
12892 assert!(
12893 matches!(
12894 err,
12895 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
12896 ),
12897 "got {err:?}",
12898 );
12899 }
12900
12901 #[test]
12902 fn fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
12903 // Diagnostic-shape pin (peer with
12904 // `fonte_caminho_shell_brace_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
12905 // on the closest two-byte peer arm): the error's Display
12906 // surfaces the offending `:nome`, the offending `:caminho`
12907 // verbatim, the offending byte's hex / character form, and
12908 // names the shell-bracket-expansion / glob-character-class
12909 // footgun explicitly so a `feira lint` run can render the
12910 // diagnostic without re-parsing.
12911 let d = dep_with_fonte(DepSource::Path {
12912 caminho: "../caixa-[a-z]/build".into(),
12913 });
12914 let rendered = d.validate().unwrap_err().to_string();
12915 assert!(
12916 rendered.contains("caixa-teia"),
12917 "diagnostic must name the offending dep: {rendered}",
12918 );
12919 assert!(
12920 rendered.contains("../caixa-[a-z]/build"),
12921 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
12922 );
12923 assert!(
12924 rendered.contains("0x5b"),
12925 "diagnostic must surface the offending byte hex: {rendered:?}",
12926 );
12927 assert!(
12928 rendered.contains("bracket-expansion"),
12929 "diagnostic must name the shell-bracket-expansion footgun: {rendered:?}",
12930 );
12931 assert!(
12932 rendered.contains("glob-character-class"),
12933 "diagnostic must reference the POSIX glob-character-class vocabulary: \
12934 {rendered:?}",
12935 );
12936 }
12937
12938 #[test]
12939 fn validate_rejects_path_fonte_with_caminho_carrying_single_quote_grouping() {
12940 // The canonical paste-from-shell-history strong-quoted
12941 // sibling-workspace-path footgun: an author copies a
12942 // `cd '../caixa-teia'` shell-history one-liner whose strong-
12943 // quoting preserved the path across a whitespace paste
12944 // boundary and silently passed every prior arm
12945 // (`Path::is_absolute` false on `'..`, no control bytes, no
12946 // `\`, no `<` / `>`, no `|`, no `;`, no `&`, no backtick, no
12947 // `*` / `?`, no `(` / `)`, no `{` / `}`, no `[` / `]`,
12948 // doesn't end in `/`; the leading-`$` f4efe9c
12949 // `FonteCaminhoVarExpansion` arm doesn't fire because the
12950 // value starts with `'` not `$`). The lacre embedded the
12951 // value verbatim, the resolver folded it through
12952 // `Path::join` looking for a literal `./'../caixa-teia'`
12953 // subdirectory, and the failure surfaced at resolve time
12954 // with a non-self-locating `No such file or directory`
12955 // error. The new arm moves the rejection to validate time
12956 // and names the offending dep + caminho + byte verbatim.
12957 // The arm fires on the first `'` encountered.
12958 let d = dep_with_fonte(DepSource::Path {
12959 caminho: "'../caixa-teia'".into(),
12960 });
12961 let err = d.validate().unwrap_err();
12962 let DepError::FonteCaminhoShellQuoteGrouping {
12963 nome,
12964 caminho,
12965 byte,
12966 } = err
12967 else {
12968 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12969 };
12970 assert_eq!(nome, "caixa-teia");
12971 assert_eq!(caminho, "'../caixa-teia'");
12972 assert_eq!(byte, b'\'');
12973 }
12974
12975 #[test]
12976 fn validate_rejects_path_fonte_with_caminho_carrying_double_quote_grouping() {
12977 // The symmetric weak-quoted paste shape (`"\"../caixa-teia\""`
12978 // — the canonical paste-from-JSON-config / paste-from-YAML-
12979 // flow-scalar / paste-from-TOML-basic-string / paste-from-
12980 // tatara-lisp-string-literal cross-idiom leak). Pinned
12981 // separately from the single-quote shape so the gate's
12982 // contract is "any `'` or `\"` anywhere", not single-byte
12983 // coverage. Mirrors the peer
12984 // `validate_rejects_path_fonte_with_caminho_carrying_close_bracket`
12985 // shape on the immediate-predecessor
12986 // `FonteCaminhoShellBracketExpansion` arm.
12987 let d = dep_with_fonte(DepSource::Path {
12988 caminho: "\"../caixa-teia\"".into(),
12989 });
12990 let err = d.validate().unwrap_err();
12991 let DepError::FonteCaminhoShellQuoteGrouping { byte, .. } = err else {
12992 panic!("expected FonteCaminhoShellQuoteGrouping, got {err:?}");
12993 };
12994 assert_eq!(byte, b'"');
12995 }
12996
12997 #[test]
12998 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_double_quote() {
12999 // Embedded-position `"` shape (`"../\"caixa-teia\""` — the
13000 // canonical "I pasted a JSON key-value pair fragment into
13001 // the middle of the path" idiom). Pinned separately from
13002 // the leading-byte shape so the gate covers every position,
13003 // not only leading.
13004 let d = dep_with_fonte(DepSource::Path {
13005 caminho: "../\"caixa-teia\"".into(),
13006 });
13007 let err = d.validate().unwrap_err();
13008 assert!(
13009 matches!(
13010 err,
13011 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13012 ),
13013 "got {err:?}",
13014 );
13015 }
13016
13017 #[test]
13018 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_flow_scalar_paste() {
13019 // The canonical YAML double-quoted flow-scalar cross-idiom
13020 // leak shape (`"path: \"../caixa-teia\""` — the "I copied a
13021 // `path: \"...\"` YAML flow-scalar entry out of an aligned
13022 // values.yaml / K8s manifest and dropped it verbatim into
13023 // the `:caminho` slot including the `path: ` key prefix"
13024 // paste-idiom). The arm fires on the first `"` encountered;
13025 // pinned so the gate's coverage extends from the bare-quote
13026 // paste shape to the aligned-YAML-manifest cross-idiom-leak
13027 // shape.
13028 let d = dep_with_fonte(DepSource::Path {
13029 caminho: "path: \"../caixa-teia\"".into(),
13030 });
13031 let err = d.validate().unwrap_err();
13032 assert!(
13033 matches!(
13034 err,
13035 DepError::FonteCaminhoShellQuoteGrouping { byte: b'"', .. },
13036 ),
13037 "got {err:?}",
13038 );
13039 }
13040
13041 #[test]
13042 fn validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping() {
13043 // The positive-control pin: the gate targets only `'` /
13044 // `"`, never adjacent printable ASCII or POSIX-valid bytes.
13045 // The canonical relative POSIX path (`"../caixa-teia"`) and
13046 // a nested deeply-pathed variant with adjacent printable
13047 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13048 // to validate cleanly so the gate doesn't widen to a "no
13049 // printable punctuation anywhere" sweep that would defeat
13050 // the entire path-fonte author surface. Peer with
13051 // `validate_accepts_path_fonte_with_caminho_carrying_no_bracket_expansion`
13052 // on the immediate-predecessor arm.
13053 let d = dep_with_fonte(DepSource::Path {
13054 caminho: "../caixa-teia/sub-dir.v2".into(),
13055 });
13056 d.validate().unwrap();
13057 }
13058
13059 #[test]
13060 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_quote_grouping() {
13061 // Cascade pin on the immediate-predecessor arm: a value
13062 // carrying both `[` and `'` (`"../[a-z]'x'"` — the canonical
13063 // "I pasted a glob-character-class followed by a strong-
13064 // quoted literal tail" footgun) routes through
13065 // `FonteCaminhoShellBracketExpansion` not
13066 // `FonteCaminhoShellQuoteGrouping`. The glob-character-class
13067 // expansion is the load-bearing root-cause edit on every
13068 // probe-as-both value; same cascade discipline every prior
13069 // `:caminho` arm establishes.
13070 let d = dep_with_fonte(DepSource::Path {
13071 caminho: "../[a-z]'x'".into(),
13072 });
13073 let err = d.validate().unwrap_err();
13074 assert!(
13075 matches!(
13076 err,
13077 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13078 ),
13079 "got {err:?}",
13080 );
13081 }
13082
13083 #[test]
13084 fn fonte_caminho_shell_brace_expansion_fires_before_shell_quote_grouping() {
13085 // Cascade pin on the upstream shell-brace-expansion arm: a
13086 // value carrying both `{` and `'` (`"../{a,b}'x'"` — the
13087 // canonical "I pasted a brace-expansion fan followed by a
13088 // strong-quoted literal tail" footgun) routes through
13089 // `FonteCaminhoShellBraceExpansion` not
13090 // `FonteCaminhoShellQuoteGrouping`. The brace-expansion fan
13091 // is the load-bearing root-cause edit on every probe-as-
13092 // both value.
13093 let d = dep_with_fonte(DepSource::Path {
13094 caminho: "../{a,b}'x'".into(),
13095 });
13096 let err = d.validate().unwrap_err();
13097 assert!(
13098 matches!(
13099 err,
13100 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13101 ),
13102 "got {err:?}",
13103 );
13104 }
13105
13106 #[test]
13107 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_quote_grouping() {
13108 // Cascade pin on the upstream shell-subshell-grouping arm:
13109 // a value carrying both `(` and `'` (`"../(cd foo)/'x'"` —
13110 // the canonical "I pasted a subshell-grouping followed by
13111 // a strong-quoted literal tail" footgun) routes through
13112 // `FonteCaminhoShellSubshellGrouping` not
13113 // `FonteCaminhoShellQuoteGrouping`. The modern Bourne
13114 // `$(<cmd>)` command-substitution boundary is the load-
13115 // bearing axis on every probe-as-both value.
13116 let d = dep_with_fonte(DepSource::Path {
13117 caminho: "../(cd foo)/'x'".into(),
13118 });
13119 let err = d.validate().unwrap_err();
13120 assert!(
13121 matches!(
13122 err,
13123 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13124 ),
13125 "got {err:?}",
13126 );
13127 }
13128
13129 #[test]
13130 fn fonte_caminho_shell_glob_fires_before_shell_quote_grouping() {
13131 // Cascade pin on the upstream shell-glob arm: a value
13132 // carrying both `*` and `'` (`"../caixa-teia/*'x'"` — the
13133 // canonical "I pasted a `*` unbounded pathname-expansion
13134 // followed by a strong-quoted literal tail" footgun) routes
13135 // through `FonteCaminhoShellGlob` not
13136 // `FonteCaminhoShellQuoteGrouping`. The unbounded pathname-
13137 // expansion sentinel is the load-bearing root-cause edit
13138 // on every probe-as-both value.
13139 let d = dep_with_fonte(DepSource::Path {
13140 caminho: "../caixa-teia/*'x'".into(),
13141 });
13142 let err = d.validate().unwrap_err();
13143 assert!(
13144 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13145 "got {err:?}",
13146 );
13147 }
13148
13149 #[test]
13150 fn fonte_caminho_shell_command_substitution_fires_before_shell_quote_grouping() {
13151 // Cascade pin on the upstream shell-command-substitution
13152 // arm: a value carrying both a backtick and `'`
13153 // (``"../`whoami`/'x'"`` — the canonical "I pasted a
13154 // legacy-backtick command-substitution followed by a
13155 // strong-quoted literal tail" footgun) routes through
13156 // `FonteCaminhoShellCommandSubstitution` not
13157 // `FonteCaminhoShellQuoteGrouping`. The CWE-78 shell-
13158 // command-injection vector is the load-bearing root-cause
13159 // edit on every probe-as-both value.
13160 let d = dep_with_fonte(DepSource::Path {
13161 caminho: "../`whoami`/'x'".into(),
13162 });
13163 let err = d.validate().unwrap_err();
13164 assert!(
13165 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13166 "got {err:?}",
13167 );
13168 }
13169
13170 #[test]
13171 fn fonte_caminho_shell_background_fires_before_shell_quote_grouping() {
13172 // Cascade pin on the upstream shell-background arm: a value
13173 // carrying both `&` and `'` (`"../caixa-teia & 'x'"` — the
13174 // canonical "I pasted a `cmd & 'literal'` background-launch
13175 // + quote chain" footgun) routes through
13176 // `FonteCaminhoShellBackground` not
13177 // `FonteCaminhoShellQuoteGrouping`. The background-launch
13178 // tail is the load-bearing root-cause edit on every
13179 // probe-as-both value.
13180 let d = dep_with_fonte(DepSource::Path {
13181 caminho: "../caixa-teia & 'x'".into(),
13182 });
13183 let err = d.validate().unwrap_err();
13184 assert!(
13185 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13186 "got {err:?}",
13187 );
13188 }
13189
13190 #[test]
13191 fn fonte_caminho_shell_semicolon_fires_before_shell_quote_grouping() {
13192 // Cascade pin on the upstream shell-semicolon arm: a value
13193 // carrying both `;` and `'` (`"../caixa-teia; 'x'"` — the
13194 // canonical sequential-cleanup + quote paste idiom) routes
13195 // through `FonteCaminhoShellSemicolon` not
13196 // `FonteCaminhoShellQuoteGrouping`. The sequential-command-
13197 // separator paste is the load-bearing root-cause edit on
13198 // every probe-as-both value.
13199 let d = dep_with_fonte(DepSource::Path {
13200 caminho: "../caixa-teia; 'x'".into(),
13201 });
13202 let err = d.validate().unwrap_err();
13203 assert!(
13204 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13205 "got {err:?}",
13206 );
13207 }
13208
13209 #[test]
13210 fn fonte_caminho_shell_pipe_fires_before_shell_quote_grouping() {
13211 // Cascade pin on the upstream shell-pipe arm: a value
13212 // carrying both `|` and `'` (`"../caixa-teia | 'x'"` — the
13213 // canonical pipeline-to-quoted-literal paste idiom) routes
13214 // through `FonteCaminhoShellPipe` not
13215 // `FonteCaminhoShellQuoteGrouping`. The pipeline-tail paste
13216 // is the load-bearing root-cause edit on every probe-as-
13217 // both value.
13218 let d = dep_with_fonte(DepSource::Path {
13219 caminho: "../caixa-teia | 'x'".into(),
13220 });
13221 let err = d.validate().unwrap_err();
13222 assert!(
13223 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13224 "got {err:?}",
13225 );
13226 }
13227
13228 #[test]
13229 fn fonte_caminho_shell_redirection_fires_before_shell_quote_grouping() {
13230 // Cascade pin on the upstream shell-redirection arm: a
13231 // value carrying both `>` and `'` (`"../caixa-teia>log 'x'"`
13232 // — the canonical "I pasted a `cmd > log 'literal'`
13233 // redirect-plus-quote chain" footgun) routes through
13234 // `FonteCaminhoShellRedirection` not
13235 // `FonteCaminhoShellQuoteGrouping`. The input/output
13236 // redirection metachar carries the more self-locating
13237 // `byte` payload, so the prior arm wins on every probe-as-
13238 // both value.
13239 let d = dep_with_fonte(DepSource::Path {
13240 caminho: "../caixa-teia>log 'x'".into(),
13241 });
13242 let err = d.validate().unwrap_err();
13243 assert!(
13244 matches!(
13245 err,
13246 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13247 ),
13248 "got {err:?}",
13249 );
13250 }
13251
13252 #[test]
13253 fn fonte_caminho_backslash_fires_before_shell_quote_grouping() {
13254 // Cascade pin on the upstream backslash arm: a value
13255 // carrying both `\` and `'` (`"..\caixa-teia\'x'"` — the
13256 // canonical "I pasted a Windows-shell `cd ..\path\'literal'`
13257 // chain" footgun) routes through `FonteCaminhoBackslash`
13258 // not `FonteCaminhoShellQuoteGrouping`. The cross-host-OS-
13259 // separator divergence is the load-bearing axis on every
13260 // probe-as-both value.
13261 let d = dep_with_fonte(DepSource::Path {
13262 caminho: "..\\caixa-teia\\'x'".into(),
13263 });
13264 let err = d.validate().unwrap_err();
13265 assert!(
13266 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13267 "got {err:?}",
13268 );
13269 }
13270
13271 #[test]
13272 fn fonte_caminho_control_char_fires_before_shell_quote_grouping() {
13273 // Cascade pin on the embedded-control-byte arm: a value
13274 // carrying both a control byte and `'` (`"../foo\n'x'"` —
13275 // the canonical paste-from-multiline-doc footgun where a
13276 // newline landed mid-caminho between two paste fragments)
13277 // routes through `FonteCaminhoControlChar` not
13278 // `FonteCaminhoShellQuoteGrouping`. The POSIX-syscall-
13279 // rejected-byte / NUL-`CString::new`-fail diagnostic is
13280 // the load-bearing axis on every value that probes
13281 // positive for both — mirrors the cascade discipline on
13282 // every prior arm.
13283 let d = dep_with_fonte(DepSource::Path {
13284 caminho: "../foo\n'x'".into(),
13285 });
13286 let err = d.validate().unwrap_err();
13287 assert!(
13288 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13289 "got {err:?}",
13290 );
13291 }
13292
13293 #[test]
13294 fn fonte_caminho_absolute_fires_before_shell_quote_grouping() {
13295 // Cascade pin on the load-bearing leading-byte arm: a
13296 // leading `/` value with embedded `'` (`"/etc/'x'"`) routes
13297 // through `FonteCaminhoAbsolute` not
13298 // `FonteCaminhoShellQuoteGrouping` — the host-layout-leak
13299 // diagnostic is the load-bearing axis, the quote byte is
13300 // the secondary observation. Same precedence logic as every
13301 // prior leading-byte arm.
13302 let d = dep_with_fonte(DepSource::Path {
13303 caminho: "/etc/'x'".into(),
13304 });
13305 let err = d.validate().unwrap_err();
13306 assert!(
13307 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13308 "got {err:?}",
13309 );
13310 }
13311
13312 #[test]
13313 fn fonte_caminho_var_expansion_fires_before_shell_quote_grouping() {
13314 // Cascade pin on the upstream leading-`$` var-expansion
13315 // arm: a value carrying both a leading `$` and a `'`
13316 // (`"$DIR/'x'"` — the canonical "I pasted a `$DIR` shell-
13317 // variable + quoted literal at the head of a sibling-
13318 // workspace path" footgun) routes through
13319 // `FonteCaminhoVarExpansion` not
13320 // `FonteCaminhoShellQuoteGrouping`. The leading-byte
13321 // shell-variable-expansion is the more self-locating
13322 // diagnostic on values that probe as both — same
13323 // load-bearing-leading-byte cascade discipline every
13324 // prior `:caminho` arm establishes.
13325 let d = dep_with_fonte(DepSource::Path {
13326 caminho: "$DIR/'x'".into(),
13327 });
13328 let err = d.validate().unwrap_err();
13329 assert!(
13330 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13331 "got {err:?}",
13332 );
13333 }
13334
13335 #[test]
13336 fn fonte_caminho_shell_quote_grouping_fires_before_trailing_slash() {
13337 // Cascade pin on the immediate-successor arm: a value
13338 // carrying both `'` and a trailing `/` (`"../'caixa-teia'/"`
13339 // — the canonical "I tab-completed a path whose strong-
13340 // quoted body already carried the quoting from a shell-
13341 // history paste" footgun) routes through
13342 // `FonteCaminhoShellQuoteGrouping` not
13343 // `FonteCaminhoTrailingSlash`. The embedded shell-metachar
13344 // is the more semantic-locating axis (an author who removes
13345 // the `'` typically also drops the trailing separator since
13346 // both are paste-from-shell artifacts).
13347 let d = dep_with_fonte(DepSource::Path {
13348 caminho: "../'caixa-teia'/".into(),
13349 });
13350 let err = d.validate().unwrap_err();
13351 assert!(
13352 matches!(
13353 err,
13354 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13355 ),
13356 "got {err:?}",
13357 );
13358 }
13359
13360 #[test]
13361 fn fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte() {
13362 // Diagnostic-shape pin (peer with
13363 // `fonte_caminho_shell_bracket_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
13364 // on the closest two-byte peer arm): the error's Display
13365 // surfaces the offending `:nome`, the offending `:caminho`
13366 // verbatim, the offending byte's hex / character form, and
13367 // names the shell-quote-grouping / cross-config-DSL-string-
13368 // literal-delimiter footgun explicitly so a `feira lint`
13369 // run can render the diagnostic without re-parsing.
13370 let d = dep_with_fonte(DepSource::Path {
13371 caminho: "'../caixa-teia'".into(),
13372 });
13373 let rendered = d.validate().unwrap_err().to_string();
13374 assert!(
13375 rendered.contains("caixa-teia"),
13376 "diagnostic must name the offending dep: {rendered}",
13377 );
13378 assert!(
13379 rendered.contains("'../caixa-teia'"),
13380 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13381 );
13382 assert!(
13383 rendered.contains("0x27"),
13384 "diagnostic must surface the offending byte hex: {rendered:?}",
13385 );
13386 assert!(
13387 rendered.contains("quote-grouping"),
13388 "diagnostic must name the shell-quote-grouping footgun: {rendered:?}",
13389 );
13390 assert!(
13391 rendered.contains("string-literal"),
13392 "diagnostic must reference the cross-config-DSL string-literal-delimiter \
13393 vocabulary: {rendered:?}",
13394 );
13395 }
13396
13397 #[test]
13398 fn validate_rejects_path_fonte_with_caminho_carrying_shell_comment_lead() {
13399 // The canonical paste-from-shell-history-with-trailing-
13400 // annotation footgun: an author pastes a `cd ../caixa-teia
13401 // # legacy sibling` shell-history one-liner whose unquoted `#`
13402 // comment-lead separates the path from an inline annotation.
13403 // The POSIX shell trims the annotation to `../caixa-teia`
13404 // (POSIX.1-2017 §2.3 Token Recognition step 6), but
13405 // `Path::is_absolute` returns false on `..`, `#` is neither
13406 // a leading-byte sentinel nor a control byte nor `\` nor
13407 // `<` / `>` nor `|` nor `;` nor `&` nor backtick nor `*` /
13408 // `?` nor `(` / `)` nor `{` / `}` nor `[` / `]` nor `'` /
13409 // `"`, and the value's last byte isn't `/` — so the value
13410 // silently passed every prior arm. The resolver folded the
13411 // value through `Path::join` looking for a literal
13412 // `./../caixa-teia # legacy sibling` subdirectory and the
13413 // failure surfaced at resolve time with a non-self-locating
13414 // `No such file or directory` error. The new arm moves the
13415 // rejection to validate time and names the offending dep +
13416 // caminho + byte verbatim.
13417 let d = dep_with_fonte(DepSource::Path {
13418 caminho: "../caixa-teia # legacy sibling".into(),
13419 });
13420 let err = d.validate().unwrap_err();
13421 let DepError::FonteCaminhoShellComment {
13422 nome,
13423 caminho,
13424 byte,
13425 } = err
13426 else {
13427 panic!("expected FonteCaminhoShellComment, got {err:?}");
13428 };
13429 assert_eq!(nome, "caixa-teia");
13430 assert_eq!(caminho, "../caixa-teia # legacy sibling");
13431 assert_eq!(byte, b'#');
13432 }
13433
13434 #[test]
13435 fn validate_rejects_path_fonte_with_caminho_carrying_yaml_comment_paste() {
13436 // The symmetric YAML flow-scalar / values.yaml / K8s-manifest
13437 // cross-idiom-leak shape (`"../caixa-teia # pin"` — the
13438 // canonical "I copied a `path: ../caixa-teia # pin` YAML
13439 // scalar-plus-comment entry out of an aligned values.yaml and
13440 // dropped it verbatim into the `:caminho` slot" paste-idiom).
13441 // Pinned separately from the shell-history shape so the
13442 // gate's coverage extends from the single-space `#` shape to
13443 // the YAML-canonical double-space ` #` shape. YAML 1.2 §6.6
13444 // requires the `#` to be preceded by whitespace to lex as a
13445 // comment (bare `foo#bar` is a single scalar); the double-
13446 // space paste from an aligned manifest is the canonical
13447 // shape.
13448 let d = dep_with_fonte(DepSource::Path {
13449 caminho: "../caixa-teia # pin".into(),
13450 });
13451 let err = d.validate().unwrap_err();
13452 assert!(
13453 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13454 "got {err:?}",
13455 );
13456 }
13457
13458 #[test]
13459 fn validate_rejects_path_fonte_with_caminho_carrying_url_fragment_anchor() {
13460 // The URL-fragment-identifier paste shape
13461 // (`"../caixa-teia#readme"` — the canonical
13462 // paste-from-browser-address-bar permalink shape where the
13463 // browser preserved the `#anchor` tail on the copy). Pinned
13464 // separately from the whitespace-separated shell / YAML
13465 // comment shapes so the gate covers the unpadded RFC 3986
13466 // §3.5 fragment-delimiter position too, not only positions
13467 // preceded by unquoted whitespace. Peer with the immediate-
13468 // sibling `is_git_repo_url` arm on the `:fonte :repo` axis
13469 // (a68f818) which closes the same byte under the same URL-
13470 // fragment-identifier banner.
13471 let d = dep_with_fonte(DepSource::Path {
13472 caminho: "../caixa-teia#readme".into(),
13473 });
13474 let err = d.validate().unwrap_err();
13475 assert!(
13476 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13477 "got {err:?}",
13478 );
13479 }
13480
13481 #[test]
13482 fn validate_rejects_path_fonte_with_caminho_carrying_leading_shell_comment() {
13483 // Leading-position `#` shape (`"#../caixa-teia"` — the
13484 // "I copied a shell-comment-out entry from a commented-out
13485 // dep row" footgun). Pinned separately from the embedded
13486 // shapes so the gate covers every position, not only
13487 // whitespace-preceded / mid-value.
13488 let d = dep_with_fonte(DepSource::Path {
13489 caminho: "#../caixa-teia".into(),
13490 });
13491 let err = d.validate().unwrap_err();
13492 assert!(
13493 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
13494 "got {err:?}",
13495 );
13496 }
13497
13498 #[test]
13499 fn validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment() {
13500 // The positive-control pin: the gate targets only `#`,
13501 // never adjacent printable ASCII or POSIX-valid bytes. The
13502 // canonical relative POSIX path (`"../caixa-teia"`) and a
13503 // nested deeply-pathed variant with adjacent printable
13504 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13505 // to validate cleanly so the gate doesn't widen to a "no
13506 // printable punctuation anywhere" sweep that would defeat
13507 // the entire path-fonte author surface. Peer with
13508 // `validate_accepts_path_fonte_with_caminho_carrying_no_quote_grouping`
13509 // on the immediate-predecessor arm.
13510 let d = dep_with_fonte(DepSource::Path {
13511 caminho: "../caixa-teia/sub-dir.v2".into(),
13512 });
13513 d.validate().unwrap();
13514 }
13515
13516 #[test]
13517 fn fonte_caminho_shell_quote_grouping_fires_before_shell_comment() {
13518 // Cascade pin on the immediate-predecessor arm: a value
13519 // carrying both `'` and `#` (`"../'x'#pin"` — the canonical
13520 // "I pasted a strong-quoted literal followed by a URL-
13521 // fragment permalink tail" footgun) routes through
13522 // `FonteCaminhoShellQuoteGrouping` not
13523 // `FonteCaminhoShellComment`. The shell-string-literal-
13524 // delimiter is the load-bearing root-cause edit on every
13525 // probe-as-both value; same cascade discipline every prior
13526 // `:caminho` arm establishes.
13527 let d = dep_with_fonte(DepSource::Path {
13528 caminho: "../'x'#pin".into(),
13529 });
13530 let err = d.validate().unwrap_err();
13531 assert!(
13532 matches!(
13533 err,
13534 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
13535 ),
13536 "got {err:?}",
13537 );
13538 }
13539
13540 #[test]
13541 fn fonte_caminho_shell_bracket_expansion_fires_before_shell_comment() {
13542 // Cascade pin on the upstream shell-bracket-expansion arm:
13543 // a value carrying both `[` and `#` (`"../[a-z]#pin"` — the
13544 // canonical "I pasted a glob-character-class followed by a
13545 // URL-fragment tail" footgun) routes through
13546 // `FonteCaminhoShellBracketExpansion` not
13547 // `FonteCaminhoShellComment`. The glob-character-class
13548 // expansion is the load-bearing root-cause edit on every
13549 // probe-as-both value.
13550 let d = dep_with_fonte(DepSource::Path {
13551 caminho: "../[a-z]#pin".into(),
13552 });
13553 let err = d.validate().unwrap_err();
13554 assert!(
13555 matches!(
13556 err,
13557 DepError::FonteCaminhoShellBracketExpansion { byte: b'[', .. },
13558 ),
13559 "got {err:?}",
13560 );
13561 }
13562
13563 #[test]
13564 fn fonte_caminho_shell_brace_expansion_fires_before_shell_comment() {
13565 // Cascade pin on the upstream shell-brace-expansion arm: a
13566 // value carrying both `{` and `#` (`"../{a,b}#pin"` — the
13567 // canonical "I pasted a brace-expansion fan followed by a
13568 // URL-fragment tail" footgun) routes through
13569 // `FonteCaminhoShellBraceExpansion` not
13570 // `FonteCaminhoShellComment`. The brace-expansion fan is the
13571 // load-bearing root-cause edit on every probe-as-both value.
13572 let d = dep_with_fonte(DepSource::Path {
13573 caminho: "../{a,b}#pin".into(),
13574 });
13575 let err = d.validate().unwrap_err();
13576 assert!(
13577 matches!(
13578 err,
13579 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. },
13580 ),
13581 "got {err:?}",
13582 );
13583 }
13584
13585 #[test]
13586 fn fonte_caminho_shell_subshell_grouping_fires_before_shell_comment() {
13587 // Cascade pin on the upstream shell-subshell-grouping arm:
13588 // a value carrying both `(` and `#` (`"../(cd foo)#pin"` —
13589 // the canonical "I pasted a subshell-grouping followed by a
13590 // URL-fragment tail" footgun) routes through
13591 // `FonteCaminhoShellSubshellGrouping` not
13592 // `FonteCaminhoShellComment`. The modern Bourne `$(<cmd>)`
13593 // command-substitution boundary is the load-bearing axis on
13594 // every probe-as-both value.
13595 let d = dep_with_fonte(DepSource::Path {
13596 caminho: "../(cd foo)#pin".into(),
13597 });
13598 let err = d.validate().unwrap_err();
13599 assert!(
13600 matches!(
13601 err,
13602 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. },
13603 ),
13604 "got {err:?}",
13605 );
13606 }
13607
13608 #[test]
13609 fn fonte_caminho_shell_glob_fires_before_shell_comment() {
13610 // Cascade pin on the upstream shell-glob arm: a value
13611 // carrying both `*` and `#` (`"../caixa-teia/*#pin"` — the
13612 // canonical "I pasted a `*` unbounded pathname-expansion
13613 // followed by a URL-fragment tail" footgun) routes through
13614 // `FonteCaminhoShellGlob` not `FonteCaminhoShellComment`.
13615 // The unbounded pathname-expansion sentinel is the load-
13616 // bearing root-cause edit on every probe-as-both value.
13617 let d = dep_with_fonte(DepSource::Path {
13618 caminho: "../caixa-teia/*#pin".into(),
13619 });
13620 let err = d.validate().unwrap_err();
13621 assert!(
13622 matches!(err, DepError::FonteCaminhoShellGlob { byte: b'*', .. }),
13623 "got {err:?}",
13624 );
13625 }
13626
13627 #[test]
13628 fn fonte_caminho_shell_command_substitution_fires_before_shell_comment() {
13629 // Cascade pin on the upstream shell-command-substitution
13630 // arm: a value carrying both a backtick and `#`
13631 // (``"../`whoami`#pin"`` — the canonical "I pasted a
13632 // legacy-backtick command-substitution followed by a URL-
13633 // fragment tail" footgun) routes through
13634 // `FonteCaminhoShellCommandSubstitution` not
13635 // `FonteCaminhoShellComment`. The CWE-78 shell-command-
13636 // injection vector is the load-bearing root-cause edit on
13637 // every probe-as-both value.
13638 let d = dep_with_fonte(DepSource::Path {
13639 caminho: "../`whoami`#pin".into(),
13640 });
13641 let err = d.validate().unwrap_err();
13642 assert!(
13643 matches!(err, DepError::FonteCaminhoShellCommandSubstitution { .. }),
13644 "got {err:?}",
13645 );
13646 }
13647
13648 #[test]
13649 fn fonte_caminho_shell_background_fires_before_shell_comment() {
13650 // Cascade pin on the upstream shell-background arm: a value
13651 // carrying both `&` and `#` (`"../caixa-teia&pin#tail"` —
13652 // the canonical "I pasted a `cmd &` background-launch
13653 // followed by a URL-fragment tail" footgun) routes through
13654 // `FonteCaminhoShellBackground` not
13655 // `FonteCaminhoShellComment`. The background-launch tail is
13656 // the load-bearing root-cause edit on every probe-as-both
13657 // value.
13658 let d = dep_with_fonte(DepSource::Path {
13659 caminho: "../caixa-teia&pin#tail".into(),
13660 });
13661 let err = d.validate().unwrap_err();
13662 assert!(
13663 matches!(err, DepError::FonteCaminhoShellBackground { .. }),
13664 "got {err:?}",
13665 );
13666 }
13667
13668 #[test]
13669 fn fonte_caminho_shell_semicolon_fires_before_shell_comment() {
13670 // Cascade pin on the upstream shell-semicolon arm: a value
13671 // carrying both `;` and `#` (`"../caixa-teia;pin#tail"` —
13672 // the canonical sequential-cleanup + URL-fragment paste
13673 // idiom) routes through `FonteCaminhoShellSemicolon` not
13674 // `FonteCaminhoShellComment`. The sequential-command-
13675 // separator paste is the load-bearing root-cause edit on
13676 // every probe-as-both value.
13677 let d = dep_with_fonte(DepSource::Path {
13678 caminho: "../caixa-teia;pin#tail".into(),
13679 });
13680 let err = d.validate().unwrap_err();
13681 assert!(
13682 matches!(err, DepError::FonteCaminhoShellSemicolon { .. }),
13683 "got {err:?}",
13684 );
13685 }
13686
13687 #[test]
13688 fn fonte_caminho_shell_pipe_fires_before_shell_comment() {
13689 // Cascade pin on the upstream shell-pipe arm: a value
13690 // carrying both `|` and `#` (`"../caixa-teia|pin#tail"` —
13691 // the canonical pipeline-to-URL-fragment paste idiom) routes
13692 // through `FonteCaminhoShellPipe` not
13693 // `FonteCaminhoShellComment`. The pipeline-tail paste is
13694 // the load-bearing root-cause edit on every probe-as-both
13695 // value.
13696 let d = dep_with_fonte(DepSource::Path {
13697 caminho: "../caixa-teia|pin#tail".into(),
13698 });
13699 let err = d.validate().unwrap_err();
13700 assert!(
13701 matches!(err, DepError::FonteCaminhoShellPipe { .. }),
13702 "got {err:?}",
13703 );
13704 }
13705
13706 #[test]
13707 fn fonte_caminho_shell_redirection_fires_before_shell_comment() {
13708 // Cascade pin on the upstream shell-redirection arm: a
13709 // value carrying both `>` and `#` (`"../caixa-teia>log#pin"`
13710 // — the canonical "I pasted a `cmd > log` redirect followed
13711 // by a URL-fragment tail" footgun) routes through
13712 // `FonteCaminhoShellRedirection` not
13713 // `FonteCaminhoShellComment`. The input/output redirection
13714 // metachar carries the more self-locating `byte` payload,
13715 // so the prior arm wins on every probe-as-both value.
13716 let d = dep_with_fonte(DepSource::Path {
13717 caminho: "../caixa-teia>log#pin".into(),
13718 });
13719 let err = d.validate().unwrap_err();
13720 assert!(
13721 matches!(
13722 err,
13723 DepError::FonteCaminhoShellRedirection { byte: b'>', .. }
13724 ),
13725 "got {err:?}",
13726 );
13727 }
13728
13729 #[test]
13730 fn fonte_caminho_backslash_fires_before_shell_comment() {
13731 // Cascade pin on the upstream backslash arm: a value
13732 // carrying both `\` and `#` (`"..\caixa-teia#pin"` — the
13733 // canonical "I pasted a Windows-shell path followed by a
13734 // URL-fragment tail" footgun) routes through
13735 // `FonteCaminhoBackslash` not `FonteCaminhoShellComment`.
13736 // The cross-host-OS-separator divergence is the load-
13737 // bearing axis on every probe-as-both value.
13738 let d = dep_with_fonte(DepSource::Path {
13739 caminho: "..\\caixa-teia#pin".into(),
13740 });
13741 let err = d.validate().unwrap_err();
13742 assert!(
13743 matches!(err, DepError::FonteCaminhoBackslash { .. }),
13744 "got {err:?}",
13745 );
13746 }
13747
13748 #[test]
13749 fn fonte_caminho_control_char_fires_before_shell_comment() {
13750 // Cascade pin on the embedded-control-byte arm: a value
13751 // carrying both a control byte and `#` (`"../foo\n#pin"` —
13752 // the canonical paste-from-multiline-doc footgun where a
13753 // newline landed mid-caminho between the path and an
13754 // annotation) routes through `FonteCaminhoControlChar` not
13755 // `FonteCaminhoShellComment`. The POSIX-syscall-rejected-
13756 // byte diagnostic is the load-bearing axis on every value
13757 // that probes positive for both — mirrors the cascade
13758 // discipline on every prior arm.
13759 let d = dep_with_fonte(DepSource::Path {
13760 caminho: "../foo\n#pin".into(),
13761 });
13762 let err = d.validate().unwrap_err();
13763 assert!(
13764 matches!(err, DepError::FonteCaminhoControlChar { .. }),
13765 "got {err:?}",
13766 );
13767 }
13768
13769 #[test]
13770 fn fonte_caminho_absolute_fires_before_shell_comment() {
13771 // Cascade pin on the load-bearing leading-byte arm: a
13772 // leading `/` value with embedded `#` (`"/etc/foo#pin"`)
13773 // routes through `FonteCaminhoAbsolute` not
13774 // `FonteCaminhoShellComment` — the host-layout-leak
13775 // diagnostic is the load-bearing axis, the fragment byte is
13776 // the secondary observation. Same precedence logic as every
13777 // prior leading-byte arm.
13778 let d = dep_with_fonte(DepSource::Path {
13779 caminho: "/etc/foo#pin".into(),
13780 });
13781 let err = d.validate().unwrap_err();
13782 assert!(
13783 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
13784 "got {err:?}",
13785 );
13786 }
13787
13788 #[test]
13789 fn fonte_caminho_var_expansion_fires_before_shell_comment() {
13790 // Cascade pin on the upstream leading-`$` var-expansion
13791 // arm: a value carrying both a leading `$` and a `#`
13792 // (`"$DIR/foo#pin"` — the canonical "I pasted a `$DIR`
13793 // shell-variable at the head of a sibling-workspace path
13794 // followed by a URL-fragment tail" footgun) routes through
13795 // `FonteCaminhoVarExpansion` not `FonteCaminhoShellComment`.
13796 // The leading-byte shell-variable-expansion is the more
13797 // self-locating diagnostic on values that probe as both.
13798 let d = dep_with_fonte(DepSource::Path {
13799 caminho: "$DIR/foo#pin".into(),
13800 });
13801 let err = d.validate().unwrap_err();
13802 assert!(
13803 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
13804 "got {err:?}",
13805 );
13806 }
13807
13808 #[test]
13809 fn fonte_caminho_shell_comment_fires_before_trailing_slash() {
13810 // Cascade pin on the immediate-successor arm: a value
13811 // carrying both `#` and a trailing `/`
13812 // (`"../caixa-teia#pin/"` — the canonical "I tab-completed
13813 // a URL-fragment-carrying path" footgun) routes through
13814 // `FonteCaminhoShellComment` not
13815 // `FonteCaminhoTrailingSlash`. The embedded fragment /
13816 // comment-lead byte is the more semantic-locating axis (an
13817 // author who removes the `#pin` fragment typically also
13818 // drops the trailing separator since both are paste-from-
13819 // URL / paste-from-shell-tab-completion artifacts).
13820 let d = dep_with_fonte(DepSource::Path {
13821 caminho: "../caixa-teia#pin/".into(),
13822 });
13823 let err = d.validate().unwrap_err();
13824 assert!(
13825 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. },),
13826 "got {err:?}",
13827 );
13828 }
13829
13830 #[test]
13831 fn fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte() {
13832 // Diagnostic-shape pin (peer with
13833 // `fonte_caminho_shell_quote_grouping_diagnostic_carries_offending_dep_caminho_and_byte`
13834 // on the immediate-predecessor arm): the error's Display
13835 // surfaces the offending `:nome`, the offending `:caminho`
13836 // verbatim, the offending byte's hex / character form, and
13837 // names the shell-comment / URL-fragment-identifier /
13838 // YAML-comment cross-config-DSL footgun explicitly so a
13839 // `feira lint` run can render the diagnostic without
13840 // re-parsing.
13841 let d = dep_with_fonte(DepSource::Path {
13842 caminho: "../caixa-teia#readme".into(),
13843 });
13844 let rendered = d.validate().unwrap_err().to_string();
13845 assert!(
13846 rendered.contains("caixa-teia"),
13847 "diagnostic must name the offending dep: {rendered}",
13848 );
13849 assert!(
13850 rendered.contains("../caixa-teia#readme"),
13851 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
13852 );
13853 assert!(
13854 rendered.contains("0x23"),
13855 "diagnostic must surface the offending byte hex: {rendered:?}",
13856 );
13857 assert!(
13858 rendered.contains("shell-comment") || rendered.contains("comment-lead"),
13859 "diagnostic must name the shell-comment footgun: {rendered:?}",
13860 );
13861 assert!(
13862 rendered.contains("fragment") || rendered.contains("URL-fragment"),
13863 "diagnostic must reference the URL-fragment-identifier vocabulary: \
13864 {rendered:?}",
13865 );
13866 }
13867
13868 #[test]
13869 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_space() {
13870 // The canonical paste-from-browser-address-bar percent-
13871 // encoded-space footgun: an author copies `../caixa%20teia`
13872 // out of a URL-encoded README hyperlink / browser address
13873 // bar / percent-encoded permalink expecting `%20` to decode
13874 // to a literal space at the filesystem layer. POSIX
13875 // `std::path::Path` treats `%` as a literal path-component
13876 // byte, so `Path::join` looks for a literal
13877 // `./../caixa%20teia` subdirectory. `Path::is_absolute`
13878 // returns false on `..`, `%` is neither a leading-byte
13879 // sentinel nor a control byte nor `\` nor `<` / `>` nor
13880 // `|` nor `;` nor `&` nor backtick nor `*` / `?` nor `(` /
13881 // `)` nor `{` / `}` nor `[` / `]` nor `'` / `"` nor `#`,
13882 // and the value's last byte isn't `/` — so the value
13883 // silently passed every prior arm. The new arm moves the
13884 // rejection to validate time and names the offending dep +
13885 // caminho + byte verbatim.
13886 let d = dep_with_fonte(DepSource::Path {
13887 caminho: "../caixa%20teia".into(),
13888 });
13889 let err = d.validate().unwrap_err();
13890 let DepError::FonteCaminhoUrlPercentEncoding {
13891 nome,
13892 caminho,
13893 byte,
13894 } = err
13895 else {
13896 panic!("expected FonteCaminhoUrlPercentEncoding, got {err:?}");
13897 };
13898 assert_eq!(nome, "caixa-teia");
13899 assert_eq!(caminho, "../caixa%20teia");
13900 assert_eq!(byte, b'%');
13901 }
13902
13903 #[test]
13904 fn validate_rejects_path_fonte_with_caminho_carrying_url_percent_encoded_slash() {
13905 // The over-encoded path-separator shape (`"../caixa%2Fteia"`
13906 // intending the `%2F` as the URL encoding of `/`) locks a
13907 // `path:../caixa%2Fteia` BLAKE3 closure that diverges from
13908 // the byte-identical `path:../caixa/teia` form. Pinned
13909 // separately from the space-encoded shape so the gate's
13910 // coverage extends past the single canonical `%20` example
13911 // to any two-hex-digit percent-encoded sequence.
13912 let d = dep_with_fonte(DepSource::Path {
13913 caminho: "../caixa%2Fteia".into(),
13914 });
13915 let err = d.validate().unwrap_err();
13916 assert!(
13917 matches!(
13918 err,
13919 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13920 ),
13921 "got {err:?}",
13922 );
13923 }
13924
13925 #[test]
13926 fn validate_rejects_path_fonte_with_caminho_carrying_lone_percent() {
13927 // The lone-`%` malformed-escape shape (`"../caixa-teia%foo"`
13928 // where `%` isn't followed by two hex digits) — every
13929 // WHATWG-conformant URL parser rejects the value at parse
13930 // time per RFC 3986 §2.1, but the byte would silently ride
13931 // into the lacre before the resolver subprocess crosses the
13932 // URL-parser boundary. Pinned separately from the well-
13933 // formed `%HH` shapes so the gate covers every percent-
13934 // occurrence, not only strictly-conformant escapes.
13935 let d = dep_with_fonte(DepSource::Path {
13936 caminho: "../caixa-teia%foo".into(),
13937 });
13938 let err = d.validate().unwrap_err();
13939 assert!(
13940 matches!(
13941 err,
13942 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13943 ),
13944 "got {err:?}",
13945 );
13946 }
13947
13948 #[test]
13949 fn validate_rejects_path_fonte_with_caminho_carrying_leading_yaml_directive() {
13950 // The YAML-directive-lead paste shape (`"%YAML/../caixa-teia"`
13951 // — the canonical paste-from-top-of-doc YAML directive
13952 // block cross-idiom leak per YAML 1.2 §6.8.1). Pinned
13953 // separately from embedded shapes so the gate covers the
13954 // leading-position `%` too, not only mid-value occurrences.
13955 let d = dep_with_fonte(DepSource::Path {
13956 caminho: "%YAML/../caixa-teia".into(),
13957 });
13958 let err = d.validate().unwrap_err();
13959 assert!(
13960 matches!(
13961 err,
13962 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13963 ),
13964 "got {err:?}",
13965 );
13966 }
13967
13968 #[test]
13969 fn validate_rejects_path_fonte_with_caminho_carrying_printf_format_specifier() {
13970 // The printf-format-specifier paste shape
13971 // (`"../caixa-%s-teia"` — the canonical paste-from-shell-
13972 // diagnostic-one-liner `printf "path=%s\n" ...` idiom, CWE-
13973 // 134 format-string-injection vector). Pinned separately
13974 // from the URL-encoding shapes so the gate's rationale
13975 // extends past the RFC 3986 axis to the C / POSIX printf
13976 // format-directive-lead axis.
13977 let d = dep_with_fonte(DepSource::Path {
13978 caminho: "../caixa-%s-teia".into(),
13979 });
13980 let err = d.validate().unwrap_err();
13981 assert!(
13982 matches!(
13983 err,
13984 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
13985 ),
13986 "got {err:?}",
13987 );
13988 }
13989
13990 #[test]
13991 fn validate_accepts_path_fonte_with_caminho_carrying_no_percent() {
13992 // The positive-control pin: the gate targets only `%`,
13993 // never adjacent printable ASCII or POSIX-valid bytes. The
13994 // canonical relative POSIX path (`"../caixa-teia"`) and a
13995 // nested deeply-pathed variant with adjacent printable
13996 // punctuation (`"../caixa-teia/sub-dir.v2"`) must continue
13997 // to validate cleanly so the gate doesn't widen to a "no
13998 // printable punctuation anywhere" sweep that would defeat
13999 // the entire path-fonte author surface. Peer with
14000 // `validate_accepts_path_fonte_with_caminho_carrying_no_shell_comment`
14001 // on the immediate-predecessor arm.
14002 let d = dep_with_fonte(DepSource::Path {
14003 caminho: "../caixa-teia/sub-dir.v2".into(),
14004 });
14005 d.validate().unwrap();
14006 }
14007
14008 #[test]
14009 fn fonte_caminho_shell_comment_fires_before_url_percent_encoding() {
14010 // Cascade pin on the immediate-predecessor arm: a value
14011 // carrying both `#` and `%` (`"../caixa-teia#pin%20"` — the
14012 // canonical "I pasted a URL-fragment permalink followed by a
14013 // percent-encoded space tail" footgun) routes through
14014 // `FonteCaminhoShellComment` not
14015 // `FonteCaminhoUrlPercentEncoding`. The URL-fragment-
14016 // identifier is the load-bearing downstream-truncation edit
14017 // on every probe-as-both value; same cascade discipline
14018 // every prior `:caminho` arm establishes.
14019 let d = dep_with_fonte(DepSource::Path {
14020 caminho: "../caixa-teia#pin%20".into(),
14021 });
14022 let err = d.validate().unwrap_err();
14023 assert!(
14024 matches!(err, DepError::FonteCaminhoShellComment { byte: b'#', .. }),
14025 "got {err:?}",
14026 );
14027 }
14028
14029 #[test]
14030 fn fonte_caminho_shell_quote_grouping_fires_before_url_percent_encoding() {
14031 // Cascade pin on the upstream shell-quote-grouping arm: a
14032 // value carrying both `'` and `%` (`"../'x'%20teia"` — the
14033 // canonical "I pasted a strong-quoted literal followed by
14034 // a percent-encoded space" footgun) routes through
14035 // `FonteCaminhoShellQuoteGrouping` not
14036 // `FonteCaminhoUrlPercentEncoding`. The shell-string-
14037 // literal-delimiter is the load-bearing root-cause edit on
14038 // every probe-as-both value.
14039 let d = dep_with_fonte(DepSource::Path {
14040 caminho: "../'x'%20teia".into(),
14041 });
14042 let err = d.validate().unwrap_err();
14043 assert!(
14044 matches!(
14045 err,
14046 DepError::FonteCaminhoShellQuoteGrouping { byte: b'\'', .. },
14047 ),
14048 "got {err:?}",
14049 );
14050 }
14051
14052 #[test]
14053 fn fonte_caminho_backslash_fires_before_url_percent_encoding() {
14054 // Cascade pin on the upstream backslash arm: a value
14055 // carrying both `\` and `%` (`"..\\caixa%20teia"` — the
14056 // canonical "I pasted a Windows-shell path followed by a
14057 // percent-encoded space" footgun) routes through
14058 // `FonteCaminhoBackslash` not
14059 // `FonteCaminhoUrlPercentEncoding`. The cross-host-OS-
14060 // separator divergence is the load-bearing root-cause edit
14061 // on every probe-as-both value.
14062 let d = dep_with_fonte(DepSource::Path {
14063 caminho: "..\\caixa%20teia".into(),
14064 });
14065 let err = d.validate().unwrap_err();
14066 assert!(
14067 matches!(err, DepError::FonteCaminhoBackslash { .. }),
14068 "got {err:?}",
14069 );
14070 }
14071
14072 #[test]
14073 fn fonte_caminho_control_char_fires_before_url_percent_encoding() {
14074 // Cascade pin on the upstream control-char arm: a value
14075 // carrying both a NUL byte and `%` (`"../caixa\0%20teia"` —
14076 // the canonical "I pasted a paste-from-binary-blob path
14077 // followed by a percent-encoded space" footgun) routes
14078 // through `FonteCaminhoControlChar` not
14079 // `FonteCaminhoUrlPercentEncoding`. The POSIX-syscall-
14080 // rejected byte is the load-bearing root-cause edit on
14081 // every probe-as-both value.
14082 let d = dep_with_fonte(DepSource::Path {
14083 caminho: "../caixa\0%20teia".into(),
14084 });
14085 let err = d.validate().unwrap_err();
14086 assert!(
14087 matches!(err, DepError::FonteCaminhoControlChar { byte: 0x00, .. },),
14088 "got {err:?}",
14089 );
14090 }
14091
14092 #[test]
14093 fn fonte_caminho_absolute_fires_before_url_percent_encoding() {
14094 // Cascade pin on the upstream absolute-path arm: a value
14095 // that's both absolute and carries `%` (`"/etc/passwd%20"`
14096 // — the canonical "I pasted an absolute path with a
14097 // percent-encoded space tail" footgun) routes through
14098 // `FonteCaminhoAbsolute` not
14099 // `FonteCaminhoUrlPercentEncoding`. The host-layout-leak is
14100 // the load-bearing root-cause edit on every probe-as-both
14101 // value.
14102 let d = dep_with_fonte(DepSource::Path {
14103 caminho: "/etc/passwd%20".into(),
14104 });
14105 let err = d.validate().unwrap_err();
14106 assert!(
14107 matches!(err, DepError::FonteCaminhoAbsolute { .. }),
14108 "got {err:?}",
14109 );
14110 }
14111
14112 #[test]
14113 fn fonte_caminho_var_expansion_fires_before_url_percent_encoding() {
14114 // Cascade pin on the upstream var-expansion arm: a value
14115 // starting with `$` and carrying `%` (`"$HOME/caixa%20teia"`
14116 // — the canonical "I pasted a `$HOME`-rooted path with a
14117 // percent-encoded space" footgun) routes through
14118 // `FonteCaminhoVarExpansion` not
14119 // `FonteCaminhoUrlPercentEncoding`. The shell-variable-
14120 // expansion is the load-bearing root-cause edit on every
14121 // probe-as-both value.
14122 let d = dep_with_fonte(DepSource::Path {
14123 caminho: "$HOME/caixa%20teia".into(),
14124 });
14125 let err = d.validate().unwrap_err();
14126 assert!(
14127 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14128 "got {err:?}",
14129 );
14130 }
14131
14132 #[test]
14133 fn fonte_caminho_url_percent_encoding_fires_before_trailing_slash() {
14134 // Cascade pin on the immediate-successor arm: a value
14135 // carrying both `%` and a trailing `/`
14136 // (`"../caixa%20teia/"` — the canonical "I tab-completed a
14137 // percent-encoded-space-carrying path" footgun) routes
14138 // through `FonteCaminhoUrlPercentEncoding` not
14139 // `FonteCaminhoTrailingSlash`. The embedded percent-
14140 // encoding-escape byte is the more semantic-locating axis
14141 // (an author who decodes the `%20` to a literal space is
14142 // likely to also tab-strip the trailing separator since
14143 // both are paste-from-URL / paste-from-shell-tab-completion
14144 // artifacts).
14145 let d = dep_with_fonte(DepSource::Path {
14146 caminho: "../caixa%20teia/".into(),
14147 });
14148 let err = d.validate().unwrap_err();
14149 assert!(
14150 matches!(
14151 err,
14152 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14153 ),
14154 "got {err:?}",
14155 );
14156 }
14157
14158 #[test]
14159 fn fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte() {
14160 // Diagnostic-shape pin (peer with
14161 // `fonte_caminho_shell_comment_diagnostic_carries_offending_dep_caminho_and_byte`
14162 // on the immediate-predecessor arm): the error's Display
14163 // surfaces the offending `:nome`, the offending `:caminho`
14164 // verbatim, the offending byte's hex / character form, and
14165 // names the URL-percent-encoding-escape / printf-format-
14166 // specifier footgun explicitly so a `feira lint` run can
14167 // render the diagnostic without re-parsing.
14168 let d = dep_with_fonte(DepSource::Path {
14169 caminho: "../caixa%20teia".into(),
14170 });
14171 let rendered = d.validate().unwrap_err().to_string();
14172 assert!(
14173 rendered.contains("caixa-teia"),
14174 "diagnostic must name the offending dep: {rendered}",
14175 );
14176 assert!(
14177 rendered.contains("../caixa%20teia"),
14178 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14179 );
14180 assert!(
14181 rendered.contains("0x25"),
14182 "diagnostic must surface the offending byte hex: {rendered:?}",
14183 );
14184 assert!(
14185 rendered.contains("percent-encoding") || rendered.contains("percent-encoded"),
14186 "diagnostic must name the URL-percent-encoding-escape footgun: {rendered:?}",
14187 );
14188 assert!(
14189 rendered.contains("printf") || rendered.contains("format-specifier"),
14190 "diagnostic must reference the printf-format-specifier vocabulary: \
14191 {rendered:?}",
14192 );
14193 }
14194
14195 #[test]
14196 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_var_expansion() {
14197 // The canonical embedded-`$` shell-variable-expansion paste
14198 // shape (`"../foo$HOME/bar"` — an author copies a partially-
14199 // substituted shell one-liner where the leading segment is a
14200 // literal `../foo` while the mid segment carries the un-
14201 // substituted `$HOME` template). The leading-`$` position is
14202 // already gated by the f4efe9c leading-byte arm which routes
14203 // through `FonteCaminhoVarExpansion`; this arm closes the
14204 // last positional gap on `$` — every position on the axis is
14205 // structurally rejected.
14206 let d = dep_with_fonte(DepSource::Path {
14207 caminho: "../foo$HOME/bar".into(),
14208 });
14209 let err = d.validate().unwrap_err();
14210 let DepError::FonteCaminhoShellVariableExpansion {
14211 nome,
14212 caminho,
14213 byte,
14214 } = err
14215 else {
14216 panic!("expected FonteCaminhoShellVariableExpansion, got {err:?}");
14217 };
14218 assert_eq!(nome, "caixa-teia");
14219 assert_eq!(caminho, "../foo$HOME/bar");
14220 assert_eq!(byte, b'$');
14221 }
14222
14223 #[test]
14224 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_braced_var_expansion() {
14225 // The symmetric braced-CI-manifest paste shape
14226 // (`"../foo${WORKSPACE}/bar"` — the canonical paste-from-
14227 // GitHub-Actions-workflow / paste-from-`.gitlab-ci.yml`
14228 // footgun). Pinned separately from the bare-`$VAR` shape so
14229 // the gate covers both POSIX shell §2.6 Parameter Expansion
14230 // syntactic forms, not only the unbraced variant. The
14231 // embedded `{` byte in `${...}` is also caught by the 598b770
14232 // shell-brace-expansion arm but that arm fires earlier in
14233 // the cascade — the `$` arm's coverage extends to `${...}`
14234 // structurally, so the diagnostic asserted here is the
14235 // brace-expansion one (which is a valid outcome; the point
14236 // of the pin is that the value never survives validation).
14237 let d = dep_with_fonte(DepSource::Path {
14238 caminho: "../foo${WORKSPACE}/bar".into(),
14239 });
14240 let err = d.validate().unwrap_err();
14241 assert!(
14242 matches!(
14243 err,
14244 DepError::FonteCaminhoShellBraceExpansion { byte: b'{', .. }
14245 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14246 ),
14247 "got {err:?}",
14248 );
14249 }
14250
14251 #[test]
14252 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_command_substitution() {
14253 // The paste-from-shell-prompt command-substitution idiom
14254 // (`"../foo$(whoami)/bar"`). Pinned separately from the bare-
14255 // `$VAR` shape so the gate's rationale extends to POSIX shell
14256 // §2.6.3 Command Substitution (the modern `$(<cmd>)` form; the
14257 // legacy `` `<cmd>` `` form is already closed by the c370458
14258 // backtick arm). The embedded `(` byte in `$(...)` is also
14259 // caught structurally by the 0633c91 shell-subshell-grouping
14260 // arm which fires earlier in the cascade — the diagnostic
14261 // asserted here is either outcome, since both structurally
14262 // reject the value; the point of the pin is that the value
14263 // never survives validation.
14264 let d = dep_with_fonte(DepSource::Path {
14265 caminho: "../foo$(whoami)/bar".into(),
14266 });
14267 let err = d.validate().unwrap_err();
14268 assert!(
14269 matches!(
14270 err,
14271 DepError::FonteCaminhoShellSubshellGrouping { byte: b'(', .. }
14272 | DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14273 ),
14274 "got {err:?}",
14275 );
14276 }
14277
14278 #[test]
14279 fn validate_rejects_path_fonte_with_caminho_carrying_embedded_positional_parameter() {
14280 // The paste-from-`Makefile` / paste-from-SQL-migration bare-
14281 // `$1` positional-parameter shape (`"../foo$1/bar"` — a Make
14282 // automatic-variable `$1` or a PostgreSQL bind-parameter `$1`
14283 // idiom copied into a caminho template). None of the prior
14284 // shell-metachar arms cover this shape (`1` is a bare digit;
14285 // no `(` / `{` / letter follows the `$`), so the arm is the
14286 // sole gate on the shape.
14287 let d = dep_with_fonte(DepSource::Path {
14288 caminho: "../foo$1/bar".into(),
14289 });
14290 let err = d.validate().unwrap_err();
14291 assert!(
14292 matches!(
14293 err,
14294 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14295 ),
14296 "got {err:?}",
14297 );
14298 }
14299
14300 #[test]
14301 fn validate_accepts_path_fonte_with_caminho_carrying_no_dollar() {
14302 // The positive-control pin (peer with
14303 // `validate_accepts_path_fonte_with_caminho_carrying_no_percent`
14304 // on the immediate-predecessor arm): the gate targets only
14305 // `$`, never adjacent printable ASCII or POSIX-valid bytes.
14306 // A relative POSIX path carrying dashes / dots / slashes /
14307 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14308 // validate cleanly so the gate doesn't widen to a "no
14309 // printable punctuation anywhere" sweep that would defeat
14310 // the entire path-fonte author surface.
14311 let d = dep_with_fonte(DepSource::Path {
14312 caminho: "../caixa-teia/sub-dir.v2".into(),
14313 });
14314 d.validate().unwrap();
14315 }
14316
14317 #[test]
14318 fn fonte_caminho_var_expansion_fires_before_shell_variable_expansion() {
14319 // Cascade pin on the leading-`$` sibling arm at line 540: a
14320 // value starting with `$` and carrying an embedded `$` too
14321 // (`"$HOME/foo$WORKSPACE/bar"` — the canonical "I pasted a
14322 // fully-templated CI path with two un-substituted variables")
14323 // routes through `FonteCaminhoVarExpansion` not
14324 // `FonteCaminhoShellVariableExpansion`. The leading-byte
14325 // host-layout-leak is the load-bearing self-locating axis
14326 // (the leading position dominates the semantic-locating
14327 // rationale on every probe-as-both value); the embedded
14328 // arm's positional-agnostic sweep catches only values whose
14329 // leading byte doesn't route through the earlier leading-
14330 // byte arms.
14331 let d = dep_with_fonte(DepSource::Path {
14332 caminho: "$HOME/foo$WORKSPACE/bar".into(),
14333 });
14334 let err = d.validate().unwrap_err();
14335 assert!(
14336 matches!(err, DepError::FonteCaminhoVarExpansion { .. }),
14337 "got {err:?}",
14338 );
14339 }
14340
14341 #[test]
14342 fn fonte_caminho_url_percent_encoding_fires_before_shell_variable_expansion() {
14343 // Cascade pin on the immediate-predecessor arm: a value
14344 // carrying both `%` and embedded `$` (`"../foo%20$HOME/bar"`
14345 // — the canonical "I pasted a percent-encoded space adjacent
14346 // to a `$HOME` template") routes through
14347 // `FonteCaminhoUrlPercentEncoding` not
14348 // `FonteCaminhoShellVariableExpansion`. The URL-percent-
14349 // encoding-escape byte is the more semantic-locating axis
14350 // (the paste-from-browser-address-bar shape is the load-
14351 // bearing self-locating edit); same cascade discipline every
14352 // prior `:caminho` arm establishes.
14353 let d = dep_with_fonte(DepSource::Path {
14354 caminho: "../foo%20$HOME/bar".into(),
14355 });
14356 let err = d.validate().unwrap_err();
14357 assert!(
14358 matches!(
14359 err,
14360 DepError::FonteCaminhoUrlPercentEncoding { byte: b'%', .. },
14361 ),
14362 "got {err:?}",
14363 );
14364 }
14365
14366 #[test]
14367 fn fonte_caminho_shell_variable_expansion_fires_before_trailing_slash() {
14368 // Cascade pin on the immediate-successor arm: a value
14369 // carrying both embedded `$` and a trailing `/`
14370 // (`"../foo$HOME/bar/"` — the canonical "I tab-completed a
14371 // `$HOME`-template-carrying path") routes through
14372 // `FonteCaminhoShellVariableExpansion` not
14373 // `FonteCaminhoTrailingSlash`. The embedded shell-variable-
14374 // expansion byte is the more semantic-locating axis on
14375 // probe-as-both values (an author who substitutes the
14376 // `$HOME` template with a literal value is likely to also
14377 // tab-strip the trailing separator).
14378 let d = dep_with_fonte(DepSource::Path {
14379 caminho: "../foo$HOME/bar/".into(),
14380 });
14381 let err = d.validate().unwrap_err();
14382 assert!(
14383 matches!(
14384 err,
14385 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14386 ),
14387 "got {err:?}",
14388 );
14389 }
14390
14391 #[test]
14392 fn fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14393 // Diagnostic-shape pin (peer with
14394 // `fonte_caminho_url_percent_encoding_diagnostic_carries_offending_dep_caminho_and_byte`
14395 // on the immediate-predecessor arm): the error's Display
14396 // surfaces the offending `:nome`, the offending `:caminho`
14397 // verbatim, the offending byte's hex / character form, and
14398 // names the shell-variable-expansion / command-substitution
14399 // footgun explicitly so a `feira lint` run can render the
14400 // diagnostic without re-parsing.
14401 let d = dep_with_fonte(DepSource::Path {
14402 caminho: "../foo$HOME/bar".into(),
14403 });
14404 let rendered = d.validate().unwrap_err().to_string();
14405 assert!(
14406 rendered.contains("caixa-teia"),
14407 "diagnostic must name the offending dep: {rendered}",
14408 );
14409 assert!(
14410 rendered.contains("../foo$HOME/bar"),
14411 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14412 );
14413 assert!(
14414 rendered.contains("0x24"),
14415 "diagnostic must surface the offending byte hex: {rendered:?}",
14416 );
14417 assert!(
14418 rendered.contains("variable-expansion") || rendered.contains("variable expansion"),
14419 "diagnostic must name the shell-variable-expansion footgun: {rendered:?}",
14420 );
14421 assert!(
14422 rendered.contains("command-substitution") || rendered.contains("command substitution"),
14423 "diagnostic must reference the command-substitution vocabulary: {rendered:?}",
14424 );
14425 }
14426
14427 #[test]
14428 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_expansion() {
14429 // The fail-before-pass-after pin for the canonical paste-from-
14430 // shell-history footgun on `:caminho`. An author copies a `cd
14431 // ../caixa-teia && !sudo make install` one-liner from a quick-
14432 // start README, intending the trailing `!sudo` as a shell-
14433 // history-expansion reference but the typed slot is itself a
14434 // byte-level string parser, not a shell context, so the byte
14435 // rides into the value verbatim. Until this arm landed the `!`
14436 // byte silently passed every prior `:caminho` cascade arm
14437 // (`!` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick /
14438 // `*` / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` /
14439 // `#` / `%` / `$`); bash with the default `histexpand` mode
14440 // rewrites `!command` to the most recent history entry
14441 // beginning with `command`, the canonical RCE-class injection
14442 // vector when the byte rides into a shell argument executed
14443 // under `bash -i` (the operator-notebook interactive shell).
14444 let d = dep_with_fonte(DepSource::Path {
14445 caminho: "../caixa-teia!sudo".into(),
14446 });
14447 let err = d.validate().unwrap_err();
14448 let DepError::FonteCaminhoShellHistoryExpansion {
14449 nome,
14450 caminho,
14451 byte,
14452 } = err
14453 else {
14454 panic!("expected FonteCaminhoShellHistoryExpansion, got {err:?}");
14455 };
14456 assert_eq!(nome, "caixa-teia");
14457 assert_eq!(caminho, "../caixa-teia!sudo");
14458 assert_eq!(byte, b'!');
14459 }
14460
14461 #[test]
14462 fn validate_rejects_path_fonte_with_caminho_carrying_double_bang_history_reference() {
14463 // The symmetric `!!` repeat-prior-command paste idiom (peer with
14464 // `validate_rejects_git_fonte_with_repo_carrying_double_bang_history_reference`
14465 // on `is_git_repo_url`). Pinned separately from the wrapped
14466 // `!command` shape so a future diagnostic-surface change that
14467 // only checked the leading or paired-bang position surfaces
14468 // here — the per-byte arm fires anywhere `!` appears in the
14469 // value, including at consecutive positions in the middle.
14470 let d = dep_with_fonte(DepSource::Path {
14471 caminho: "../foo!!/bar".into(),
14472 });
14473 let err = d.validate().unwrap_err();
14474 assert!(
14475 matches!(
14476 err,
14477 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14478 ),
14479 "got {err:?}",
14480 );
14481 }
14482
14483 #[test]
14484 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_enthusiasm_bang() {
14485 // The English-typography enthusiasm-form paste-from-prose
14486 // idiom: an author writes `:caminho "../caixa-teia!"`
14487 // expecting the substrate to coerce it to a kebab-case slug.
14488 // Pinned separately from the `!<word>` shell-history shape so
14489 // the gate's rationale extends to the paste-from-prose surface
14490 // (the same rationale the peer `is_git_repo_url` bang arm at
14491 // 7d53c68 covers). None of the prior shell-metachar arms cover
14492 // this shape (no `!<word>` reference and no `!!` repeat), so
14493 // the arm is the sole gate on the shape.
14494 let d = dep_with_fonte(DepSource::Path {
14495 caminho: "../caixa-teia!".into(),
14496 });
14497 let err = d.validate().unwrap_err();
14498 assert!(
14499 matches!(
14500 err,
14501 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14502 ),
14503 "got {err:?}",
14504 );
14505 }
14506
14507 #[test]
14508 fn validate_accepts_path_fonte_with_caminho_carrying_no_bang() {
14509 // The positive-control pin (peer with
14510 // `validate_accepts_path_fonte_with_caminho_carrying_no_dollar`
14511 // on the immediate-predecessor arm): the gate targets only
14512 // `!`, never adjacent printable ASCII or POSIX-valid bytes.
14513 // A relative POSIX path carrying dashes / dots / slashes /
14514 // digits (`"../caixa-teia/sub-dir.v2"`) must continue to
14515 // validate cleanly so the gate doesn't widen to a "no
14516 // printable punctuation anywhere" sweep that would defeat
14517 // the entire path-fonte author surface.
14518 let d = dep_with_fonte(DepSource::Path {
14519 caminho: "../caixa-teia/sub-dir.v2".into(),
14520 });
14521 d.validate().unwrap();
14522 }
14523
14524 #[test]
14525 fn fonte_caminho_shell_variable_expansion_fires_before_shell_history_expansion() {
14526 // Cascade pin on the immediate-predecessor arm: a value
14527 // carrying both embedded `$` and `!` (`"../foo$HOME/bar!sudo"`
14528 // — the canonical "I pasted a `$HOME`-templated path adjacent
14529 // to a trailing `!sudo` history-expansion") routes through
14530 // `FonteCaminhoShellVariableExpansion` not
14531 // `FonteCaminhoShellHistoryExpansion`. The shell-variable-
14532 // expansion byte is the more semantic-locating axis on
14533 // probe-as-both values (the paste-from-CI-manifest-with-`$VAR`-
14534 // template shape is the load-bearing self-locating edit);
14535 // same cascade discipline every prior `:caminho` arm
14536 // establishes.
14537 let d = dep_with_fonte(DepSource::Path {
14538 caminho: "../foo$HOME/bar!sudo".into(),
14539 });
14540 let err = d.validate().unwrap_err();
14541 assert!(
14542 matches!(
14543 err,
14544 DepError::FonteCaminhoShellVariableExpansion { byte: b'$', .. },
14545 ),
14546 "got {err:?}",
14547 );
14548 }
14549
14550 #[test]
14551 fn fonte_caminho_shell_history_expansion_fires_before_trailing_slash() {
14552 // Cascade pin on the immediate-successor arm: a value carrying
14553 // both embedded `!` and a trailing `/` (`"../caixa-teia!sudo/"`
14554 // — the canonical "I tab-completed a `!sudo`-carrying path")
14555 // routes through `FonteCaminhoShellHistoryExpansion` not
14556 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14557 // expansion byte is the more semantic-locating axis on probe-
14558 // as-both values (an author who removes the `!sudo` history
14559 // reference is likely to also tab-strip the trailing separator).
14560 let d = dep_with_fonte(DepSource::Path {
14561 caminho: "../caixa-teia!sudo/".into(),
14562 });
14563 let err = d.validate().unwrap_err();
14564 assert!(
14565 matches!(
14566 err,
14567 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14568 ),
14569 "got {err:?}",
14570 );
14571 }
14572
14573 #[test]
14574 fn fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte() {
14575 // Diagnostic-shape pin (peer with
14576 // `fonte_caminho_shell_variable_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14577 // on the immediate-predecessor arm): the error's Display
14578 // surfaces the offending `:nome`, the offending `:caminho`
14579 // verbatim, the offending byte's hex / character form, and
14580 // names the shell-history-expansion / bang-operator footgun
14581 // explicitly so a `feira lint` run can render the diagnostic
14582 // without re-parsing.
14583 let d = dep_with_fonte(DepSource::Path {
14584 caminho: "../caixa-teia!sudo".into(),
14585 });
14586 let rendered = d.validate().unwrap_err().to_string();
14587 assert!(
14588 rendered.contains("caixa-teia"),
14589 "diagnostic must name the offending dep: {rendered}",
14590 );
14591 assert!(
14592 rendered.contains("../caixa-teia!sudo"),
14593 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14594 );
14595 assert!(
14596 rendered.contains("0x21"),
14597 "diagnostic must surface the offending byte hex: {rendered:?}",
14598 );
14599 assert!(
14600 rendered.contains("history-expansion") || rendered.contains("history expansion"),
14601 "diagnostic must name the shell-history-expansion footgun: {rendered:?}",
14602 );
14603 assert!(
14604 rendered.contains("bang"),
14605 "diagnostic must reference the bang-operator vocabulary: {rendered:?}",
14606 );
14607 }
14608
14609 #[test]
14610 fn validate_rejects_path_fonte_with_caminho_carrying_shell_history_substitution() {
14611 // The fail-before-pass-after pin for the canonical paste-from-
14612 // shell-history-quick-substitution footgun on `:caminho`. An
14613 // author copies a `git clone <bad-url>` line from their terminal,
14614 // corrects it via bash's `^bad^good` quick-substitution history
14615 // operator (bash reference §9.3, `set -o histexpand` mode's
14616 // default for interactive sessions), and pastes the trailing
14617 // `^bad^good` substitution fragment into a `:caminho` value
14618 // without trimming the leading `git clone` prefix — the byte
14619 // rides into the manifest verbatim. Until this arm landed the
14620 // `^` byte silently passed every prior `:caminho` cascade arm
14621 // (`^` isn't `\` / `<` / `>` / `|` / `;` / `&` / backtick / `*`
14622 // / `?` / `(` / `)` / `{` / `}` / `[` / `]` / `'` / `"` / `#` /
14623 // `%` / `$` / `!`); bash with the default `histexpand` mode
14624 // rewrites the prior command's `bad` string to `good` and re-
14625 // executes it, the paired-operator half of the `set -o
14626 // histexpand` feature the peer `!` arm already closes the prefix
14627 // half of. The peer `is_git_repo_url` axis rejects the byte at
14628 // 49e142f under the same shell-history-substitution / RFC-3986-
14629 // unwise banner.
14630 let d = dep_with_fonte(DepSource::Path {
14631 caminho: "../foo^bad^good".into(),
14632 });
14633 let err = d.validate().unwrap_err();
14634 let DepError::FonteCaminhoShellHistorySubstitution {
14635 nome,
14636 caminho,
14637 byte,
14638 } = err
14639 else {
14640 panic!("expected FonteCaminhoShellHistorySubstitution, got {err:?}");
14641 };
14642 assert_eq!(nome, "caixa-teia");
14643 assert_eq!(caminho, "../foo^bad^good");
14644 assert_eq!(byte, b'^');
14645 }
14646
14647 #[test]
14648 fn validate_rejects_path_fonte_with_caminho_carrying_regex_negation_anchor() {
14649 // The symmetric paste-from-doc-grep-pipeline footgun (peer with
14650 // `validate_rejects_git_fonte_with_repo_carrying_caret_regex_anchor`
14651 // on `is_git_repo_url`). An author copies a `grep '^archived'`
14652 // regex-anchor / negation idiom from a doc snippet and the byte
14653 // rides in verbatim. Pinned separately from the `^old^new^`
14654 // quick-substitution shape so a future diagnostic-surface change
14655 // that only checked the paired-caret history-substitution
14656 // position surfaces here — the per-byte arm fires anywhere `^`
14657 // appears in the value, including at a solitary leading-of-
14658 // segment position.
14659 let d = dep_with_fonte(DepSource::Path {
14660 caminho: "../foo/^archived".into(),
14661 });
14662 let err = d.validate().unwrap_err();
14663 assert!(
14664 matches!(
14665 err,
14666 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14667 ),
14668 "got {err:?}",
14669 );
14670 }
14671
14672 #[test]
14673 fn validate_rejects_path_fonte_with_caminho_carrying_trailing_history_substitution_open() {
14674 // The trailing-`^` history-substitution-open shape — an author
14675 // starts typing a `^bad^good` quick-substitution but pastes only
14676 // the leading `^` sentinel before context-switching (a bash-
14677 // reference §9.3 valid histexpand prefix on its own — even a
14678 // solitary `^` on the prior command's whole re-execution shape).
14679 // Pinned separately from the `^old^new^` full-form and the leading-
14680 // of-segment `^archived` regex-anchor shape so the gate's
14681 // rationale extends to the paste-from-shell-history-with-only-
14682 // the-first-byte-selected surface. None of the prior shell-
14683 // metachar arms cover this shape.
14684 let d = dep_with_fonte(DepSource::Path {
14685 caminho: "../caixa-teia^".into(),
14686 });
14687 let err = d.validate().unwrap_err();
14688 assert!(
14689 matches!(
14690 err,
14691 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14692 ),
14693 "got {err:?}",
14694 );
14695 }
14696
14697 #[test]
14698 fn validate_accepts_path_fonte_with_caminho_carrying_no_caret() {
14699 // The positive-control pin (peer with
14700 // `validate_accepts_path_fonte_with_caminho_carrying_no_bang`
14701 // on the immediate-predecessor arm): the gate targets only
14702 // `^`, never adjacent printable ASCII or POSIX-valid bytes.
14703 // A relative POSIX path carrying dashes / dots / slashes /
14704 // digits / underscore (`"../caixa-teia/sub_v2.rc"`) must
14705 // continue to validate cleanly so the gate doesn't widen to
14706 // a "no printable punctuation anywhere" sweep that would
14707 // defeat the entire path-fonte author surface.
14708 let d = dep_with_fonte(DepSource::Path {
14709 caminho: "../caixa-teia/sub_v2.rc".into(),
14710 });
14711 d.validate().unwrap();
14712 }
14713
14714 #[test]
14715 fn fonte_caminho_shell_history_expansion_fires_before_shell_history_substitution() {
14716 // Cascade pin on the immediate-predecessor arm: a value carrying
14717 // both embedded `!` and `^` (`"../foo!sudo^bad^good"` — the
14718 // canonical "I pasted a `!sudo` history-reference next to a
14719 // `^bad^good` quick-substitution") routes through
14720 // `FonteCaminhoShellHistoryExpansion` not
14721 // `FonteCaminhoShellHistorySubstitution`. The `!` prefix form is
14722 // the more semantic-locating axis on probe-as-both values (an
14723 // author who removes the `!sudo` reference is likely to also
14724 // strip the paired `^` substitution fragment); same cascade
14725 // discipline every prior `:caminho` arm establishes.
14726 let d = dep_with_fonte(DepSource::Path {
14727 caminho: "../foo!sudo^bad^good".into(),
14728 });
14729 let err = d.validate().unwrap_err();
14730 assert!(
14731 matches!(
14732 err,
14733 DepError::FonteCaminhoShellHistoryExpansion { byte: b'!', .. },
14734 ),
14735 "got {err:?}",
14736 );
14737 }
14738
14739 #[test]
14740 fn fonte_caminho_shell_history_substitution_fires_before_trailing_slash() {
14741 // Cascade pin on the immediate-successor arm: a value carrying
14742 // both embedded `^` and a trailing `/` (`"../foo^bad^good/"` —
14743 // the canonical "I tab-completed a `^bad^good`-carrying path")
14744 // routes through `FonteCaminhoShellHistorySubstitution` not
14745 // `FonteCaminhoTrailingSlash`. The embedded shell-history-
14746 // substitution byte is the more semantic-locating axis on probe-
14747 // as-both values (an author who removes the `^bad^good`
14748 // substitution fragment is likely to also tab-strip the trailing
14749 // separator).
14750 let d = dep_with_fonte(DepSource::Path {
14751 caminho: "../foo^bad^good/".into(),
14752 });
14753 let err = d.validate().unwrap_err();
14754 assert!(
14755 matches!(
14756 err,
14757 DepError::FonteCaminhoShellHistorySubstitution { byte: b'^', .. },
14758 ),
14759 "got {err:?}",
14760 );
14761 }
14762
14763 #[test]
14764 fn fonte_caminho_shell_history_substitution_diagnostic_carries_offending_dep_caminho_and_byte()
14765 {
14766 // Diagnostic-shape pin (peer with
14767 // `fonte_caminho_shell_history_expansion_diagnostic_carries_offending_dep_caminho_and_byte`
14768 // on the immediate-predecessor arm): the error's Display
14769 // surfaces the offending `:nome`, the offending `:caminho`
14770 // verbatim, the offending byte's hex form, and names the
14771 // shell-history-substitution / RFC-3986-'unwise' / regex-
14772 // negation footgun explicitly so a `feira lint` run can render
14773 // the diagnostic without re-parsing.
14774 let d = dep_with_fonte(DepSource::Path {
14775 caminho: "../foo^bad^good".into(),
14776 });
14777 let rendered = d.validate().unwrap_err().to_string();
14778 assert!(
14779 rendered.contains("caixa-teia"),
14780 "diagnostic must name the offending dep: {rendered}",
14781 );
14782 assert!(
14783 rendered.contains("../foo^bad^good"),
14784 "diagnostic must quote the offending caminho verbatim: {rendered:?}",
14785 );
14786 assert!(
14787 rendered.contains("0x5e") || rendered.contains("0x5E"),
14788 "diagnostic must surface the offending byte hex: {rendered:?}",
14789 );
14790 assert!(
14791 rendered.contains("history-substitution") || rendered.contains("history substitution"),
14792 "diagnostic must name the shell-history-substitution footgun: {rendered:?}",
14793 );
14794 assert!(
14795 rendered.contains("unwise"),
14796 "diagnostic must reference the RFC-3986 'unwise' set vocabulary: {rendered:?}",
14797 );
14798 }
14799
14800 #[test]
14801 fn fonte_repo_empty_fires_before_pin_missing() {
14802 // Order pin: empty `:repo` is the more self-locating diagnostic
14803 // (every git source needs a repo; the pin discussion is
14804 // secondary), so it fires before the pin-missing arm even when
14805 // both are violated. Mirrors the
14806 // `nome_empty_takes_precedence_over_versao_invalid` ordering
14807 // discipline on the per-entry layer.
14808 let d = dep_with_fonte(DepSource::Git {
14809 repo: String::new(),
14810 tag: None,
14811 rev: None,
14812 branch: None,
14813 });
14814 let err = d.validate().unwrap_err();
14815 assert!(
14816 matches!(err, DepError::FonteRepoEmpty { .. }),
14817 "got {err:?}"
14818 );
14819 }
14820
14821 #[test]
14822 fn fonte_pin_missing_fires_before_pin_empty() {
14823 // Order pin: a fully-None pin set is structurally distinct from
14824 // a Some(empty) pin — the first surfaces as FontePinMissing
14825 // (no axis chosen), the second as FontePinEmpty (axis chosen
14826 // but value blank). Pin the disjoint relationship so a future
14827 // unification collapses to one variant only as a structural
14828 // decision.
14829 let d = dep_with_fonte(DepSource::Git {
14830 repo: "github:pleme-io/caixa-teia".into(),
14831 tag: None,
14832 rev: None,
14833 branch: None,
14834 });
14835 assert!(matches!(
14836 d.validate().unwrap_err(),
14837 DepError::FontePinMissing { .. }
14838 ));
14839 }
14840
14841 #[test]
14842 fn nome_empty_takes_precedence_over_fonte_invalid() {
14843 // Order pin: a per-entry diagnostic without a non-empty :nome
14844 // can't be self-locating, so :nome "" fires first even when
14845 // :fonte is also malformed. Mirrors
14846 // `nome_empty_takes_precedence_over_versao_invalid` on the
14847 // adjacent axis.
14848 let mut d = dep_with_fonte(DepSource::Git {
14849 repo: String::new(),
14850 tag: None,
14851 rev: None,
14852 branch: None,
14853 });
14854 d.nome = String::new();
14855 assert_eq!(d.validate().unwrap_err(), DepError::NomeEmpty);
14856 }
14857
14858 #[test]
14859 fn versao_invalid_takes_precedence_over_fonte_invalid() {
14860 // Order pin: the :versao parse-side diagnostic is narrower than
14861 // the :fonte shape diagnostic — a malformed :versao always names
14862 // the parser's reason, which is more actionable than the
14863 // :fonte gate's "the pins are wrong" wording. Pin the ordering
14864 // so a re-ordering surfaces here.
14865 let mut d = dep_with_fonte(DepSource::Git {
14866 repo: String::new(),
14867 tag: None,
14868 rev: None,
14869 branch: None,
14870 });
14871 d.versao = "v0.1".into();
14872 let err = d.validate().unwrap_err();
14873 assert!(
14874 matches!(err, DepError::VersaoInvalid { ref nome, .. } if nome == "caixa-teia"),
14875 "got {err:?}"
14876 );
14877 }
14878
14879 #[test]
14880 fn fonte_invalid_diagnostic_carries_offending_nome() {
14881 // The diagnostic-shape pin: every :fonte error variant names
14882 // the offending dep's :nome verbatim, so the author can grep
14883 // caixa.lisp for the `:nome "<n>"` block and fix it in one
14884 // edit. Cover all seven variants so a future variant addition
14885 // forces a parallel diagnostic-shape decision.
14886 for (case, fonte) in [
14887 (
14888 "repo-empty",
14889 DepSource::Git {
14890 repo: String::new(),
14891 tag: Some("v1".into()),
14892 rev: None,
14893 branch: None,
14894 },
14895 ),
14896 (
14897 "repo-shape",
14898 DepSource::Git {
14899 repo: "github:p/x ".into(),
14900 tag: Some("v1".into()),
14901 rev: None,
14902 branch: None,
14903 },
14904 ),
14905 (
14906 "pin-missing",
14907 DepSource::Git {
14908 repo: "github:p/x".into(),
14909 tag: None,
14910 rev: None,
14911 branch: None,
14912 },
14913 ),
14914 (
14915 "pin-ambiguous",
14916 DepSource::Git {
14917 repo: "github:p/x".into(),
14918 tag: Some("v1".into()),
14919 rev: None,
14920 branch: Some("main".into()),
14921 },
14922 ),
14923 (
14924 "pin-empty",
14925 DepSource::Git {
14926 repo: "github:p/x".into(),
14927 tag: Some(String::new()),
14928 rev: None,
14929 branch: None,
14930 },
14931 ),
14932 (
14933 "caminho-empty",
14934 DepSource::Path {
14935 caminho: String::new(),
14936 },
14937 ),
14938 (
14939 "caminho-absolute",
14940 DepSource::Path {
14941 caminho: "/home/me/work/caixa-teia".into(),
14942 },
14943 ),
14944 ] {
14945 let d = dep_with_fonte(fonte);
14946 let msg = d
14947 .validate()
14948 .expect_err(&format!("{case}: expected fonte error"))
14949 .to_string();
14950 assert!(
14951 msg.contains("\"caixa-teia\""),
14952 "{case}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
14953 );
14954 }
14955 }
14956
14957 // -- :tag / :branch value-shape gate ----------------------------------
14958
14959 #[test]
14960 fn validate_rejects_git_fonte_with_tag_carrying_trailing_space() {
14961 // The canonical paste-from-doc footgun on `:tag` — author
14962 // copies `"v0.1.0 "` (trailing space) out of a release-notes
14963 // paragraph. Until this gate landed the empty-pin arm passed
14964 // (the string isn't empty), the resolver issued
14965 // `git fetch <remote> tag 'v0.1.0 '`, and the failure
14966 // surfaced at clone time with a quoting-confused git error
14967 // far from the source caixa.lisp. The new gate moves the
14968 // check to caixa-build time and names the offending dep +
14969 // pin + value verbatim.
14970 let d = dep_with_fonte(DepSource::Git {
14971 repo: "github:pleme-io/caixa-teia".into(),
14972 tag: Some("v0.1.0 ".into()),
14973 rev: None,
14974 branch: None,
14975 });
14976 let err = d.validate().unwrap_err();
14977 let DepError::FontePinShape {
14978 nome,
14979 pin,
14980 value,
14981 reason,
14982 } = err
14983 else {
14984 panic!("expected FontePinShape, got other variant");
14985 };
14986 assert_eq!(nome, "caixa-teia");
14987 assert_eq!(pin, ":tag");
14988 assert_eq!(value, "v0.1.0 ");
14989 assert!(
14990 reason.contains("whitespace"),
14991 "reason must surface the whitespace arm, got {reason:?}"
14992 );
14993 }
14994
14995 #[test]
14996 fn validate_rejects_git_fonte_with_tag_carrying_lock_suffix() {
14997 // The `.lock` suffix is git's atomic-rename guard for
14998 // in-flight ref updates — a refname ending in `.lock` is
14999 // unwritable on disk. Pinned separately from the whitespace
15000 // arm so a future relaxation that admits one but not the
15001 // other surfaces here.
15002 let d = dep_with_fonte(DepSource::Git {
15003 repo: "github:pleme-io/caixa-teia".into(),
15004 tag: Some("v0.1.0.lock".into()),
15005 rev: None,
15006 branch: None,
15007 });
15008 let err = d.validate().unwrap_err();
15009 let DepError::FontePinShape {
15010 pin, value, reason, ..
15011 } = err
15012 else {
15013 panic!("expected FontePinShape, got other variant");
15014 };
15015 assert_eq!(pin, ":tag");
15016 assert_eq!(value, "v0.1.0.lock");
15017 assert!(
15018 reason.contains(".lock"),
15019 "reason must surface the .lock arm, got {reason:?}"
15020 );
15021 }
15022
15023 #[test]
15024 fn validate_rejects_git_fonte_with_branch_carrying_embedded_space() {
15025 // The canonical "branch name with spaces" footgun (`feature
15026 // foo`, `release branch`) — git's refname parser rejects raw
15027 // whitespace, and the failure surfaces at `git checkout
15028 // 'feature foo'` time with a quoting-confused error far from
15029 // the source caixa.lisp. Pinned on the `:branch` axis so the
15030 // gate-applies-to-both-:tag-and-:branch contract is a build-
15031 // error to relax.
15032 let d = dep_with_fonte(DepSource::Git {
15033 repo: "github:pleme-io/caixa-teia".into(),
15034 tag: None,
15035 rev: None,
15036 branch: Some("feature/foo bar".into()),
15037 });
15038 let err = d.validate().unwrap_err();
15039 let DepError::FontePinShape {
15040 pin, value, reason, ..
15041 } = err
15042 else {
15043 panic!("expected FontePinShape, got other variant");
15044 };
15045 assert_eq!(pin, ":branch");
15046 assert_eq!(value, "feature/foo bar");
15047 assert!(
15048 reason.contains("whitespace"),
15049 "reason must surface the whitespace arm, got {reason:?}"
15050 );
15051 }
15052
15053 #[test]
15054 fn validate_rejects_git_fonte_with_branch_carrying_qualified_prefix() {
15055 // The `refs/heads/main` shape — the canonical "I copied the
15056 // fully-qualified ref out of `git show-ref` instead of the
15057 // leaf" footgun. The caixa-resolver prepends `refs/heads/`
15058 // at clone time, so this resolves to a literal ref named
15059 // `refs/heads/refs/heads/main` on disk; the silent double-
15060 // prefix is the load-bearing reason to gate at validate.
15061 // The diagnostic must enumerate the leaf the author probably
15062 // meant (`"main"`) so the fix is one edit.
15063 let d = dep_with_fonte(DepSource::Git {
15064 repo: "github:pleme-io/caixa-teia".into(),
15065 tag: None,
15066 rev: None,
15067 branch: Some("refs/heads/main".into()),
15068 });
15069 let err = d.validate().unwrap_err();
15070 let DepError::FontePinShape {
15071 pin, value, reason, ..
15072 } = err
15073 else {
15074 panic!("expected FontePinShape, got other variant");
15075 };
15076 assert_eq!(pin, ":branch");
15077 assert_eq!(value, "refs/heads/main");
15078 assert!(
15079 reason.contains("fully-qualified"),
15080 "reason must surface the qualified-prefix arm, got {reason:?}"
15081 );
15082 assert!(
15083 reason.contains("\"main\""),
15084 "reason must quote the leaf the author probably meant, got {reason:?}"
15085 );
15086 }
15087
15088 #[test]
15089 fn validate_rejects_git_fonte_with_tag_carrying_qualified_prefix() {
15090 // Sibling arm of the qualified-prefix gate on the `:tag`
15091 // axis (`refs/tags/v0.1.0` — same `git show-ref` output-leak
15092 // footgun). Pinned separately so a future relaxation that
15093 // only catches the `:branch` arm surfaces here.
15094 let d = dep_with_fonte(DepSource::Git {
15095 repo: "github:pleme-io/caixa-teia".into(),
15096 tag: Some("refs/tags/v0.1.0".into()),
15097 rev: None,
15098 branch: None,
15099 });
15100 let err = d.validate().unwrap_err();
15101 let DepError::FontePinShape {
15102 pin, value, reason, ..
15103 } = err
15104 else {
15105 panic!("expected FontePinShape, got other variant");
15106 };
15107 assert_eq!(pin, ":tag");
15108 assert_eq!(value, "refs/tags/v0.1.0");
15109 assert!(
15110 reason.contains("fully-qualified"),
15111 "reason must surface the qualified-prefix arm, got {reason:?}"
15112 );
15113 assert!(
15114 reason.contains("\"v0.1.0\""),
15115 "reason must quote the leaf the author probably meant, got {reason:?}"
15116 );
15117 }
15118
15119 #[test]
15120 fn validate_rejects_git_fonte_with_branch_named_at() {
15121 // The bare `@` is git's alias for `HEAD`; a `:branch "@"` is
15122 // unsourceable. Pinned so a future relaxation that admits
15123 // any single-character refname surfaces here.
15124 let d = dep_with_fonte(DepSource::Git {
15125 repo: "github:pleme-io/caixa-teia".into(),
15126 tag: None,
15127 rev: None,
15128 branch: Some("@".into()),
15129 });
15130 let err = d.validate().unwrap_err();
15131 let DepError::FontePinShape { pin, value, .. } = err else {
15132 panic!("expected FontePinShape, got other variant");
15133 };
15134 assert_eq!(pin, ":branch");
15135 assert_eq!(value, "@");
15136 }
15137
15138 #[test]
15139 fn validate_rejects_git_fonte_with_tag_carrying_double_dot() {
15140 // Git's `<rev1>..<rev2>` range grammar reserves `..` —
15141 // a `:tag "../escape"` (path-traversal-shaped slug) silently
15142 // passes parse and surfaces as a refname-parse error or, on
15143 // older git, a literal `../escape` checkout that escapes the
15144 // refs/ directory tree. Pinned separately from the
15145 // qualified-prefix arm so a future relaxation that catches
15146 // one but not the other surfaces here.
15147 let d = dep_with_fonte(DepSource::Git {
15148 repo: "github:pleme-io/caixa-teia".into(),
15149 tag: Some("../escape".into()),
15150 rev: None,
15151 branch: None,
15152 });
15153 let err = d.validate().unwrap_err();
15154 let DepError::FontePinShape { pin, value, .. } = err else {
15155 panic!("expected FontePinShape, got other variant");
15156 };
15157 assert_eq!(pin, ":tag");
15158 assert_eq!(value, "../escape");
15159 }
15160
15161 #[test]
15162 fn validate_accepts_git_fonte_with_hierarchical_branch() {
15163 // The positive-control pin: hierarchical refnames with one or
15164 // more `/` separators (the `feature/foo` / `user/jdoe/feat`
15165 // canonical idiom) round-trip through the gate. Pinned
15166 // separately from the leaf-`"main"` positive control so a
15167 // future tightening that rejects all multi-component refnames
15168 // surfaces here.
15169 let d = dep_with_fonte(DepSource::Git {
15170 repo: "github:pleme-io/caixa-teia".into(),
15171 tag: None,
15172 rev: None,
15173 branch: Some("feature/checkout-rewrite".into()),
15174 });
15175 d.validate().unwrap();
15176 }
15177
15178 #[test]
15179 fn validate_accepts_git_fonte_with_prerelease_tag() {
15180 // The positive-control pin: semver pre-release shape
15181 // (`v0.1.0-alpha.1`) — the in-component dot is allowed
15182 // (only consecutive `..` and trailing `.` are rejected), the
15183 // mid-component hyphen is allowed. Pinned separately from
15184 // the bare-`"v0.1.0"` positive control so a future tightening
15185 // that rejects pre-release tags surfaces here.
15186 let d = dep_with_fonte(DepSource::Git {
15187 repo: "github:pleme-io/caixa-teia".into(),
15188 tag: Some("v0.1.0-alpha.1".into()),
15189 rev: None,
15190 branch: None,
15191 });
15192 d.validate().unwrap();
15193 }
15194
15195 #[test]
15196 fn validate_rejects_git_fonte_with_rev_carrying_refname_unfriendly_value() {
15197 // The `:rev` axis is routed through `crate::render::is_git_oid`
15198 // (a SHA's character set is `[0-9a-f]`, not a refname's), so a
15199 // value with refname-shape punctuation (here, a `:` mid-string
15200 // — would be a refname violation under `is_git_ref_name` too)
15201 // is rejected at the OID-shape gate. The two predicates
15202 // partition the `:fonte` pin axes structurally: an `:rev` value
15203 // that's a valid refname (`:rev "main"`, `:rev "v0.1.0"`) is
15204 // *still* rejected here because every refname character outside
15205 // `[0-9a-f]` fails the OID gate. Same shape as
15206 // `fonte_pin_shape_diagnostic_carries_offending_nome_pin_value`
15207 // on the refname-shaped axes — the diagnostic names the
15208 // offending dep + pin + value verbatim. The flip-from-accept
15209 // case the prior `:tag`/`:branch` gate left as a "future axis"
15210 // (e70d213) — now landed.
15211 let d = dep_with_fonte(DepSource::Git {
15212 repo: "github:pleme-io/caixa-teia".into(),
15213 tag: None,
15214 rev: Some("c0ffee:notarefname".into()),
15215 branch: None,
15216 });
15217 let err = d.validate().unwrap_err();
15218 let DepError::FontePinShape {
15219 nome,
15220 pin,
15221 value,
15222 reason,
15223 } = err
15224 else {
15225 panic!("expected FontePinShape, got other variant");
15226 };
15227 assert_eq!(nome, "caixa-teia");
15228 assert_eq!(pin, ":rev");
15229 assert_eq!(value, "c0ffee:notarefname");
15230 assert!(
15231 !reason.is_empty(),
15232 "FontePinShape `reason` must carry the predicate's wording verbatim"
15233 );
15234 }
15235
15236 #[test]
15237 fn validate_accepts_git_fonte_with_rev_full_sha1() {
15238 // The positive-control pin on the SHA-1 OID width: exactly 40
15239 // lowercase hex characters — the canonical `git rev-parse HEAD`
15240 // emission on a SHA-1-hashed repository (the default on every
15241 // pre-2.42 git and the canonical pleme-io substrate hash).
15242 // Pinned separately from the SHA-256 positive control so a
15243 // future tightening that only admits one width surfaces here.
15244 let d = dep_with_fonte(DepSource::Git {
15245 repo: "github:pleme-io/caixa-teia".into(),
15246 tag: None,
15247 rev: Some("0123456789abcdef0123456789abcdef01234567".into()),
15248 branch: None,
15249 });
15250 d.validate().unwrap();
15251 }
15252
15253 #[test]
15254 fn validate_accepts_git_fonte_with_rev_full_sha256() {
15255 // The positive-control pin on the SHA-256 OID width: exactly
15256 // 64 lowercase hex characters — `git`'s
15257 // `extensions.objectFormat = sha256` emission (GA since Git
15258 // 2.42 / Oct 2023). The substrate admits either canonical
15259 // width so an `:rev` authored against a SHA-256-hashed
15260 // upstream round-trips through the gate without per-repo
15261 // configuration. Pinned separately from the SHA-1 positive
15262 // control so a future tightening that drops one width surfaces
15263 // here as a structural decision.
15264 let d = dep_with_fonte(DepSource::Git {
15265 repo: "github:pleme-io/caixa-teia".into(),
15266 tag: None,
15267 rev: Some("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef".into()),
15268 branch: None,
15269 });
15270 d.validate().unwrap();
15271 }
15272
15273 #[test]
15274 fn validate_rejects_git_fonte_with_rev_abbreviated_prefix() {
15275 // The canonical `git log --short` / `git rev-parse --short HEAD`
15276 // paste-from-release-notes footgun: a 7-char prefix (git's
15277 // default `core.abbrev`) silently passes string emptiness
15278 // checks and resolves to one commit today, but becomes ambiguous
15279 // tomorrow as the repo grows. Until this gate landed the empty-
15280 // pin arm passed (the string isn't empty) and the resolver
15281 // accepted the prefix through git's separate prefix-lookup pass
15282 // — defeating the reproducibility contract `:rev` carries vs.
15283 // `:tag` / `:branch`. The new gate moves the check to caixa-
15284 // build time and names the offending dep + pin + value verbatim.
15285 let d = dep_with_fonte(DepSource::Git {
15286 repo: "github:pleme-io/caixa-teia".into(),
15287 tag: None,
15288 rev: Some("c0ffee0".into()),
15289 branch: None,
15290 });
15291 let err = d.validate().unwrap_err();
15292 let DepError::FontePinShape {
15293 pin, value, reason, ..
15294 } = err
15295 else {
15296 panic!("expected FontePinShape, got other variant");
15297 };
15298 assert_eq!(pin, ":rev");
15299 assert_eq!(value, "c0ffee0");
15300 assert!(
15301 reason.contains("abbreviated") || reason.contains("ambiguous"),
15302 "reason must surface the abbreviation arm, got {reason:?}"
15303 );
15304 }
15305
15306 #[test]
15307 fn validate_rejects_git_fonte_with_rev_uppercase_hex() {
15308 // The canonical "I pasted the SHA in uppercase" footgun: `git
15309 // porcelain` emits OIDs lowercase exclusively, so an uppercase-
15310 // bearing `:rev` round-trips inconsistently across the
15311 // resolver's `git fetch <remote> <:rev>` ↔ `git rev-parse HEAD`
15312 // equality-check pipeline and fails the lacre's content-
15313 // addressing probe with a confusing case-only diff. Pinned
15314 // separately from the non-hex arm so a future relaxation that
15315 // admits one but not the other surfaces here.
15316 let d = dep_with_fonte(DepSource::Git {
15317 repo: "github:pleme-io/caixa-teia".into(),
15318 tag: None,
15319 rev: Some("DEADBEEFCAFEBABE0123456789ABCDEF01234567".into()),
15320 branch: None,
15321 });
15322 let err = d.validate().unwrap_err();
15323 let DepError::FontePinShape {
15324 pin, value, reason, ..
15325 } = err
15326 else {
15327 panic!("expected FontePinShape, got other variant");
15328 };
15329 assert_eq!(pin, ":rev");
15330 assert_eq!(value, "DEADBEEFCAFEBABE0123456789ABCDEF01234567");
15331 assert!(
15332 reason.contains("uppercase"),
15333 "reason must surface the uppercase arm, got {reason:?}"
15334 );
15335 }
15336
15337 #[test]
15338 fn validate_rejects_git_fonte_with_rev_refname_value() {
15339 // The cross-axis mis-slot footgun: `:rev "main"` — the author
15340 // conflated `:rev` (hex commit ID, immutable) and `:branch`
15341 // (mutable ref pointing at whatever HEAD is today). Until this
15342 // gate landed the resolver silently dispatched on the value
15343 // shape ("`main` doesn't look like a SHA, fall back to
15344 // refname"), defeating the `:rev` reproducibility contract.
15345 // The new gate rejects every non-hex value on the `:rev` axis,
15346 // so the `:rev`/`:branch` boundary is structurally enforced —
15347 // a refname in the `:rev` slot is a build error, not a
15348 // resolver-time silent reinterpretation.
15349 let d = dep_with_fonte(DepSource::Git {
15350 repo: "github:pleme-io/caixa-teia".into(),
15351 tag: None,
15352 rev: Some("main".into()),
15353 branch: None,
15354 });
15355 let err = d.validate().unwrap_err();
15356 let DepError::FontePinShape {
15357 pin, value, reason, ..
15358 } = err
15359 else {
15360 panic!("expected FontePinShape, got other variant");
15361 };
15362 assert_eq!(pin, ":rev");
15363 assert_eq!(value, "main");
15364 // 4 chars `main` fails the length arm before the character arm,
15365 // so the diagnostic surfaces the abbreviation wording (same
15366 // path the `c0ffee0` 7-char fixture lands on); the structural
15367 // assertion is just that the `:rev "main"` value is rejected.
15368 assert!(
15369 !reason.is_empty(),
15370 "FontePinShape reason must be non-empty for refname-shaped :rev"
15371 );
15372 }
15373
15374 #[test]
15375 fn validate_rejects_git_fonte_with_rev_tag_shaped_value() {
15376 // Sibling cross-axis mis-slot: `:rev "v0.1.0"` — the author
15377 // conflated `:rev` and `:tag`. Pinned separately from the
15378 // `:rev "main"` (`:branch` mis-slot) arm so a future relaxation
15379 // that catches one but not the other surfaces here. The
15380 // length arm fires first (6 chars ≠ 40 ≠ 64); the structural
15381 // assertion is just that the cross-axis mis-slot is a build
15382 // error, regardless of which sub-arm surfaces the diagnostic
15383 // (`is_git_oid` rejects at the first violation; longer
15384 // tag-shape values would hit the non-hex arm instead).
15385 let d = dep_with_fonte(DepSource::Git {
15386 repo: "github:pleme-io/caixa-teia".into(),
15387 tag: None,
15388 rev: Some("v0.1.0".into()),
15389 branch: None,
15390 });
15391 let err = d.validate().unwrap_err();
15392 let DepError::FontePinShape {
15393 pin, value, reason, ..
15394 } = err
15395 else {
15396 panic!("expected FontePinShape, got other variant");
15397 };
15398 assert_eq!(pin, ":rev");
15399 assert_eq!(value, "v0.1.0");
15400 assert!(
15401 !reason.is_empty(),
15402 "FontePinShape reason must be non-empty for tag-shaped :rev"
15403 );
15404 }
15405
15406 #[test]
15407 fn validate_rejects_git_fonte_with_rev_too_long() {
15408 // Boundary case on the upper end: 41 hex chars — one past the
15409 // SHA-1 width, well below the SHA-256 width. Pin so a future
15410 // relaxation that admits "long enough to be a SHA" without
15411 // matching either canonical width surfaces here. The diagnostic
15412 // names the offending length verbatim so the author's grep
15413 // target is unambiguous (either trim one char or paste the
15414 // full SHA-256).
15415 let too_long: String = "0".repeat(41);
15416 let d = dep_with_fonte(DepSource::Git {
15417 repo: "github:pleme-io/caixa-teia".into(),
15418 tag: None,
15419 rev: Some(too_long.clone()),
15420 branch: None,
15421 });
15422 let err = d.validate().unwrap_err();
15423 let DepError::FontePinShape {
15424 pin, value, reason, ..
15425 } = err
15426 else {
15427 panic!("expected FontePinShape, got other variant");
15428 };
15429 assert_eq!(pin, ":rev");
15430 assert_eq!(value, too_long);
15431 assert!(
15432 reason.contains("41"),
15433 "reason must surface the offending length verbatim, got {reason:?}"
15434 );
15435 }
15436
15437 #[test]
15438 fn validate_rejects_git_fonte_with_rev_carrying_whitespace() {
15439 // The canonical paste-from-doc footgun on `:rev` — author
15440 // copies `"deadbeefcafe…0123 "` (trailing space) out of a
15441 // commit-message paragraph. Until this gate landed the empty-
15442 // pin arm passed (the string isn't empty), the resolver issued
15443 // `git fetch <remote> 'deadbeef… '` and the failure surfaced at
15444 // clone time with a quoting-confused git error far from the
15445 // source caixa.lisp. The new gate moves the check to caixa-
15446 // build time. Length is 41 (40 hex + space) so the length arm
15447 // fires first — pinned separately from the pure-length arm to
15448 // ensure the diagnostic surfaces *some* parser wording, not
15449 // silently pass through.
15450 let with_space = "0123456789abcdef0123456789abcdef01234567 ".to_string();
15451 let d = dep_with_fonte(DepSource::Git {
15452 repo: "github:pleme-io/caixa-teia".into(),
15453 tag: None,
15454 rev: Some(with_space.clone()),
15455 branch: None,
15456 });
15457 let err = d.validate().unwrap_err();
15458 let DepError::FontePinShape {
15459 pin, value, reason, ..
15460 } = err
15461 else {
15462 panic!("expected FontePinShape, got other variant");
15463 };
15464 assert_eq!(pin, ":rev");
15465 assert_eq!(value, with_space);
15466 assert!(
15467 !reason.is_empty(),
15468 "FontePinShape reason must be non-empty for whitespace-bearing :rev"
15469 );
15470 }
15471
15472 #[test]
15473 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value_for_rev() {
15474 // Diagnostic-shape pin on the `:rev` axis: every FontePinShape
15475 // variant on this axis names the offending dep's `:nome` + the
15476 // `:rev` axis + the offending value verbatim, so the author's
15477 // grep target is the literal `:rev "<value>"` block in
15478 // caixa.lisp. Sibling of the `fonte_pin_shape_diagnostic_
15479 // carries_offending_nome_pin_value` test on the refname-shaped
15480 // (`:tag` / `:branch`) axes.
15481 let d = dep_with_fonte(DepSource::Git {
15482 repo: "github:p/x".into(),
15483 tag: None,
15484 rev: Some("not-a-sha".into()),
15485 branch: None,
15486 });
15487 let msg = d
15488 .validate()
15489 .expect_err(":rev: expected FontePinShape")
15490 .to_string();
15491 assert!(
15492 msg.contains("\"caixa-teia\""),
15493 ":rev: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15494 );
15495 assert!(
15496 msg.contains(":rev"),
15497 ":rev: diagnostic must name the offending pin axis, got {msg:?}"
15498 );
15499 assert!(
15500 msg.contains("not-a-sha"),
15501 ":rev: diagnostic must quote the offending value verbatim, got {msg:?}"
15502 );
15503 }
15504
15505 #[test]
15506 fn fonte_pin_empty_fires_before_pin_shape() {
15507 // Order pin: a `Some("")` `:tag` is the more self-locating
15508 // diagnostic (the author chose an axis but left it blank;
15509 // grep is unambiguous), so it fires before the shape gate
15510 // even when both arms would match. Pinned so a future
15511 // reordering surfaces here. Mirrors the
15512 // `fonte_repo_empty_fires_before_pin_missing` ordering
15513 // discipline on the peer per-axis arms.
15514 let d = dep_with_fonte(DepSource::Git {
15515 repo: "github:pleme-io/caixa-teia".into(),
15516 tag: Some(String::new()),
15517 rev: None,
15518 branch: None,
15519 });
15520 assert!(matches!(
15521 d.validate().unwrap_err(),
15522 DepError::FontePinEmpty { ref pin, .. } if pin == ":tag"
15523 ));
15524 }
15525
15526 #[test]
15527 fn fonte_pin_shape_fires_after_repo_empty() {
15528 // Order pin: `:repo ""` is the more self-locating axis
15529 // (every git source needs a repo; the per-pin shape gate is
15530 // secondary), so the repo-empty arm fires before the
15531 // per-pin shape arm even when both are violated. Pinned so
15532 // a future reordering surfaces here. Mirrors
15533 // `fonte_repo_empty_fires_before_pin_missing` on the
15534 // adjacent axis pair.
15535 let d = dep_with_fonte(DepSource::Git {
15536 repo: String::new(),
15537 tag: Some("v0.1.0 ".into()),
15538 rev: None,
15539 branch: None,
15540 });
15541 assert!(matches!(
15542 d.validate().unwrap_err(),
15543 DepError::FonteRepoEmpty { .. }
15544 ));
15545 }
15546
15547 #[test]
15548 fn fonte_pin_shape_diagnostic_carries_offending_nome_pin_value() {
15549 // Diagnostic-shape pin across both refname-shaped axes
15550 // (`:tag` + `:branch`): every `FontePinShape` variant names
15551 // the offending dep's `:nome` + the offending pin axis + the
15552 // offending value verbatim, so the author's grep target is
15553 // unambiguous (the literal `:tag "<value>"` / `:branch
15554 // "<value>"` lands in caixa.lisp with quotes). Cover both
15555 // pin axes so a future variant addition forces a parallel
15556 // diagnostic-shape decision.
15557 for (pin_label, fonte) in [
15558 (
15559 ":tag",
15560 DepSource::Git {
15561 repo: "github:p/x".into(),
15562 tag: Some("v0.1.0~1".into()),
15563 rev: None,
15564 branch: None,
15565 },
15566 ),
15567 (
15568 ":branch",
15569 DepSource::Git {
15570 repo: "github:p/x".into(),
15571 tag: None,
15572 rev: None,
15573 branch: Some("feature/foo*".into()),
15574 },
15575 ),
15576 ] {
15577 let d = dep_with_fonte(fonte);
15578 let msg = d
15579 .validate()
15580 .expect_err(&format!("{pin_label}: expected FontePinShape"))
15581 .to_string();
15582 assert!(
15583 msg.contains("\"caixa-teia\""),
15584 "{pin_label}: diagnostic must quote the offending :nome verbatim, got {msg:?}"
15585 );
15586 assert!(
15587 msg.contains(pin_label),
15588 "{pin_label}: diagnostic must name the offending pin axis, got {msg:?}"
15589 );
15590 }
15591 }
15592
15593 #[test]
15594 fn git_source_json_round_trip() {
15595 let src = DepSource::Git {
15596 repo: "github:pleme-io/caixa-teia".into(),
15597 tag: Some("v0.1.0".into()),
15598 rev: None,
15599 branch: None,
15600 };
15601 let s = serde_json::to_string(&src).unwrap();
15602 assert!(s.contains(&format!(
15603 r#""{tipo}":"{git}""#,
15604 tipo = crate::render::DEP_SOURCE_KEY_TIPO,
15605 git = crate::render::DEP_SOURCE_TIPO_GIT,
15606 )));
15607 assert!(s.contains(r#""repo":"github:pleme-io/caixa-teia""#));
15608 assert!(s.contains(r#""tag":"v0.1.0""#));
15609 assert!(!s.contains("rev"));
15610 assert!(!s.contains("branch"));
15611 let round: DepSource = serde_json::from_str(&s).unwrap();
15612 assert_eq!(round, src);
15613 }
15614
15615 // ── DEP_SOURCE_{KEY_TIPO,TIPO_GIT,TIPO_PATH} drift-detection ────────
15616 //
15617 // The `#[serde(tag = "tipo", rename_all = "lowercase")]` derive
15618 // attribute on [`DepSource`] pins three load-bearing byte-sequences
15619 // that flow into every serialized `Dep.fonte` block: the outer
15620 // discriminator-key `"tipo"` the `tag = "tipo"` attribute names, and
15621 // the two admitted variant-tag values `"git"` / `"path"` the
15622 // `rename_all = "lowercase"` attribute pins as the discriminator's
15623 // closed-set arms. The three pin tests below round-trip a
15624 // fully-populated variant of each arm through
15625 // [`serde_json::to_value`] and assert each canonical byte-sequence
15626 // appears at its axis — pins a hypothetical future
15627 // `tag = "type"` / `tag = "source_type"` typo, a `rename_all`
15628 // rebrand (`"UPPERCASE"` / `"snake_case"` / `"kebab-case"`), or a
15629 // Rust-side variant rename (`Git` → `Repository`, `Path` → `Local`)
15630 // at build time rather than at fetch time when the resolver's
15631 // `Dep.fonte` dispatch silently fails to match on the drifted
15632 // discriminator. Same "serialize-and-check" discipline the peer
15633 // `M2_LIMITS_KEY_*`, `M2_BEHAVIOR_KEY_ON_*`, `SUPERVISOR_KEY_*`,
15634 // and `MEMBRO_KEY_*` drift-detection pins carry — extended here
15635 // to the last `#[serde(tag = ..., rename_all = ...)]` discriminator
15636 // family in caixa-core lacking a lifted peer.
15637
15638 #[test]
15639 fn dep_source_git_serde_keys_match_lifted_dep_source_key_consts() {
15640 // Fail-before-pass-after: a future `tag = "type"` at the derive
15641 // attribute would serialize under `"type":"git"`, and this test
15642 // would trip because `"tipo"` no longer appears at the emitted
15643 // discriminator key. A future `rename_all = "kebab-case"` /
15644 // `"snake_case"` (both no-ops on `Git` since it lacks internal
15645 // word boundaries) is caught by the sibling
15646 // `dep_source_path_serde_keys_match_lifted_dep_source_key_consts`
15647 // pin below (Path has no internal boundary either but the pair
15648 // catches any per-arm inconsistency). A future variant rename
15649 // `Git` → `Repository` would emit `"tipo":"repository"` and
15650 // trip this pin.
15651 let src = DepSource::Git {
15652 repo: "github:pleme-io/caixa-teia".into(),
15653 tag: Some("v0.1.0".into()),
15654 rev: None,
15655 branch: None,
15656 };
15657 let json = serde_json::to_value(&src).unwrap();
15658 let obj = json.as_object().expect("Git serializes as a JSON object");
15659 assert_eq!(
15660 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15661 .and_then(serde_json::Value::as_str),
15662 Some(crate::render::DEP_SOURCE_TIPO_GIT),
15663 "DepSource::Git must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15664 with value DEP_SOURCE_TIPO_GIT — attribute drift or variant rename \
15665 detected in {json}"
15666 );
15667 }
15668
15669 #[test]
15670 fn dep_source_path_serde_keys_match_lifted_dep_source_key_consts() {
15671 // Fail-before-pass-after: a future variant rename `Path` →
15672 // `Local` / `Filesystem` would emit `"tipo":"local"` and trip
15673 // this pin. A per-consumer disambiguation as the `defcaixa`
15674 // macro stabilizes ("caminho" → "path" for English-uniformity)
15675 // is scoped to the inner field key, not the discriminator; this
15676 // pin is orthogonal to that and catches only the outer
15677 // discriminator drift.
15678 let src = DepSource::Path {
15679 caminho: "../caixa-teia".into(),
15680 };
15681 let json = serde_json::to_value(&src).unwrap();
15682 let obj = json.as_object().expect("Path serializes as a JSON object");
15683 assert_eq!(
15684 obj.get(crate::render::DEP_SOURCE_KEY_TIPO)
15685 .and_then(serde_json::Value::as_str),
15686 Some(crate::render::DEP_SOURCE_TIPO_PATH),
15687 "DepSource::Path must serialize the tipo discriminator at DEP_SOURCE_KEY_TIPO \
15688 with value DEP_SOURCE_TIPO_PATH — attribute drift or variant rename \
15689 detected in {json}"
15690 );
15691 }
15692
15693 #[test]
15694 fn dep_source_key_consts_are_pairwise_distinct() {
15695 // Cross-axis collapse detector: a hypothetical future edit that
15696 // accidentally set two of the three consts to the same byte
15697 // (`DEP_SOURCE_TIPO_GIT = "path"` typo matching a peer arm) would
15698 // pass every per-arm serialize pin above but silently collapse
15699 // the discriminator's closed-set arms onto one another; this pin
15700 // catches the collapse at build time.
15701 assert_ne!(
15702 crate::render::DEP_SOURCE_KEY_TIPO,
15703 crate::render::DEP_SOURCE_TIPO_GIT,
15704 );
15705 assert_ne!(
15706 crate::render::DEP_SOURCE_KEY_TIPO,
15707 crate::render::DEP_SOURCE_TIPO_PATH,
15708 );
15709 assert_ne!(
15710 crate::render::DEP_SOURCE_TIPO_GIT,
15711 crate::render::DEP_SOURCE_TIPO_PATH,
15712 );
15713 }
15714
15715 #[test]
15716 fn dep_source_tipo_variant_consts_are_ascii_lowercase_shape() {
15717 // Shape pin against `rename_all` drift: the two variant-tag
15718 // consts must be ASCII-lowercase-only to match the
15719 // `rename_all = "lowercase"` attribute the derive uses; a future
15720 // rebrand to `"UPPERCASE"` / `"PascalCase"` at the attribute
15721 // would emit `"GIT"` / `"Git"` instead and trip this pin.
15722 for (label, s) in [
15723 ("DEP_SOURCE_TIPO_GIT", crate::render::DEP_SOURCE_TIPO_GIT),
15724 ("DEP_SOURCE_TIPO_PATH", crate::render::DEP_SOURCE_TIPO_PATH),
15725 ] {
15726 assert!(!s.is_empty(), "{label} must not be empty");
15727 assert!(
15728 s.bytes().all(|b| b.is_ascii_lowercase()),
15729 "{label} must be ASCII-lowercase-only (matching \
15730 rename_all = \"lowercase\"), got {s:?}",
15731 );
15732 }
15733 }
15734
15735 // ── per-entry :caracteristicas set-not-multiset gate ────────────
15736 //
15737 // Every Vec-keyed-by-name authoring surface on the typed Caixa
15738 // surface that identifies its entries by a name field now uniformly
15739 // closes the set-not-multiset discipline at build time (cite
15740 // `validate_caracteristicas`'s peer-axis enumeration). The
15741 // `:caracteristicas` axis is per-`Dep`: the feature-toggle slot is
15742 // set-shaped (a feature is either enabled or not — there is no
15743 // `feature × 2` semantic), so two entries naming the same feature
15744 // are a redundant declaration the caixa-resolver's lacre pipeline
15745 // would silently dedup at resolve time. The empty-feature arm
15746 // closes the parallel "operationally-meaningless value" axis on
15747 // the same slot. Same linear-walk + `HashSet` + first-collision
15748 // shape every peer set gate uses; same empty-first cascade every
15749 // peer per-entry shape + duplicate gate uses (the empty-feature
15750 // axis is the more-actionable defect since two `""` entries would
15751 // both report `caracteristica: ""` under a duplicate-first
15752 // ordering, with no way to distinguish the offending site).
15753
15754 fn dep_with_features(features: &[&str]) -> Dep {
15755 Dep {
15756 nome: "caixa-teia".into(),
15757 versao: "^0.1".into(),
15758 fonte: None,
15759 opcional: false,
15760 caracteristicas: features.iter().map(|s| (*s).into()).collect(),
15761 }
15762 }
15763
15764 #[test]
15765 fn validate_rejects_empty_caracteristica() {
15766 // Fail-before-pass-after pin: every pre-gate codebase accepted
15767 // `(:caracteristicas (""))` cleanly (the `Vec<String>` field
15768 // imposed no per-entry shape contract), the dep validated, and
15769 // the empty feature would have reached the future caixa-resolver
15770 // lacre pipeline as a no-op feature enable — silently dropping
15771 // the author's intent far from the source `caixa.lisp`. The new
15772 // gate surfaces the structural defect at the typed-validate
15773 // surface with a self-locating diagnostic naming the offending
15774 // dep's `:nome`.
15775 let d = dep_with_features(&[""]);
15776 assert!(
15777 matches!(d.validate().unwrap_err(), DepError::CaracteristicaEmpty { ref nome } if nome == "caixa-teia"),
15778 "expected CaracteristicaEmpty, got {:?}",
15779 d.validate(),
15780 );
15781 }
15782
15783 #[test]
15784 fn validate_rejects_duplicate_caracteristica() {
15785 // Fail-before-pass-after pin on the set-not-multiset arm: the
15786 // feature-toggle slot is set-shaped, so `(:caracteristicas
15787 // ("http" "http"))` is a redundant declaration the lacre
15788 // pipeline dedupes silently at resolve time. The diagnostic
15789 // names the offending dep + the colliding feature verbatim so
15790 // the author can grep their caixa.lisp for `:caracteristicas`
15791 // and fix it in one edit. First-collision determinism is
15792 // pinned separately below.
15793 let d = dep_with_features(&["http", "http"]);
15794 assert!(
15795 matches!(
15796 d.validate().unwrap_err(),
15797 DepError::CaracteristicaDuplicate { ref nome, ref caracteristica }
15798 if nome == "caixa-teia" && caracteristica == "http"
15799 ),
15800 "expected CaracteristicaDuplicate, got {:?}",
15801 d.validate(),
15802 );
15803 }
15804
15805 #[test]
15806 fn validate_accepts_distinct_caracteristicas() {
15807 // The canonical authoring shape — every feature distinct — must
15808 // remain a clean pass (positive control sweep). Covers the
15809 // canonical kebab-case feature names a target caixa typically
15810 // declares.
15811 dep_with_features(&["http", "json", "tls"])
15812 .validate()
15813 .unwrap();
15814 }
15815
15816 #[test]
15817 fn validate_accepts_single_caracteristica() {
15818 // Single-element list is the minimum non-empty shape; passes
15819 // the gate as the identity of the duplicate check (no second
15820 // entry to collide with).
15821 dep_with_features(&["http"]).validate().unwrap();
15822 }
15823
15824 #[test]
15825 fn validate_accepts_empty_caracteristicas_list() {
15826 // The bare-dep authoring shape (`Dep::simple` / `Dep::git`)
15827 // produces `caracteristicas: Vec::new()`; the empty list is
15828 // the gate's empty-set identity and passes vacuously. Pin
15829 // this so a future tightening that requires ≥1 feature
15830 // surfaces here as a test failure rather than a silent
15831 // contract narrowing.
15832 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
15833 assert!(dep_with_features(&[]).validate().is_ok());
15834 }
15835
15836 #[test]
15837 fn validate_caracteristica_empty_fires_before_duplicate() {
15838 // Empty-first cascade: an entry with an empty feature *and*
15839 // duplicate entries surfaces the empty diagnostic first. The
15840 // empty-feature axis is the more-actionable defect since
15841 // `caracteristica: ""` is unambiguous; under duplicate-first
15842 // ordering the diagnostic could report the empty string from
15843 // either of two empty entries with no way to distinguish.
15844 // Mirrors the peer empty-before-duplicate ordering
15845 // discipline every per-entry shape + duplicate gate establishes
15846 // (`SupervisorSpec::validate`'s `EmptyChildName` arm before
15847 // `DuplicateChildCaixa`, `validate_membros`'s
15848 // `MembroCaixaEmpty` arm before `MembroDuplicate`).
15849 let d = dep_with_features(&["", "http", "http"]);
15850 assert!(matches!(
15851 d.validate().unwrap_err(),
15852 DepError::CaracteristicaEmpty { .. }
15853 ));
15854 }
15855
15856 #[test]
15857 fn validate_caracteristica_duplicate_first_collision_determinism() {
15858 // Three matching entries: the second occurrence surfaces the
15859 // diagnostic (the second is the first *collision* — the first
15860 // entry is the establishing one, not a duplicate). Mirrors
15861 // every peer first-collision posture
15862 // (`SupervisorError::DuplicateChildCaixa` reports the second
15863 // collision, `AplicacaoError::MembroDuplicate` reports the
15864 // second, `DepError::DuplicateNome` reports the second).
15865 // Pinning this so a future shortcut that flips to last-
15866 // collision (or non-deterministic) surfaces here.
15867 let d = dep_with_features(&["http", "http", "http"]);
15868 assert!(matches!(
15869 d.validate().unwrap_err(),
15870 DepError::CaracteristicaDuplicate { ref caracteristica, .. } if caracteristica == "http"
15871 ));
15872 }
15873
15874 #[test]
15875 fn validate_per_entry_shape_fires_before_caracteristicas() {
15876 // Per-entry shape precedence: a dep with a malformed `:nome`
15877 // (uppercase) AND duplicate `:caracteristicas` surfaces the
15878 // narrower `NomeInvalid` diagnostic first, not the set-gate
15879 // diagnostic. The `:nome` is the self-locating axis (every
15880 // diagnostic from the caracteristicas gate quotes the
15881 // offending dep's `:nome` to anchor the grep target —
15882 // surfacing the malformed name first keeps that anchor
15883 // valid). Same precedence shape every peer per-entry-shape
15884 // arm establishes against its peer set-gate
15885 // (`validate_deps_per_entry_validate_fires_before_duplicate_in_deps`
15886 // on the cross-entry `:nome` axis).
15887 let d = Dep {
15888 nome: "Caixa-Teia".into(), // uppercase — DNS-1123 violation
15889 versao: "^0.1".into(),
15890 fonte: None,
15891 opcional: false,
15892 caracteristicas: vec!["http".into(), "http".into()],
15893 };
15894 assert!(matches!(
15895 d.validate().unwrap_err(),
15896 DepError::NomeInvalid { .. }
15897 ));
15898 }
15899
15900 // ── per-entry :caracteristicas value-shape gate ──────────────────
15901 //
15902 // Until this gate landed `:caracteristicas` only refused the empty
15903 // string and cross-entry duplicates: a non-empty distinct but
15904 // structurally invalid feature name silently passed validate and the
15905 // failure surfaced at `cargo metadata` time as Cargo's
15906 // `restricted_names::validate_feature_name` parser rejection, far from
15907 // the source `caixa.lisp` with no field naming which `:deps` entry's
15908 // `:caracteristicas` carried the typo. The lifted predicate makes the
15909 // Cargo-feature-name-grammar intersection-floor a substrate-level
15910 // invariant at validate time. Same trajectory as the eight peer
15911 // value-shape predicates each typed surface downstream of a structured
15912 // grammar already follows.
15913
15914 #[test]
15915 fn validate_rejects_caracteristica_with_leading_plus() {
15916 // Fail-before-pass-after pin on the canonical Cargo
15917 // `+<feature>` activation-form-in-feature-name-slot footgun.
15918 // Cargo's `[dependencies.<dep>.features]` list grammar accepts
15919 // `+optional-feature` as an enablement of a previously-disabled
15920 // feature; pasting that activation form into `:caracteristicas`
15921 // (which names the feature itself) silently passed pre-gate and
15922 // failed at `cargo metadata` parse time.
15923 let d = dep_with_features(&["+http"]);
15924 let err = d.validate().unwrap_err();
15925 assert!(
15926 matches!(
15927 err,
15928 DepError::CaracteristicaInvalid { ref nome, ref caracteristica, .. }
15929 if nome == "caixa-teia" && caracteristica == "+http"
15930 ),
15931 "expected CaracteristicaInvalid, got {err:?}"
15932 );
15933 }
15934
15935 #[test]
15936 fn validate_rejects_caracteristica_with_leading_hyphen() {
15937 // Fail-before-pass-after pin on the leading-hyphen footgun. `-`
15938 // is a legitimate continuation character (kebab-case feature
15939 // names like `runtime-tokio` pass) but Cargo rejects it at the
15940 // start; the structural defect — and its CLI-argument-injection
15941 // adjacency at any downstream Cargo subprocess invocation — is
15942 // closed at validate time, not at `cargo metadata` time.
15943 let d = dep_with_features(&["-json"]);
15944 let err = d.validate().unwrap_err();
15945 assert!(
15946 matches!(
15947 err,
15948 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "-json"
15949 ),
15950 "expected CaracteristicaInvalid, got {err:?}"
15951 );
15952 }
15953
15954 #[test]
15955 fn validate_rejects_caracteristica_with_leading_dot() {
15956 // Fail-before-pass-after pin on the leading-dot footgun. `.` is
15957 // a legitimate continuation character (version-suffix shapes
15958 // like `feat.v2` pass) but the leading-dot form is the
15959 // canonical dotted-version-suffix-as-feature-name confusion.
15960 let d = dep_with_features(&[".feat"]);
15961 let err = d.validate().unwrap_err();
15962 assert!(matches!(
15963 err,
15964 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == ".feat"
15965 ));
15966 }
15967
15968 #[test]
15969 fn validate_rejects_caracteristica_with_whitespace() {
15970 // Fail-before-pass-after pin on the embedded-whitespace footgun:
15971 // a feature name with a space inside is structurally a multi-
15972 // token blob (the canonical paste-from-doc footgun, or an
15973 // accidental `"http server"` where the author meant
15974 // `"http-server"`).
15975 let d = dep_with_features(&["http feature"]);
15976 let err = d.validate().unwrap_err();
15977 assert!(matches!(
15978 err,
15979 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http feature"
15980 ));
15981 }
15982
15983 #[test]
15984 fn validate_rejects_caracteristica_with_comma() {
15985 // Fail-before-pass-after pin on the embedded-comma footgun:
15986 // the list-separator-belongs-to-the-list-grammar
15987 // miscomprehension where the author writes
15988 // `:caracteristicas ("http,json")` intending two features but
15989 // the `Vec<String>` field consumes the bare token as one entry.
15990 let d = dep_with_features(&["http,json"]);
15991 let err = d.validate().unwrap_err();
15992 assert!(matches!(
15993 err,
15994 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http,json"
15995 ));
15996 }
15997
15998 #[test]
15999 fn validate_rejects_caracteristica_with_slash() {
16000 // Fail-before-pass-after pin on the embedded-slash footgun:
16001 // Cargo's `dep/feat` namespaced-dep syntax applies inside
16002 // `[dependencies.<dep>.features]` list entries that already
16003 // name the parent dep (so the syntax says "enable feature
16004 // `feat` on a transitive dep `dep`"); `:caracteristicas` is
16005 // per-dep already (a sibling slot on the `Dep` itself), so the
16006 // segment separator within an entry must be `-`, `_`, `+`,
16007 // or `.`. The diagnostic remediation points at the canonical
16008 // Cargo namespaced-dep discipline.
16009 let d = dep_with_features(&["http/json"]);
16010 let err = d.validate().unwrap_err();
16011 assert!(matches!(
16012 err,
16013 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "http/json"
16014 ));
16015 }
16016
16017 #[test]
16018 fn validate_rejects_caracteristica_with_non_ascii() {
16019 // Fail-before-pass-after pin on the un-percent-encoded non-ASCII
16020 // byte footgun: NFC-vs-NFD normalization across filesystems
16021 // silently rewrites the feature-key, breaking the lacre's
16022 // content-addressing invariant. Pinned at a canonical
16023 // smart-quote-paste shape (`café`) where the raw `é` byte is the
16024 // documented APFS round-trip break.
16025 let d = dep_with_features(&["caf\u{e9}"]);
16026 let err = d.validate().unwrap_err();
16027 assert!(matches!(
16028 err,
16029 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "caf\u{e9}"
16030 ));
16031 }
16032
16033 #[test]
16034 fn validate_rejects_caracteristica_with_control_character() {
16035 // Fail-before-pass-after pin on the embedded-control-character
16036 // footgun: a CR/LF or any 0x00..0x1F / 0x7F byte landing in a
16037 // feature name is the canonical paste-from-multiline-doc
16038 // footgun the predicate's reason wording specifically calls out.
16039 let d = dep_with_features(&["http\njson"]);
16040 let err = d.validate().unwrap_err();
16041 assert!(matches!(err, DepError::CaracteristicaInvalid { .. }));
16042 }
16043
16044 #[test]
16045 fn validate_accepts_canonical_caracteristicas_shapes() {
16046 // Positive control sweep: every canonical Cargo feature name
16047 // shape the pleme-io ecosystem uses must still pass. Mirrors
16048 // the substrate-side `cargo_feature_name_accepts_canonical_forms`
16049 // sweep — drift between either landing site and the predicate's
16050 // accepted set is a build error visible at this pair of tests,
16051 // not a per-renderer "this passed validate but failed at
16052 // cargo metadata time" surprise on the next acceptance.
16053 for s in [
16054 "http",
16055 "json",
16056 "derive",
16057 "serde_json",
16058 "runtime-tokio",
16059 "tokio.full",
16060 "v0.1",
16061 "http+json",
16062 "_internal",
16063 "__private",
16064 "default",
16065 "rt-multi-thread",
16066 "feat.v2",
16067 ] {
16068 let d = dep_with_features(&[s]);
16069 d.validate().unwrap_or_else(|e| {
16070 panic!("canonical Cargo feature name {s:?} must pass validate: {e:?}")
16071 });
16072 }
16073 }
16074
16075 #[test]
16076 fn validate_caracteristica_empty_fires_before_invalid() {
16077 // Cascade precedence pin: an entry list with both an empty
16078 // feature AND an invalid-shape feature surfaces the
16079 // `CaracteristicaEmpty` arm first (the empty value carries no
16080 // self-locating data — `caracteristica: ""` is the diagnostic
16081 // with no way to anchor a grep target — so closing the empty
16082 // axis first preserves the per-entry-shape diagnostic's
16083 // self-locating discipline). Same empty-first cascade every
16084 // peer per-entry shape gate establishes
16085 // (`SupervisorSpec::validate`'s `EmptyChildName` before
16086 // `ChildCaixaInvalid`, `validate_membros`'s `MembroCaixaEmpty`
16087 // before `MembroCaixaInvalid`).
16088 let d = dep_with_features(&["", "+http"]);
16089 assert!(matches!(
16090 d.validate().unwrap_err(),
16091 DepError::CaracteristicaEmpty { .. }
16092 ));
16093 }
16094
16095 #[test]
16096 fn validate_caracteristica_invalid_fires_before_duplicate() {
16097 // Per-entry-shape precedence pin: an entry list with the same
16098 // invalid feature shape declared twice surfaces the
16099 // `CaracteristicaInvalid` diagnostic on the first entry, not
16100 // the `CaracteristicaDuplicate` on the second collision. The
16101 // per-entry shape gate fires before the cross-entry set gate
16102 // — same precedence shape every peer two-arm-plus-set gate
16103 // establishes (`SupervisorSpec::validate`'s
16104 // `ChildCaixaInvalid` before `DuplicateChildCaixa`,
16105 // `validate_membros`'s `MembroCaixaInvalid` before
16106 // `MembroDuplicate`, `Dep::validate`'s `NomeInvalid` before
16107 // cross-list `DuplicateNome`).
16108 let d = dep_with_features(&["+http", "+http"]);
16109 assert!(matches!(
16110 d.validate().unwrap_err(),
16111 DepError::CaracteristicaInvalid { ref caracteristica, .. } if caracteristica == "+http"
16112 ));
16113 }
16114
16115 #[test]
16116 fn validate_rejects_caracteristica_at_65_byte_boundary() {
16117 // Boundary pin on the 64-byte cap — both the boundary-accepting
16118 // case and the boundary-exceeding case in one place, so a
16119 // future cap shift surfaces both arms simultaneously, mirroring
16120 // the peer `cargo_feature_name_rejects_at_65_byte_boundary`
16121 // predicate-level pin at the dep-axis landing site.
16122 let max_ok = "a".repeat(64);
16123 dep_with_features(&[&max_ok])
16124 .validate()
16125 .unwrap_or_else(|e| panic!("64-byte feature name must pass: {e:?}"));
16126 let too_long = "a".repeat(65);
16127 let d = dep_with_features(&[&too_long]);
16128 assert!(matches!(
16129 d.validate().unwrap_err(),
16130 DepError::CaracteristicaInvalid { .. }
16131 ));
16132 }
16133
16134 // ── self-dep cross-slot gate ─────────────────────────────────────
16135
16136 #[test]
16137 fn validate_no_self_dep_rejects_self_in_deps() {
16138 // A caixa whose `:deps` lists its own `:nome` is a one-node
16139 // cycle in the lacre closure's dep-graph traversal — rejected,
16140 // naming the parent and the offending list tag.
16141 let deps = vec![
16142 Dep::simple("caixa-teia", "^0.1"),
16143 Dep::simple("orquestra", "^0.1"),
16144 ];
16145 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16146 assert!(
16147 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16148 "got {err:?}"
16149 );
16150 }
16151
16152 #[test]
16153 fn validate_no_self_dep_rejects_self_in_deps_dev() {
16154 // Same gate on the `:deps-dev` axis — neither dep list is a
16155 // second-class citizen on the self-edge invariant.
16156 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16157 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16158 assert!(
16159 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16160 "got {err:?}"
16161 );
16162 }
16163
16164 #[test]
16165 fn validate_no_self_dep_deps_fires_before_deps_dev() {
16166 // Walk order pin: a caixa that self-references on both lists
16167 // surfaces the `:deps` arm first — the load-bearing axis the
16168 // lacre closure resolves at every build. Mirrors the canonical
16169 // [`Caixa::validate_deps`] cascade (`:deps` → `:deps-dev`).
16170 let deps = vec![Dep::simple("orquestra", "^0.1")];
16171 let deps_dev = vec![Dep::simple("orquestra", "^0.2")];
16172 let err = validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap_err();
16173 assert!(
16174 matches!(err, DepError::DepIsSelf { ref nome, list } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS),
16175 "got {err:?}"
16176 );
16177 }
16178
16179 #[test]
16180 fn validate_no_self_dep_accepts_distinct_names() {
16181 // Positive control: every dep names a distinct caixa. The
16182 // canonical author surface — peer of
16183 // [`validate_no_self_supervision_accepts_distinct_children`].
16184 let deps = vec![
16185 Dep::simple("caixa-teia", "^0.1"),
16186 Dep::simple("caixa-arch", "^0.1"),
16187 ];
16188 let deps_dev = vec![Dep::simple("caixa-test", "^0.1")];
16189 validate_no_self_dep(&deps, &deps_dev, "orquestra").unwrap();
16190 }
16191
16192 #[test]
16193 fn validate_no_self_dep_empty_lists_pass() {
16194 // A caixa with no declared deps has nothing to self-reference —
16195 // the gate is vacuously satisfied. Peer of
16196 // [`validate_no_self_supervision_empty_children_is_ok`].
16197 validate_no_self_dep(&[], &[], "orquestra").unwrap();
16198 }
16199
16200 #[test]
16201 fn validate_no_self_dep_diagnostic_carries_offending_list_and_nome() {
16202 // Diagnostic-shape pin (peer with
16203 // [`validate_no_self_supervision`]'s diagnostic): the error's
16204 // Display surfaces both the offending list tag and the
16205 // parent's `:nome` verbatim, so the author can grep their
16206 // caixa.lisp for the offending block in one edit. Names
16207 // `:bibliotecas` / `:exe` / `:servicos` as the corrective
16208 // surface — every legitimate "I want to use code from this
16209 // caixa" intent routes through one of those three slots.
16210 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16211 let rendered = validate_no_self_dep(&[], &deps_dev, "orquestra")
16212 .unwrap_err()
16213 .to_string();
16214 assert!(
16215 rendered.contains(crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
16216 "diagnostic must name the offending list tag: {rendered}",
16217 );
16218 assert!(
16219 rendered.contains("orquestra"),
16220 "diagnostic must quote the parent caixa name: {rendered}",
16221 );
16222 assert!(
16223 rendered.contains(":bibliotecas"),
16224 "diagnostic must point at the corrective code-surface slot: {rendered}",
16225 );
16226 }
16227
16228 #[test]
16229 fn validate_no_self_dep_accepts_coincidental_substring_match() {
16230 // Identity is exact-string equality, not substring — a dep
16231 // named `"orquestra-helper"` is a distinct caixa even when the
16232 // parent is `"orquestra"`. Pin the exact-match discipline so a
16233 // future relaxation that uses `contains` surfaces here, peer
16234 // with the supervision-tree and Aplicacao-membership gates
16235 // which all use exact-string equality on the typed identity.
16236 let deps = vec![Dep::simple("orquestra-helper", "^0.1")];
16237 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16238 }
16239
16240 // ── drift-detection: DEP_AUTHOR_KEY_{DEPS,DEPS_DEV} pin ─────────────
16241
16242 #[test]
16243 fn dep_author_key_consts_pin_canonical_kebab_case_labels() {
16244 // Scalar-value pin: the two author-facing kebab-case labels the
16245 // `(defcaixa … :deps ((…)) :deps-dev ((…)))` surface admits on
16246 // the two-list dep-graph slot axis, one arm per typed slot.
16247 // Mirrors the peer scalar-value pin the sibling
16248 // [`crate::M2_AUTHOR_KEY_LIMITS`] /
16249 // [`crate::M2_AUTHOR_KEY_BEHAVIOR`] /
16250 // [`crate::M2_AUTHOR_KEY_UPGRADE_FROM`] (f49c8b0) M2 top-level
16251 // author-labels, [`crate::M3_AUTHOR_KEY_MEMBROS`] etc.
16252 // (882f498) M3 top-level author-labels, and
16253 // [`crate::SUPERVISOR_AUTHOR_KEY_ESTRATEGIA`] etc. (be40492)
16254 // Supervisor top-level author-labels carry, so every kind-scoped
16255 // typed-slot-family axis routes through one canonical per-arm
16256 // declaration.
16257 //
16258 // A future rebrand (`:deps` → `:dependencies` matching Cargo's
16259 // verbatim key, `:deps-dev` → `:dev-dependencies` matching the
16260 // same, `:deps` / `:deps-dev` → `:runtime-deps` / `:dev-deps`
16261 // for symmetry) lands as an edit to exactly one const, and
16262 // every consumer that reaches for the label picks it up at
16263 // build time rather than at runtime as a downstream mismatch on
16264 // a `DepError::DuplicateNome { list: … }` diagnostic far from
16265 // the rename's commit.
16266 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS, ":deps");
16267 assert_eq!(crate::render::DEP_AUTHOR_KEY_DEPS_DEV, ":deps-dev");
16268 }
16269
16270 #[test]
16271 fn dep_author_key_consts_are_pairwise_distinct() {
16272 // Distinct-labels pin: the two `:deps` / `:deps-dev` labels
16273 // must not collapse onto one byte-string. A future copy-paste
16274 // slip that renamed both consts to the same value (or a rebrand
16275 // that dropped the `-dev` suffix from one but not the other)
16276 // would leave every `DepError::DuplicateNome { list: … }`
16277 // diagnostic naming an unattributable list — the linter would
16278 // route the author to the wrong caixa.lisp block, or the
16279 // cross-list precedence gate
16280 // (`validate_deps_duplicate_in_deps_fires_before_duplicate_in_deps_dev`)
16281 // would surface a `:deps`-tagged diagnostic on a `:deps-dev`
16282 // duplicate. Peer of the sibling
16283 // `m2_author_key_consts_are_pairwise_distinct`-shape gates the
16284 // other top-level kind-scoped slot-family axes carry
16285 // (implicitly held by their different byte-values today).
16286 assert_ne!(
16287 crate::render::DEP_AUTHOR_KEY_DEPS,
16288 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16289 "DEP_AUTHOR_KEY_{{DEPS,DEPS_DEV}} consts must be pairwise-distinct \
16290 so a `DepError::DuplicateNome {{ list: … }}` diagnostic \
16291 self-locates the offending block in the author's caixa.lisp",
16292 );
16293 }
16294
16295 #[test]
16296 fn validate_no_self_dep_routes_through_lifted_dep_author_key_consts() {
16297 // Production-through-const pin: the two per-arm list tags
16298 // [`validate_no_self_dep`] threads onto the `list:` field of a
16299 // returned [`DepError::DepIsSelf`] route through the lifted
16300 // [`crate::DEP_AUTHOR_KEY_DEPS`] /
16301 // [`crate::DEP_AUTHOR_KEY_DEPS_DEV`] consts. A future drift at
16302 // the walker (a rename that reaches one arm but not the const,
16303 // or vice versa) surfaces here at build time rather than at
16304 // runtime as a `feira lint` diagnostic naming the wrong list
16305 // tag. Mirror of the peer
16306 // [`crate::Caixa::declared_servico_slots`] production tagger
16307 // pin (f49c8b0) on the sibling M2 top-level slot axis, extended
16308 // onto the two-list dep-graph gate.
16309 let deps = vec![Dep::simple("orquestra", "^0.1")];
16310 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16311 let DepError::DepIsSelf { list, .. } = err else {
16312 panic!("expected DepIsSelf from :deps walk");
16313 };
16314 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS);
16315
16316 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16317 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16318 let DepError::DepIsSelf { list, .. } = err else {
16319 panic!("expected DepIsSelf from :deps-dev walk");
16320 };
16321 assert_eq!(list, crate::render::DEP_AUTHOR_KEY_DEPS_DEV);
16322 }
16323
16324 // ── Dep::nome accessor pins ───────────────────────────────────────
16325 //
16326 // Three coherence pins on the lifted `Dep::nome` accessor: byte-equal
16327 // projection over the plain-shorthand / explicit-git / explicit-path
16328 // fixture triad the [`Dep`] docstring lists (so the accessor's
16329 // accept-set is exercised across every author-surface `:fonte`
16330 // shape); by-borrow pointer identity so the projection stays
16331 // zero-copy at every consumer site; and validate-composition through
16332 // the [`validate_no_self_dep`] cross-slot gate reading its
16333 // parent-name equality check through the lifted accessor rather than
16334 // the raw field.
16335
16336 #[test]
16337 fn dep_nome_returns_declared_nome_across_fonte_shapes() {
16338 // Plain-shorthand form (`:fonte None`).
16339 assert_eq!(Dep::simple("caixa-teia", "^0.1").nome(), "caixa-teia");
16340 // Explicit git-source form with a tag pin — same accessor path.
16341 assert_eq!(
16342 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").nome(),
16343 "caixa-teia",
16344 );
16345 // Explicit path-source form.
16346 assert_eq!(
16347 Dep {
16348 nome: "caixa-teia".to_string(),
16349 versao: "0.1.0".to_string(),
16350 fonte: Some(DepSource::Path {
16351 caminho: "../caixa-teia".to_string(),
16352 }),
16353 opcional: false,
16354 caracteristicas: Vec::new(),
16355 }
16356 .nome(),
16357 "caixa-teia",
16358 );
16359 // The empty-string `:nome` sentinel (which [`Dep::validate`]
16360 // refuses through the [`DepError::NomeEmpty`] arm) still round-
16361 // trips as an empty `&str` through the accessor — the accessor is
16362 // a projection, not a gate; the gate is [`Dep::validate`].
16363 assert_eq!(Dep::simple("", "^0.1").nome(), "");
16364 }
16365
16366 #[test]
16367 fn dep_nome_is_by_borrow_pointer_identity() {
16368 // Zero-copy pin: the accessor must borrow into the field's own
16369 // storage, not clone. If a future rewrite regresses to
16370 // `self.nome.clone().leak()` or an owned-buffer shape, the two
16371 // pointers diverge and this pin fails at build time.
16372 let d = Dep::simple("caixa-teia", "^0.1");
16373 assert!(std::ptr::eq(d.nome().as_ptr(), d.nome.as_ptr()));
16374 }
16375
16376 // ── Dep::versao_requirement accessor pins ─────────────────────────
16377 //
16378 // Three coherence pins on the lifted `Dep::versao_requirement`
16379 // accessor: byte-equal projection over the plain-shorthand /
16380 // explicit-git / explicit-path fixture triad the [`Dep`] docstring
16381 // lists plus the empty-sentinel that round-trips as `""` (the accessor
16382 // is a projection, not a gate; the gate is [`Dep::validate`]); by-
16383 // borrow pointer identity so the projection stays zero-copy at every
16384 // consumer site; and validate-composition through the
16385 // [`crate::render::require_valid_versao_requirement`] cascade reading
16386 // its requirement-shape check through the lifted accessor rather than
16387 // the raw field.
16388 #[test]
16389 fn dep_versao_requirement_returns_declared_versao_across_fonte_shapes() {
16390 // Plain-shorthand form (`:fonte None`).
16391 assert_eq!(
16392 Dep::simple("caixa-teia", "^0.1").versao_requirement(),
16393 "^0.1",
16394 );
16395 // Explicit git-source form with a tag pin — same accessor path.
16396 assert_eq!(
16397 Dep::git(
16398 "caixa-teia",
16399 "~0.1.2",
16400 "github:pleme-io/caixa-teia",
16401 "v0.1.0"
16402 )
16403 .versao_requirement(),
16404 "~0.1.2",
16405 );
16406 // Explicit path-source form.
16407 assert_eq!(
16408 Dep {
16409 nome: "caixa-teia".to_string(),
16410 versao: "0.1.0".to_string(),
16411 fonte: Some(DepSource::Path {
16412 caminho: "../caixa-teia".to_string(),
16413 }),
16414 opcional: false,
16415 caracteristicas: Vec::new(),
16416 }
16417 .versao_requirement(),
16418 "0.1.0",
16419 );
16420 // The wildcard requirement (`"*"`) — the shorthand
16421 // `parse_requirement` accepts as `VersionReq::STAR` — round-trips
16422 // verbatim through the accessor as `"*"`, same byte-shape the
16423 // author wrote.
16424 assert_eq!(Dep::simple("caixa-teia", "*").versao_requirement(), "*");
16425 // The empty-string `:versao` sentinel (which [`Dep::validate`]
16426 // refuses through the [`DepError::VersaoEmpty`] arm) still round-
16427 // trips as an empty `&str` through the accessor — the accessor is
16428 // a projection, not a gate; the gate is [`Dep::validate`]. Peer
16429 // of the sibling [`Dep::nome`] empty-sentinel round-trip pin.
16430 assert_eq!(Dep::simple("caixa-teia", "").versao_requirement(), "");
16431 }
16432
16433 #[test]
16434 fn dep_versao_requirement_is_by_borrow_pointer_identity() {
16435 // Zero-copy pin: the accessor must borrow into the field's own
16436 // storage, not clone. If a future rewrite regresses to
16437 // `self.versao.clone().leak()` or an owned-buffer shape, the two
16438 // pointers diverge and this pin fails at build time. Peer of the
16439 // sibling [`Dep::nome`] pointer-identity pin — same by-borrow
16440 // discipline extended onto the requirement-carrying axis.
16441 let d = Dep::simple("caixa-teia", "^0.1");
16442 assert!(std::ptr::eq(
16443 d.versao_requirement().as_ptr(),
16444 d.versao.as_ptr(),
16445 ));
16446 }
16447
16448 #[test]
16449 fn dep_validate_reads_requirement_through_accessor() {
16450 // Composition pin: the [`Dep::validate`]
16451 // [`crate::render::require_valid_versao_requirement`] cascade
16452 // consumes the requirement string through the lifted accessor —
16453 // both the requirement-gate input and the
16454 // [`DepError::VersaoInvalid`] error-body carrier route through
16455 // `self.versao_requirement()`. A valid requirement passes
16456 // (positive control); a malformed-but-non-empty requirement fails
16457 // and the diagnostic quotes the offending byte-string verbatim
16458 // (same shape the accessor projects), so a future regression that
16459 // detoured the requirement carrier through a different byte-
16460 // string (say the parsed `VersionReq`'s `Display`, or a
16461 // normalized rewrite) would surface here at build time. The
16462 // empty-`:versao` arm fires the [`DepError::VersaoEmpty`] variant
16463 // ahead of the parse arm, pinning the empty-first cascade the
16464 // accessor's `""` sentinel round-trip acknowledges.
16465 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16466 let err = Dep::simple("caixa-teia", "v0.1").validate().unwrap_err();
16467 assert!(
16468 matches!(
16469 &err,
16470 DepError::VersaoInvalid {
16471 nome,
16472 versao,
16473 ..
16474 } if nome == "caixa-teia" && versao == "v0.1",
16475 ),
16476 "expected VersaoInvalid quoting the accessor-projected requirement, got {err:?}",
16477 );
16478 let err = Dep::simple("caixa-teia", "").validate().unwrap_err();
16479 assert!(
16480 matches!(
16481 &err,
16482 DepError::VersaoEmpty { nome } if nome == "caixa-teia",
16483 ),
16484 "expected VersaoEmpty from the empty-first arm, got {err:?}",
16485 );
16486 }
16487
16488 // ── Dep::fonte accessor pins ──────────────────────────────────────
16489 //
16490 // Three coherence pins on the lifted `Dep::fonte` accessor: byte-
16491 // equal projection over the plain-shorthand (`:fonte None`) /
16492 // explicit-git-tag / explicit-path fixture triad the [`Dep`]
16493 // docstring lists (so the accessor's accept-set is exercised across
16494 // every author-surface `:fonte` shape and both `DepSource` variants);
16495 // pointer identity so the borrowed reference points into the field's
16496 // own `Option<DepSource>` storage (not a cloned side-buffer); and
16497 // validate-composition through the [`Dep::validate`] gate reading
16498 // its per-`:fonte` [`DepSource::validate`] delegation through the
16499 // lifted accessor rather than the raw `if let Some(ref fonte) =
16500 // self.fonte` bracket.
16501
16502 #[test]
16503 fn dep_fonte_returns_declared_source_across_shapes() {
16504 // Plain-shorthand form — `:fonte` omitted, accessor projects
16505 // the `None` partition the resolver-side default-fill treats
16506 // as "resolve through `github:<default-org>/<nome>`".
16507 assert!(Dep::simple("caixa-teia", "^0.1").fonte().is_none());
16508 // Explicit git-source form with a tag pin — same accessor path.
16509 let git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16510 match git.fonte() {
16511 Some(DepSource::Git {
16512 repo,
16513 tag,
16514 rev,
16515 branch,
16516 }) => {
16517 assert_eq!(repo, "github:pleme-io/caixa-teia");
16518 assert_eq!(tag.as_deref(), Some("v0.1.0"));
16519 assert!(rev.is_none());
16520 assert!(branch.is_none());
16521 }
16522 other => panic!("expected explicit git :fonte, got {other:?}"),
16523 }
16524 // Explicit path-source form — the dev-only local-filesystem
16525 // arm the [`Dep`] docstring's third fixture carries.
16526 let path = Dep {
16527 nome: "caixa-teia".to_string(),
16528 versao: "0.1.0".to_string(),
16529 fonte: Some(DepSource::Path {
16530 caminho: "../caixa-teia".to_string(),
16531 }),
16532 opcional: false,
16533 caracteristicas: Vec::new(),
16534 };
16535 match path.fonte() {
16536 Some(DepSource::Path { caminho }) => {
16537 assert_eq!(caminho, "../caixa-teia");
16538 }
16539 other => panic!("expected explicit path :fonte, got {other:?}"),
16540 }
16541 }
16542
16543 #[test]
16544 fn dep_fonte_is_by_borrow_pointer_identity() {
16545 // Zero-copy pin: the accessor must borrow into the field's own
16546 // `Option<DepSource>` storage, not clone into a side buffer. If
16547 // a future rewrite regresses to `self.fonte.clone()` or an
16548 // owned-buffer shape, the two pointers diverge and this pin
16549 // fails at build time. Peer of the sibling per-`Dep` [`Dep::nome`]
16550 // (eba2cde) / [`Dep::versao_requirement`] (05529b1) pointer-
16551 // identity pins — same by-borrow discipline extended onto the
16552 // outer-`Dep` `Option<&Composite>` composite-reference axis.
16553 let d = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0");
16554 let accessed = d.fonte().expect("git :fonte present") as *const DepSource;
16555 let raw = d.fonte.as_ref().expect("git :fonte present") as *const DepSource;
16556 assert!(std::ptr::eq(accessed, raw));
16557 }
16558
16559 #[test]
16560 fn dep_validate_reads_fonte_through_accessor() {
16561 // Composition pin: [`Dep::validate`]'s per-`:fonte`
16562 // [`DepSource::validate`] delegation consumes the typed slot
16563 // through the lifted accessor — an author-omitted `:fonte`
16564 // still passes the outer gate (positive control), an explicit
16565 // well-formed git source with exactly one pin passes, and a
16566 // malformed git source (empty `:repo`) surfaces the
16567 // [`DepError::FonteRepoEmpty`] variant quoting the offending
16568 // dep's `:nome` verbatim so a future regression that detoured
16569 // the `:fonte` delegation through a different path (say a
16570 // per-scope override projector) would surface here at build
16571 // time. Peer of the sibling
16572 // `dep_validate_reads_requirement_through_accessor` composition
16573 // pin on the `:versao` axis.
16574 // Positive control 1: no `:fonte` at all.
16575 Dep::simple("caixa-teia", "^0.1").validate().unwrap();
16576 // Positive control 2: well-formed git source.
16577 Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
16578 .validate()
16579 .unwrap();
16580 // Negative control: empty `:repo` — the accessor still returns
16581 // `Some(&DepSource::Git { repo: "", … })` and the delegated
16582 // `DepSource::validate` gate raises the typed carrier.
16583 let bad = Dep {
16584 nome: "caixa-teia".to_string(),
16585 versao: "^0.1".to_string(),
16586 fonte: Some(DepSource::Git {
16587 repo: String::new(),
16588 tag: Some("v0.1.0".to_string()),
16589 rev: None,
16590 branch: None,
16591 }),
16592 opcional: false,
16593 caracteristicas: Vec::new(),
16594 };
16595 let err = bad.validate().unwrap_err();
16596 assert!(
16597 matches!(
16598 &err,
16599 DepError::FonteRepoEmpty { nome } if nome == "caixa-teia",
16600 ),
16601 "expected FonteRepoEmpty from the accessor-routed :fonte gate, got {err:?}",
16602 );
16603 }
16604
16605 #[test]
16606 fn validate_no_self_dep_reads_parent_equality_through_accessor() {
16607 // Composition pin: the cross-slot [`validate_no_self_dep`] gate
16608 // rejects a `:deps` entry whose `:nome` equals the parent caixa's
16609 // own `:nome` through the lifted accessor rather than the raw
16610 // field. Fails-before-passes-after: with the accessor lifted the
16611 // gate reads its equality check through `dep.nome() ==
16612 // parent_nome` on both the `:deps` and `:deps-dev` traversals, so
16613 // the diagnostic still names the offending list tag as expected.
16614 let deps = vec![Dep::simple("orquestra", "^0.1")];
16615 let err = validate_no_self_dep(&deps, &[], "orquestra").unwrap_err();
16616 assert!(matches!(
16617 err,
16618 DepError::DepIsSelf {
16619 ref nome,
16620 list,
16621 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS,
16622 ));
16623 let deps_dev = vec![Dep::simple("orquestra", "^0.1")];
16624 let err = validate_no_self_dep(&[], &deps_dev, "orquestra").unwrap_err();
16625 assert!(matches!(
16626 err,
16627 DepError::DepIsSelf {
16628 ref nome,
16629 list,
16630 } if nome == "orquestra" && list == crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
16631 ));
16632 // A non-matching `:nome` passes through the accessor gate.
16633 let deps = vec![Dep::simple("caixa-teia", "^0.1")];
16634 validate_no_self_dep(&deps, &[], "orquestra").unwrap();
16635 }
16636
16637 // ── Dep::caracteristicas accessor pins ────────────────────────────
16638 //
16639 // Three coherence pins on the lifted `Dep::caracteristicas` accessor:
16640 // byte-equal projection over the default-empty / single-entry /
16641 // multi-entry fixture triad (so the accessor's accept-set is
16642 // exercised across every author-surface `:caracteristicas` shape,
16643 // matching the peer sibling family's fixture-triad discipline); by-
16644 // borrow pointer identity so the projection stays zero-copy at every
16645 // consumer site; and validate-composition through the
16646 // [`Dep::validate_caracteristicas`] gate reading its per-entry
16647 // linear walk through the lifted accessor rather than the raw
16648 // `for c in &self.caracteristicas` bracket.
16649
16650 #[test]
16651 fn dep_caracteristicas_returns_declared_features_across_shapes() {
16652 // Default-empty form — the [`Dep::simple`] constructor's
16653 // `Vec::new()` fill; the accessor projects the empty slice
16654 // verbatim (no `None` collapse).
16655 assert!(
16656 Dep::simple("caixa-teia", "^0.1")
16657 .caracteristicas()
16658 .is_empty(),
16659 );
16660 // Single-entry form — the canonical Cargo-shaped one-feature
16661 // enable ([`crate::render::is_cargo_feature_name`] accepts the
16662 // `"http"` byte-string as a valid feature name).
16663 let one = Dep {
16664 nome: "caixa-teia".to_string(),
16665 versao: "^0.1".to_string(),
16666 fonte: None,
16667 opcional: false,
16668 caracteristicas: vec!["http".to_string()],
16669 };
16670 assert_eq!(one.caracteristicas(), &["http".to_string()]);
16671 // Multi-entry form — the substrate's set-shaped multi-feature
16672 // enable, exercising the accessor over a length-two slice with
16673 // no duplicate collapse.
16674 let two = Dep {
16675 nome: "caixa-teia".to_string(),
16676 versao: "^0.1".to_string(),
16677 fonte: None,
16678 opcional: false,
16679 caracteristicas: vec!["http".to_string(), "json".to_string()],
16680 };
16681 assert_eq!(
16682 two.caracteristicas(),
16683 &["http".to_string(), "json".to_string()],
16684 );
16685 }
16686
16687 #[test]
16688 fn dep_caracteristicas_is_by_borrow_pointer_identity() {
16689 // Zero-copy pin: the accessor must borrow into the field's own
16690 // `Vec<String>` storage, not clone into a side buffer. If a
16691 // future rewrite regresses to `self.caracteristicas.clone()` or
16692 // an owned-buffer shape, the two pointers diverge and this pin
16693 // fails at build time. Peer of the sibling per-`Dep`
16694 // [`Dep::nome`] (eba2cde) / [`Dep::versao_requirement`] (05529b1)
16695 // / [`Dep::fonte`] (d65d1bf) pointer-identity pins — same by-
16696 // borrow discipline extended onto the outer-`Dep` `&[String]`
16697 // slice-projection axis.
16698 let d = Dep {
16699 nome: "caixa-teia".to_string(),
16700 versao: "^0.1".to_string(),
16701 fonte: None,
16702 opcional: false,
16703 caracteristicas: vec!["http".to_string(), "json".to_string()],
16704 };
16705 assert!(std::ptr::eq(
16706 d.caracteristicas().as_ptr(),
16707 d.caracteristicas.as_ptr(),
16708 ));
16709 }
16710
16711 #[test]
16712 fn dep_validate_reads_caracteristicas_through_accessor() {
16713 // Composition pin: [`Dep::validate_caracteristicas`]'s per-entry
16714 // linear walk consumes the feature-toggle list through the
16715 // lifted accessor — a well-formed `:caracteristicas` set passes
16716 // (positive control), an empty-string entry surfaces the
16717 // [`DepError::CaracteristicaEmpty`] variant quoting the offending
16718 // `Dep::nome`, and a within-list duplicate surfaces the
16719 // [`DepError::CaracteristicaDuplicate`] variant so a future
16720 // regression that detoured the walk through a different byte-
16721 // string list (say a per-scope override projector) would surface
16722 // here at build time. Peer of the sibling
16723 // `dep_validate_reads_fonte_through_accessor` /
16724 // `dep_validate_reads_requirement_through_accessor` composition
16725 // pins on the `:fonte` / `:versao` axes.
16726 // Positive control: two distinct well-formed feature names pass.
16727 Dep {
16728 nome: "caixa-teia".to_string(),
16729 versao: "^0.1".to_string(),
16730 fonte: None,
16731 opcional: false,
16732 caracteristicas: vec!["http".to_string(), "json".to_string()],
16733 }
16734 .validate()
16735 .unwrap();
16736 // Negative control 1: empty-string feature-name entry — the
16737 // accessor still returns `&[""]` and the walk raises the typed
16738 // empty-first carrier.
16739 let err = Dep {
16740 nome: "caixa-teia".to_string(),
16741 versao: "^0.1".to_string(),
16742 fonte: None,
16743 opcional: false,
16744 caracteristicas: vec![String::new()],
16745 }
16746 .validate()
16747 .unwrap_err();
16748 assert!(
16749 matches!(
16750 &err,
16751 DepError::CaracteristicaEmpty { nome } if nome == "caixa-teia",
16752 ),
16753 "expected CaracteristicaEmpty from the accessor-routed walk, got {err:?}",
16754 );
16755 // Negative control 2: within-list duplicate — the accessor's
16756 // slice view carries both entries, and the walk's dedup arm
16757 // raises the typed duplicate carrier quoting the offending
16758 // feature name verbatim.
16759 let err = Dep {
16760 nome: "caixa-teia".to_string(),
16761 versao: "^0.1".to_string(),
16762 fonte: None,
16763 opcional: false,
16764 caracteristicas: vec!["http".to_string(), "http".to_string()],
16765 }
16766 .validate()
16767 .unwrap_err();
16768 assert!(
16769 matches!(
16770 &err,
16771 DepError::CaracteristicaDuplicate {
16772 nome,
16773 caracteristica,
16774 } if nome == "caixa-teia" && caracteristica == "http",
16775 ),
16776 "expected CaracteristicaDuplicate from the accessor-routed dedup, got {err:?}",
16777 );
16778 }
16779
16780 // ── Dep::opcional accessor pins ───────────────────────────────────
16781 //
16782 // Two coherence pins on the lifted `Dep::opcional` accessor: byte-
16783 // equal projection over the default-`false` / explicit-`true`
16784 // fixture pair across the plain-shorthand (`:fonte None`) / explicit-
16785 // git-tag / explicit-path fixture triad the [`Dep`] docstring lists,
16786 // exercising the accessor's accept-set over every author-surface
16787 // `:fonte` shape × every author-surface `:opcional` shape; and by-
16788 // `Copy` idempotency so the projection stays value-return (no
16789 // silent detour to a fresh `&bool` borrow that would introduce a
16790 // lifetime on the return type the plain-`Copy`-scalar axis's `bool`
16791 // shape elides). No composition pin — `:opcional` does not
16792 // participate in [`Dep::validate`] (an opcional dep with any bool
16793 // value is validate-accepted; the missing-source arm is a resolver-
16794 // side runtime dispatch, not a build-time refusal), so the axis
16795 // reduces to the value-shape + `Copy` pin pair the peer
16796 // [`crate::Caixa::max_restarts`] / [`crate::Caixa::estrategia`]
16797 // outer-`Option<Copy>` accessor pins already carry.
16798
16799 #[test]
16800 fn dep_opcional_returns_declared_opcional_across_fonte_shapes() {
16801 // Default-`false` form via the [`Dep::simple`] constructor —
16802 // the accessor projects the `false` bit the default-fill sets.
16803 assert!(!Dep::simple("caixa-teia", "^0.1").opcional());
16804 // Default-`false` form via the [`Dep::git`] constructor — same
16805 // default fill; the accessor projects `false` regardless of the
16806 // `:fonte` arm.
16807 assert!(!Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0").opcional(),);
16808 // Explicit-`true` form × plain-shorthand `:fonte` — the
16809 // canonical author-surface "this dep may be missing" shape.
16810 let plain_true = Dep {
16811 nome: "caixa-teia".to_string(),
16812 versao: "^0.1".to_string(),
16813 fonte: None,
16814 opcional: true,
16815 caracteristicas: Vec::new(),
16816 };
16817 assert!(plain_true.opcional());
16818 // Explicit-`true` form × explicit git-source — the accessor
16819 // projects the bit verbatim regardless of the `:fonte` arm.
16820 let git_true = Dep {
16821 nome: "caixa-teia".to_string(),
16822 versao: "^0.1".to_string(),
16823 fonte: Some(DepSource::Git {
16824 repo: "github:pleme-io/caixa-teia".to_string(),
16825 tag: Some("v0.1.0".to_string()),
16826 rev: None,
16827 branch: None,
16828 }),
16829 opcional: true,
16830 caracteristicas: Vec::new(),
16831 };
16832 assert!(git_true.opcional());
16833 // Explicit-`true` form × explicit path-source — the dev-only
16834 // local-filesystem arm the [`Dep`] docstring's third fixture
16835 // carries.
16836 let path_true = Dep {
16837 nome: "caixa-teia".to_string(),
16838 versao: "0.1.0".to_string(),
16839 fonte: Some(DepSource::Path {
16840 caminho: "../caixa-teia".to_string(),
16841 }),
16842 opcional: true,
16843 caracteristicas: Vec::new(),
16844 };
16845 assert!(path_true.opcional());
16846 }
16847
16848 #[test]
16849 fn dep_opcional_projects_bool_by_copy() {
16850 // The by-`Copy` pin: [`Dep::opcional`] returns `bool` by value
16851 // (`bool: Copy`) — the accessor does not borrow `&self` past
16852 // the call (no lifetime on the return type), and calling the
16853 // accessor twice on the same [`Dep`] must yield discriminant-
16854 // equal values (idempotent, no side effects on `&self`). Peer
16855 // of the sibling outer-`Caixa` `Option<Copy>` by-`Copy`
16856 // `max_restarts_projects_option_by_copy` (eba5211) /
16857 // `estrategia_projects_option_by_copy` (ed04d3c) pins on the
16858 // outer-`Caixa` altitude — extended here to the outer-`Dep`
16859 // altitude's plain-`Copy` `bool` axis. The `Copy` discipline
16860 // replaces the pointer-equality claim the sibling per-`Dep`
16861 // by-borrow pins (`dep_nome_is_by_borrow_pointer_identity`
16862 // eba2cde, `dep_versao_requirement_is_by_borrow_pointer_identity`
16863 // 05529b1, `dep_fonte_is_by_borrow_pointer_identity` d65d1bf,
16864 // `dep_caracteristicas_is_by_borrow_pointer_identity` 9197944)
16865 // carry (a fresh `Copy` of a `Copy` discriminant is definitionally
16866 // the same discriminant, so the axis reduces to discriminant
16867 // equality).
16868 //
16869 // Pins against a future silent detour that returned a fresh
16870 // `&bool` reference (which would type-check but silently
16871 // introduce a borrow of `&self` past the call, collapsing the
16872 // load-bearing "no lifetime on the return type" `Copy`
16873 // projection the plain-`Copy`-scalar axis's `bool` shape
16874 // carries) or a stale-read side effect that flipped the outer
16875 // discriminant on successive calls.
16876 for opcional in [false, true] {
16877 let d = Dep {
16878 nome: "caixa-teia".to_string(),
16879 versao: "^0.1".to_string(),
16880 fonte: None,
16881 opcional,
16882 caracteristicas: Vec::new(),
16883 };
16884 let first = d.opcional();
16885 let second = d.opcional();
16886 assert_eq!(
16887 first, second,
16888 "Dep::opcional must be idempotent — two successive calls \
16889 on the same &self must return the same bool",
16890 );
16891 assert_eq!(
16892 first, opcional,
16893 "Dep::opcional must return :opcional verbatim by Copy — \
16894 got {first}, expected {opcional}",
16895 );
16896 assert_eq!(
16897 d.opcional(),
16898 d.opcional,
16899 "Dep::opcional accessor and self.opcional field access \
16900 must byte-equal — a bit-flip drift would silently split \
16901 the paired resolver-side drop-vs-error dispatch from \
16902 the storage-side default-fill the [`Dep::simple`] / \
16903 [`Dep::git`] constructor pair carries",
16904 );
16905 }
16906 }
16907
16908 // ── DepSource::sole_pin — sole-set git-pin accessor ─────────────────
16909
16910 #[test]
16911 fn sole_pin_returns_none_for_path_source() {
16912 // A path source carries no git-ref, so `sole_pin()` returns
16913 // `None` structurally — the sibling arm every git-fetching
16914 // consumer partitions off before reaching for a git-ref. Pins
16915 // the Path-arm branch of the accessor against a future silent
16916 // detour that treats a `Self::Path` as an unpinned-git source
16917 // and returns the wrong "no pin" signal (e.g. the empty string,
16918 // or a hard-coded `Some("HEAD")` matching the caixa-crd
16919 // path-arm `git_ref` fill).
16920 let s = DepSource::Path {
16921 caminho: "../local-caixa".to_string(),
16922 };
16923 assert_eq!(s.sole_pin(), None);
16924 }
16925
16926 #[test]
16927 fn sole_pin_returns_none_for_unpinned_git_source() {
16928 // The [`DepSource::default_github`] shorthand shape carries no
16929 // pin — every `tag`/`rev`/`branch` is `None`, and `sole_pin()`
16930 // returns `None`. This is the shape caixa-resolver's `fetch_dep`
16931 // materializes when the author omits `:fonte` entirely, then
16932 // hands to `fetch_git` which raises `ResolveError::MissingPin`
16933 // on the `None` arm — the accessor's return matches the arm
16934 // the resolver's diagnostic keys off.
16935 let s = DepSource::default_github("pleme-io", "caixa-teia");
16936 assert_eq!(s.sole_pin(), None);
16937 }
16938
16939 #[test]
16940 fn sole_pin_returns_rev_when_only_rev_is_set() {
16941 let s = DepSource::Git {
16942 repo: "github:o/x".into(),
16943 tag: None,
16944 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16945 branch: None,
16946 };
16947 assert_eq!(
16948 s.sole_pin(),
16949 Some("deadbeefcafebabe1234567890abcdef12345678")
16950 );
16951 }
16952
16953 #[test]
16954 fn sole_pin_returns_tag_when_only_tag_is_set() {
16955 let s = DepSource::Git {
16956 repo: "github:o/x".into(),
16957 tag: Some("v0.1.0".into()),
16958 rev: None,
16959 branch: None,
16960 };
16961 assert_eq!(s.sole_pin(), Some("v0.1.0"));
16962 }
16963
16964 #[test]
16965 fn sole_pin_returns_branch_when_only_branch_is_set() {
16966 let s = DepSource::Git {
16967 repo: "github:o/x".into(),
16968 tag: None,
16969 rev: None,
16970 branch: Some("main".into()),
16971 };
16972 assert_eq!(s.sole_pin(), Some("main"));
16973 }
16974
16975 #[test]
16976 fn sole_pin_precedence_rev_beats_tag_and_branch() {
16977 // Precedence: rev > tag > branch. Validate() rejects
16978 // multiple-pin shapes, but the accessor's precedence is defined
16979 // for pre-validate consumers (the resolver's `MissingPin`
16980 // diagnostic path, the caixa-crd round-trip's default `"main"`
16981 // fallback) and as defense-in-depth if the gate is ever
16982 // bypassed. Pins the same precedence caixa-resolver's
16983 // `fetch_git` and caixa-crd's `dep_into_ref` already apply
16984 // inline.
16985 let s = DepSource::Git {
16986 repo: "github:o/x".into(),
16987 tag: Some("v1".into()),
16988 rev: Some("deadbeefcafebabe1234567890abcdef12345678".into()),
16989 branch: Some("main".into()),
16990 };
16991 assert_eq!(
16992 s.sole_pin(),
16993 Some("deadbeefcafebabe1234567890abcdef12345678")
16994 );
16995 }
16996
16997 #[test]
16998 fn sole_pin_precedence_tag_beats_branch_when_no_rev() {
16999 let s = DepSource::Git {
17000 repo: "github:o/x".into(),
17001 tag: Some("v1".into()),
17002 rev: None,
17003 branch: Some("main".into()),
17004 };
17005 assert_eq!(s.sole_pin(), Some("v1"));
17006 }
17007
17008 #[test]
17009 fn sole_pin_byte_equals_inline_rev_or_tag_or_branch_cascade() {
17010 // Fail-before-pass-after byte-parity pin: the substrate accessor
17011 // must return byte-identical to the inline
17012 // `rev.as_deref().or(tag.as_deref()).or(branch.as_deref())`
17013 // cascade both caixa-resolver's `fetch_git` and caixa-crd's
17014 // `dep_into_ref` open-coded pre-lift. Trips at caixa-core build
17015 // time if the accessor's precedence silently drifts from the
17016 // consumer-side cascade — the exact drift this lift converges
17017 // to one substrate primitive to close structurally.
17018 //
17019 // Iterates through the 2^3 = 8 combinations of (tag, rev,
17020 // branch) each-either-`None`-or-`Some`, so every arm of the
17021 // precedence cascade lands under the pin. `validate()` refuses
17022 // the 4 multi-pin combinations, but the accessor's return is
17023 // defined on all 8.
17024 let vals = [Some("R".to_string()), None];
17025 for tag in &vals {
17026 for rev in &vals {
17027 for branch in &vals {
17028 let s = DepSource::Git {
17029 repo: "github:o/x".into(),
17030 tag: tag.clone(),
17031 rev: rev.clone(),
17032 branch: branch.clone(),
17033 };
17034 // The exact inline cascade the two pre-lift
17035 // consumer sites hand-rolled, byte-for-byte.
17036 let expected = rev.as_deref().or(tag.as_deref()).or(branch.as_deref());
17037 assert_eq!(
17038 s.sole_pin(),
17039 expected,
17040 "sole_pin() must byte-equal \
17041 rev.or(tag).or(branch) for \
17042 (tag={tag:?}, rev={rev:?}, branch={branch:?}) — \
17043 a drift would silently split caixa-resolver's \
17044 fetch_git checkout target from caixa-crd's \
17045 dep_into_ref git_ref fill",
17046 );
17047 }
17048 }
17049 }
17050 }
17051
17052 // Fail-before-pass-after pins on the eleven
17053 // [`fonte_caminho_ctors!`]-generated `DepError::fonte_caminho_*`
17054 // constructors folded from the [`DepSource::validate_caminho`]
17055 // wire-up sites. Each pins the generated ctor's output to the
17056 // pre-lift struct-literal on the same `(&str, &str)` fixture, so
17057 // any wrapper-side lowercase / trim / re-order / silent-field-swap
17058 // regression on the two-field `{ nome: nome.to_string(), caminho:
17059 // caminho.to_string() }` construction surfaces here rather than at
17060 // a downstream diagnostic-shape mismatch. Peer of the sibling
17061 // `empty_child_version_ctor_matches_struct_literal_wrap` /
17062 // `contrato_endpoint_empty_ctor_matches_struct_literal_wrap` /
17063 // `entrada_host_invalid_ctor_matches_struct_literal_wrap` /
17064 // `nome_only_ctor_routes_caixa_through_nome_accessor` equivalence
17065 // pins on the peer `SupervisorError` / `AplicacaoError` /
17066 // `LayoutError` / `LimitsError` / `UpgradeError` envelopes.
17067
17068 #[test]
17069 fn fonte_caminho_absolute_ctor_matches_struct_literal_wrap() {
17070 assert_eq!(
17071 DepError::fonte_caminho_absolute("caixa-teia", "/home/me/work/caixa-teia"),
17072 DepError::FonteCaminhoAbsolute {
17073 nome: "caixa-teia".to_string(),
17074 caminho: "/home/me/work/caixa-teia".to_string(),
17075 },
17076 "generated fonte_caminho_absolute ctor must produce byte-equal \
17077 DepError to the open-coded struct-literal wrap on the same \
17078 (&str, &str) fixture",
17079 );
17080 }
17081
17082 #[test]
17083 fn fonte_caminho_tilde_expansion_ctor_matches_struct_literal_wrap() {
17084 assert_eq!(
17085 DepError::fonte_caminho_tilde_expansion("caixa-teia", "~/work/caixa-teia"),
17086 DepError::FonteCaminhoTildeExpansion {
17087 nome: "caixa-teia".to_string(),
17088 caminho: "~/work/caixa-teia".to_string(),
17089 },
17090 );
17091 }
17092
17093 #[test]
17094 fn fonte_caminho_var_expansion_ctor_matches_struct_literal_wrap() {
17095 assert_eq!(
17096 DepError::fonte_caminho_var_expansion("caixa-teia", "$HOME/work/caixa-teia"),
17097 DepError::FonteCaminhoVarExpansion {
17098 nome: "caixa-teia".to_string(),
17099 caminho: "$HOME/work/caixa-teia".to_string(),
17100 },
17101 );
17102 }
17103
17104 #[test]
17105 fn fonte_caminho_leading_whitespace_ctor_matches_struct_literal_wrap() {
17106 assert_eq!(
17107 DepError::fonte_caminho_leading_whitespace("caixa-teia", " ../caixa-teia"),
17108 DepError::FonteCaminhoLeadingWhitespace {
17109 nome: "caixa-teia".to_string(),
17110 caminho: " ../caixa-teia".to_string(),
17111 },
17112 );
17113 }
17114
17115 #[test]
17116 fn fonte_caminho_leading_hyphen_ctor_matches_struct_literal_wrap() {
17117 assert_eq!(
17118 DepError::fonte_caminho_leading_hyphen("caixa-teia", "-rf"),
17119 DepError::FonteCaminhoLeadingHyphen {
17120 nome: "caixa-teia".to_string(),
17121 caminho: "-rf".to_string(),
17122 },
17123 );
17124 }
17125
17126 #[test]
17127 fn fonte_caminho_backslash_ctor_matches_struct_literal_wrap() {
17128 assert_eq!(
17129 DepError::fonte_caminho_backslash("caixa-teia", "..\\caixa-teia"),
17130 DepError::FonteCaminhoBackslash {
17131 nome: "caixa-teia".to_string(),
17132 caminho: "..\\caixa-teia".to_string(),
17133 },
17134 );
17135 }
17136
17137 #[test]
17138 fn fonte_caminho_shell_pipe_ctor_matches_struct_literal_wrap() {
17139 assert_eq!(
17140 DepError::fonte_caminho_shell_pipe("caixa-teia", "../caixa-teia|evil"),
17141 DepError::FonteCaminhoShellPipe {
17142 nome: "caixa-teia".to_string(),
17143 caminho: "../caixa-teia|evil".to_string(),
17144 },
17145 );
17146 }
17147
17148 #[test]
17149 fn fonte_caminho_shell_semicolon_ctor_matches_struct_literal_wrap() {
17150 assert_eq!(
17151 DepError::fonte_caminho_shell_semicolon("caixa-teia", "../caixa-teia;evil"),
17152 DepError::FonteCaminhoShellSemicolon {
17153 nome: "caixa-teia".to_string(),
17154 caminho: "../caixa-teia;evil".to_string(),
17155 },
17156 );
17157 }
17158
17159 #[test]
17160 fn fonte_caminho_shell_background_ctor_matches_struct_literal_wrap() {
17161 assert_eq!(
17162 DepError::fonte_caminho_shell_background("caixa-teia", "../caixa-teia&"),
17163 DepError::FonteCaminhoShellBackground {
17164 nome: "caixa-teia".to_string(),
17165 caminho: "../caixa-teia&".to_string(),
17166 },
17167 );
17168 }
17169
17170 #[test]
17171 fn fonte_caminho_shell_command_substitution_ctor_matches_struct_literal_wrap() {
17172 assert_eq!(
17173 DepError::fonte_caminho_shell_command_substitution(
17174 "caixa-teia",
17175 "../caixa-teia`whoami`",
17176 ),
17177 DepError::FonteCaminhoShellCommandSubstitution {
17178 nome: "caixa-teia".to_string(),
17179 caminho: "../caixa-teia`whoami`".to_string(),
17180 },
17181 );
17182 }
17183
17184 #[test]
17185 fn fonte_caminho_trailing_slash_ctor_matches_struct_literal_wrap() {
17186 assert_eq!(
17187 DepError::fonte_caminho_trailing_slash("caixa-teia", "../caixa-teia/"),
17188 DepError::FonteCaminhoTrailingSlash {
17189 nome: "caixa-teia".to_string(),
17190 caminho: "../caixa-teia/".to_string(),
17191 },
17192 );
17193 }
17194
17195 #[test]
17196 fn fonte_caminho_ctors_route_nome_and_caminho_through_to_string() {
17197 // Cross-axis pin: sweep the two constructor input axes
17198 // (`nome: &str`, `caminho: &str`) through a non-default fixture
17199 // pair against every generated arm in the
17200 // [`fonte_caminho_ctors!`] macro, so any wrapper-side lowercase
17201 // / trim / truncate / re-order on the two-field
17202 // `{ nome, caminho }` construction — or a silent field swap
17203 // between the two axes at codegen time — surfaces here rather
17204 // than at a downstream diagnostic-shape mismatch. Peer of the
17205 // sibling `supervisor_caixa_only_ctors_route_caixa_through_
17206 // to_string` cross-axis routing pin on the peer
17207 // `SupervisorError` envelope, extended here onto the
17208 // `DepError` `{ nome: String, caminho: String }` envelope so
17209 // every substrate-primitive ctor family in caixa-core
17210 // guarantees each `&str`-field construction routes the
17211 // caller's `&str` verbatim through `.to_string()`.
17212 let nome = "sibling-teia";
17213 let caminho = "../workspace/sibling";
17214 let cases: [(DepError, DepError); 11] = [
17215 (
17216 DepError::fonte_caminho_absolute(nome, caminho),
17217 DepError::FonteCaminhoAbsolute {
17218 nome: nome.to_string(),
17219 caminho: caminho.to_string(),
17220 },
17221 ),
17222 (
17223 DepError::fonte_caminho_tilde_expansion(nome, caminho),
17224 DepError::FonteCaminhoTildeExpansion {
17225 nome: nome.to_string(),
17226 caminho: caminho.to_string(),
17227 },
17228 ),
17229 (
17230 DepError::fonte_caminho_var_expansion(nome, caminho),
17231 DepError::FonteCaminhoVarExpansion {
17232 nome: nome.to_string(),
17233 caminho: caminho.to_string(),
17234 },
17235 ),
17236 (
17237 DepError::fonte_caminho_leading_whitespace(nome, caminho),
17238 DepError::FonteCaminhoLeadingWhitespace {
17239 nome: nome.to_string(),
17240 caminho: caminho.to_string(),
17241 },
17242 ),
17243 (
17244 DepError::fonte_caminho_leading_hyphen(nome, caminho),
17245 DepError::FonteCaminhoLeadingHyphen {
17246 nome: nome.to_string(),
17247 caminho: caminho.to_string(),
17248 },
17249 ),
17250 (
17251 DepError::fonte_caminho_backslash(nome, caminho),
17252 DepError::FonteCaminhoBackslash {
17253 nome: nome.to_string(),
17254 caminho: caminho.to_string(),
17255 },
17256 ),
17257 (
17258 DepError::fonte_caminho_shell_pipe(nome, caminho),
17259 DepError::FonteCaminhoShellPipe {
17260 nome: nome.to_string(),
17261 caminho: caminho.to_string(),
17262 },
17263 ),
17264 (
17265 DepError::fonte_caminho_shell_semicolon(nome, caminho),
17266 DepError::FonteCaminhoShellSemicolon {
17267 nome: nome.to_string(),
17268 caminho: caminho.to_string(),
17269 },
17270 ),
17271 (
17272 DepError::fonte_caminho_shell_background(nome, caminho),
17273 DepError::FonteCaminhoShellBackground {
17274 nome: nome.to_string(),
17275 caminho: caminho.to_string(),
17276 },
17277 ),
17278 (
17279 DepError::fonte_caminho_shell_command_substitution(nome, caminho),
17280 DepError::FonteCaminhoShellCommandSubstitution {
17281 nome: nome.to_string(),
17282 caminho: caminho.to_string(),
17283 },
17284 ),
17285 (
17286 DepError::fonte_caminho_trailing_slash(nome, caminho),
17287 DepError::FonteCaminhoTrailingSlash {
17288 nome: nome.to_string(),
17289 caminho: caminho.to_string(),
17290 },
17291 ),
17292 ];
17293 for (via_ctor, via_struct_literal) in cases {
17294 assert_eq!(
17295 via_ctor, via_struct_literal,
17296 "fonte_caminho_ctors!-generated ctor must route (nome, caminho) \
17297 through `.to_string()` in declared field order — a field-swap or \
17298 silent-conversion regression surfaces here rather than at a \
17299 downstream diagnostic-shape mismatch",
17300 );
17301 }
17302 }
17303
17304 // ── `dep_nome_only_ctors!` — the paired `{ nome: String }` single-slot
17305 // envelope on `DepError`, sibling of the peer `fonte_caminho_ctors!`
17306 // (f85f145) on the `{ nome, caminho }` two-slot envelope of the same
17307 // enum, and of `supervisor_caixa_only_ctors!` (db09650) on the peer
17308 // `SupervisorError` envelope's `{ caixa: String }` single-slot axis.
17309
17310 #[test]
17311 fn versao_empty_ctor_matches_struct_literal_wrap() {
17312 assert_eq!(
17313 DepError::versao_empty("caixa-teia"),
17314 DepError::VersaoEmpty {
17315 nome: "caixa-teia".to_string(),
17316 },
17317 );
17318 }
17319
17320 #[test]
17321 fn fonte_repo_empty_ctor_matches_struct_literal_wrap() {
17322 assert_eq!(
17323 DepError::fonte_repo_empty("caixa-teia"),
17324 DepError::FonteRepoEmpty {
17325 nome: "caixa-teia".to_string(),
17326 },
17327 );
17328 }
17329
17330 #[test]
17331 fn fonte_pin_missing_ctor_matches_struct_literal_wrap() {
17332 assert_eq!(
17333 DepError::fonte_pin_missing("caixa-teia"),
17334 DepError::FontePinMissing {
17335 nome: "caixa-teia".to_string(),
17336 },
17337 );
17338 }
17339
17340 #[test]
17341 fn fonte_caminho_empty_ctor_matches_struct_literal_wrap() {
17342 assert_eq!(
17343 DepError::fonte_caminho_empty("caixa-teia"),
17344 DepError::FonteCaminhoEmpty {
17345 nome: "caixa-teia".to_string(),
17346 },
17347 );
17348 }
17349
17350 #[test]
17351 fn caracteristica_empty_ctor_matches_struct_literal_wrap() {
17352 assert_eq!(
17353 DepError::caracteristica_empty("caixa-teia"),
17354 DepError::CaracteristicaEmpty {
17355 nome: "caixa-teia".to_string(),
17356 },
17357 );
17358 }
17359
17360 #[test]
17361 fn dep_nome_only_ctors_route_nome_through_to_string() {
17362 // Cross-axis routing pin: sweep the single constructor input
17363 // axis (`nome: &str`) through a non-default fixture against
17364 // every generated arm in the [`dep_nome_only_ctors!`] macro, so
17365 // any wrapper-side lowercase / trim / truncate at codegen time
17366 // — or a silent field re-name away from the canonical `nome`
17367 // axis on any one variant — surfaces here rather than at a
17368 // downstream diagnostic-shape mismatch. Peer of the sibling
17369 // `fonte_caminho_ctors_route_nome_and_caminho_through_
17370 // to_string` cross-axis routing pin on the same envelope's
17371 // two-slot family (f85f145) and of the peer
17372 // `supervisor_caixa_only_ctors_route_caixa_through_to_string`
17373 // pin on the `SupervisorError` single-slot family (db09650).
17374 let nome = "sibling-teia";
17375 let cases: [(DepError, DepError); 5] = [
17376 (
17377 DepError::versao_empty(nome),
17378 DepError::VersaoEmpty {
17379 nome: nome.to_string(),
17380 },
17381 ),
17382 (
17383 DepError::fonte_repo_empty(nome),
17384 DepError::FonteRepoEmpty {
17385 nome: nome.to_string(),
17386 },
17387 ),
17388 (
17389 DepError::fonte_pin_missing(nome),
17390 DepError::FontePinMissing {
17391 nome: nome.to_string(),
17392 },
17393 ),
17394 (
17395 DepError::fonte_caminho_empty(nome),
17396 DepError::FonteCaminhoEmpty {
17397 nome: nome.to_string(),
17398 },
17399 ),
17400 (
17401 DepError::caracteristica_empty(nome),
17402 DepError::CaracteristicaEmpty {
17403 nome: nome.to_string(),
17404 },
17405 ),
17406 ];
17407 for (via_ctor, via_struct_literal) in cases {
17408 assert_eq!(
17409 via_ctor, via_struct_literal,
17410 "dep_nome_only_ctors!-generated ctor must route `nome` \
17411 through `.to_string()` onto the canonical `nome` field \
17412 — a field-rename or silent-conversion regression surfaces \
17413 here rather than at a downstream diagnostic-shape mismatch",
17414 );
17415 }
17416 }
17417
17418 // ── `dep_nome_list_ctors!` — the paired `{ nome: String, list:
17419 // &'static str }` two-slot envelope on `DepError`, strict
17420 // sibling of the peer `dep_nome_only_ctors!` (792aa92) on the
17421 // same envelope's `{ nome: String }` one-slot shape and of the
17422 // peer `supervisor_caixa_only_ctors!` (db09650) on the
17423 // `SupervisorError` envelope's `{ caixa: String }` one-slot axis.
17424
17425 #[test]
17426 fn duplicate_nome_ctor_matches_struct_literal_wrap() {
17427 assert_eq!(
17428 DepError::duplicate_nome("caixa-teia", crate::render::DEP_AUTHOR_KEY_DEPS),
17429 DepError::DuplicateNome {
17430 nome: "caixa-teia".to_string(),
17431 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17432 },
17433 "generated duplicate_nome ctor must produce byte-equal \
17434 `DepError::DuplicateNome` to the pre-lift struct-literal \
17435 wrap on the same scalar fixtures",
17436 );
17437 }
17438
17439 #[test]
17440 fn dep_is_self_ctor_matches_struct_literal_wrap() {
17441 assert_eq!(
17442 DepError::dep_is_self("orquestra", crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17443 DepError::DepIsSelf {
17444 nome: "orquestra".to_string(),
17445 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17446 },
17447 "generated dep_is_self ctor must produce byte-equal \
17448 `DepError::DepIsSelf` to the pre-lift struct-literal \
17449 wrap on the same scalar fixtures",
17450 );
17451 }
17452
17453 #[test]
17454 fn dep_nome_list_ctors_route_nome_and_list_through_uniformly() {
17455 // Cross-axis routing pin: sweep the two constructor input axes
17456 // (`nome: &str`, `list: &'static str`) through non-default
17457 // fixtures against every generated arm in the
17458 // [`dep_nome_list_ctors!`] macro, so any wrapper-side
17459 // lowercase / trim / truncate at codegen time — or a silent
17460 // field re-name away from the canonical `nome` / `list` axes
17461 // on any one variant, or a `list` axis silently rerouted
17462 // through `.to_string()` instead of passed as `&'static str`
17463 // verbatim — surfaces here rather than at a downstream
17464 // diagnostic-shape mismatch. Peer of the sibling
17465 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17466 // (792aa92) on the same envelope's one-slot family, and of the
17467 // peer
17468 // `supervisor_child_reason_ctors_route_reason_through_into_uniformly`
17469 // pin (d2ef2ec) on the sibling `SupervisorError` envelope's
17470 // two-slot `{ caixa: String, reason: String }` shape.
17471 let nome = "sibling-teia";
17472 let cases: [(DepError, DepError); 4] = [
17473 (
17474 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17475 DepError::DuplicateNome {
17476 nome: nome.to_string(),
17477 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17478 },
17479 ),
17480 (
17481 DepError::duplicate_nome(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17482 DepError::DuplicateNome {
17483 nome: nome.to_string(),
17484 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17485 },
17486 ),
17487 (
17488 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS),
17489 DepError::DepIsSelf {
17490 nome: nome.to_string(),
17491 list: crate::render::DEP_AUTHOR_KEY_DEPS,
17492 },
17493 ),
17494 (
17495 DepError::dep_is_self(nome, crate::render::DEP_AUTHOR_KEY_DEPS_DEV),
17496 DepError::DepIsSelf {
17497 nome: nome.to_string(),
17498 list: crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
17499 },
17500 ),
17501 ];
17502 for (via_ctor, via_struct_literal) in cases {
17503 assert_eq!(
17504 via_ctor, via_struct_literal,
17505 "dep_nome_list_ctors!-generated ctor must route `nome` \
17506 through `.to_string()` onto the canonical `nome` field \
17507 and pass `list` verbatim onto the canonical `&'static str` \
17508 `list` field — a field-rename, silent-conversion, or \
17509 axis-swap regression surfaces here rather than at a \
17510 downstream diagnostic-shape mismatch",
17511 );
17512 }
17513 }
17514
17515 // ── `fonte_pin_shape` — the paired `{ nome: String, pin: String,
17516 // value: String, reason: String }` four-slot envelope on
17517 // `DepError`, sibling of the peer `dep_nome_only_ctors!` (792aa92),
17518 // `dep_nome_list_ctors!` (6f5e0cd), `fonte_caminho_ctors!` (f85f145),
17519 // and `fonte_caminho_byte_ctors!` (0e35793) folds on the same
17520 // envelope, and of the peer `contrato_pair_value_reason_ctors!`
17521 // (14e13f1) four-slot fold on the sibling `AplicacaoError`
17522 // envelope. Single-variant lift closing the last open-coded ctor
17523 // site on the `:fonte (:tipo git …)` value-shape trajectory.
17524
17525 #[test]
17526 fn fonte_pin_shape_ctor_matches_struct_literal_wrap() {
17527 // Pre-lift equivalence pin on the [`DepError::fonte_pin_shape`]
17528 // ctor: sweep both wire-up-shape arms (the refname-pin arm
17529 // routing `":tag"` / `":branch"` value through
17530 // [`crate::render::is_git_ref_name`], and the hex-OID-pin arm
17531 // routing `":rev"` through [`crate::render::is_git_oid`]) and
17532 // assert byte-equal `PartialEq` against the pre-lift
17533 // struct-literal, so any wrapper-side field-rename /
17534 // silent-conversion regression surfaces here rather than at a
17535 // downstream diagnostic-shape mismatch. Peer of the sibling
17536 // per-envelope byte-equal ctor pins
17537 // ([`fonte_pin_missing_ctor_matches_struct_literal_wrap`],
17538 // [`duplicate_nome_ctor_matches_struct_literal_wrap`],
17539 // [`dep_is_self_ctor_matches_struct_literal_wrap`]).
17540 assert_eq!(
17541 DepError::fonte_pin_shape(
17542 "caixa-teia",
17543 ":tag",
17544 "v0.1.0 ",
17545 "trailing whitespace".to_string(),
17546 ),
17547 DepError::FontePinShape {
17548 nome: "caixa-teia".to_string(),
17549 pin: ":tag".to_string(),
17550 value: "v0.1.0 ".to_string(),
17551 reason: "trailing whitespace".to_string(),
17552 },
17553 "fonte_pin_shape ctor must produce byte-equal \
17554 `DepError::FontePinShape` to the pre-lift struct-literal \
17555 wrap on a refname-pin (`:tag` / `:branch`) fixture",
17556 );
17557 assert_eq!(
17558 DepError::fonte_pin_shape(
17559 "caixa-teia",
17560 ":rev",
17561 "DEADBEEF",
17562 "abbreviated OID rejected".to_string(),
17563 ),
17564 DepError::FontePinShape {
17565 nome: "caixa-teia".to_string(),
17566 pin: ":rev".to_string(),
17567 value: "DEADBEEF".to_string(),
17568 reason: "abbreviated OID rejected".to_string(),
17569 },
17570 "fonte_pin_shape ctor must produce byte-equal \
17571 `DepError::FontePinShape` to the pre-lift struct-literal \
17572 wrap on a hex-OID-pin (`:rev`) fixture",
17573 );
17574 }
17575
17576 #[test]
17577 fn fonte_pin_shape_ctor_routes_all_four_axes_through_to_string() {
17578 // Cross-axis routing pin: sweep every one of the four
17579 // constructor input axes (`nome: &str`, `pin: &str`,
17580 // `value: &str`, `reason: String`) through non-default
17581 // fixtures against the [`DepError::fonte_pin_shape`] ctor, so
17582 // any wrapper-side lowercase / trim / truncate at codegen time
17583 // — or a silent field re-name / axis-swap on any one of the
17584 // four fields, or a `reason` axis silently routed through
17585 // `.to_string()` instead of forwarded owned — surfaces here
17586 // rather than at a downstream diagnostic-shape mismatch. Peer
17587 // of the sibling
17588 // `dep_nome_only_ctors_route_nome_through_to_string` pin
17589 // (792aa92) and
17590 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
17591 // pin (6f5e0cd) on the same envelope's one- and two-slot
17592 // families. Distinct-per-axis fixtures rule out any two-axis
17593 // swap (`nome` ↔ `pin`, `pin` ↔ `value`, `value` ↔ `reason`,
17594 // etc.) that would still pass a same-fixture-per-axis pin.
17595 let nome = "sibling-teia";
17596 let pin = ":branch";
17597 let value = "feature/bar";
17598 let reason = "embedded space".to_string();
17599 let via_ctor = DepError::fonte_pin_shape(nome, pin, value, reason.clone());
17600 let via_struct_literal = DepError::FontePinShape {
17601 nome: nome.to_string(),
17602 pin: pin.to_string(),
17603 value: value.to_string(),
17604 reason: reason.clone(),
17605 };
17606 assert_eq!(
17607 via_ctor, via_struct_literal,
17608 "fonte_pin_shape ctor must route `nome` / `pin` / `value` \
17609 through `.to_string()` onto their canonical fields and \
17610 forward `reason` owned onto the canonical `reason` field \
17611 — a field-rename, silent-conversion, or axis-swap \
17612 regression surfaces here rather than at a downstream \
17613 diagnostic-shape mismatch",
17614 );
17615 let DepError::FontePinShape {
17616 nome: n,
17617 pin: p,
17618 value: v,
17619 reason: r,
17620 } = via_ctor
17621 else {
17622 panic!("fonte_pin_shape ctor produced non-FontePinShape variant")
17623 };
17624 assert_eq!(n, nome);
17625 assert_eq!(p, pin);
17626 assert_eq!(v, value);
17627 assert_eq!(r, reason);
17628 }
17629
17630 // ── `fonte_caminho_byte_ctors!` — the paired `{ nome: String,
17631 // caminho: String, byte: u8 }` three-slot envelope on `DepError`,
17632 // strict sibling of the peer `fonte_caminho_ctors!` (f85f145) on
17633 // the same envelope's `{ nome: String, caminho: String }` two-slot
17634 // shape, and of the peer `dep_nome_only_ctors!` (792aa92) on the
17635 // same envelope's `{ nome: String }` one-slot shape.
17636
17637 #[test]
17638 fn fonte_caminho_control_char_ctor_matches_struct_literal_wrap() {
17639 assert_eq!(
17640 DepError::fonte_caminho_control_char("caixa-teia", "../caixa-teia\x00foo", 0x00),
17641 DepError::FonteCaminhoControlChar {
17642 nome: "caixa-teia".to_string(),
17643 caminho: "../caixa-teia\x00foo".to_string(),
17644 byte: 0x00,
17645 },
17646 );
17647 }
17648
17649 #[test]
17650 fn fonte_caminho_shell_redirection_ctor_matches_struct_literal_wrap() {
17651 assert_eq!(
17652 DepError::fonte_caminho_shell_redirection("caixa-teia", "../caixa-teia>log", b'>'),
17653 DepError::FonteCaminhoShellRedirection {
17654 nome: "caixa-teia".to_string(),
17655 caminho: "../caixa-teia>log".to_string(),
17656 byte: b'>',
17657 },
17658 );
17659 }
17660
17661 #[test]
17662 #[allow(
17663 clippy::too_many_lines,
17664 reason = "cross-axis routing pin sweeps twelve typed variants, one per \
17665 byte-classification arm on the {nome,caminho,byte} envelope; \
17666 the linear per-variant repetition is exactly what the sweep \
17667 is pinning — a helper macro would hide the shape the fold is \
17668 keying on"
17669 )]
17670 fn fonte_caminho_byte_ctors_route_nome_caminho_and_byte_through_to_string() {
17671 // Cross-axis routing pin: sweep the three constructor input axes
17672 // (`nome: &str`, `caminho: &str`, `byte: u8`) through a
17673 // non-default fixture triple against every generated arm in the
17674 // [`fonte_caminho_byte_ctors!`] macro, so any wrapper-side
17675 // lowercase / trim / truncate on the two `&str` axes — a silent
17676 // field swap between `nome` and `caminho`, or a silent
17677 // re-classification of the offending byte — surfaces here rather
17678 // than at a downstream diagnostic-shape mismatch. Peer of the
17679 // sibling `fonte_caminho_ctors_route_nome_and_caminho_through_
17680 // to_string` cross-axis routing pin on the same envelope's
17681 // two-slot family (f85f145) and of the sibling
17682 // `dep_nome_only_ctors_route_nome_through_to_string` pin on the
17683 // same envelope's one-slot family (792aa92), extended here onto
17684 // the `{ nome: String, caminho: String, byte: u8 }` three-slot
17685 // envelope so every substrate-primitive ctor family in
17686 // caixa-core's `DepError` envelope guarantees each field routes
17687 // the caller's value verbatim through `.to_string()` (or byte-
17688 // identity for `byte: u8`) in declared field order.
17689 let nome = "sibling-teia";
17690 let caminho = "../workspace/sibling";
17691 let byte = 0x2A_u8;
17692 let cases: [(DepError, DepError); 12] = [
17693 (
17694 DepError::fonte_caminho_control_char(nome, caminho, byte),
17695 DepError::FonteCaminhoControlChar {
17696 nome: nome.to_string(),
17697 caminho: caminho.to_string(),
17698 byte,
17699 },
17700 ),
17701 (
17702 DepError::fonte_caminho_shell_redirection(nome, caminho, byte),
17703 DepError::FonteCaminhoShellRedirection {
17704 nome: nome.to_string(),
17705 caminho: caminho.to_string(),
17706 byte,
17707 },
17708 ),
17709 (
17710 DepError::fonte_caminho_shell_glob(nome, caminho, byte),
17711 DepError::FonteCaminhoShellGlob {
17712 nome: nome.to_string(),
17713 caminho: caminho.to_string(),
17714 byte,
17715 },
17716 ),
17717 (
17718 DepError::fonte_caminho_shell_subshell_grouping(nome, caminho, byte),
17719 DepError::FonteCaminhoShellSubshellGrouping {
17720 nome: nome.to_string(),
17721 caminho: caminho.to_string(),
17722 byte,
17723 },
17724 ),
17725 (
17726 DepError::fonte_caminho_shell_brace_expansion(nome, caminho, byte),
17727 DepError::FonteCaminhoShellBraceExpansion {
17728 nome: nome.to_string(),
17729 caminho: caminho.to_string(),
17730 byte,
17731 },
17732 ),
17733 (
17734 DepError::fonte_caminho_shell_bracket_expansion(nome, caminho, byte),
17735 DepError::FonteCaminhoShellBracketExpansion {
17736 nome: nome.to_string(),
17737 caminho: caminho.to_string(),
17738 byte,
17739 },
17740 ),
17741 (
17742 DepError::fonte_caminho_shell_quote_grouping(nome, caminho, byte),
17743 DepError::FonteCaminhoShellQuoteGrouping {
17744 nome: nome.to_string(),
17745 caminho: caminho.to_string(),
17746 byte,
17747 },
17748 ),
17749 (
17750 DepError::fonte_caminho_shell_comment(nome, caminho, byte),
17751 DepError::FonteCaminhoShellComment {
17752 nome: nome.to_string(),
17753 caminho: caminho.to_string(),
17754 byte,
17755 },
17756 ),
17757 (
17758 DepError::fonte_caminho_url_percent_encoding(nome, caminho, byte),
17759 DepError::FonteCaminhoUrlPercentEncoding {
17760 nome: nome.to_string(),
17761 caminho: caminho.to_string(),
17762 byte,
17763 },
17764 ),
17765 (
17766 DepError::fonte_caminho_shell_variable_expansion(nome, caminho, byte),
17767 DepError::FonteCaminhoShellVariableExpansion {
17768 nome: nome.to_string(),
17769 caminho: caminho.to_string(),
17770 byte,
17771 },
17772 ),
17773 (
17774 DepError::fonte_caminho_shell_history_expansion(nome, caminho, byte),
17775 DepError::FonteCaminhoShellHistoryExpansion {
17776 nome: nome.to_string(),
17777 caminho: caminho.to_string(),
17778 byte,
17779 },
17780 ),
17781 (
17782 DepError::fonte_caminho_shell_history_substitution(nome, caminho, byte),
17783 DepError::FonteCaminhoShellHistorySubstitution {
17784 nome: nome.to_string(),
17785 caminho: caminho.to_string(),
17786 byte,
17787 },
17788 ),
17789 ];
17790 for (via_ctor, via_struct_literal) in cases {
17791 assert_eq!(
17792 via_ctor, via_struct_literal,
17793 "fonte_caminho_byte_ctors!-generated ctor must route \
17794 (nome, caminho, byte) through `.to_string()` / byte-\
17795 identity in declared field order — a field-swap or \
17796 silent-conversion regression surfaces here rather than \
17797 at a downstream diagnostic-shape mismatch",
17798 );
17799 }
17800 }
17801
17802 #[test]
17803 fn dep_list_as_ref_str_routes_through_as_str_accessor() {
17804 // Fail-before-pass-after byte-parity pin on the lifted
17805 // `impl AsRef<str> for DepList` — asserts the standard-
17806 // library trait impl and the substrate-primitive
17807 // [`super::DepList::as_str`] `pub const fn` accessor resolve
17808 // to the same `&str` per instance across the two-arm closed
17809 // set, so any future silent detour that routes the impl
17810 // through a divergent projection (a per-arm inline
17811 // `match self { DepList::Prod => ":deps", … }` re-inlining
17812 // that opens a compile-time link to the un-lifted arm-literal,
17813 // a swap onto a second projection axis) trips at caixa-core
17814 // test time under `PartialEq` rather than at a downstream
17815 // `impl AsRef<str>`-bound consumer's silent split. Sweeps
17816 // every one of the two arms [`super::DepList::ALL`] carries
17817 // so no arm's projection is covered only by the sibling
17818 // `Display` path. Peer of the sibling
17819 // `caixa_dialeto_as_ref_str_routes_through_as_str_accessor`
17820 // (1723611) on the top-level dialect-classification closed-
17821 // set typed enum, and the peer
17822 // `rate_limit_unit_as_ref_str_routes_through_as_suffix_accessor`
17823 // (d8136db) pin on the M3 `:politicas :rate-limit` closed-set
17824 // typed enum — the pins together close the substrate
17825 // primitive's `AsRef<str>` projection axis onto the seventh
17826 // (and last unlifted) closed-set typed enum on the caixa
17827 // surface.
17828 for &list in super::DepList::ALL {
17829 assert_eq!(
17830 <super::DepList as AsRef<str>>::as_ref(&list),
17831 list.as_str(),
17832 "AsRef<str> impl on DepList::{list:?} must byte-equal \
17833 DepList::as_str on the same instance — divergence \
17834 signals a silent detour off the substrate-primitive \
17835 accessor"
17836 );
17837 }
17838 }
17839
17840 #[test]
17841 fn dep_list_as_ref_str_routes_through_display_via_shared_accessor() {
17842 // Fail-before-pass-after byte-parity pin on the three-path
17843 // convergence discipline the [`super::DepList`] two-list
17844 // dep-graph closed-set typed enum now carries on the `&str`-
17845 // projection axis: `<DepList as AsRef<str>>::as_ref(&v)` (the
17846 // newly lifted impl), `format!("{v}")` (the pre-existing
17847 // [`fmt::Display`] impl), and `v.as_str()` (the substrate-
17848 // primitive `pub const fn` accessor both trait impls delegate
17849 // through) must resolve to the same byte-string on every
17850 // instance across the two-arm closed set. Refuses any future
17851 // divergence between the two trait impls (a stray
17852 // [`fmt::Display::fmt`] rewrite that hand-rolls the arms
17853 // rather than delegating through the shared accessor; a
17854 // hypothetical `AsRef<str>` rewrite that inlines a per-arm
17855 // literal cascade) that would silently split the two
17856 // projection paths of the same closed-set typed enum. Mirrors
17857 // the sibling three-path-convergence discipline the peer
17858 // [`crate::CaixaDialeto`] typed enum carries
17859 // (`caixa_dialeto_as_ref_str_routes_through_display_via_shared_accessor`,
17860 // 1723611), the peer [`crate::aplicacao::RateLimitUnit`] triple
17861 // (`rate_limit_unit_as_ref_str_routes_through_display_via_shared_accessor`,
17862 // d8136db), the peer [`crate::CaixaKind`] triple
17863 // (`caixa_kind_as_ref_str_routes_through_display_via_shared_accessor`,
17864 // cd2091f), and the [`crate::CaixaVersion`] typed newtype
17865 // triple (`caixa_version_as_ref_str_routes_through_display_via_shared_accessor`,
17866 // 16d5c7e).
17867 for &list in super::DepList::ALL {
17868 let via_as_ref: &str = <super::DepList as AsRef<str>>::as_ref(&list);
17869 let via_display: String = format!("{list}");
17870 let via_accessor: &str = list.as_str();
17871 assert_eq!(via_as_ref, via_accessor);
17872 assert_eq!(via_display, via_accessor);
17873 assert_eq!(via_as_ref, via_display.as_str());
17874 }
17875 }
17876
17877 #[test]
17878 fn dep_list_try_from_str_routes_through_from_wire_accessor() {
17879 // Fail-before-pass-after byte-parity pin on the newly lifted
17880 // `impl TryFrom<&str> for DepList` — asserts the standard-
17881 // library trait impl and the substrate-primitive
17882 // [`super::DepList::from_wire`] `Option<Self>` accessor resolve
17883 // to the same two-arm accept-set across every arm the
17884 // exhaustive [`super::DepList::ALL`] slice enumerates. Peer of
17885 // the sibling
17886 // `restart_strategy_try_from_str_routes_through_from_wire_accessor`
17887 // (5b828ed), `caixa_kind_try_from_str_routes_through_from_wire_accessor`,
17888 // and the 12 other substrate-wide trait-idiomatic reverse-
17889 // projection routes-through pins — closes the campaign's
17890 // completeness gap on the two-list dep-graph closed-set enum.
17891 for &list in super::DepList::ALL {
17892 let wire = list.as_str();
17893 assert_eq!(
17894 <super::DepList as TryFrom<&str>>::try_from(wire),
17895 Ok(list),
17896 "TryFrom<&str> impl on DepList must round-trip \
17897 DepList::{list:?}.as_str() = {wire:?} back to \
17898 Ok(DepList::{list:?}) — divergence from \
17899 DepList::from_wire signals a silent detour off the \
17900 substrate-primitive accessor"
17901 );
17902 assert_eq!(
17903 <super::DepList as TryFrom<&str>>::try_from(wire).ok(),
17904 super::DepList::from_wire(wire),
17905 "TryFrom<&str> ok()-projection on {wire:?} must byte-equal \
17906 DepList::from_wire on the same input"
17907 );
17908 }
17909 }
17910
17911 #[test]
17912 fn dep_list_try_from_str_rejects_unknown_byte_strings() {
17913 // Rejection witness on the `impl TryFrom<&str> for DepList` —
17914 // sweeps candidate byte-strings outside the two-arm accept-set
17915 // the sibling [`super::DepList::as_str`] emits (`:deps` /
17916 // `:deps-dev`) and asserts every one lands on `Err(())`, so a
17917 // future accidental widening of the trait impl's accept-set (a
17918 // stray case-fold path, a silent inclusion of a rebrand alias
17919 // like `":packages"`, an English rebrand `":dev-deps"` in
17920 // reverse arm-order that would silently swap the two arms) trips
17921 // at caixa-core test time. Peer of the sibling
17922 // `restart_strategy_try_from_str_rejects_unknown_byte_strings`
17923 // (5b828ed) rejection witness.
17924 let rejected: &[&str] = &[
17925 "",
17926 " ",
17927 "\t",
17928 "\n",
17929 ":deps ",
17930 " :deps",
17931 ":DEPS",
17932 ":Deps",
17933 ":Deps-Dev",
17934 ":deps_dev",
17935 ":deps-development",
17936 ":dev-deps",
17937 ":packages",
17938 ":packages-dev",
17939 "deps",
17940 "deps-dev",
17941 "Prod",
17942 "Dev",
17943 "prod",
17944 "dev",
17945 "\":deps\"",
17946 "\":deps-dev\"",
17947 ":deps\n",
17948 ":deps-dev\n",
17949 ];
17950 for &input in rejected {
17951 assert_eq!(
17952 <super::DepList as TryFrom<&str>>::try_from(input),
17953 Err(()),
17954 "TryFrom<&str> impl on DepList must reject unknown \
17955 byte-string {input:?} — divergence from \
17956 DepList::from_wire on the same input signals a silent \
17957 accept-set widening past the two lifted \
17958 crate::render::DEP_AUTHOR_KEY_DEPS* wire constants"
17959 );
17960 assert_eq!(
17961 <super::DepList as TryFrom<&str>>::try_from(input).ok(),
17962 super::DepList::from_wire(input),
17963 "TryFrom<&str> ok()-projection on {input:?} must byte-equal \
17964 DepList::from_wire on the same input — divergence signals \
17965 the two reverse-projection paths have drifted onto \
17966 different accept-sets"
17967 );
17968 }
17969 }
17970
17971 #[test]
17972 fn dep_list_from_into_static_str_routes_through_as_str_accessor() {
17973 // Fail-before-pass-after byte-parity pin on the newly lifted
17974 // `impl From<DepList> for &'static str` — asserts the standard-
17975 // library trait impl and the substrate-primitive
17976 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
17977 // the same two-arm emit-set across every arm the exhaustive
17978 // [`super::DepList::ALL`] slice enumerates. Materializes the
17979 // `<&'static str as From<DepList>>::from` output in a
17980 // `const`-shape binding to make the `'static` lifetime promise
17981 // a build-time invariant — a future accidental downgrade of
17982 // either arm to a non-`&'static str` (a `String::leak()`-
17983 // produced return, a `Box::leak`-cast) trips at caixa-core
17984 // build time rather than at a downstream `'static`-bound
17985 // consumer. Peer of the sibling
17986 // `restart_strategy_from_into_static_str_routes_through_as_str_accessor`
17987 // (523157d) and the 13 other substrate-wide forward-projection
17988 // routes-through pins.
17989 const PROD: &str = super::DepList::Prod.as_str();
17990 const DEV: &str = super::DepList::Dev.as_str();
17991 for &list in super::DepList::ALL {
17992 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
17993 let via_method: &'static str = list.as_str();
17994 assert_eq!(
17995 via_trait, via_method,
17996 "From<DepList> for &'static str impl must round-trip \
17997 DepList::{list:?} to the same lifted \
17998 crate::render::DEP_AUTHOR_KEY_DEPS* const \
17999 DepList::as_str returns — divergence signals a silent \
18000 detour off the substrate-primitive accessor"
18001 );
18002 let via_into: &'static str = list.into();
18003 assert_eq!(
18004 via_into, via_method,
18005 "Into<&'static str>::into on DepList::{list:?} must \
18006 byte-equal DepList::as_str on the same input — the \
18007 blanket-derived Into shape must resolve to the same \
18008 as_str dispatch as the explicit From impl"
18009 );
18010 }
18011 assert_eq!(
18012 [PROD, DEV],
18013 [
18014 crate::render::DEP_AUTHOR_KEY_DEPS,
18015 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18016 ],
18017 "const-context DepList::as_str must resolve to the two lifted \
18018 DEP_AUTHOR_KEY_DEPS* consts — a future accidental downgrade \
18019 of either arm to a non-const or non-static byte-string breaks \
18020 the `&'static str`-lifetime promise the paired \
18021 From<DepList> for &'static str impl carries by construction"
18022 );
18023 }
18024
18025 #[test]
18026 fn dep_list_from_into_static_str_and_as_str_partition_the_emit_set() {
18027 // Cross-axis partition pin: the paired trait-idiomatic
18028 // `From<DepList> for &'static str` forward projection and the
18029 // method-named [`super::DepList::as_str`] forward projection
18030 // must resolve identically on every arm, locking the two paths
18031 // together so any future detour trips at caixa-core test time.
18032 // Then a round-trip witness: every arm's forward `From` output
18033 // re-parses through the paired trait-idiomatic reverse
18034 // `TryFrom<&str>` back to the original variant, closing the
18035 // two-way `DepList ↔ &'static str` round-trip on the trait-
18036 // idiomatic axis pair, mirroring the pre-existing method-named
18037 // `as_str` + `from_wire` round-trip. Peer of the sibling
18038 // `restart_strategy_from_into_static_str_and_as_str_partition_the_emit_set`
18039 // (523157d).
18040 for &list in super::DepList::ALL {
18041 let via_trait: &'static str = <&'static str as From<super::DepList>>::from(list);
18042 let via_method: &'static str = list.as_str();
18043 assert_eq!(
18044 via_trait, via_method,
18045 "From<DepList> for &'static str and DepList::as_str must \
18046 resolve identically on DepList::{list:?} — divergence \
18047 signals the two forward-projection paths have drifted \
18048 onto different emit-sets"
18049 );
18050 }
18051 for &list in super::DepList::ALL {
18052 let emitted: &'static str = list.into();
18053 let re_parsed: Result<super::DepList, ()> =
18054 <super::DepList as TryFrom<&str>>::try_from(emitted);
18055 assert_eq!(
18056 re_parsed,
18057 Ok(list),
18058 "trait-idiomatic axis pair must round-trip \
18059 DepList::{list:?} through `.into::<&'static str>()` and \
18060 back through `TryFrom<&str>` — a break signals the \
18061 forward-emit and reverse-parse axes have drifted onto \
18062 different vocabularies"
18063 );
18064 }
18065 }
18066
18067 #[test]
18068 fn dep_list_from_borrowed_into_static_str_routes_through_as_str_accessor() {
18069 // Fail-before-pass-after byte-parity pin on the newly lifted
18070 // `impl From<&DepList> for &'static str` — asserts the borrowed-
18071 // input standard-library trait impl and the substrate-primitive
18072 // [`super::DepList::as_str`] `pub const fn` accessor resolve to
18073 // the same two-arm emit-set across every arm the exhaustive
18074 // [`super::DepList::ALL`] slice enumerates. Rust's `From` trait
18075 // does not auto-derive the borrowed-input sibling from a paired
18076 // owned-input impl (no `impl<T, U> From<&T> for U where T: Copy,
18077 // U: From<T>` blanket in `core`), so the borrowed-input axis is
18078 // a distinct trait-idiomatic surface that a `.iter().map(Into::into)`
18079 // shape over [`super::DepList::ALL`] (whose iterator yields
18080 // `&DepList`, not `DepList`) reaches through this impl and no
18081 // other — the paired owned-input [`From<DepList>`] impl requires
18082 // an explicit `.copied()` / dereference before the trait fires.
18083 // Materializes the `<&'static str as From<&DepList>>::from`
18084 // output in a `const`-shape binding to make the `'static`
18085 // lifetime promise a build-time invariant.
18086 const PROD: &str = super::DepList::Prod.as_str();
18087 const DEV: &str = super::DepList::Dev.as_str();
18088 for list in super::DepList::ALL {
18089 let via_trait: &'static str = <&'static str as From<&super::DepList>>::from(list);
18090 let via_method: &'static str = list.as_str();
18091 assert_eq!(
18092 via_trait, via_method,
18093 "From<&DepList> for &'static str impl must round-trip \
18094 &DepList::{list:?} to the same lifted \
18095 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18096 DepList::as_str returns — divergence signals a silent \
18097 detour off the substrate-primitive accessor"
18098 );
18099 let via_into: &'static str = list.into();
18100 assert_eq!(
18101 via_into, via_method,
18102 "Into<&'static str>::into on &DepList::{list:?} must \
18103 byte-equal DepList::as_str on the same input — the \
18104 blanket-derived Into shape must resolve to the same \
18105 as_str dispatch as the explicit From impl"
18106 );
18107 }
18108 assert_eq!(
18109 [PROD, DEV],
18110 [
18111 crate::render::DEP_AUTHOR_KEY_DEPS,
18112 crate::render::DEP_AUTHOR_KEY_DEPS_DEV,
18113 ],
18114 "const-context DepList::as_str must resolve to the two lifted \
18115 DEP_AUTHOR_KEY_DEPS* consts — the borrowed-input \
18116 From<&DepList> for &'static str impl inherits its `'static` \
18117 lifetime promise from the same accessor the owned-input \
18118 sibling routes through"
18119 );
18120 }
18121
18122 #[test]
18123 fn dep_list_from_owned_and_borrowed_into_static_str_agree_on_every_arm() {
18124 // Cross-axis partition pin: the paired trait-idiomatic
18125 // owned-input `From<DepList> for &'static str` (523157d
18126 // campaign-shape) and borrowed-input `From<&DepList> for
18127 // &'static str` (this lift) forward projections must resolve
18128 // identically on every arm, locking the two input-shape paths
18129 // together so any future detour trips at caixa-core test time.
18130 // Then a witness that a `.iter().map(Into::into)` pipe over
18131 // [`super::DepList::ALL`] (whose iterator yields `&DepList`)
18132 // materializes the two-arm accept-set through the borrowed-
18133 // input axis alone — the exact shape a future M4 admission-
18134 // webhook rejection body composer, a future substrate-wide
18135 // per-arm diagnostic column, or a
18136 // `HashMap::<&'static str, DepList>::from_iter(DepList::ALL.iter()
18137 // .map(|l| (l.into(), *l)))`-style per-list lookup reaches
18138 // through — closing the two-way owned/borrowed input-shape
18139 // symmetry on the forward-projection trait-idiomatic axis.
18140 for &list in super::DepList::ALL {
18141 let owned: &'static str = <&'static str as From<super::DepList>>::from(list);
18142 let borrowed: &'static str = <&'static str as From<&super::DepList>>::from(&list);
18143 assert_eq!(
18144 owned, borrowed,
18145 "From<DepList> and From<&DepList> for &'static str must \
18146 resolve identically on DepList::{list:?} — divergence \
18147 signals the owned-input and borrowed-input forward-\
18148 projection paths have drifted onto different emit-sets"
18149 );
18150 }
18151 let via_iter: Vec<&'static str> = super::DepList::ALL.iter().map(Into::into).collect();
18152 let via_method: Vec<&'static str> =
18153 super::DepList::ALL.iter().map(|l| l.as_str()).collect();
18154 assert_eq!(
18155 via_iter, via_method,
18156 "`.iter().map(Into::into)` over DepList::ALL must byte-equal \
18157 `.iter().map(|l| l.as_str())` on every arm — the borrowed-\
18158 input `From<&DepList> for &'static str` axis is what makes \
18159 the `.iter().map(Into::into)` shape route through the \
18160 substrate-primitive `DepList::as_str` accessor rather than \
18161 through a per-call-site `.copied()` / dereference detour"
18162 );
18163 }
18164
18165 #[test]
18166 fn dep_list_from_into_owned_string_routes_through_as_str_accessor() {
18167 // Fail-before-pass-after byte-parity pin on the newly lifted
18168 // `impl From<DepList> for String` — asserts the owned-`String`
18169 // -returning standard-library trait impl and the substrate-
18170 // primitive [`super::DepList::as_str`] `pub const fn` accessor
18171 // resolve to the same two-arm emit-set across every arm the
18172 // exhaustive [`super::DepList::ALL`] slice enumerates. Rust's
18173 // standard library does not carry a blanket
18174 // `impl<T: AsRef<str>> From<T> for String` (nor an
18175 // `impl<T: fmt::Display> From<T> for String`), so the
18176 // owned-`String` forward-projection axis is a distinct trait-
18177 // idiomatic surface that a `let key: String = list.into();`-
18178 // shaped call site reaches through this impl and no other — the
18179 // paired sibling `From<DepList> for &'static str` impl forces
18180 // every owned-`String` call site through an explicit
18181 // `.to_owned()` / `String::from` restatement. Peer of the
18182 // first-mover
18183 // [`crate::supervisor::tests::restart_strategy_from_into_owned_string_routes_through_as_str_accessor`]
18184 // (7baa18a), the second-peer
18185 // [`crate::supervisor::tests::restart_policy_from_into_owned_string_routes_through_as_str_accessor`]
18186 // (7851725), the third-peer
18187 // [`crate::kind::tests::caixa_kind_from_into_owned_string_routes_through_as_str_accessor`]
18188 // (231a18c), and the fourth-peer
18189 // [`crate::dialeto::tests::caixa_dialeto_from_into_owned_string_routes_through_as_str_accessor`]
18190 // (88942cd) — extends the trait-idiomatic owned-`String`
18191 // forward-projection axis onto the fifth closed-set fieldless
18192 // typed enum on the caixa surface (the two-list dep-graph axis).
18193 for &variant in super::DepList::ALL {
18194 let via_trait: String = <String as From<super::DepList>>::from(variant);
18195 let via_method: &'static str = variant.as_str();
18196 assert_eq!(
18197 via_trait.as_str(),
18198 via_method,
18199 "From<DepList> for String impl must round-trip \
18200 DepList::{variant:?} to the same lifted \
18201 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18202 DepList::as_str returns — divergence signals a silent \
18203 detour off the substrate-primitive accessor"
18204 );
18205 let via_into: String = variant.into();
18206 assert_eq!(
18207 via_into.as_str(),
18208 via_method,
18209 "Into<String>::into on DepList::{variant:?} must \
18210 byte-equal DepList::as_str on the same input — the \
18211 blanket-derived Into shape must resolve to the same \
18212 as_str dispatch as the explicit From impl"
18213 );
18214 }
18215 }
18216
18217 #[test]
18218 fn dep_list_from_into_owned_string_and_static_str_agree_on_every_arm() {
18219 // Cross-axis partition pin: the paired trait-idiomatic
18220 // owned-`String` `From<DepList> for String` (this lift) and
18221 // owned-`&'static str` `From<DepList> for &'static str`
18222 // (523157d campaign-shape) forward projections must resolve
18223 // identically on every arm, locking the two return-type-shape
18224 // paths together so any future detour trips at caixa-core test
18225 // time. Also byte-parity witness against the sibling
18226 // [`ToString::to_string`] surface routed through
18227 // [`std::fmt::Display`] — the three owned-heap-string paths
18228 // (`.into::<String>()`, `String::from`, `.to_string()`) must
18229 // resolve identically on every arm so a future consumer that
18230 // picks any of the three lands on the same two-arm lifted
18231 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18232 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] accept-set.
18233 // Then a `.iter().copied().map(String::from)` pipe witness
18234 // over [`super::DepList::ALL`] that materializes the two-arm
18235 // accept-set through the owned-`String` axis alone — the exact
18236 // shape a future M4 admission-webhook rejection body composer
18237 // or a
18238 // `HashMap::<String, DepList>::from_iter(
18239 // DepList::ALL.iter().copied().map(|l| (l.into(), l)))`-
18240 // style owned-key per-list lookup reaches through — closing the
18241 // owned-`String` forward-projection axis's iterator-pipe shape.
18242 // Then a direct round-trip witness through the paired
18243 // trait-idiomatic reverse [`TryFrom<&str>`] axis on the
18244 // owned-`String`'s [`String::as_str`] borrow that closes the
18245 // two-way `Self → String → Self` round-trip on the trait-
18246 // idiomatic owned-`String` forward + reverse axis pair.
18247 //
18248 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18249 // `From` emit lands on the lowercase Portuguese `as_str`
18250 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18251 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18252 // forcing the round-trip through an intermediate
18253 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18254 // [`super::DepList::as_str`] emit and [`super::DepList::from_wire`]
18255 // parse resolve through the same lifted
18256 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18257 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18258 // construction (there is no wire/diagnostic axis split on this
18259 // enum), so the owned-`String` forward axis and the reverse
18260 // axis compose directly — matching the peer
18261 // [`crate::supervisor::RestartStrategy`] /
18262 // [`crate::supervisor::RestartPolicy`] /
18263 // [`crate::CaixaDialeto`] owned-`String` axis pairs.
18264 for &list in super::DepList::ALL {
18265 let owned_string: String = <String as From<super::DepList>>::from(list);
18266 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18267 assert_eq!(
18268 owned_string.as_str(),
18269 owned_static,
18270 "From<DepList> for String and From<DepList> for \
18271 &'static str must resolve identically on \
18272 DepList::{list:?} — divergence signals the owned-\
18273 `String` and owned-`&'static str` forward-projection \
18274 return-type-shape paths have drifted onto different \
18275 emit-sets"
18276 );
18277 let via_to_string: String = list.to_string();
18278 assert_eq!(
18279 owned_string, via_to_string,
18280 "From<DepList> for String must byte-equal \
18281 DepList::to_string on DepList::{list:?} — divergence \
18282 signals the trait-idiomatic owned-`String` forward-\
18283 projection axis and the ToString-through-Display axis \
18284 have drifted onto different emit-sets"
18285 );
18286 }
18287 let via_iter: Vec<String> = super::DepList::ALL
18288 .iter()
18289 .copied()
18290 .map(String::from)
18291 .collect();
18292 let via_method: Vec<String> = super::DepList::ALL
18293 .iter()
18294 .map(|l| l.as_str().to_owned())
18295 .collect();
18296 assert_eq!(
18297 via_iter, via_method,
18298 "`.iter().copied().map(String::from)` over DepList::ALL must \
18299 byte-equal `.iter().map(|l| l.as_str().to_owned())` on \
18300 every arm — the owned-`String` `From<DepList> for String` \
18301 axis is what makes the `String::from` composition route \
18302 through the substrate-primitive `DepList::as_str` accessor \
18303 rather than through a per-call-site `.to_owned()` / \
18304 `String::from(list.as_str())` detour"
18305 );
18306 for &variant in super::DepList::ALL {
18307 let emitted: String = variant.into();
18308 let re_parsed: Result<super::DepList, ()> =
18309 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18310 assert_eq!(
18311 re_parsed,
18312 Ok(variant),
18313 "trait-idiomatic owned-`String` forward-projection + \
18314 reverse-projection axis pair must round-trip \
18315 DepList::{variant:?} through `.into::<String>()` and \
18316 back through `TryFrom<&str>` on the owned-`String`'s \
18317 String::as_str borrow — a break signals the owned-\
18318 `String` forward-emit and reverse-parse axes have \
18319 drifted onto different vocabularies (unlike the peer \
18320 CaixaKind axis pair, DepList's forward emit and \
18321 reverse parse share the same lifted \
18322 DEP_AUTHOR_KEY_DEPS* consts by construction, so the \
18323 round-trip composes directly)"
18324 );
18325 }
18326 }
18327
18328 #[test]
18329 fn dep_list_from_into_borrowed_owned_string_routes_through_as_str_accessor() {
18330 // Fail-before-pass-after byte-parity pin on the newly lifted
18331 // `impl From<&DepList> for String` — asserts the borrowed-input
18332 // owned-`String`-returning standard-library trait impl and the
18333 // substrate-primitive [`super::DepList::as_str`] `pub const fn`
18334 // accessor resolve to the same two-arm emit-set across every
18335 // arm the exhaustive [`super::DepList::ALL`] slice enumerates.
18336 // Rust's standard library does not carry a blanket
18337 // `impl<T: AsRef<str>> From<&T> for String` (nor an
18338 // `impl<T: fmt::Display> From<&T> for String`), so the
18339 // borrowed-input owned-`String` forward-projection axis is a
18340 // distinct trait-idiomatic surface that a
18341 // `let key: String = (&list).into();`-shaped call site reaches
18342 // through this impl and no other — the paired sibling
18343 // `From<DepList> for String` impl forces every borrowed-input
18344 // call site through an explicit `Copy` deref
18345 // (`String::from(*list)`) or an `.as_str().to_owned()` /
18346 // `.to_string()` detour. Peer of the first-mover
18347 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18348 // (579385f) and the second-peer
18349 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_routes_through_as_str_accessor`]
18350 // (8465740) — extends the trait-idiomatic borrowed-input owned-
18351 // `String` forward-projection axis off the M2 OTP-shape sibling
18352 // axis pair onto the first non-M2 closed-set fieldless typed
18353 // enum peer (the two-list dep-graph axis).
18354 for &variant in super::DepList::ALL {
18355 let via_trait: String = <String as From<&super::DepList>>::from(&variant);
18356 let via_method: &'static str = variant.as_str();
18357 assert_eq!(
18358 via_trait.as_str(),
18359 via_method,
18360 "From<&DepList> for String impl must round-trip \
18361 &DepList::{variant:?} to the same lifted \
18362 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18363 DepList::as_str returns — divergence signals a silent \
18364 detour off the substrate-primitive accessor"
18365 );
18366 let via_into: String = (&variant).into();
18367 assert_eq!(
18368 via_into.as_str(),
18369 via_method,
18370 "Into<String>::into on &DepList::{variant:?} must \
18371 byte-equal DepList::as_str on the same input — the \
18372 blanket-derived Into shape must resolve to the same \
18373 as_str dispatch as the explicit From impl"
18374 );
18375 }
18376 }
18377
18378 #[test]
18379 fn dep_list_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm() {
18380 // Cross-axis partition pin: the newly lifted trait-idiomatic
18381 // borrowed-input owned-`String` `From<&DepList> for String`
18382 // (this lift), the paired owned-input owned-`String`
18383 // `From<DepList> for String` (32b0ee8), the paired borrowed-
18384 // input owned-`&'static str` `From<&DepList> for &'static str`
18385 // (64aa742), and the paired owned-input owned-`&'static str`
18386 // `From<DepList> for &'static str` (3455cbf) — every corner of
18387 // the `{Self, &Self} × {&'static str, String}` 2×2 trait-
18388 // idiomatic projection family — must resolve identically on
18389 // every arm, locking the four return-shape × input-shape paths
18390 // together so any future detour trips at caixa-core test time.
18391 // Also byte-parity witness against the sibling
18392 // [`ToString::to_string`] surface routed through
18393 // [`std::fmt::Display`] and a direct round-trip witness through
18394 // the paired trait-idiomatic reverse [`TryFrom<&str>`] axis on
18395 // the owned-`String`'s [`String::as_str`] borrow that closes
18396 // the two-way `&Self → String → Self` round-trip on the trait-
18397 // idiomatic borrowed-input owned-`String` forward + reverse
18398 // axis pair. Peer of the first-mover
18399 // [`crate::supervisor::tests::restart_strategy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18400 // (579385f) and the second-peer
18401 // [`crate::supervisor::tests::restart_policy_from_into_borrowed_owned_string_agrees_with_paired_axes_on_every_arm`]
18402 // (8465740) — closes the whole `{Self, &Self} × {&'static str,
18403 // String}` 2×2 projection corner on the third substrate-wide
18404 // closed-set fieldless typed enum peer (the two-list dep-graph
18405 // axis, first outside the M2 OTP-shape sibling pair).
18406 //
18407 // Unlike the peer [`crate::CaixaKind`] axis pair (whose forward
18408 // `From` emit lands on the lowercase Portuguese `as_str`
18409 // diagnostic vocabulary while the reverse `TryFrom<&str>`
18410 // parses the `PascalCase` `wire_name` author-surface vocabulary,
18411 // forcing the round-trip through an intermediate
18412 // [`crate::CaixaKind::wire_name`] hop), [`super::DepList`]'s
18413 // [`super::DepList::as_str`] emit and
18414 // [`super::DepList::from_wire`] parse resolve through the same
18415 // lifted [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18416 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] consts by
18417 // construction (there is no wire/diagnostic axis split on this
18418 // enum), so the borrowed-input owned-`String` forward axis and
18419 // the reverse axis compose directly — matching the peer
18420 // [`crate::supervisor::RestartStrategy`] /
18421 // [`crate::supervisor::RestartPolicy`] borrowed-input owned-
18422 // `String` axis pairs.
18423 for &list in super::DepList::ALL {
18424 let borrowed_string: String = <String as From<&super::DepList>>::from(&list);
18425 let owned_string: String = <String as From<super::DepList>>::from(list);
18426 let borrowed_static: &'static str =
18427 <&'static str as From<&super::DepList>>::from(&list);
18428 let owned_static: &'static str = <&'static str as From<super::DepList>>::from(list);
18429 assert_eq!(
18430 borrowed_string, owned_string,
18431 "From<&DepList> for String and From<DepList> for String \
18432 must resolve identically on DepList::{list:?} — \
18433 divergence signals the borrowed-input and owned-input \
18434 owned-`String` forward-projection input-shape paths \
18435 have drifted onto different emit-sets"
18436 );
18437 assert_eq!(
18438 borrowed_string.as_str(),
18439 borrowed_static,
18440 "From<&DepList> for String and From<&DepList> for \
18441 &'static str must resolve identically on \
18442 DepList::{list:?} — divergence signals the borrowed-\
18443 input `&'static str` and owned-`String` return-shape \
18444 paths have drifted onto different emit-sets"
18445 );
18446 assert_eq!(
18447 borrowed_string.as_str(),
18448 owned_static,
18449 "From<&DepList> for String and From<DepList> for \
18450 &'static str must resolve identically on \
18451 DepList::{list:?} — divergence signals a break in the \
18452 diagonal corner of the {{Self, &Self}} × {{&'static \
18453 str, String}} 2×2 trait-idiomatic projection family"
18454 );
18455 let via_to_string: String = list.to_string();
18456 assert_eq!(
18457 borrowed_string, via_to_string,
18458 "From<&DepList> for String must byte-equal \
18459 DepList::to_string on DepList::{list:?} — divergence \
18460 signals the trait-idiomatic borrowed-input owned-\
18461 `String` forward-projection axis and the ToString-\
18462 through-Display axis have drifted onto different \
18463 emit-sets"
18464 );
18465 }
18466 let via_iter: Vec<String> = super::DepList::ALL.iter().map(String::from).collect();
18467 let via_method: Vec<String> = super::DepList::ALL
18468 .iter()
18469 .map(|l| l.as_str().to_owned())
18470 .collect();
18471 assert_eq!(
18472 via_iter, via_method,
18473 "`.iter().map(String::from)` over DepList::ALL — a call \
18474 site whose iteration axis holds `&DepList` by construction \
18475 — must byte-equal `.iter().map(|l| l.as_str().to_owned())` \
18476 on every arm — the borrowed-input owned-`String` \
18477 `From<&DepList> for String` axis is what makes the \
18478 `String::from` composition route through the substrate-\
18479 primitive `DepList::as_str` accessor without a spurious \
18480 `Copy` deref (which would only be reachable through the \
18481 owned-input `From<DepList> for String` axis by first \
18482 calling `.copied()` on the iterator)"
18483 );
18484 for &variant in super::DepList::ALL {
18485 let emitted: String = (&variant).into();
18486 let re_parsed: Result<super::DepList, ()> =
18487 <super::DepList as TryFrom<&str>>::try_from(emitted.as_str());
18488 assert_eq!(
18489 re_parsed,
18490 Ok(variant),
18491 "trait-idiomatic borrowed-input owned-`String` \
18492 forward-projection + reverse-projection axis pair must \
18493 round-trip &DepList::{variant:?} through \
18494 `.into::<String>()` on the borrowed-input surface and \
18495 back through `TryFrom<&str>` on the owned-`String`'s \
18496 String::as_str borrow — a break signals the \
18497 borrowed-input owned-`String` forward-emit and \
18498 reverse-parse axes have drifted onto different \
18499 vocabularies (unlike the peer CaixaKind axis pair, \
18500 DepList's forward emit and reverse parse share the \
18501 same lifted DEP_AUTHOR_KEY_DEPS* consts by \
18502 construction, so the round-trip composes directly)"
18503 );
18504 }
18505 }
18506
18507 #[test]
18508 fn dep_list_from_into_static_cow_str_routes_through_as_str_accessor() {
18509 // Fail-before-pass-after byte-parity pin on the newly lifted
18510 // `impl From<DepList> for std::borrow::Cow<'static, str>` —
18511 // asserts the standard-library trait impl and the substrate-
18512 // primitive [`super::DepList::as_str`] `pub const fn`
18513 // accessor resolve to the same two-arm emit-set across every
18514 // arm the exhaustive [`super::DepList::ALL`] slice
18515 // enumerates. Rust's standard library does not carry a
18516 // blanket `impl<T: AsRef<str>> From<T> for Cow<'static, str>`
18517 // (nor an `impl<T: fmt::Display> From<T> for
18518 // Cow<'static, str>`), so the `Cow<'static, str>` forward-
18519 // projection axis is a distinct trait-idiomatic surface that
18520 // a `let key: Cow<'static, str> = list.into();`-shaped call
18521 // site reaches through this impl and no other — the paired
18522 // sibling `From<DepList> for &'static str` and
18523 // `From<DepList> for String` impls force every
18524 // `Cow<'static, str>`-parameterized call site through a
18525 // `Cow::Borrowed(list.as_str())` /
18526 // `Cow::Owned(list.to_string())` composition whose type
18527 // bounds have no compile-time link back to the substrate
18528 // primitive.
18529 //
18530 // Also asserts the projection lands on the zero-alloc
18531 // [`std::borrow::Cow::Borrowed`] arm (not the
18532 // [`std::borrow::Cow::Owned`] arm) — the substrate-primitive
18533 // [`super::DepList::as_str`] accessor's `&'static str`
18534 // return lifetime by construction (each match arm resolves
18535 // to one of the two lifted
18536 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18537 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] `pub const
18538 // &str` values) makes the borrowed arm the type-correct
18539 // projection with no runtime allocation. Any future silent
18540 // detour that routes the impl through the owned arm trips
18541 // at caixa-core test time under the
18542 // [`std::borrow::Cow::Borrowed`] discriminator witness
18543 // rather than at a downstream `Cow<'static, str>`-bound
18544 // consumer's silent allocation.
18545 //
18546 // First-mover on the outside-M3 substrate-wide tier of the
18547 // substrate-wide trait-idiomatic
18548 // [`std::borrow::Cow<'static, str>`] forward-projection
18549 // campaign — extends the axis off the paired
18550 // [`crate::CaixaKind`] top-level opener (99c1735 + d45c409),
18551 // the paired M2 OTP-shape
18552 // [`crate::supervisor::RestartStrategy`] (7dd28b3 + 9b3e4b3)
18553 // and [`crate::supervisor::RestartPolicy`] (0612398 +
18554 // ee577fd), and the paired M3-mesh-shape
18555 // [`crate::aplicacao::WitShape`] (8634dec + 25690ef),
18556 // [`crate::aplicacao::PlacementStrategy`] (eee504d +
18557 // afdf0f4), and [`crate::aplicacao::RateLimitUnit`] (1d59925)
18558 // peers onto the first outside-M3 caixa-core peer (the two-
18559 // list dep-graph axis), opening the outside-M3 caixa-core
18560 // tier of the substrate-wide Cow<'static, str> forward-
18561 // projection campaign's owned-input corner.
18562 for &variant in super::DepList::ALL {
18563 let via_trait: std::borrow::Cow<'static, str> =
18564 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18565 let via_method: &'static str = variant.as_str();
18566 assert_eq!(
18567 via_trait.as_ref(),
18568 via_method,
18569 "From<DepList> for Cow<'static, str> impl must \
18570 round-trip DepList::{variant:?} to the same lifted \
18571 crate::render::DEP_AUTHOR_KEY_DEPS* const \
18572 DepList::as_str returns — divergence signals a \
18573 silent detour off the substrate-primitive accessor"
18574 );
18575 assert!(
18576 matches!(via_trait, std::borrow::Cow::Borrowed(_)),
18577 "From<DepList> for Cow<'static, str> impl must land \
18578 on the zero-alloc Cow::Borrowed arm on \
18579 DepList::{variant:?} — a Cow::Owned outcome signals \
18580 the projection has silently allocated where the \
18581 substrate-primitive DepList::as_str `&'static str` \
18582 return makes the borrowed arm the type-correct \
18583 projection"
18584 );
18585 let via_into: std::borrow::Cow<'static, str> = variant.into();
18586 assert_eq!(
18587 via_into.as_ref(),
18588 via_method,
18589 "Into<Cow<'static, str>>::into on DepList::\
18590 {variant:?} must byte-equal DepList::as_str on the \
18591 same input — the blanket-derived Into shape must \
18592 resolve to the same as_str dispatch as the explicit \
18593 From impl"
18594 );
18595 assert!(
18596 matches!(via_into, std::borrow::Cow::Borrowed(_)),
18597 "Into<Cow<'static, str>>::into on DepList::\
18598 {variant:?} must land on the zero-alloc \
18599 Cow::Borrowed arm — the blanket-derived Into shape \
18600 must resolve to the same Cow::Borrowed dispatch as \
18601 the explicit From impl"
18602 );
18603 }
18604 }
18605
18606 #[test]
18607 fn dep_list_from_into_static_cow_str_agrees_with_paired_axes_on_every_arm() {
18608 // Cross-axis partition pin: the newly lifted trait-idiomatic
18609 // `From<DepList> for std::borrow::Cow<'static, str>` (this
18610 // lift), the paired owned-input `From<DepList> for
18611 // &'static str` (3455cbf), and the paired owned-input
18612 // `From<DepList> for String` (32b0ee8) forward projections
18613 // must resolve identically on every arm, locking the three
18614 // return-shape paths together by construction so any future
18615 // detour trips at caixa-core test time. Also byte-parity
18616 // witness against the sibling [`ToString::to_string`]
18617 // surface routed through [`std::fmt::Display`] — every
18618 // owned-heap-string path (the `Cow::Owned` promotion of
18619 // this axis's `.into_owned()`, `From<DepList> for String`,
18620 // and `.to_string()`) resolves to the same two-arm lifted
18621 // [`crate::render::DEP_AUTHOR_KEY_DEPS`] /
18622 // [`crate::render::DEP_AUTHOR_KEY_DEPS_DEV`] byte-string per
18623 // arm.
18624 //
18625 // Then a `.iter().copied().map(std::borrow::Cow::from)` pipe
18626 // witness over [`super::DepList::ALL`] that materializes the
18627 // two-arm accept-set through the
18628 // [`std::borrow::Cow<'static, str>`] axis alone — the exact
18629 // shape a future M4 admission-webhook rejection body's
18630 // accepted-`:deps` / `:deps-dev` list-key enumeration, a
18631 // future substrate-wide per-arm diagnostic surface whose
18632 // typing rules out the sibling [`AsRef<str>`] borrowed
18633 // return, or a future per-arm dep-list emitter that binds
18634 // through a [`std::borrow::Cow<'static, str>`] boundary
18635 // reaches through — opening the composable-projection axis
18636 // on the first outside-M3 caixa-core closed-set fieldless
18637 // typed enum peer on the caixa surface. The pipe witness
18638 // also pins the zero-alloc discipline: every element in the
18639 // collected vector satisfies the
18640 // [`std::borrow::Cow::Borrowed`] arm predicate, so a future
18641 // accidental silent-allocation regression on the pipe's
18642 // iteration axis is a caixa-core-test-time failure.
18643 for &variant in super::DepList::ALL {
18644 let via_cow: std::borrow::Cow<'static, str> =
18645 <std::borrow::Cow<'static, str> as From<super::DepList>>::from(variant);
18646 let via_static: &'static str = <&'static str as From<super::DepList>>::from(variant);
18647 let via_string: String = <String as From<super::DepList>>::from(variant);
18648 assert_eq!(
18649 via_cow.as_ref(),
18650 via_static,
18651 "From<DepList> for Cow<'static, str> and \
18652 From<DepList> for &'static str must resolve \
18653 identically on DepList::{variant:?} — divergence \
18654 signals the Cow<'static, str> and &'static str \
18655 return-shape paths have drifted onto different \
18656 emit-sets"
18657 );
18658 assert_eq!(
18659 via_cow.as_ref(),
18660 via_string.as_str(),
18661 "From<DepList> for Cow<'static, str> and \
18662 From<DepList> for String must resolve identically \
18663 on DepList::{variant:?} — divergence signals the \
18664 Cow<'static, str> and String return-shape paths \
18665 have drifted onto different emit-sets"
18666 );
18667 let via_to_string: String = variant.to_string();
18668 assert_eq!(
18669 via_cow.as_ref(),
18670 via_to_string.as_str(),
18671 "From<DepList> for Cow<'static, str> must byte-equal \
18672 DepList::to_string on DepList::{variant:?} — \
18673 divergence signals the trait-idiomatic \
18674 Cow<'static, str> forward-projection axis and the \
18675 ToString-through-Display axis have drifted onto \
18676 different emit-sets"
18677 );
18678 }
18679 let via_iter: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18680 .iter()
18681 .copied()
18682 .map(std::borrow::Cow::from)
18683 .collect();
18684 let via_method: Vec<std::borrow::Cow<'static, str>> = super::DepList::ALL
18685 .iter()
18686 .map(|l| std::borrow::Cow::Borrowed(l.as_str()))
18687 .collect();
18688 assert_eq!(
18689 via_iter, via_method,
18690 "`.iter().copied().map(Cow::from)` over DepList::ALL \
18691 must byte-equal `.iter().map(|l| \
18692 Cow::Borrowed(l.as_str()))` on every arm — the trait-\
18693 idiomatic `From<DepList> for Cow<'static, str>` axis is \
18694 what makes the `Cow::from` composition route through \
18695 the substrate-primitive `DepList::as_str` accessor with \
18696 the zero-alloc Cow::Borrowed arm by construction, \
18697 rather than a per-call-site `Cow::Owned(list.to_string())` \
18698 allocation"
18699 );
18700 for cow in &via_iter {
18701 assert!(
18702 matches!(cow, std::borrow::Cow::Borrowed(_)),
18703 "every element of the .iter().copied().map(Cow::from) \
18704 pipe over DepList::ALL must land on the zero-alloc \
18705 Cow::Borrowed arm — a Cow::Owned outcome on any arm \
18706 signals the pipe's iteration axis has silently \
18707 allocated where the substrate-primitive \
18708 DepList::as_str `&'static str` return makes the \
18709 borrowed arm the type-correct projection"
18710 );
18711 }
18712 }
18713}
18714
18715#[cfg(test)]
18716mod dep_source_is_variant_tests {
18717 use super::*;
18718
18719 fn all_variants() -> Vec<(DepSource, &'static str)> {
18720 vec![
18721 (
18722 DepSource::Git {
18723 repo: "github:pleme-io/caixa-teia".into(),
18724 tag: Some("v0.1.0".into()),
18725 rev: None,
18726 branch: None,
18727 },
18728 "Git",
18729 ),
18730 (
18731 DepSource::Path {
18732 caminho: "../caixa-teia".into(),
18733 },
18734 "Path",
18735 ),
18736 ]
18737 }
18738
18739 fn predicate_row(s: &DepSource) -> [bool; 2] {
18740 [s.is_git(), s.is_path()]
18741 }
18742
18743 // Fail-before-pass-after pin on the [`gen_platform::IsVariant`]
18744 // derive-generated per-arm predicate partition — for every variant
18745 // in `all_variants()`, the observed 2-slot predicate row must equal
18746 // a one-hot row with the `true` at exactly the same index as the
18747 // variant's declaration order. Expected rows are generated live
18748 // from the enumeration rather than transcribed by hand, so a
18749 // copy-paste flip that reroutes one arm through the wrong predicate
18750 // lane trips at the identity-diagonal assertion the way every peer
18751 // sibling [`DepList`] / [`crate::CaixaKind`] / [`crate::CaixaDialeto`]
18752 // / [`crate::supervisor::RestartStrategy`] / [`crate::supervisor::RestartPolicy`]
18753 // / [`crate::upgrade::UpgradeInstruction`] /
18754 // [`crate::aplicacao::PlacementStrategy`] /
18755 // [`crate::aplicacao::RateLimitUnit`] /
18756 // [`crate::aplicacao::WitTarget`] /
18757 // [`crate::render::PathShapeViolation`] partition pin already does.
18758 #[test]
18759 fn dep_source_is_variant_predicates_partition_the_arm_set() {
18760 let variants = all_variants();
18761 for (idx, (variant, name)) in variants.iter().enumerate() {
18762 let observed = predicate_row(variant);
18763 let mut expected = [false; 2];
18764 expected[idx] = true;
18765 assert_eq!(
18766 observed, expected,
18767 "DepSource::{name} at declaration-order slot {idx} must \
18768 satisfy exactly one is_* predicate (its own); observed \
18769 row must equal the one-hot expected row — a drift \
18770 would silently reroute one `:fonte`-arm consumer \
18771 through the wrong predicate lane"
18772 );
18773 }
18774 }
18775
18776 // Byte-parity pin on the two field-agnostic `matches!` shapes the
18777 // per-arm arm-discriminator predicates replace at any future
18778 // consumer site (a `:fonte`-shape-only lint rule that flags path
18779 // deps outside dev-caixas via `dep.fonte().is_some_and(DepSource::is_path)`,
18780 // a future admission-webhook that rejects `:fonte` shapes outside
18781 // the `is_git()` accept-set, a caixa-lacre indexing pass that
18782 // dispatches on `s.is_git()` without extracting `repo` / `caminho`).
18783 // Refuses a future accidental split between the derived predicate
18784 // and its `matches!` shape — a hand-rolled shadow impl that
18785 // overrides one path, an accidental rebrand that leaves one
18786 // consumer on the raw `matches!` form — on the two load-bearing
18787 // `:fonte`-arm-discriminator axes every downstream substrate
18788 // consumer of the dep-source axis keys off.
18789 #[test]
18790 fn dep_source_is_git_and_is_path_byte_equal_matches_shape() {
18791 for (variant, name) in all_variants() {
18792 let via_matches_git = matches!(variant, DepSource::Git { .. });
18793 let via_predicate_git = variant.is_git();
18794 assert_eq!(
18795 via_predicate_git, via_matches_git,
18796 "DepSource::{name}.is_git() must byte-equal \
18797 matches!(_, DepSource::Git {{ .. }}) — otherwise a \
18798 future converged consumer site would silently \
18799 disagree with its pre-lift shape"
18800 );
18801 let via_matches_path = matches!(variant, DepSource::Path { .. });
18802 let via_predicate_path = variant.is_path();
18803 assert_eq!(
18804 via_predicate_path, via_matches_path,
18805 "DepSource::{name}.is_path() must byte-equal \
18806 matches!(_, DepSource::Path {{ .. }}) — otherwise a \
18807 future converged consumer site would silently \
18808 disagree with its pre-lift shape"
18809 );
18810 }
18811 }
18812
18813 // Cross-pin against every constructor path that materializes a
18814 // [`DepSource`] shape today (the [`DepSource::default_github`]
18815 // resolver-side fallback that materializes an unpinned
18816 // `github:<org>/<nome>` git shorthand, the [`Dep::git`] author-
18817 // surface constructor that materializes a pinned `:tag`-carrying
18818 // `DepSource::Git`, a hand-rolled `DepSource::Path` the dev-mode
18819 // fixture family builds inline). Every constructor's return must
18820 // satisfy the arm-discriminator predicate the constructor's
18821 // variant name matches — a future constructor addition (an
18822 // in-tree registry-fetch pin, a `DepSource::Feira` variant the
18823 // enclosing docstring already names as a trajectory item) surfaces
18824 // as a build-time failure that names the offending drift when its
18825 // return arm doesn't route through the paired predicate.
18826 #[test]
18827 fn dep_source_constructors_route_through_paired_is_variant_predicate() {
18828 let via_default_github = DepSource::default_github("pleme-io", "caixa-teia");
18829 assert!(
18830 via_default_github.is_git(),
18831 "DepSource::default_github must materialize a Git-arm shape — \
18832 a future constructor that routed through a non-Git arm \
18833 (a registry-fetch pin, a `DepSource::Feira` promotion) \
18834 would silently split the resolver's unpinned-shorthand \
18835 materializer from the sole_pin() precedence cascade"
18836 );
18837 assert!(
18838 !via_default_github.is_path(),
18839 "DepSource::default_github must NOT materialize a Path-arm \
18840 shape — the paired negation pin"
18841 );
18842
18843 let via_dep_git = Dep::git("caixa-teia", "^0.1", "github:pleme-io/caixa-teia", "v0.1.0")
18844 .fonte
18845 .expect("Dep::git materializes a Some(fonte)");
18846 assert!(
18847 via_dep_git.is_git(),
18848 "Dep::git's `:fonte` materialization must land on the Git \
18849 arm — the author-surface pinned-git constructor's return \
18850 must route through the paired predicate"
18851 );
18852 assert!(!via_dep_git.is_path(), "paired negation pin");
18853
18854 let via_path = DepSource::Path {
18855 caminho: "../caixa-teia".into(),
18856 };
18857 assert!(
18858 via_path.is_path(),
18859 "the dev-mode Path-arm materialization must satisfy is_path()"
18860 );
18861 assert!(!via_path.is_git(), "paired negation pin");
18862 }
18863
18864 // ── `dep_nome_axis_reason_ctors!` — the `{ nome: String, <axis>:
18865 // String, reason: String }` three-slot envelope on `DepError`,
18866 // strict sibling of the peer `dep_nome_only_ctors!` (792aa92) on
18867 // the one-slot `{ nome }` envelope, `dep_nome_list_ctors!`
18868 // (6f5e0cd) on the two-slot `{ nome, list: &'static str }`
18869 // envelope, `fonte_caminho_ctors!` (f85f145) on the two-slot
18870 // `{ nome, caminho }` envelope, and `fonte_caminho_byte_ctors!`
18871 // (0e35793) on the three-slot `{ nome, caminho, byte }` envelope.
18872
18873 #[test]
18874 fn versao_invalid_ctor_matches_struct_literal_wrap() {
18875 assert_eq!(
18876 DepError::versao_invalid("caixa-teia", "^0..1", "invalid comparator".to_string()),
18877 DepError::VersaoInvalid {
18878 nome: "caixa-teia".to_string(),
18879 versao: "^0..1".to_string(),
18880 reason: "invalid comparator".to_string(),
18881 },
18882 "versao_invalid ctor must produce byte-equal \
18883 `DepError::VersaoInvalid` to the pre-lift struct-literal wrap",
18884 );
18885 }
18886
18887 #[test]
18888 fn fonte_repo_shape_ctor_matches_struct_literal_wrap() {
18889 assert_eq!(
18890 DepError::fonte_repo_shape(
18891 "caixa-teia",
18892 "-upload-pack=evil",
18893 "leading dash rejected".to_string(),
18894 ),
18895 DepError::FonteRepoShape {
18896 nome: "caixa-teia".to_string(),
18897 repo: "-upload-pack=evil".to_string(),
18898 reason: "leading dash rejected".to_string(),
18899 },
18900 "fonte_repo_shape ctor must produce byte-equal \
18901 `DepError::FonteRepoShape` to the pre-lift struct-literal wrap",
18902 );
18903 }
18904
18905 #[test]
18906 fn caracteristica_invalid_ctor_matches_struct_literal_wrap() {
18907 assert_eq!(
18908 DepError::caracteristica_invalid(
18909 "caixa-teia",
18910 "bad feature!",
18911 "embedded space rejected".to_string(),
18912 ),
18913 DepError::CaracteristicaInvalid {
18914 nome: "caixa-teia".to_string(),
18915 caracteristica: "bad feature!".to_string(),
18916 reason: "embedded space rejected".to_string(),
18917 },
18918 "caracteristica_invalid ctor must produce byte-equal \
18919 `DepError::CaracteristicaInvalid` to the pre-lift struct-literal wrap",
18920 );
18921 }
18922
18923 #[test]
18924 fn dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly() {
18925 // Cross-axis routing pin: sweep the three constructor input axes
18926 // (`nome: &str`, `<axis>: &str`, `reason: String`) through
18927 // distinct-per-axis fixtures against every generated arm in the
18928 // [`dep_nome_axis_reason_ctors!`] macro, so any wrapper-side
18929 // lowercase / trim / truncate on the two `&str` axes — a silent
18930 // field swap between `nome`, the middle `<axis>` field, and
18931 // `reason`, or a `reason` axis silently rerouted through
18932 // `.to_string()` instead of forwarded owned — surfaces here rather
18933 // than at a downstream diagnostic-shape mismatch. Peer of the
18934 // sibling `fonte_caminho_byte_ctors_route_nome_caminho_and_byte_
18935 // through_to_string` (0e35793) cross-axis routing pin on the same
18936 // envelope's `{ nome, caminho, byte }` three-slot family and of
18937 // the peer `dep_nome_list_ctors_route_nome_and_list_through_
18938 // uniformly` (6f5e0cd) pin on the same envelope's two-slot family
18939 // — extended here onto the `{ nome, <axis>: String, reason:
18940 // String }` three-slot envelope so every substrate-primitive ctor
18941 // family in caixa-core's `DepError` envelope guarantees each field
18942 // routes the caller's value verbatim through `.to_string()` (or
18943 // owned-forward for `reason: String`) in declared field order.
18944 // Distinct-per-axis fixtures rule out any two-axis swap
18945 // (`nome` ↔ `<axis>`, `<axis>` ↔ `reason`) that would still pass a
18946 // same-fixture-per-axis pin.
18947 let nome = "sibling-teia";
18948 let axis = "distinct-axis-value";
18949 let reason = "distinct rejection sentence".to_string();
18950 assert_eq!(
18951 DepError::versao_invalid(nome, axis, reason.clone()),
18952 DepError::VersaoInvalid {
18953 nome: nome.to_string(),
18954 versao: axis.to_string(),
18955 reason: reason.clone(),
18956 },
18957 "versao_invalid must route `nome` → `nome`, `axis` → `versao`, \
18958 `reason` → `reason` in declared field order",
18959 );
18960 assert_eq!(
18961 DepError::fonte_repo_shape(nome, axis, reason.clone()),
18962 DepError::FonteRepoShape {
18963 nome: nome.to_string(),
18964 repo: axis.to_string(),
18965 reason: reason.clone(),
18966 },
18967 "fonte_repo_shape must route `nome` → `nome`, `axis` → `repo`, \
18968 `reason` → `reason` in declared field order",
18969 );
18970 assert_eq!(
18971 DepError::caracteristica_invalid(nome, axis, reason.clone()),
18972 DepError::CaracteristicaInvalid {
18973 nome: nome.to_string(),
18974 caracteristica: axis.to_string(),
18975 reason: reason.clone(),
18976 },
18977 "caracteristica_invalid must route `nome` → `nome`, \
18978 `axis` → `caracteristica`, `reason` → `reason` in declared \
18979 field order",
18980 );
18981 }
18982
18983 // ── `dep_nome_axis_ctors!` — the `{ nome: String, <axis>: String }`
18984 // two-slot envelope on `DepError`, missing rung between
18985 // `dep_nome_only_ctors!` (792aa92) on the one-slot `{ nome }`
18986 // envelope and `dep_nome_axis_reason_ctors!` (5621f8a) on the
18987 // three-slot `{ nome, <axis>: String, reason: String }` envelope.
18988 // Sibling of `dep_nome_list_ctors!` (6f5e0cd) on the peer
18989 // two-slot `{ nome, list: &'static str }` envelope (same slot
18990 // count, `&'static str` axis instead of owned `String` axis).
18991
18992 #[test]
18993 fn fonte_pin_empty_ctor_matches_struct_literal_wrap() {
18994 assert_eq!(
18995 DepError::fonte_pin_empty("caixa-teia", ":tag"),
18996 DepError::FontePinEmpty {
18997 nome: "caixa-teia".to_string(),
18998 pin: ":tag".to_string(),
18999 },
19000 "fonte_pin_empty ctor must produce byte-equal \
19001 `DepError::FontePinEmpty` to the pre-lift struct-literal wrap \
19002 on the same `(&str, &str)` fixture",
19003 );
19004 }
19005
19006 #[test]
19007 fn fonte_pin_ambiguous_ctor_matches_struct_literal_wrap() {
19008 assert_eq!(
19009 DepError::fonte_pin_ambiguous("caixa-teia", ":tag, :rev"),
19010 DepError::FontePinAmbiguous {
19011 nome: "caixa-teia".to_string(),
19012 pins: ":tag, :rev".to_string(),
19013 },
19014 "fonte_pin_ambiguous ctor must produce byte-equal \
19015 `DepError::FontePinAmbiguous` to the pre-lift struct-literal \
19016 wrap on the same `(&str, &str)` fixture",
19017 );
19018 }
19019
19020 #[test]
19021 fn caracteristica_duplicate_ctor_matches_struct_literal_wrap() {
19022 assert_eq!(
19023 DepError::caracteristica_duplicate("caixa-teia", "http"),
19024 DepError::CaracteristicaDuplicate {
19025 nome: "caixa-teia".to_string(),
19026 caracteristica: "http".to_string(),
19027 },
19028 "caracteristica_duplicate ctor must produce byte-equal \
19029 `DepError::CaracteristicaDuplicate` to the pre-lift \
19030 struct-literal wrap on the same `(&str, &str)` fixture",
19031 );
19032 }
19033
19034 #[test]
19035 fn fonte_pin_ambiguous_ctor_matches_owned_string_join_shape() {
19036 // Owned-`String` routing pin: thread the real
19037 // `set.join(", ")` `String` carrier through the ctor's
19038 // `&str`-parameter Deref coercion, so the ambiguity-arm
19039 // wire-up site's actual `&set.join(", ")` shape stays
19040 // byte-equal to a direct `":tag, :rev"` literal. A future
19041 // parameter-shape change silently dropping the Deref
19042 // coercion route (e.g., a switch to `impl Into<String>`)
19043 // surfaces here rather than at the wire-up's compile
19044 // error far from the ctor definition.
19045 let set: Vec<&'static str> = vec![":tag", ":rev"];
19046 let joined: String = set.join(", ");
19047 assert_eq!(
19048 DepError::fonte_pin_ambiguous("caixa-teia", &joined),
19049 DepError::FontePinAmbiguous {
19050 nome: "caixa-teia".to_string(),
19051 pins: ":tag, :rev".to_string(),
19052 },
19053 "fonte_pin_ambiguous ctor must accept an owned-`String` \
19054 `&set.join(\", \")` carrier via Deref coercion — the exact \
19055 shape the ambiguity-arm wire-up site passes into it",
19056 );
19057 }
19058
19059 #[test]
19060 fn dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly() {
19061 // Cross-axis routing pin: sweep the two constructor input axes
19062 // (`nome: &str`, `<axis>: &str`) through distinct-per-axis
19063 // fixtures against every generated arm in the
19064 // [`dep_nome_axis_ctors!`] macro, so any wrapper-side lowercase /
19065 // trim / truncate at codegen time — a silent field swap between
19066 // `nome` and the middle `<axis>` field, or a `<axis>` axis
19067 // silently rerouted through the wrong field on any one variant
19068 // — surfaces here rather than at a downstream diagnostic-shape
19069 // mismatch. Peer of the sibling
19070 // `dep_nome_list_ctors_route_nome_and_list_through_uniformly`
19071 // (6f5e0cd) pin on the same envelope's peer two-slot family
19072 // (`{ nome, list: &'static str }`) and of the sibling
19073 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19074 // (5621f8a) pin on the same envelope's three-slot `{ nome,
19075 // <axis>: String, reason: String }` family — extended here onto
19076 // the `{ nome, <axis>: String }` two-slot envelope so the last
19077 // per-`DepError`-two-slot-owned-axis rung on the ctor-family
19078 // ladder guarantees each field routes the caller's value
19079 // verbatim through `.to_string()` in declared field order.
19080 // Distinct-per-axis fixtures rule out any two-axis swap
19081 // (`nome` ↔ `<axis>`) that would still pass a same-fixture-
19082 // per-axis pin.
19083 let nome = "sibling-teia";
19084 let axis = "distinct-axis-value";
19085 assert_eq!(
19086 DepError::fonte_pin_empty(nome, axis),
19087 DepError::FontePinEmpty {
19088 nome: nome.to_string(),
19089 pin: axis.to_string(),
19090 },
19091 "fonte_pin_empty must route `nome` → `nome`, `axis` → `pin` \
19092 in declared field order",
19093 );
19094 assert_eq!(
19095 DepError::fonte_pin_ambiguous(nome, axis),
19096 DepError::FontePinAmbiguous {
19097 nome: nome.to_string(),
19098 pins: axis.to_string(),
19099 },
19100 "fonte_pin_ambiguous must route `nome` → `nome`, `axis` → `pins` \
19101 in declared field order",
19102 );
19103 assert_eq!(
19104 DepError::caracteristica_duplicate(nome, axis),
19105 DepError::CaracteristicaDuplicate {
19106 nome: nome.to_string(),
19107 caracteristica: axis.to_string(),
19108 },
19109 "caracteristica_duplicate must route `nome` → `nome`, \
19110 `axis` → `caracteristica` in declared field order",
19111 );
19112 }
19113
19114 #[test]
19115 fn nome_invalid_ctor_matches_struct_literal_wrap() {
19116 // Equivalence pin: the ctor produces byte-equal
19117 // `DepError::NomeInvalid` to the pre-lift open-coded struct-
19118 // literal that cloned the offending `:deps :nome` verbatim and
19119 // forwarded the [`crate::render::is_dns_1123_label`]-shaped
19120 // owned `reason` payload at the caller site inside
19121 // [`Dep::validate`]. Guards any future field-addition /
19122 // reordering / accessor-return tweak on the variant. Sibling of
19123 // the peer four-slot `fonte_pin_shape` ctor equivalence pins
19124 // (below) and the sibling three-slot
19125 // `dep_nome_axis_reason_ctors_route_nome_axis_and_reason_through_uniformly`
19126 // pin on the same envelope's three-slot `{ nome, <axis>: String,
19127 // reason: String }` family.
19128 let nome = "Caixa-Teia";
19129 let reason = crate::render::is_dns_1123_label(nome).unwrap_err();
19130 let via_ctor = DepError::nome_invalid(nome, reason.clone());
19131 let via_literal = DepError::NomeInvalid {
19132 nome: nome.to_string(),
19133 reason,
19134 };
19135 assert_eq!(
19136 via_ctor, via_literal,
19137 "nome_invalid(nome, reason) must byte-equal the open-coded \
19138 NomeInvalid struct-literal on the same `(nome, reason)` fixture"
19139 );
19140 assert_eq!(
19141 via_ctor.to_string(),
19142 via_literal.to_string(),
19143 "Display byte-string must byte-equal the open-coded struct-literal"
19144 );
19145 }
19146
19147 #[test]
19148 fn nome_invalid_ctor_routes_nome_and_reason_through_to_string_uniformly() {
19149 // Boundary-sweep pin on the ctor's two-slot projection: sweep
19150 // the two ctor input axes (`nome: &str`, `reason: String`)
19151 // through distinct-per-axis fixtures against a representative
19152 // set of DNS-1123-refused `:deps :nome` byte-strings, so any
19153 // wrapper-side silent lowercase / trim / truncate at codegen
19154 // time — a silent field swap between `nome` and `reason`, an
19155 // accidental `nome`-side `.to_lowercase()` shim, or a `.into()`
19156 // divergence on the `reason` axis — surfaces at caixa-core
19157 // build time rather than at a downstream diagnostic consumer
19158 // that reads `err.nome` / `err.reason` back and gets a different
19159 // value than the one it stored. Peer of the sibling
19160 // `dep_nome_axis_ctors_route_nome_and_axis_through_to_string_uniformly`
19161 // (7f7c950) pin on the same envelope's peer two-slot family
19162 // (`{ nome, <axis>: String }`) — extended here onto the
19163 // `{ nome, reason: String }` two-slot rung the sole `NomeInvalid`
19164 // variant carries. Distinct-per-axis fixtures rule out any
19165 // two-axis swap (`nome` ↔ `reason`) that would still pass a
19166 // same-fixture-per-axis pin. The sweep list carries a mixed
19167 // DNS-1123-refused set (uppercase-carrying, underscore-carrying,
19168 // dot-carrying, leading-hyphen, trailing-hyphen, slash-carrying,
19169 // over-63-byte) so a future silent per-input normalization
19170 // surfaces on the arm that diverges.
19171 for nome in [
19172 "Caixa-Teia",
19173 "caixa_teia",
19174 "caixa.teia",
19175 "-caixa-teia",
19176 "caixa-teia-",
19177 "caixa/teia",
19178 &"a".repeat(64),
19179 ] {
19180 let reason = crate::render::is_dns_1123_label(nome)
19181 .expect_err("fixture must be a DNS-1123-refused label");
19182 let via_ctor = DepError::nome_invalid(nome, reason.clone());
19183 let DepError::NomeInvalid {
19184 nome: stored_nome,
19185 reason: stored_reason,
19186 } = via_ctor
19187 else {
19188 panic!("nome_invalid must construct NomeInvalid for {nome:?}");
19189 };
19190 assert_eq!(
19191 stored_nome, nome,
19192 "nome slot must round-trip verbatim through `.to_string()` for {nome:?}"
19193 );
19194 assert_eq!(
19195 stored_reason, reason,
19196 "reason slot must forward the owned `String` verbatim for {nome:?}"
19197 );
19198 }
19199 }
19200
19201 #[test]
19202 fn validate_nome_invalid_arm_routes_through_nome_invalid_ctor() {
19203 // End-to-end pin: the sole in-crate wire-up site
19204 // ([`Dep::validate`]'s DNS-1123 refusal arm) routes through
19205 // [`DepError::nome_invalid`] and the observed `Err` byte-equals
19206 // the ctor's output on the same DNS-1123-refused `:deps :nome`
19207 // fixture, with identical `Display` rendering. A future silent
19208 // de-lift of the wire-up back to the open-coded struct-literal
19209 // trips this test at caixa-core build time rather than at a
19210 // downstream diagnostic consumer far from the wire-up commit.
19211 // Sibling of the peer
19212 // `nome_invalid_diagnostic_carries_offending_name` pattern-match
19213 // pin on the same wire-up — extended here from a `matches!`
19214 // shape check to a byte-identity + Display parity route through
19215 // the ctor.
19216 let d = Dep::simple("Caixa_Teia", "^0.1");
19217 let observed = d.validate().unwrap_err();
19218 let reason = crate::render::is_dns_1123_label("Caixa_Teia")
19219 .expect_err("fixture must be DNS-1123-refused");
19220 let expected = DepError::nome_invalid("Caixa_Teia", reason);
19221 assert_eq!(
19222 observed, expected,
19223 "Dep::validate's DNS-1123 refusal arm must byte-equal \
19224 nome_invalid(nome, reason)"
19225 );
19226 assert_eq!(
19227 observed.to_string(),
19228 expected.to_string(),
19229 "Display byte-string parity"
19230 );
19231 }
19232}